From 620fef4291b4287621a2cd9f1236e23ab11ec227 Mon Sep 17 00:00:00 2001 From: mighty-programmer <83077551+mighty-programmer@users.noreply.github.com> Date: Thu, 8 Oct 2026 15:48:01 +0300 Subject: [PATCH 001/649] Add optional local matting and object selection models --- .github/workflows/local-models.yml | 72 + ATTRIBUTION.md | 15 + Cargo.lock | 340 +- Cargo.toml | 1 + apps/photocraft-cli/Cargo.toml | 2 +- apps/photocraft-cli/src/lib.rs | 26 +- apps/photocraft/Cargo.toml | 1 + apps/photocraft/src/main.rs | 11 +- contributors/people.toml | 3 + crates/engine/Cargo.toml | 2 + crates/engine/examples/local_models_bench.rs | 59 + crates/engine/src/commands.rs | 1 + crates/engine/src/cutout_cmds.rs | 17 +- crates/engine/src/file_cmds.rs | 7 +- crates/engine/src/jobs.rs | 3 +- crates/engine/src/lib.rs | 4 + crates/engine/src/model_cmds.rs | 502 ++ crates/engine/src/prefs.rs | 9 +- crates/engine/src/smartselect_cmds.rs | 56 +- crates/ml/Cargo.toml | 27 + crates/ml/README.md | 31 + crates/ml/licenses/BiRefNet-MIT.txt | 21 + crates/ml/licenses/ONNXRuntime-MIT.txt | 21 + .../ONNXRuntime-ThirdPartyNotices.txt | 6121 +++++++++++++++++ crates/ml/licenses/SAM2-Apache-2.0.txt | 201 + crates/ml/src/catalog.rs | 145 + crates/ml/src/image.rs | 127 + crates/ml/src/lib.rs | 68 + crates/ml/src/native.rs | 542 ++ crates/ml/src/test_models.rs | 45 + crates/ui-egui/Cargo.toml | 4 + crates/ui-egui/examples/snapshot.rs | 13 +- crates/ui-egui/src/i18n/cs.tsv | 2 + crates/ui-egui/src/i18n/de.tsv | 2 + crates/ui-egui/src/i18n/el.tsv | 2 + crates/ui-egui/src/i18n/es.tsv | 2 + crates/ui-egui/src/i18n/fr.tsv | 2 + crates/ui-egui/src/i18n/id.tsv | 2 + crates/ui-egui/src/i18n/it.tsv | 2 + crates/ui-egui/src/i18n/ja.tsv | 2 + crates/ui-egui/src/i18n/ko.tsv | 2 + crates/ui-egui/src/i18n/pt-br.tsv | 2 + crates/ui-egui/src/i18n/ru.tsv | 2 + crates/ui-egui/src/i18n/zh-hans.tsv | 2 + crates/ui-egui/src/i18n/zh-hant.tsv | 2 + crates/ui-egui/src/prefs_ui.rs | 117 +- docs/architecture.md | 2 +- docs/development.md | 4 + docs/images/LICENSE-local-models.txt | 10 + docs/images/SOURCES.md | 2 + docs/images/local-models-before.png | Bin 0 -> 123594 bytes docs/images/local-models-comparison.png | Bin 0 -> 364764 bytes docs/images/local-models-preferences.png | Bin 0 -> 190125 bytes docs/local-models-validation.md | 85 + docs/local-models.md | 135 + scorecard/automation.toml | 4 +- 56 files changed, 8849 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/local-models.yml create mode 100644 crates/engine/examples/local_models_bench.rs create mode 100644 crates/engine/src/model_cmds.rs create mode 100644 crates/ml/Cargo.toml create mode 100644 crates/ml/README.md create mode 100644 crates/ml/licenses/BiRefNet-MIT.txt create mode 100644 crates/ml/licenses/ONNXRuntime-MIT.txt create mode 100644 crates/ml/licenses/ONNXRuntime-ThirdPartyNotices.txt create mode 100644 crates/ml/licenses/SAM2-Apache-2.0.txt create mode 100644 crates/ml/src/catalog.rs create mode 100644 crates/ml/src/image.rs create mode 100644 crates/ml/src/lib.rs create mode 100644 crates/ml/src/native.rs create mode 100644 crates/ml/src/test_models.rs create mode 100644 docs/images/LICENSE-local-models.txt create mode 100644 docs/images/local-models-before.png create mode 100644 docs/images/local-models-comparison.png create mode 100644 docs/images/local-models-preferences.png create mode 100644 docs/local-models-validation.md create mode 100644 docs/local-models.md diff --git a/.github/workflows/local-models.yml b/.github/workflows/local-models.yml new file mode 100644 index 0000000000..f5f8a97351 --- /dev/null +++ b/.github/workflows/local-models.yml @@ -0,0 +1,72 @@ +name: Optional local models + +on: + # Let contributors verify native platforms in their fork before maintainer approval of PR CI. + push: + paths: + - "crates/ml/**" + - "crates/engine/**" + - "crates/ui-egui/**" + - "apps/photocraft/**" + - "apps/photocraft-cli/**" + - "Cargo.toml" + - "Cargo.lock" + - ".github/workflows/local-models.yml" + pull_request: + paths: + - "crates/ml/**" + - "crates/engine/**" + - "crates/ui-egui/**" + - "apps/photocraft/**" + - "apps/photocraft-cli/**" + - "Cargo.toml" + - "Cargo.lock" + - ".github/workflows/local-models.yml" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: local-models-${{ github.ref }} + cancel-in-progress: true + +jobs: + cpu: + if: ${{ github.event_name != 'push' || github.event.repository.fork }} + name: CPU (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 45 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + env: + CARGO_INCREMENTAL: "0" + CARGO_PROFILE_DEV_DEBUG: "0" + CARGO_PROFILE_TEST_DEBUG: "0" + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + with: + key: optional-local-ml + - name: Install Linux UI dependencies + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + libxkbcommon-dev libwayland-dev libx11-dev libxrandr-dev libxi-dev \ + libgl1-mesa-dev libgtk-3-dev + # Synthetic ONNX graphs exercise the actual runtime and both adapters. No model weights + # are fetched in CI; only ort's pinned build-time runtime redistribution is downloaded. + - name: Test native runtime and download verification + run: cargo test -p photocraft-ml --features onnx --locked + - name: Test commands and CLI with the optional backend + run: cargo test -p photocraft-engine -p photocraft-cli --features local-ml --locked + - name: Check native app and UI with the optional backend + run: cargo check -p photocraft -p photocraft-ui-egui --features local-ml --locked + - name: Clippy optional backend + run: cargo clippy -p photocraft-ml -p photocraft-engine -p photocraft-cli --features photocraft-ml/onnx,local-ml --all-targets --locked -- -D warnings diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index dfc31372f2..092941b417 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -54,10 +54,25 @@ The other built-in ICC profiles and the generated LUT looks are produced by code (`crates/cms/src/builtin.rs`, `crates/cms/src/lutfile.rs`) and dedicated to the public domain (CC0-1.0); they are not separate files. +## Optional local models and runtime + +Model weights are explicit downloads, not files committed or bundled in the default app. +Immutable revisions, artifact sizes and hashes are recorded in `crates/ml/src/catalog.rs`. +The download cache includes the original model licence and a source/revision notice. + +| Path / optional artifact | Title | Author | Source | License | +|---|---|---|---|---| +| Downloaded `birefnet-hr-matting-*/model.onnx` | BiRefNet HR Matting, FP32 ONNX export | Peng Zheng and BiRefNet contributors; export by PinkPixel | [Original checkpoint](https://huggingface.co/ZhengPeng7/BiRefNet_HR-matting), [pinned export](https://huggingface.co/PinkPixel/birefnet-hr-matting-onnx/tree/792518b9d4dfe9793891712677de25e554f948c6) | MIT, [`BiRefNet-MIT.txt`](crates/ml/licenses/BiRefNet-MIT.txt) | +| Downloaded `sam2.1-large-*/{vision_encoder,prompt_encoder_mask_decoder}.onnx{,_data}` | SAM 2.1 Hiera Large, FP32 ONNX export | Meta / SAM 2 contributors; export by ONNX Community | [Original checkpoint](https://huggingface.co/facebook/sam2.1-hiera-large), [pinned export](https://huggingface.co/onnx-community/sam2.1-hiera-large-ONNX/tree/3c23431f721e69cae82dbfd0c28fd692cc714021) | Apache-2.0, [`SAM2-Apache-2.0.txt`](crates/ml/licenses/SAM2-Apache-2.0.txt) | +| Build-time ONNX Runtime redistribution (`local-ml` only) | ONNX Runtime 1.28 CPU runtime | Microsoft and contributors; redistribution by pyke / ort | [ONNX Runtime](https://github.com/microsoft/onnxruntime), [ort 2.0.0-rc.13](https://github.com/pykeio/ort) | MIT, [`ONNXRuntime-MIT.txt`](crates/ml/licenses/ONNXRuntime-MIT.txt), [`third-party notices`](crates/ml/licenses/ONNXRuntime-ThirdPartyNotices.txt) | +| `crates/ml/src/test_models.rs` | Original tiny ONNX contract fixtures (Rust byte constants, no learned weights) | PhotoCraft contributors | Original synthetic graphs: mean/sigmoid, constant embeddings and scored masks | MIT OR Apache-2.0 | + ## Documentation and README | Path | Title | Author | Source | License | |---|---|---|---|---| +| `docs/images/local-models-before.png`, `docs/images/local-models-preferences.png` | PhotoCraft Preferences before / after optional models | PhotoCraft contributors | Original offscreen screenshots | MIT OR Apache-2.0, [`licence`](docs/images/LICENSE-local-models.txt) | +| `docs/images/local-models-comparison.png` | Classical / BiRefNet / SAM actual command outputs using *Girl with a Pearl Earring* | Artwork: Johannes Vermeer, c. 1665; presentation: PhotoCraft contributors | [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:1665_Girl_with_a_Pearl_Earring.jpg), exported masks | Artwork: public domain (PD-Art); presentation: MIT OR Apache-2.0, [`licence`](docs/images/LICENSE-local-models.txt) | | `docs/brand/` (all files) | ArtCraft name, wordmark and mark | ArtCraft Team | getartcraft.com | Not open source; trademarks of the ArtCraft Team, [`docs/brand/LICENSE-brand.txt`](docs/brand/LICENSE-brand.txt) | | `docs/images/photocraft-*.jpg` | PhotoCraft screenshots | PhotoCraft contributors (UI) | Rendered offscreen with the `snapshot` example | MIT OR Apache-2.0 (UI); the artwork in each is public domain, listed below | | `docs/images/preferences-apply-*.png` | Preferences before and after adding Apply (no artwork) | PhotoCraft contributors | PhotoCraft control-channel capture and offscreen `snapshot` example | MIT OR Apache-2.0 | diff --git a/Cargo.lock b/Cargo.lock index 5d3156368d..c3a6f38646 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -556,6 +556,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + [[package]] name = "bindgen" version = "0.72.1" @@ -645,7 +651,7 @@ dependencies = [ "cc", "cfg-if", "constant_time_eq", - "cpufeatures", + "cpufeatures 0.3.1", ] [[package]] @@ -654,6 +660,15 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "block2" version = "0.5.1" @@ -727,6 +742,12 @@ dependencies = [ "syn 3.0.6", ] +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "byteorder-lite" version = "0.1.0" @@ -885,7 +906,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" dependencies = [ "cfg-if", - "cpufeatures", + "cpufeatures 0.3.1", "rand_core 0.10.1", ] @@ -1112,6 +1133,15 @@ dependencies = [ "libm", ] +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + [[package]] name = "cpufeatures" version = "0.3.1" @@ -1204,6 +1234,16 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "cursor-icon" version = "1.2.0" @@ -1263,6 +1303,16 @@ dependencies = [ "rayon", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -2055,6 +2105,16 @@ dependencies = [ "libc", ] +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "gethostname" version = "1.1.0" @@ -2074,6 +2134,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "getrandom" version = "0.3.4" @@ -2341,6 +2412,28 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hmac-sha256" +version = "1.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad320b3b96fb2a455a0726d16efe0a5afdbd34b71dea5bc53b05ea057714d4e" + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + [[package]] name = "iana-time-zone" version = "0.1.65" @@ -3170,6 +3263,22 @@ dependencies = [ "imgref", ] +[[package]] +name = "lzma-rust2" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e20f57f9918e5bd7bc58c22cdd70a6afc7375d4dd9683af5f2b34bd3d2bba619" + +[[package]] +name = "matrixmultiply" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f607c237553f086e7043417a51df26b2eb899d3caff94e6a67592ff992fedc7" +dependencies = [ + "autocfg", + "rawpointer", +] + [[package]] name = "maybe-owned" version = "0.3.4" @@ -3322,6 +3431,21 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "ndarray" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520080814a7a6b4a6e9070823bb24b4531daac8c4627e08ba5de8c5ef2f2752d" +dependencies = [ + "matrixmultiply", + "num-complex", + "num-integer", + "num-traits", + "portable-atomic", + "portable-atomic-util", + "rawpointer", +] + [[package]] name = "ndk" version = "0.9.0" @@ -4008,6 +4132,30 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "ort" +version = "2.0.0-rc.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4336a1e2b38848325241c72889086886004e589b7c74f335e60a8e8db5138a0b" +dependencies = [ + "ndarray", + "ort-sys", + "smallvec", + "tracing", + "ureq", +] + +[[package]] +name = "ort-sys" +version = "2.0.0-rc.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf211e3776eea6aec988552fa118dd746d70e1b1e5e244058d1c98015f3e5872" +dependencies = [ + "hmac-sha256", + "lzma-rust2", + "ureq", +] + [[package]] name = "os_pipe" version = "1.2.3" @@ -4239,7 +4387,7 @@ dependencies = [ name = "photocraft-automation" version = "0.6.0" dependencies = [ - "base64", + "base64 0.22.1", "cap-std", "getrandom 0.3.4", "photocraft-codecs", @@ -4351,6 +4499,7 @@ dependencies = [ "photocraft-format", "photocraft-geom", "photocraft-io", + "photocraft-ml", "photocraft-ops", "photocraft-paint", "photocraft-plugins", @@ -4446,6 +4595,20 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "photocraft-ml" +version = "0.5.0" +dependencies = [ + "ort", + "photocraft-algo", + "photocraft-raster", + "serde", + "sha2", + "tempfile", + "thiserror 2.0.21", + "ureq", +] + [[package]] name = "photocraft-ops" version = "0.6.0" @@ -4556,7 +4719,7 @@ dependencies = [ name = "photocraft-ui-egui" version = "0.6.0" dependencies = [ - "base64", + "base64 0.22.1", "eframe", "egui", "egui_extras", @@ -5086,6 +5249,12 @@ dependencies = [ "objc2-quartz-core 0.3.2", ] +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + [[package]] name = "rayon" version = "1.12.0" @@ -5258,6 +5427,20 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rmcp" version = "3.5.0" @@ -5385,6 +5568,41 @@ dependencies = [ "rustix 1.1.5", ] +[[package]] +name = "rustls" +version = "0.23.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.23" @@ -5563,6 +5781,17 @@ dependencies = [ "serde_core", ] +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest", +] + [[package]] name = "shlex" version = "1.3.0" @@ -5747,6 +5976,17 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "socks" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c3dbbd9ae980613c6dd8e28a9407b50509d3803b57624d5dfe8315218cd58b" +dependencies = [ + "byteorder", + "libc", + "winapi", +] + [[package]] name = "spin" version = "0.9.9" @@ -5805,6 +6045,12 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "svgtypes" version = "0.15.3" @@ -6190,6 +6436,12 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + [[package]] name = "uds_windows" version = "1.2.1" @@ -6267,6 +6519,41 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "ureq" +version = "3.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a7ac20be9b7726e0bbdbf974c059676d9acb1cd414961f570a4e8231cacd7fc" +dependencies = [ + "base64 0.23.1", + "log", + "percent-encoding", + "rustls", + "rustls-pki-types", + "socks", + "ureq-proto", + "utf8-zero", + "webpki-roots", +] + +[[package]] +name = "ureq-proto" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f86fd172ccca569e458f61b6bdd6220965a9ef36e672a6852953b51a0e1583be" +dependencies = [ + "base64 0.23.1", + "http", + "httparse", + "log", +] + [[package]] name = "url" version = "2.5.8" @@ -6285,7 +6572,7 @@ version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80be9b06fbae3b8b303400ab20778c80bbaf338f563afe567cf3c9eea17b47ef" dependencies = [ - "base64", + "base64 0.22.1", "data-url", "flate2", "fontdb", @@ -6306,6 +6593,12 @@ dependencies = [ "xmlwriter", ] +[[package]] +name = "utf8-zero" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8c0a043c9540bae7c578c88f91dda8bd82e59ae27c21baca69c8b191aaf5a6e" + [[package]] name = "utf8_iter" version = "1.0.4" @@ -6727,6 +7020,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "weezl" version = "0.1.12" @@ -6922,6 +7224,22 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471" +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + [[package]] name = "winapi-util" version = "0.1.11" @@ -6931,6 +7249,12 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "windows" version = "0.62.2" @@ -7618,6 +7942,12 @@ dependencies = [ "synstructure", ] +[[package]] +name = "zeroize" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" + [[package]] name = "zerotrie" version = "0.2.5" diff --git a/Cargo.toml b/Cargo.toml index afcfdd1522..a91dac3aeb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ photocraft-vector = { path = "crates/vector" } photocraft-format = { path = "crates/format" } photocraft-automation = { path = "crates/automation" } photocraft-plugins = { path = "crates/plugins" } +photocraft-ml = { path = "crates/ml" } photocraft-engine = { path = "crates/engine" } photocraft-ui-egui = { path = "crates/ui-egui" } photocraft-testkit = { path = "crates/testkit" } diff --git a/apps/photocraft-cli/Cargo.toml b/apps/photocraft-cli/Cargo.toml index a6d3b49389..156ff683bd 100644 --- a/apps/photocraft-cli/Cargo.toml +++ b/apps/photocraft-cli/Cargo.toml @@ -10,6 +10,7 @@ build = "build.rs" # Open HEIC/HEIF photos (the optional photocraft-heif crate). Not default so distributors choose # it; official builds (CI, packaging/, release) build with `--features heif`. heif = ["photocraft-codecs/heif"] +local-ml = ["photocraft-engine/local-ml"] [lints] workspace = true @@ -34,4 +35,3 @@ tokio = { version = "1", features = ["rt-multi-thread", "macros"] } [build-dependencies] # Icon + VERSIONINFO for photocraft-cli.exe; build.rs only uses it when targeting Windows. winresource = "0.1" - diff --git a/apps/photocraft-cli/src/lib.rs b/apps/photocraft-cli/src/lib.rs index 345edf9657..2d1f48299b 100644 --- a/apps/photocraft-cli/src/lib.rs +++ b/apps/photocraft-cli/src/lib.rs @@ -232,11 +232,28 @@ fn print_json(out: &mut dyn Write, v: &Value, compact: bool) -> R { writeln!(out, "{s}").map_err(|e| e.to_string()) } +/// Only explicit, trusted CLI invocations receive a model-cache capability. MCP sessions keep +/// their existing filesystem authority; merely starting the CLI never downloads a model. +fn local_headless() -> Headless { + let mut h = Headless::trusted_local(); + configure_cli_models(&mut h.session); + h +} + +fn configure_cli_models(session: &mut photocraft_engine::Session) { + #[cfg(all(feature = "local-ml", not(target_arch = "wasm32")))] + if let Some(dir) = std::env::var_os("PHOTOCRAFT_MODEL_DIR") { + session.configure_local_models(dir.into()); + } + #[cfg(any(not(feature = "local-ml"), target_arch = "wasm32"))] + let _ = session; +} + fn info(a: &Args, out: &mut dyn Write) -> R { let [file] = a.positional.as_slice() else { return Err("info needs ".into()); }; - let mut h = Headless::trusted_local(); + let mut h = local_headless(); let opened = h.open(Path::new(file)).map_err(|e| e.to_string())?; let mut doc = h.inspect(None).map_err(|e| e.to_string())?; let mut warnings = opened["warnings"].as_array().cloned().unwrap_or_default(); @@ -272,7 +289,7 @@ fn command_list(a: &Args) -> Result, String> { fn run_cmds(a: &Args, out: &mut dyn Write, err: &mut dyn Write) -> R { let opts = export_opts(a)?; - let mut h = Headless::trusted_local(); + let mut h = local_headless(); match (a.positional.as_slice(), a.get("--new")) { ([file], None) => { let o = h.open(Path::new(file)).map_err(|e| e.to_string())?; @@ -368,6 +385,9 @@ fn batch(a: &Args, out: &mut dyn Write, err: &mut dyn Write) -> R { inputs.sort(); let (mut ok, mut failed) = (0, 0); let mut written = photocraft_engine::file_cmds::OutputClaims::default(); + // Keep only model weights resident across files, rather than retaining their documents or + // loading a new native session for each image in the same explicit batch invocation. + let model_backend = local_headless().session.model_backend; // `--format .jpg` names outputs `.jpg`, as `--format jpg` does (#490). let format = a.get("--format").map(|f| f.strip_prefix('.').unwrap_or(f)); for input in &inputs { @@ -378,6 +398,7 @@ fn batch(a: &Args, out: &mut dyn Write, err: &mut dyn Write) -> R { let r = (|| -> Result, String> { written.check(&target_text)?; let mut h = Headless::trusted_local(); + h.session.model_backend = model_backend.clone(); h.open(input).map_err(|e| e.to_string())?; for (id, p) in &actions { h.command_run(id, p.clone()).map_err(|e| format!("`{id}`: {e}"))?; @@ -412,6 +433,7 @@ fn droplet(a: &Args, out: &mut dyn Write, err: &mut dyn Write) -> R { p["output"] = json!(o); } let mut s = photocraft_engine::Session::new(); + configure_cli_models(&mut s); let r = s.execute("file.automate.runDroplet", p).map_err(|e| e.to_string())?; for f in r["files"].as_array().into_iter().flatten() { let _ = writeln!(out, "ok {}", f.as_str().unwrap_or_default()); diff --git a/apps/photocraft/Cargo.toml b/apps/photocraft/Cargo.toml index c031c4495e..586be540b5 100644 --- a/apps/photocraft/Cargo.toml +++ b/apps/photocraft/Cargo.toml @@ -11,6 +11,7 @@ build = "build.rs" # Open HEIC/HEIF photos (the optional photocraft-heif crate). Not default so distributors choose # it; official builds (CI, packaging/, release) build with `--features heif`. heif = ["photocraft-codecs/heif"] +local-ml = ["photocraft-engine/local-ml"] [lints] workspace = true diff --git a/apps/photocraft/src/main.rs b/apps/photocraft/src/main.rs index 709c2b9bb9..20a438765c 100644 --- a/apps/photocraft/src/main.rs +++ b/apps/photocraft/src/main.rs @@ -348,7 +348,16 @@ fn main() -> eframe::Result { services::xwayland_command(var("FLATPAK_ID").as_deref(), var("APPIMAGE").as_deref(), std::env::var_os("DISPLAY").is_some()); } } - let mut app = PhotocraftApp::new(Session::new(), services); + let session = Session::new(); + #[cfg(feature = "local-ml")] + let session = { + let mut session = session; + if let Some(dir) = services::config_dir() { + session.configure_local_models(dir.join("Models")); + } + session + }; + let mut app = PhotocraftApp::new(session, services); app.integrated_titlebar = cfg!(target_os = "macos"); app.custom_titlebar = custom_titlebar; // Only the title bar's free gap drags the window, never the menus (mac_window.rs). diff --git a/contributors/people.toml b/contributors/people.toml index af8591c1a9..b2b97d2438 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -90,3 +90,6 @@ sync_github_name = false [people.vangel76] sync_github_name = true + +[people.mighty-programmer] +sync_github_name = true diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml index fa15c30986..3a08c52a83 100644 --- a/crates/engine/Cargo.toml +++ b/crates/engine/Cargo.toml @@ -10,6 +10,7 @@ workspace = true [features] # Real-file corpus tests (opt-in; `cargo xtask test-corpus`). Fail when the corpus is missing. corpus = [] +local-ml = ["photocraft-ml/onnx"] [dependencies] photocraft-geom = { workspace = true } @@ -31,6 +32,7 @@ photocraft-io = { workspace = true } photocraft-psd = { workspace = true } photocraft-format = { workspace = true } photocraft-plugins = { workspace = true } +photocraft-ml = { workspace = true } blake3 = { version = "1.8", default-features = false, features = ["pure"] } photocraft-codecs = { workspace = true } flate2 = { workspace = true } diff --git a/crates/engine/examples/local_models_bench.rs b/crates/engine/examples/local_models_bench.rs new file mode 100644 index 0000000000..b6a2e4d55a --- /dev/null +++ b/crates/engine/examples/local_models_bench.rs @@ -0,0 +1,59 @@ +//! Opt-in end-to-end timing on a caller-provided, public-domain 24–36 MP image. No downloads. +//! cargo run --release -p photocraft-engine --features local-ml --example local_models_bench -- +//! /absolute/model-cache /absolute/image.png [/absolute/cutout-directory] +#[cfg(all(feature = "local-ml", not(target_arch = "wasm32")))] +fn main() -> Result<(), Box> { + use photocraft_engine::Session; + use serde_json::json; + let args: Vec = std::env::args().skip(1).collect(); + let cache = args.first().ok_or("provide a model-cache directory")?; + let input = args.get(1).ok_or("provide a public-domain test image")?; + let decoded = photocraft_io::import(input, &photocraft_format::read_file(std::path::Path::new(input))?)?; + if let Some(out) = args.get(2) { + std::fs::create_dir_all(out)?; + } + let mut s = Session::new(); + s.configure_local_models(cache.into()); + s.add_document(decoded.document, None); + let bounds = s.active().ok_or("no document")?.doc.bounds(); + for (command, model) in [ + ("layer.removeBackground", "classical"), + ("layer.removeBackground", "birefnet-hr-matting"), + ("select.object", "classical"), + ("select.object", "sam2.1-large"), + ] { + for run in 0..2 { + let steps = s.active().ok_or("no document")?.history.past_len(); + let params = + json!({"model":model,"rect":[bounds.width() as f32*0.1,bounds.height() as f32*0.05,bounds.width() as f32*0.85,bounds.height() as f32*0.95]}); + let start = std::time::Instant::now(); + let result = s.execute(command, params); + println!( + "{}", + json!({"command":command,"model":model,"run":run,"width":bounds.width(),"height":bounds.height(),"ms":start.elapsed().as_secs_f64()*1000.0,"ok":result.is_ok()}) + ); + result?; + if run == 0 + && let Some(out) = args.get(2) + { + // Turn a selection into a mask for the comparison export; undo separately below. + if command == "select.object" { + s.execute("layer.layerMask.revealSelection", json!({}))?; + } + let d = s.active().ok_or("no document")?; + let export = photocraft_io::export(&d.doc, "comparison.png", &Default::default())?; + let path = std::path::Path::new(out).join(format!("{command}-{model}.png")); + std::fs::write(path, export.bytes)?; + } + while s.active().ok_or("no document")?.history.past_len() > steps { + s.execute("edit.undo", json!({}))?; + } + } + } + Ok(()) +} + +#[cfg(any(not(feature = "local-ml"), target_arch = "wasm32"))] +fn main() { + eprintln!("Enable local-ml on a native target to run this opt-in benchmark."); +} diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs index 35974fc235..cbe37f7338 100644 --- a/crates/engine/src/commands.rs +++ b/crates/engine/src/commands.rs @@ -1130,6 +1130,7 @@ fn build() -> Vec { v.extend(crate::vector_cmds::specs()); v.extend(crate::path_edit_cmds::specs()); v.extend(crate::smartselect_cmds::specs()); + v.extend(crate::model_cmds::specs()); v.extend(crate::cutout_cmds::specs()); v.extend(crate::symmetry_cmds::specs()); v.extend(crate::edit_cmds::specs()); diff --git a/crates/engine/src/cutout_cmds.rs b/crates/engine/src/cutout_cmds.rs index 762830ee83..c0ed7a2b6f 100644 --- a/crates/engine/src/cutout_cmds.rs +++ b/crates/engine/src/cutout_cmds.rs @@ -41,17 +41,26 @@ fn run(s: &mut Session, p: &Value) -> Result { check(doc, doc.layer(id).ok_or(EngineError::NoLayer(id))?).map_err(EngineError::Other)?; let sample_all = p.get("sampleAllLayers").and_then(Value::as_bool).unwrap_or(false); let refine = p.get("refine").and_then(Value::as_bool).unwrap_or(true); + let model = crate::model_cmds::subject_model(s, p)?; + let backend = model.map(|_| crate::model_cmds::backend(s)).transpose()?; crate::jobs::edit_job( s, "Remove Background", move |doc, _, ctx| { ctx.progress(0.1, "Finding subject"); - let found = with_doc_sampler(doc, Some(id), sample_all, |smp, d| subject::select_subject(smp, d.bounds())); + let found = match (model, backend.as_ref()) { + (Some(model), Some(backend)) => with_doc_sampler(doc, Some(id), sample_all, |smp, d| { + crate::model_cmds::infer_region(backend.as_ref(), model, smp, d, photocraft_ml::Prompt::Subject, ctx) + })?, + _ => with_doc_sampler(doc, Some(id), sample_all, |smp, d| subject::select_subject(smp, d.bounds())), + }; let mut region = found.ok_or_else(|| EngineError::Other("no subject found".into()))?; if ctx.cancelled() { return Err(EngineError::Cancelled); } - if refine { + // BiRefNet already estimates a soft alpha matte. Classical edge refinement would + // threshold or change those opacities, so it applies only to the classical selector. + if refine && model.is_none() { ctx.progress(0.6, "Refining edge"); let refined = with_doc_sampler(doc, Some(id), sample_all, |smp, d| { matting::refine_mask(smp, &matting::region_reader(®ion), region.bbox, d.bounds(), &REFINE) @@ -67,7 +76,7 @@ fn run(s: &mut Session, p: &Value) -> Result { let b = region.bbox; Ok([b.x0, b.y0, b.width() as i32, b.height() as i32]) }, - move |bounds| json!({ "layer": id.0, "bounds": bounds }), + move |bounds| json!({ "layer": id.0, "bounds": bounds, "model": model.map_or("classical", |m| m.name()) }), ) } @@ -78,7 +87,7 @@ pub fn specs() -> Vec { label: "Remove Background", menu: &[], shortcut: None, - params: r##"{"layer":id?,"sampleAllLayers":bool=false,"refine":bool=true} → {layer,bounds} (adds a layer mask from Select Subject; the Background becomes a normal layer)"##, + params: r##"{"layer":id?,"sampleAllLayers":bool=false,"refine":bool=true,"model":"classical|birefnet-hr-matting"?} → {layer,bounds,model} (model defaults to Preferences; refine applies to classical only; replaces the layer mask; the Background becomes a normal layer)"##, enabled, run, journal: true, diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index 103a1f6f3b..52625beca6 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -770,7 +770,7 @@ impl OutputClaims { } } -fn batch(_s: &mut Session, p: &Value) -> Result { +fn batch(s: &mut Session, p: &Value) -> Result { let cmd = "file.automate.batch"; let steps = parse_steps(p.get("steps").or_else(|| p.get("action")).ok_or_else(|| EngineError::BadParams { cmd: cmd.into(), msg: "missing \"steps\"".into() })?)?; @@ -781,6 +781,11 @@ fn batch(_s: &mut Session, p: &Value) -> Result { let output = str_param(p, "output", cmd)?.to_string(); let format = p.get("format").and_then(Value::as_str).unwrap_or("same").to_string(); let r = process_files(&inputs, &output, &format, SaveOpts::from_params(p), "", &|scratch| { + // Reuse a host-granted backend (and its resident model) across inputs. A default or + // untrusted session still has no model-cache capability; nested steps retain its gate. + scratch.model_backend = s.model_backend.clone(); + scratch.authorize = s.authorize; + scratch.edit_prefs(|p| p.integrations = s.prefs().integrations.clone()); for (id, params) in &steps { scratch.execute(id, params.clone())?; } diff --git a/crates/engine/src/jobs.rs b/crates/engine/src/jobs.rs index 9b612e3c4c..3155231a1f 100644 --- a/crates/engine/src/jobs.rs +++ b/crates/engine/src/jobs.rs @@ -253,7 +253,7 @@ pub enum Started { /// Commands that never edit the active document, allowed while a job runs on it. fn independent_of_document(id: &str) -> bool { - const PREFIXES: &[&str] = &["jobs.", "tools.", "view.", "window.", "help.", "brush.presets.", "gradient.presets."]; + const PREFIXES: &[&str] = &["jobs.", "models.", "tools.", "view.", "window.", "help.", "brush.presets.", "gradient.presets."]; const IDS: &[&str] = &["file.new", "file.close", "file.closeAll", "edit.preferences", "edit.colorSettings", "edit.keyboardShortcuts", "edit.menus"]; PREFIXES.iter().any(|p| id.starts_with(p)) || IDS.contains(&id) } @@ -623,6 +623,7 @@ impl Session { if let Some(v) = crate::float_cmds::before_command(self, id)? { return Ok(Started::Done(v)); } + let params = crate::model_cmds::inject_model(self, id, params); // Pixel commands follow the Channels panel target unless the caller names one. let run_params = crate::channel_cmds::inject_target(self, id, crate::commands::inject_kind(id, params.clone())); if let Err(why) = crate::smart_cmds::target_enabled(self, spec, ¶ms).unwrap_or_else(|| self.precondition(spec, &run_params)) { diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 5245eed1c4..63c82d1797 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -64,6 +64,7 @@ pub mod magnetic_cmds; pub mod mask_view_cmds; mod migrate_cmds; pub mod mode_cmds; +pub mod model_cmds; pub mod multichannel_cmds; pub mod notes_cmds; pub mod paint_cmds; @@ -346,6 +347,9 @@ pub struct Session { color_restrict: Option, /// Edit › Preferences, keyboard shortcuts, menu and toolbar customisation (see `prefs`). pub prefs: prefs::PrefsStore, + /// Optional native model service, injected by a platform frontend. An ordinary/test/web + /// session has none: creating a Session never downloads models or accesses a model directory. + pub model_backend: Option>, /// Edit menu state: Fade source, custom shape library (see `edit_menu_cmds`). pub edit_state: edit_menu_cmds::EditState, /// The pattern library (Window › Patterns; see `pattern.*`). diff --git a/crates/engine/src/model_cmds.rs b/crates/engine/src/model_cmds.rs new file mode 100644 index 0000000000..7524449fc8 --- /dev/null +++ b/crates/engine/src/model_cmds.rs @@ -0,0 +1,502 @@ +//! Optional model lifecycle commands and the colour/depth-agnostic selection adapter. +use std::sync::Arc; + +use photocraft_algo::segment::{Sampler, antialias_u8, trim_region}; +use photocraft_algo::selection::Region; +use photocraft_cms::{Builtin, Transform, transform::TransformOptions}; +use photocraft_doc::Document; +use photocraft_geom::Rect; +use photocraft_ml::{InferenceBackend, MaskKind, ModelId, Prompt}; +use serde_json::{Value, json}; + +use crate::commands::CommandSpec; +use crate::jobs::JobCtx; +use crate::{EngineError, Result, Session}; + +fn error(e: photocraft_ml::Error) -> EngineError { + match e { + photocraft_ml::Error::Cancelled => EngineError::Cancelled, + e => EngineError::Other(e.to_string()), + } +} + +pub(crate) fn backend(s: &Session) -> Result> { + s.model_backend + .clone() + .ok_or_else(|| EngineError::Other("local models are not available in this build or session; choose Classical in Preferences › Integrations".into())) +} + +/// An explicit command choice overrides the saved preference, allowing an action or script to +/// request the same method every time. Inference never silently falls back or starts a download. +pub(crate) fn subject_model(s: &Session, p: &Value) -> Result> { + model_choice(p, s.prefs().integrations.subject_model.name(), ModelId::BiRefNet) +} + +pub(crate) fn object_model(s: &Session, p: &Value) -> Result> { + model_choice(p, s.prefs().integrations.object_model.name(), ModelId::Sam2) +} + +/// Resolve the preference before dispatch so recorded actions keep the method used, even if +/// the preference changes before playback. Explicit choices (including invalid ones) stay intact. +pub(crate) fn inject_model(s: &Session, command: &str, mut params: Value) -> Value { + let model = match command { + "select.subject" | "layer.removeBackground" => s.prefs().integrations.subject_model.name(), + "select.object" => s.prefs().integrations.object_model.name(), + _ => return params, + }; + if params.is_null() { + params = json!({}); + } + if let Some(fields) = params.as_object_mut() { + fields.entry("model").or_insert_with(|| json!(model)); + } + params +} + +fn model_choice(p: &Value, default: &str, allowed: ModelId) -> Result> { + let name = match p.get("model") { + Some(v) => v.as_str().ok_or_else(|| EngineError::Other("model must be a string".into()))?, + None => default, + }; + if name == "classical" { + return Ok(None); + } + match ModelId::parse(name) { + Some(id) if id == allowed => Ok(Some(id)), + _ => Err(EngineError::Other(format!("model must be classical or {} for this command", allowed.name()))), + } +} + +struct ModelSampler<'a> { + source: &'a dyn Sampler, + cmyk: Option>, + transform: Arc, +} + +impl Sampler for ModelSampler<'_> { + fn rgba(&self, rect: Rect) -> Vec<[f32; 4]> { + // rgb_scaled reads strips on rayon workers. Enter the document's CMYK context on each + // worker, and convert its RGB/gray profile before downsampling or compositing transparency. + let mut px = photocraft_color::convert::with_cmyk_space(self.cmyk.as_ref(), || self.source.rgba(rect)); + for p in &mut px { + let mut rgb = [0.0; 3]; + self.transform.eval(&p[..3], &mut rgb); + for (dst, v) in p.iter_mut().take(3).zip(rgb) { + *dst = if v.is_finite() { v.clamp(0.0, 1.0) } else { 0.0 }; + } + if !p[3].is_finite() { + p[3] = 0.0; + } + } + px + } +} + +pub(crate) fn infer_region( + backend: &dyn InferenceBackend, + id: ModelId, + source: &dyn Sampler, + doc: &Document, + prompt: Prompt, + ctx: &JobCtx, +) -> Result> { + let bounds = doc.bounds(); + let (w, h) = (bounds.width() as usize, bounds.height() as usize); + let n = w + .checked_mul(h) + .filter(|n| *n > 0 && *n <= 64_000_000) + .ok_or_else(|| EngineError::Other("local models currently support canvases up to 64 megapixels".into()))?; + ctx.check()?; + ctx.progress(0.02, "Preparing image"); + let transform = photocraft_cms::transform::cached(&crate::color_cmds::composite_profile(doc), Builtin::Srgb.profile(), TransformOptions::default()) + .map_err(|e| EngineError::Other(format!("model colour conversion: {e}")))?; + let sampler = ModelSampler { source, cmyk: photocraft_compose::cmyk_space(doc), transform }; + let step = w.max(h).div_ceil(id.info().input_side).max(1); + let image = sampler.rgb_scaled(bounds, step); + ctx.check()?; + ctx.progress(0.1, "Running local model (CPU)"); + let mask = ctx.stage(0.1, 0.85, "Running local model (CPU)", |ctl| backend.infer(id, &image, prompt, ctl)).map_err(error)?; + mask.validate().map_err(error)?; + let mut values = vec![0u8; n]; + for (y, row) in values.chunks_exact_mut(w).enumerate() { + ctx.check()?; + for (x, dst) in row.iter_mut().enumerate() { + *dst = mask.coverage((x as f32 + 0.5) / w as f32, (y as f32 + 0.5) / h as f32); + } + if y % 64 == 0 { + ctx.progress(0.85 + 0.14 * y as f32 / h as f32, "Building mask"); + } + } + if mask.kind == MaskKind::Logits { + antialias_u8(&mut values, w, h); + } + ctx.check()?; + Ok(trim_region(Region { bbox: bounds, mask: values })) +} + +impl Session { + /// Inject a native model cache. Host code supplies the location; no arbitrary model path or + /// URL is accepted by an engine command. Default builds and wasm have no native backend. + #[cfg(all(feature = "local-ml", not(target_arch = "wasm32")))] + pub fn configure_local_models(&mut self, directory: std::path::PathBuf) { + self.model_backend = Some(Arc::new(photocraft_ml::NativeBackend::new(directory))); + } + + pub fn local_model_status(&self) -> Value { + let states = self.model_backend.as_ref().map(|b| b.status()).unwrap_or_default(); + let models: Vec = photocraft_ml::MODELS + .iter() + .map(|m| { + let status = states.iter().find(|s| s.id == m.id); + json!({"id": m.id, "label": m.label, "purpose": m.purpose, "license": m.license, + "downloadBytes": m.download_bytes(), "upstream": m.upstream, "exportSource": m.export_source, + "revision": m.revision, "installed": status.is_some_and(|s| s.installed), "busy": status.is_some_and(|s| s.busy)}) + }) + .collect(); + json!({"available": self.model_backend.is_some(), "models": models}) + } +} + +fn model_id(p: &Value, cmd: &str) -> Result { + p.get("id") + .and_then(Value::as_str) + .and_then(ModelId::parse) + .ok_or_else(|| EngineError::BadParams { cmd: cmd.into(), msg: "id must be birefnet-hr-matting or sam2.1-large".into() }) +} + +fn available(s: &Session) -> std::result::Result<(), String> { + if s.model_backend.is_some() { Ok(()) } else { Err("local models are not available in this build or session".into()) } +} + +fn download(s: &mut Session, p: &Value) -> Result { + let id = model_id(p, "models.download")?; + let backend = backend(s)?; + crate::jobs::run( + s, + &format!("Downloading {}", id.info().label), + false, + move |ctx| ctx.stage(0.0, 1.0, "Downloading model", |ctl| backend.download(id, ctl)).map_err(error), + move |s, ()| Ok(s.local_model_status()), + ) +} + +fn remove(s: &mut Session, p: &Value) -> Result { + let id = model_id(p, "models.remove")?; + let backend = backend(s)?; + crate::jobs::run( + s, + &format!("Removing {}", id.info().label), + false, + move |ctx| ctx.stage(0.0, 1.0, "Removing model", |ctl| backend.remove(id, ctl)).map_err(error), + move |s, ()| { + s.prefs.edit(|p| match id { + ModelId::BiRefNet => p.integrations.subject_model = crate::prefs::SubjectModel::Classical, + ModelId::Sam2 => p.integrations.object_model = crate::prefs::ObjectModel::Classical, + }); + Ok(s.local_model_status()) + }, + ) +} + +pub fn specs() -> Vec { + vec![ + CommandSpec { + id: "models.list", + label: "Local Selection Models", + menu: &[], + shortcut: None, + params: "{} → {available,models:[{id,label,installed,busy,downloadBytes,license,revision,upstream,exportSource}]}", + enabled: |_| Ok(()), + run: |s, _| Ok(s.local_model_status()), + journal: false, + }, + CommandSpec { + id: "models.download", + label: "Download Local Selection Model", + menu: &[], + shortcut: None, + params: r#"{"id":"birefnet-hr-matting|sam2.1-large"} (explicit download; size/SHA-256 verified; no document edits)"#, + enabled: available, + run: download, + journal: false, + }, + CommandSpec { + id: "models.remove", + label: "Remove Local Selection Model", + menu: &[], + shortcut: None, + params: r#"{"id":"birefnet-hr-matting|sam2.1-large"} (remove only this model; restore its selection preference to classical)"#, + enabled: available, + run: remove, + journal: false, + }, + ] +} + +#[cfg(test)] +mod tests { + use super::*; + use photocraft_algo::segment::RgbImage; + use photocraft_ml::{AlphaMask, ModelStatus}; + use photocraft_raster::Interrupt; + use std::sync::Mutex; + use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; + + #[derive(Default)] + struct Fake { + installed: AtomicBool, + downloads: AtomicUsize, + block: AtomicBool, + entered: AtomicBool, + calls: Mutex>, + } + impl InferenceBackend for Fake { + fn status(&self) -> Vec { + photocraft_ml::MODELS.iter().map(|m| ModelStatus { id: m.id, installed: self.installed.load(Ordering::Relaxed), busy: false }).collect() + } + fn download(&self, _: ModelId, _: &Interrupt<'_>) -> photocraft_ml::Result<()> { + self.downloads.fetch_add(1, Ordering::Relaxed); + self.installed.store(true, Ordering::Relaxed); + Ok(()) + } + fn remove(&self, _: ModelId, _: &Interrupt<'_>) -> photocraft_ml::Result<()> { + self.installed.store(false, Ordering::Relaxed); + Ok(()) + } + fn infer(&self, id: ModelId, image: &RgbImage, prompt: Prompt, ctl: &Interrupt<'_>) -> photocraft_ml::Result { + self.entered.store(true, Ordering::Relaxed); + if !self.installed.load(Ordering::Relaxed) { + return Err(photocraft_ml::Error::Unavailable("download first".into())); + } + self.calls.lock().unwrap().push((id, RgbImage { w: image.w, h: image.h, px: image.px.clone() }, prompt)); + if self.block.load(Ordering::Relaxed) { + for _ in 0..400 { + if ctl.cancelled() { + return Err(photocraft_ml::Error::Cancelled); + } + std::thread::sleep(std::time::Duration::from_millis(5)); + } + return Err(photocraft_ml::Error::Inference("test backend timed out".into())); + } + Ok(AlphaMask { width: 2, height: 1, values: vec![0.0, 1.0], kind: MaskKind::Alpha }) + } + } + fn session(mode: &str, depth: u32) -> (Session, Arc) { + let mut s = Session::new(); + s.execute("file.new", json!({"width":8,"height":4,"depth":depth,"mode":mode})).unwrap(); + let fake = Arc::new(Fake::default()); + fake.installed.store(true, Ordering::Relaxed); + s.model_backend = Some(fake.clone()); + (s, fake) + } + fn cov(s: &Session, x: i32) -> f32 { + s.active().unwrap().doc.selection.as_ref().map_or(0.0, |m| m.sample_channel(x, 2, 0)) + } + fn pixels(s: &Session) -> Vec { + let d = s.active().unwrap(); + d.doc.layer(d.active_layer.unwrap()).unwrap().surface().unwrap().read_region(d.doc.bounds()) + } + + #[test] + fn learned_background_mask_preserves_pixels_soft_alpha_and_one_undo_at_all_depths_and_modes() { + for mode in ["rgb", "gray", "cmyk", "lab"] { + for depth in [8, 16, 32] { + let (mut s, fake) = session(mode, depth); + s.execute("select.rect", json!({"x":0,"y":0,"width":2,"height":4})).unwrap(); + let old_selection = s.active().unwrap().doc.selection.clone(); + let before = pixels(&s); + let steps = s.active().unwrap().history.past_len(); + s.execute("layer.removeBackground", json!({"model":"birefnet-hr-matting"})).unwrap(); + let d = s.active().unwrap(); + let mask = d.doc.layer(d.active_layer.unwrap()).unwrap().mask.as_ref().unwrap(); + assert_eq!(mask.value(0, 2), 0.0); + assert_eq!(mask.value(7, 2), 1.0); + assert!((mask.value(3, 2) - 0.376).abs() < 0.01); + assert_eq!(pixels(&s), before, "{mode} {depth}"); + assert!(d.doc.selection.is_none()); + assert_eq!(d.history.past_len(), steps + 1); + let calls = fake.calls.lock().unwrap(); + assert_eq!((calls[0].1.w, calls[0].1.h), (8, 4)); + assert!(calls[0].1.px.iter().flatten().all(|v| v.is_finite() && (0.0..=1.0).contains(v))); + drop(calls); + s.execute("edit.undo", json!({})).unwrap(); + let d = s.active().unwrap(); + assert!(d.doc.layer(d.active_layer.unwrap()).unwrap().mask.is_none()); + assert_eq!(d.doc.selection.as_ref().unwrap().read_region(d.doc.bounds()), old_selection.as_ref().unwrap().read_region(d.doc.bounds())); + s.execute("edit.redo", json!({})).unwrap(); + assert!(s.active().unwrap().doc.layers[0].mask.is_some()); + } + } + } + + #[test] + fn learned_selection_combines_modes_and_maps_boxes_on_non_square_images() { + for (mode, left, right) in [("replace", false, true), ("add", true, true), ("subtract", true, false), ("intersect", false, false)] { + let (mut s, fake) = session("rgb", 16); + s.execute("select.rect", json!({"x":0,"y":0,"width":2,"height":4})).unwrap(); + let steps = s.active().unwrap().history.past_len(); + s.execute("select.object", json!({"rect":[6,3,-4,-2],"model":"sam2.1-large","mode":mode})).unwrap(); + assert_eq!(cov(&s, 0) > 0.5, left, "{mode}"); + assert_eq!(cov(&s, 7) > 0.5, right, "{mode}"); + let calls = fake.calls.lock().unwrap(); + assert_eq!(calls[0].2, Prompt::Box([0.25, 0.25, 0.75, 0.75])); + drop(calls); + assert_eq!(s.active().unwrap().history.past_len(), steps + 1); + s.execute("edit.undo", json!({})).unwrap(); + assert_eq!(cov(&s, 0), 1.0); + assert_eq!(cov(&s, 7), 0.0); + } + } + + #[test] + fn missing_models_invalid_choices_and_bad_boxes_never_edit_or_download() { + let (mut s, fake) = session("rgb", 8); + fake.installed.store(false, Ordering::Relaxed); + let revision = s.active().unwrap().revision; + for (cmd, p) in [ + ("select.subject", json!({"model":"birefnet-hr-matting"})), + ("layer.removeBackground", json!({"model":"birefnet-hr-matting"})), + ("select.object", json!({"model":"sam2.1-large","rect":[0,0,8,4]})), + ("select.subject", json!({"model":"sam2.1-large"})), + ("select.subject", json!({"model":42})), + ("models.download", json!({"id":"../unsafe"})), + ("models.remove", json!({"id":42})), + ] { + assert!(s.execute(cmd, p).is_err(), "{cmd}"); + } + for rect in [json!([0, 0, "bad", 8, 4]), json!([0, 0, 8]), json!([1e100, 0, 8, 4]), json!([0, 0, 0, 0]), json!([100, 100, 8, 4])] { + assert!(s.execute("select.object", json!({"model":"sam2.1-large","rect":rect})).is_err()); + } + assert_eq!(s.active().unwrap().revision, revision); + assert_eq!(fake.downloads.load(Ordering::Relaxed), 0); + s.model_backend = None; + assert_eq!(s.execute("models.list", json!({})).unwrap()["available"], false); + assert!(s.execute("select.subject", json!({"model":"birefnet-hr-matting"})).is_err()); + } + + #[test] + fn downloads_need_no_document_never_replay_and_removal_resets_only_its_preference() { + let mut s = Session::new(); + let fake = Arc::new(Fake::default()); + s.model_backend = Some(fake.clone()); + s.execute("models.download", json!({"id":"birefnet-hr-matting"})).unwrap(); + assert!(s.journal.is_empty()); + assert_eq!(fake.downloads.load(Ordering::Relaxed), 1); + s.execute("prefs.set", json!({"values":{"integrations.subjectModel":"birefnet-hr-matting","integrations.objectModel":"sam2.1-large"}})).unwrap(); + s.execute("models.remove", json!({"id":"birefnet-hr-matting"})).unwrap(); + assert_eq!(s.prefs().integrations.subject_model, crate::prefs::SubjectModel::Classical); + assert_eq!(s.prefs().integrations.object_model, crate::prefs::ObjectModel::Sam2); + assert!(s.execute("prefs.set", json!({"path":"integrations.objectModel","value":"birefnet-hr-matting"})).is_err()); + let mut old = s.prefs_value(); + old["integrations"].as_object_mut().unwrap().remove("objectModel"); + old["integrations"].as_object_mut().unwrap().remove("subjectModel"); + let loaded: crate::prefs::Preferences = serde_json::from_value(old).unwrap(); + assert_eq!(loaded.integrations.subject_model, crate::prefs::SubjectModel::Classical); + assert_eq!(loaded.integrations.object_model, crate::prefs::ObjectModel::Classical); + } + + #[test] + fn preferences_select_a_model_and_explicit_classical_overrides_it() { + let (mut s, fake) = session("rgb", 32); + s.execute("prefs.set", json!({"path":"integrations.subjectModel","value":"birefnet-hr-matting"})).unwrap(); + s.execute("select.subject", json!({})).unwrap(); + assert_eq!(fake.calls.lock().unwrap().len(), 1); + s.execute("select.subject", json!({"model":"classical"})).unwrap(); + assert_eq!(fake.calls.lock().unwrap().len(), 1); + } + + #[test] + fn recorded_actions_keep_the_selected_method_when_preferences_change() { + let (mut s, fake) = session("rgb", 8); + s.edit_prefs(|p| { + p.integrations.subject_model = crate::prefs::SubjectModel::BiRefNet; + p.integrations.object_model = crate::prefs::ObjectModel::Sam2; + }); + s.execute("actions.record", json!({"name":"Models"})).unwrap(); + s.execute("select.subject", Value::Null).unwrap(); + s.execute("select.object", json!({"rect":[0,0,8,4]})).unwrap(); + s.execute("layer.removeBackground", json!({})).unwrap(); + s.execute("actions.stop", json!({})).unwrap(); + let action = &s.actions.list[0]; + assert_eq!(action.steps.len(), 3); + assert_eq!(action.steps[0].1["model"], "birefnet-hr-matting"); + assert_eq!(action.steps[1].1["model"], "sam2.1-large"); + assert_eq!(action.steps[2].1["model"], "birefnet-hr-matting"); + s.edit_prefs(|p| p.integrations = Default::default()); + assert!(s.execute("actions.play", json!({"action":"Models"})).unwrap().get("failed").is_none()); + assert_eq!(fake.calls.lock().unwrap().len(), 6); + } + + #[test] + #[cfg(not(target_arch = "wasm32"))] + fn batch_and_droplet_share_only_the_explicitly_configured_model_capability() { + let dir = std::env::temp_dir().join(format!("photocraft-model-batch-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir(&dir).unwrap(); + let input = dir.join("input.png"); + let output = dir.join("output"); + std::fs::create_dir(&output).unwrap(); + let (mut s, fake) = session("rgb", 8); + let exported = photocraft_io::export(&s.active().unwrap().doc, "input.png", &Default::default()).unwrap(); + std::fs::write(&input, exported.bytes).unwrap(); + s.edit_prefs(|p| p.integrations.subject_model = crate::prefs::SubjectModel::BiRefNet); + let droplet = dir.join("models.pcdroplet"); + std::fs::write( + &droplet, + serde_json::to_vec(&json!({"photocraftDroplet":1,"action":{"steps":[["layer.removeBackground",{}]]},"options":{"format":"png"}})).unwrap(), + ) + .unwrap(); + let result = s.execute("file.automate.runDroplet", json!({"droplet":droplet,"input":[input],"output":output})).unwrap(); + assert_eq!(result["errors"], json!([])); + assert_eq!(fake.calls.lock().unwrap().len(), 1); + s.model_backend = None; + let result = + s.execute("file.automate.batch", json!({"steps":[["select.subject",{"model":"birefnet-hr-matting"}]],"input":[input],"output":output})).unwrap(); + assert_eq!(result["errors"].as_array().unwrap().len(), 1); + assert_eq!(fake.calls.lock().unwrap().len(), 1); + std::fs::remove_dir_all(dir).unwrap(); + } + + #[test] + fn model_input_uses_document_profile_and_existing_mask_replacement_undo_is_preserved() { + let (mut s, fake) = session("rgb", 32); + s.edit("linear pixels and old mask", |doc, _| { + doc.icc_profile = Some(Builtin::LinearSrgb.profile().to_bytes()); + let bounds = doc.bounds(); + doc.layers[0].surface_mut().unwrap().fill_rect(bounds, &[0.25, 0.25, 0.25, 1.0]); + doc.layers[0].mask = Some(photocraft_doc::LayerMask::hide_all()); + Ok(()) + }) + .unwrap(); + s.execute("select.subject", json!({"model":"birefnet-hr-matting","sampleAllLayers":false})).unwrap(); + let calls = fake.calls.lock().unwrap(); + assert!((calls[0].1.px[0][0] - 0.5371).abs() < 0.005, "linear RGB must be transformed to sRGB"); + drop(calls); + s.execute("layer.removeBackground", json!({"model":"birefnet-hr-matting"})).unwrap(); + assert_eq!(s.active().unwrap().doc.layers[0].mask.as_ref().unwrap().value(7, 2), 1.0); + s.execute("edit.undo", json!({})).unwrap(); + assert_eq!(s.active().unwrap().doc.layers[0].mask.as_ref().unwrap().value(7, 2), 0.0); + } + + #[test] + #[cfg(not(target_arch = "wasm32"))] + fn cancelling_model_inference_discards_result_and_unlocks_document() { + let (mut s, fake) = session("rgb", 8); + fake.block.store(true, Ordering::Relaxed); + let before = s.active().unwrap().revision; + let crate::jobs::Started::Job(job) = s.start("layer.removeBackground", json!({"model":"birefnet-hr-matting"})).unwrap() else { panic!("expected job") }; + for _ in 0..200 { + if fake.entered.load(Ordering::Relaxed) { + break; + } + std::thread::sleep(std::time::Duration::from_millis(5)); + } + assert!(fake.entered.load(Ordering::Relaxed)); + assert!(s.cancel_job(job)); + assert!(matches!(s.wait_job(job), Err(EngineError::Cancelled))); + assert_eq!(s.active().unwrap().revision, before); + assert!(s.active().unwrap().doc.layers[0].mask.is_none()); + s.execute("select.all", json!({})).unwrap(); + assert!(s.active().unwrap().doc.selection.is_some()); + } +} diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index 8ecdafa885..faa4fdadaa 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -108,6 +108,8 @@ choice!(FontPreview { Off = "off", Small = "small", Medium = "medium", Large = " choice!(RawColorSpace { Srgb = "srgb", AdobeRgb = "adobeRgb", ProPhoto = "proPhoto", DisplayP3 = "displayP3" } default AdobeRgb); choice!(RawDepth { Eight = "8", Sixteen = "16" } default Sixteen); choice!(RawSharpen { None = "none", Screen = "screen", Glossy = "glossy", Matte = "matte" } default None); +choice!(SubjectModel { Classical = "classical", BiRefNet = "birefnet-hr-matting" } default Classical); +choice!(ObjectModel { Classical = "classical", Sam2 = "sam2.1-large" } default Classical); impl Unit { /// Document pixels → this unit. `dpi` is the document resolution, `extent` the 100% length @@ -867,11 +869,14 @@ pub struct Integrations { pub allow_agent_control: bool, /// Default control port (0 = only when `--control` is given). pub control_port: u32, + /// Optional, downloaded local model; classical selection remains the default. + pub subject_model: SubjectModel, + pub object_model: ObjectModel, } impl Default for Integrations { fn default() -> Self { - Self { allow_agent_control: true, control_port: 0 } + Self { allow_agent_control: true, control_port: 0, subject_model: SubjectModel::Classical, object_model: ObjectModel::Classical } } } @@ -1065,6 +1070,8 @@ pub fn choices(path: &str) -> Option<&'static [&'static str]> { "performance.gpuBackend" => GpuBackend::NAMES, "performance.linuxDisplayServer" => LinuxDisplayServer::NAMES, "performance.renderingMode" => RenderingMode::NAMES, + "integrations.subjectModel" => SubjectModel::NAMES, + "integrations.objectModel" => ObjectModel::NAMES, _ => return None, }) } diff --git a/crates/engine/src/smartselect_cmds.rs b/crates/engine/src/smartselect_cmds.rs index 5871ad6098..50ab59cb26 100644 --- a/crates/engine/src/smartselect_cmds.rs +++ b/crates/engine/src/smartselect_cmds.rs @@ -73,7 +73,7 @@ pub(crate) fn with_doc_sampler(doc: &Document, layer: Option, all_la /// caller gets `changed: false`, whatever the mode. (Select Subject and Object Selection run /// heuristics that often find nothing on busy photos; clearing the selection then looks like /// a dead button.) -fn apply(s: &mut Session, label: &str, region: Option, m: SelectionMode) -> Result { +pub(crate) fn apply(s: &mut Session, label: &str, region: Option, m: SelectionMode) -> Result { if region.is_none() { // Nothing found: leave the selection (and history) alone. let selected = s.active().ok_or(EngineError::NoDocument)?.doc.selection.is_some(); @@ -120,27 +120,73 @@ fn quick_selection(s: &mut Session, p: &Value) -> Result { fn rect_param(p: &Value) -> Option { let a = p.get("rect")?.as_array()?; - let v: Vec = a.iter().filter_map(Value::as_f64).collect(); - if v.len() < 4 { + let v: Vec = a.iter().map(Value::as_f64).collect::>()?; + if v.len() != 4 || v.iter().any(|v| !v.is_finite()) { return None; } // Negative sizes (dragging up/left) are normalised. let (x0, x1) = (v[0].min(v[0] + v[2]), v[0].max(v[0] + v[2])); let (y0, y1) = (v[1].min(v[1] + v[3]), v[1].max(v[1] + v[3])); + if [x0, y0, x1, y1].iter().any(|v| !v.is_finite() || *v < i32::MIN as f64 || *v > i32::MAX as f64) { + return None; + } Some(Rect::new(x0.floor() as i32, y0.floor() as i32, x1.ceil() as i32, y1.ceil() as i32)) } fn object_selection(s: &mut Session, p: &Value) -> Result { let rect = rect_param(p).ok_or_else(|| bad("select.object", "needs \"rect\": [x, y, w, h]"))?; + if let Some(id) = crate::model_cmds::object_model(s, p)? { + let d = s.active().ok_or(EngineError::NoDocument)?; + let canvas = d.doc.bounds(); + let rect = rect.intersect(&canvas); + if rect.is_empty() { + return Err(bad("select.object", "box must overlap the canvas")); + } + let prompt = photocraft_ml::Prompt::Box([ + (rect.x0 - canvas.x0) as f32 / canvas.width() as f32, + (rect.y0 - canvas.y0) as f32 / canvas.height() as f32, + (rect.x1 - canvas.x0) as f32 / canvas.width() as f32, + (rect.y1 - canvas.y0) as f32 / canvas.height() as f32, + ]); + return model_selection(s, p, id, prompt, "Object Selection", false); + } let region = with_sampler(s, b(p, "sampleAllLayers", false), |smp, doc| grabcut::object_select(smp, doc.bounds(), rect, 160_000))?; apply(s, "Object Selection", region, mode(p, "replace")) } fn select_subject(s: &mut Session, p: &Value) -> Result { + if let Some(id) = crate::model_cmds::subject_model(s, p)? { + return model_selection(s, p, id, photocraft_ml::Prompt::Subject, "Select Subject", true); + } let region = with_sampler(s, b(p, "sampleAllLayers", true), |smp, doc| subject::select_subject(smp, doc.bounds()))?; apply(s, "Select Subject", region, mode(p, "replace")) } +fn model_selection( + s: &mut Session, + p: &Value, + id: photocraft_ml::ModelId, + prompt: photocraft_ml::Prompt, + label: &'static str, + all_default: bool, +) -> Result { + let backend = crate::model_cmds::backend(s)?; + let d = s.active().ok_or(EngineError::NoDocument)?; + let (doc, layer) = (d.doc.clone(), d.active_layer); + let (all, m) = (b(p, "sampleAllLayers", all_default), mode(p, "replace")); + crate::jobs::run( + s, + label, + true, + move |ctx| with_doc_sampler(&doc, layer, all, |smp, d| crate::model_cmds::infer_region(backend.as_ref(), id, smp, d, prompt, ctx)), + move |s, region| { + let mut result = apply(s, label, region, m)?; + result["model"] = json!(id); + Ok(result) + }, + ) +} + fn focus_area(s: &mut Session, p: &Value) -> Result { let (range, noise) = (f(p, "range", 0.5).clamp(0.0, 1.0), f(p, "noise", 0.0).clamp(0.0, 1.0)); let region = with_sampler(s, b(p, "sampleAllLayers", true), |smp, doc| focus::focus_area(smp, doc.bounds(), range, noise))?; @@ -256,7 +302,7 @@ pub fn specs() -> Vec { "select.object", "Object Selection", [], - r##"{"rect":[x,y,w,h],"mode":"replace|add|subtract|intersect"="replace","sampleAllLayers":bool=false}"##, + r##"{"rect":[x,y,w,h],"mode":"replace|add|subtract|intersect"="replace","sampleAllLayers":bool=false,"model":"classical|sam2.1-large"? (defaults to Preferences)}"##, has_doc, object_selection ), @@ -264,7 +310,7 @@ pub fn specs() -> Vec { "select.subject", "Subject", ["Select"], - r##"{"sampleAllLayers":bool=true,"mode":"replace|add|subtract|intersect"="replace"}"##, + r##"{"sampleAllLayers":bool=true,"mode":"replace|add|subtract|intersect"="replace","model":"classical|birefnet-hr-matting"? (defaults to Preferences)}"##, has_doc, select_subject ), diff --git a/crates/ml/Cargo.toml b/crates/ml/Cargo.toml new file mode 100644 index 0000000000..cd64710423 --- /dev/null +++ b/crates/ml/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "photocraft-ml" +version.workspace = true +edition.workspace = true +license.workspace = true + +[lints] +workspace = true + +[features] +default = [] +# Native C++ runtime at the I/O edge; never enabled by default or linked into wasm. +onnx = ["dep:ort", "dep:ureq", "dep:sha2", "dep:tempfile"] + +[dependencies] +photocraft-algo = { workspace = true } +photocraft-raster = { workspace = true } +serde = { workspace = true } +thiserror = { workspace = true } + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +# Pin prereleases: the API and matching native runtime must be reviewed together. +ort = { version = "=2.0.0-rc.13", default-features = false, features = ["std", "api-27", "download-binaries", "tls-rustls"], optional = true } +# Pinned because the idle-timeout transport adapter uses ureq's unversioned seam. +ureq = { version = "=3.4.2", default-features = false, features = ["rustls"], optional = true } +sha2 = { version = "0.10", optional = true } +tempfile = { version = "3", optional = true } diff --git a/crates/ml/README.md b/crates/ml/README.md new file mode 100644 index 0000000000..3dcc9abf0a --- /dev/null +++ b/crates/ml/README.md @@ -0,0 +1,31 @@ +# photocraft-ml + +L4 boundary for optional local image segmentation. The default crate contains a pinned model +catalogue, image/mask validation and an `InferenceBackend` trait. The `onnx` Cargo feature adds +the native CPU backend using the safe `ort` API. It never links ONNX Runtime into wasm. + +Hosts inject a cache directory. Constructing a backend, querying its status, opening an image +or selecting a method never downloads anything. Only `download` contacts the pinned export +URLs. Downloads stream into a temporary directory, verify exact sizes and SHA-256 hashes, and +install by rename after every artifact succeeds. Failure/cancellation discards staging files. +Inference re-verifies artifacts before parsing; arbitrary model paths and URLs are not commands. + +One model's weights stay resident at a time. CPU arena and memory-pattern caching are disabled +to release large temporary tensors between runs instead of retaining peak allocations. +Per-model locks protect download/removal/inference, and a +shared session lock prevents two large inferences from running together. CPU runs use up to eight +threads; `RunOptions::terminate` handles cancellation. Slow session construction finishes before +the next cancellation check. Stalled HTTP reads time out after 30 seconds, separately from the +one-hour total body budget. `ureq` is pinned because its idle-timeout adapter uses the unversioned +transport seam without changing the default TLS/proxy connector. + +`RgbImage` inputs must already be sRGB; the engine converts the document profile through CMS. +Inputs are mapped to the training square with bilinear interpolation and ImageNet-normalized +NCHW. BiRefNet's reviewed export returns sigmoid alpha directly; SAM returns logits, with the +best predicted-IoU mask chosen and thresholding after interpolation. Box prompts share the +full-image normalized coordinates. `AlphaMask::coverage` supplies the existing selection/mask +coverage representation while source pixels retain their original depth and colour mode. + +See [local models](../../docs/local-models.md) for UI/CLI usage, limitations, exact provenance, +licences and reproducible checks. Tiny original synthetic ONNX graphs in `src/test_models.rs` +test the runtime contracts offline; they contain no learned weights and make no accuracy claim. diff --git a/crates/ml/licenses/BiRefNet-MIT.txt b/crates/ml/licenses/BiRefNet-MIT.txt new file mode 100644 index 0000000000..485921e827 --- /dev/null +++ b/crates/ml/licenses/BiRefNet-MIT.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 ZhengPeng + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/ml/licenses/ONNXRuntime-MIT.txt b/crates/ml/licenses/ONNXRuntime-MIT.txt new file mode 100644 index 0000000000..48bc6bb499 --- /dev/null +++ b/crates/ml/licenses/ONNXRuntime-MIT.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/ml/licenses/ONNXRuntime-ThirdPartyNotices.txt b/crates/ml/licenses/ONNXRuntime-ThirdPartyNotices.txt new file mode 100644 index 0000000000..fbd9f9a95f --- /dev/null +++ b/crates/ml/licenses/ONNXRuntime-ThirdPartyNotices.txt @@ -0,0 +1,6121 @@ +THIRD PARTY SOFTWARE NOTICES AND INFORMATION + +Do Not Translate or Localize + +This software incorporates material from third parties. Microsoft makes certain +open source code available at http://3rdpartysource.microsoft.com, or you may +send a check or money order for US $5.00, including the product name, the open +source component name, and version number, to: + +Source Code Compliance Team +Microsoft Corporation +One Microsoft Way +Redmond, WA 98052 +USA + +Notwithstanding any other terms, you may reverse engineer this software to the +extent required to debug changes to any libraries licensed under the GNU Lesser +General Public License. + +_____ + +Intel Math Kernel Library (Intel MKL) + +Intel Simplified Software License (Version April 2018) + +Copyright (c) 2018 Intel Corporation. + +Use and Redistribution. You may use and redistribute the software (the “Software”), without modification, +provided the following conditions are met: + +* Redistributions must reproduce the above copyright notice and the following terms of use in the Software +and in the documentation and/or other materials provided with the distribution. + +* Neither the name of Intel nor the names of its suppliers may be used to endorse or promote products +derived from this Software without specific prior written permission. + +* No reverse engineering, decompilation, or disassembly of this Software is permitted. + +Limited patent license. Intel grants you a world-wide, royalty-free, non-exclusive license under patents it now +or hereafter owns or controls to make, have made, use, import, offer to sell and sell (“Utilize”) this Software, +but solely to the extent that any such patent is necessary to Utilize the Software alone. The patent license +shall not apply to any combinations which include this software. No hardware per se is licensed hereunder. + +Third party and other Intel programs. “Third Party Programs” are the files listed in the “third-party-programs.txt” +text file that is included with the Software and may include Intel programs under separate license terms. +Third Party Programs, even if included with the distribution of the Materials, are governed by +separate license terms and those license terms solely govern your use of those programs. + +DISCLAIMER. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE DISCLAIMED. THIS SOFTWARE IS +NOT INTENDED FOR USE IN SYSTEMS OR APPLICATIONS WHERE FAILURE OF THE SOFTWARE +MAY CAUSE PERSONAL INJURY OR DEATH AND YOU AGREE THAT YOU ARE FULLY RESPONSIBLE FOR ANY +CLAIMS, COSTS, DAMAGES, EXPENSES, AND ATTORNEYS’ FEES ARISING OUT OF ANY SUCH USE, +EVEN IF ANY CLAIM ALLEGES THAT INTEL WAS NEGLIGENT REGARDING THE DESIGN OR MANUFACTURE OF +THE MATERIALS. + +LIMITATION OF LIABILITY. IN NO EVENT WILL INTEL BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +OF SUCH DAMAGE. YOU AGREE TO INDEMNIFY AND HOLD INTEL HARMLESS AGAINST ANY CLAIMS +AND EXPENSES RESULTING FROM YOUR USE OR UNAUTHORIZED USE OF THE SOFTWARE. + +No support. Intel may make changes to the Software, at any time without notice, and is not obligated to +support, update or provide training for the Software. + +Termination. Intel may terminate your right to use the Software in the event of your breach of this Agreement +and you fail to cure the breach within a reasonable period of time. + +Feedback. Should you provide Intel with comments, modifications, corrections, enhancements or other input +(“Feedback”) related to the Software Intel will be free to use, disclose, reproduce, license or otherwise +distribute or exploit the Feedback in its sole discretion without any obligations or restrictions of any kind, +including without limitation, intellectual property rights or licensing obligations. + +Compliance with laws. You agree to comply with all relevant laws and regulations governing your use, +transfer, import or export (or prohibition thereof) of the Software. + +Governing law. All disputes will be governed by the laws of the United States of America and the State of +Delaware without reference to conflict of law principles and subject to the exclusive jurisdiction of the state or +federal courts sitting in the State of Delaware, and each party agrees that it submits to the personal +jurisdiction and venue of those courts and waives any objections. The United Nations Convention on +Contracts for the International Sale of Goods (1980) is specifically excluded and will not apply to the +Software. + +*Other names and brands may be claimed as the property of others. + +_____ + +protocolbuffers/protobuf + +Copyright 2008 Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Code generated by the Protocol Buffer compiler is owned by the owner +of the input file used when generating it. This code is not +standalone and requires a support library to be linked with it. This +support library is itself covered by the above license. + +_____ + +madler/zlib + +The deflate format used by zlib was defined by Phil Katz. The deflate and +zlib specifications were written by L. Peter Deutsch. Thanks to all the +people who reported problems and suggested various improvements in zlib; they +are too numerous to cite here. + +Copyright notice: + + (C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +If you use the zlib library in a product, we would appreciate *not* receiving +lengthy legal documents to sign. The sources are provided for free but without +warranty of any kind. The library has been entirely written by Jean-loup +Gailly and Mark Adler; it does not include third-party code. + +If you redistribute modified sources, we would appreciate that you include in +the file ChangeLog history information documenting your changes. Please read +the FAQ for more information on the distribution of modified source versions. + +_____ + +pybind/pybind11 + +Copyright (c) 2016 Wenzel Jakob , All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Please also refer to the file CONTRIBUTING.md, which clarifies licensing of +external contributions to this project including patches, pull requests, etc. + +_____ + +onnx +Open Neural Network Exchange + +Copyright (c) Facebook, Inc. and Microsoft Corporation. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +_____ + +Eigen + +MPL v2.0 +Mozilla Public License Version 2.0 + + +================================== + +1. Definitions + +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions + +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities + +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination + +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. + +_____ + +intel/dnnl + +Copyright 2016-2018 Intel Corporation + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +sub-components: + +xbyak + +Copyright (c) 2007 MITSUNARI Shigeo. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. +Neither the name of the copyright owner nor the names of its contributors may +be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +Microsoft GSL + +Copyright (c) 2015 Microsoft Corporation. All rights reserved. + +This code is licensed under the MIT License (MIT). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +_____ + +Tensorflow + +Copyright 2018 The TensorFlow Authors. All rights reserved. + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work, +where such license applies only to those patent claims licensable +by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) +with the Work to which such Contribution(s) was submitted. If You +institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct +or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate +as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You +meet the following conditions: + +(a) You must give any other recipients of the Work or +Derivative Works a copy of this License; and + +(b) You must cause any modified files to carry prominent notices +stating that You changed the files; and + +(c) You must retain, in the Source form of any Derivative Works +that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, +excluding those notices that do not pertain to any part of +the Derivative Works; and + +(d) If the Work includes a "NOTICE" text file as part of its +distribution, then any Derivative Works that You distribute must +include a readable copy of the attribution notices contained +within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one +of the following places: within a NOTICE text file distributed +as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, +within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents +of the NOTICE file are for informational purposes only and +do not modify the License. You may add Your own attribution +notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided +that such additional attribution notices cannot be construed +as modifying the License. + +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017, The TensorFlow Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +_____ + +Microsoft Cognitive Toolkit (CNTK) + +Copyright (c) Microsoft Corporation. All rights reserved. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +_____ + +NumPy License + +Copyright (c) 2005, NumPy Developers + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + Neither the name of the NumPy Developers nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +Pytorch / Caffe2 + +From PyTorch: + +Copyright (c) 2016- Facebook, Inc (Adam Paszke) +Copyright (c) 2014- Facebook, Inc (Soumith Chintala) +Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert) +Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu) +Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu) +Copyright (c) 2011-2013 NYU (Clement Farabet) +Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston) +Copyright (c) 2006 Idiap Research Institute (Samy Bengio) +Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz) + +From Caffe2: + +Copyright (c) 2016-present, Facebook Inc. All rights reserved. + +All contributions by Facebook: +Copyright (c) 2016 Facebook Inc. + +All contributions by Google: +Copyright (c) 2015 Google Inc. +All rights reserved. + +All contributions by Yangqing Jia: +Copyright (c) 2015 Yangqing Jia +All rights reserved. + +All contributions from Caffe: +Copyright(c) 2013, 2014, 2015, the respective contributors +All rights reserved. + +All other contributions: +Copyright(c) 2015, 2016 the respective contributors +All rights reserved. + +Caffe2 uses a copyright model similar to Caffe: each contributor holds +copyright over their contributions to Caffe2. The project versioning records +all such contribution and copyright details. If a contributor wants to further +mark their specific copyright on a particular contribution, they should +indicate their copyright solely in the commit message of the change when it is +committed. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the names of Facebook, Deepmind Technologies, NYU, NEC Laboratories America + and IDIAP Research Institute nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +_____ + +Caffe + +COPYRIGHT + +All contributions by the University of California: +Copyright (c) 2014-2017 The Regents of the University of California (Regents) +All rights reserved. + +All other contributions: +Copyright (c) 2014-2017, the respective contributors +All rights reserved. + +Caffe uses a shared copyright model: each contributor holds copyright over +their contributions to Caffe. The project versioning records all such +contribution and copyright details. If a contributor wants to further mark +their specific copyright on a particular contribution, they should indicate +their copyright solely in the commit message of the change when it is +committed. + +LICENSE + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +CONTRIBUTION AGREEMENT + +By contributing to the BVLC/caffe repository through pull-request, comment, +or otherwise, the contributor releases their content to the +license and copyright terms herein. + +_____ + +The LLVM Compiler Infrastructure + +============================================================================== +LLVM Release License +============================================================================== +University of Illinois/NCSA +Open Source License + +Copyright (c) 2003-2017 University of Illinois at Urbana-Champaign. +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== +Copyrights and Licenses for Third Party Software Distributed with LLVM: +============================================================================== +The LLVM software contains code written by third parties. Such software will +have its own individual LICENSE.TXT file in the directory in which it appears. +This file will describe the copyrights, license, and restrictions which apply +to that code. + +The disclaimer of warranty in the University of Illinois Open Source License +applies to all code in the LLVM Distribution, and nothing in any of the +other licenses gives permission to use the names of the LLVM Team or the +University of Illinois to endorse or promote products derived from this +Software. + +The following pieces of software have additional or alternate copyrights, +licenses, and/or restrictions: + +Program Directory +------- --------- +Google Test llvm/utils/unittest/googletest +OpenBSD regex llvm/lib/Support/{reg*, COPYRIGHT.regex} +pyyaml tests llvm/test/YAMLParser/{*.data, LICENSE.TXT} +ARM contributions llvm/lib/Target/ARM/LICENSE.TXT +md5 contributions llvm/lib/Support/MD5.cpp llvm/include/llvm/Support/MD5.h + +_____ + +google/benchmark + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +CONTRIBUTORS + +# People who have agreed to one of the CLAs and can contribute patches. +# The AUTHORS file lists the copyright holders; this file +# lists people. For example, Google employees are listed here +# but not in AUTHORS, because Google holds the copyright. +# +# Names should be added to this file only after verifying that +# the individual or the individual's organization has agreed to +# the appropriate Contributor License Agreement, found here: +# +# https://developers.google.com/open-source/cla/individual +# https://developers.google.com/open-source/cla/corporate +# +# The agreement for individuals can be filled out on the web. +# +# When adding J Random Contributor's name to this file, +# either J's name or J's organization's name should be +# added to the AUTHORS file, depending on whether the +# individual or corporate CLA was used. +# +# Names should be added to this file as: +# Name +# +# Please keep the list sorted. + +Albert Pretorius +Arne Beer +Billy Robert O'Neal III +Chris Kennelly +Christopher Seymour +David Coeurjolly +Deniz Evrenci +Dominic Hamon +Dominik Czarnota +Eric Fiselier +Eugene Zhuk +Evgeny Safronov +Federico Ficarelli +Felix Homann +Ismael Jimenez Martinez +Jern-Kuan Leong +JianXiong Zhou +Joao Paulo Magalhaes +John Millikin +Jussi Knuuttila +Kai Wolf +Kishan Kumar +Kaito Udagawa +Lei Xu +Matt Clarkson +Maxim Vafin +Nick Hutchinson +Oleksandr Sochka +Pascal Leroy +Paul Redmond +Pierre Phaneuf +Radoslav Yovchev +Raul Marin +Ray Glover +Robert Guo +Roman Lebedev +Shuo Chen +Tobias Ulvgård +Tom Madams +Yixuan Qiu +Yusuke Suzuki +Zbigniew Skowron + +AUTHORS + +# This is the official list of benchmark authors for copyright purposes. +# This file is distinct from the CONTRIBUTORS files. +# See the latter for an explanation. +# +# Names should be added to this file as: +# Name or Organization +# The email address is not required for organizations. +# +# Please keep the list sorted. + +Albert Pretorius +Arne Beer +Carto +Christopher Seymour +David Coeurjolly +Deniz Evrenci +Dirac Research +Dominik Czarnota +Eric Fiselier +Eugene Zhuk +Evgeny Safronov +Federico Ficarelli +Felix Homann +Google Inc. +International Business Machines Corporation +Ismael Jimenez Martinez +Jern-Kuan Leong +JianXiong Zhou +Joao Paulo Magalhaes +Jussi Knuuttila +Kaito Udagawa +Kishan Kumar +Lei Xu +Matt Clarkson +Maxim Vafin +MongoDB Inc. +Nick Hutchinson +Oleksandr Sochka +Paul Redmond +Radoslav Yovchev +Roman Lebedev +Shuo Chen +Steinar H. Gunderson +Stripe, Inc. +Yixuan Qiu +Yusuke Suzuki +Zbigniew Skowron + +_____ + +HalideIR + +Copyright (c) 2016 HalideIR contributors +Copyright (c) 2012-2014 MIT CSAIL, Google Inc., and other contributors +HalideIR is derived from the Halide project. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +_____ + +Distributed Machine Learning Common Codebase + +Copyright (c) 2015 by Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +_____ + +DLPack: Open In Memory Tensor Structure + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017 by Contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +_____ + +HowardHinnant/date + +The source code in this project is released using the MIT License. There is no +global license for the project because each file is licensed individually with +different author names and/or dates. + +If you contribute to this project, please add your name to the license of each +file you modify. If you have already contributed to this project and forgot to +add your name to the license, please feel free to submit a new P/R to add your +name to the license in each file you modified. + +For convenience, here is a copy of the MIT license found in each file except +without author names or dates: + +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +_____ + +FreeBSD: getopt.c file + +Copyright (c) 1987, 1993, 1994 +The Regents of the University of California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither the name of the University nor the names of its contributors +may be used to endorse or promote products derived from this software +without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. +_____ + + +google/googletest + +Copyright 2008, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +G3log : Asynchronous logger with Dynamic Sinks + +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to +_____ + +Scikit-learn + +Copyright (c) 2007–2018 The scikit-learn developers. +All rights reserved. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + a. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + b. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + c. Neither the name of the Scikit-learn Developers nor the names of + its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. + +_____ + +google/re2 + +Copyright (c) 2009 The RE2 Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +_____ +onnx/onnx-tensorrt + +MIT License + +Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. +Copyright (c) 2018 Open Neural Network Exchange + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +_____ +nvidia/cutlass + +Copyright (c) 2017 - 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +SPDX-License-Identifier: BSD-3-Clause + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ +Boost + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + + +_____ + +JDAI-CV/DNNLibrary + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [2019] [JD.com Inc. JD AI] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +_____ + +google/flatbuffers + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014 Google Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +_____ + +google/glog + +Copyright (c) 2008, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +A function gettimeofday in utilities.cc is based on + +http://www.google.com/codesearch/p?hl=en#dR3YEbitojA/COPYING&q=GetSystemTimeAsFileTime%20license:bsd + +The license of this code is: + +Copyright (c) 2003-2008, Jouni Malinen and contributors +All Rights Reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name(s) of the above-listed copyright holder(s) nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +abseil-cpp +https://github.com/abseil/abseil-cpp + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +_____ + +microsoft/wil + +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE + +_____ + +nlohmann/json + +MIT License + +Copyright (c) 2013-2019 Niels Lohmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +_____ + +dcleblanc/SafeInt + +MIT License + +Copyright (c) 2018 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +_____ +Open MPI + +3-Clause BSD License + +Most files in this release are marked with the copyrights of the +organizations who have edited them. The copyrights below are in no +particular order and generally reflect members of the Open MPI core +team who have contributed code to this release. The copyrights for +code used under license from other parties are included in the +corresponding files. + +Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana + University Research and Technology + Corporation. All rights reserved. +Copyright (c) 2004-2017 The University of Tennessee and The University + of Tennessee Research Foundation. All rights + reserved. +Copyright (c) 2004-2010 High Performance Computing Center Stuttgart, + University of Stuttgart. All rights reserved. +Copyright (c) 2004-2008 The Regents of the University of California. + All rights reserved. +Copyright (c) 2006-2017 Los Alamos National Security, LLC. All rights + reserved. +Copyright (c) 2006-2017 Cisco Systems, Inc. All rights reserved. +Copyright (c) 2006-2010 Voltaire, Inc. All rights reserved. +Copyright (c) 2006-2017 Sandia National Laboratories. All rights reserved. +Copyright (c) 2006-2010 Sun Microsystems, Inc. All rights reserved. + Use is subject to license terms. +Copyright (c) 2006-2017 The University of Houston. All rights reserved. +Copyright (c) 2006-2009 Myricom, Inc. All rights reserved. +Copyright (c) 2007-2017 UT-Battelle, LLC. All rights reserved. +Copyright (c) 2007-2017 IBM Corporation. All rights reserved. +Copyright (c) 1998-2005 Forschungszentrum Juelich, Juelich Supercomputing + Centre, Federal Republic of Germany +Copyright (c) 2005-2008 ZIH, TU Dresden, Federal Republic of Germany +Copyright (c) 2007 Evergrid, Inc. All rights reserved. +Copyright (c) 2008 Chelsio, Inc. All rights reserved. +Copyright (c) 2008-2009 Institut National de Recherche en + Informatique. All rights reserved. +Copyright (c) 2007 Lawrence Livermore National Security, LLC. + All rights reserved. +Copyright (c) 2007-2017 Mellanox Technologies. All rights reserved. +Copyright (c) 2006-2010 QLogic Corporation. All rights reserved. +Copyright (c) 2008-2017 Oak Ridge National Labs. All rights reserved. +Copyright (c) 2006-2012 Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2009-2015 Bull SAS. All rights reserved. +Copyright (c) 2010 ARM ltd. All rights reserved. +Copyright (c) 2016 ARM, Inc. All rights reserved. +Copyright (c) 2010-2011 Alex Brick . All rights reserved. +Copyright (c) 2012 The University of Wisconsin-La Crosse. All rights + reserved. +Copyright (c) 2013-2016 Intel, Inc. All rights reserved. +Copyright (c) 2011-2017 NVIDIA Corporation. All rights reserved. +Copyright (c) 2016 Broadcom Limited. All rights reserved. +Copyright (c) 2011-2017 Fujitsu Limited. All rights reserved. +Copyright (c) 2014-2015 Hewlett-Packard Development Company, LP. All + rights reserved. +Copyright (c) 2013-2017 Research Organization for Information Science (RIST). + All rights reserved. +Copyright (c) 2017-2018 Amazon.com, Inc. or its affiliates. All Rights + reserved. +Copyright (c) 2018 DataDirect Networks. All rights reserved. +Copyright (c) 2018-2019 Triad National Security, LLC. All rights reserved. + +$COPYRIGHT$ + +Additional copyrights may follow + +$HEADER$ + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer listed + in this license in the documentation and/or other materials + provided with the distribution. + +- Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +The copyright holders provide no reassurances that the source code +provided does not infringe any patent, copyright, or any other +intellectual property rights of third parties. The copyright holders +disclaim any liability to any recipient for claims brought against +recipient by any third party for infringement of that parties +intellectual property rights. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +The Android Open Source Project + +Copyright (C) 2017 The Android Open Source Project +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +------ + +libprotobuf-mutator + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + ----- + + openucx/ucx + https://github.com/openucx/ucx + + Copyright (c) 2014-2015 UT-Battelle, LLC. All rights reserved. + Copyright (C) 2014-2020 Mellanox Technologies Ltd. All rights reserved. + Copyright (C) 2014-2015 The University of Houston System. All rights reserved. + Copyright (C) 2015 The University of Tennessee and The University + of Tennessee Research Foundation. All rights reserved. + Copyright (C) 2016-2020 ARM Ltd. All rights reserved. + Copyright (c) 2016 Los Alamos National Security, LLC. All rights reserved. + Copyright (C) 2016-2020 Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2019 UChicago Argonne, LLC. All rights reserved. + Copyright (c) 2018-2020 NVIDIA CORPORATION. All rights reserved. + Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + Copyright (C) 2016-2020 Stony Brook University. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + ----- + + From PyTorch: + + Copyright (c) 2016- Facebook, Inc (Adam Paszke) + Copyright (c) 2014- Facebook, Inc (Soumith Chintala) + Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert) + Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu) + Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu) + Copyright (c) 2011-2013 NYU (Clement Farabet) + Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston) + Copyright (c) 2006 Idiap Research Institute (Samy Bengio) + Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz) + + From Caffe2: + + Copyright (c) 2016-present, Facebook Inc. All rights reserved. + + All contributions by Facebook: + Copyright (c) 2016 Facebook Inc. + + All contributions by Google: + Copyright (c) 2015 Google Inc. + All rights reserved. + + All contributions by Yangqing Jia: + Copyright (c) 2015 Yangqing Jia + All rights reserved. + + All contributions from Caffe: + Copyright(c) 2013, 2014, 2015, the respective contributors + All rights reserved. + + All other contributions: + Copyright(c) 2015, 2016 the respective contributors + All rights reserved. + + Caffe2 uses a copyright model similar to Caffe: each contributor holds + copyright over their contributions to Caffe2. The project versioning records + all such contribution and copyright details. If a contributor wants to further + mark their specific copyright on a particular contribution, they should + indicate their copyright solely in the commit message of the change when it is + committed. + + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the names of Facebook, Deepmind Technologies, NYU, NEC Laboratories America + and IDIAP Research Institute nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +_____ + + mpi4py + https://github.com/mpi4py/mpi4py/ + + ======================= + LICENSE: MPI for Python + ======================= + + :Author: Lisandro Dalcin + :Contact: dalcinl@gmail.com + + + Copyright (c) 2019, Lisandro Dalcin. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +_____ +huggingface/transformers + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +_____ +msgpack/msgpack-python + +Copyright (C) 2008-2011 INADA Naoki + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +_____ +lanpa/tensorboardX + +MIT License + +Copyright (c) 2017 Tzu-Wei Huang + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +_____ +tensorflow/tensorboard + +Copyright 2017 The TensorFlow Authors. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017, The TensorFlow Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +_____ + +cerberus + +Cerberus is a lightweight and extensible data validation library for Python. + +ISC License + +Copyright (c) 2012-2016 Nicola Iarocci. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + +_____ + +MurmurHash3 + +MIT license + +https://github.com/aappleby/smhasher + +SMHasher is a test suite designed to test the distribution, collision, and +performance properties of non-cryptographic hash functions. +This is the home for the MurmurHash family of hash functions along with the +SMHasher test suite used to verify them. +SMHasher is released under the MIT license. +All MurmurHash versions are public domain software, and the author disclaims all copyright to their code. + +_____ + +gtest-ios-framework + +https://github.com/mestevens/gtest-ios-framework + +Copyright (c) 2013 Matthew Stevens + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +_____ + +DLPack + +https://github.com/dmlc/dlpack + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017 by Contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +_____ + +emsdk + +MIT/Expat license + +https://github.com/emscripten-core/emsdk + +Copyright (c) 2018 Emscripten authors (see AUTHORS in Emscripten) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +---------------------------------------------------------------------------- + +This is the MIT/Expat License. For more information see: + +1. http://www.opensource.org/licenses/mit-license.php + +2. http://en.wikipedia.org/wiki/MIT_License + +_____ + +coremltools + +BSD-3-Clause License + +https://github.com/apple/coremltools + +Copyright (c) 2020, Apple Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder(s) nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +© 2021 GitHub, Inc. + +_____ + +react-native + +MIT License + +https://github.com/facebook/react-native + +Copyright (c) Facebook, Inc. and its affiliates. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +_____ + +pytorch/cpuinfo + +BSD 2-Clause "Simplified" License + +https://github.com/pytorch/cpuinfo + +Copyright (c) 2019 Google LLC +Copyright (c) 2017-2018 Facebook Inc. +Copyright (C) 2012-2017 Georgia Institute of Technology +Copyright (C) 2010-2012 Marat Dukhan + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +SQLite Is Public Domain + +All of the code and documentation in SQLite has been dedicated to the public +domain by the authors. All code authors, and representatives of the companies +they work for, have signed affidavits dedicating their contributions to the +public domain and originals of those signed affidavits are stored in a firesafe +at the main offices of Hwaci. Anyone is free to copy, modify, publish, use, +compile, sell, or distribute the original SQLite code, either in source code +form or as a compiled binary, for any purpose, commercial or non-commercial, +and by any means. + +The previous paragraph applies to the deliverable code and documentation in +SQLite - those parts of the SQLite library that you actually bundle and ship +with a larger application. Some scripts used as part of the build process (for +example the "configure" scripts generated by autoconf) might fall under other +open-source licenses. Nothing from these build scripts ever reaches the final +deliverable SQLite library, however, and so the licenses associated with those +scripts should not be a factor in assessing your rights to copy and use the +SQLite library. + +All of the deliverable code in SQLite has been written from scratch. No code +has been taken from other projects or from the open internet. Every line of +code can be traced back to its original author, and all of those authors have +public domain dedications on file. So the SQLite code base is clean and is +uncontaminated with licensed code from other projects. + +_____ + +google/XNNPACK + +BSD License + +For XNNPACK software + +Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. +Copyright 2019 Google LLC + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name Facebook nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +google/sentencepiece, https://github.com/google/sentencepiece +(included when statically linked with onnxruntime-extensions) + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +_____ + +dlfcn-win32/dlfcn-win32 is licensed under the MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +_____ + +The Python Imaging Library (PIL) is + + Copyright © 1997-2011 by Secret Labs AB + Copyright © 1995-2011 by Fredrik Lundh + +Pillow is the friendly PIL fork. It is + + Copyright © 2010-2023 by Alex Clark and contributors + +Like PIL, Pillow is licensed under the open source HPND License: + +By obtaining, using, and/or copying this software and/or its associated +documentation, you agree that you have read, understood, and will comply +with the following terms and conditions: + +Permission to use, copy, modify, and distribute this software and its +associated documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appears in all copies, and that +both that copyright notice and this permission notice appear in supporting +documentation, and that the name of Secret Labs AB or the author not be +used in advertising or publicity pertaining to distribution of the software +without specific, written prior permission. + +SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR ANY SPECIAL, +INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + +_____ + +openssl/openssl, https://github.com/openssl/openssl + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + +_____ + +Tencent/rapidjson, https://github.com/Tencent/rapidjson + +Tencent is pleased to support the open source community by making RapidJSON available. + +Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. + +If you have downloaded a copy of the RapidJSON binary from Tencent, please note that the RapidJSON binary is licensed under the MIT License. +If you have downloaded a copy of the RapidJSON source code from Tencent, please note that RapidJSON source code is licensed under the MIT License, except for the third-party components listed below which are subject to different license terms. Your integration of RapidJSON into your own projects may require compliance with the MIT License, as well as the other licenses applicable to the third-party components included within RapidJSON. To avoid the problematic JSON license in your own projects, it's sufficient to exclude the bin/jsonchecker/ directory, as it's the only code under the JSON license. +A copy of the MIT License is included in this file. + +Other dependencies and licenses: + +Open Source Software Licensed Under the BSD License: +-------------------------------------------------------------------- + +The msinttypes r29 +Copyright (c) 2006-2013 Alexander Chemeris +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +* Neither the name of copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Open Source Software Licensed Under the JSON License: +-------------------------------------------------------------------- + +json.org +Copyright (c) 2002 JSON.org +All Rights Reserved. + +JSON_checker +Copyright (c) 2002 JSON.org +All Rights Reserved. + + +Terms of the JSON License: +--------------------------------------------------- + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +The Software shall be used for Good, not Evil. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +Terms of the MIT License: +-------------------------------------------------------------------- + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +_____ + +boostorg/boost, https://github.com/boostorg/boost + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +_____ + +libb64/libb64, https://github.com/libb64/libb64 + +Copyright-Only Dedication (based on United States law) or Public Domain Certification + +The person or persons who have associated work with this document (the "Dedicator" or "Certifier") hereby either (a) certifies that, to the best of his knowledge, the work of authorship identified is in the public domain of the country from which the work is published, or (b) hereby dedicates whatever copyright the dedicators holds in the work of authorship identified below (the "Work") to the public domain. A certifier, moreover, dedicates any copyright interest he may have in the associated work, and for these purposes, is described as a "dedicator" below. + +A certifier has taken reasonable steps to verify the copyright status of this work. Certifier recognizes that his good faith efforts may not shield him from liability if in fact the work certified is not in the public domain. + +Dedicator makes this dedication for the benefit of the public at large and to the detriment of the Dedicator's heirs and successors. Dedicator intends this dedication to be an overt act of relinquishment in perpetuity of all present and future rights under copyright law, whether vested or contingent, in the Work. Dedicator understands that such relinquishment of all rights includes the relinquishment of all rights to enforce (by lawsuit or otherwise) those copyrights in the Work. + +Dedicator recognizes that, once placed in the public domain, the Work may be freely reproduced, distributed, transmitted, used, modified, built upon, or otherwise exploited by anyone for any purpose, commercial or non-commercial, and in any way, including by methods that have not yet been invented or conceived. + +_____ + +posix pthread library, https://sourceforge.net/projects/pthreads4w + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +_____ + +Triton Inference Server & Client, https://github.com/triton-inference-server + +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of NVIDIA CORPORATION nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +microsoft/mimalloc, https://github.com/microsoft/mimalloc + +MIT License + +Copyright (c) 2018-2021 Microsoft Corporation, Daan Leijen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +_____ + +TensorFlow.js + +https://github.com/tensorflow/tfjs + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +—— + +curl/curl + +https://github.com/curl + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (C) Daniel Stenberg, , and many +contributors, see the THANKS file. + +All rights reserved. + +Permission to use, copy, modify, and distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright +notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of a copyright holder shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization of the copyright holder. + +_____ + +Intel neural-compressor + +https://github.com/intel/neural-compressor + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + ============================================================================ + + Copyright 2016-2019 Intel Corporation + Copyright 2018 YANDEX LLC + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + This distribution includes third party software ("third party programs"). + This third party software, even if included with the distribution of + the Intel software, may be governed by separate license terms, including + without limitation, third party license terms, other Intel software license + terms, and open source software license terms. These separate license terms + govern your use of the third party programs as set forth in the + "THIRD-PARTY-PROGRAMS" file. + +_____ + +FlashAttention, https://github.com/Dao-AILab/flash-attention + +BSD 3-Clause License + +Copyright (c) 2022, the respective contributors, as shown by the AUTHORS file. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +neural-speed + +https://github.com/intel/neural-speed + + Apache License + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + ============================================================================ + + Copyright 2016-2019 Intel Corporation + Copyright 2018 YANDEX LLC + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + This distribution includes third party software ("third party programs"). + This third party software, even if included with the distribution of + the Intel software, may be governed by separate license terms, including + without limitation, third party license terms, other Intel software license + terms, and open source software license terms. These separate license terms + govern your use of the third party programs as set forth in the + "THIRD-PARTY-PROGRAMS" file. + +_____ + +dawn + +https://dawn.googlesource.com/dawn + + BSD 3-Clause License + + Copyright 2017-2023 The Dawn & Tint Authors + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +KleidiAI + +https://gitlab.arm.com/kleidi/kleidiai + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +Copyright 2024-2025 Arm Limited and/or its affiliates + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/crates/ml/licenses/SAM2-Apache-2.0.txt b/crates/ml/licenses/SAM2-Apache-2.0.txt new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/crates/ml/licenses/SAM2-Apache-2.0.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/crates/ml/src/catalog.rs b/crates/ml/src/catalog.rs new file mode 100644 index 0000000000..d9d2287c5f --- /dev/null +++ b/crates/ml/src/catalog.rs @@ -0,0 +1,145 @@ +//! Reviewed FP32 exports. URLs contain immutable revisions; sizes and SHA-256s come from their +//! Hugging Face LFS metadata. Updating a model is a code review, never a remote manifest update. +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub enum ModelId { + #[serde(rename = "birefnet-hr-matting")] + BiRefNet, + #[serde(rename = "sam2.1-large")] + Sam2, +} + +impl ModelId { + pub fn parse(id: &str) -> Option { + match id { + "birefnet-hr-matting" => Some(Self::BiRefNet), + "sam2.1-large" => Some(Self::Sam2), + _ => None, + } + } + pub fn name(self) -> &'static str { + match self { + Self::BiRefNet => "birefnet-hr-matting", + Self::Sam2 => "sam2.1-large", + } + } + pub fn index(self) -> usize { + match self { + Self::BiRefNet => 0, + Self::Sam2 => 1, + } + } + pub fn info(self) -> &'static ModelInfo { + match self { + Self::BiRefNet => &MODELS[0], + Self::Sam2 => &MODELS[1], + } + } +} + +#[derive(Clone, Copy, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct Artifact { + pub file: &'static str, + pub url: &'static str, + pub bytes: u64, + pub sha256: &'static str, +} + +#[derive(Clone, Copy, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct ModelInfo { + pub id: ModelId, + pub label: &'static str, + pub purpose: &'static str, + pub input_side: usize, + pub revision: &'static str, + pub license: &'static str, + pub upstream: &'static str, + pub export_source: &'static str, + pub artifacts: &'static [Artifact], +} + +impl ModelInfo { + pub fn download_bytes(&self) -> u64 { + self.artifacts.iter().map(|a| a.bytes).sum() + } +} + +pub const MODELS: [ModelInfo; 2] = [ + ModelInfo { + id: ModelId::BiRefNet, + label: "BiRefNet HR Matting", + purpose: "Select Subject and Remove Background; detailed, soft edges", + input_side: 2048, + revision: "792518b9d4dfe9793891712677de25e554f948c6", + license: "MIT", + upstream: "https://huggingface.co/ZhengPeng7/BiRefNet_HR-matting", + export_source: "https://huggingface.co/PinkPixel/birefnet-hr-matting-onnx", + artifacts: &[Artifact { + file: "model.onnx", + url: "https://huggingface.co/PinkPixel/birefnet-hr-matting-onnx/resolve/792518b9d4dfe9793891712677de25e554f948c6/model.onnx", + bytes: 932_150_975, + sha256: "a548a1f3307250766bef50b174026b3cfa39a695bc1e42ec131c14fe82797ffd", + }], + }, + ModelInfo { + id: ModelId::Sam2, + label: "SAM 2.1 Large", + purpose: "Object Selection; drag a box around the object", + input_side: 1024, + revision: "3c23431f721e69cae82dbfd0c28fd692cc714021", + license: "Apache-2.0", + upstream: "https://huggingface.co/facebook/sam2.1-hiera-large", + export_source: "https://huggingface.co/onnx-community/sam2.1-hiera-large-ONNX", + artifacts: &[ + Artifact { + file: "vision_encoder.onnx", + url: "https://huggingface.co/onnx-community/sam2.1-hiera-large-ONNX/resolve/3c23431f721e69cae82dbfd0c28fd692cc714021/onnx/vision_encoder.onnx", + bytes: 1_350_487, + sha256: "ad3a8161c6bd6d8beea811300c60e20d626035feaa3c19622ace27b22e25bec8", + }, + Artifact { + file: "vision_encoder.onnx_data", + url: "https://huggingface.co/onnx-community/sam2.1-hiera-large-ONNX/resolve/3c23431f721e69cae82dbfd0c28fd692cc714021/onnx/vision_encoder.onnx_data", + bytes: 888_587_456, + sha256: "88c501a65b6aaeac99b65a275f3f559727404283930d107d499fda8714ba7e5a", + }, + Artifact { + file: "prompt_encoder_mask_decoder.onnx", + url: "https://huggingface.co/onnx-community/sam2.1-hiera-large-ONNX/resolve/3c23431f721e69cae82dbfd0c28fd692cc714021/onnx/prompt_encoder_mask_decoder.onnx", + bytes: 213_114, + sha256: "a21b3b09f6e5f5838d630d92a150914ca58f8f58b603b8f53fc32b03da982203", + }, + Artifact { + file: "prompt_encoder_mask_decoder.onnx_data", + url: "https://huggingface.co/onnx-community/sam2.1-hiera-large-ONNX/resolve/3c23431f721e69cae82dbfd0c28fd692cc714021/onnx/prompt_encoder_mask_decoder.onnx_data", + bytes: 20_958_208, + sha256: "bfdcd4f7ee04298a82fe1aaf1bd7b8edf544d36901e1a886f01892fb915bd63c", + }, + ], + }, +]; + +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn catalog_is_pinned_and_ids_cannot_escape_storage() { + for m in MODELS { + assert_eq!(ModelId::parse(m.id.name()), Some(m.id)); + for a in m.artifacts { + assert!(a.url.starts_with("https://huggingface.co/")); + assert!(a.url.contains(m.revision)); + assert!(a.bytes > 0 && a.bytes < 2_000_000_000); + assert_eq!(a.sha256.len(), 64); + assert!(a.sha256.bytes().all(|c| c.is_ascii_hexdigit())); + assert!(!a.file.contains(['/', '\\'])); + } + } + for id in ["../model", "sam3", "", "https://example.com/model.onnx"] { + assert_eq!(ModelId::parse(id), None); + } + } +} diff --git a/crates/ml/src/image.rs b/crates/ml/src/image.rs new file mode 100644 index 0000000000..2381674e27 --- /dev/null +++ b/crates/ml/src/image.rs @@ -0,0 +1,127 @@ +use photocraft_algo::segment::RgbImage; +use photocraft_raster::Interrupt; + +use crate::{Error, Result, check}; + +const MAX_PIXELS: usize = 2048 * 2048; + +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum MaskKind { + /// A matting model's continuous opacity, interpolated without thresholding. + Alpha, + /// SAM logits: interpolate at destination resolution, then threshold at zero. + Logits, +} + +#[derive(Clone, Debug)] +pub struct AlphaMask { + pub width: usize, + pub height: usize, + pub values: Vec, + pub kind: MaskKind, +} + +impl AlphaMask { + pub fn validate(&self) -> Result<()> { + let n = self.width.checked_mul(self.height).filter(|n| *n > 0 && *n <= MAX_PIXELS); + if n != Some(self.values.len()) || self.values.iter().any(|v| !v.is_finite()) { + return Err(Error::Inference("invalid mask dimensions or non-finite values".into())); + } + Ok(()) + } + + /// Bilinear, half-pixel centres, with border clamping. Coordinates are normalized to the + /// source image, so non-square documents and prompts use the same mapping. + pub fn sample(&self, x: f32, y: f32) -> f32 { + bilinear(self.width, self.height, x, y, |i| self.values.get(i).copied().unwrap_or(0.0)) + } + + pub fn coverage(&self, x: f32, y: f32) -> u8 { + let v = self.sample(x, y); + match self.kind { + MaskKind::Alpha => (v.clamp(0.0, 1.0) * 255.0).round() as u8, + MaskKind::Logits => { + if v > 0.0 { + 255 + } else { + 0 + } + } + } + } +} + +fn bilinear(w: usize, h: usize, x: f32, y: f32, at: impl Fn(usize) -> f32) -> f32 { + if w.checked_mul(h).is_none_or(|n| n == 0 || n > MAX_PIXELS) || !x.is_finite() || !y.is_finite() { + return 0.0; + } + let x = (x * w as f32 - 0.5).clamp(0.0, (w - 1) as f32); + let y = (y * h as f32 - 0.5).clamp(0.0, (h - 1) as f32); + let (x0, y0) = (x.floor() as usize, y.floor() as usize); + let (x1, y1) = ((x0 + 1).min(w - 1), (y0 + 1).min(h - 1)); + let (fx, fy) = (x - x0 as f32, y - y0 as f32); + let a = at(y0 * w + x0) * (1.0 - fx) + at(y0 * w + x1) * fx; + let b = at(y1 * w + x0) * (1.0 - fx) + at(y1 * w + x1) * fx; + a * (1.0 - fy) + b * fy +} + +/// Model RGB is sRGB in 0..=1, resized to its training square and ImageNet-normalized NCHW. +/// The engine is responsible for converting the document profile before reaching this seam. +pub fn normalize(image: &RgbImage, side: usize, ctl: &Interrupt<'_>) -> Result> { + let n = image.w.checked_mul(image.h).filter(|n| *n > 0 && *n <= MAX_PIXELS); + let plane = side.checked_mul(side).filter(|n| *n > 0 && *n <= MAX_PIXELS); + if n != Some(image.px.len()) || plane.is_none() || image.px.iter().flatten().any(|v| !v.is_finite()) { + return Err(Error::Input("invalid image dimensions or values".into())); + } + let plane = plane.ok_or_else(|| Error::Input("invalid input size".into()))?; + let mut out = vec![0.0; plane * 3]; + let mean = [0.485, 0.456, 0.406]; + let std = [0.229, 0.224, 0.225]; + for (c, channel) in out.chunks_exact_mut(plane).enumerate() { + for (y, row) in channel.chunks_exact_mut(side).enumerate() { + check(ctl)?; + for (x, dst) in row.iter_mut().enumerate() { + let v = bilinear(image.w, image.h, (x as f32 + 0.5) / side as f32, (y as f32 + 0.5) / side as f32, |i| { + image.px.get(i).and_then(|p| p.get(c)).copied().unwrap_or(0.0) + }); + *dst = (v.clamp(0.0, 1.0) - mean.get(c).copied().unwrap_or(0.0)) / std.get(c).copied().unwrap_or(1.0); + } + } + } + Ok(out) +} + +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn normalized_rgb_uses_channels_first_and_keeps_aspect_mapping() { + let im = RgbImage { w: 2, h: 1, px: vec![[1.0, 0.0, 0.5], [0.0, 1.0, 0.5]] }; + let v = normalize(&im, 2, &Interrupt::NONE).unwrap(); + assert_eq!(v.len(), 12); + assert!((v[0] - (1.0 - 0.485) / 0.229).abs() < 1e-6); + assert!((v[5] - (1.0 - 0.456) / 0.224).abs() < 1e-6); + assert_eq!(v[0], v[2]); + assert_eq!(v[8], v[11]); + } + #[test] + fn matting_preserves_fractional_coverage_and_sam_thresholds_after_resize() { + let mut m = AlphaMask { width: 2, height: 1, values: vec![0.0, 1.0], kind: MaskKind::Alpha }; + assert_eq!(m.coverage(0.5, 0.5), 128); + assert_eq!(m.coverage(0.0, 0.5), 0); + assert_eq!(m.coverage(1.0, 0.5), 255); + m.kind = MaskKind::Logits; + m.values = vec![-2.0, 2.0]; + assert_eq!(m.coverage(0.75, 0.5), 255); + assert_eq!(m.coverage(0.25, 0.5), 0); + } + #[test] + fn malformed_tensors_and_cancellation_fail_gracefully() { + let im = RgbImage { w: usize::MAX, h: 2, px: vec![] }; + assert!(normalize(&im, 2048, &Interrupt::NONE).is_err()); + let m = AlphaMask { width: 1, height: 1, values: vec![f32::NAN], kind: MaskKind::Alpha }; + assert!(m.validate().is_err()); + let im = RgbImage { w: 1, h: 1, px: vec![[0.0; 3]] }; + assert!(matches!(normalize(&im, 2, &Interrupt::cancel_only(&|| true)), Err(Error::Cancelled))); + } +} diff --git a/crates/ml/src/lib.rs b/crates/ml/src/lib.rs new file mode 100644 index 0000000000..2d633be5b5 --- /dev/null +++ b/crates/ml/src/lib.rs @@ -0,0 +1,68 @@ +//! Optional, local image segmentation. The default build contains only the model catalogue and +//! the backend seam; `onnx` adds native CPU inference and explicit, verified downloads. +#![forbid(unsafe_code)] +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] + +pub mod catalog; +mod image; +pub use catalog::{MODELS, ModelId, ModelInfo}; +pub use image::{AlphaMask, MaskKind, normalize}; + +#[cfg(all(feature = "onnx", not(target_arch = "wasm32")))] +mod native; +#[cfg(all(feature = "onnx", not(target_arch = "wasm32")))] +pub use native::NativeBackend; + +#[cfg(all(test, feature = "onnx", not(target_arch = "wasm32")))] +mod test_models; + +use photocraft_algo::segment::RgbImage; +use photocraft_raster::Interrupt; +use serde::Serialize; + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error("cancelled")] + Cancelled, + #[error("invalid model input: {0}")] + Input(String), + #[error("local model unavailable: {0}")] + Unavailable(String), + #[error("model download: {0}")] + Download(String), + #[error("model inference: {0}")] + Inference(String), + #[error("model storage: {0}")] + Io(#[from] std::io::Error), +} + +pub type Result = std::result::Result; + +pub(crate) fn check(ctl: &Interrupt<'_>) -> Result<()> { + ctl.check().map_err(|_| Error::Cancelled) +} + +/// Coordinates relative to the full input image, in 0..=1. A box guides SAM to one object; +/// automatic foreground matting uses `Subject`. +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum Prompt { + Subject, + Box([f32; 4]), +} + +#[derive(Clone, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct ModelStatus { + pub id: ModelId, + pub installed: bool, + pub busy: bool, +} + +/// No document or UI types cross this seam. Tests can inject a deterministic backend; the web +/// and builds without `onnx` keep the existing classical algorithms and never access the network. +pub trait InferenceBackend: Send + Sync { + fn status(&self) -> Vec; + fn download(&self, id: ModelId, ctl: &Interrupt<'_>) -> Result<()>; + fn remove(&self, id: ModelId, ctl: &Interrupt<'_>) -> Result<()>; + fn infer(&self, id: ModelId, image: &RgbImage, prompt: Prompt, ctl: &Interrupt<'_>) -> Result; +} diff --git a/crates/ml/src/native.rs b/crates/ml/src/native.rs new file mode 100644 index 0000000000..25f61d195d --- /dev/null +++ b/crates/ml/src/native.rs @@ -0,0 +1,542 @@ +//! Native CPU backend. Model installation is explicit; inference never downloads anything. +use std::fs::{self, File}; +use std::io::{Read, Write}; +use std::path::{Path, PathBuf}; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{Arc, Mutex, MutexGuard, PoisonError}; +use std::time::Duration; + +use ort::session::{RunOptions, Session as OnnxSession, builder::GraphOptimizationLevel}; +use ort::value::Tensor; +use photocraft_algo::segment::RgbImage; +use photocraft_raster::Interrupt; +use sha2::{Digest, Sha256}; +use ureq::unversioned::transport::{Buffers, ConnectionDetails, Connector, DefaultConnector, NextTimeout, Transport}; + +use crate::catalog::Artifact; +use crate::{AlphaMask, Error, InferenceBackend, MaskKind, ModelId, ModelStatus, Prompt, Result, check, normalize}; + +impl From> for Error { + fn from(e: ort::Error) -> Self { + Self::Inference(e.to_string()) + } +} + +/// Platform frontends choose the directory. Constructing a backend does not create it, contact +/// a server, load ONNX Runtime or load any model. At most one model stays resident at a time. +pub struct NativeBackend { + root: PathBuf, + operations: [Mutex<()>; 2], + sessions: Mutex>, +} + +enum Sessions { + BiRefNet(OnnxSession), + Sam2 { encoder: OnnxSession, decoder: OnnxSession }, +} + +struct Loaded { + id: ModelId, + sessions: Sessions, +} + +/// ureq's body timeout covers the whole download, rather than each read. Keep large downloads +/// possible while bounding stalled reads (and cancellation cleanup) to 30 seconds. Delegate TLS, +/// redirects and proxy handling to its default connector; never weaken certificate validation. +#[derive(Debug)] +struct IdleConnector; +#[derive(Debug)] +struct IdleTransport(Box); +impl Connector for IdleConnector { + type Out = IdleTransport; + fn connect(&self, details: &ConnectionDetails<'_>, chained: Option<()>) -> std::result::Result, ureq::Error> { + Ok(DefaultConnector::default().connect(details, chained)?.map(IdleTransport)) + } +} +fn idle_timeout(timeout: NextTimeout) -> NextTimeout { + let after = ureq::unversioned::transport::time::Duration::from_secs(30); + if *timeout.after > *after { NextTimeout { after, reason: ureq::Timeout::RecvBody } } else { timeout } +} +impl Transport for IdleTransport { + fn buffers(&mut self) -> &mut dyn Buffers { + self.0.buffers() + } + fn transmit_output(&mut self, amount: usize, timeout: NextTimeout) -> std::result::Result<(), ureq::Error> { + self.0.transmit_output(amount, timeout) + } + fn await_input(&mut self, timeout: NextTimeout) -> std::result::Result { + self.0.await_input(idle_timeout(timeout)) + } + fn is_open(&mut self) -> bool { + self.0.is_open() + } + fn is_tls(&self) -> bool { + self.0.is_tls() + } +} + +impl NativeBackend { + pub fn new(root: PathBuf) -> Self { + Self { root, operations: Default::default(), sessions: Mutex::new(None) } + } + + fn directory(&self, id: ModelId) -> PathBuf { + self.root.join(format!("{}-{}", id.name(), id.info().revision)) + } + + fn operation(&self, id: ModelId) -> Result> { + let lock = self.operations.get(id.index()).ok_or_else(|| Error::Input("unknown model".into()))?; + match lock.try_lock() { + Ok(guard) => Ok(guard), + Err(std::sync::TryLockError::Poisoned(e)) => { + lock.clear_poison(); + Ok(e.into_inner()) + } + Err(std::sync::TryLockError::WouldBlock) => { + Err(Error::Unavailable(format!("{} is in use or downloading; try again when it finishes", id.info().label))) + } + } + } + + fn installed(&self, id: ModelId) -> bool { + let dir = self.directory(id); + fs::symlink_metadata(&dir).is_ok_and(|m| m.is_dir()) + && id.info().artifacts.iter().all(|a| fs::symlink_metadata(dir.join(a.file)).is_ok_and(|m| m.is_file() && m.len() == a.bytes)) + } + + fn verify(&self, id: ModelId, ctl: &Interrupt<'_>) -> Result<()> { + if !self.installed(id) { + return Err(Error::Unavailable(format!("download {} in Preferences › Integrations first", id.info().label))); + } + for a in id.info().artifacts { + check(ctl)?; + // Hash before parsing, including external weights. No ONNX from a mutable URL or an + // unverified local file is executed, and external data paths are pinned with it. + copy_verified(&mut File::open(self.directory(id).join(a.file))?, &mut std::io::sink(), a, ctl, |_| {})?; + } + Ok(()) + } +} + +impl InferenceBackend for NativeBackend { + fn status(&self) -> Vec { + crate::MODELS + .iter() + .map(|m| ModelStatus { + id: m.id, + installed: self.installed(m.id), + busy: self.operations.get(m.id.index()).is_some_and(|l| matches!(l.try_lock(), Err(std::sync::TryLockError::WouldBlock))), + }) + .collect() + } + + fn download(&self, id: ModelId, ctl: &Interrupt<'_>) -> Result<()> { + let _guard = self.operation(id)?; + check(ctl)?; + if self.installed(id) { + self.verify(id, ctl)?; + ctl.progress(1.0); + return Ok(()); + } + let dest = self.directory(id); + if dest.try_exists()? { + return Err(Error::Download("incomplete or corrupt installation; remove this model in Preferences and download it again".into())); + } + fs::create_dir_all(&self.root)?; + // Every error, timeout or cancellation drops the staging directory. Windows rename is + // atomic too because the destination does not exist; installed files are never overwritten. + let staging = tempfile::Builder::new().prefix("photocraft-model-").tempdir_in(&self.root)?; + let config = ureq::Agent::config_builder() + .https_only(true) + .max_redirects(5) + .timeout_resolve(Some(Duration::from_secs(15))) + .timeout_connect(Some(Duration::from_secs(15))) + .timeout_recv_response(Some(Duration::from_secs(30))) + .timeout_recv_body(Some(Duration::from_secs(3600))) + .build(); + let agent = ureq::Agent::with_parts(config, IdleConnector, ureq::unversioned::resolver::DefaultResolver::default()); + let total = id.info().download_bytes() as f32; + let mut completed = 0u64; + for a in id.info().artifacts { + check(ctl)?; + let mut response = agent + .get(a.url) + .header("User-Agent", "PhotoCraft-model-download") + .call() + .map_err(|e| Error::Download(format!("{}: {e}; try again", a.file)))?; + let mut file = File::create(staging.path().join(a.file))?; + copy_verified(&mut response.body_mut().as_reader(), &mut file, a, ctl, |bytes| ctl.progress((completed + bytes) as f32 / total * 0.98)).map_err( + |e| match e { + Error::Cancelled => e, + e => Error::Download(format!("{}: {e}; partial download discarded; try again", a.file)), + }, + )?; + file.flush()?; + file.sync_all()?; + completed += a.bytes; + } + let license = match id { + ModelId::BiRefNet => include_str!("../licenses/BiRefNet-MIT.txt"), + ModelId::Sam2 => include_str!("../licenses/SAM2-Apache-2.0.txt"), + }; + fs::write(staging.path().join("LICENSE.txt"), license)?; + fs::write( + staging.path().join("SOURCE.txt"), + format!("{}\nUpstream: {}\nONNX export: {}\nRevision: {}\n", id.info().label, id.info().upstream, id.info().export_source, id.info().revision), + )?; + check(ctl)?; + fs::rename(staging.path(), dest)?; + ctl.progress(1.0); + Ok(()) + } + + fn remove(&self, id: ModelId, ctl: &Interrupt<'_>) -> Result<()> { + let _guard = self.operation(id)?; + check(ctl)?; + let mut loaded = self.sessions.lock().unwrap_or_else(PoisonError::into_inner); + check(ctl)?; + if loaded.as_ref().is_some_and(|l| l.id == id) { + // Close external weight files before removing on Windows. + *loaded = None; + } + let path = self.directory(id); + if path.try_exists()? { + if !fs::symlink_metadata(&path)?.is_dir() { + return Err(Error::Unavailable("model installation is not a regular directory".into())); + } + fs::remove_dir_all(path)?; + } + ctl.progress(1.0); + Ok(()) + } + + fn infer(&self, id: ModelId, image: &RgbImage, prompt: Prompt, ctl: &Interrupt<'_>) -> Result { + let _guard = self.operation(id)?; + validate_prompt(id, prompt)?; + let input = normalize(image, id.info().input_side, ctl)?; + self.verify(id, ctl)?; + let mut loaded = match self.sessions.try_lock() { + Ok(guard) => guard, + Err(std::sync::TryLockError::Poisoned(e)) => { + let mut guard = e.into_inner(); + *guard = None; + self.sessions.clear_poison(); + guard + } + Err(std::sync::TryLockError::WouldBlock) => return Err(Error::Unavailable("another local model is running; try again when it finishes".into())), + }; + if loaded.as_ref().is_none_or(|l| l.id != id) { + *loaded = None; + check(ctl)?; + let dir = self.directory(id); + let sessions = match id { + ModelId::BiRefNet => Sessions::BiRefNet(session(&dir.join("model.onnx"))?), + ModelId::Sam2 => { + Sessions::Sam2 { encoder: session(&dir.join("vision_encoder.onnx"))?, decoder: session(&dir.join("prompt_encoder_mask_decoder.onnx"))? } + } + }; + *loaded = Some(Loaded { id, sessions }); + } + check(ctl)?; + ctl.progress(0.2); + let current = loaded.as_mut().ok_or_else(|| Error::Inference("model did not load".into()))?; + let result = match &mut current.sessions { + Sessions::BiRefNet(model) => birefnet(model, input, ctl), + Sessions::Sam2 { encoder, decoder } => sam2(encoder, decoder, input, prompt, ctl), + }?; + result.validate()?; + check(ctl)?; + ctl.progress(1.0); + Ok(result) + } +} + +fn validate_prompt(id: ModelId, p: Prompt) -> Result<()> { + match (id, p) { + (ModelId::BiRefNet, Prompt::Subject) => Ok(()), + (ModelId::Sam2, Prompt::Box([x0, y0, x1, y1])) if [x0, y0, x1, y1].iter().all(|v| v.is_finite() && (0.0..=1.0).contains(v)) && x0 < x1 && y0 < y1 => { + Ok(()) + } + _ => Err(Error::Input("this model does not support the requested prompt".into())), + } +} + +fn session(path: &Path) -> Result { + let threads = std::thread::available_parallelism().map_or(2, |v| v.get()).clamp(1, 8); + // Keeping weights resident is useful, but retaining peak 2048px intermediates in an arena + // (then allocating a contiguous memory-pattern block on the second run) can exhaust RAM. + // Prefer releasing temporary buffers over latency: these models are explicitly optional. + Ok(OnnxSession::builder()? + .with_execution_providers([ort::ep::CPU::default().with_arena_allocator(false).build()])? + .with_memory_pattern(false)? + .with_intra_threads(threads)? + .with_optimization_level(GraphOptimizationLevel::Level3)? + .commit_from_file(path)?) +} + +/// ORT supports terminating a run from another thread. The watcher exits at completion or +/// cancellation; it owns no document and never outlives the job. No fictitious per-node progress. +fn cancellable(ctl: &Interrupt<'_>, f: impl FnOnce(&RunOptions) -> Result) -> Result { + check(ctl)?; + let options = Arc::new(RunOptions::new()?); + let done = AtomicBool::new(false); + std::thread::scope(|scope| { + let monitor = std::thread::Builder::new().name("photocraft-model-cancel".into()).spawn_scoped(scope, || { + while !done.load(Ordering::Relaxed) { + if ctl.cancelled() { + let _ = options.terminate(); + break; + } + std::thread::sleep(Duration::from_millis(25)); + } + })?; + // Release the scoped watcher even if a dependency unexpectedly unwinds: the engine's + // last-resort panic guard must be able to report it instead of hanging while joining. + struct Complete<'a>(&'a AtomicBool); + impl Drop for Complete<'_> { + fn drop(&mut self) { + self.0.store(true, Ordering::Relaxed); + } + } + let complete = Complete(&done); + let result = f(&options); + drop(complete); + monitor.join().map_err(|_| Error::Inference("cancellation watcher failed".into()))?; + check(ctl)?; + result + }) +} + +fn birefnet(model: &mut OnnxSession, input: Vec, ctl: &Interrupt<'_>) -> Result { + let tensor = Tensor::from_array(([1usize, 3, 2048, 2048], input.into_boxed_slice()))?; + cancellable(ctl, |options| { + let outputs = model.run_with_options(ort::inputs!["image" => tensor], options)?; + let output = outputs.get("alpha").ok_or_else(|| Error::Inference("BiRefNet export has no alpha output".into()))?; + let (shape, values) = output.try_extract_tensor::()?; + if shape.as_ref() != [1, 1, 2048, 2048] { + return Err(Error::Inference("unexpected BiRefNet output shape".into())); + } + // This reviewed export already includes sigmoid: applying it twice turns backgrounds gray. + Ok(AlphaMask { width: 2048, height: 2048, values: values.to_vec(), kind: MaskKind::Alpha }) + }) +} + +fn sam2(encoder: &mut OnnxSession, decoder: &mut OnnxSession, input: Vec, prompt: Prompt, ctl: &Interrupt<'_>) -> Result { + let Prompt::Box(bbox) = prompt else { return Err(Error::Input("SAM needs a box".into())) }; + let image = Tensor::from_array(([1usize, 3, 1024, 1024], input.into_boxed_slice()))?; + let (e0, e1, e2) = cancellable(ctl, |options| { + let outputs = encoder.run_with_options(ort::inputs!["pixel_values" => image], options)?; + let embedding = |name| -> Result> { + let v = outputs.get(name).ok_or_else(|| Error::Inference(format!("SAM export has no {name} output")))?; + let (shape, values) = v.try_extract_tensor::()?; + Ok(Tensor::from_array((shape.to_vec(), values.to_vec().into_boxed_slice()))?) + }; + Ok((embedding("image_embeddings.0")?, embedding("image_embeddings.1")?, embedding("image_embeddings.2")?)) + })?; + ctl.progress(0.85); + // A padding point is ignored by SAM; the box supplies corner labels 2 and 3 inside the + // decoder. The reviewed export uses int64 labels and coordinates on its 1024-pixel square. + let points = Tensor::from_array(([1usize, 1, 1, 2], vec![0.0f32; 2].into_boxed_slice()))?; + let labels = Tensor::from_array(([1usize, 1, 1], vec![-1i64].into_boxed_slice()))?; + let boxes = Tensor::from_array(([1usize, 1, 4], bbox.map(|v| v * 1024.0).to_vec().into_boxed_slice()))?; + cancellable(ctl, |options| { + let outputs = decoder.run_with_options( + ort::inputs![ + "input_points" => points, + "input_labels" => labels, + "input_boxes" => boxes, + "image_embeddings.0" => e0, + "image_embeddings.1" => e1, + "image_embeddings.2" => e2, + ], + options, + )?; + let masks = outputs.get("pred_masks").ok_or_else(|| Error::Inference("SAM has no mask output".into()))?; + let scores = outputs.get("iou_scores").ok_or_else(|| Error::Inference("SAM has no score output".into()))?; + let (shape, values) = masks.try_extract_tensor::()?; + let (_, scores) = scores.try_extract_tensor::()?; + sam_mask(shape.as_ref(), values, scores) + }) +} + +fn sam_mask(shape: &[i64], values: &[f32], scores: &[f32]) -> Result { + let [1, 1, count, height, width] = shape else { return Err(Error::Inference("unexpected SAM output shape".into())) }; + if ![count, height, width].iter().all(|v| **v > 0) + || *count > 3 + || *height > 2048 + || *width > 2048 + || scores.len() != *count as usize + || scores.iter().any(|v| !v.is_finite()) + { + return Err(Error::Inference("invalid SAM mask dimensions or scores".into())); + } + let plane = (*width as usize).checked_mul(*height as usize).ok_or_else(|| Error::Inference("mask too large".into()))?; + if values.len() != plane * *count as usize { + return Err(Error::Inference("SAM mask length mismatch".into())); + } + let best = scores.iter().enumerate().max_by(|(_, a), (_, b)| a.total_cmp(b)).map_or(0, |(i, _)| i); + let chosen = values.get(best * plane..(best + 1) * plane).ok_or_else(|| Error::Inference("SAM mask missing".into()))?; + Ok(AlphaMask { width: *width as usize, height: *height as usize, values: chosen.to_vec(), kind: MaskKind::Logits }) +} + +fn copy_verified(reader: &mut dyn Read, writer: &mut dyn Write, artifact: &Artifact, ctl: &Interrupt<'_>, progress: impl Fn(u64)) -> Result<()> { + let mut hasher = Sha256::new(); + let mut buffer = [0u8; 64 * 1024]; + let mut count = 0u64; + loop { + check(ctl)?; + let read = reader.read(&mut buffer)?; + if read == 0 { + break; + } + count = count.checked_add(read as u64).ok_or_else(|| Error::Download("download too large".into()))?; + if count > artifact.bytes { + return Err(Error::Download(format!("{} exceeds its pinned size", artifact.file))); + } + let chunk = buffer.get(..read).ok_or_else(|| Error::Download("invalid read length".into()))?; + writer.write_all(chunk)?; + hasher.update(chunk); + progress(count); + } + check(ctl)?; + if count != artifact.bytes || format!("{:x}", hasher.finalize()) != artifact.sha256 { + return Err(Error::Download(format!("{} failed size/SHA-256 verification; no model was installed", artifact.file))); + } + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + const ABC: Artifact = Artifact { + file: "test.onnx", + url: "https://example.invalid/test.onnx", + bytes: 3, + sha256: "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", + }; + + #[test] + fn stalled_reads_are_bounded_without_shortening_a_stricter_deadline() { + use ureq::unversioned::transport::time::Duration; + let t = NextTimeout { after: Duration::NotHappening, reason: ureq::Timeout::RecvBody }; + assert_eq!(idle_timeout(t).after, Duration::from_secs(30)); + let t = NextTimeout { after: Duration::from_secs(3), reason: ureq::Timeout::Global }; + assert_eq!(idle_timeout(t), t); + } + + #[test] + fn cancellation_watcher_exits_when_a_dependency_unwinds() { + let started = std::time::Instant::now(); + let r = std::panic::catch_unwind(|| cancellable::<()>(&Interrupt::NONE, |_| panic!("synthetic dependency panic"))); + assert!(r.is_err()); + assert!(started.elapsed() < Duration::from_secs(1)); + } + + #[test] + fn a_dependency_panic_does_not_leave_the_model_permanently_busy() { + let temp = tempfile::tempdir().unwrap(); + let backend = NativeBackend::new(temp.path().into()); + let _ = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let _guard = backend.operation(ModelId::Sam2).unwrap(); + panic!("synthetic dependency panic"); + })); + assert!(backend.status().iter().all(|s| !s.busy)); + assert!(backend.operation(ModelId::Sam2).is_ok()); + } + + #[test] + fn cpu_runtime_executes_both_export_contracts_without_downloads() { + let dir = tempfile::tempdir().unwrap(); + for (name, bytes) in + [("matte.onnx", crate::test_models::MATTE), ("encoder.onnx", crate::test_models::ENCODER), ("decoder.onnx", crate::test_models::DECODER)] + { + fs::write(dir.path().join(name), bytes).unwrap(); + } + let mut matte = session(&dir.path().join("matte.onnx")).unwrap(); + let alpha = birefnet(&mut matte, vec![0.0; 3 * 2048 * 2048], &Interrupt::NONE).unwrap(); + assert_eq!(alpha.kind, MaskKind::Alpha); + assert!(alpha.values.iter().all(|v| (*v - 0.5).abs() < 1e-6)); + let mut encoder = session(&dir.path().join("encoder.onnx")).unwrap(); + let mut decoder = session(&dir.path().join("decoder.onnx")).unwrap(); + let mask = sam2(&mut encoder, &mut decoder, vec![0.0; 3 * 1024 * 1024], Prompt::Box([0.1, 0.2, 0.9, 0.8]), &Interrupt::NONE).unwrap(); + assert_eq!(mask.kind, MaskKind::Logits); + assert_eq!(mask.values, vec![1.0, 2.0]); + assert!(matches!(birefnet(&mut matte, vec![0.0; 3 * 2048 * 2048], &Interrupt::cancel_only(&|| true)), Err(Error::Cancelled))); + } + + #[test] + fn verified_stream_rejects_truncation_corruption_overflow_and_cancel() { + let mut out = Vec::new(); + copy_verified(&mut &b"abc"[..], &mut out, &ABC, &Interrupt::NONE, |_| {}).unwrap(); + assert_eq!(out, b"abc"); + for input in [b"ab".as_slice(), b"abd".as_slice(), b"abcd".as_slice()] { + assert!(copy_verified(&mut &input[..], &mut Vec::new(), &ABC, &Interrupt::NONE, |_| {}).is_err()); + } + assert!(matches!(copy_verified(&mut &b"abc"[..], &mut Vec::new(), &ABC, &Interrupt::cancel_only(&|| true), |_| {}), Err(Error::Cancelled))); + } + + #[test] + fn constructing_and_querying_a_backend_does_not_create_a_directory_or_download() { + let temp = tempfile::tempdir().unwrap(); + let root = temp.path().join("models"); + let b = NativeBackend::new(root.clone()); + assert!(b.status().iter().all(|m| !m.installed)); + assert!(!root.exists()); + assert!(b.infer(ModelId::BiRefNet, &RgbImage::new(1, 1), Prompt::Subject, &Interrupt::NONE).is_err()); + assert!(!root.exists()); + } + + #[test] + fn remove_is_scoped_to_the_selected_model_and_busy_models_are_protected() { + let temp = tempfile::tempdir().unwrap(); + let b = NativeBackend::new(temp.path().into()); + let dir = b.directory(ModelId::BiRefNet); + fs::create_dir_all(&dir).unwrap(); + fs::write(dir.join("partial"), b"bad").unwrap(); + let unrelated = temp.path().join("preferences.json"); + fs::write(&unrelated, b"keep").unwrap(); + let guard = b.operation(ModelId::BiRefNet).unwrap(); + assert!(b.remove(ModelId::BiRefNet, &Interrupt::NONE).is_err()); + drop(guard); + b.remove(ModelId::BiRefNet, &Interrupt::NONE).unwrap(); + assert!(!dir.exists()); + assert_eq!(fs::read(unrelated).unwrap(), b"keep"); + } + + #[test] + fn sam_selects_the_highest_scoring_mask_and_rejects_bad_shapes() { + let m = sam_mask(&[1, 1, 3, 1, 2], &[-1.0, -1.0, 1.0, 2.0, 9.0, 9.0], &[0.2, 0.9, 0.4]).unwrap(); + assert_eq!(m.values, vec![1.0, 2.0]); + assert!(sam_mask(&[1, 1, i64::MAX, 1, 2], &[], &[]).is_err()); + assert!(sam_mask(&[1, 1, 1, 1, 2], &[0.0], &[1.0]).is_err()); + assert!(validate_prompt(ModelId::Sam2, Prompt::Box([0.0, 0.0, f32::NAN, 1.0])).is_err()); + } + + /// Explicit developer opt-in only. No normal test or first launch downloads weights. + #[test] + #[ignore = "requires PHOTOCRAFT_MODEL_TEST_DIR; PHOTOCRAFT_MODEL_TEST_DOWNLOAD=1 explicitly downloads ~1.8 GB"] + fn real_models_cpu_smoke() { + let root = std::env::var_os("PHOTOCRAFT_MODEL_TEST_DIR").expect("set a dedicated model test directory"); + let backend = NativeBackend::new(root.into()); + let mut image = RgbImage::new(192, 128); + for (i, p) in image.px.iter_mut().enumerate() { + let (x, y) = ((i % 192) as i32 - 96, (i / 192) as i32 - 64); + *p = if x * x + y * y < 45 * 45 { [0.9, 0.2, 0.1] } else { [0.1, 0.4, 0.7] }; + } + if std::env::var("PHOTOCRAFT_MODEL_TEST_DOWNLOAD").as_deref() == Ok("1") { + for id in [ModelId::BiRefNet, ModelId::Sam2] { + eprintln!("Downloading / verifying {}", id.name()); + backend.download(id, &Interrupt::NONE).unwrap(); + } + } + for id in [ModelId::BiRefNet, ModelId::Sam2] { + let prompt = if id == ModelId::Sam2 { Prompt::Box([0.2, 0.1, 0.8, 0.9]) } else { Prompt::Subject }; + let start = std::time::Instant::now(); + let mask = backend.infer(id, &image, prompt, &Interrupt::NONE).unwrap(); + mask.validate().unwrap(); + assert!(mask.values.iter().any(|v| v.abs() > 0.01)); + eprintln!("{} CPU: {:.2}s; mask {}x{}", id.name(), start.elapsed().as_secs_f64(), mask.width, mask.height); + } + } +} diff --git a/crates/ml/src/test_models.rs b/crates/ml/src/test_models.rs new file mode 100644 index 0000000000..fd31fccbb5 --- /dev/null +++ b/crates/ml/src/test_models.rs @@ -0,0 +1,45 @@ +//! Original synthetic ONNX protobufs: channel mean → sigmoid; constant embeddings; three +//! scored masks. No learned weights, network, Python runtime or external assets in CI. +//! Shapes and names deliberately match the reviewed export adapters, not model quality. +pub(super) const MATTE: &[u8] = &[ + 8, 9, 58, 237, 1, 10, 43, 18, 4, 97, 120, 101, 115, 34, 8, 67, 111, 110, 115, 116, 97, 110, 116, 42, 25, 10, 5, 118, 97, 108, 117, 101, 42, 13, 8, 1, 16, + 7, 58, 1, 1, 66, 4, 97, 120, 101, 115, 160, 1, 4, 10, 48, 10, 5, 105, 109, 97, 103, 101, 10, 4, 97, 120, 101, 115, 18, 4, 109, 101, 97, 110, 34, 10, 82, + 101, 100, 117, 99, 101, 77, 101, 97, 110, 42, 15, 10, 8, 107, 101, 101, 112, 100, 105, 109, 115, 24, 1, 160, 1, 2, 10, 22, 10, 4, 109, 101, 97, 110, 18, 5, + 97, 108, 112, 104, 97, 34, 7, 83, 105, 103, 109, 111, 105, 100, 18, 46, 80, 104, 111, 116, 111, 67, 114, 97, 102, 116, 32, 111, 114, 105, 103, 105, 110, + 97, 108, 32, 115, 121, 110, 116, 104, 101, 116, 105, 99, 32, 99, 111, 110, 116, 114, 97, 99, 116, 32, 102, 105, 120, 116, 117, 114, 101, 90, 33, 10, 5, + 105, 109, 97, 103, 101, 18, 24, 10, 22, 8, 1, 18, 18, 10, 2, 8, 1, 10, 2, 8, 3, 10, 3, 8, 128, 16, 10, 3, 8, 128, 16, 98, 33, 10, 5, 97, 108, 112, 104, 97, + 18, 24, 10, 22, 8, 1, 18, 18, 10, 2, 8, 1, 10, 2, 8, 1, 10, 3, 8, 128, 16, 10, 3, 8, 128, 16, 66, 4, 10, 0, 16, 18, +]; +pub(super) const ENCODER: &[u8] = &[ + 8, 9, 58, 218, 3, 10, 80, 18, 18, 105, 109, 97, 103, 101, 95, 101, 109, 98, 101, 100, 100, 105, 110, 103, 115, 46, 48, 34, 8, 67, 111, 110, 115, 116, 97, + 110, 116, 42, 48, 10, 5, 118, 97, 108, 117, 101, 42, 36, 8, 1, 8, 1, 8, 1, 8, 1, 16, 1, 34, 4, 0, 0, 0, 0, 66, 18, 105, 109, 97, 103, 101, 95, 101, 109, + 98, 101, 100, 100, 105, 110, 103, 115, 46, 48, 160, 1, 4, 10, 80, 18, 18, 105, 109, 97, 103, 101, 95, 101, 109, 98, 101, 100, 100, 105, 110, 103, 115, 46, + 49, 34, 8, 67, 111, 110, 115, 116, 97, 110, 116, 42, 48, 10, 5, 118, 97, 108, 117, 101, 42, 36, 8, 1, 8, 1, 8, 1, 8, 1, 16, 1, 34, 4, 0, 0, 128, 63, 66, + 18, 105, 109, 97, 103, 101, 95, 101, 109, 98, 101, 100, 100, 105, 110, 103, 115, 46, 49, 160, 1, 4, 10, 80, 18, 18, 105, 109, 97, 103, 101, 95, 101, 109, + 98, 101, 100, 100, 105, 110, 103, 115, 46, 50, 34, 8, 67, 111, 110, 115, 116, 97, 110, 116, 42, 48, 10, 5, 118, 97, 108, 117, 101, 42, 36, 8, 1, 8, 1, 8, + 1, 8, 1, 16, 1, 34, 4, 0, 0, 0, 64, 66, 18, 105, 109, 97, 103, 101, 95, 101, 109, 98, 101, 100, 100, 105, 110, 103, 115, 46, 50, 160, 1, 4, 18, 46, 80, + 104, 111, 116, 111, 67, 114, 97, 102, 116, 32, 111, 114, 105, 103, 105, 110, 97, 108, 32, 115, 121, 110, 116, 104, 101, 116, 105, 99, 32, 99, 111, 110, + 116, 114, 97, 99, 116, 32, 102, 105, 120, 116, 117, 114, 101, 90, 40, 10, 12, 112, 105, 120, 101, 108, 95, 118, 97, 108, 117, 101, 115, 18, 24, 10, 22, 8, + 1, 18, 18, 10, 2, 8, 1, 10, 2, 8, 3, 10, 3, 8, 128, 8, 10, 3, 8, 128, 8, 98, 44, 10, 18, 105, 109, 97, 103, 101, 95, 101, 109, 98, 101, 100, 100, 105, 110, + 103, 115, 46, 48, 18, 22, 10, 20, 8, 1, 18, 16, 10, 2, 8, 1, 10, 2, 8, 1, 10, 2, 8, 1, 10, 2, 8, 1, 98, 44, 10, 18, 105, 109, 97, 103, 101, 95, 101, 109, + 98, 101, 100, 100, 105, 110, 103, 115, 46, 49, 18, 22, 10, 20, 8, 1, 18, 16, 10, 2, 8, 1, 10, 2, 8, 1, 10, 2, 8, 1, 10, 2, 8, 1, 98, 44, 10, 18, 105, 109, + 97, 103, 101, 95, 101, 109, 98, 101, 100, 100, 105, 110, 103, 115, 46, 50, 18, 22, 10, 20, 8, 1, 18, 16, 10, 2, 8, 1, 10, 2, 8, 1, 10, 2, 8, 1, 10, 2, 8, + 1, 66, 4, 10, 0, 16, 18, +]; +pub(super) const DECODER: &[u8] = &[ + 8, 9, 58, 149, 4, 10, 86, 18, 10, 112, 114, 101, 100, 95, 109, 97, 115, 107, 115, 34, 8, 67, 111, 110, 115, 116, 97, 110, 116, 42, 62, 10, 5, 118, 97, 108, + 117, 101, 42, 50, 8, 1, 8, 1, 8, 3, 8, 1, 8, 2, 16, 1, 34, 24, 0, 0, 128, 191, 0, 0, 0, 192, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 128, 64, 0, 0, 160, 64, 66, + 10, 112, 114, 101, 100, 95, 109, 97, 115, 107, 115, 160, 1, 4, 10, 70, 18, 10, 105, 111, 117, 95, 115, 99, 111, 114, 101, 115, 34, 8, 67, 111, 110, 115, + 116, 97, 110, 116, 42, 46, 10, 5, 118, 97, 108, 117, 101, 42, 34, 8, 1, 8, 1, 8, 3, 16, 1, 34, 12, 205, 204, 204, 61, 102, 102, 102, 63, 205, 204, 76, 62, + 66, 10, 105, 111, 117, 95, 115, 99, 111, 114, 101, 115, 160, 1, 4, 18, 46, 80, 104, 111, 116, 111, 67, 114, 97, 102, 116, 32, 111, 114, 105, 103, 105, 110, + 97, 108, 32, 115, 121, 110, 116, 104, 101, 116, 105, 99, 32, 99, 111, 110, 116, 114, 97, 99, 116, 32, 102, 105, 120, 116, 117, 114, 101, 90, 38, 10, 12, + 105, 110, 112, 117, 116, 95, 112, 111, 105, 110, 116, 115, 18, 22, 10, 20, 8, 1, 18, 16, 10, 2, 8, 1, 10, 2, 8, 1, 10, 2, 8, 1, 10, 2, 8, 2, 90, 34, 10, + 12, 105, 110, 112, 117, 116, 95, 108, 97, 98, 101, 108, 115, 18, 18, 10, 16, 8, 7, 18, 12, 10, 2, 8, 1, 10, 2, 8, 1, 10, 2, 8, 1, 90, 33, 10, 11, 105, 110, + 112, 117, 116, 95, 98, 111, 120, 101, 115, 18, 18, 10, 16, 8, 1, 18, 12, 10, 2, 8, 1, 10, 2, 8, 1, 10, 2, 8, 4, 90, 44, 10, 18, 105, 109, 97, 103, 101, 95, + 101, 109, 98, 101, 100, 100, 105, 110, 103, 115, 46, 48, 18, 22, 10, 20, 8, 1, 18, 16, 10, 2, 8, 1, 10, 2, 8, 1, 10, 2, 8, 1, 10, 2, 8, 1, 90, 44, 10, 18, + 105, 109, 97, 103, 101, 95, 101, 109, 98, 101, 100, 100, 105, 110, 103, 115, 46, 49, 18, 22, 10, 20, 8, 1, 18, 16, 10, 2, 8, 1, 10, 2, 8, 1, 10, 2, 8, 1, + 10, 2, 8, 1, 90, 44, 10, 18, 105, 109, 97, 103, 101, 95, 101, 109, 98, 101, 100, 100, 105, 110, 103, 115, 46, 50, 18, 22, 10, 20, 8, 1, 18, 16, 10, 2, 8, + 1, 10, 2, 8, 1, 10, 2, 8, 1, 10, 2, 8, 1, 98, 40, 10, 10, 112, 114, 101, 100, 95, 109, 97, 115, 107, 115, 18, 26, 10, 24, 8, 1, 18, 20, 10, 2, 8, 1, 10, 2, + 8, 1, 10, 2, 8, 3, 10, 2, 8, 1, 10, 2, 8, 2, 98, 32, 10, 10, 105, 111, 117, 95, 115, 99, 111, 114, 101, 115, 18, 18, 10, 16, 8, 1, 18, 12, 10, 2, 8, 1, 10, + 2, 8, 1, 10, 2, 8, 3, 66, 4, 10, 0, 16, 18, +]; diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index 479de86891..5854d17163 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -7,6 +7,10 @@ license.workspace = true [lints] workspace = true +[features] +default = [] +local-ml = ["photocraft-engine/local-ml"] + [dependencies] photocraft-geom = { workspace = true } photocraft-color = { workspace = true } diff --git a/crates/ui-egui/examples/snapshot.rs b/crates/ui-egui/examples/snapshot.rs index 25ade0aa7d..bb0871e765 100644 --- a/crates/ui-egui/examples/snapshot.rs +++ b/crates/ui-egui/examples/snapshot.rs @@ -65,13 +65,24 @@ fn main() { let custom_titlebar = args.iter().any(|a| a == "--custom-titlebar"); // `--settle-ms N`: keep rendering frames for N ms before the capture (e.g. mid-job). let settle_ms: u64 = arg(&args, "--settle-ms").and_then(|s| s.parse().ok()).unwrap_or(0); + #[cfg(feature = "local-ml")] + let models_dir = arg(&args, "--models-dir"); let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(w, h)).with_pixels_per_point(scale).with_max_steps(64).wgpu().build_eframe(move |cc| { PhotocraftApp::setup_context(&cc.egui_ctx, Default::default()); let mut services = services; services.is_wayland = wayland_notice; services.xwayland_command = wayland_notice.then(|| "WAYLAND_DISPLAY= photocraft".into()); - let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), services); + let session = photocraft_engine::Session::new(); + #[cfg(feature = "local-ml")] + let session = { + let mut session = session; + if let Some(dir) = models_dir { + session.configure_local_models(dir.into()); + } + session + }; + let mut app = PhotocraftApp::new(session, services); app.background_jobs = background_jobs; app.custom_titlebar = custom_titlebar; // `--safe-gpu`: the CPU canvas, as the desktop app's `--safe-gpu` launch. diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index d8a91bba60..c121ee3403 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -1,3 +1,5 @@ + + # Czech (cs) catalog. Columns, separated by a TAB: context source translation # # context empty a plain UI string; `source` is the English text in the code diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index b6ab73ce9d..21b3a3f156 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -1,3 +1,5 @@ + + # German (de) catalog. Columns, separated by a TAB: context source translation # # context empty a plain UI string; `source` is the English text in the code diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 6c2b7adf7e..2100ea27ad 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -1,3 +1,5 @@ + + # Greek (el) PhotoCraft interface catalog. # Columns separated by TAB: context, English source, Greek translation. # Original translations based on general Greek graphics/computing terminology. diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index f08fd2ceaa..0647b59dc3 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -1,3 +1,5 @@ + + # Spanish (es) catalog. Columns, separated by a TAB: context source translation # # context empty a plain UI string; `source` is the English text in the code diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index e71f7cad0d..daa78d6f7d 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -1,3 +1,5 @@ + + # French (fr) catalog. Columns, separated by a TAB: context source translation # # context empty a plain UI string; `source` is the English text in the code diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 71fb019474..a5118bda91 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -1,3 +1,5 @@ + + # Indonesian (id) catalog. Columns, separated by a TAB: context source translation # # context empty a plain UI string; `source` is the English text in the code diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index c037107357..10356202de 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -1,3 +1,5 @@ + + # Italian (it) catalog. Columns, separated by a TAB: context source translation # # context empty a plain UI string; `source` is the English text in the code diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 235f663785..1a83a49836 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -1,3 +1,5 @@ + + # Japanese (ja) catalog. Columns, separated by a TAB: context source translation # # context empty a plain UI string; `source` is the English text in the code diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index ca0923b7d1..afb127f18b 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -1,3 +1,5 @@ + + # Korean (ko) catalog. UTF-8: contextEnglish sourcetranslation. # Empty context: plain UI text; @id: command ID; @plural: one|other source # with one Korean form. Other contexts disambiguate English meanings. diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index d222d86fbe..e51132fdf3 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -1,3 +1,5 @@ + + # Brazilian Portuguese (pt-br) catalog. Columns, separated by a TAB: context source translation # # context empty a plain UI string; `source` is the English text in the code diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 62b7c28fd5..56580dc26b 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -1,3 +1,5 @@ + + # Russian (ru) catalog. Columns, separated by a TAB: context source translation # # context empty a plain UI string; `source` is the English text in the code diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 52a4f5009b..1f9da7010d 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -1,3 +1,5 @@ + + # Simplified Chinese (zh-hans) catalog. UTF-8, TAB-separated columns: # context English source Simplified Chinese translation # diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 9f8ac1f94e..3fcd92cc04 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -1,3 +1,5 @@ + + # Traditional Chinese (zh-hant) catalog. Columns, separated by a TAB: context source translation # # context empty a plain UI string; `source` is the English text in the code diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs index 9b0f48ac0c..67e3c596b8 100644 --- a/crates/ui-egui/src/prefs_ui.rs +++ b/crates/ui-egui/src/prefs_ui.rs @@ -884,7 +884,7 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map { f.insert("__gpuInfo".into(), json!(app.perf.gpu_info.lines())); let system = system_theme(app, ui.ctx()); - prefs_body(ui, f, system); + prefs_body(app, ui, f, system); } "shortcuts" => shortcuts_body(app, ui, f), "presets" => presets_body(app, ui, f), @@ -943,6 +943,9 @@ fn choice_label(v: &str) -> String { "metal" => "Metal".into(), "gl" => "OpenGL".into(), "cpu" => "CPU (no GPU acceleration)".into(), + "classical" => "Classical (built in)".into(), + "birefnet-hr-matting" => "BiRefNet HR Matting".into(), + "sam2.1-large" => "SAM 2.1 Large".into(), v => humanize(v), } } @@ -971,7 +974,7 @@ fn color_of(s: &str) -> Color32 { } /// Preferences: section list on the left, the section's settings on the right. -fn prefs_body(ui: &mut egui::Ui, f: &mut Map, system: Option) { +fn prefs_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map, system: Option) { let t = Tokens::get(ui.ctx()); let mut section = f.get("section").and_then(Value::as_str).unwrap_or("general").to_string(); let mut values = f.get("values").cloned().unwrap_or(Value::Null); @@ -1024,7 +1027,7 @@ fn prefs_body(ui: &mut egui::Ui, f: &mut Map, system: Option, system: Option, system: Option) { + let t = Tokens::get(ui.ctx()); + let status = app.session.local_model_status(); + let available = status["available"].as_bool().unwrap_or(false); + ui.add_space(10.0); + ui.label(RichText::new(tl!("Local selection models")).font(crate::theme::semibold(12.5)).color(t.text)); + ui.label(RichText::new(tl!("Models run on this device. Images stay on this device.")).color(t.text_dim)); + ui.label(RichText::new(tl!("Download a model before choosing it. Downloads do not change the current method.")).color(t.text_dim)); + if !available { + ui.label(RichText::new(tl!("Local models aren't available in this build or session.")).color(t.text_faint)); + } + ui.add_space(6.0); + for model in status["models"].as_array().into_iter().flatten() { + let id = model["id"].as_str().unwrap_or_default(); + let label = model["label"].as_str().unwrap_or_default(); + let installed = model["installed"].as_bool().unwrap_or(false); + let busy = model["busy"].as_bool().unwrap_or(false); + let mib = model["downloadBytes"].as_u64().unwrap_or(0).div_ceil(1024 * 1024); + ui.push_id(id, |ui| { + ui.horizontal(|ui| { + ui.label(RichText::new(label).color(t.text)); + ui.label( + RichText::new(if busy { + tl!("In use…") + } else if installed { + tl!("Downloaded") + } else { + tl!("Not downloaded") + }) + .color(t.text_faint), + ); + }); + ui.label(RichText::new(tl!(model["purpose"].as_str().unwrap_or_default())).color(t.text_dim)); + ui.horizontal(|ui| { + let button = if installed { tl!("Remove download").to_string() } else { format!("{} ({mib} MiB)", tl!("Download")) }; + let clicked = ui.add_enabled_ui(available && !busy, |ui| crate::widgets::secondary_button(ui, &button, 190.0).clicked()).inner; + if clicked { + let command = if installed { "models.remove" } else { "models.download" }; + if app.run(command, json!({"id": id})).is_ok() && installed { + let pref = if id == "sam2.1-large" { "objectModel" } else { "subjectModel" }; + obj.insert(pref.into(), json!("classical")); + } + } + ui.hyperlink_to(model["license"].as_str().unwrap_or_default(), model["upstream"].as_str().unwrap_or_default()); + ui.hyperlink_to(tl!("Model details"), model["exportSource"].as_str().unwrap_or_default()); + }); + ui.add_space(8.0); + }); + } + ui.label(RichText::new(tl!("Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar.")).color(t.text_faint)); +} + /// Preferences › Performance: what the app renders with now, and a reset of the GPU backend /// (a crashed start may have moved it to a safer choice). fn gpu_status_rows(ui: &mut egui::Ui, info: Option<&Value>, obj: &mut Map) { @@ -1249,7 +1309,21 @@ fn ctx_take_pick(ui: &egui::Ui) -> Option<(String, String)> { /// Generic editor for a section's fields: checkboxes, dropdowns for choices, colour swatches, /// number fields with the preference's range, text fields. -fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map, order: &[String], lang: crate::i18n::Lang, system: Option) { +fn field_label(section: &str, key: &str) -> String { + match (section, key) { + ("integrations", "subjectModel") => "Subject / background removal".into(), + ("integrations", "objectModel") => "Object selection".into(), + _ => humanize(key), + } +} + +fn model_choice_available(status: &Value, option: &str) -> bool { + option == "classical" + || (status["available"].as_bool().unwrap_or(false) + && status["models"].as_array().into_iter().flatten().any(|m| m["id"].as_str() == Some(option) && m["installed"].as_bool() == Some(true))) +} + +fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map, order: &[String], lang: crate::i18n::Lang, system: Option, models: &Value) { let t = Tokens::get(ui.ctx()); if section == "interface" { appearance_rows(ui, obj, system); @@ -1272,7 +1346,7 @@ fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map continue; } let v = obj.get(&k).cloned().unwrap_or(Value::Null); - let human = humanize(&k); + let human = field_label(section, &k); let label = tl!(&human).to_string(); match &v { Value::Bool(b) => { @@ -1298,7 +1372,14 @@ fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map } Value::String(s) if prefs::choices(&path).is_some() => { ui.label(RichText::new(tl!(&label)).color(t.text_dim)); - let opts = prefs::choices(&path).unwrap_or(&[]); + let opts: Vec<&str> = prefs::choices(&path) + .unwrap_or(&[]) + .iter() + .copied() + .filter(|v| { + !matches!(path.as_str(), "integrations.subjectModel" | "integrations.objectModel") || *v == s || model_choice_available(models, v) + }) + .collect(); let labels: Vec = opts.iter().map(|o| choice_label(o)).collect(); let pairs: Vec<(String, &str)> = opts.iter().map(|o| o.to_string()).zip(labels.iter().map(String::as_str)).collect(); let mut cur = s.clone(); @@ -1837,6 +1918,17 @@ mod tests { let shortcuts = serde_json::json!({"__prefsui": "shortcuts"}); assert_eq!(super::width(shortcuts.as_object().unwrap(), 3000.0), Some(720.0)); } + + #[test] + fn local_model_choices_need_a_backend_and_a_download() { + assert!(model_choice_available(&json!({"available":false}), "classical")); + assert!(!model_choice_available(&json!({"available":false}), "sam2.1-large")); + let mut status = json!({"available":true,"models":[{"id":"sam2.1-large","installed":false}]}); + assert!(!model_choice_available(&status, "sam2.1-large")); + status["models"][0]["installed"] = json!(true); + assert!(model_choice_available(&status, "sam2.1-large")); + assert!(!model_choice_available(&status, "birefnet-hr-matting")); + } use super::*; use std::sync::{Arc, Mutex}; @@ -2084,11 +2176,18 @@ mod tests { } let Some(obj) = v.get(sec).and_then(Value::as_object) else { continue }; for k in obj.keys() { - let mut labels = vec![humanize(k)]; + let mut labels = vec![field_label(sec, k)]; labels.extend(prefs::choices(&format!("{sec}.{k}")).into_iter().flatten().map(|c| choice_label(c))); missing.extend(labels.into_iter().filter(|l| !crate::i18n::has(lang, l))); } } + for model in session.local_model_status()["models"].as_array().into_iter().flatten() { + if let Some(purpose) = model["purpose"].as_str() + && !crate::i18n::has(lang, purpose) + { + missing.push(purpose.to_string()); + } + } missing.sort(); missing.dedup(); assert!(missing.is_empty(), "{}: untranslated preference labels: {missing:#?}", lang.code()); @@ -2391,8 +2490,10 @@ mod tests { let values = prefs::Preferences::default().to_json(); assert!(has_visible_fields(&values, "general")); assert!(has_visible_fields(&values, "fileHandling")); + assert!(has_visible_fields(&values, "integrations")); + assert!(has_visible_fields(&values, "enhancedControls")); // Every setting of these sections is still unimplemented. - for section in ["integrations", "scratchDisks"] { + for section in ["scratchDisks"] { assert!(!has_visible_fields(&values, section), "{section}"); } // "Fill new type layers with placeholder text" and "Use Escape to Commit" are live; other Type rows stay hidden. diff --git a/docs/architecture.md b/docs/architecture.md index 7db7ba0e24..eaa098d6f7 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -154,7 +154,7 @@ photocraft/ └─ plan/ this directory ``` -**What exists today.** This layout is the target design. Built so far: `geom`, `cms`, `color`, `raster`, `psd`, `codecs`, `doc`, `ops`, `algo`, `paint`, `text`, `vector`, `compose`, `gpu`, `format`, `raw`, `io`, `plugins`, `engine`, `ui-egui`, `automation`, `testkit`, and the three apps. Not yet split out: `viewport` and `tools` live inside `ui-egui` and `engine`; `platform` services are function hooks injected by each app (`ui_egui::Services`); `adobe-assets` and `ml` are not started. +**What exists today.** This layout is the target design. Built so far: `geom`, `cms`, `color`, `raster`, `psd`, `codecs`, `doc`, `ops`, `algo`, `paint`, `text`, `vector`, `compose`, `gpu`, `format`, `raw`, `io`, `plugins`, `ml`, `engine`, `ui-egui`, `automation`, `testkit`, and the three apps. `ml` supplies the optional native CPU backend for BiRefNet matting and SAM 2.1 box selection; [local models](local-models.md) documents its downloads and limits. Not yet split out: `viewport` and `tools` live inside `ui-egui` and `engine`; `platform` services are function hooks injected by each app (`ui_egui::Services`); `adobe-assets` is not started. Web ML, depth and sky models remain planned. **Crate granularity:** start with the crates above. Split `algo` into `-adjust`, `-filters`, `-select`, `-inpaint` and `-warp` once any module passes about 10k lines, or once compile times hurt. Its internal module boundaries should already follow those lines. diff --git a/docs/development.md b/docs/development.md index e75aad769e..c62e7a79d8 100644 --- a/docs/development.md +++ b/docs/development.md @@ -46,6 +46,10 @@ cargo xtask parity # Photoshop menu cove Image code is slow at `opt-level 0`, so the workspace profile builds dependencies at `opt-level 2`. Use `--release` for anything interactive. +Optional CPU models for Object Selection, Select Subject and Remove Background are enabled with +`--features local-ml`. Weights remain separate, explicit downloads. See [local models](local-models.md) +for Preferences, CLI, provenance and native runtime packaging details. + The dev profile builds with `debug = "line-tables-only"`: panic backtraces keep file and line, and test binaries link about twice as fast. To inspect local variables in a debugger, build with `CARGO_PROFILE_DEV_DEBUG=true`. ### Faster test loops diff --git a/docs/images/LICENSE-local-models.txt b/docs/images/LICENSE-local-models.txt new file mode 100644 index 0000000000..4936621edd --- /dev/null +++ b/docs/images/LICENSE-local-models.txt @@ -0,0 +1,10 @@ +local-models-before.png and local-models-preferences.png are original PhotoCraft UI screenshots +and are licensed under this repository's MIT OR Apache-2.0 terms (LICENSE-MIT / LICENSE-APACHE). + +local-models-comparison.png uses Johannes Vermeer's Girl with a Pearl Earring, c. 1665. +The original artwork and its faithful photographic reproduction are public domain (PD-Art). +Source: https://commons.wikimedia.org/wiki/File:1665_Girl_with_a_Pearl_Earring.jpg +The comparison layout and command output presentation are original PhotoCraft contributions, +licensed under this repository's MIT OR Apache-2.0 terms. + +No learned model weights or personal photographs are included in these documentation assets. diff --git a/docs/images/SOURCES.md b/docs/images/SOURCES.md index 723d1837fc..12a8896fa1 100644 --- a/docs/images/SOURCES.md +++ b/docs/images/SOURCES.md @@ -11,6 +11,8 @@ | `photocraft-transform.jpg` | Photocraft UI screenshot (offscreen snapshot) with *The Tetons and the Snake River*, Ansel Adams, 1942 (U.S. National Archives) | Artwork: public domain, [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Adams_The_Tetons_and_the_Snake_River.jpg). UI: this project. | | `photocraft-type.jpg` | Photocraft UI screenshot (offscreen snapshot) with *Among the Sierra Nevada, California*, Albert Bierstadt, 1868 | Artwork: public domain, [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Albert_Bierstadt_-_Among_the_Sierra_Nevada,_California_-_Google_Art_Project.jpg). UI: this project. | | `photocraft-export-light.jpg` | Photocraft UI screenshot (offscreen snapshot) with *The Kiss*, Gustav Klimt, 1907–1908 | Artwork: public domain, [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Gustav_Klimt_016.jpg). UI: this project. | +| `local-models-before.png`, `local-models-preferences.png` | PhotoCraft Preferences, offscreen snapshots before / after optional local models | Original project UI, MIT OR Apache-2.0; [licence](LICENSE-local-models.txt). | +| `local-models-comparison.png` | Actual exported classical / BiRefNet / SAM masks over a checkerboard, using *Girl with a Pearl Earring*, Johannes Vermeer, c. 1665 | Artwork: public domain, [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:1665_Girl_with_a_Pearl_Earring.jpg); original layout: MIT OR Apache-2.0; [licence](LICENSE-local-models.txt). | Screenshots must use famous public-domain artwork (or content made in the app), never personal photos. diff --git a/docs/images/local-models-before.png b/docs/images/local-models-before.png new file mode 100644 index 0000000000000000000000000000000000000000..90442321a124caabbf7822b9addc221ee2533275 GIT binary patch literal 123594 zcmbTf3s{u(_C5Y0Cf-RcEj1`5J!Xk%q9!nQvdGLh)hWvhXqINEh-84k3~HukO5P$R z!H&nQJV<7WC@?50D(YCKU?9UCuP|I^24?2{ueHZ6rhR|U^M9T~7>1em{e1Rk@3q%n zd(WzWy&TY`WABcNqI4Pm!njuzrS12M;`(s=c6elXNn#ttrEJ~!anJla(&c8h>o%{q zK0jWkM%1i1aeC*%2{U)kE8KtUzd4^Keg0x<(y-zEYOEioy}$VD6=Om!q-I?%%-ouO z?YmvO58m-b-Q4~zkMfziAxrP}2fKE+B(E;H>uc?DRR3q;h1VxdTXg%ECgXJf{FH7gW#lPwkmH@PhU&&xL#+97?!xqn?^I3C)%Watd25^L z`zF`*+g6`y+8ChoR@bMUHk8dS50BJ(I6g90+~s=S-}B}IW2_l(mVQl5s9bo`+EATd zwI$?DymkBbLE{3W8qIAMoUhOSMrUypd27p4BDdP(tF^`kyXJ^@mU{kx@d;h)*?*@h zk*Bun6YjPalLzNjuHWU*O&*f)%jBqT-E4znD_etdTlF{d7Pgcb!mhS@<|V{lTv0!z zF!=c17i<@6Z7#lbQ(Pi{UjC4_!Y}Fh2Myu3FO{sob>AB^+{?e)JMXfJRpmvegI!H4XI4jE9vL$w%QV8V z@-7z~T%Dt_n)VY8Vl`AtEXvqBOfO!+}(qePX4ZTwxr+lxib1xt4C^;NclV`gxH>mYl>yBXS z#GtG92X}RR@yENXA0*o^C9m(Kh zD!&l4>e%t6Zhlv0W!ZLRb(`<-`Fc)SgWj^sQs>$7VNlb);xAL}r@Twbjy>8ZvD5s6 zSKDP(w`$v3-g69(X`Zd~Ss%GgV_Bvt@pP1WM(WMcnyi}ZS!-98^w-q)xBk!2^0;Gr z>~GIg8#L9`+M4Rf`Jqj3gdWTBbS%g!8=S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2z8SqDH#?92qJXo5618+-GFj>%|k`z^!3^2yHr>fzk7MLLE>?cA^ zj@T{rnRhMxa#1*0>tr^b5{@YJq1XAd3MkoO3dkp6;HvZ%BW1FMMcj#6ikz7Y5IonS zQ32nog))YaIO=S;fs6?MVZ?nhtVmw0ZR2;g6*LJXE|x|c!r2^8(Zw+am93KK(D zy6gy%hUD=SBOOniD`41liE?(n+ga!-`-C0!(UepaRm+%lO65cfzy{8Bj|xt?rk?`8 z2Xn8$X1<^3JONCRl?t_#5zj=p0E9D8l$NmIjd;Ypi z!jTU?lM~(l!1>pPXFb zz_6o1$3dbxGX_g%9yD3tTPU*ULHi}leYk$#J(yM-Kgu`KwGwLKT(`=#F;``j;_fW2 zElN->!=?N)T$p&V6#c>_Awzm7$`frhh3Ta=z+tU&W$GbOX7bf9Kq9PZ6MhcW5h)tFI<8Qq;@@c&<{kSYcoK~ zlvYJ{Q*gi3(cDM00e}TdF$}_3{iadeKRv^L^sJzBpa~JpjXd=15|IVKfih_8k`Nb> zmCJI6zh%Xn_(fh**pHs!J%r@Xn8^{IN;#z%n9?@3+*-FLIqX#ORqBYbwrjg6qU Date: Thu, 8 Oct 2026 16:16:49 +0300 Subject: [PATCH 002/649] Keep model management independent of document state --- crates/engine/src/float_cmds.rs | 2 +- crates/engine/src/model_cmds.rs | 50 +++++++++++++++++++++++++++++++-- docs/local-models-validation.md | 14 +++++---- docs/local-models.md | 8 ++++++ 4 files changed, 65 insertions(+), 9 deletions(-) diff --git a/crates/engine/src/float_cmds.rs b/crates/engine/src/float_cmds.rs index 892f754748..ea1bd37af1 100644 --- a/crates/engine/src/float_cmds.rs +++ b/crates/engine/src/float_cmds.rs @@ -205,7 +205,7 @@ pub fn drop_floating(s: &mut Session) -> Result { /// Commands that leave a floating piece floating: its own, and ones that don't touch documents. fn keeps_floating(id: &str) -> bool { - matches!(id, "select.float" | "select.drop") || ["view.", "window.", "help.", "prefs."].iter().any(|p| id.starts_with(p)) + matches!(id, "select.float" | "select.drop") || ["view.", "window.", "help.", "prefs.", "models."].iter().any(|p| id.starts_with(p)) } /// Before any command (`Session::dispatch`): Undo puts a floating piece back (and is used up: diff --git a/crates/engine/src/model_cmds.rs b/crates/engine/src/model_cmds.rs index 7524449fc8..8b209cfa63 100644 --- a/crates/engine/src/model_cmds.rs +++ b/crates/engine/src/model_cmds.rs @@ -84,9 +84,7 @@ impl Sampler for ModelSampler<'_> { for (dst, v) in p.iter_mut().take(3).zip(rgb) { *dst = if v.is_finite() { v.clamp(0.0, 1.0) } else { 0.0 }; } - if !p[3].is_finite() { - p[3] = 0.0; - } + p[3] = if p[3].is_finite() { p[3].clamp(0.0, 1.0) } else { 0.0 }; } px } @@ -395,6 +393,33 @@ mod tests { assert_eq!(loaded.integrations.object_model, crate::prefs::ObjectModel::Classical); } + #[test] + fn managing_models_does_not_drop_a_floating_selection_or_edit_the_document() { + let (mut s, _) = session("rgb", 8); + s.execute("layer.new.layer", json!({})).unwrap(); + s.edit("paint", |doc, layer| { + let bounds = doc.bounds(); + doc.layer_mut(layer.unwrap()).unwrap().surface_mut().unwrap().fill_rect(bounds, &[1.0, 0.0, 0.0, 1.0]); + Ok(()) + }) + .unwrap(); + s.execute("select.rect", json!({"x":0,"y":0,"width":2,"height":2})).unwrap(); + s.execute("select.float", json!({"dx":2,"dy":1})).unwrap(); + let doc = s.active().unwrap().doc.clone(); + let history = s.active().unwrap().history.past_len(); + let journal = s.journal.len(); + for (command, params) in + [("models.list", json!({})), ("models.download", json!({"id":"birefnet-hr-matting"})), ("models.remove", json!({"id":"birefnet-hr-matting"}))] + { + s.execute(command, params).unwrap(); + let state = s.active().unwrap(); + assert!(Arc::ptr_eq(&state.doc, &doc)); + assert_eq!(state.history.past_len(), history); + assert_eq!(state.floating.as_ref().unwrap().offset, (2, 1)); + assert_eq!(s.journal.len(), journal); + } + } + #[test] fn preferences_select_a_model_and_explicit_classical_overrides_it() { let (mut s, fake) = session("rgb", 32); @@ -478,6 +503,25 @@ mod tests { assert_eq!(s.active().unwrap().doc.layers[0].mask.as_ref().unwrap().value(7, 2), 0.0); } + #[test] + fn out_of_range_and_non_finite_alpha_only_affect_the_model_input() { + // The existing segmentation sampler composites transparent pixels over neutral gray. + for (alpha, expected) in [(2.0, 0.25), (f32::NAN, 0.5)] { + let (mut s, fake) = session("rgb", 32); + s.edit("HDR alpha", |doc, _| { + doc.icc_profile = Some(Builtin::Srgb.profile().to_bytes()); + let bounds = doc.bounds(); + doc.layers[0].surface_mut().unwrap().fill_rect(bounds, &[0.25, 0.25, 0.25, alpha]); + Ok(()) + }) + .unwrap(); + let before: Vec = pixels(&s).iter().map(|v| v.to_bits()).collect(); + s.execute("select.subject", json!({"model":"birefnet-hr-matting","sampleAllLayers":false})).unwrap(); + assert_eq!(pixels(&s).iter().map(|v| v.to_bits()).collect::>(), before); + assert!(fake.calls.lock().unwrap()[0].1.px.iter().flatten().all(|v| v.is_finite() && (*v - expected).abs() < 0.005)); + } + } + #[test] #[cfg(not(target_arch = "wasm32"))] fn cancelling_model_inference_discards_result_and_unlocks_document() { diff --git a/docs/local-models-validation.md b/docs/local-models-validation.md index 41a31e6976..8bce5a5b62 100644 --- a/docs/local-models-validation.md +++ b/docs/local-models-validation.md @@ -62,7 +62,9 @@ cargo run --release -p photocraft-engine --features local-ml --example local_mod tests cover scoped removal, busy state and dependency panic recovery. - Engine tests cover RGB/Gray/CMYK/Lab at 8/16/32-bit, ICC input conversion, fractional alpha, layer-mask replacement, selection modes and rectangle mapping, one-step Undo/Redo, cancellation, - missing-model errors, recorded method choices and batch/droplet capability inheritance. + missing-model errors, recorded method choices, batch/droplet capability inheritance and model + management while a selection floats. Non-finite/out-of-range alpha is sanitized for model input + while original 32-bit pixel values are preserved. - Full engine, CLI and UI test suites pass locally. UI preference/localization coverage includes every supported complete-menu language. Default and `local-ml` build paths retain classical operation without installing models. @@ -76,10 +78,12 @@ cargo run --release -p photocraft-engine --features local-ml --example local_mod - `xtask perf --quick --bench perf_scenarios` passes for the existing selection/retouch scenarios; it does not establish a sub-100 ms budget for the optional models. -The dedicated `local-models.yml` workflow adds Linux, Windows and macOS CPU runtime tests and -native build checks. Windows/Linux results must be verified in CI before removing the draft -status; they have not been run on this Mac. Quantitative accuracy evaluation, packaged installer -enablement, web inference, point prompts and GPU acceleration remain separate work. +The dedicated `local-models.yml` workflow runs Linux, Windows and macOS CPU runtime tests and +native build checks. The [initial cross-platform run](https://github.com/mighty-programmer/photocraft/actions/runs/37780207526) +passes on all three platforms. Final document-state regression tests are being rerun in the +same matrix before this contribution leaves draft. Upstream PR CI needs maintainer approval for +this first contribution. Quantitative accuracy evaluation, packaged installer / sandbox download +checks, web inference, point prompts and GPU acceleration remain separate work. Image sources and licences: [SOURCES.md](images/SOURCES.md), [LICENSE-local-models.txt](images/LICENSE-local-models.txt). diff --git a/docs/local-models.md b/docs/local-models.md index 42be82d267..21056b559c 100644 --- a/docs/local-models.md +++ b/docs/local-models.md @@ -49,6 +49,14 @@ The desktop cache is `Models/` under the existing per-user configuration directo preferences. Each immutable model revision gets its own directory with `LICENSE.txt` and `SOURCE.txt`; inference verifies the hashes again, including SAM's external weights. +Linux uses the existing XDG configuration path, so an AppImage stores models outside its +read-only mounted image and a Flatpak uses its sandbox's XDG configuration directory. The current +Flatpak manifests omit network permission and do not enable `local-ml`. A distributor opting in +must also choose how explicit downloads receive network access (or prepopulate a verified cache); +this backend does not alter sandbox permissions. Windows uses `%APPDATA%\\Photocraft\\Models` +outside portable/override mode. Installer packaging and sandbox download checks remain separate +from the native CPU build matrix. + ## Commands and CLI | Command | Parameters | From ab2c0e7c2c763f0a4b700dac6d386e9509809e41 Mon Sep 17 00:00:00 2001 From: mighty-programmer <83077551+mighty-programmer@users.noreply.github.com> Date: Thu, 8 Oct 2026 16:27:56 +0300 Subject: [PATCH 003/649] Record successful cross-platform model validation --- docs/local-models-validation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/local-models-validation.md b/docs/local-models-validation.md index 8bce5a5b62..aec48b9254 100644 --- a/docs/local-models-validation.md +++ b/docs/local-models-validation.md @@ -79,9 +79,9 @@ cargo run --release -p photocraft-engine --features local-ml --example local_mod it does not establish a sub-100 ms budget for the optional models. The dedicated `local-models.yml` workflow runs Linux, Windows and macOS CPU runtime tests and -native build checks. The [initial cross-platform run](https://github.com/mighty-programmer/photocraft/actions/runs/37780207526) -passes on all three platforms. Final document-state regression tests are being rerun in the -same matrix before this contribution leaves draft. Upstream PR CI needs maintainer approval for +native build checks. The [final cross-platform run](https://github.com/mighty-programmer/photocraft/actions/runs/37783114338) +passes on all three platforms, including the final document-state and input regression tests. +The contribution is ready for review. Upstream PR CI needs maintainer approval for this first contribution. Quantitative accuracy evaluation, packaged installer / sandbox download checks, web inference, point prompts and GPU acceleration remain separate work. From 7f272aacd6534c1afb19c51913717e66ae808798 Mon Sep 17 00:00:00 2001 From: mighty-programmer <83077551+mighty-programmer@users.noreply.github.com> Date: Fri, 9 Oct 2026 00:00:25 +0300 Subject: [PATCH 004/649] Translate optional model settings into Polish --- crates/ui-egui/src/i18n/pl.tsv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 797a79a93d..87d310620f 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -1,3 +1,5 @@ + + # Polish (pl) catalog. Columns, separated by a TAB: context source translation # # context empty a plain UI string; `source` is the English text in the code From 58fceda01f29d3d624e304f2aa457edb003be0e8 Mon Sep 17 00:00:00 2001 From: mighty-programmer <83077551+mighty-programmer@users.noreply.github.com> Date: Fri, 9 Oct 2026 01:15:33 +0300 Subject: [PATCH 005/649] Publish fixed model evaluation and register contributor real name --- contributors/people.toml | 1 + docs/local-models-validation.md | 53 ++++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/contributors/people.toml b/contributors/people.toml index b2b97d2438..4ed028a4ab 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -92,4 +92,5 @@ sync_github_name = false sync_github_name = true [people.mighty-programmer] +real_name = "John Pantrakis" sync_github_name = true diff --git a/docs/local-models-validation.md b/docs/local-models-validation.md index aec48b9254..a07cbd4f58 100644 --- a/docs/local-models-validation.md +++ b/docs/local-models-validation.md @@ -2,8 +2,9 @@ Recorded 2026-10-08 on an Apple M3 Max with 36 GiB RAM, Rust 1.98.0, native CPU inference and the immutable model exports listed in [local-models.md](local-models.md). No learned weights -are included in this repository. This is an initial integration and performance check, not a -labelled accuracy benchmark or evidence that a model always improves on the classical method. +are included in this repository. The integration/performance checks below are supplemented by a +fixed 22-case evaluation. Its 20 labelled COCO targets are exploratory evidence, not a representative +or held-out benchmark, a soft-alpha matting assessment, or evidence of a universal winner. ## Preferences before and after @@ -41,8 +42,8 @@ selection, SAM object selection. ![Actual command outputs](images/local-models-comparison.png) The classical method works well on this example. BiRefNet supplies continuous edge alpha; -SAM leaves some unwanted holes. These results support keeping both choices available and -requiring a labelled multi-image benchmark before a general accuracy claim. +SAM leaves some unwanted holes. These results support keeping both choices available. The +exploratory multi-image evaluation below also includes failures and cases where Classical is better. Repeated BiRefNet runs initially exhausted memory with ONNX Runtime's default CPU arena and memory-pattern caching. Disabling both while retaining only the current model's weights let @@ -55,6 +56,44 @@ cargo run --release -p photocraft-engine --features local-ml --example local_mod /absolute/model-cache /absolute/image.png /absolute/comparison-directory ``` +## Fixed multi-image evaluation + +The [33-page comparison PDF and public reproducibility supplement](https://github.com/mighty-programmer/photocraft/releases/tag/model-evaluation-2026-10-08) +contain all 22 distinct cases: 20 COCO val2017 images with independent binary instance references, +plus two user-supplied LEGO photos for visual inspection. There are 44 paired comparisons, +88 final method outcomes and 86 actual exported cutouts. BiRefNet's no-subject chair result and +Classical's empty zebra object selection are explicit failures, counted as zero rather than omitted. + +| Feature | Classical mean target IoU | Learned mean target IoU | Learned wins / losses / near-ties | +|---|---:|---:|---:| +| Remove Background | 31.5% | 51.5% (BiRefNet HR Matting) | 15 / 2 / 3 | +| Box Object Selection | 52.5% | 79.1% (SAM 2.1 Large) | 16 / 3 / 1 | + +Cases were selected using a fixed hash seed before inference, one from each of 20 categories. +Alpha is thresholded at 128/255, and a win/loss requires over one percentage point of IoU change. +Object boxes are derived from the annotation with 10% padding and reused for both methods. +The two unlabelled LEGO photos are excluded from the means. Each background-removal reference +contains one instance; keeping other plausible foreground subjects counts as a false positive. +COCO polygons cannot establish hair, soft-alpha or transparent-glass matting quality. This selected +pilot may overlap training data, and its annotation-derived boxes are easier than imperfect user boxes. + +Median warm command times on the M3 Max / 36 GiB were 0.19 / 26.63 seconds for Classical / +BiRefNet removal and 0.20 / 5.59 seconds for Classical / SAM selection. These single-pass observations +exclude image import/export and initial/model-loading cases; they are not Windows/Linux timings. +Storage pressure interrupted two exports, which were rerun; the supplement preserves all 90 raw +attempts, 88 final outcomes and the recovery notes. Sampled resumed-run peak RSS was 13.35 GiB; +initial memory samples were not saved. + +All methods ran in the same release engine at benchmark commit +`6e2b7bc9b20938787cf1f7af9718a832a2edf716`. The Classical algorithm sources match stock 0.3.0 +`60224d3fb7d4006bcfcc97603c1611b9b756aebd`; the installed stock GUI was not timed separately. +Later UI/account changes were not re-benchmarked. The release tag identifies the tested engine, +and the supplement supplies the exact rectangles, annotation polygons/reference masks, source +hashes, command logs, CSV scores, model revisions and Rust harness. Its helper downloads and +hash-checks the 20 public inputs; model installation stays explicit. The report retains photo and +annotation attribution. Standalone user-photo originals, full-resolution cutouts and model weights +are not bundled in the public supplement or software repository. + ## Checks - ML unit tests execute both contracts through the actual CPU runtime using original tiny ONNX @@ -79,11 +118,11 @@ cargo run --release -p photocraft-engine --features local-ml --example local_mod it does not establish a sub-100 ms budget for the optional models. The dedicated `local-models.yml` workflow runs Linux, Windows and macOS CPU runtime tests and -native build checks. The [final cross-platform run](https://github.com/mighty-programmer/photocraft/actions/runs/37783114338) +native build checks. The [cross-platform run at `1904396`](https://github.com/mighty-programmer/photocraft/actions/runs/37849240044) passes on all three platforms, including the final document-state and input regression tests. The contribution is ready for review. Upstream PR CI needs maintainer approval for -this first contribution. Quantitative accuracy evaluation, packaged installer / sandbox download -checks, web inference, point prompts and GPU acceleration remain separate work. +this first contribution. Representative held-out/matting evaluation, packaged installer / sandbox +download checks, web inference, point prompts and GPU acceleration remain separate work. Image sources and licences: [SOURCES.md](images/SOURCES.md), [LICENSE-local-models.txt](images/LICENSE-local-models.txt). From 2591e5c6dc18cbb1d4b8322ece4af177e4695d27 Mon Sep 17 00:00:00 2001 From: mighty-programmer <83077551+mighty-programmer@users.noreply.github.com> Date: Fri, 9 Oct 2026 01:19:21 +0300 Subject: [PATCH 006/649] Link exploratory evaluation without overstating matting quality --- docs/local-models.md | 14 +++++++++----- scorecard/automation.toml | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/local-models.md b/docs/local-models.md index 21056b559c..9b889f3bd4 100644 --- a/docs/local-models.md +++ b/docs/local-models.md @@ -134,10 +134,14 @@ PHOTOCRAFT_MODEL_TEST_DOWNLOAD=1 \ cargo test -p photocraft-ml --features onnx real_models_cpu_smoke -- --ignored --nocapture ``` -Omit `PHOTOCRAFT_MODEL_TEST_DOWNLOAD` to test existing verified files offline. A quantitative -accuracy benchmark with labelled hair, fine structures, multiple objects and transparent -materials remains necessary before making a general improvement claim. This initial contribution -keeps the smart-features scorecard partial for that reason. +Omit `PHOTOCRAFT_MODEL_TEST_DOWNLOAD` to test existing verified files offline. The +[22-case PDF and public supplement](https://github.com/mighty-programmer/photocraft/releases/tag/model-evaluation-2026-10-08) +include an exploratory comparison on 20 fixed COCO polygon targets plus two visual-only photos. +The protocol, model failures, measured scores and reproducible harness are documented in +[local-models-validation.md](local-models-validation.md). These binary instance references do not +establish labelled hair/soft-alpha/transparency matting quality. Representative quality evaluation +and web inference remain open, so the smart-features scorecard stays partial. See [validation and comparison](local-models-validation.md) for the measured 24 MP timings, -before/after Preferences screenshots, actual exported masks and outstanding platform checks. +before/after Preferences screenshots, actual exported masks, completed three-platform native +CI and outstanding packaged-installer/production checks. diff --git a/scorecard/automation.toml b/scorecard/automation.toml index 7878cc73c4..97c6e3507a 100644 --- a/scorecard/automation.toml +++ b/scorecard/automation.toml @@ -58,7 +58,7 @@ id = "AUTO-219-7" target = "Local ONNX models behind a flag, managed in Preferences; subject select, background removal" status = "partial" issue = 219 -note = "local-ml: CPU BiRefNet alpha / SAM 2.1 box selection, pinned verified explicit downloads in Preferences; labelled accuracy benchmarks and web inference remain open" +note = "local-ml: CPU BiRefNet alpha / SAM 2.1 box selection, pinned verified explicit downloads in Preferences; exploratory 20-target COCO comparison in docs/local-models-validation.md; representative matting quality and web inference remain open" [[item]] id = "AUTO-219-8" From 52eb5a154321f3a9b129bc10952f8c3a7e71f0e5 Mon Sep 17 00:00:00 2001 From: mighty-programmer <83077551+mighty-programmer@users.noreply.github.com> Date: Fri, 9 Oct 2026 11:57:46 +0300 Subject: [PATCH 007/649] Preserve upstream controls and verify rebased model integration --- .github/workflows/local-models.yml | 4 ++++ docs/local-models-validation.md | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/.github/workflows/local-models.yml b/.github/workflows/local-models.yml index f5f8a97351..79e6016932 100644 --- a/.github/workflows/local-models.yml +++ b/.github/workflows/local-models.yml @@ -66,6 +66,10 @@ jobs: run: cargo test -p photocraft-ml --features onnx --locked - name: Test commands and CLI with the optional backend run: cargo test -p photocraft-engine -p photocraft-cli --features local-ml --locked + - name: Test model preferences and translated labels + run: | + cargo test -p photocraft-ui-egui --features local-ml --locked prefs_ui::tests + cargo test -p photocraft-ui-egui --features local-ml --locked i18n::tests - name: Check native app and UI with the optional backend run: cargo check -p photocraft -p photocraft-ui-egui --features local-ml --locked - name: Clippy optional backend diff --git a/docs/local-models-validation.md b/docs/local-models-validation.md index a07cbd4f58..2ea48e8c0d 100644 --- a/docs/local-models-validation.md +++ b/docs/local-models-validation.md @@ -6,6 +6,25 @@ are included in this repository. The integration/performance checks below are su fixed 22-case evaluation. Its 20 labelled COCO targets are exploratory evidence, not a representative or held-out benchmark, a soft-alpha matting assessment, or evidence of a universal winner. +## Upstream integration check: 2026-10-09 + +Rebased on upstream `ec350d64aedd019afc5eda290cc32909bc9bab7d`. The integration keeps the +upstream Rotate View preference and Linux Wayland snapshot behavior alongside the optional +model controls. It adds model labels to the newly supported Greek catalog and keeps every +upstream translation and contributor entry. Additive catalog/self-credit blocks are placed +before existing entries to reduce conflicts with future upstream additions. + +The native optional-backend suites passed on macOS: engine unit tests **944 passed / 11 ignored**, +UI unit tests **1,107 passed / 7 ignored**, plus ML runtime and CLI integration tests. Six-package +all-target Clippy with warnings denied, the default native build, layers, 627/627 parity, +regenerated scorecard, optional-backend adversarial panic hunt, full L0–L6 wasm and optional +engine/UI wasm checks passed. Ignored tests are not counted as passes. The native matrix now +also runs model Preferences and complete-language catalog tests; its current run is linked from +[#1199](https://github.com/storytold/photocraft/pull/1199). + +The real-image measurements and screenshots below remain the earlier evidence at their stated +commits; rebasing does not turn them into a new accuracy or performance benchmark. + ## Preferences before and after Before, from the unmodified `5896f0b` source: From 69f1cbeeafbf013e31ce9d875e5f8e408a8f0671 Mon Sep 17 00:00:00 2001 From: mighty-programmer <83077551+mighty-programmer@users.noreply.github.com> Date: Fri, 9 Oct 2026 12:19:56 +0300 Subject: [PATCH 008/649] Record current upstream checks and focus UI matrix targets --- .github/workflows/local-models.yml | 4 ++-- docs/local-models-validation.md | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/local-models.yml b/.github/workflows/local-models.yml index 79e6016932..8e387b2493 100644 --- a/.github/workflows/local-models.yml +++ b/.github/workflows/local-models.yml @@ -68,8 +68,8 @@ jobs: run: cargo test -p photocraft-engine -p photocraft-cli --features local-ml --locked - name: Test model preferences and translated labels run: | - cargo test -p photocraft-ui-egui --features local-ml --locked prefs_ui::tests - cargo test -p photocraft-ui-egui --features local-ml --locked i18n::tests + cargo test -p photocraft-ui-egui --features local-ml --locked --lib prefs_ui::tests + cargo test -p photocraft-ui-egui --features local-ml --locked --lib i18n::tests - name: Check native app and UI with the optional backend run: cargo check -p photocraft -p photocraft-ui-egui --features local-ml --locked - name: Clippy optional backend diff --git a/docs/local-models-validation.md b/docs/local-models-validation.md index 2ea48e8c0d..0b24e5a641 100644 --- a/docs/local-models-validation.md +++ b/docs/local-models-validation.md @@ -8,14 +8,14 @@ or held-out benchmark, a soft-alpha matting assessment, or evidence of a univers ## Upstream integration check: 2026-10-09 -Rebased on upstream `ec350d64aedd019afc5eda290cc32909bc9bab7d`. The integration keeps the -upstream Rotate View preference and Linux Wayland snapshot behavior alongside the optional +Integrated upstream `2515fa7cee624cf232c873ba283aa0359ec159d7`. The integration keeps the +upstream Rotate View preference, Linux display-server selection and Wayland snapshot behavior alongside the optional model controls. It adds model labels to the newly supported Greek catalog and keeps every upstream translation and contributor entry. Additive catalog/self-credit blocks are placed before existing entries to reduce conflicts with future upstream additions. -The native optional-backend suites passed on macOS: engine unit tests **944 passed / 11 ignored**, -UI unit tests **1,107 passed / 7 ignored**, plus ML runtime and CLI integration tests. Six-package +The native optional-backend suites passed on macOS: engine unit tests **945 passed / 11 ignored**, +UI unit tests **1,112 passed / 7 ignored**, plus ML runtime and CLI integration tests. Five-package all-target Clippy with warnings denied, the default native build, layers, 627/627 parity, regenerated scorecard, optional-backend adversarial panic hunt, full L0–L6 wasm and optional engine/UI wasm checks passed. Ignored tests are not counted as passes. The native matrix now From f3e0c208ce442c0f027d4b734c4fcb6995da27e5 Mon Sep 17 00:00:00 2001 From: mighty-programmer <83077551+mighty-programmer@users.noreply.github.com> Date: Sat, 10 Oct 2026 22:37:09 +0300 Subject: [PATCH 009/649] Address local-model review conditions and preserve upstream updates --- .github/workflows/local-models.yml | 23 +------------ Cargo.lock | 2 +- contributors/people.toml | 9 ++--- crates/ui-egui/src/i18n/cs.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/de.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/el.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/es.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/fr.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/id.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/it.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/ja.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/ko.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/nl.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/pl.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/pt-br.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/ru.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/uk.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/zh-hans.tsv | 20 +++++++++++ crates/ui-egui/src/i18n/zh-hant.tsv | 20 +++++++++++ crates/ui-egui/src/prefs_ui.rs | 52 +++++++++++++++++++++++++---- docs/development.md | 8 +++++ docs/gaps.md | 11 ++++-- docs/local-models.md | 30 +++++++++++++++-- docs/scorecard.md | 12 +++---- 24 files changed, 423 insertions(+), 44 deletions(-) diff --git a/.github/workflows/local-models.yml b/.github/workflows/local-models.yml index 8e387b2493..bf382759a0 100644 --- a/.github/workflows/local-models.yml +++ b/.github/workflows/local-models.yml @@ -1,27 +1,7 @@ name: Optional local models +# This optional, native-only gate runs solely on an explicit maintainer/contributor request. on: - # Let contributors verify native platforms in their fork before maintainer approval of PR CI. - push: - paths: - - "crates/ml/**" - - "crates/engine/**" - - "crates/ui-egui/**" - - "apps/photocraft/**" - - "apps/photocraft-cli/**" - - "Cargo.toml" - - "Cargo.lock" - - ".github/workflows/local-models.yml" - pull_request: - paths: - - "crates/ml/**" - - "crates/engine/**" - - "crates/ui-egui/**" - - "apps/photocraft/**" - - "apps/photocraft-cli/**" - - "Cargo.toml" - - "Cargo.lock" - - ".github/workflows/local-models.yml" workflow_dispatch: permissions: @@ -33,7 +13,6 @@ concurrency: jobs: cpu: - if: ${{ github.event_name != 'push' || github.event.repository.fork }} name: CPU (${{ matrix.os }}) runs-on: ${{ matrix.os }} timeout-minutes: 45 diff --git a/Cargo.lock b/Cargo.lock index c3a6f38646..09b8031584 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4597,7 +4597,7 @@ dependencies = [ [[package]] name = "photocraft-ml" -version = "0.5.0" +version = "0.6.0" dependencies = [ "ort", "photocraft-algo", diff --git a/contributors/people.toml b/contributors/people.toml index 4ed028a4ab..60ad955ac5 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -17,6 +17,11 @@ # To remove your names, delete your entry (or set fields empty) in a PR. The next # contributors.py run, and the next build, drop them. +[people.mighty-programmer] +real_name = "John Pantrakis" +sync_github_name = true + + [people.AlanRockefeller] sync_github_name = true @@ -90,7 +95,3 @@ sync_github_name = false [people.vangel76] sync_github_name = true - -[people.mighty-programmer] -real_name = "John Pantrakis" -sync_github_name = true diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index c121ee3403..ef70f0c8b7 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -21,6 +21,26 @@ # (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...) stay in Latin letters; the trailing "…" of # dialog commands is kept. +# Optional local selection models. + Subject / background removal Výběr subjektu / odstranění pozadí + Object selection Výběr objektu + Classical (built in) Klasická metoda (vestavěná) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download Stáhnout + Download a model before choosing it. Downloads do not change the current method. Před výběrem model stáhněte. Stažení nemění aktuální metodu. + Downloaded Staženo + In use… Používá se… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. Velké modely mohou trvat déle a použít několik GB paměti. Průběh a Zrušit se zobrazují na stavovém řádku. + Local models aren't available in this build or session. Místní modely nejsou v tomto sestavení nebo relaci dostupné. + Local selection models Místní modely výběru + Model details Podrobnosti modelu + Models run on this device. Images stay on this device. Modely běží na tomto zařízení. Obrázky zůstávají na tomto zařízení. + Not downloaded Nestaženo + Remove download Odstranit stažený model + Select Subject and Remove Background; detailed, soft edges Vybrat objekt a odstranit pozadí; podrobné, měkké okraje + Object Selection; drag a box around the object Výběr objektu; nakreslete rámeček kolem objektu + File Soubor Edit Úpravy Image Obraz diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 21b3a3f156..de05e93eeb 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -17,6 +17,26 @@ # way. Product and technology names (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...) stay in Latin # letters; the trailing "…" of dialog commands is kept. Plural rule: one|other (n != 1 -> other). +# Optional local selection models. + Subject / background removal Motiv / Hintergrund entfernen + Object selection Objektauswahl + Classical (built in) Klassische Methode (integriert) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download Herunterladen + Download a model before choosing it. Downloads do not change the current method. Laden Sie ein Modell herunter, bevor Sie es auswählen. Downloads ändern die aktuelle Methode nicht. + Downloaded Heruntergeladen + In use… Wird verwendet… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. Große Modelle können Zeit und mehrere GB Arbeitsspeicher benötigen. Fortschritt und Abbrechen erscheinen in der Statusleiste. + Local models aren't available in this build or session. Lokale Modelle sind in diesem Build oder dieser Sitzung nicht verfügbar. + Local selection models Lokale Auswahlmodelle + Model details Modelldetails + Models run on this device. Images stay on this device. Modelle laufen auf diesem Gerät. Bilder bleiben auf diesem Gerät. + Not downloaded Nicht heruntergeladen + Remove download Download entfernen + Select Subject and Remove Background; detailed, soft edges Motiv auswählen und Hintergrund entfernen; detaillierte, weiche Kanten + Object Selection; drag a box around the object Objektauswahl; einen Rahmen um das Objekt ziehen + File Datei Edit Bearbeiten Image Bild diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 2100ea27ad..2df9564fb9 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -4,6 +4,26 @@ # Columns separated by TAB: context, English source, Greek translation. # Original translations based on general Greek graphics/computing terminology. # Covers every source label the i18n coverage check lists. +# Optional local selection models. + Subject / background removal Θέμα / αφαίρεση φόντου + Object selection Επιλογή αντικειμένου + Classical (built in) Κλασική μέθοδος (ενσωματωμένη) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download Λήψη + Download a model before choosing it. Downloads do not change the current method. Κάντε λήψη ενός μοντέλου πριν το επιλέξετε. Οι λήψεις δεν αλλάζουν την τρέχουσα μέθοδο. + Downloaded Έγινε λήψη + In use… Σε χρήση… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. Τα μεγάλα μοντέλα μπορεί να χρειαστούν χρόνο και αρκετά GB μνήμης. Η πρόοδος και η Ακύρωση εμφανίζονται στη γραμμή κατάστασης. + Local models aren't available in this build or session. Τα τοπικά μοντέλα δεν είναι διαθέσιμα σε αυτή την έκδοση ή συνεδρία. + Local selection models Τοπικά μοντέλα επιλογής + Model details Λεπτομέρειες μοντέλου + Models run on this device. Images stay on this device. Τα μοντέλα εκτελούνται σε αυτή τη συσκευή. Οι εικόνες παραμένουν σε αυτή τη συσκευή. + Not downloaded Δεν έχει γίνει λήψη + Remove download Διαγραφή λήψης + Select Subject and Remove Background; detailed, soft edges Επιλογή θέματος και αφαίρεση φόντου· λεπτομερή, απαλά όρια + Object Selection; drag a box around the object Επιλογή αντικειμένου· σύρετε ένα πλαίσιο γύρω από το αντικείμενο + File Αρχείο Edit Επεξεργασία Image Εικόνα diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 0647b59dc3..1a171b3d72 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -13,6 +13,26 @@ # resource, string table or product UI was consulted or copied; add entries the same way. # Product and technology names (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...) stay in Latin # letters; the trailing "…" of dialog commands is kept. +# Optional local selection models. + Subject / background removal Sujeto / eliminación del fondo + Object selection Selección de objetos + Classical (built in) Método clásico (incluido) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download Descargar + Download a model before choosing it. Downloads do not change the current method. Descarga un modelo antes de elegirlo. Las descargas no cambian el método actual. + Downloaded Descargado + In use… En uso… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. Los modelos grandes pueden tardar y usar varios GB de memoria. El progreso y Cancelar aparecen en la barra de estado. + Local models aren't available in this build or session. Los modelos locales no están disponibles en esta compilación o sesión. + Local selection models Modelos de selección locales + Model details Detalles del modelo + Models run on this device. Images stay on this device. Los modelos se ejecutan en este dispositivo. Las imágenes permanecen en este dispositivo. + Not downloaded Sin descargar + Remove download Eliminar descarga + Select Subject and Remove Background; detailed, soft edges Seleccionar sujeto y eliminar fondo; bordes suaves y detallados + Object Selection; drag a box around the object Selección de objetos; dibuja un recuadro alrededor del objeto + File Archivo Edit Edición Image Imagen diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index daa78d6f7d..decf620f00 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -20,6 +20,26 @@ # « : ; ? ! » and "%", and inside guillemets « … ». Product and technology names (PhotoCraft, # ArtCraft, OpenType, Lab ...) stay as they are; RGB/CMYK read RVB/CMJN; the trailing "…" of # dialog commands is kept. +# Optional local selection models. + Subject / background removal Sujet / suppression de l’arrière-plan + Object selection Sélection d’objet + Classical (built in) Méthode classique (intégrée) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download Télécharger + Download a model before choosing it. Downloads do not change the current method. Téléchargez un modèle avant de le choisir. Le téléchargement ne change pas la méthode actuelle. + Downloaded Téléchargé + In use… En cours d’utilisation… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. Les grands modèles peuvent prendre du temps et utiliser plusieurs Go de mémoire. La progression et Annuler apparaissent dans la barre d’état. + Local models aren't available in this build or session. Les modèles locaux ne sont pas disponibles dans cette version ou session. + Local selection models Modèles de sélection locaux + Model details Détails du modèle + Models run on this device. Images stay on this device. Les modèles s’exécutent sur cet appareil. Les images restent sur cet appareil. + Not downloaded Non téléchargé + Remove download Supprimer le téléchargement + Select Subject and Remove Background; detailed, soft edges Sélectionner le sujet et supprimer l’arrière-plan ; contours fins et doux + Object Selection; drag a box around the object Sélection d’objet ; tracer un cadre autour de l’objet + File Fichier Edit Édition Image Image diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index a5118bda91..4bfa6ee628 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -13,6 +13,26 @@ # resource, string table or product UI was consulted or copied; add entries the same way. # Product and technology names (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...) stay in Latin # letters; the trailing "…" of dialog commands is kept. +# Optional local selection models. + Subject / background removal Subjek / penghapusan latar belakang + Object selection Seleksi objek + Classical (built in) Metode klasik (bawaan) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download Unduh + Download a model before choosing it. Downloads do not change the current method. Unduh model sebelum memilihnya. Unduhan tidak mengubah metode saat ini. + Downloaded Sudah diunduh + In use… Sedang digunakan… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. Model besar dapat membutuhkan waktu dan beberapa GB memori. Progres dan Batal muncul di bilah status. + Local models aren't available in this build or session. Model lokal tidak tersedia dalam build atau sesi ini. + Local selection models Model seleksi lokal + Model details Detail model + Models run on this device. Images stay on this device. Model dijalankan di perangkat ini. Gambar tetap berada di perangkat ini. + Not downloaded Belum diunduh + Remove download Hapus unduhan + Select Subject and Remove Background; detailed, soft edges Pilih Subjek dan Hapus Latar Belakang; tepi halus dan terperinci + Object Selection; drag a box around the object Pemilihan Objek; seret kotak di sekitar objek + File Berkas Edit Edit Image Gambar diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 10356202de..3a6daa3956 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -13,6 +13,26 @@ # resource, string table or product UI was consulted or copied; add entries the same way. # Product and technology names (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...) stay in Latin # letters; the trailing … of dialog commands is kept. +# Optional local selection models. + Subject / background removal Soggetto / rimozione dello sfondo + Object selection Selezione oggetti + Classical (built in) Metodo classico (integrato) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download Scarica + Download a model before choosing it. Downloads do not change the current method. Scarica un modello prima di sceglierlo. Il download non cambia il metodo attuale. + Downloaded Scaricato + In use… In uso… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. I modelli grandi possono richiedere tempo e diversi GB di memoria. Avanzamento e Annulla appaiono nella barra di stato. + Local models aren't available in this build or session. I modelli locali non sono disponibili in questa build o sessione. + Local selection models Modelli di selezione locali + Model details Dettagli del modello + Models run on this device. Images stay on this device. I modelli vengono eseguiti su questo dispositivo. Le immagini restano su questo dispositivo. + Not downloaded Non scaricato + Remove download Rimuovi download + Select Subject and Remove Background; detailed, soft edges Seleziona soggetto e rimuovi sfondo; bordi morbidi e dettagliati + Object Selection; drag a box around the object Selezione oggetto; trascina un riquadro attorno all’oggetto + File File Edit Modifica Image Immagine diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 1a83a49836..79065f8561 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -17,6 +17,26 @@ # Product and technology names (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...) stay in Latin # letters; the trailing "…" of dialog commands is kept. +# Optional local selection models. + Subject / background removal 被写体選択 / 背景の削除 + Object selection オブジェクト選択 + Classical (built in) 従来の方法(内蔵) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download ダウンロード + Download a model before choosing it. Downloads do not change the current method. モデルをダウンロードしてから選択してください。ダウンロードだけでは現在の方法は変わりません。 + Downloaded ダウンロード済み + In use… 使用中… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. 大きなモデルは時間と数GBのメモリを使う場合があります。進捗とキャンセルはステータスバーに表示されます。 + Local models aren't available in this build or session. このビルドまたはセッションではローカルモデルを利用できません。 + Local selection models ローカル選択モデル + Model details モデルの詳細 + Models run on this device. Images stay on this device. モデルはこのデバイス上で実行されます。画像はこのデバイス上に留まります。 + Not downloaded 未ダウンロード + Remove download ダウンロードを削除 + Select Subject and Remove Background; detailed, soft edges 被写体を選択して背景を削除。細部を保った柔らかなエッジ + Object Selection; drag a box around the object オブジェクト選択。オブジェクトを囲む矩形をドラッグ + File ファイル Edit 編集 Image 画像 diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index afb127f18b..d7eb91d102 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -9,6 +9,26 @@ # Licensed MIT OR Apache-2.0. See LICENSE-translations.txt and ATTRIBUTION.md. # Product names and technology names retain their spelling. +# Optional local selection models. + Subject / background removal 피사체 선택 / 배경 제거 + Object selection 개체 선택 + Classical (built in) 기존 방식 (내장) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download 다운로드 + Download a model before choosing it. Downloads do not change the current method. 모델을 다운로드한 후 선택하세요. 다운로드는 현재 방식을 변경하지 않습니다. + Downloaded 다운로드됨 + In use… 사용 중… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. 큰 모델은 시간이 걸리고 수 GB의 메모리를 사용할 수 있습니다. 진행률과 취소는 상태 표시줄에 나타납니다. + Local models aren't available in this build or session. 이 빌드 또는 세션에서는 로컬 모델을 사용할 수 없습니다. + Local selection models 로컬 선택 모델 + Model details 모델 세부 정보 + Models run on this device. Images stay on this device. 모델은 이 기기에서 실행됩니다. 이미지는 이 기기에 보관됩니다. + Not downloaded 다운로드되지 않음 + Remove download 다운로드 삭제 + Select Subject and Remove Background; detailed, soft edges 피사체 선택 및 배경 제거; 섬세하고 부드러운 가장자리 + Object Selection; drag a box around the object 개체 선택; 개체 주위에 상자를 드래그하세요 + File 파일 Edit 편집 Image 이미지 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index f32b2398f8..76c80402a2 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -8,6 +8,26 @@ # stay as they are; the trailing "…" of dialog commands is kept. UI text addresses the user # informally ("je") and uses sentence case. +# Optional local selection models. + Subject / background removal Onderwerp / achtergrond verwijderen + Object selection Objectselectie + Classical (built in) Klassiek (ingebouwd) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download Downloaden + Download a model before choosing it. Downloads do not change the current method. Download een model voordat u het kiest. Downloads wijzigen de huidige methode niet. + Downloaded Gedownload + In use… In gebruik… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. Grote modellen kunnen lang duren en meerdere GB geheugen gebruiken. Voortgang en Annuleren verschijnen in de statusbalk. + Local models aren't available in this build or session. Lokale modellen zijn niet beschikbaar in deze build of sessie. + Local selection models Lokale selectiemodellen + Model details Modeldetails + Models run on this device. Images stay on this device. Modellen draaien op dit apparaat. Afbeeldingen blijven op dit apparaat. + Not downloaded Niet gedownload + Remove download Download verwijderen + Select Subject and Remove Background; detailed, soft edges Onderwerp selecteren en achtergrond verwijderen; gedetailleerde, zachte randen + Object Selection; drag a box around the object Objectselectie; sleep een kader rond het object + File Bestand Edit Bewerken Image Afbeelding diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 87d310620f..db8647efb3 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -20,6 +20,26 @@ # Conventions: menus are nouns (Plik, Edycja, Obraz ...), commands are infinitives (Otwórz…, # Zapisz jako…), sentence case as in the English source. Quotes: „…”. +# Optional local selection models. + Subject / background removal Temat / usuwanie tła + Object selection Zaznaczanie obiektów + Classical (built in) Metoda klasyczna (wbudowana) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download Pobierz + Download a model before choosing it. Downloads do not change the current method. Pobierz model przed jego wybraniem. Pobieranie nie zmienia bieżącej metody. + Downloaded Pobrano + In use… W użyciu… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. Duże modele mogą potrzebować czasu i kilku GB pamięci. Postęp i przycisk Anuluj są wyświetlane na pasku stanu. + Local models aren't available in this build or session. Modele lokalne nie są dostępne w tej wersji lub sesji. + Local selection models Lokalne modele zaznaczania + Model details Szczegóły modelu + Models run on this device. Images stay on this device. Modele działają na tym urządzeniu. Obrazy pozostają na tym urządzeniu. + Not downloaded Nie pobrano + Remove download Usuń pobrany model + Select Subject and Remove Background; detailed, soft edges Zaznacz temat i Usuń tło; szczegółowe, miękkie krawędzie + Object Selection; drag a box around the object Zaznaczanie obiektów; przeciągnij prostokąt wokół obiektu + File Plik Edit Edycja Image Obraz diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index e51132fdf3..d37117c302 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -17,6 +17,26 @@ # entries the same way. Product and technology names (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...) # stay as they are; the trailing "…" of dialog commands is kept. +# Optional local selection models. + Subject / background removal Assunto / remoção de fundo + Object selection Seleção de objetos + Classical (built in) Método clássico (incluído) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download Baixar + Download a model before choosing it. Downloads do not change the current method. Baixe um modelo antes de escolhê-lo. O download não altera o método atual. + Downloaded Baixado + In use… Em uso… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. Modelos grandes podem demorar e usar vários GB de memória. O progresso e Cancelar aparecem na barra de status. + Local models aren't available in this build or session. Modelos locais não estão disponíveis nesta versão ou sessão. + Local selection models Modelos de seleção locais + Model details Detalhes do modelo + Models run on this device. Images stay on this device. Os modelos são executados neste dispositivo. As imagens permanecem neste dispositivo. + Not downloaded Não baixado + Remove download Remover download + Select Subject and Remove Background; detailed, soft edges Selecionar assunto e remover fundo; bordas suaves e detalhadas + Object Selection; drag a box around the object Seleção de objeto; arraste uma caixa ao redor do objeto + File Arquivo Edit Editar Image Imagem diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 56580dc26b..4126f2e6f5 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -20,6 +20,26 @@ # the Russian typographic equivalent, with the space the source carries. # Menus +# Optional local selection models. + Subject / background removal Выделение объекта / удаление фона + Object selection Выделение объектов + Classical (built in) Классический метод (встроенный) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download Скачать + Download a model before choosing it. Downloads do not change the current method. Скачайте модель перед выбором. Скачивание не меняет текущий метод. + Downloaded Скачано + In use… Используется… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. Большие модели могут требовать времени и нескольких ГБ памяти. Прогресс и отмена доступны в строке состояния. + Local models aren't available in this build or session. Локальные модели недоступны в этой сборке или сеансе. + Local selection models Локальные модели выделения + Model details Подробнее о модели + Models run on this device. Images stay on this device. Модели работают на этом устройстве. Изображения остаются на этом устройстве. + Not downloaded Не скачано + Remove download Удалить скачанное + Select Subject and Remove Background; detailed, soft edges Выделение объекта и удаление фона; детализированные мягкие края + Object Selection; drag a box around the object Выделение объекта; обведите объект прямоугольником + File Файл Edit Редактирование Image Изображение diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 96eabeca0b..db4b7ff1bd 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -9,6 +9,26 @@ # Licensed MIT OR Apache-2.0. See LICENSE-translations.txt and ATTRIBUTION.md. # Menus +# Optional local selection models. + Subject / background removal Об’єкт / видалення тла + Object selection Вибір об’єкта + Classical (built in) Класичний (вбудований) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download Завантажити + Download a model before choosing it. Downloads do not change the current method. Завантажте модель перед вибором. Завантаження не змінюють поточний метод. + Downloaded Завантажено + In use… Використовується… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. Великі моделі можуть працювати довго та використовувати кілька ГБ пам’яті. Прогрес і Скасувати з’являються в рядку стану. + Local models aren't available in this build or session. Локальні моделі недоступні в цій збірці або сеансі. + Local selection models Локальні моделі вибору + Model details Відомості про модель + Models run on this device. Images stay on this device. Моделі працюють на цьому пристрої. Зображення залишаються на цьому пристрої. + Not downloaded Не завантажено + Remove download Видалити завантаження + Select Subject and Remove Background; detailed, soft edges Вибір об’єкта та видалення тла; докладні, м’які краї + Object Selection; drag a box around the object Вибір об’єкта; перетягніть рамку навколо об’єкта + File Файл Edit Редагування Image Зображення diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 1f9da7010d..9abbbab805 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -13,6 +13,26 @@ # Licensed MIT OR Apache-2.0, as the code. # Product and technology names retain their spelling. See docs/localization-zh-hans.md. +# Optional local selection models. + Subject / background removal 主体选择 / 移除背景 + Object selection 对象选择 + Classical (built in) 传统方法(内置) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download 下载 + Download a model before choosing it. Downloads do not change the current method. 请先下载模型再选择。下载不会改变当前方法。 + Downloaded 已下载 + In use… 使用中… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. 大型模型可能耗时并占用数 GB 内存。进度和取消按钮显示在状态栏中。 + Local models aren't available in this build or session. 此版本或会话无法使用本地模型。 + Local selection models 本地选择模型 + Model details 模型详情 + Models run on this device. Images stay on this device. 模型在此设备上运行。图像保留在此设备上。 + Not downloaded 未下载 + Remove download 删除下载 + Select Subject and Remove Background; detailed, soft edges 选择主体和移除背景;精细、柔和的边缘 + Object Selection; drag a box around the object 对象选择;拖动矩形框以包围对象 + File 文件 Edit 编辑 Image 图像 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 3fcd92cc04..5490ada2ef 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -21,6 +21,26 @@ # kept. Full-width punctuation (,。:) inside sentences; half-width parentheses and the " · " # separators as in the English. +# Optional local selection models. + Subject / background removal 主體選取 / 移除背景 + Object selection 物件選取 + Classical (built in) 傳統方法(內建) + BiRefNet HR Matting BiRefNet HR Matting + SAM 2.1 Large SAM 2.1 Large + Download 下載 + Download a model before choosing it. Downloads do not change the current method. 請先下載模型再選擇。下載不會變更目前的方法。 + Downloaded 已下載 + In use… 使用中… + Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar. 大型模型可能耗時並使用數 GB 記憶體。進度與取消按鈕顯示在狀態列中。 + Local models aren't available in this build or session. 此版本或工作階段無法使用本機模型。 + Local selection models 本機選取模型 + Model details 模型詳細資訊 + Models run on this device. Images stay on this device. 模型在此裝置上執行。影像保留在此裝置上。 + Not downloaded 尚未下載 + Remove download 刪除下載 + Select Subject and Remove Background; detailed, soft edges 選取主體和移除背景;精細、柔和的邊緣 + Object Selection; drag a box around the object 物件選取;拖曳矩形框以包圍物件 + File 檔案 Edit 編輯 Image 影像 diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs index 67e3c596b8..f5c6078d35 100644 --- a/crates/ui-egui/src/prefs_ui.rs +++ b/crates/ui-egui/src/prefs_ui.rs @@ -1323,7 +1323,15 @@ fn model_choice_available(status: &Value, option: &str) -> bool { && status["models"].as_array().into_iter().flatten().any(|m| m["id"].as_str() == Some(option) && m["installed"].as_bool() == Some(true))) } -fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map, order: &[String], lang: crate::i18n::Lang, system: Option, models: &Value) { +fn section_fields( + ui: &mut egui::Ui, + section: &str, + obj: &mut Map, + order: &[String], + lang: crate::i18n::Lang, + system: Option, + models: &Value, +) { let t = Tokens::get(ui.ctx()); if section == "interface" { appearance_rows(ui, obj, system); @@ -1919,6 +1927,38 @@ mod tests { assert_eq!(super::width(shortcuts.as_object().unwrap(), 3000.0), Some(720.0)); } + #[test] + fn local_model_labels_cover_every_complete_language() { + let labels = [ + "Subject / background removal", + "Object selection", + "Classical (built in)", + "BiRefNet HR Matting", + "SAM 2.1 Large", + "Download", + "Download a model before choosing it. Downloads do not change the current method.", + "Downloaded", + "In use…", + "Large models can take time and use several GB of memory. Progress and Cancel appear in the status bar.", + "Local models aren't available in this build or session.", + "Local selection models", + "Model details", + "Models run on this device. Images stay on this device.", + "Not downloaded", + "Remove download", + "Select Subject and Remove Background; detailed, soft edges", + "Object Selection; drag a box around the object", + ]; + for info in &crate::i18n::LANGUAGES { + if !info.complete_menus { + continue; + } + let lang = crate::i18n::Lang::from_pref(info.code); + let missing: Vec<_> = labels.iter().filter(|label| !crate::i18n::has(lang, label)).collect(); + assert!(missing.is_empty(), "{}: missing model labels: {missing:?}", info.code); + } + } + #[test] fn local_model_choices_need_a_backend_and_a_download() { assert!(model_choice_available(&json!({"available":false}), "classical")); @@ -2493,9 +2533,7 @@ mod tests { assert!(has_visible_fields(&values, "integrations")); assert!(has_visible_fields(&values, "enhancedControls")); // Every setting of these sections is still unimplemented. - for section in ["scratchDisks"] { - assert!(!has_visible_fields(&values, section), "{section}"); - } + assert!(!has_visible_fields(&values, "scratchDisks")); // "Fill new type layers with placeholder text" and "Use Escape to Commit" are live; other Type rows stay hidden. assert!(has_visible_fields(&values, "type")); assert!(!prefs::is_hidden("type.fillNewTypeLayersWithPlaceholder")); @@ -2698,8 +2736,10 @@ mod tests { fn next_launch_notice_does_not_mark_unrelated_interface_preferences() { use egui_kittest::{Harness, kittest::Queryable}; let obj = json!({"showTooltips": true}).as_object().unwrap().clone(); - let mut h = - Harness::new_ui_state(|ui, obj: &mut Map| section_fields(ui, "interface", obj, &[], crate::i18n::Lang::from_pref("en"), None), obj); + let mut h = Harness::new_ui_state( + |ui, obj: &mut Map| section_fields(ui, "interface", obj, &[], crate::i18n::Lang::from_pref("en"), None, &json!({"available":false})), + obj, + ); h.run_steps(4); assert!(h.query_by_label("Applies at next launch.").is_none()); h.get_by_label("Show tooltips").click(); diff --git a/docs/development.md b/docs/development.md index c62e7a79d8..6941d55059 100644 --- a/docs/development.md +++ b/docs/development.md @@ -50,6 +50,14 @@ Optional CPU models for Object Selection, Select Subject and Remove Background a `--features local-ml`. Weights remain separate, explicit downloads. See [local models](local-models.md) for Preferences, CLI, provenance and native runtime packaging details. +The native `local-ml` feature also enables `ort`'s `download-binaries` feature. Its pinned +ONNX Runtime 1.28 redistribution is fetched at **build time**, separately from Cargo crates +and the optional learned weights. A fresh `local-ml` build therefore requires network access +and is **not reproducible offline from Cargo.lock alone**. `cargo --offline` controls Cargo +resolution; it does not supply that runtime archive. Default builds and wasm omit this +dependency. Enabled distributors must ship the runtime licence and third-party notices; +see [native runtime packaging](local-models.md#build-and-use). + The dev profile builds with `debug = "line-tables-only"`: panic backtraces keep file and line, and test binaries link about twice as fast. To inspect local variables in a debugger, build with `CARGO_PROFILE_DEV_DEBUG=true`. ### Faster test loops diff --git a/docs/gaps.md b/docs/gaps.md index b360009f4d..c716db2578 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -101,11 +101,15 @@ what an agent can't finish alone. ### G15. AI and generative features - **Missing:** Generative Fill and Expand, Generative Upscale, Neural Filters, Sky Replacement, - Super Zoom, ML Select Subject/Sky. There is no ML runtime (AUTO-219-7). Classical substitutes - exist (GrabCut/max-flow selection, Remove tool by non-local patch completion). + Super Zoom and ML Select Sky. The off-by-default `local-ml` backend supplies optional + BiRefNet subject matting/removal and SAM box selection (AUTO-219-7 remains partial). + Its 20-target COCO pilot is exploratory, not representative alpha-matting quality; + web inference and accelerated providers remain open. Classical substitutes exist + (GrabCut/max-flow selection, Remove tool by non-local patch completion). - **Evidence:** Photoshop's `Required/UXP` ships the Neural Filters gallery and its `.kys` has a Neural Filters taskspace; users ask for local models (#2313, #1996, #2682). -- **Estimate:** 300–600 h. **Human:** owner decision #41 (model licences, local vs remote). +- **Estimate:** 300–600 h. **Human:** owner decision #41 (generative provider interface). +- **2026-10-10 evidence:** [optional models](local-models.md), [pilot and limitations](local-models-validation.md); no new accuracy measurement from the rebase. ### G16. Plug-in compatibility - **Missing:** hosting Photoshop .8BF filters (#2647), UXP panels, CEP. PhotoCraft has its own @@ -211,5 +215,6 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| +| 2026-10-10 | minor | G15 records optional local selection models and the exploratory pilot; generative provider work remains open | | 2026-10-10 | minor | Checked against the alpha gate (no alpha blockers); #2374 marked closed | | 2026-10-10 | major | First version, from the full re-measure against Photoshop 2026 27.11.0 and the open issues | diff --git a/docs/local-models.md b/docs/local-models.md index 9b889f3bd4..1e76d6f6a1 100644 --- a/docs/local-models.md +++ b/docs/local-models.md @@ -101,6 +101,31 @@ decision, and this change does not enable the feature in official release workfl ## Provenance and review +### Why these community exports + +Source review on 2026-10-10 found no ONNX files in the exact official checkpoint trees: +[BiRefNet HR Matting at `5d6b6f8`](https://huggingface.co/ZhengPeng7/BiRefNet_HR-matting/tree/5d6b6f8adcb5b417c871b1d84ceaae9871355b7f) +publishes Safetensors; [Meta SAM 2.1 Large at `665f8e2`](https://huggingface.co/facebook/sam2.1-hiera-large/tree/665f8e2ad61cf5f53d65644ff27c8ee525124610) +publishes Safetensors and a PyTorch checkpoint. This Rust backend needs ONNX graphs, so it +retains the already evaluated FP32 exports below rather than introducing Python/PyTorch or +changing the benchmarked model variant. No Hugging Face Python or `trust_remote_code` runs. + +The [pinned PinkPixel card](https://huggingface.co/PinkPixel/birefnet-hr-matting-onnx/blob/792518b9d4dfe9793891712677de25e554f948c6/README.md) +identifies the original BiRefNet checkpoint and documents its 2048-pixel input/alpha contract. +The [pinned onnx-community configuration](https://huggingface.co/onnx-community/sam2.1-hiera-large-ONNX/blob/3c23431f721e69cae82dbfd0c28fd692cc714021/config.json) +specifies FP32 SAM 2 at 1024 pixels; that revision has no model card or conversion recipe. +Our review therefore relies on graph/IO inspection, actual CPU execution of both downloaded +models and the published 22-case output evidence, with failures retained. It does not claim +independent verification of the conversion's equivalence to Meta's checkpoint. + +Every selected artifact's LFS byte count and SHA-256 was rechecked against its immutable +export revision on 2026-10-10 and still matches the catalog. Exact pins, streaming integrity +checks, explicit opt-in, original-model licences and evaluated outputs make these +community artifacts reviewable; hashes establish identity, not training provenance or +upstream endorsement. A compatible author-published ONNX export can replace one through a +future reviewed catalog/adapter update and new output comparisons. + + All URLs, exact byte counts and SHA-256 hashes are in [`crates/ml/src/catalog.rs`](../crates/ml/src/catalog.rs), derived from the pinned exports' Hugging Face LFS metadata. A model update requires a code change and review; there is no mutable remote @@ -124,8 +149,9 @@ cargo test -p photocraft-engine -p photocraft-cli --features local-ml cargo clippy -p photocraft-ml -p photocraft-engine --features photocraft-ml/onnx,local-ml --all-targets -- -D warnings ``` -`.github/workflows/local-models.yml` exercises CPU runtime contracts, commands and native build -paths on Windows, Linux and macOS without downloading learned weights. The opt-in full-model +`.github/workflows/local-models.yml` is **manual-only** (`workflow_dispatch`): no push or +pull-request trigger. An explicit run exercises CPU runtime contracts, commands, Preferences, +catalogs and native build paths on Windows, Linux and macOS without downloading learned weights. The opt-in full-model smoke test is separate; the download flag is explicit and transfers about 1.8 GB: ```sh diff --git a/docs/scorecard.md b/docs/scorecard.md index b79ed215f3..5bf470ef2b 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -9,10 +9,10 @@ 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, 15 not run, 7 not measurable yet (baseline 2026-10-05) | | [File compatibility](#file-compatibility) | 5 | 11 | 11 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 | | [Tools](#tools) | 21 | 15 | 6 | | -| [Workspace and UI](#workspace-and-ui) | 6 | 7 | 10 | settings that do nothing: 45 of 149 (target 0) | +| [Workspace and UI](#workspace-and-ui) | 6 | 7 | 10 | settings that do nothing: 45 of 151 (target 0) | | [Type](#type) | 0 | 3 | 6 | | -| [Automation](#automation) | 3 | 2 | 6 | 628 of 628 menu items live (100.0%) | -| [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present | +| [Automation](#automation) | 3 | 3 | 5 | 628 of 628 menu items live (100.0%) | +| [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 29 of 29 crates; panic_hunt present | | [Distribution](#distribution) | 4 | 4 | 3 | | | [Open bugs](#open-bugs) | 22 | 2 | 8 | | @@ -175,7 +175,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t ## Workspace and UI -**Settings that do nothing: 45 of 149** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. +**Settings that do nothing: 45 of 151** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. Unread: `general.color_picker`, `general.beep_when_done`, `general.resize_image_during_place`, `general.always_create_smart_objects_when_placing`, `general.animated_zoom`, `general.zoom_resizes_windows`, `interface.dynamic_color_sliders`, `workspace.auto_collapse_icon_panels`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `workspace.enable_narrow_options_bar`, `tools.enable_flick_panning`, `tools.vary_round_brush_hardness_on_hud`, `tools.show_transformation_values`, `file_handling.image_previews`, `file_handling.save_in_background`, `file_handling.ignore_exif_profile_tag`, `file_handling.maximize_psd_compatibility`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `cursors.brush_preview_color`, `units_and_rulers.type_units`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `units_and_rulers.print_resolution`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.missing_glyph_protection`, `type_.show_font_names_in_english`, `type_.text_engine`, `type_.font_preview`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `enhanced_controls.zoom_with_trackpad_pinch`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`. @@ -232,14 +232,14 @@ Menu wiring (`docs/parity-checklist.md`): 628 of 628 menu items live (100.0%). T | AUTO-219-4 | Replay tests for crop, filters, selections and styled text on a second document | missing | [#219](https://github.com/storytold/photocraft/issues/219) | One replay test (actions.rs:171: new layer, rect select, fill) | | AUTO-219-5 | Batch: subfolders, open documents, naming template, progress/cancel, error log, stop | partial | [#219](https://github.com/storytold/photocraft/issues/219) | file_cmds.rs:590-631 folder/array input, per-file errors; no recursion, template or cancel | | AUTO-219-6 | Plug-in ABI v2: panel kind, progress/cancel calls, read other layers, Last Filter repeats | missing | [#219](https://github.com/storytold/photocraft/issues/219) | runtime.rs:15 ABI_VERSION = 1; manifest.rs:18 Kind::Filter only | -| AUTO-219-7 | Local ONNX models behind a flag, managed in Preferences; subject select, background removal | missing | [#219](https://github.com/storytold/photocraft/issues/219) | No ONNX runtime dependency | +| AUTO-219-7 | Local ONNX models behind a flag, managed in Preferences; subject select, background removal | partial | [#219](https://github.com/storytold/photocraft/issues/219) | local-ml: CPU BiRefNet alpha / SAM 2.1 box selection, pinned verified explicit downloads in Preferences; exploratory 20-target COCO comparison in docs/local-models-validation.md; representative matting quality and web inference remain open | | AUTO-219-8 | xtask check that every panel button routes through a command id | missing | [#219](https://github.com/storytold/photocraft/issues/219) | No such xtask check | | AUTO-219-9 | Headless commands for in-canvas type editing, Liquify/Puppet strokes, transform handles | done | [#219](https://github.com/storytold/photocraft/issues/219) | type.hitTest, type.caret, type.navigate; filter.liquify strokes, edit.puppetWarp pins, type.edit, edit.transform | | AUTO-219-10 | Agent acceptance suite grown to 30-50 workflows | partial | [#219](https://github.com/storytold/photocraft/issues/219) | automation/tests/agent_tasks.rs runs 10 workflows over MCP | ## Reliability -Never-crash attribute on 28 of 28 crate roots. +Never-crash attribute on 29 of 29 crate roots. | Id | Target | Status | Issue | Note | |---|---|---|---|---| From f48f69b7c4974e114a6e70738ec2c1a3dcf250de Mon Sep 17 00:00:00 2001 From: mighty-programmer <83077551+mighty-programmer@users.noreply.github.com> Date: Sat, 10 Oct 2026 22:43:48 +0300 Subject: [PATCH 010/649] Record final model integration validation on upstream 0.6 --- docs/local-models-validation.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/local-models-validation.md b/docs/local-models-validation.md index 0b24e5a641..4b75ef1c5d 100644 --- a/docs/local-models-validation.md +++ b/docs/local-models-validation.md @@ -6,6 +6,31 @@ are included in this repository. The integration/performance checks below are su fixed 22-case evaluation. Its 20 labelled COCO targets are exploratory evidence, not a representative or held-out benchmark, a soft-alpha matting assessment, or evidence of a universal winner. +## Review update: 2026-10-10 + +Rebased on upstream 0.6.0 (`ab76c242a1225efc680dc88bd761cc202e1e29df`). The optional model +workflow is manual-only (`workflow_dispatch`), with no push/PR triggers. The development guide +now identifies the ONNX Runtime build-time download and offline limitation. The +[export review rationale](local-models.md#why-these-community-exports) links exact official +checkpoint trees and community metadata, explains why ONNX re-exports remain selected, and +separates artifact identity from independently proven conversion equivalence. + +All 18 model labels now cover Dutch and Ukrainian and the other 14 complete catalogs, guarded +by a runtime lookup regression. Existing catalog entries and all other contributors' credits +are preserved. New entries are kept away from append locations to reduce future conflicts. +The lockfile preserves all 728 existing upstream package versions; it adds only the optional +backend entries. Model revisions/bytes and the historical benchmark remain unchanged. + +Fresh optional-native tests, lint, default builds, dependency layers, parity, scorecard, +adversarial command tests and wasm checks are linked from [#1199](https://github.com/storytold/photocraft/pull/1199). +Native engine tests passed 1,169 / 11 ignored; the final UI suite after the file-dialog update +passed 1,721 / 10 ignored, with all integration tests green. Five-package all-target Clippy +(`local-ml,heif`), the default build, layers, parity (628/628), scorecard, optional-feature +adversarial commands, full L0–L6 wasm and optional engine/UI wasm all pass. Ignored tests +are not counted as passes. An offscreen 1200×800 Preferences › Integrations capture was +inspected: both explicit downloads are offered while both selected methods remain Classical. +Historical screenshots below are not current 0.6.0 captures. + ## Upstream integration check: 2026-10-09 Integrated upstream `2515fa7cee624cf232c873ba283aa0359ec159d7`. The integration keeps the From 49e20eeace0be4218bd352fdd01da31aaf87db1c Mon Sep 17 00:00:00 2001 From: mighty-programmer <83077551+mighty-programmer@users.noreply.github.com> Date: Sun, 11 Oct 2026 01:27:50 +0300 Subject: [PATCH 011/649] Fix inherited UI test warning and measure antialiased preview ink --- crates/ui-egui/src/file_dialog/tests.rs | 2 -- crates/ui-egui/tests/drag_preview_canvas.rs | 31 ++++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/crates/ui-egui/src/file_dialog/tests.rs b/crates/ui-egui/src/file_dialog/tests.rs index d490e8b10c..dc4db4c51a 100644 --- a/crates/ui-egui/src/file_dialog/tests.rs +++ b/crates/ui-egui/src/file_dialog/tests.rs @@ -311,8 +311,6 @@ fn save_dialogs_remember_where_each_document_was_last_saved() { FileDialogRequest::Save { suggested } => suggested.clone(), other => panic!("save dialog expected, got {other:?}"), }; - // Suggestions are built with `Path::join`, which uses `\` on Windows (#2745). - let joined = |dir: &str, name: &str| std::path::Path::new(dir).join(name).to_string_lossy().into_owned(); // An export starts beside the document; the user saves it under /renders instead. app.pick_save("result.png", |_, _| Ok(Value::Null)).unwrap(); app.poll_file_dialog(&ctx, None); diff --git a/crates/ui-egui/tests/drag_preview_canvas.rs b/crates/ui-egui/tests/drag_preview_canvas.rs index b3c8cc3f09..4d6dd17a02 100644 --- a/crates/ui-egui/tests/drag_preview_canvas.rs +++ b/crates/ui-egui/tests/drag_preview_canvas.rs @@ -121,31 +121,35 @@ fn render(h: &mut Harness) -> Image { Image { w: img.width(), h: img.height(), px: img.into_raw() } } -/// Fraction of positions along the screen segment `a`–`b` (points) where a pixel within ±2 -/// physical pixels across the line passes `test`. -fn coverage(img: &Image, ppp: f32, a: Pos2, b: Pos2, test: impl Fn(u8) -> bool) -> f32 { +/// Mean contrasting ink along the screen segment `a`–`b` (points), using the strongest pixel +/// within ±2 physical pixels across the line. Antialiased pixels contribute their actual contrast +/// instead of disappearing at a binary luma cutoff. +fn coverage(img: &Image, ppp: f32, a: Pos2, b: Pos2, contrast: impl Fn(u8) -> f32) -> f32 { let (a, b) = (a * ppp, b * ppp); let len = a.distance(b).max(1.0); let dir = (b - a) / len; let normal = egui::vec2(-dir.y, dir.x); // Skip the ends (corners, where the other edges and the readout may be). let n = (len as usize).saturating_sub(16); - let mut hits = 0; + let mut ink = 0.0; for i in 0..n { let p = a + dir * (8.0 + i as f32); - let hit = (-2..=2).any(|o| { - let q = p + normal * o as f32; - img.luma(q.x.round() as i64, q.y.round() as i64).is_some_and(&test) - }); - hits += usize::from(hit); + let strongest = (-2..=2) + .filter_map(|o| { + let q = p + normal * o as f32; + img.luma(q.x.round() as i64, q.y.round() as i64) + }) + .map(&contrast) + .fold(0.0, f32::max); + ink += strongest; } - hits as f32 / n.max(1) as f32 + ink / n.max(1) as f32 } /// Ink that contrasts with `background`: dark on white, light on black. -fn ink(background: &str) -> impl Fn(u8) -> bool { +fn ink(background: &str) -> impl Fn(u8) -> f32 { let white = background == "white"; - move |l| if white { l < 64 } else { l > 192 } + move |l| if white { 1.0 - f32::from(l) / 255.0 } else { f32::from(l) / 255.0 } } /// The four edges of the document rectangle `[x0, y0]`–`[x1, y1]` on screen. @@ -181,8 +185,9 @@ fn marquee_previews_show_while_dragging_on_white_and_black_at_1x_and_2x() { for (mx, my) in [(200.0, 80.0), (300.0, 150.0), (200.0, 220.0), (100.0, 150.0)] { let m = screen(&h, mx, my); let along = if mx == 200.0 { egui::vec2(14.0 / ppp, 0.0) } else { egui::vec2(0.0, 14.0 / ppp) }; + let was = coverage(&before, ppp, m - along, m + along, ink(bg)); let now = coverage(&img, ppp, m - along, m + along, ink(bg)); - assert!(now > 0.3, "{tool} on {bg} @{ppp}x at {m:?}: {now:.2} contrasting"); + assert!(was < 0.05 && now > 0.3, "{tool} on {bg} @{ppp}x at {m:?}: {was:.2} → {now:.2} contrasting"); } } // Each move's frame shows the outline where the pointer is now (no stale frame). From fc48f21f0fa7ba5090f7dc3ee7767d8828ed413d Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 11 Oct 2026 04:34:27 +0200 Subject: [PATCH 012/649] Vanishing Point: on-canvas plane editor with Create/Edit Plane, grid and paste (#3122) Filter > Vanishing Point now opens a dialog mode on the canvas instead of the generic parameter dialog: - Create Plane (C): four clicks, in any order, make a plane (corners are normalised clockwise from the top-left, the order paste expects). - Edit Plane (V): drag corner nodes, or edge nodes to slide an edge along the plane's own perspective; click a plane to select it, Delete removes it. - The plane grid is drawn at the Grid Size, in the accent colour when the plane is valid, warning yellow when its perspective is doubtful and red (outline only) when the quad isn't convex (VpPlane::check). - With an image on the clipboard the selected plane previews it pasted in perspective; drag to move it, Width sets its size, New Layer renders it on a new layer. OK / Enter runs filter.vanishingPoint with the planes and the paste as one history step; the control channel drives the same session through {"ui": {...}}. The engine now rejects a drawn plane whose corners don't form a convex quad (bow-tie, dented) instead of warping along it. Co-Authored-By: Claude Opus 5.5 --- crates/algo/src/vanishing.rs | 86 ++++ crates/engine/src/vp_cmds.rs | 33 +- crates/ui-egui/src/distort_ui.rs | 36 +- crates/ui-egui/src/i18n/cs.tsv | 8 + crates/ui-egui/src/i18n/de.tsv | 8 + crates/ui-egui/src/i18n/el.tsv | 5 + crates/ui-egui/src/i18n/es.tsv | 8 + crates/ui-egui/src/i18n/fr.tsv | 6 + crates/ui-egui/src/i18n/id.tsv | 6 + crates/ui-egui/src/i18n/it.tsv | 8 + crates/ui-egui/src/i18n/ja.tsv | 5 + crates/ui-egui/src/i18n/ko.tsv | 7 + crates/ui-egui/src/i18n/nl.tsv | 5 + crates/ui-egui/src/i18n/pl.tsv | 5 + crates/ui-egui/src/i18n/pt-br.tsv | 6 + crates/ui-egui/src/i18n/ru.tsv | 6 + crates/ui-egui/src/i18n/uk.tsv | 5 + crates/ui-egui/src/i18n/zh-hans.tsv | 8 + crates/ui-egui/src/i18n/zh-hant.tsv | 8 + crates/ui-egui/src/lib.rs | 1 + crates/ui-egui/src/vp_ui.rs | 611 ++++++++++++++++++++++++++++ docs/scorecard.md | 2 +- scorecard/tools.toml | 2 +- 23 files changed, 864 insertions(+), 11 deletions(-) create mode 100644 crates/ui-egui/src/vp_ui.rs diff --git a/crates/algo/src/vanishing.rs b/crates/algo/src/vanishing.rs index 5661d66c9d..77b7bb107c 100644 --- a/crates/algo/src/vanishing.rs +++ b/crates/algo/src/vanishing.rs @@ -114,6 +114,73 @@ impl VpPlane { }); Lifted { focal: f, center: c, pts } } + + /// Turn of each corner (`sin` of the angle between consecutive edges, positive when the + /// corners run clockwise on screen); `None` when an edge is shorter than a pixel or a corner + /// is not finite. + fn turns(&self) -> Option<[f64; 4]> { + let q = &self.corners; + if q.iter().flatten().any(|v| !v.is_finite() || v.abs() > 1e9) { + return None; + } + let e = |i: usize| [q[(i + 1) % 4][0] - q[i][0], q[(i + 1) % 4][1] - q[i][1]]; + let mut out = [0.0; 4]; + for (i, t) in out.iter_mut().enumerate() { + let (a, b) = (e(i), e((i + 1) % 4)); + let (la, lb) = (a[0].hypot(a[1]), b[0].hypot(b[1])); + if la < 1.0 || lb < 1.0 { + return None; + } + *t = (a[0] * b[1] - a[1] * b[0]) / (la * lb); + } + Some(out) + } + + /// How usable the plane is, the way Photoshop colours its grid: [`PlaneCheck::Invalid`] for + /// a quad that isn't convex (self-intersecting, a corner pushed inside, a near-straight or + /// near-zero corner), [`PlaneCheck::Questionable`] for a convex quad whose perspective can't + /// come from a camera centred at `center` (or with a corner sharper than 10°), else + /// [`PlaneCheck::Valid`]. + pub fn check(&self, center: [f64; 2]) -> PlaneCheck { + let Some(t) = self.turns() else { return PlaneCheck::Invalid }; + let same_sign = t.iter().all(|v| *v > 0.0) || t.iter().all(|v| *v < 0.0); + let min = t.iter().fold(f64::MAX, |m, v| m.min(v.abs())); + if !same_sign || min < 1f64.to_radians().sin() || self.homography().is_none() { + return PlaneCheck::Invalid; + } + if min < 10f64.to_radians().sin() { + return PlaneCheck::Questionable; + } + // Both vanishing points finite but no real focal length fits them. + let q = &self.corners; + let (v1, v2) = (meet(q[0], q[1], q[3], q[2]), meet(q[0], q[3], q[1], q[2])); + let finite = |v: V3| v[2].abs() > 1e-9 * (v[0].abs() + v[1].abs()).max(1.0); + if finite(v1) && finite(v2) && self.focal(center).is_none() { + return PlaneCheck::Questionable; + } + PlaneCheck::Valid + } + + /// The same quad with its corners clockwise on screen, starting at the top-left one + /// (the order [`paste`] and [`Scene::tear_off`] expect), however they were clicked. + pub fn normalized(&self) -> VpPlane { + let mut q = self.corners; + if self.turns().is_some_and(|t| t.iter().sum::() < 0.0) { + q = [q[0], q[3], q[2], q[1]]; + } + let first = (0..4).min_by(|&a, &b| (q[a][0] + q[a][1]).total_cmp(&(q[b][0] + q[b][1]))).unwrap_or(0); + VpPlane { corners: [q[first], q[(first + 1) % 4], q[(first + 2) % 4], q[(first + 3) % 4]] } + } +} + +/// Plane validity ([`VpPlane::check`]): Photoshop draws a valid plane's grid blue, a doubtful +/// one yellow and an invalid one red. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum PlaneCheck { + Valid, + Questionable, + Invalid, } impl Lifted { @@ -363,6 +430,25 @@ mod tests { assert!((lu / lv - 2.0).abs() < 0.01, "aspect {}", lu / lv); } + #[test] + fn plane_check_and_corner_order() { + let c = [400.0, 300.0]; + assert_eq!(floor_quad(500.0, c).check(c), PlaneCheck::Valid); + let square = VpPlane { corners: [[10.0, 10.0], [110.0, 10.0], [110.0, 110.0], [10.0, 110.0]] }; + assert_eq!(square.check(c), PlaneCheck::Valid, "fronto-parallel"); + let bowtie = VpPlane { corners: [[10.0, 10.0], [110.0, 110.0], [110.0, 10.0], [10.0, 110.0]] }; + assert_eq!(bowtie.check(c), PlaneCheck::Invalid); + let dent = VpPlane { corners: [[10.0, 10.0], [110.0, 10.0], [40.0, 40.0], [10.0, 110.0]] }; + assert_eq!(dent.check(c), PlaneCheck::Invalid, "concave"); + let sliver = VpPlane { corners: [[10.0, 10.0], [300.0, 10.0], [300.0, 40.0], [200.0, 40.0]] }; + assert_eq!(sliver.check(c), PlaneCheck::Questionable, "a corner sharper than 10°"); + let nan = VpPlane { corners: [[f64::NAN, 10.0], [110.0, 10.0], [110.0, 110.0], [10.0, 110.0]] }; + assert_eq!(nan.check(c), PlaneCheck::Invalid); + // Clicked counter-clockwise from the bottom-right: clockwise from the top-left. + let ccw = VpPlane { corners: [[110.0, 110.0], [110.0, 10.0], [10.0, 10.0], [10.0, 110.0]] }; + assert_eq!(ccw.normalized(), square); + } + #[test] fn tear_off_is_perpendicular_and_shares_the_edge() { let c = [400.0, 300.0]; diff --git a/crates/engine/src/vp_cmds.rs b/crates/engine/src/vp_cmds.rs index 4d386d60d7..185930298a 100644 --- a/crates/engine/src/vp_cmds.rs +++ b/crates/engine/src/vp_cmds.rs @@ -3,7 +3,7 @@ //! ([`photocraft_algo::vanishing`]). The edit lands on the active pixel layer, or on a new layer //! with `"newLayer": true` (Photoshop's advice for non-destructive Vanishing Point work). -use photocraft_algo::vanishing::{Edge, Scene, VpPlane, clone_stroke, paste}; +use photocraft_algo::vanishing::{Edge, PlaneCheck, Scene, VpPlane, clone_stroke, paste}; use photocraft_doc::{Document, Layer, LayerContent, LayerId}; use photocraft_geom::Rect; use photocraft_raster::Surface; @@ -34,12 +34,22 @@ pub fn scene(p: &Value, canvas: Rect) -> Result { let a = v.get("corners")?.as_array()?; Some([pt(a.first()?)?, pt(a.get(1)?)?, pt(a.get(2)?)?, pt(a.get(3)?)?]) }; - let first = corners(&planes[0]).ok_or_else(|| bad("the first plane needs four `corners`"))?; + // A drawn quad must be convex (Photoshop's red plane): a bow-tie or dented quad has no + // perspective to paste or clone along. + let drawn = |i: usize, c: [[f64; 2]; 4]| -> Result { + let pl = VpPlane { corners: c }; + if pl.check(center) == PlaneCheck::Invalid { + return Err(bad(format!("plane {i}: the four corners must form a convex quad"))); + } + Ok(pl) + }; + let first = planes.first().and_then(corners).ok_or_else(|| bad("the first plane needs four `corners`"))?; + let first = drawn(0, first)?; let focal = p.get("focalLength").and_then(Value::as_f64).filter(|f| *f > 0.0); - let mut sc = Scene::new(VpPlane { corners: first }, center, focal, canvas.width().max(canvas.height()) as f64); + let mut sc = Scene::new(first, center, focal, canvas.width().max(canvas.height()) as f64); for (i, pl) in planes.iter().enumerate().skip(1) { if let Some(c) = corners(pl) { - sc.planes.push(VpPlane { corners: c }); + sc.planes.push(drawn(i, c)?); continue; } let from = pl @@ -257,4 +267,19 @@ mod tests { let r = s.execute(VP, json!({"planes": planes, "newLayer": true})).unwrap(); assert_ne!(r["layer"].as_u64().unwrap(), floor.0); } + + #[test] + fn rejects_planes_that_are_not_convex() { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 200, "height": 200, "depth": 16})).unwrap(); + s.execute("layer.new.layer", json!({})).unwrap(); + let bowtie = json!([[20, 20], [180, 180], [180, 20], [20, 180]]); + let dent = json!([[20, 20], [180, 20], [60, 60], [20, 180]]); + let square = json!([[20, 20], [180, 20], [180, 180], [20, 180]]); + for planes in [json!([{"corners": bowtie}]), json!([{"corners": square}, {"corners": dent}])] { + let e = s.execute(VP, json!({"planes": planes})).unwrap_err().to_string(); + assert!(e.contains("convex"), "{e}"); + } + assert!(s.execute(VP, json!({"planes": [{"corners": square}]})).is_ok()); + } } diff --git a/crates/ui-egui/src/distort_ui.rs b/crates/ui-egui/src/distort_ui.rs index b3bda3a7f5..0a0d7914b0 100644 --- a/crates/ui-egui/src/distort_ui.rs +++ b/crates/ui-egui/src/distort_ui.rs @@ -1,10 +1,11 @@ -//! Interactive Liquify (full-window dialog), Puppet Warp and Perspective Warp (on-canvas modes). +//! Interactive Liquify (full-window dialog), Puppet Warp, Perspective Warp and Vanishing Point +//! (on-canvas modes). //! //! All three are previews over plain data (strokes, pins, planes); committing runs the engine -//! command with that data (`filter.liquify`, `edit.puppetWarp`, `edit.perspectiveWarp`, or the -//! smart-object twins), so the result is one history step and exactly replayable. This module +//! command with that data (`filter.liquify`, `edit.puppetWarp`, `edit.perspectiveWarp`, +//! `filter.vanishingPoint`, or the smart-object twins), so the result is one history step and exactly replayable. This module //! holds the shared runtime state and the hooks the shell calls (menus, pointer, keys, overlay, -//! options bar); the modes live in `liquify_ui`, `puppet_ui` and `perspective_ui`. +//! options bar); the modes live in `liquify_ui`, `puppet_ui`, `perspective_ui` and `vp_ui`. use std::sync::Arc; @@ -23,13 +24,14 @@ pub struct Distort { pub liquify: Option, pub puppet: Option, pub perspective: Option, + pub vanishing: Option, /// Filter Gallery dialog (gallery_ui). pub gallery: Option, } impl Distort { pub fn active(&self) -> bool { - self.liquify.is_some() || self.puppet.is_some() || self.perspective.is_some() + self.liquify.is_some() || self.puppet.is_some() || self.perspective.is_some() || self.vanishing.is_some() } /// Short description for `ui.inspect`. @@ -38,6 +40,7 @@ impl Distort { "liquify": self.liquify.as_ref().map(|d| d.describe()), "puppet": self.puppet.as_ref().map(|p| p.describe()), "perspective": self.perspective.as_ref().map(|p| p.describe()), + "vanishingPoint": self.vanishing.as_ref().map(|v| v.describe()), "gallery": self.gallery.as_ref().map(|g| g.describe()), }) } @@ -118,6 +121,8 @@ pub fn menu(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str, params: &Val "edit.perspectiveWarp" | "layer.smartObjects.perspectiveWarp" if ui.is_some() && app.distort.perspective.is_some() => { Some(crate::perspective_ui::control(app, ui.unwrap_or(&Value::Null))) } + "filter.vanishingPoint" if empty => Some(crate::vp_ui::begin(app, ctx).map(|_| json!({"vanishingPoint": app.distort.describe()["vanishingPoint"]}))), + "filter.vanishingPoint" if ui.is_some() && app.distort.vanishing.is_some() => Some(crate::vp_ui::control(app, ui.unwrap_or(&Value::Null))), _ => None, } } @@ -136,6 +141,10 @@ pub fn pointer(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers) -> crate::perspective_ui::pointer(app, ev, mods); return true; } + if app.distort.vanishing.is_some() { + crate::vp_ui::pointer(app, ev, mods); + return true; + } false } @@ -179,6 +188,16 @@ pub fn keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool { } return true; } + if app.distort.vanishing.is_some() { + if enter(ctx) { + let _ = crate::vp_ui::commit(app); + } else if esc(ctx) { + crate::vp_ui::escape(app); + } else { + crate::vp_ui::keys(app, ctx); + } + return true; + } false } @@ -190,6 +209,9 @@ pub fn draw_overlay(app: &PhotocraftApp, painter: &egui::Painter, xf: &ViewXform if let Some(p) = &app.distort.perspective { crate::perspective_ui::draw(p, painter, xf); } + if let Some(v) = &app.distort.vanishing { + crate::vp_ui::draw(v, painter, xf); + } } /// Options bar for the on-canvas modes. True when drawn. @@ -202,6 +224,10 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) -> bool { crate::perspective_ui::options_bar(app, ui); return true; } + if app.distort.vanishing.is_some() { + crate::vp_ui::options_bar(app, ui); + return true; + } false } diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 23339c72f5..b39e9381a8 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -2441,3 +2441,11 @@ fontWeight Italic Kurzíva Front Image Přední obraz Search settings… Hledat nastavení… No matching settings Žádná odpovídající nastavení + Edit Plane Upravit rovinu + Create Plane Vytvořit rovinu + Grid Size: Velikost mřížky: + New Layer Nová vrstva + Vanishing Point: click four corners to create a plane Úběžník: klepnutím na čtyři rohy vytvoříte rovinu + Vanishing Point is not active Úběžník není aktivní + Apply Vanishing Point ({key}) Použít úběžník ({key}) + Fix the red plane first: its corners must form a convex quad Nejprve opravte červenou rovinu: její rohy musí tvořit konvexní čtyřúhelník diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index fa9bd5bf0f..b5eee5bed2 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -2479,3 +2479,11 @@ fontWeight Italic Kursiv Front Image Vorderes Bild Search settings… Einstellungen durchsuchen… No matching settings Keine passenden Einstellungen + Edit Plane Ebene bearbeiten + Create Plane Ebene erstellen + Grid Size: Rastergröße: + New Layer Neue Ebene + Vanishing Point: click four corners to create a plane Fluchtpunkt: Klicken Sie auf vier Ecken, um eine Ebene zu erstellen + Vanishing Point is not active Fluchtpunkt ist nicht aktiv + Apply Vanishing Point ({key}) Fluchtpunkt anwenden ({key}) + Fix the red plane first: its corners must form a convex quad Korrigieren Sie zuerst die rote Ebene: Ihre Ecken müssen ein konvexes Viereck bilden diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 4c79317146..f01045950d 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3548,3 +3548,8 @@ fontWeight Thin Πολύ λεπτά Front Image Μπροστινή εικόνα Search settings… Αναζήτηση ρυθμίσεων… No matching settings Δεν βρέθηκαν ρυθμίσεις + Grid Size: Μέγεθος πλέγματος: + Vanishing Point: click four corners to create a plane Σημείο φυγής: κάντε κλικ σε τέσσερις γωνίες για να δημιουργήσετε ένα επίπεδο + Vanishing Point is not active Το Σημείο φυγής δεν είναι ενεργό + Apply Vanishing Point ({key}) Εφαρμογή σημείου φυγής ({key}) + Fix the red plane first: its corners must form a convex quad Διορθώστε πρώτα το κόκκινο επίπεδο: οι γωνίες του πρέπει να σχηματίζουν κυρτό τετράπλευρο diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index a8be679f29..5517d8dadf 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2520,3 +2520,11 @@ fontWeight Italic Cursiva Front Image Imagen frontal Search settings… Buscar ajustes… No matching settings No hay ajustes que coincidan + Edit Plane Editar plano + Create Plane Crear plano + Grid Size: Tamaño de rejilla: + New Layer Capa nueva + Vanishing Point: click four corners to create a plane Punto de fuga: haga clic en cuatro esquinas para crear un plano + Vanishing Point is not active Punto de fuga no está activo + Apply Vanishing Point ({key}) Aplicar punto de fuga ({key}) + Fix the red plane first: its corners must form a convex quad Corrija primero el plano rojo: sus esquinas deben formar un cuadrilátero convexo diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 25c8e0f377..8d3121dd79 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -2858,3 +2858,9 @@ fontWeight Italic Italique Front Image Image de premier plan Search settings… Rechercher des réglages… No matching settings Aucun réglage correspondant + Grid Size: Taille de la grille : + New Layer Nouveau calque + Vanishing Point: click four corners to create a plane Point de fuite : cliquez sur quatre coins pour créer un plan + Vanishing Point is not active Point de fuite n’est pas actif + Apply Vanishing Point ({key}) Appliquer le point de fuite ({key}) + Fix the red plane first: its corners must form a convex quad Corrigez d’abord le plan rouge : ses coins doivent former un quadrilatère convexe diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 9030e72525..910342b185 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -2845,3 +2845,9 @@ fontWeight Italic Miring Front Image Gambar Depan Search settings… Cari pengaturan… No matching settings Tidak ada pengaturan yang cocok + Grid Size: Ukuran Grid: + New Layer Layer Baru + Vanishing Point: click four corners to create a plane Vanishing Point: klik empat sudut untuk membuat bidang + Vanishing Point is not active Vanishing Point tidak aktif + Apply Vanishing Point ({key}) Terapkan Vanishing Point ({key}) + Fix the red plane first: its corners must form a convex quad Perbaiki bidang merah dulu: sudut-sudutnya harus membentuk segi empat cembung diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 9993449c5a..81c3145854 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -2510,3 +2510,11 @@ fontWeight Italic Corsivo Front Image Immagine in primo piano Search settings… Cerca impostazioni… No matching settings Nessuna impostazione corrispondente + Edit Plane Modifica piano + Create Plane Crea piano + Grid Size: Dimensione griglia: + New Layer Nuovo livello + Vanishing Point: click four corners to create a plane Punto di fuga: fai clic su quattro angoli per creare un piano + Vanishing Point is not active Punto di fuga non è attivo + Apply Vanishing Point ({key}) Applica punto di fuga ({key}) + Fix the red plane first: its corners must form a convex quad Correggi prima il piano rosso: i suoi angoli devono formare un quadrilatero convesso diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 310650e1dc..08f56447ed 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3459,3 +3459,8 @@ fontWeight Italic 斜体 Front Image 前面の画像 Search settings… 設定を検索… No matching settings 一致する設定はありません + Grid Size: グリッドサイズ: + Vanishing Point: click four corners to create a plane 消点:4 つの角をクリックして面を作成します + Vanishing Point is not active 消点はアクティブではありません + Apply Vanishing Point ({key}) 消点を適用({key}) + Fix the red plane first: its corners must form a convex quad 先に赤い面を修正してください:角が凸四角形になる必要があります diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 21cf014d52..81b10fb7ce 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3019,3 +3019,10 @@ fontWeight Italic 기울임 Front Image 전면 이미지 Search settings… 설정 검색… No matching settings 일치하는 설정 없음 + Edit Plane 평면 편집 + Create Plane 평면 만들기 + Grid Size: 격자 크기: + Vanishing Point: click four corners to create a plane 소실점: 네 모서리를 클릭하여 평면을 만드십시오 + Vanishing Point is not active 소실점이 활성화되어 있지 않습니다 + Apply Vanishing Point ({key}) 소실점 적용 ({key}) + Fix the red plane first: its corners must form a convex quad 먼저 빨간색 평면을 수정하십시오: 모서리가 볼록 사각형을 이루어야 합니다 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 20370b4326..456b8c3f44 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -3618,3 +3618,8 @@ cameraRaw Whites Witten Search settings… Instellingen zoeken… No matching settings Geen overeenkomende instellingen PhotoCraft — Screen Color Picker PhotoCraft — Schermkleurkiezer + Grid Size: Rastergrootte: + Vanishing Point: click four corners to create a plane Verdwijnpunt: klik op vier hoeken om een vlak te maken + Vanishing Point is not active Verdwijnpunt is niet actief + Apply Vanishing Point ({key}) Verdwijnpunt toepassen ({key}) + Fix the red plane first: its corners must form a convex quad Herstel eerst het rode vlak: de hoeken moeten een convexe vierhoek vormen diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index ac086df7a4..8acdcd1c62 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3459,3 +3459,8 @@ cameraRaw Roughness Chropowatość Front Image Obraz na wierzchu Search settings… Szukaj ustawień… No matching settings Brak pasujących ustawień + Grid Size: Rozmiar siatki: + Vanishing Point: click four corners to create a plane Punkt zbieżności: kliknij cztery narożniki, aby utworzyć płaszczyznę + Vanishing Point is not active Punkt zbieżności nie jest aktywny + Apply Vanishing Point ({key}) Zastosuj punkt zbieżności ({key}) + Fix the red plane first: its corners must form a convex quad Najpierw popraw czerwoną płaszczyznę: jej narożniki muszą tworzyć czworokąt wypukły diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index a664352cc2..1b58102b86 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2866,3 +2866,9 @@ fontWeight Italic Itálico Front Image Imagem frontal Search settings… Pesquisar configurações… No matching settings Nenhuma configuração encontrada + Grid Size: Tamanho da grade: + New Layer Nova camada + Vanishing Point: click four corners to create a plane Ponto de fuga: clique em quatro cantos para criar um plano + Vanishing Point is not active Ponto de fuga não está ativo + Apply Vanishing Point ({key}) Aplicar ponto de fuga ({key}) + Fix the red plane first: its corners must form a convex quad Corrija primeiro o plano vermelho: seus cantos devem formar um quadrilátero convexo diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index f7d3cee401..22eda77f08 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -2725,3 +2725,9 @@ fontWeight Italic Курсив Rasterize Layer Style Растрировать стиль слоя Search settings… Поиск настроек… No matching settings Нет подходящих настроек + Grid Size: Размер сетки: + New Layer Новый слой + Vanishing Point: click four corners to create a plane Точка схода: щелкните четыре угла, чтобы создать плоскость + Vanishing Point is not active Точка схода не активна + Apply Vanishing Point ({key}) Применить точку схода ({key}) + Fix the red plane first: its corners must form a convex quad Сначала исправьте красную плоскость: ее углы должны образовывать выпуклый четырехугольник diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 1f9a076d8d..3fd50ffaf1 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3546,3 +3546,8 @@ cameraRaw Masking Маскування Search settings… Пошук налаштувань… No matching settings Немає відповідних налаштувань PhotoCraft — Screen Color Picker PhotoCraft — Піпетка кольору екрана + Grid Size: Розмір сітки: + Vanishing Point: click four corners to create a plane Точка сходження: клацніть чотири кути, щоб створити площину + Vanishing Point is not active Точка сходження не активна + Apply Vanishing Point ({key}) Застосувати точку сходження ({key}) + Fix the red plane first: its corners must form a convex quad Спершу виправте червону площину: її кути мають утворювати опуклий чотирикутник diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index de1d2dcac2..644eb96e9c 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2448,3 +2448,11 @@ fontWeight Italic 斜体 Front Image 前面的图像 Search settings… 搜索设置… No matching settings 没有匹配的设置 + Edit Plane 编辑平面 + Create Plane 创建平面 + Grid Size: 网格大小: + New Layer 新建图层 + Vanishing Point: click four corners to create a plane 消失点:单击四个角以创建平面 + Vanishing Point is not active 消失点未处于活动状态 + Apply Vanishing Point ({key}) 应用消失点({key}) + Fix the red plane first: its corners must form a convex quad 请先修正红色平面:其四个角必须构成凸四边形 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 697e5312ca..2150018ee0 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2418,3 +2418,11 @@ fontWeight Italic 斜體 Front Image 前面的影像 Search settings… 搜尋設定… No matching settings 沒有符合的設定 + Edit Plane 編輯平面 + Create Plane 建立平面 + Grid Size: 格點大小: + New Layer 新增圖層 + Vanishing Point: click four corners to create a plane 消失點:按一下四個角以建立平面 + Vanishing Point is not active 消失點未啟用 + Apply Vanishing Point ({key}) 套用消失點 ({key}) + Fix the red plane first: its corners must form a convex quad 請先修正紅色平面:其四個角必須構成凸四邊形 diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 0adf31b0f2..cbc2913acb 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -170,6 +170,7 @@ mod type_transform; mod variables_ui; pub mod vector_ui; pub mod view_cmds; +pub mod vp_ui; pub mod warp_preview; pub mod wheel_nav; pub mod wide_angle_ui; diff --git a/crates/ui-egui/src/vp_ui.rs b/crates/ui-egui/src/vp_ui.rs new file mode 100644 index 0000000000..bdaad601c6 --- /dev/null +++ b/crates/ui-egui/src/vp_ui.rs @@ -0,0 +1,611 @@ +//! Filter › Vanishing Point on the canvas (dialog mode). +//! +//! **Create Plane** (C): four clicks set a plane's corners, in any order. **Edit Plane** (V): +//! drag a corner node, or an edge node to slide that edge along the plane's own perspective; +//! click a plane to select it, Delete removes it. The plane's grid is drawn at the Grid Size and, +//! like Photoshop's, in the accent colour when the plane is valid, yellow when its perspective is +//! doubtful and red when it is invalid ([`VpPlane::check`]). With an image on the clipboard the +//! selected plane shows it pasted in perspective; drag it to move it on the plane. ↩ / OK runs +//! `filter.vanishingPoint` with the planes and the paste, so it is one history step and an +//! action or agent can replay it exactly. + +use egui::{Color32, Pos2, Stroke, TextureHandle, pos2}; +use photocraft_algo::transform::Homography; +use photocraft_algo::vanishing::{PlaneCheck, Scene, VpPlane}; +use photocraft_doc::{LayerContent, LayerId}; +use photocraft_engine::vp_cmds::VP; +use photocraft_geom::Rect; +use serde_json::{Value, json}; + +use crate::PhotocraftApp; +use crate::canvas::{ToolEvent, ViewXform}; + +#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize)] +#[serde(rename_all = "camelCase")] +pub enum VpTool { + EditPlane, + CreatePlane, +} + +enum Drag { + /// A corner node, and the pointer offset from it. + Corner { plane: usize, corner: usize, offset: [f64; 2] }, + /// An edge node (0 top, 1 right, 2 bottom, 3 left): the edge slides along the plane's + /// perspective as it was at the press. + Edge { plane: usize, edge: usize, h: Homography, inv: Homography }, + /// The pasted image, and the pointer offset from its top-left in plane coordinates. + Paste { offset: [f64; 2] }, +} + +/// The clipboard image shown pasted onto the plane. +struct Clip { + texture: TextureHandle, + width: f64, + height: f64, +} + +pub struct VpSession { + pub layer: LayerId, + canvas: Rect, + pub planes: Vec, + pub tool: VpTool, + /// Corners clicked so far with Create Plane. + pending: Vec<[f64; 2]>, + pub selected: Option, + /// Grid cell size in px at the plane's nearest edge. + pub grid_size: f64, + /// Paste the clipboard onto the selected plane on OK. + pub paste: bool, + /// Top-left of the pasted image in plane coordinates (0..1). + pub paste_at: [f64; 2], + /// Width of the pasted image as a fraction of the plane's width. + pub paste_width: f64, + pub new_layer: bool, + clip: Option, + drag: Option, +} + +/// Most planes a session holds (the control channel can't make it allocate without bound). +const MAX_PLANES: usize = 64; +/// Most grid lines drawn per direction. +const MAX_LINES: usize = 200; + +impl VpSession { + pub fn describe(&self) -> Value { + let center = self.center(); + let planes: Vec = self.planes.iter().map(|p| json!({"corners": p.corners, "check": p.check(center)})).collect(); + json!({ + "layer": self.layer.0, + "tool": self.tool, + "planes": planes, + "pending": self.pending, + "selected": self.selected, + "gridSize": self.grid_size, + "paste": self.paste && self.clip.is_some(), + "pasteAt": self.paste_at, + "pasteWidth": self.paste_width, + "newLayer": self.new_layer, + }) + } + + fn center(&self) -> [f64; 2] { + let c = self.canvas; + [f64::from(c.x0 + c.x1) / 2.0, f64::from(c.y0 + c.y1) / 2.0] + } + + /// The planes with the shared camera the engine derives from the first one. + fn scene(&self) -> Option { + let first = self.planes.first()?.clone(); + let fallback = f64::from(self.canvas.width().max(self.canvas.height())); + let mut sc = Scene::new(first, self.center(), None, fallback); + sc.planes.extend(self.planes.iter().skip(1).cloned()); + Some(sc) + } + + /// Plane `i`'s unit square → image map and metric side lengths. + fn frame(&self, i: usize) -> Option<(Homography, f64, f64)> { + if i >= self.planes.len() { + return None; + } + let (h, lu, lv) = self.scene()?.frame(i)?; + (lu.is_finite() && lv.is_finite() && lu > 1e-12 && lv > 1e-12).then_some((h, lu, lv)) + } + + /// The plane the paste lands on. + fn paste_plane(&self) -> Option { + if !self.paste || self.clip.is_none() { + return None; + } + self.selected.filter(|i| *i < self.planes.len()).or_else(|| (!self.planes.is_empty()).then_some(0)) + } + + /// Size of the pasted image in plane coordinates (the engine keeps its metric aspect). + fn paste_extent(&self, lu: f64, lv: f64) -> Option<[f64; 2]> { + let c = self.clip.as_ref()?; + Some([self.paste_width, self.paste_width * lu / lv * c.height / c.width.max(1.0)]) + } + + /// The command's params: the planes, and the paste when there is one. + pub fn params(&self) -> Value { + let planes: Vec = self.planes.iter().map(|p| json!({"corners": p.corners})).collect(); + let mut p = json!({"planes": planes}); + if let Some(i) = self.paste_plane() { + p["paste"] = json!([{"plane": i, "at": self.paste_at, "width": self.paste_width}]); + } + if self.new_layer { + p["newLayer"] = json!(true); + } + p + } + + fn add_corner(&mut self, p: [f64; 2]) { + if self.planes.len() >= MAX_PLANES { + return; + } + self.pending.push(p); + if let Ok(corners) = <[[f64; 2]; 4]>::try_from(self.pending.as_slice()) { + self.pending.clear(); + self.planes.push(VpPlane { corners }.normalized()); + self.selected = Some(self.planes.len() - 1); + // Photoshop hands over to Edit Plane once a plane is closed. + self.tool = VpTool::EditPlane; + } + } + + fn delete_selected(&mut self) { + if let Some(i) = self.selected.take().filter(|i| *i < self.planes.len()) { + self.planes.remove(i); + self.drag = None; + } + } + + /// Image positions of the edge nodes of plane `i`. + fn edge_nodes(&self, i: usize) -> Option<[[f64; 2]; 4]> { + let h = self.planes.get(i)?.homography()?; + let at = |u: f64, v: f64| { + let (x, y) = h.apply(u, v); + [x, y] + }; + Some([at(0.5, 0.0), at(1.0, 0.5), at(0.5, 1.0), at(0.0, 0.5)]) + } + + fn press(&mut self, p: [f64; 2], tol: f64) { + if self.tool == VpTool::CreatePlane { + self.add_corner(p); + return; + } + let near = |c: [f64; 2]| (c[0] - p[0]).hypot(c[1] - p[1]) <= tol; + // The selected plane's nodes win over the others'. + let order: Vec = self.selected.into_iter().chain((0..self.planes.len()).rev()).filter(|i| *i < self.planes.len()).collect(); + for &i in &order { + if let Some(ci) = self.planes[i].corners.iter().position(|c| near(*c)) { + let c = self.planes[i].corners[ci]; + self.selected = Some(i); + self.drag = Some(Drag::Corner { plane: i, corner: ci, offset: [c[0] - p[0], c[1] - p[1]] }); + return; + } + if let Some(e) = self.edge_nodes(i).and_then(|n| n.iter().position(|c| near(*c))) + && let Some(h) = self.planes[i].homography() + && let Some(inv) = h.inverse() + { + self.selected = Some(i); + self.drag = Some(Drag::Edge { plane: i, edge: e, h, inv }); + return; + } + } + if let Some(i) = self.paste_plane() + && let Some((h, lu, lv)) = self.frame(i) + && let Some(ext) = self.paste_extent(lu, lv) + && let Some(inv) = h.inverse() + { + let (u, v) = inv.apply(p[0], p[1]); + let (a, b) = (self.paste_at, [self.paste_at[0] + ext[0], self.paste_at[1] + ext[1]]); + if (a[0]..=b[0]).contains(&u) && (a[1]..=b[1]).contains(&v) { + self.drag = Some(Drag::Paste { offset: [a[0] - u, a[1] - v] }); + return; + } + } + self.selected = self.scene().and_then(|sc| sc.plane_at(p)); + } + + fn drag_to(&mut self, p: [f64; 2]) { + match &self.drag { + Some(Drag::Corner { plane, corner, offset }) => { + if let Some(c) = self.planes.get_mut(*plane).and_then(|pl| pl.corners.get_mut(*corner)) { + *c = [p[0] + offset[0], p[1] + offset[1]]; + } + } + Some(Drag::Edge { plane, edge, h, inv }) => { + let (u, v) = inv.apply(p[0], p[1]); + // The plane's (u, v) rectangle after the move. + let (u0, v0, u1, v1) = match edge { + 0 => (0.0, v.min(0.99), 1.0, 1.0), + 1 => (0.0, 0.0, u.max(0.01), 1.0), + 2 => (0.0, 0.0, 1.0, v.max(0.01)), + _ => (u.min(0.99), 0.0, 1.0, 1.0), + }; + if let Some(q) = slid_quad(h, u0, v0, u1, v1) + && let Some(pl) = self.planes.get_mut(*plane) + { + pl.corners = q; + } + } + Some(Drag::Paste { offset }) => { + let offset = *offset; + if let Some(i) = self.paste_plane() + && let Some(inv) = self.planes.get(i).and_then(VpPlane::homography).and_then(|h| h.inverse()) + { + let (u, v) = inv.apply(p[0], p[1]); + let at = [(u + offset[0]).clamp(-1.0, 2.0), (v + offset[1]).clamp(-1.0, 2.0)]; + if at.iter().all(|x| x.is_finite()) { + self.paste_at = at; + } + } + } + None => {} + } + } +} + +/// Corners of the image of `[u0, u1] × [v0, v1]` under `h`, or `None` when part of it would lie +/// on or beyond the plane's horizon (where the edge can't follow the perspective). +fn slid_quad(h: &Homography, u0: f64, v0: f64, u1: f64, v1: f64) -> Option<[[f64; 2]; 4]> { + let m = &h.0; + let w = |u: f64, v: f64| m[6] * u + m[7] * v + m[8]; + let side = w(0.5, 0.5).signum(); + let uv = [[u0, v0], [u1, v0], [u1, v1], [u0, v1]]; + if uv.iter().any(|c| w(c[0], c[1]) * side <= 1e-9 * w(0.5, 0.5).abs()) { + return None; + } + let q = uv.map(|c| { + let (x, y) = h.apply(c[0], c[1]); + [x, y] + }); + (VpPlane { corners: q }.check([0.0, 0.0]) != PlaneCheck::Invalid).then_some(q) +} + +/// Starts Vanishing Point on the active pixel layer. +pub fn begin(app: &mut PhotocraftApp, ctx: &egui::Context) -> Result<(), String> { + if app.ui.transform.is_some() { + return Err("finish Free Transform first".into()); + } + let st = app.session.active().ok_or("no document")?; + let layer = st.active_layer.ok_or("no active layer")?; + match st.doc.layer(layer).map(|l| &l.content) { + Some(LayerContent::Raster(_)) => {} + Some(other) => return Err(format!("Vanishing Point needs a pixel layer (active layer is {} {} layer)", other.article(), other.kind_name())), + None => return Err("no active layer".into()), + } + let canvas = st.doc.bounds(); + let key = app.ui.alloc_id(); + let clip = app.session.clipboard.as_ref().and_then(|c| { + let r = c.surface.content_bounds(); + (!r.is_empty()).then(|| Clip { + texture: ctx.load_texture(format!("vp-paste-{key}"), crate::distort_ui::surface_image(&c.surface, r, 1024), egui::TextureOptions::LINEAR), + width: f64::from(r.width()), + height: f64::from(r.height()), + }) + }); + app.distort.vanishing = Some(VpSession { + layer, + canvas, + planes: Vec::new(), + tool: VpTool::CreatePlane, + pending: Vec::new(), + selected: None, + grid_size: 100.0, + paste: clip.is_some(), + paste_at: [0.25, 0.25], + paste_width: 0.5, + new_layer: false, + clip, + drag: None, + }); + app.ui.status = tl!("Vanishing Point: click four corners to create a plane").into(); + Ok(()) +} + +/// OK: runs `filter.vanishingPoint` with the planes (and the paste). An invalid plane keeps the +/// mode open; with nothing to paste the mode just closes. +pub fn commit(app: &mut PhotocraftApp) -> Result { + let Some(s) = app.distort.vanishing.as_ref() else { return Ok(Value::Null) }; + let center = s.center(); + if s.planes.iter().any(|p| p.check(center) == PlaneCheck::Invalid) { + let msg = tl!("Fix the red plane first: its corners must form a convex quad"); + app.ui.status = msg.into(); + return Err(msg.into()); + } + let params = s.params(); + app.distort.vanishing = None; + if params.get("paste").is_none() { + return Ok(json!({"committed": false})); + } + app.run(VP, params).map(|r| json!({"committed": true, "result": r})) +} + +/// Control channel: `filter.vanishingPoint {"ui": {...}}` while the mode is active. +pub fn control(app: &mut PhotocraftApp, ui: &Value) -> Result { + if ui.get("commit").and_then(Value::as_bool) == Some(true) { + return commit(app); + } + if ui.get("cancel").and_then(Value::as_bool) == Some(true) { + app.distort.vanishing = None; + return Ok(json!({"cancelled": true})); + } + let s = app.distort.vanishing.as_mut().ok_or(tl!("Vanishing Point is not active"))?; + if let Some(t) = ui.get("tool").and_then(Value::as_str) { + s.tool = match t { + "edit" | "editPlane" => VpTool::EditPlane, + "create" | "createPlane" => VpTool::CreatePlane, + other => return Err(format!("tool: edit|create, not `{other}`")), + }; + s.pending.clear(); + } + if let Some(p) = ui.get("planes") { + let planes: Vec = serde_json::from_value(p.clone()).map_err(|e| format!("bad planes: {e}"))?; + if planes.len() > MAX_PLANES { + return Err(format!("at most {MAX_PLANES} planes")); + } + s.planes = planes; + // A drag holds indices into the old list. + s.drag = None; + s.selected = (!s.planes.is_empty()).then(|| s.planes.len() - 1); + } + if let Some(i) = ui.get("select").and_then(Value::as_u64) { + s.selected = usize::try_from(i).ok().filter(|i| *i < s.planes.len()); + } + if let Some(g) = ui.get("gridSize").and_then(Value::as_f64).filter(|g| g.is_finite()) { + s.grid_size = g.clamp(2.0, 2000.0); + } + if let Some(b) = ui.get("paste").and_then(Value::as_bool) { + s.paste = b; + } + if let Some(at) = ui.get("pasteAt").and_then(|v| Some([v.get(0)?.as_f64()?, v.get(1)?.as_f64()?])) { + s.paste_at = at.map(|x| if x.is_finite() { x.clamp(-1.0, 2.0) } else { 0.25 }); + } + if let Some(w) = ui.get("pasteWidth").and_then(Value::as_f64).filter(|w| w.is_finite()) { + s.paste_width = w.clamp(0.01, 10.0); + } + if let Some(b) = ui.get("newLayer").and_then(Value::as_bool) { + s.new_layer = b; + } + Ok(s.describe()) +} + +pub fn pointer(app: &mut PhotocraftApp, ev: ToolEvent, _mods: egui::Modifiers) { + let tol = crate::distort_ui::tolerance(app); + let Some(s) = app.distort.vanishing.as_mut() else { return }; + match ev { + ToolEvent::Down { x, y, .. } => s.press([x, y], tol), + ToolEvent::Move { x, y, .. } => s.drag_to([x, y]), + ToolEvent::Up { x, y } => { + s.drag_to([x, y]); + s.drag = None; + } + } +} + +/// Keys while the mode is active (↩ and Esc are handled by `distort_ui::keys`). +pub fn keys(app: &mut PhotocraftApp, ctx: &egui::Context) { + use egui::{Key, Modifiers}; + if ctx.memory(|m| m.focused().is_some()) { + return; + } + let Some(s) = app.distort.vanishing.as_mut() else { return }; + let key = |k: Key| ctx.input_mut(|i| i.consume_key(Modifiers::NONE, k)); + if key(Key::V) { + s.tool = VpTool::EditPlane; + s.pending.clear(); + } else if key(Key::C) { + s.tool = VpTool::CreatePlane; + } else if key(Key::Delete) || key(Key::Backspace) { + s.delete_selected(); + } +} + +/// Esc: drops a half-clicked plane first, then leaves the mode. +pub fn escape(app: &mut PhotocraftApp) { + match app.distort.vanishing.as_mut() { + Some(s) if !s.pending.is_empty() => s.pending.clear(), + _ => app.distort.vanishing = None, + } +} + +pub fn draw(s: &VpSession, painter: &egui::Painter, xf: &ViewXform) { + let scr = |p: [f64; 2]| xf.to_screen(p[0] as f32, p[1] as f32); + let tokens = crate::theme::Tokens::get(painter.ctx()); + let center = s.center(); + // The paste first, under the grids. + if let Some(i) = s.paste_plane() + && s.planes.get(i).is_some_and(|p| p.check(center) != PlaneCheck::Invalid) + && let (Some((h, lu, lv)), Some(c)) = (s.frame(i), s.clip.as_ref()) + && let Some(ext) = s.paste_extent(lu, lv) + { + draw_paste(painter, &scr, &h, s.paste_at, ext, &c.texture); + } + for (i, p) in s.planes.iter().enumerate() { + let check = p.check(center); + let colour = match check { + PlaneCheck::Valid => tokens.accent, + PlaneCheck::Questionable => tokens.warning, + PlaneCheck::Invalid => tokens.danger, + }; + let selected = s.selected == Some(i); + // An invalid plane has no perspective to grid: just its red outline, as in Photoshop. + if check != PlaneCheck::Invalid + && let Some((h, lu, lv)) = s.frame(i) + { + let thin = Stroke::new(0.75, colour.gamma_multiply(0.6)); + let at = |u: f64, v: f64| { + let (x, y) = h.apply(u, v); + scr([x, y]) + }; + for u in grid_steps(p, lu, lv, s.grid_size, true) { + painter.line_segment([at(u, 0.0), at(u, 1.0)], thin); + } + for v in grid_steps(p, lu, lv, s.grid_size, false) { + painter.line_segment([at(0.0, v), at(1.0, v)], thin); + } + } + let pts: Vec = p.corners.iter().map(|c| scr(*c)).collect(); + painter.add(egui::Shape::closed_line(pts.clone(), Stroke::new(if selected { 2.0 } else { 1.25 }, colour))); + if selected { + let nodes = pts.into_iter().chain(s.edge_nodes(i).into_iter().flatten().map(scr)); + for c in nodes { + let r = egui::Rect::from_center_size(c, egui::vec2(7.0, 7.0)); + painter.rect_filled(r, 0.0, Color32::WHITE); + painter.rect_stroke(r, 0.0, Stroke::new(1.25, colour), egui::StrokeKind::Inside); + } + } + } + // Create Plane: the corners so far and a rubber band to the pointer. + if !s.pending.is_empty() { + let mut pts: Vec = s.pending.iter().map(|c| scr(*c)).collect(); + if let Some(hover) = painter.ctx().pointer_hover_pos() { + pts.push(hover); + } + painter.add(egui::Shape::line(pts.clone(), Stroke::new(1.25, tokens.accent))); + for c in pts.iter().take(s.pending.len()) { + painter.rect_filled(egui::Rect::from_center_size(*c, egui::vec2(6.0, 6.0)), 0.0, tokens.accent); + } + } +} + +/// Plane coordinates (0..1, exclusive) of the grid lines across `u` (or `v`) for cells of +/// `size` px at the plane's nearest edge, square in the plane's metric. +fn grid_steps(p: &VpPlane, lu: f64, lv: f64, size: f64, along_u: bool) -> Vec { + let q = &p.corners; + let d = |a: [f64; 2], b: [f64; 2]| (a[0] - b[0]).hypot(a[1] - b[1]); + // Image px per metric unit at the nearest (longest-looking) edge. + let k = [d(q[0], q[1]) / lu, d(q[3], q[2]) / lu, d(q[0], q[3]) / lv, d(q[1], q[2]) / lv].into_iter().fold(0.0, f64::max); + let cell = size.max(1.0) / k; + let len = if along_u { lu } else { lv }; + if !cell.is_finite() || cell <= 0.0 || !len.is_finite() { + return Vec::new(); + } + let step = cell / len; + (1..MAX_LINES).map(|j| j as f64 * step).take_while(|t| *t < 1.0 - 1e-9).collect() +} + +/// The clipboard image on the plane: a mesh through the plane's homography, cells outside the +/// plane left out (the engine clips the paste to the plane). +fn draw_paste(painter: &egui::Painter, scr: &dyn Fn([f64; 2]) -> Pos2, h: &Homography, at: [f64; 2], ext: [f64; 2], tex: &TextureHandle) { + const N: usize = 24; + let mut mesh = egui::Mesh::with_texture(tex.id()); + let tint = Color32::from_white_alpha(230); + for j in 0..=N { + for i in 0..=N { + let (s, t) = (i as f64 / N as f64, j as f64 / N as f64); + let (x, y) = h.apply(at[0] + s * ext[0], at[1] + t * ext[1]); + mesh.vertices.push(egui::epaint::Vertex { pos: scr([x, y]), uv: pos2(s as f32, t as f32), color: tint }); + } + } + for j in 0..N { + for i in 0..N { + let (u, v) = (at[0] + (i as f64 + 0.5) / N as f64 * ext[0], at[1] + (j as f64 + 0.5) / N as f64 * ext[1]); + if !(0.0..=1.0).contains(&u) || !(0.0..=1.0).contains(&v) { + continue; + } + let a = (j * (N + 1) + i) as u32; + mesh.add_triangle(a, a + 1, a + N as u32 + 2); + mesh.add_triangle(a, a + N as u32 + 2, a + N as u32 + 1); + } + } + painter.add(mesh); +} + +pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { + let Some(s) = app.distort.vanishing.as_mut() else { return }; + if crate::widgets::pill_tab(ui, tl!("Edit Plane"), s.tool == VpTool::EditPlane).on_hover_text("V").clicked() { + s.tool = VpTool::EditPlane; + s.pending.clear(); + } + if crate::widgets::pill_tab(ui, tl!("Create Plane"), s.tool == VpTool::CreatePlane).on_hover_text("C").clicked() { + s.tool = VpTool::CreatePlane; + } + crate::widgets::vline(ui, 22.0); + ui.label(tl!("Grid Size:")); + let mut g = s.grid_size as f32; + if crate::widgets::value_field(ui, &mut g, 2.0..=2000.0, "px", 56.0).changed() { + s.grid_size = f64::from(g); + } + if s.clip.is_some() { + crate::widgets::vline(ui, 22.0); + crate::widgets::checkbox(ui, &mut s.paste, tl!("Paste")); + if s.paste { + ui.label(tl!("Width:")); + let mut w = (s.paste_width * 100.0) as f32; + if crate::widgets::value_field(ui, &mut w, 1.0..=1000.0, "%", 56.0).changed() { + s.paste_width = f64::from(w) / 100.0; + } + } + crate::widgets::checkbox(ui, &mut s.new_layer, tl!("New Layer")); + } + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + if crate::widgets::primary_button(ui, "✓", 32.0) + .on_hover_text(crate::i18n::fmt(tl!("Apply Vanishing Point ({key})"), &[("key", &crate::shortcuts::pretty("Enter"))])) + .clicked() + { + let _ = commit(app); + } else if crate::widgets::secondary_button(ui, "⊘", 32.0).on_hover_text(tl!("Cancel (Esc)")).clicked() { + app.distort.vanishing = None; + } + }); +} + +#[cfg(test)] +mod tests { + use super::*; + + fn app_with_layer() -> (egui::Context, PhotocraftApp) { + let ctx = egui::Context::default(); + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + app.session.execute("file.new", json!({"width": 240, "height": 160, "depth": 16})).unwrap(); + app.session.execute("layer.new.layer", json!({})).unwrap(); + app.session.execute("edit.fill", json!({"color": "#4080c0"})).unwrap(); + app.sync_views(); + (ctx, app) + } + + #[test] + fn four_clicks_make_a_plane_and_ok_pastes_in_one_step() { + let (ctx, mut app) = app_with_layer(); + // Something to paste: a red square on the clipboard. + app.session.execute("select.rect", json!({"x": 0, "y": 0, "width": 20, "height": 20})).unwrap(); + app.session.execute("edit.fill", json!({"color": "#ff0000"})).unwrap(); + app.session.execute("edit.copy", json!({})).unwrap(); + app.session.execute("select.deselect", json!({})).unwrap(); + crate::distort_ui::menu(&mut app, &ctx, VP, &json!({})).unwrap().unwrap(); + let click = |app: &mut PhotocraftApp, x: f64, y: f64| { + crate::distort_ui::pointer(app, ToolEvent::Down { x, y, pressure: 1.0 }, egui::Modifiers::NONE); + crate::distort_ui::pointer(app, ToolEvent::Up { x, y }, egui::Modifiers::NONE); + }; + // A floor receding to the top, clicked counter-clockwise from the bottom-left. + for (x, y) in [(20.0, 150.0), (220.0, 150.0), (170.0, 60.0), (70.0, 60.0)] { + click(&mut app, x, y); + } + let s = app.distort.vanishing.as_ref().unwrap(); + assert_eq!(s.planes.len(), 1); + assert_eq!(s.planes[0].corners, [[70.0, 60.0], [170.0, 60.0], [220.0, 150.0], [20.0, 150.0]], "clockwise from the top-left"); + assert_eq!(s.tool, VpTool::EditPlane); + assert_eq!(s.describe()["planes"][0]["check"], "valid"); + // Edit Plane: drag the top edge node up; the edge slides along the perspective. + let top = s.edge_nodes(0).unwrap()[0]; + crate::distort_ui::pointer(&mut app, ToolEvent::Down { x: top[0], y: top[1], pressure: 1.0 }, egui::Modifiers::NONE); + crate::distort_ui::pointer(&mut app, ToolEvent::Up { x: top[0], y: top[1] - 15.0 }, egui::Modifiers::NONE); + let c = app.distort.vanishing.as_ref().unwrap().planes[0].corners; + assert!(c[0][1] < 60.0 && c[1][1] < 60.0 && c[1][0] - c[0][0] < 100.0, "taller and narrower at the far edge: {c:?}"); + assert_eq!(c[2], [220.0, 150.0]); + let before = app.session.active().unwrap().history.past_len(); + commit(&mut app).unwrap(); + assert!(app.distort.vanishing.is_none()); + assert_eq!(app.session.active().unwrap().history.past_len(), before + 1); + // The paste landed on the plane: red at its middle, blue outside it. + let st = app.session.active().unwrap(); + let l = st.doc.layer(st.active_layer.unwrap()).unwrap().surface().unwrap(); + let h = VpPlane { corners: c }.homography().unwrap(); + let (x, y) = h.apply(0.5, 0.35); + assert!(l.rgba(x as i32, y as i32)[0] > 0.9, "{:?}", l.rgba(x as i32, y as i32)); + assert!(l.rgba(230, 20)[0] < 0.5, "outside the plane"); + } +} diff --git a/docs/scorecard.md b/docs/scorecard.md index 6c7f540004..aad562e6c8 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -158,7 +158,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t | TOOL-214-11 | Stroke Path dialog: pick any brush-based tool, Simulate Pressure | partial | [#214](https://github.com/storytold/photocraft/issues/214) | path.stroke brush, pencil, eraser (vector_cmds.rs:1170); brush-only button, no dialog | | TOOL-214-12 | Shapes: on-canvas corner radius handles, shape feather, selection to shape with tolerance | partial | [#214](https://github.com/storytold/photocraft/issues/214) | select.convertToShape with tolerance (vector_cmds.rs:1256); radius as a field only | | TOOL-214-13 | Mask Properties: Density and Feather controls | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Vector-mask density/feather in the engine (vector_cmds.rs:948); no UI controls | -| TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | partial | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15) behind a parameter dialog | +| TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | partial | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15); on-canvas plane editor (vp_ui.rs: Create/Edit Plane, edge nodes, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane on OK); clone stamp, marquee and tear-off planes in the window still missing | | TOOL-214-15 | Content-Aware Fill workspace: paint the sampling area, preview, rotate/scale/mirror, new layer | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Engine sampling auto, rect, custom (edit_menu_cmds.rs:324); generic dialog | | TOOL-214-16 | Liquify: redo (Cmd+Shift+Z) | done | [#214](https://github.com/storytold/photocraft/issues/214) | liquify_ui.rs supports bounded redo through Cmd+Shift+Z and the control channel; new strokes clear redo | | TOOL-213-17 | Red Eye tool: click a pupil to neutralize the red reflection | done | [#213](https://github.com/storytold/photocraft/issues/213) | paint.redEye (redeye_cmds.rs) + Tool::RedEye in the J flyout; Pupil Size and Darken Amount; catchlights kept; a miss is an error | diff --git a/scorecard/tools.toml b/scorecard/tools.toml index c5190643a4..cefb18e599 100644 --- a/scorecard/tools.toml +++ b/scorecard/tools.toml @@ -206,7 +206,7 @@ id = "TOOL-214-14" target = "Vanishing Point window: draw and edit planes, paste, clone in perspective" status = "partial" issue = 214 -note = "filter.vanishingPoint (vp_cmds.rs:15) behind a parameter dialog" +note = "filter.vanishingPoint (vp_cmds.rs:15); on-canvas plane editor (vp_ui.rs: Create/Edit Plane, edge nodes, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane on OK); clone stamp, marquee and tear-off planes in the window still missing" [[item]] id = "TOOL-214-15" From 914bb89a606722c7a902065438f80641831eeef5 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 11 Oct 2026 08:57:16 +0200 Subject: [PATCH 013/649] Vanishing Point: tear off planes and clone in perspective (#3280) Tear-off planes in the Vanishing Point window: - Ctrl/Cmd-drag an edge node (Create or Edit Plane) tears off a plane at 90 degrees. Dragging its far edge node sets the depth, and Alt-dragging it sets the angle. - A torn plane is stored in its torn-off form (from/edge/angle/depth). Its corners are recomputed from its parent after every edit, the same way the engine builds the scene. It is drawn and validated like any other plane and sent to filter.vanishingPoint in that form. - Deleting a parent keeps its torn planes as drawn planes. Stamp tool (S): - Alt-click a plane to set the source, then drag to clone in perspective. - Options: Diameter, Hardness, Opacity and Aligned (later strokes keep the first stroke's offset). Cmd/Ctrl+Z removes the last stroke. - The canvas shows the strokes as they are painted. The preview paints them in pieces with the same frame the engine uses, and only the painted area recomposites. - The overlay shows the source crosshair and the foreshortened brush. - OK sends the strokes as the command's "clone" param, so the session is one history step. Algo: clone_stroke is split into clone_dabs (anchored stroke pieces, which return the changed area) and clone_source. sample() is safe for non-finite or edge coordinates. Engine: "clone" is parsed and validated up front. The engine caps clone strokes (4096), clone points (200k) and planes (64), checks numbers are finite, and checks the tear-off angle and depth ranges. It returns Err instead of silently dropping bad points. Clone strokes copy back only the area they changed, not the whole layer on every stroke. Scorecard TOOL-214-14 is now done. Still missing: the Marquee tool in the window and the Stamp's Heal modes. Co-Authored-By: Claude Opus 5.5 --- crates/algo/src/vanishing.rs | 114 ++++- crates/engine/src/vp_cmds.rs | 169 +++++-- crates/ui-egui/src/canvas.rs | 7 + crates/ui-egui/src/distort_ui.rs | 6 +- crates/ui-egui/src/i18n/cs.tsv | 3 + crates/ui-egui/src/i18n/de.tsv | 2 + crates/ui-egui/src/i18n/el.tsv | 2 + crates/ui-egui/src/i18n/es.tsv | 2 + crates/ui-egui/src/i18n/fr.tsv | 2 + crates/ui-egui/src/i18n/id.tsv | 2 + crates/ui-egui/src/i18n/it.tsv | 2 + crates/ui-egui/src/i18n/ja.tsv | 2 + crates/ui-egui/src/i18n/ko.tsv | 2 + crates/ui-egui/src/i18n/nl.tsv | 2 + crates/ui-egui/src/i18n/pl.tsv | 2 + crates/ui-egui/src/i18n/pt-br.tsv | 2 + crates/ui-egui/src/i18n/ru.tsv | 2 + crates/ui-egui/src/i18n/uk.tsv | 2 + crates/ui-egui/src/i18n/zh-hans.tsv | 3 + crates/ui-egui/src/i18n/zh-hant.tsv | 3 + crates/ui-egui/src/vp_ui.rs | 679 ++++++++++++++++++++++++++-- docs/scorecard.md | 4 +- scorecard/tools.toml | 4 +- 23 files changed, 925 insertions(+), 93 deletions(-) diff --git a/crates/algo/src/vanishing.rs b/crates/algo/src/vanishing.rs index 77b7bb107c..2ac85badb4 100644 --- a/crates/algo/src/vanishing.rs +++ b/crates/algo/src/vanishing.rs @@ -324,38 +324,97 @@ pub fn paste(scene: &Scene, i: usize, src: &Surface, src_rect: Rect, at: [f64; 2 Ok(Some(out)) } +/// The fixed frame of one clone stroke: the source and destination planes, the source offset in +/// plane-metric units and the brush radius, all set at the stroke's anchor (its first dab). +struct CloneFrame { + hs: Homography, + ls: (f64, f64), + hd: Homography, + hd_inv: Homography, + ld: (f64, f64), + offset: [f64; 2], + r_m: f64, +} + +impl CloneFrame { + fn new(scene: &Scene, source: [f64; 2], anchor: [f64; 2], size: f64) -> Option { + let (ps, pd) = (scene.plane_at(source)?, scene.plane_at(anchor)?); + let ((hs, lus, lvs), (hd, lud, lvd)) = (scene.frame(ps)?, scene.frame(pd)?); + let (hs_inv, hd_inv) = (hs.inverse()?, hd.inverse()?); + let ms = metric(&hs_inv, (lus, lvs), source); + let md0 = metric(&hd_inv, (lud, lvd), anchor); + // Brush radius in metric units (from the image size at the anchor). + let probe = metric(&hd_inv, (lud, lvd), [anchor[0] + size / 2.0, anchor[1]]); + let r_m = ((probe[0] - md0[0]).hypot(probe[1] - md0[1])).max(1e-9); + let offset = [ms[0] - md0[0], ms[1] - md0[1]]; + (offset.iter().all(|v| v.is_finite()) && r_m.is_finite()).then_some(CloneFrame { hs, ls: (lus, lvs), hd, hd_inv, ld: (lud, lvd), offset, r_m }) + } + + /// The source point (image px) that destination `p` copies from. + fn source_of(&self, p: [f64; 2]) -> [f64; 2] { + let m = metric(&self.hd_inv, self.ld, p); + let (x, y) = self.hs.apply((m[0] + self.offset[0]) / self.ls.0, (m[1] + self.offset[1]) / self.ls.1); + [x, y] + } +} + +/// Image point → plane-metric coordinates through the plane's inverse homography. +fn metric(inv: &Homography, l: (f64, f64), p: [f64; 2]) -> [f64; 2] { + let (u, v) = inv.apply(p[0], p[1]); + [u * l.0, v * l.1] +} + /// Perspective clone stamp: one stroke of dabs at image points `points` on the destination /// plane, copying from `source` (image px) with the offset fixed in plane-metric units at the /// first dab. `size` is the brush diameter in px at the first dab; `hardness` 0..=1. pub fn clone_stroke(scene: &Scene, surf: &mut Surface, source: [f64; 2], points: &[[f64; 2]], size: f64, hardness: f64, opacity: f32) -> usize { let Some(first) = points.first() else { return 0 }; - let (Some(ps), Some(pd)) = (scene.plane_at(source), scene.plane_at(*first)) else { return 0 }; - let (Some((hs, lus, lvs)), Some((hd, lud, lvd))) = (scene.frame(ps), scene.frame(pd)) else { return 0 }; - let (Some(hs_inv), Some(hd_inv)) = (hs.inverse(), hd.inverse()) else { return 0 }; - let metric = |inv: &Homography, lu: f64, lv: f64, p: [f64; 2]| { - let (u, v) = inv.apply(p[0], p[1]); - [u * lu, v * lv] - }; - let ms = metric(&hs_inv, lus, lvs, source); - let md0 = metric(&hd_inv, lud, lvd, *first); - let offset = [ms[0] - md0[0], ms[1] - md0[1]]; - // Brush radius in metric units (from the image size at the first dab). - let probe = metric(&hd_inv, lud, lvd, [first[0] + size / 2.0, first[1]]); - let r_m = ((probe[0] - md0[0]).hypot(probe[1] - md0[1])).max(1e-9); + clone_dabs(scene, surf, source, *first, points, size, hardness, opacity).0 +} + +/// Where a clone stroke that starts at `anchor` copying from `source` samples for destination +/// `p`: the same plane-metric offset. A live preview paints a stroke in pieces with it, and +/// Aligned strokes keep the first stroke's offset. `None` when `source` or `anchor` is off the +/// planes. +pub fn clone_source(scene: &Scene, source: [f64; 2], anchor: [f64; 2], p: [f64; 2]) -> Option<[f64; 2]> { + let s = CloneFrame::new(scene, source, anchor, 1.0)?.source_of(p); + s.iter().all(|v| v.is_finite()).then_some(s) +} + +/// [`clone_stroke`]'s dabs at `points` for a stroke anchored at `anchor` (its first dab, which +/// fixes the offset and the brush's metric size), so a stroke can be painted in pieces exactly +/// as one. Returns the dabs painted and the area they changed. +#[allow(clippy::too_many_arguments)] +pub fn clone_dabs( + scene: &Scene, + surf: &mut Surface, + source: [f64; 2], + anchor: [f64; 2], + points: &[[f64; 2]], + size: f64, + hardness: f64, + opacity: f32, +) -> (usize, Rect) { + let Some(f) = CloneFrame::new(scene, source, anchor, size) else { return (0, Rect::EMPTY) }; + let (lud, lvd) = f.ld; let src_copy = surf.clone(); let fmt = surf.format(); let n = fmt.channels(); let mut dabs = 0; + let mut changed_area = Rect::EMPTY; for p in points { - let mc = metric(&hd_inv, lud, lvd, *p); + let mc = metric(&f.hd_inv, f.ld, *p); // Image-space footprint: map a metric circle's bounding points. let mut bb = [f64::MAX, f64::MAX, f64::MIN, f64::MIN]; for k in 0..16 { let a = k as f64 / 16.0 * std::f64::consts::TAU; - let (u, v) = ((mc[0] + r_m * a.cos()) / lud, (mc[1] + r_m * a.sin()) / lvd); - let (x, y) = hd.apply(u, v); + let (u, v) = ((mc[0] + f.r_m * a.cos()) / lud, (mc[1] + f.r_m * a.sin()) / lvd); + let (x, y) = f.hd.apply(u, v); bb = [bb[0].min(x), bb[1].min(y), bb[2].max(x), bb[3].max(y)]; } + if bb.iter().any(|v| !v.is_finite()) { + continue; + } let area = Rect::new(bb[0].floor() as i32, bb[1].floor() as i32, (bb[2].ceil() as i32).saturating_add(1), (bb[3].ceil() as i32).saturating_add(1)); if area.is_empty() || area.width() > 4096 || area.height() > 4096 { continue; @@ -365,17 +424,16 @@ pub fn clone_stroke(scene: &Scene, surf: &mut Surface, source: [f64; 2], points: let mut changed = false; for (i, px) in data.chunks_exact_mut(n).enumerate() { let (x, y) = (area.x0 as f64 + (i % w) as f64 + 0.5, area.y0 as f64 + (i / w) as f64 + 0.5); - let m = metric(&hd_inv, lud, lvd, [x, y]); - let d = (m[0] - mc[0]).hypot(m[1] - mc[1]) / r_m; - if d >= 1.0 { + let m = metric(&f.hd_inv, f.ld, [x, y]); + let d = (m[0] - mc[0]).hypot(m[1] - mc[1]) / f.r_m; + if d >= 1.0 || d.is_nan() { continue; } let hard = hardness.clamp(0.0, 0.99); let fall = if d <= hard { 1.0 } else { 1.0 - (d - hard) / (1.0 - hard) }; let k = (fall * fall * (3.0 - 2.0 * fall)) as f32 * opacity; // Source pixel at the same metric offset. - let sm = [m[0] + offset[0], m[1] + offset[1]]; - let (sx, sy) = hs.apply(sm[0] / lus, sm[1] / lvs); + let (sx, sy) = f.hs.apply((m[0] + f.offset[0]) / f.ls.0, (m[1] + f.offset[1]) / f.ls.1); let s = sample(&src_copy, sx - 0.5, sy - 0.5, n); for c in 0..n { px[c] += (s[c] - px[c]) * k; @@ -385,15 +443,22 @@ pub fn clone_stroke(scene: &Scene, surf: &mut Surface, source: [f64; 2], points: if changed { surf.write_region(area, &data); dabs += 1; + changed_area = if changed_area.is_empty() { area } else { changed_area.union(&area) }; } } - dabs + (dabs, changed_area) } fn sample(s: &Surface, x: f64, y: f64, n: usize) -> Vec { + if !x.is_finite() || !y.is_finite() { + return vec![0.0; n]; + } let (x0, y0) = (x.floor() as i32, y.floor() as i32); let (tx, ty) = ((x - x0 as f64) as f32, (y - y0 as f64) as f32); - let r = s.read_region(Rect::new(x0, y0, x0 + 2, y0 + 2)); + let r = s.read_region(Rect::new(x0, y0, x0.saturating_add(2), y0.saturating_add(2))); + if r.len() < 4 * n { + return vec![0.0; n]; + } (0..n).map(|c| (r[c] * (1.0 - tx) + r[n + c] * tx) * (1.0 - ty) + (r[2 * n + c] * (1.0 - tx) + r[3 * n + c] * tx) * ty).collect() } @@ -486,5 +551,8 @@ mod tests { let n = clone_stroke(&sc, &mut s, [sx, sy], &[[dx, dy]], 10.0, 0.8, 1.0); assert_eq!(n, 1); assert!(s.rgba(dx as i32, dy as i32)[0] > 0.8, "{:?}", s.rgba(dx as i32, dy as i32)); + // The stroke's anchor copies from the source itself. + let back = clone_source(&sc, [sx, sy], [dx, dy], [dx, dy]).unwrap(); + assert!((back[0] - sx).abs() < 1e-6 && (back[1] - sy).abs() < 1e-6, "{back:?}"); } } diff --git a/crates/engine/src/vp_cmds.rs b/crates/engine/src/vp_cmds.rs index 185930298a..e1e342a10a 100644 --- a/crates/engine/src/vp_cmds.rs +++ b/crates/engine/src/vp_cmds.rs @@ -3,7 +3,7 @@ //! ([`photocraft_algo::vanishing`]). The edit lands on the active pixel layer, or on a new layer //! with `"newLayer": true` (Photoshop's advice for non-destructive Vanishing Point work). -use photocraft_algo::vanishing::{Edge, PlaneCheck, Scene, VpPlane, clone_stroke, paste}; +use photocraft_algo::vanishing::{Edge, PlaneCheck, Scene, VpPlane, clone_dabs, paste}; use photocraft_doc::{Document, Layer, LayerContent, LayerId}; use photocraft_geom::Rect; use photocraft_raster::Surface; @@ -13,6 +13,11 @@ use crate::commands::CommandSpec; use crate::{EngineError, Result, Session}; pub const VP: &str = "filter.vanishingPoint"; +/// Most planes a scene holds. +pub const MAX_PLANES: usize = 64; +/// Most clone strokes, and dabs over all of them, one run paints. +pub const MAX_CLONE_STROKES: usize = 4096; +pub const MAX_CLONE_DABS: usize = 200_000; fn bad(msg: impl Into) -> EngineError { EngineError::BadParams { cmd: VP.into(), msg: msg.into() } @@ -29,6 +34,9 @@ pub fn scene(p: &Value, canvas: Rect) -> Result { .and_then(Value::as_array) .filter(|a| !a.is_empty()) .ok_or_else(|| bad("pass `planes`: [{\"corners\":[[x,y]×4]}, {\"from\":0,\"edge\":\"top\",\"angle\":90}]"))?; + if planes.len() > MAX_PLANES { + return Err(bad(format!("at most {MAX_PLANES} planes"))); + } let center = [(canvas.x0 + canvas.x1) as f64 / 2.0, (canvas.y0 + canvas.y1) as f64 / 2.0]; let corners = |v: &Value| -> Option<[[f64; 2]; 4]> { let a = v.get("corners")?.as_array()?; @@ -67,6 +75,12 @@ pub fn scene(p: &Value, canvas: Rect) -> Result { }; let angle = pl.get("angle").and_then(Value::as_f64).unwrap_or(90.0); let depth = pl.get("depth").and_then(Value::as_f64).unwrap_or(1.0); + if !angle.is_finite() || !(0.0..=360.0).contains(&angle) { + return Err(bad(format!("plane {i}: `angle` must be 0..360 degrees"))); + } + if !depth.is_finite() || depth <= 0.0 || depth > 1000.0 { + return Err(bad(format!("plane {i}: `depth` must be above 0 and at most 1000"))); + } sc.tear_off(from, edge, angle, depth).ok_or_else(|| bad(format!("plane {i} would lie behind the camera")))?; } if sc.planes.iter().any(|p| p.homography().is_none()) { @@ -75,6 +89,86 @@ pub fn scene(p: &Value, canvas: Rect) -> Result { Ok(sc) } +/// One stroke of `"clone"`. +#[derive(Clone, Debug, PartialEq)] +pub struct CloneSpec { + pub source: [f64; 2], + pub points: Vec<[f64; 2]>, + pub size: f64, + pub hardness: f64, + pub opacity: f64, +} + +/// Reads `"clone"`: finite points, at most [`MAX_CLONE_STROKES`] strokes and +/// [`MAX_CLONE_DABS`] dabs in all. +pub fn clone_specs(p: &Value) -> Result> { + let Some(v) = p.get("clone").filter(|v| !v.is_null()) else { return Ok(Vec::new()) }; + let strokes = v.as_array().ok_or_else(|| bad("`clone` is a list of strokes"))?; + if strokes.len() > MAX_CLONE_STROKES { + return Err(bad(format!("at most {MAX_CLONE_STROKES} clone strokes"))); + } + let finite = |q: [f64; 2]| q.iter().all(|v| v.is_finite() && v.abs() < 1e7); + let num = |c: &Value, k: &str, default: f64, lo: f64, hi: f64| -> Result { + match c.get(k) { + None | Some(Value::Null) => Ok(default), + Some(v) => v.as_f64().filter(|x| x.is_finite()).map(|x| x.clamp(lo, hi)).ok_or_else(|| bad(format!("clone `{k}` must be a number"))), + } + }; + let mut dabs = 0usize; + let mut out = Vec::with_capacity(strokes.len()); + for (k, c) in strokes.iter().enumerate() { + let source = c.get("source").and_then(pt).filter(|q| finite(*q)).ok_or_else(|| bad(format!("clone {k}: `source` [x,y]")))?; + let raw = c.get("points").and_then(Value::as_array).ok_or_else(|| bad(format!("clone {k}: `points` [[x,y], …]")))?; + dabs = dabs.saturating_add(raw.len()); + if dabs > MAX_CLONE_DABS { + return Err(bad(format!("at most {MAX_CLONE_DABS} clone points in all"))); + } + let points = + raw.iter().map(|q| pt(q).filter(|q| finite(*q))).collect::>>().ok_or_else(|| bad(format!("clone {k}: every point is [x,y]")))?; + out.push(CloneSpec { + source, + points, + size: num(c, "size", 40.0, 1.0, 2000.0)?, + hardness: num(c, "hardness", 50.0, 0.0, 100.0)? / 100.0, + opacity: num(c, "opacity", 100.0, 0.0, 100.0)? / 100.0, + }); + } + Ok(out) +} + +/// Paints clone stroke `c` on `surf`, or, with `work` (the image it samples), on `work` and copies +/// the pixels it changed to `surf`. Returns the dabs painted. +pub fn clone_into(sc: &Scene, surf: &mut Surface, work: Option<&mut Surface>, c: &CloneSpec) -> usize { + let Some(first) = c.points.first() else { return 0 }; + let Some(work) = work else { + return clone_dabs(sc, surf, c.source, *first, &c.points, c.size, c.hardness, c.opacity as f32).0; + }; + let before = work.clone(); + let (dabs, area) = clone_dabs(sc, work, c.source, *first, &c.points, c.size, c.hardness, c.opacity as f32); + copy_changed(surf, &before, work, area); + dabs +} + +/// Copies to `dst` the pixels of `area` where `after` differs from `before` (same format). +pub fn copy_changed(dst: &mut Surface, before: &Surface, after: &Surface, area: Rect) { + if area.is_empty() { + return; + } + let n = dst.format().channels(); + let (nw, ow, mut cur) = (after.read_region(area), before.read_region(area), dst.read_region(area)); + for ((c, a), b) in cur.chunks_exact_mut(n).zip(nw.chunks_exact(n)).zip(ow.chunks_exact(n)) { + if a != b { + c.copy_from_slice(a); + } + } + dst.write_region(area, &cur); +} + +/// The image a `"newLayer"` run's clone strokes sample: the visible document. +pub fn visible_image(doc: &Document) -> Surface { + crate::file_cmds::flattened(doc, doc.pixel_format()) +} + fn has_layer(s: &Session) -> std::result::Result<(), String> { let d = s.active().ok_or("no document open")?; match d.active_layer.and_then(|id| d.doc.layer(id)).map(|l| &l.content) { @@ -134,7 +228,7 @@ fn vanishing_point(s: &mut Session, p: &Value) -> Result { let width = item.get("width").and_then(Value::as_f64).unwrap_or(0.5).clamp(0.01, 10.0); pastes.push((plane, surf, rect, at, width)); } - let clones: Vec = p.get("clone").and_then(Value::as_array).cloned().unwrap_or_default(); + let clones = clone_specs(p)?; let new_layer = p.get("newLayer").and_then(Value::as_bool).unwrap_or(false); let mut dabs = 0usize; let target = s.edit("Vanishing Point", |doc: &mut Document, active| { @@ -147,7 +241,7 @@ fn vanishing_point(s: &mut Session, p: &Value) -> Result { active.ok_or_else(|| EngineError::Other("no active layer".into()))? }; // A new layer clones from the visible image; otherwise from the layer itself. - let base: Option = new_layer.then(|| crate::file_cmds::flattened(doc, doc.pixel_format())); + let base: Option = new_layer.then(|| visible_image(doc)); let locks = doc.effective_locks(id); let l = doc.layer_mut(id).ok_or(EngineError::NoLayer(id))?; if locks.all || locks.pixels { @@ -159,36 +253,14 @@ fn vanishing_point(s: &mut Session, p: &Value) -> Result { over(surf, &out); } } - for (k, c) in clones.iter().enumerate() { - let source = c.get("source").and_then(pt).ok_or_else(|| bad(format!("clone {k}: `source` [x,y]")))?; - let points: Vec<[f64; 2]> = c.get("points").and_then(Value::as_array).map(|a| a.iter().filter_map(pt).collect()).unwrap_or_default(); - let size = c.get("size").and_then(Value::as_f64).unwrap_or(40.0).clamp(1.0, 2000.0); - let hardness = c.get("hardness").and_then(Value::as_f64).unwrap_or(50.0).clamp(0.0, 100.0) / 100.0; - let opacity = (c.get("opacity").and_then(Value::as_f64).unwrap_or(100.0).clamp(0.0, 100.0) / 100.0) as f32; - // Sample from the original pixels (merged with what's been pasted). - let mut work = match &base { - Some(b) => { - let mut w = b.clone(); - over(&mut w, surf); - w - } - None => surf.clone(), - }; - let before = work.clone(); - dabs += clone_stroke(&sc, &mut work, source, &points, size, hardness, opacity); - // Copy back only what the stroke changed. - let b = work.content_bounds().union(&before.content_bounds()); - if !b.is_empty() { - let (nw, ow) = (work.read_region(b), before.read_region(b)); - let n = surf.format().channels(); - let mut cur = surf.read_region(b); - for i in 0..cur.len() / n { - if nw[i * n..(i + 1) * n] != ow[i * n..(i + 1) * n] { - cur[i * n..(i + 1) * n].copy_from_slice(&nw[i * n..(i + 1) * n]); - } - } - surf.write_region(b, &cur); - } + // A new layer samples the visible image (merged with what's been pasted) and takes only + // the pixels the strokes change; otherwise the strokes paint the layer itself. + let mut work = base.map(|mut w| { + over(&mut w, surf); + w + }); + for c in &clones { + dabs += clone_into(&sc, surf, work.as_mut(), c); } surf.prune(); Ok(id) @@ -282,4 +354,35 @@ mod tests { } assert!(s.execute(VP, json!({"planes": [{"corners": square}]})).is_ok()); } + + #[test] + fn rejects_hostile_clone_and_tear_off_params() { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 200, "height": 200, "depth": 32})).unwrap(); + s.execute("layer.new.layer", json!({})).unwrap(); + let floor = json!({"corners": [[60, 60], [140, 60], [190, 190], [10, 190]]}); + for torn in [json!({"from": 0, "angle": 1e9}), json!({"from": 0, "depth": -1}), json!({"from": 0, "depth": 1e300})] { + let e = s.execute(VP, json!({"planes": [floor, torn]})).unwrap_err().to_string(); + assert!(e.contains("plane 1"), "{e}"); + } + let many: Vec<[f64; 2]> = vec![[100.0, 150.0]; MAX_CLONE_DABS + 1]; + for clone in [ + json!([{"points": [[100, 150]]}]), + json!([{"source": [100, 180], "points": [[100, 150], "x"]}]), + json!([{"source": [100, 180], "points": [[100, 150]], "size": "big"}]), + json!([{"source": [100, 180], "points": many}]), + json!({"source": [100, 180]}), + ] { + let label: String = clone.to_string().chars().take(80).collect(); + assert!(s.execute(VP, json!({"planes": [floor], "clone": clone})).is_err(), "{label}"); + } + let planes: Vec = std::iter::repeat_n(floor.clone(), MAX_PLANES + 1).collect(); + assert!(s.execute(VP, json!({"planes": planes})).is_err()); + // A clone on a torn-off wall, at 32 bits, sampling the floor. + let r = s + .execute(VP, json!({"planes": [floor, {"from": 0, "edge": "top", "angle": 90, "depth": 0.5}], "clone": [{"source": [100, 150], "points": [[100, 50], [104, 50]], "size": 8}]})) + .unwrap(); + assert_eq!(r["planes"].as_array().unwrap().len(), 2); + assert!(r["dabs"].as_u64().unwrap() >= 1, "{r}"); + } } diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 3cd4d294d8..0f389f4971 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -1164,6 +1164,13 @@ pub(crate) fn damage_since(app: &PhotocraftApp, idx: usize, seen: (u64, u64), no { return Some(if r.is_empty() { r } else { r.inflate(effect_reach(&st.doc.layers)) }); } + // Between Vanishing Point stamp previews (and the document): the areas the strokes painted. + if seen.0 == now.0 + && let Some(st) = app.session.documents().get(idx) + && let Some(r) = crate::vp_ui::damage(app, st.doc.id, now.0, seen.1 ^ display_key, now.1) + { + return Some(if r.is_empty() { r } else { r.inflate(effect_reach(&st.doc.layers)) }); + } // Between hovered blend modes (and the document): where the layer's blending shows. if seen.0 == now.0 && let Some(st) = app.session.documents().get(idx) diff --git a/crates/ui-egui/src/distort_ui.rs b/crates/ui-egui/src/distort_ui.rs index 0a0d7914b0..1acb42e909 100644 --- a/crates/ui-egui/src/distort_ui.rs +++ b/crates/ui-egui/src/distort_ui.rs @@ -86,7 +86,8 @@ pub(crate) fn surface_image(surf: &Surface, r: Rect, max_side: usize) -> ColorIm ColorImage::new([tw, th], px) } -/// The document shown on the canvas while Puppet or Perspective Warp previews a layer. +/// The document shown on the canvas while Puppet or Perspective Warp previews a layer, or +/// Vanishing Point's Stamp has painted. pub fn display_doc(app: &PhotocraftApp, idx: usize) -> Option<(Arc, u64)> { if app.session.active_index() != Some(idx) { return None; @@ -97,7 +98,8 @@ pub fn display_doc(app: &PhotocraftApp, idx: usize) -> Option<(Arc, u6 if let Some(p) = &app.distort.perspective { return Some((p.preview_doc.clone(), (1 << 42) + p.key)); } - None + // Vanishing Point: the clone strokes painted so far. + app.distort.vanishing.as_ref().and_then(crate::vp_ui::VpSession::shown) } /// Menu / control routing. `Some` when this module handles the invocation. diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index b39e9381a8..ebcb09e1b4 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -2449,3 +2449,6 @@ fontWeight Italic Kurzíva Vanishing Point is not active Úběžník není aktivní Apply Vanishing Point ({key}) Použít úběžník ({key}) Fix the red plane first: its corners must form a convex quad Nejprve opravte červenou rovinu: její rohy musí tvořit konvexní čtyřúhelník + Alt-click a plane to set the clone source Klepnutím s Alt na rovinu nastavte zdroj klonování + Too many clone strokes: apply Vanishing Point first Příliš mnoho tahů klonování: nejprve použijte Úběžník + Stamp Razítko diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index b5eee5bed2..41ae8d221e 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -2487,3 +2487,5 @@ fontWeight Italic Kursiv Vanishing Point is not active Fluchtpunkt ist nicht aktiv Apply Vanishing Point ({key}) Fluchtpunkt anwenden ({key}) Fix the red plane first: its corners must form a convex quad Korrigieren Sie zuerst die rote Ebene: Ihre Ecken müssen ein konvexes Viereck bilden + Alt-click a plane to set the clone source Alt-Klick auf eine Ebene legt die Kopierquelle fest + Too many clone strokes: apply Vanishing Point first Zu viele Kopierstriche: Wenden Sie zuerst Fluchtpunkt an diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index f01045950d..b156cd0717 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3553,3 +3553,5 @@ fontWeight Thin Πολύ λεπτά Vanishing Point is not active Το Σημείο φυγής δεν είναι ενεργό Apply Vanishing Point ({key}) Εφαρμογή σημείου φυγής ({key}) Fix the red plane first: its corners must form a convex quad Διορθώστε πρώτα το κόκκινο επίπεδο: οι γωνίες του πρέπει να σχηματίζουν κυρτό τετράπλευρο + Alt-click a plane to set the clone source Alt-κλικ σε ένα επίπεδο για να ορίσετε την πηγή κλωνοποίησης + Too many clone strokes: apply Vanishing Point first Πάρα πολλές πινελιές κλωνοποίησης: εφαρμόστε πρώτα το Σημείο φυγής diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 5517d8dadf..79f84360c1 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2528,3 +2528,5 @@ fontWeight Italic Cursiva Vanishing Point is not active Punto de fuga no está activo Apply Vanishing Point ({key}) Aplicar punto de fuga ({key}) Fix the red plane first: its corners must form a convex quad Corrija primero el plano rojo: sus esquinas deben formar un cuadrilátero convexo + Alt-click a plane to set the clone source Haga Alt-clic en un plano para definir el origen de clonación + Too many clone strokes: apply Vanishing Point first Demasiados trazos de clonación: aplique primero Punto de fuga diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 8d3121dd79..e319253071 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -2864,3 +2864,5 @@ fontWeight Italic Italique Vanishing Point is not active Point de fuite n’est pas actif Apply Vanishing Point ({key}) Appliquer le point de fuite ({key}) Fix the red plane first: its corners must form a convex quad Corrigez d’abord le plan rouge : ses coins doivent former un quadrilatère convexe + Alt-click a plane to set the clone source Alt-clic sur un plan pour définir la source de duplication + Too many clone strokes: apply Vanishing Point first Trop de traits de duplication : appliquez d’abord Point de fuite diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 910342b185..66e496645b 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -2851,3 +2851,5 @@ fontWeight Italic Miring Vanishing Point is not active Vanishing Point tidak aktif Apply Vanishing Point ({key}) Terapkan Vanishing Point ({key}) Fix the red plane first: its corners must form a convex quad Perbaiki bidang merah dulu: sudut-sudutnya harus membentuk segi empat cembung + Alt-click a plane to set the clone source Alt-klik sebuah bidang untuk menetapkan sumber kloning + Too many clone strokes: apply Vanishing Point first Terlalu banyak goresan kloning: terapkan Vanishing Point terlebih dahulu diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 81c3145854..5857ef220b 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -2518,3 +2518,5 @@ fontWeight Italic Corsivo Vanishing Point is not active Punto di fuga non è attivo Apply Vanishing Point ({key}) Applica punto di fuga ({key}) Fix the red plane first: its corners must form a convex quad Correggi prima il piano rosso: i suoi angoli devono formare un quadrilatero convesso + Alt-click a plane to set the clone source Alt-clic su un piano per impostare l’origine della clonazione + Too many clone strokes: apply Vanishing Point first Troppi tratti di clonazione: applica prima Punto di fuga diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 08f56447ed..383e83dfed 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3464,3 +3464,5 @@ fontWeight Italic 斜体 Vanishing Point is not active 消点はアクティブではありません Apply Vanishing Point ({key}) 消点を適用({key}) Fix the red plane first: its corners must form a convex quad 先に赤い面を修正してください:角が凸四角形になる必要があります + Alt-click a plane to set the clone source Alt キーを押しながら平面をクリックしてコピー元を設定 + Too many clone strokes: apply Vanishing Point first コピースタンプのストロークが多すぎます:先に消点を適用してください diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 81b10fb7ce..4e37562ff0 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3026,3 +3026,5 @@ fontWeight Italic 기울임 Vanishing Point is not active 소실점이 활성화되어 있지 않습니다 Apply Vanishing Point ({key}) 소실점 적용 ({key}) Fix the red plane first: its corners must form a convex quad 먼저 빨간색 평면을 수정하십시오: 모서리가 볼록 사각형을 이루어야 합니다 + Alt-click a plane to set the clone source Alt 키를 누른 채 평면을 클릭하여 복제 소스를 설정하십시오 + Too many clone strokes: apply Vanishing Point first 복제 획이 너무 많습니다. 먼저 소실점을 적용하십시오 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 456b8c3f44..106f3f347a 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -3623,3 +3623,5 @@ cameraRaw Whites Witten Vanishing Point is not active Verdwijnpunt is niet actief Apply Vanishing Point ({key}) Verdwijnpunt toepassen ({key}) Fix the red plane first: its corners must form a convex quad Herstel eerst het rode vlak: de hoeken moeten een convexe vierhoek vormen + Alt-click a plane to set the clone source Alt-klik op een vlak om de kloonbron in te stellen + Too many clone strokes: apply Vanishing Point first Te veel kloonstreken: pas eerst Verdwijnpunt toe diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 8acdcd1c62..aaeed61b53 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3464,3 +3464,5 @@ cameraRaw Roughness Chropowatość Vanishing Point is not active Punkt zbieżności nie jest aktywny Apply Vanishing Point ({key}) Zastosuj punkt zbieżności ({key}) Fix the red plane first: its corners must form a convex quad Najpierw popraw czerwoną płaszczyznę: jej narożniki muszą tworzyć czworokąt wypukły + Alt-click a plane to set the clone source Kliknij płaszczyznę z Alt, aby ustawić źródło klonowania + Too many clone strokes: apply Vanishing Point first Zbyt wiele pociągnięć klonowania: najpierw zastosuj Punkt zbieżności diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 1b58102b86..b724f5d70c 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2872,3 +2872,5 @@ fontWeight Italic Itálico Vanishing Point is not active Ponto de fuga não está ativo Apply Vanishing Point ({key}) Aplicar ponto de fuga ({key}) Fix the red plane first: its corners must form a convex quad Corrija primeiro o plano vermelho: seus cantos devem formar um quadrilátero convexo + Alt-click a plane to set the clone source Clique com Alt em um plano para definir a origem da clonagem + Too many clone strokes: apply Vanishing Point first Traços de clonagem demais: aplique Ponto de fuga primeiro diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 22eda77f08..6264aa9c00 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -2731,3 +2731,5 @@ fontWeight Italic Курсив Vanishing Point is not active Точка схода не активна Apply Vanishing Point ({key}) Применить точку схода ({key}) Fix the red plane first: its corners must form a convex quad Сначала исправьте красную плоскость: ее углы должны образовывать выпуклый четырехугольник + Alt-click a plane to set the clone source Щёлкните плоскость с Alt, чтобы задать источник клонирования + Too many clone strokes: apply Vanishing Point first Слишком много мазков клонирования: сначала примените «Точку схода» diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 3fd50ffaf1..cc39bf218b 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3551,3 +3551,5 @@ cameraRaw Masking Маскування Vanishing Point is not active Точка сходження не активна Apply Vanishing Point ({key}) Застосувати точку сходження ({key}) Fix the red plane first: its corners must form a convex quad Спершу виправте червону площину: її кути мають утворювати опуклий чотирикутник + Alt-click a plane to set the clone source Клацніть площину з Alt, щоб задати джерело клонування + Too many clone strokes: apply Vanishing Point first Забагато мазків клонування: спочатку застосуйте «Точку сходження» diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 644eb96e9c..422ef6a1a0 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2456,3 +2456,6 @@ fontWeight Italic 斜体 Vanishing Point is not active 消失点未处于活动状态 Apply Vanishing Point ({key}) 应用消失点({key}) Fix the red plane first: its corners must form a convex quad 请先修正红色平面:其四个角必须构成凸四边形 + Alt-click a plane to set the clone source 按住 Alt 键单击平面以设置仿制源 + Too many clone strokes: apply Vanishing Point first 仿制描边过多:请先应用消失点 + Stamp 图章 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 2150018ee0..09887f0bd5 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2426,3 +2426,6 @@ fontWeight Italic 斜體 Vanishing Point is not active 消失點未啟用 Apply Vanishing Point ({key}) 套用消失點 ({key}) Fix the red plane first: its corners must form a convex quad 請先修正紅色平面:其四個角必須構成凸四邊形 + Alt-click a plane to set the clone source 按住 Alt 鍵按一下平面以設定仿製來源 + Too many clone strokes: apply Vanishing Point first 仿製筆畫過多:請先套用消失點 + Stamp 印章 diff --git a/crates/ui-egui/src/vp_ui.rs b/crates/ui-egui/src/vp_ui.rs index bdaad601c6..4e32edc72b 100644 --- a/crates/ui-egui/src/vp_ui.rs +++ b/crates/ui-egui/src/vp_ui.rs @@ -2,19 +2,27 @@ //! //! **Create Plane** (C): four clicks set a plane's corners, in any order. **Edit Plane** (V): //! drag a corner node, or an edge node to slide that edge along the plane's own perspective; -//! click a plane to select it, Delete removes it. The plane's grid is drawn at the Grid Size and, +//! click a plane to select it, Delete removes it. Ctrl/Cmd-dragging an edge node tears off a +//! perpendicular plane; dragging the torn plane's far edge node sets its depth and Alt-dragging +//! it its angle (it stays a torn-off plane, so it follows its parent). The plane's grid is drawn +//! at the Grid Size and, //! like Photoshop's, in the accent colour when the plane is valid, yellow when its perspective is //! doubtful and red when it is invalid ([`VpPlane::check`]). With an image on the clipboard the -//! selected plane shows it pasted in perspective; drag it to move it on the plane. ↩ / OK runs -//! `filter.vanishingPoint` with the planes and the paste, so it is one history step and an -//! action or agent can replay it exactly. +//! selected plane shows it pasted in perspective; drag it to move it on the plane. **Stamp** (S): +//! Alt-click a plane to set the source, then paint to clone in perspective (Diameter, Hardness, +//! Opacity, Aligned); the canvas shows the strokes as they are painted. ↩ / OK runs +//! `filter.vanishingPoint` with the planes, the paste and the strokes, so the whole session is +//! one history step and an action or agent can replay it exactly. + +use std::sync::Arc; use egui::{Color32, Pos2, Stroke, TextureHandle, pos2}; use photocraft_algo::transform::Homography; -use photocraft_algo::vanishing::{PlaneCheck, Scene, VpPlane}; -use photocraft_doc::{LayerContent, LayerId}; -use photocraft_engine::vp_cmds::VP; +use photocraft_algo::vanishing::{Edge, PlaneCheck, Scene, VpPlane, clone_dabs, clone_source}; +use photocraft_doc::{DocId, Document, Layer, LayerContent, LayerId}; +use photocraft_engine::vp_cmds::{CloneSpec, MAX_CLONE_DABS, MAX_CLONE_STROKES, VP, copy_changed, visible_image}; use photocraft_geom::Rect; +use photocraft_raster::Surface; use serde_json::{Value, json}; use crate::PhotocraftApp; @@ -25,6 +33,45 @@ use crate::canvas::{ToolEvent, ViewXform}; pub enum VpTool { EditPlane, CreatePlane, + Stamp, +} + +/// A plane torn off an edge of an earlier plane: the engine's +/// `{"from", "edge", "angle", "depth"}`, so it follows its parent when that is edited. +#[derive(Clone, Copy, Debug, PartialEq, serde::Serialize)] +pub struct Torn { + pub from: usize, + pub edge: Edge, + /// Degrees between the planes (90 = perpendicular). + pub angle: f64, + /// Extent as a multiple of the parent's adjacent side. + pub depth: f64, +} + +/// The Stamp tool's options. +#[derive(Clone, Copy, Debug, PartialEq, serde::Serialize)] +#[serde(rename_all = "camelCase")] +pub struct StampOptions { + /// Brush diameter in px where a stroke starts. + pub diameter: f64, + /// 0..=100. + pub hardness: f64, + /// 0..=100. + pub opacity: f64, + /// Later strokes keep the first stroke's source offset instead of restarting at the source. + pub aligned: bool, +} + +/// Edge node `i` (0 top, 1 right, 2 bottom, 3 left) as the engine's edge. +const EDGES: [Edge; 4] = [Edge::Top, Edge::Right, Edge::Bottom, Edge::Left]; + +fn edge_index(e: Edge) -> usize { + match e { + Edge::Top => 0, + Edge::Right => 1, + Edge::Bottom => 2, + Edge::Left => 3, + } } enum Drag { @@ -35,6 +82,28 @@ enum Drag { Edge { plane: usize, edge: usize, h: Homography, inv: Homography }, /// The pasted image, and the pointer offset from its top-left in plane coordinates. Paste { offset: [f64; 2] }, + /// The far edge node of torn-off plane `plane` (or of one being torn off): the drag sets + /// its depth, or with `rotate` (Alt) its angle, once it has left `start`. + Torn { plane: usize, rotate: bool, start: [f64; 2], moved: bool }, + /// Painting the last of the clone strokes. + Stamp, +} + +/// The clone strokes painted onto the target layer, shown on the canvas while stamping. +struct StampPreview { + /// The session's `rev` and New Layer it was painted with (either changing repaints it). + rev: u64, + new_layer: bool, + /// On a new layer: the visible image the strokes sample, with the strokes so far. + work: Option, + /// The target layer's pixels as painted so far. + out: Surface, + /// Strokes painted: those before `.0`, and the first `.1` points of stroke `.0`. + done: (usize, usize), + /// Preview keys shown, each with the area changed since the previous one (the first since + /// the document). + keys: Vec<(u64, Rect)>, + shown: Arc, } /// The clipboard image shown pasted onto the plane. @@ -47,7 +116,10 @@ struct Clip { pub struct VpSession { pub layer: LayerId, canvas: Rect, + /// The planes' corners; torn-off planes' are derived from their parents ([`Self::resolve`]). pub planes: Vec, + /// Per plane: how it was torn off, or `None` for a drawn plane (always the first one). + pub torn: Vec>, pub tool: VpTool, /// Corners clicked so far with Create Plane. pending: Vec<[f64; 2]>, @@ -63,21 +135,61 @@ pub struct VpSession { pub new_layer: bool, clip: Option, drag: Option, + pub stamp: StampOptions, + /// Stamp source (Alt-click), image px. + pub source: Option<[f64; 2]>, + /// Clone strokes painted so far, sent as `"clone"` on OK. + pub strokes: Vec, + /// The first stroke's (source, start) since the source was set: Aligned strokes keep its offset. + aligned_ref: Option<([f64; 2], [f64; 2])>, + /// Bumped whenever the planes or the strokes change other than by painting on. + rev: u64, + /// The document as the session began (the preview paints over it). + base: Arc, + doc_revision: u64, + preview: Option, } /// Most planes a session holds (the control channel can't make it allocate without bound). const MAX_PLANES: usize = 64; /// Most grid lines drawn per direction. const MAX_LINES: usize = 200; +/// Preview keys of the stamp preview: `PREVIEW_KEY + id` (see `canvas::display_doc`). +const PREVIEW_KEY: u64 = 1 << 42; + +fn union(a: Rect, b: Rect) -> Rect { + if a.is_empty() { + b + } else if b.is_empty() { + a + } else { + a.union(&b) + } +} impl VpSession { pub fn describe(&self) -> Value { let center = self.center(); - let planes: Vec = self.planes.iter().map(|p| json!({"corners": p.corners, "check": p.check(center)})).collect(); + let planes: Vec = self + .planes + .iter() + .enumerate() + .map(|(i, p)| { + let mut v = json!({"corners": p.corners, "check": p.check(center)}); + if let Some(t) = self.torn.get(i).copied().flatten() { + v["tornOff"] = json!(t); + } + v + }) + .collect(); json!({ "layer": self.layer.0, "tool": self.tool, "planes": planes, + "stamp": self.stamp, + "source": self.source, + "strokes": self.strokes.len(), + "dabs": self.dabs(), "pending": self.pending, "selected": self.selected, "gridSize": self.grid_size, @@ -125,19 +237,70 @@ impl VpSession { Some([self.paste_width, self.paste_width * lu / lv * c.height / c.width.max(1.0)]) } - /// The command's params: the planes, and the paste when there is one. + /// The command's params: the planes (torn-off ones as such), the paste and the clone + /// strokes when there are any. pub fn params(&self) -> Value { - let planes: Vec = self.planes.iter().map(|p| json!({"corners": p.corners})).collect(); + let planes: Vec = self + .planes + .iter() + .enumerate() + .map(|(i, p)| match self.torn.get(i).copied().flatten() { + Some(t) => json!({"from": t.from, "edge": t.edge, "angle": t.angle, "depth": t.depth}), + None => json!({"corners": p.corners}), + }) + .collect(); let mut p = json!({"planes": planes}); if let Some(i) = self.paste_plane() { p["paste"] = json!([{"plane": i, "at": self.paste_at, "width": self.paste_width}]); } + if !self.strokes.is_empty() { + let clone: Vec = self + .strokes + .iter() + .map(|c| json!({"source": c.source, "points": c.points, "size": c.size, "hardness": c.hardness * 100.0, "opacity": c.opacity * 100.0})) + .collect(); + p["clone"] = json!(clone); + } if self.new_layer { p["newLayer"] = json!(true); } p } + fn dabs(&self) -> usize { + self.strokes.iter().map(|c| c.points.len()).sum() + } + + /// Recomputes the torn-off planes' corners from their parents, in order (the way the engine + /// builds the scene), so they follow every edit. A plane that can't be torn off any more + /// (it would lie behind the camera) collapses to an invalid one. + fn resolve(&mut self) { + self.rev += 1; + self.torn.resize(self.planes.len(), None); + let Some(first) = self.planes.first().cloned() else { return }; + let fallback = f64::from(self.canvas.width().max(self.canvas.height())); + let mut sc = Scene::new(first, self.center(), None, fallback); + for i in 1..self.planes.len() { + match self.torn.get(i).copied().flatten().filter(|t| t.from < i) { + Some(t) => { + if sc.tear_off(t.from, t.edge, t.angle, t.depth).is_none() { + sc.planes.push(VpPlane { corners: [[0.0; 2]; 4] }); + } + } + None => sc.planes.push(self.planes[i].clone()), + } + } + self.planes = sc.planes; + } + + fn push_plane(&mut self, plane: VpPlane, torn: Option) { + self.torn.resize(self.planes.len(), None); + self.planes.push(plane); + self.torn.push(torn); + self.selected = Some(self.planes.len() - 1); + self.resolve(); + } + fn add_corner(&mut self, p: [f64; 2]) { if self.planes.len() >= MAX_PLANES { return; @@ -145,20 +308,194 @@ impl VpSession { self.pending.push(p); if let Ok(corners) = <[[f64; 2]; 4]>::try_from(self.pending.as_slice()) { self.pending.clear(); - self.planes.push(VpPlane { corners }.normalized()); - self.selected = Some(self.planes.len() - 1); + self.push_plane(VpPlane { corners }.normalized(), None); // Photoshop hands over to Edit Plane once a plane is closed. self.tool = VpTool::EditPlane; } } + /// Deletes the selected plane; planes torn off it keep their place as drawn planes. fn delete_selected(&mut self) { if let Some(i) = self.selected.take().filter(|i| *i < self.planes.len()) { + self.torn.resize(self.planes.len(), None); self.planes.remove(i); + self.torn.remove(i); + for t in self.torn.iter_mut() { + match t { + Some(c) if c.from == i => *t = None, + Some(c) if c.from > i => c.from -= 1, + _ => {} + } + } self.drag = None; + self.resolve(); } } + /// Starts tearing a plane off edge `edge` of plane `from` at the press `p`. + fn tear_off(&mut self, from: usize, edge: usize, p: [f64; 2]) { + if self.planes.len() >= MAX_PLANES { + return; + } + let Some(&e) = EDGES.get(edge) else { return }; + self.push_plane(VpPlane { corners: [[0.0; 2]; 4] }, Some(Torn { from, edge: e, angle: 90.0, depth: 0.5 })); + // As after closing a plane, Edit Plane takes over. + self.tool = VpTool::EditPlane; + self.pending.clear(); + self.drag = Some(Drag::Torn { plane: self.planes.len() - 1, rotate: false, start: p, moved: false }); + } + + /// Fits torn plane `i`'s depth (or with `rotate` its angle) so its far edge's middle is as + /// near `p` as it can get. + fn fit_torn(&mut self, i: usize, rotate: bool, p: [f64; 2]) { + let Some(t) = self.torn.get(i).copied().flatten() else { return }; + let Some(first) = self.planes.first().cloned() else { return }; + if t.from >= i || i >= self.planes.len() { + return; + } + let fallback = f64::from(self.canvas.width().max(self.canvas.height())); + let mut sc = Scene::new(first, self.center(), None, fallback); + sc.planes.extend(self.planes.iter().take(i).skip(1).cloned()); + let e = edge_index(t.edge); + let mut miss = |angle: f64, depth: f64| -> f64 { + if sc.tear_off(t.from, t.edge, angle, depth).is_none() { + return f64::MAX; + } + let Some(c) = sc.planes.pop().map(|pl| pl.corners) else { return f64::MAX }; + let (a, b) = (c[e], c[(e + 1) % 4]); + let d = ((a[0] + b[0]) / 2.0 - p[0]).hypot((a[1] + b[1]) / 2.0 - p[1]); + if d.is_finite() { d } else { f64::MAX } + }; + let best = |values: &mut dyn Iterator, miss: &mut dyn FnMut(f64) -> f64| { + values.map(|v| (miss(v), v)).filter(|m| m.0 < f64::MAX).min_by(|a, b| a.0.total_cmp(&b.0)).map(|m| m.1) + }; + let (angle, depth) = if rotate { + let Some(a) = best(&mut (1..180).map(f64::from), &mut |a| miss(a, t.depth)) else { return }; + let a = best(&mut (-10..=10).map(|k| a + f64::from(k) / 10.0), &mut |a| miss(a, t.depth)).unwrap_or(a); + (a.clamp(1.0, 179.0), t.depth) + } else { + let Some(d) = best(&mut (0..=160).map(|k| 0.02 * 1.06f64.powi(k)), &mut |d| miss(t.angle, d)) else { return }; + let d = best(&mut (-10..=10).map(|k| d * (1.0 + f64::from(k) * 0.006)), &mut |d| miss(t.angle, d)).unwrap_or(d); + (t.angle, d.clamp(0.02, 1000.0)) + }; + if let Some(Some(t)) = self.torn.get_mut(i) { + t.angle = angle; + t.depth = depth; + } + self.resolve(); + } + + /// Stamp press: Alt sets the source, otherwise a stroke starts. Returns a status message. + fn stamp_press(&mut self, p: [f64; 2], alt: bool) -> Option<&'static str> { + let sc = self.scene()?; + let on_plane = |q: [f64; 2]| sc.plane_at(q).is_some(); + if alt { + if !on_plane(p) { + return Some(tl!("Alt-click a plane to set the clone source")); + } + self.source = Some(p); + self.aligned_ref = None; + return None; + } + let Some(source) = self.source else { return Some(tl!("Alt-click a plane to set the clone source")) }; + if !on_plane(p) { + return None; + } + if self.strokes.len() >= MAX_CLONE_STROKES || self.dabs() >= MAX_CLONE_DABS { + return Some(tl!("Too many clone strokes: apply Vanishing Point first")); + } + let src = match self.aligned_ref.filter(|_| self.stamp.aligned) { + Some((s0, a0)) => clone_source(&sc, s0, a0, p).filter(|s| on_plane(*s)).unwrap_or(source), + None => source, + }; + if self.aligned_ref.is_none() { + self.aligned_ref = Some((src, p)); + } + let o = self.stamp; + self.strokes.push(CloneSpec { source: src, points: vec![p], size: o.diameter, hardness: o.hardness / 100.0, opacity: o.opacity / 100.0 }); + self.drag = Some(Drag::Stamp); + None + } + + /// Extends the current stroke to `p` with dabs a tenth of the brush apart. + fn stamp_to(&mut self, p: [f64; 2]) { + let room = MAX_CLONE_DABS.saturating_sub(self.dabs()); + let Some(c) = self.strokes.last_mut() else { return }; + let Some(last) = c.points.last().copied() else { return }; + let step = (c.size * 0.1).max(1.0); + let d = (p[0] - last[0]).hypot(p[1] - last[1]); + if !d.is_finite() || d < step { + return; + } + let n = ((d / step) as usize).min(room); + c.points.extend((1..=n).map(|k| { + let t = k as f64 * step / d; + [last[0] + (p[0] - last[0]) * t, last[1] + (p[1] - last[1]) * t] + })); + } + + /// Paints what the preview doesn't show yet (all of it after the planes changed). `key` + /// names a new preview. False when nothing changed. + fn paint_preview(&mut self, key: impl FnOnce() -> u64) -> bool { + if self.strokes.is_empty() { + let had = self.preview.is_some(); + self.preview = None; + return had; + } + let Some(sc) = self.scene() else { return false }; + let stale = self.preview.as_ref().is_none_or(|p| p.rev != self.rev || p.new_layer != self.new_layer); + let mut area = Rect::EMPTY; + if stale { + let Some(layer) = self.base.layer(self.layer).and_then(Layer::surface) else { return false }; + let (out, work) = if self.new_layer { (Surface::new(layer.format()), Some(visible_image(&self.base))) } else { (layer.clone(), None) }; + // The old preview's area changes back too. + let keys = self.preview.take().map(|p| p.keys).unwrap_or_default(); + area = keys.iter().fold(Rect::EMPTY, |a, k| union(a, k.1)); + self.preview = Some(StampPreview { rev: self.rev, new_layer: self.new_layer, work, out, done: (0, 0), keys, shown: self.base.clone() }); + } + let Some(pv) = self.preview.as_mut() else { return false }; + let (from_stroke, from_point) = pv.done; + for (si, c) in self.strokes.iter().enumerate().skip(from_stroke) { + let skip = if si == from_stroke { from_point } else { 0 }; + let (Some(anchor), Some(points)) = (c.points.first(), c.points.get(skip..)) else { continue }; + if points.is_empty() { + continue; + } + let (hard, opacity) = (c.hardness, c.opacity as f32); + let changed = match pv.work.as_mut() { + Some(work) => { + let before = work.clone(); + let (_, a) = clone_dabs(&sc, work, c.source, *anchor, points, c.size, hard, opacity); + copy_changed(&mut pv.out, &before, work, a); + a + } + None => clone_dabs(&sc, &mut pv.out, c.source, *anchor, points, c.size, hard, opacity).1, + }; + area = union(area, changed); + } + pv.done = (self.strokes.len() - 1, self.strokes.last().map_or(0, |c| c.points.len())); + if area.is_empty() && !stale { + return false; + } + let mut d = (*self.base).clone(); + if self.new_layer { + let mut l = Layer::raster(d.next_layer_name("Vanishing Point"), d.pixel_format()); + l.content = LayerContent::Raster(pv.out.clone()); + d.insert_above(Some(self.layer), l); + } else if let Some(LayerContent::Raster(s)) = d.layer_mut(self.layer).map(|l| &mut l.content) { + *s = pv.out.clone(); + } + pv.shown = Arc::new(d); + pv.keys.push((key(), area)); + true + } + + /// The document with the strokes painted, and its preview key. + pub(crate) fn shown(&self) -> Option<(Arc, u64)> { + let p = self.preview.as_ref()?; + Some((p.shown.clone(), PREVIEW_KEY + p.keys.last()?.0)) + } + /// Image positions of the edge nodes of plane `i`. fn edge_nodes(&self, i: usize) -> Option<[[f64; 2]; 4]> { let h = self.planes.get(i)?.homography()?; @@ -169,20 +506,40 @@ impl VpSession { Some([at(0.5, 0.0), at(1.0, 0.5), at(0.5, 1.0), at(0.0, 0.5)]) } - fn press(&mut self, p: [f64; 2], tol: f64) { - if self.tool == VpTool::CreatePlane { - self.add_corner(p); - return; + fn press(&mut self, p: [f64; 2], tol: f64, mods: egui::Modifiers) -> Option<&'static str> { + if self.tool == VpTool::Stamp { + return self.stamp_press(p, mods.alt); } let near = |c: [f64; 2]| (c[0] - p[0]).hypot(c[1] - p[1]) <= tol; // The selected plane's nodes win over the others'. let order: Vec = self.selected.into_iter().chain((0..self.planes.len()).rev()).filter(|i| *i < self.planes.len()).collect(); + // Ctrl/Cmd on an edge node tears off a perpendicular plane (with either plane tool). + if mods.command + && let Some((i, e)) = order.iter().find_map(|&i| Some((i, self.edge_nodes(i)?.iter().position(|c| near(*c))?))) + { + self.tear_off(i, e, p); + return None; + } + if self.tool == VpTool::CreatePlane { + self.add_corner(p); + return None; + } for &i in &order { + // A torn-off plane follows its parent: only its far edge node drags (depth, or + // with Alt the angle). + if let Some(t) = self.torn.get(i).copied().flatten() { + if self.edge_nodes(i).and_then(|n| n.get(edge_index(t.edge)).copied()).is_some_and(near) { + self.selected = Some(i); + self.drag = Some(Drag::Torn { plane: i, rotate: mods.alt, start: p, moved: false }); + return None; + } + continue; + } if let Some(ci) = self.planes[i].corners.iter().position(|c| near(*c)) { let c = self.planes[i].corners[ci]; self.selected = Some(i); self.drag = Some(Drag::Corner { plane: i, corner: ci, offset: [c[0] - p[0], c[1] - p[1]] }); - return; + return None; } if let Some(e) = self.edge_nodes(i).and_then(|n| n.iter().position(|c| near(*c))) && let Some(h) = self.planes[i].homography() @@ -190,7 +547,7 @@ impl VpSession { { self.selected = Some(i); self.drag = Some(Drag::Edge { plane: i, edge: e, h, inv }); - return; + return None; } } if let Some(i) = self.paste_plane() @@ -202,19 +559,30 @@ impl VpSession { let (a, b) = (self.paste_at, [self.paste_at[0] + ext[0], self.paste_at[1] + ext[1]]); if (a[0]..=b[0]).contains(&u) && (a[1]..=b[1]).contains(&v) { self.drag = Some(Drag::Paste { offset: [a[0] - u, a[1] - v] }); - return; + return None; } } self.selected = self.scene().and_then(|sc| sc.plane_at(p)); + None } fn drag_to(&mut self, p: [f64; 2]) { - match &self.drag { + match &mut self.drag { Some(Drag::Corner { plane, corner, offset }) => { if let Some(c) = self.planes.get_mut(*plane).and_then(|pl| pl.corners.get_mut(*corner)) { *c = [p[0] + offset[0], p[1] + offset[1]]; } + self.resolve(); } + Some(Drag::Torn { plane, rotate, start, moved }) => { + // A click without a drag leaves the plane as it is. + *moved |= (p[0] - start[0]).hypot(p[1] - start[1]) > 2.0; + if *moved { + let (i, r) = (*plane, *rotate); + self.fit_torn(i, r, p); + } + } + Some(Drag::Stamp) => self.stamp_to(p), Some(Drag::Edge { plane, edge, h, inv }) => { let (u, v) = inv.apply(p[0], p[1]); // The plane's (u, v) rectangle after the move. @@ -229,6 +597,7 @@ impl VpSession { { pl.corners = q; } + self.resolve(); } Some(Drag::Paste { offset }) => { let offset = *offset; @@ -277,6 +646,7 @@ pub fn begin(app: &mut PhotocraftApp, ctx: &egui::Context) -> Result<(), String> None => return Err("no active layer".into()), } let canvas = st.doc.bounds(); + let (base, doc_revision) = (st.doc.clone(), st.revision); let key = app.ui.alloc_id(); let clip = app.session.clipboard.as_ref().and_then(|c| { let r = c.surface.content_bounds(); @@ -290,6 +660,7 @@ pub fn begin(app: &mut PhotocraftApp, ctx: &egui::Context) -> Result<(), String> layer, canvas, planes: Vec::new(), + torn: Vec::new(), tool: VpTool::CreatePlane, pending: Vec::new(), selected: None, @@ -300,13 +671,21 @@ pub fn begin(app: &mut PhotocraftApp, ctx: &egui::Context) -> Result<(), String> new_layer: false, clip, drag: None, + stamp: StampOptions { diameter: 40.0, hardness: 50.0, opacity: 100.0, aligned: true }, + source: None, + strokes: Vec::new(), + aligned_ref: None, + rev: 0, + base, + doc_revision, + preview: None, }); app.ui.status = tl!("Vanishing Point: click four corners to create a plane").into(); Ok(()) } -/// OK: runs `filter.vanishingPoint` with the planes (and the paste). An invalid plane keeps the -/// mode open; with nothing to paste the mode just closes. +/// OK: runs `filter.vanishingPoint` with the planes (and the paste and the clone strokes). An +/// invalid plane keeps the mode open; with nothing to paste or clone the mode just closes. pub fn commit(app: &mut PhotocraftApp) -> Result { let Some(s) = app.distort.vanishing.as_ref() else { return Ok(Value::Null) }; let center = s.center(); @@ -317,7 +696,7 @@ pub fn commit(app: &mut PhotocraftApp) -> Result { } let params = s.params(); app.distort.vanishing = None; - if params.get("paste").is_none() { + if params.get("paste").is_none() && params.get("clone").is_none() { return Ok(json!({"committed": false})); } app.run(VP, params).map(|r| json!({"committed": true, "result": r})) @@ -337,19 +716,39 @@ pub fn control(app: &mut PhotocraftApp, ui: &Value) -> Result { s.tool = match t { "edit" | "editPlane" => VpTool::EditPlane, "create" | "createPlane" => VpTool::CreatePlane, - other => return Err(format!("tool: edit|create, not `{other}`")), + "stamp" => VpTool::Stamp, + other => return Err(format!("tool: edit|create|stamp, not `{other}`")), }; s.pending.clear(); } if let Some(p) = ui.get("planes") { - let planes: Vec = serde_json::from_value(p.clone()).map_err(|e| format!("bad planes: {e}"))?; - if planes.len() > MAX_PLANES { - return Err(format!("at most {MAX_PLANES} planes")); - } + let (planes, torn) = parse_planes(p)?; s.planes = planes; + s.torn = torn; // A drag holds indices into the old list. s.drag = None; s.selected = (!s.planes.is_empty()).then(|| s.planes.len() - 1); + s.resolve(); + } + if let Some(o) = ui.get("stamp") { + let num = |k: &str, lo: f64, hi: f64| o.get(k).and_then(Value::as_f64).filter(|v| v.is_finite()).map(|v| v.clamp(lo, hi)); + let st = &mut s.stamp; + st.diameter = num("diameter", 1.0, 2000.0).unwrap_or(st.diameter); + st.hardness = num("hardness", 0.0, 100.0).unwrap_or(st.hardness); + st.opacity = num("opacity", 0.0, 100.0).unwrap_or(st.opacity); + st.aligned = o.get("aligned").and_then(Value::as_bool).unwrap_or(st.aligned); + } + if let Some(src) = ui.get("source") { + s.source = match src { + Value::Null => None, + v => Some(pt(v).ok_or("source: [x, y]")?), + }; + s.aligned_ref = None; + } + if let Some(c) = ui.get("clone") { + s.strokes = photocraft_engine::vp_cmds::clone_specs(&json!({"clone": c})).map_err(|e| e.to_string())?; + s.drag = None; + s.rev += 1; } if let Some(i) = ui.get("select").and_then(Value::as_u64) { s.selected = usize::try_from(i).ok().filter(|i| *i < s.planes.len()); @@ -369,20 +768,96 @@ pub fn control(app: &mut PhotocraftApp, ui: &Value) -> Result { if let Some(b) = ui.get("newLayer").and_then(Value::as_bool) { s.new_layer = b; } - Ok(s.describe()) + sync_preview(app); + Ok(app.distort.vanishing.as_ref().map(VpSession::describe).unwrap_or(Value::Null)) } -pub fn pointer(app: &mut PhotocraftApp, ev: ToolEvent, _mods: egui::Modifiers) { +fn pt(v: &Value) -> Option<[f64; 2]> { + let p = [v.get(0)?.as_f64()?, v.get(1)?.as_f64()?]; + p.iter().all(|x| x.is_finite() && x.abs() < 1e7).then_some(p) +} + +/// The control channel's planes, in the command's form: `{"corners": [[x, y]×4]}` or +/// `{"from": earlier plane, "edge", "angle": 90, "depth": 1}`. +fn parse_planes(v: &Value) -> Result<(Vec, Vec>), String> { + let list = v.as_array().ok_or("planes: a list")?; + if list.len() > MAX_PLANES { + return Err(format!("at most {MAX_PLANES} planes")); + } + let (mut planes, mut torn) = (Vec::new(), Vec::new()); + for (i, p) in list.iter().enumerate() { + if let Some(c) = p.get("corners") { + let c = c.as_array().filter(|c| c.len() == 4).ok_or(format!("plane {i}: four corners"))?; + let corners = [0, 1, 2, 3].map(|k| c.get(k).and_then(pt)); + let [Some(a), Some(b), Some(c), Some(d)] = corners else { return Err(format!("plane {i}: corners are [x, y]")) }; + planes.push(VpPlane { corners: [a, b, c, d] }); + torn.push(None); + continue; + } + let from = p + .get("from") + .and_then(Value::as_u64) + .and_then(|f| usize::try_from(f).ok()) + .filter(|f| *f < i) + .ok_or(format!("plane {i}: `corners` or `from` (an earlier plane)"))?; + let edge = match p.get("edge").and_then(Value::as_str).unwrap_or("top") { + "top" => Edge::Top, + "right" => Edge::Right, + "bottom" => Edge::Bottom, + "left" => Edge::Left, + e => return Err(format!("plane {i}: unknown edge `{e}`")), + }; + let angle = p.get("angle").and_then(Value::as_f64).unwrap_or(90.0); + let depth = p.get("depth").and_then(Value::as_f64).unwrap_or(1.0); + if !(0.0..=360.0).contains(&angle) || !(depth > 0.0 && depth <= 1000.0) { + return Err(format!("plane {i}: angle 0..360, depth above 0 and at most 1000")); + } + planes.push(VpPlane { corners: [[0.0; 2]; 4] }); + torn.push(Some(Torn { from, edge, angle, depth })); + } + Ok((planes, torn)) +} + +/// Brings the stamp preview up to date with the strokes (and repaints it after the planes +/// changed, once no plane is being dragged). +pub(crate) fn sync_preview(app: &mut PhotocraftApp) { + let Some(s) = app.distort.vanishing.as_mut() else { return }; + if matches!(s.drag, Some(Drag::Corner { .. } | Drag::Edge { .. } | Drag::Torn { .. })) { + return; + } + let ui = &mut app.ui; + s.paint_preview(|| ui.alloc_id()); +} + +/// What changed between stamp preview (or document) key `seen` and `now` of document `doc` at +/// `revision`: the areas the strokes painted. `None` when either key isn't the session's. +pub(crate) fn damage(app: &PhotocraftApp, doc: DocId, revision: u64, seen: u64, now: u64) -> Option { + let s = app.distort.vanishing.as_ref().filter(|s| s.base.id == doc && s.doc_revision == revision)?; + let keys = &s.preview.as_ref()?.keys; + let at = |k: u64| if k == 0 { Some(0) } else { keys.iter().position(|e| PREVIEW_KEY + e.0 == k).map(|i| i + 1) }; + let (a, b) = (at(seen)?, at(now)?); + if a == b { + return None; + } + Some(keys.get(a.min(b)..a.max(b))?.iter().fold(Rect::EMPTY, |r, k| union(r, k.1))) +} + +pub fn pointer(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers) { let tol = crate::distort_ui::tolerance(app); let Some(s) = app.distort.vanishing.as_mut() else { return }; match ev { - ToolEvent::Down { x, y, .. } => s.press([x, y], tol), + ToolEvent::Down { x, y, .. } => { + if let Some(msg) = s.press([x, y], tol, mods) { + app.ui.status = msg.into(); + } + } ToolEvent::Move { x, y, .. } => s.drag_to([x, y]), ToolEvent::Up { x, y } => { s.drag_to([x, y]); s.drag = None; } } + sync_preview(app); } /// Keys while the mode is active (↩ and Esc are handled by `distort_ui::keys`). @@ -398,9 +873,17 @@ pub fn keys(app: &mut PhotocraftApp, ctx: &egui::Context) { s.pending.clear(); } else if key(Key::C) { s.tool = VpTool::CreatePlane; + } else if key(Key::S) { + s.tool = VpTool::Stamp; + s.pending.clear(); } else if key(Key::Delete) || key(Key::Backspace) { s.delete_selected(); + } else if ctx.input_mut(|i| i.consume_key(Modifiers::COMMAND, Key::Z)) && s.strokes.pop().is_some() { + // Undo inside the window: the last clone stroke. + s.drag = None; + s.rev += 1; } + sync_preview(app); } /// Esc: drops a half-clicked plane first, then leaves the mode. @@ -469,6 +952,50 @@ pub fn draw(s: &VpSession, painter: &egui::Painter, xf: &ViewXform) { painter.rect_filled(egui::Rect::from_center_size(*c, egui::vec2(6.0, 6.0)), 0.0, tokens.accent); } } + if s.tool == VpTool::Stamp { + draw_stamp(s, painter, xf, &scr); + } +} + +/// Stamp: the source as a crosshair and the brush under the pointer as the circle it paints on +/// the plane, foreshortened. +fn draw_stamp(s: &VpSession, painter: &egui::Painter, xf: &ViewXform, scr: &dyn Fn([f64; 2]) -> Pos2) { + let outline = |pts: &[Pos2]| { + painter.add(egui::Shape::closed_line(pts.to_vec(), Stroke::new(2.5, Color32::from_black_alpha(160)))); + painter.add(egui::Shape::closed_line(pts.to_vec(), Stroke::new(1.0, Color32::WHITE))); + }; + if let Some(src) = s.source { + let c = scr(src); + for (a, b) in [(egui::vec2(-7.0, 0.0), egui::vec2(7.0, 0.0)), (egui::vec2(0.0, -7.0), egui::vec2(0.0, 7.0))] { + painter.line_segment([c + a, c + b], Stroke::new(2.5, Color32::from_black_alpha(160))); + painter.line_segment([c + a, c + b], Stroke::new(1.0, Color32::WHITE)); + } + } + let Some(hover) = painter.ctx().pointer_hover_pos() else { return }; + let p = xf.to_doc(hover); + let Some(sc) = s.scene() else { return }; + let Some(i) = sc.plane_at(p) else { return }; + let Some((h, lu, lv)) = s.frame(i) else { return }; + let Some(inv) = h.inverse() else { return }; + let metric = |q: [f64; 2]| { + let (u, v) = inv.apply(q[0], q[1]); + [u * lu, v * lv] + }; + let (m, probe) = (metric(p), metric([p[0] + s.stamp.diameter / 2.0, p[1]])); + let r = (probe[0] - m[0]).hypot(probe[1] - m[1]); + if !r.is_finite() || r <= 0.0 { + return; + } + let ring: Vec = (0..48) + .map(|k| { + let a = f64::from(k) / 48.0 * std::f64::consts::TAU; + let (x, y) = h.apply((m[0] + r * a.cos()) / lu, (m[1] + r * a.sin()) / lv); + scr([x, y]) + }) + .collect(); + if ring.iter().all(|q| q.is_finite()) { + outline(&ring); + } } /// Plane coordinates (0..1, exclusive) of the grid lines across `u` (or `v`) for cells of @@ -515,6 +1042,8 @@ fn draw_paste(painter: &egui::Painter, scr: &dyn Fn([f64; 2]) -> Pos2, h: &Homog } pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { + // New Layer toggled last frame repaints the stamp preview. + sync_preview(app); let Some(s) = app.distort.vanishing.as_mut() else { return }; if crate::widgets::pill_tab(ui, tl!("Edit Plane"), s.tool == VpTool::EditPlane).on_hover_text("V").clicked() { s.tool = VpTool::EditPlane; @@ -523,7 +1052,27 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { if crate::widgets::pill_tab(ui, tl!("Create Plane"), s.tool == VpTool::CreatePlane).on_hover_text("C").clicked() { s.tool = VpTool::CreatePlane; } + if crate::widgets::pill_tab(ui, tl!("Stamp"), s.tool == VpTool::Stamp).on_hover_text("S").clicked() { + s.tool = VpTool::Stamp; + s.pending.clear(); + } crate::widgets::vline(ui, 22.0); + if s.tool == VpTool::Stamp { + let st = &mut s.stamp; + for (label, value, range, unit) in [ + (tl!("Diameter:"), &mut st.diameter, 1.0..=2000.0, "px"), + (tl!("Hardness:"), &mut st.hardness, 0.0..=100.0, "%"), + (tl!("Opacity:"), &mut st.opacity, 0.0..=100.0, "%"), + ] { + ui.label(label); + let mut v = *value as f32; + if crate::widgets::value_field(ui, &mut v, range, unit, 56.0).changed() { + *value = f64::from(v); + } + } + crate::widgets::checkbox(ui, &mut st.aligned, tl!("Aligned")); + crate::widgets::vline(ui, 22.0); + } ui.label(tl!("Grid Size:")); let mut g = s.grid_size as f32; if crate::widgets::value_field(ui, &mut g, 2.0..=2000.0, "px", 56.0).changed() { @@ -539,6 +1088,8 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { s.paste_width = f64::from(w) / 100.0; } } + } + if s.clip.is_some() || !s.strokes.is_empty() || s.tool == VpTool::Stamp { crate::widgets::checkbox(ui, &mut s.new_layer, tl!("New Layer")); } ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { @@ -608,4 +1159,70 @@ mod tests { assert!(l.rgba(x as i32, y as i32)[0] > 0.9, "{:?}", l.rgba(x as i32, y as i32)); assert!(l.rgba(230, 20)[0] < 0.5, "outside the plane"); } + + #[test] + fn ctrl_drag_tears_off_a_wall_and_the_stamp_clones_in_one_step() { + let (ctx, mut app) = app_with_layer(); + // A green mark near the floor's front edge to clone. + app.session.execute("select.rect", json!({"x": 100, "y": 135, "width": 40, "height": 8})).unwrap(); + app.session.execute("edit.fill", json!({"color": "#00ff00"})).unwrap(); + app.session.execute("select.deselect", json!({})).unwrap(); + crate::distort_ui::menu(&mut app, &ctx, VP, &json!({})).unwrap().unwrap(); + control(&mut app, &json!({"planes": [{"corners": [[70, 60], [170, 60], [220, 150], [20, 150]]}]})).unwrap(); + let ev = |app: &mut PhotocraftApp, e: ToolEvent, m: egui::Modifiers| crate::distort_ui::pointer(app, e, m); + let drag = |app: &mut PhotocraftApp, a: [f64; 2], b: [f64; 2], m: egui::Modifiers| { + ev(app, ToolEvent::Down { x: a[0], y: a[1], pressure: 1.0 }, m); + ev(app, ToolEvent::Move { x: (a[0] + b[0]) / 2.0, y: (a[1] + b[1]) / 2.0, pressure: 1.0 }, m); + ev(app, ToolEvent::Up { x: b[0], y: b[1] }, m); + }; + fn vp(app: &PhotocraftApp) -> &VpSession { + app.distort.vanishing.as_ref().unwrap() + } + + // Ctrl/Cmd-drag the top edge node up: a wall torn off the floor's far edge, 90° to it. + let top = vp(&app).edge_nodes(0).unwrap()[0]; + drag(&mut app, top, [top[0], top[1] - 35.0], egui::Modifiers::COMMAND); + let s = vp(&app); + assert_eq!(s.planes.len(), 2); + let t = s.torn[1].unwrap(); + assert_eq!((t.from, t.edge, t.angle), (0, Edge::Top, 90.0)); + let c = s.planes[1].corners; + assert!((c[0][1] + c[1][1]) / 2.0 < 40.0, "the far edge followed the pointer up: {c:?}"); + assert_ne!(s.describe()["planes"][1]["check"], "invalid"); + assert_eq!(s.params()["planes"][1], json!({"from": 0, "edge": "top", "angle": 90.0, "depth": t.depth})); + // Alt-dragging its far edge node turns it; editing the floor carries it along. + let far = s.edge_nodes(1).unwrap()[0]; + drag(&mut app, far, [far[0], far[1] + 12.0], egui::Modifiers::ALT); + assert_ne!(vp(&app).torn[1].unwrap().angle, 90.0); + let before = vp(&app).planes[1].corners; + drag(&mut app, [220.0, 150.0], [228.0, 150.0], egui::Modifiers::NONE); + assert_ne!(vp(&app).planes[1].corners, before); + assert!(vp(&app).torn[1].is_some()); + + // Stamp: painting needs a source first; Alt-click sets it on the floor's green mark. + control(&mut app, &json!({"tool": "stamp", "stamp": {"diameter": 12, "hardness": 80}})).unwrap(); + drag(&mut app, [120.0, 100.0], [120.0, 100.0], egui::Modifiers::NONE); + assert!(vp(&app).strokes.is_empty() && app.ui.status.contains("Alt-click"), "{}", app.ui.status); + drag(&mut app, [120.0, 139.0], [120.0, 139.0], egui::Modifiers::ALT); + assert_eq!(vp(&app).source, Some([120.0, 139.0])); + drag(&mut app, [118.0, 100.0], [126.0, 100.0], egui::Modifiers::NONE); + assert_eq!(vp(&app).strokes.len(), 1); + assert!(vp(&app).strokes[0].points.len() >= 3, "dabs along the drag"); + // The canvas shows the stroke; the document is untouched until OK. + let layer = app.session.active().unwrap().active_layer.unwrap(); + let green = |d: &Document| d.layer(layer).unwrap().surface().unwrap().rgba(122, 100)[1]; + let (shown, key) = crate::distort_ui::display_doc(&app, 0).expect("a stamp preview"); + assert!(green(&shown) > 0.8, "{}", green(&shown)); + let st = app.session.active().unwrap(); + assert!(green(&st.doc) < 0.6); + let area = damage(&app, st.doc.id, st.revision, 0, key).unwrap(); + assert!(area.contains(122, 100) && !area.contains(20, 20), "only the stroke recomposites: {area:?}"); + + let before = app.session.active().unwrap().history.past_len(); + let r = commit(&mut app).unwrap(); + assert_eq!(r["committed"], true, "{r}"); + let st = app.session.active().unwrap(); + assert_eq!(st.history.past_len(), before + 1, "one history step for the whole session"); + assert!(green(&st.doc) > 0.8, "{}", green(&st.doc)); + } } diff --git a/docs/scorecard.md b/docs/scorecard.md index aad562e6c8..270a865d40 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -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, 15 not run, 7 not measurable yet (baseline 2026-10-05) | | [File compatibility](#file-compatibility) | 5 | 11 | 11 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 | -| [Tools](#tools) | 21 | 16 | 5 | | +| [Tools](#tools) | 22 | 15 | 5 | | | [Workspace and UI](#workspace-and-ui) | 6 | 7 | 10 | settings that do nothing: 43 of 150 (target 0) | | [Type](#type) | 0 | 3 | 6 | | | [Automation](#automation) | 3 | 2 | 6 | 630 of 630 menu items live (100.0%) | @@ -158,7 +158,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t | TOOL-214-11 | Stroke Path dialog: pick any brush-based tool, Simulate Pressure | partial | [#214](https://github.com/storytold/photocraft/issues/214) | path.stroke brush, pencil, eraser (vector_cmds.rs:1170); brush-only button, no dialog | | TOOL-214-12 | Shapes: on-canvas corner radius handles, shape feather, selection to shape with tolerance | partial | [#214](https://github.com/storytold/photocraft/issues/214) | select.convertToShape with tolerance (vector_cmds.rs:1256); radius as a field only | | TOOL-214-13 | Mask Properties: Density and Feather controls | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Vector-mask density/feather in the engine (vector_cmds.rs:948); no UI controls | -| TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | partial | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15); on-canvas plane editor (vp_ui.rs: Create/Edit Plane, edge nodes, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane on OK); clone stamp, marquee and tear-off planes in the window still missing | +| TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | done | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15); on-canvas window (vp_ui.rs: Create/Edit Plane, edge nodes, Ctrl/Cmd-drag tear-off planes with depth and Alt-drag angle, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane, Stamp tool cloning in perspective with live preview, all applied on OK as one step); the window's Marquee tool and the Stamp's Heal modes are still missing | | TOOL-214-15 | Content-Aware Fill workspace: paint the sampling area, preview, rotate/scale/mirror, new layer | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Engine sampling auto, rect, custom (edit_menu_cmds.rs:324); generic dialog | | TOOL-214-16 | Liquify: redo (Cmd+Shift+Z) | done | [#214](https://github.com/storytold/photocraft/issues/214) | liquify_ui.rs supports bounded redo through Cmd+Shift+Z and the control channel; new strokes clear redo | | TOOL-213-17 | Red Eye tool: click a pupil to neutralize the red reflection | done | [#213](https://github.com/storytold/photocraft/issues/213) | paint.redEye (redeye_cmds.rs) + Tool::RedEye in the J flyout; Pupil Size and Darken Amount; catchlights kept; a miss is an error | diff --git a/scorecard/tools.toml b/scorecard/tools.toml index cefb18e599..c346038427 100644 --- a/scorecard/tools.toml +++ b/scorecard/tools.toml @@ -204,9 +204,9 @@ note = "Vector-mask density/feather in the engine (vector_cmds.rs:948); no UI co [[item]] id = "TOOL-214-14" target = "Vanishing Point window: draw and edit planes, paste, clone in perspective" -status = "partial" +status = "done" issue = 214 -note = "filter.vanishingPoint (vp_cmds.rs:15); on-canvas plane editor (vp_ui.rs: Create/Edit Plane, edge nodes, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane on OK); clone stamp, marquee and tear-off planes in the window still missing" +note = "filter.vanishingPoint (vp_cmds.rs:15); on-canvas window (vp_ui.rs: Create/Edit Plane, edge nodes, Ctrl/Cmd-drag tear-off planes with depth and Alt-drag angle, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane, Stamp tool cloning in perspective with live preview, all applied on OK as one step); the window's Marquee tool and the Stamp's Heal modes are still missing" [[item]] id = "TOOL-214-15" From 2c9fdb56e8a7546379f2233edb8273cf2110b3f8 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 11 Oct 2026 09:25:09 +0200 Subject: [PATCH 014/649] Smart Filters: paint the filter mask directly, with undo (#3290) Clicking the filter mask thumbnail on a smart object's Smart Filters row targets the filter mask. Painting, fills, filters and adjustments then edit it through a new "target":"filterMask". The first stroke starts a white mask, black hides the smart filters, and each stroke is one undo step that re-renders the smart object. Alt-click shows the mask alone (view.layerMask "mask":"filter") and Shift-click disables it. The thumbnail draws the mask itself. ui.set takes filterMaskTarget. The painted mask is kept through .pcraft and PSD (FEid). Scorecard FILE-215-3 is done. Co-Authored-By: Claude Opus 5.5 --- crates/automation/src/server.rs | 2 +- crates/engine/src/brush_cmds.rs | 2 +- crates/engine/src/channel_cmds.rs | 26 +++- crates/engine/src/commands.rs | 18 +-- crates/engine/src/fill_key_cmds.rs | 2 +- crates/engine/src/float_cmds.rs | 2 +- crates/engine/src/jobs.rs | 8 +- crates/engine/src/lib.rs | 7 ++ crates/engine/src/mask_view_cmds.rs | 44 +++++-- crates/engine/src/paint_cmds.rs | 4 +- crates/engine/src/redeye_cmds.rs | 2 +- crates/engine/src/retouch_cmds.rs | 6 +- crates/engine/src/smart_cmds.rs | 34 +++++ crates/engine/src/smart_cmds/tests.rs | 1 + .../src/smart_cmds/tests/filter_mask_paint.rs | 79 ++++++++++++ crates/engine/src/transform_cmds.rs | 2 + crates/ui-egui/src/canvas.rs | 6 +- crates/ui-egui/src/control.rs | 15 ++- crates/ui-egui/src/lib.rs | 46 +++++-- crates/ui-egui/src/mask_thumbs_ui/tests.rs | 1 + crates/ui-egui/src/panels.rs | 14 ++- crates/ui-egui/src/smart_ui.rs | 118 +++++++++++++++++- crates/ui-egui/src/state.rs | 6 + docs/control-protocol.md | 2 +- docs/scorecard.md | 4 +- scorecard/file_compat.toml | 4 +- 26 files changed, 406 insertions(+), 49 deletions(-) create mode 100644 crates/engine/src/smart_cmds/tests/filter_mask_paint.rs diff --git a/crates/automation/src/server.rs b/crates/automation/src/server.rs index 74a4c623f4..104bb31115 100644 --- a/crates/automation/src/server.rs +++ b/crates/automation/src/server.rs @@ -228,7 +228,7 @@ pub struct MenuParams { pub struct UiSetParams { /// Fields for the control method `ui.set`: tool, panels, dock, dockTabs, dockWidth, colorPanel /// ({background: bool} picks which swatch the Color panel edits), maskTarget, - /// vectorMaskTarget, selectionMode, zoom, center, rotation (view angle in degrees), fit, theme (pro, proMedium, studio, + /// vectorMaskTarget, filterMaskTarget (paint the active smart object's filter mask), selectionMode, zoom, center, rotation (view angle in degrees), fit, theme (pro, proMedium, studio, /// studioLight, classic, solarizedDark, adwaita, adwaitaDark, breezeLight, breezeDark), brushSection, brushTab, /// brushesView, brushPicker ([x, y] opens the Brush Preset picker there, null closes it), /// brushPickerName, brushPickerStroke, brushPickerTip (the picker card's parts, at least one diff --git a/crates/engine/src/brush_cmds.rs b/crates/engine/src/brush_cmds.rs index 473edbaf02..8b21d867e6 100644 --- a/crates/engine/src/brush_cmds.rs +++ b/crates/engine/src/brush_cmds.rs @@ -984,7 +984,7 @@ pub fn specs() -> Vec { spec!( "paint.pencil", "Pencil", - r##"{"points":[[x,y,pressure?,tiltX?,tiltY?,rotation?,timeMs?,wheel?],…],"brush":{…}?,"preset":name?,"size":0.5..5000 px?,"opacity":0..1?,"color":"#rrggbb"?=foreground,"mode":"normal|multiply|screen|…"="normal","erase":bool?,"block":bool=false (a hard 16×16 screen-px square, 16/zoom doc px; size, opacity, flow, hardness and dynamics ignored: the Eraser's Block mode),"zoom":view zoom=1,"autoErase":bool=false,"seed":u64?,"target":"pixels"|"mask"|"quickMask"|{"channel":i}=Channels panel target}"##, + r##"{"points":[[x,y,pressure?,tiltX?,tiltY?,rotation?,timeMs?,wheel?],…],"brush":{…}?,"preset":name?,"size":0.5..5000 px?,"opacity":0..1?,"color":"#rrggbb"?=foreground,"mode":"normal|multiply|screen|…"="normal","erase":bool?,"block":bool=false (a hard 16×16 screen-px square, 16/zoom doc px; size, opacity, flow, hardness and dynamics ignored: the Eraser's Block mode),"zoom":view zoom=1,"autoErase":bool=false,"seed":u64?,"target":"pixels"|"mask"|"filterMask"|"quickMask"|{"channel":i}=Channels panel target}"##, has_paintable, pencil, true diff --git a/crates/engine/src/channel_cmds.rs b/crates/engine/src/channel_cmds.rs index 321d0d1a6e..ef9d48c937 100644 --- a/crates/engine/src/channel_cmds.rs +++ b/crates/engine/src/channel_cmds.rs @@ -90,7 +90,7 @@ impl ChannelView { /// The layer mask shown on the canvas (#196) and how, if its layer still has a mask. pub fn shown_layer_mask<'a>(&self, doc: &'a Document) -> Option<(&'a photocraft_doc::LayerMask, crate::mask_view_cmds::MaskViewMode)> { let v = self.layer_mask?; - Some((doc.layer(v.layer)?.mask.as_ref()?, v.mode)) + Some((crate::mask_view_cmds::viewed_mask(doc.layer(v.layer)?, v.filter)?, v.mode)) } } @@ -483,6 +483,9 @@ fn mask_plane(s: &Session, p: &Value, cmd: &str) -> Result>> { pub(crate) enum Target { Pixels, Mask, + /// A smart object's filter mask (`"target":"filterMask"`): where it is black the smart + /// filters don't show (FILE-215-3). + FilterMask, Alpha(usize), QuickMask, } @@ -491,6 +494,7 @@ pub(crate) fn target_of(p: &Value) -> Target { match p.get("target") { Some(Value::String(s)) => match s.as_str() { "mask" => Target::Mask, + "filterMask" => Target::FilterMask, "quickMask" => Target::QuickMask, _ => Target::Pixels, }, @@ -547,10 +551,14 @@ fn edits_mask(id: &str) -> bool { /// The precondition of `id` when `p` targets the active layer's mask (`"target":"mask"`): the /// layer needs a mask. None when another precondition applies. pub(crate) fn mask_target_enabled(s: &Session, id: &str, p: &Value) -> Option> { - if target_of(p) != Target::Mask || !edits_mask(id) { - return None; + match target_of(p) { + // Every pixel command that follows the target paints, fills or filters the filter mask. + Target::FilterMask if routed(id) => Some(crate::active_layer_of(s).and_then(crate::smart_cmds::filter_mask_paintable)), + Target::Mask if edits_mask(id) => { + Some(crate::active_layer_of(s).and_then(|l| if l.mask.is_some() { Ok(()) } else { Err("the active layer has no layer mask".into()) })) + } + _ => None, } - Some(crate::active_layer_of(s).and_then(|l| if l.mask.is_some() { Ok(()) } else { Err("the active layer has no layer mask".into()) })) } /// Whether command `id` edits the targeted channel or mask when its params name no `"target"` @@ -597,6 +605,7 @@ pub(crate) fn inject_target(s: &Session, id: &str, params: Value) -> Value { ChannelTarget::Alpha(i) if i < st.doc.channels.len() => json!({ "channel": i }), ChannelTarget::Composite if st.doc.quick_mask.is_some() => json!("quickMask"), // Viewing the active layer's mask (⌥-click): pixel commands edit the mask. + ChannelTarget::Composite if crate::mask_view_cmds::current(st).is_some_and(|v| v.filter) => json!("filterMask"), ChannelTarget::Composite if crate::mask_view_cmds::current(st).is_some() => json!("mask"), _ => return params, }; @@ -609,6 +618,15 @@ pub(crate) fn inject_target(s: &Session, id: &str, params: Value) -> Value { } } +/// The smart object whose filter mask a command with `params` edits (`"target":"filterMask"`): +/// its `"layer"` param, else the active layer. +pub(crate) fn filter_mask_layer(s: &Session, params: &Value) -> Option { + if target_of(params) != Target::FilterMask { + return None; + } + params.get("layer").and_then(Value::as_u64).map(LayerId).or_else(|| s.active()?.active_layer) +} + /// The colour channel pixel commands are limited to, if a single colour channel is targeted. pub(crate) fn color_restriction(s: &Session, id: &str, params: &Value) -> Option { if !routed(id) || is_channel_target(params) || crate::commands::is_mask_target(params) { diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs index df6671f455..dcad3f153d 100644 --- a/crates/engine/src/commands.rs +++ b/crates/engine/src/commands.rs @@ -65,11 +65,15 @@ pub(crate) fn has_paintable(s: &Session) -> std::result::Result<(), String> { } } -/// Surface a paint command writes to: the layer's pixels, or its mask with `"target":"mask"`. +/// Surface a paint command writes to: the layer's pixels, its mask with `"target":"mask"`, or a +/// smart object's filter mask with `"target":"filterMask"`. pub(crate) fn paint_surface<'a>(doc: &'a mut Document, id: LayerId, p: &Value) -> Result<&'a mut photocraft_raster::Surface> { if !is_mask_target(p) { check_pixels_unlocked(doc, id)?; } + if crate::channel_cmds::target_of(p) == crate::channel_cmds::Target::FilterMask { + return crate::smart_cmds::filter_mask_surface(doc, id); + } let l = doc.layer_mut(id).ok_or(EngineError::NoLayer(id))?; if is_mask_target(p) { l.mask.as_mut().map(|m| &mut m.surface).ok_or_else(|| EngineError::Other("layer has no mask".into())) @@ -88,8 +92,10 @@ pub(crate) fn check_pixels_unlocked(doc: &Document, id: LayerId) -> Result<()> { Ok(()) } +/// The params target a grayscale mask of the layer: its layer mask (`"mask"`) or, on a smart +/// object, its filter mask (`"filterMask"`). pub(crate) fn is_mask_target(p: &Value) -> bool { - p.get("target").and_then(Value::as_str) == Some("mask") + matches!(p.get("target").and_then(Value::as_str), Some("mask" | "filterMask")) } fn can_undo(s: &Session) -> std::result::Result<(), String> { @@ -289,9 +295,7 @@ fn destructive_adjust(s: &mut Session, label: &str, adj: Adjustment, p: &Value) let id = layer_param(s, &Value::Null)?; return s.edit(label, |doc, _| { let sel = doc.selection.clone(); - let l = doc.layer_mut(id).ok_or(EngineError::NoLayer(id))?; - let mask = l.mask.as_mut().ok_or_else(|| EngineError::Other("layer has no mask".into()))?; - pixels::adjust_mask(&mut mask.surface, &adj, sel.as_ref()); + pixels::adjust_mask(paint_surface(doc, id, p)?, &adj, sel.as_ref()); Ok(Value::Null) }); } @@ -393,7 +397,7 @@ fn build() -> Vec { "Fill…", ["Edit"], Some("Shift+F5"), - r##"{"contents":"foreground|background|color|contentAware|pattern|history|black|gray|white"="color","color":"#rrggbb|[r,g,b,a]"=foreground (contents=color),"pattern":id|name (contents=pattern),"scale":%=100,"angle":deg,"state":index? (contents=history; default the oldest state),"colorAdaptation":bool=true (contents=contentAware),"mode":"normal|multiply|…"="normal","opacity":0..100=100,"preserveTransparency":bool=false,"target":"pixels"|"mask"|"quickMask"|{"channel":i}?}"##, + r##"{"contents":"foreground|background|color|contentAware|pattern|history|black|gray|white"="color","color":"#rrggbb|[r,g,b,a]"=foreground (contents=color),"pattern":id|name (contents=pattern),"scale":%=100,"angle":deg,"state":index? (contents=history; default the oldest state),"colorAdaptation":bool=true (contents=contentAware),"mode":"normal|multiply|…"="normal","opacity":0..100=100,"preserveTransparency":bool=false,"target":"pixels"|"mask"|"filterMask"|"quickMask"|{"channel":i}?}"##, has_pixel_or_channel, crate::fill_cmds::fill ), @@ -887,7 +891,7 @@ fn build() -> Vec { "Brush Stroke", [], None, - r##"{"points":[[x,y,pressure?,tiltX?,tiltY?,rotation?,timeMs?,wheel?],…],"brush":{…BrushSettings}?,"preset":name?,"size":0.5..5000 px?,"hardness":0..1?,"opacity":0..1?,"flow":0..1?,"spacing":0..10?,"color":"#rrggbb"?=foreground,"mode":"normal|multiply|screen|…"="normal","erase":bool?,"smoothing":0..1?,"zoom":number=1,"seed":u64?,"target":"pixels"|"mask"|"quickMask"|{"channel":i}=Channels panel target}"##, + r##"{"points":[[x,y,pressure?,tiltX?,tiltY?,rotation?,timeMs?,wheel?],…],"brush":{…BrushSettings}?,"preset":name?,"size":0.5..5000 px?,"hardness":0..1?,"opacity":0..1?,"flow":0..1?,"spacing":0..10?,"color":"#rrggbb"?=foreground,"mode":"normal|multiply|screen|…"="normal","erase":bool?,"smoothing":0..1?,"zoom":number=1,"seed":u64?,"target":"pixels"|"mask"|"filterMask"|"quickMask"|{"channel":i}=Channels panel target}"##, has_paintable, crate::brush_cmds::paint_stroke ), diff --git a/crates/engine/src/fill_key_cmds.rs b/crates/engine/src/fill_key_cmds.rs index 6235b629bb..f721a16e09 100644 --- a/crates/engine/src/fill_key_cmds.rs +++ b/crates/engine/src/fill_key_cmds.rs @@ -14,7 +14,7 @@ use crate::{EngineError, Result, Session}; /// The fill-key command ids (routed to the Channels panel target like `edit.fill`). pub const IDS: [&str; 4] = ["edit.fillForeground", "edit.fillBackground", "edit.fillForegroundPreserve", "edit.fillBackgroundPreserve"]; -const PARAMS: &str = r##"{"layer":id?,"target":"pixels"|"mask"|"quickMask"|{"channel":i}?}"##; +const PARAMS: &str = r##"{"layer":id?,"target":"pixels"|"mask"|"filterMask"|"quickMask"|{"channel":i}?}"##; fn enabled(s: &Session) -> std::result::Result<(), String> { let edit_fill = crate::commands::find("edit.fill").ok_or_else(|| "Fill is unavailable".to_string())?; diff --git a/crates/engine/src/float_cmds.rs b/crates/engine/src/float_cmds.rs index 892f754748..3cd81acab9 100644 --- a/crates/engine/src/float_cmds.rs +++ b/crates/engine/src/float_cmds.rs @@ -175,7 +175,7 @@ fn float(s: &mut Session, p: &Value) -> Result { let st = s.active_mut().ok_or(EngineError::NoDocument)?; if floating(st).is_none() { let layer = st.active_layer.ok_or_else(|| EngineError::Other("no active layer".into()))?; - let parts = CutParts::new(&st.doc, layer, copy, background, crate::commands::is_mask_target(p))?; + let parts = CutParts::new(&st.doc, layer, copy, background, crate::channel_cmds::target_of(p) == crate::channel_cmds::Target::Mask)?; st.floating = Some(Floating { layer, offset: (0, 0), revision: st.revision, parts: Arc::new(parts) }); } let f = st.floating.as_mut().ok_or(EngineError::NoDocument)?; diff --git a/crates/engine/src/jobs.rs b/crates/engine/src/jobs.rs index 9b612e3c4c..7892902232 100644 --- a/crates/engine/src/jobs.rs +++ b/crates/engine/src/jobs.rs @@ -182,6 +182,7 @@ struct Running { started_ms: f64, coalesce: Option, color_restrict: Option, + filter_mask_layer: Option, rx: std::sync::mpsc::Receiver>, apply: Option, #[cfg(not(target_arch = "wasm32"))] @@ -335,6 +336,7 @@ pub fn run( started_ms: now_ms(), coalesce: s.coalesce_request.clone(), color_restrict: s.color_restrict, + filter_mask_layer: s.filter_mask_layer, rx, apply: Some(erased), #[cfg(not(target_arch = "wasm32"))] @@ -637,6 +639,7 @@ impl Session { } self.coalesce_request = params.get("coalesce").and_then(Value::as_str).map(str::to_string); self.color_restrict = crate::channel_cmds::color_restriction(self, id, &run_params); + self.filter_mask_layer = crate::channel_cmds::filter_mask_layer(self, &run_params); self.jobs.spawn = background; // Last-resort guard (AGENTS.md, Never crash): a command that panics anyway fails with an // error instead of taking the app down. `edit` only commits a document after its closure @@ -646,6 +649,7 @@ impl Session { self.jobs.spawn = false; self.coalesce_request = None; self.color_restrict = None; + self.filter_mask_layer = None; let pending = self.jobs.pending.take(); match (r, pending) { (Err(e), Some(job)) => { @@ -699,7 +703,7 @@ impl Session { } fn apply_job(&mut self, job: &Running, apply: Option, payload: Payload) -> Result { - let Running { label, doc, snapshot, coalesce, color_restrict, command, params, journal, .. } = job; + let Running { label, doc, snapshot, coalesce, color_restrict, filter_mask_layer, command, params, journal, .. } = job; let prev_active = self.active; let target = match doc { Some(d) => { @@ -716,6 +720,7 @@ impl Session { }; self.coalesce_request = coalesce.clone(); self.color_restrict = *color_restrict; + self.filter_mask_layer = *filter_mask_layer; let r = match apply { Some(f) => std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| f(self, payload))) .unwrap_or_else(|_| Err(EngineError::Other(format!("`{label}` failed with an internal error (logged); the document is unchanged")))), @@ -723,6 +728,7 @@ impl Session { }; self.coalesce_request = None; self.color_restrict = None; + self.filter_mask_layer = None; // Finish successful command bookkeeping on the document the job edited. // Restoring the viewed document first would attribute Fade and slice updates // to that document instead, when the user switched tabs mid-job. diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 3a56d63953..610a6453ac 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -347,6 +347,9 @@ pub struct Session { pub quick_mask_options: channel_cmds::QuickMaskOptions, /// Colour channel the running command may change (a single colour channel is targeted). color_restrict: Option, + /// Smart object whose filter mask the running command edits (`"target":"filterMask"`): each + /// edit re-renders it, in the same history step. + filter_mask_layer: Option, /// Edit › Preferences, keyboard shortcuts, menu and toolbar customisation (see `prefs`). pub prefs: prefs::PrefsStore, /// Edit menu state: Fade source, custom shape library (see `edit_menu_cmds`). @@ -533,6 +536,7 @@ impl Session { /// Apply an undoable edit to the active document. pub fn edit(&mut self, label: &str, f: impl FnOnce(&mut Document, &mut Option) -> Result) -> Result { let restrict = self.color_restrict; + let filter_mask_layer = self.filter_mask_layer; let st = self.active_mut().ok_or(EngineError::NoDocument)?; let before = st.doc.clone(); // Selecting layers is not a step, so the state this edit leaves behind targets what was @@ -544,6 +548,9 @@ impl Session { if let (Some(k), Some(id)) = (restrict, active) { channel_cmds::restrict_to_color(&before, &mut doc, id, k); } + if let Some(id) = filter_mask_layer { + smart_cmds::refresh_after_filter_mask_edit(&mut doc, id)?; + } st.doc = Arc::new(doc); st.active_layer = active; fix_selection(st); diff --git a/crates/engine/src/mask_view_cmds.rs b/crates/engine/src/mask_view_cmds.rs index 055557480e..598e844bd5 100644 --- a/crates/engine/src/mask_view_cmds.rs +++ b/crates/engine/src/mask_view_cmds.rs @@ -7,6 +7,9 @@ //! While a mask is shown, pixel commands without an explicit `target` edit that mask //! ([`crate::channel_cmds`]'s target injection), so painting in mask view paints the mask. //! The view ends when its layer stops being the active layer or loses its mask ([`fix`]). +//! +//! With `"mask":"filter"` the same view shows a smart object's filter mask (⌥-click the filter +//! mask thumbnail on its Smart Filters row), and painting while it's shown paints that mask. use photocraft_doc::LayerId; use serde::Serialize; @@ -35,6 +38,19 @@ pub enum MaskViewMode { pub struct LayerMaskView { pub layer: LayerId, pub mode: MaskViewMode, + /// The smart object's filter mask is shown, not its layer mask. + pub filter: bool, +} + +/// The mask a view of `l` shows: its layer mask, or (`filter`) its smart filter mask. +pub fn viewed_mask(l: &photocraft_doc::Layer, filter: bool) -> Option<&photocraft_doc::LayerMask> { + if !filter { + return l.mask.as_ref(); + } + match &l.content { + photocraft_doc::LayerContent::Smart(sm) => sm.filter_mask.as_ref(), + _ => None, + } } fn bad(msg: impl Into) -> EngineError { @@ -48,7 +64,7 @@ fn has_doc(s: &Session) -> std::result::Result<(), String> { /// The mask view of `st` when it is live: its layer is the active layer and still has a mask. pub fn current(st: &DocState) -> Option { let v = st.channel_view.layer_mask?; - let live = st.active_layer == Some(v.layer) && st.doc.layer(v.layer).is_some_and(|l| l.mask.is_some()); + let live = st.active_layer == Some(v.layer) && st.doc.layer(v.layer).is_some_and(|l| viewed_mask(l, v.filter).is_some()); live.then_some(v) } @@ -68,16 +84,26 @@ fn mode_name(v: Option) -> &'static str { } } -/// The view as JSON (`{"layer","mode"}`, or `null` when off); part of `document.inspect`. +/// The view as JSON (`{"layer","mode"}`, plus `"mask":"filter"` for a filter mask, or `null` when +/// off); part of `document.inspect`. pub fn view_json(st: &DocState) -> Value { match current(st) { + Some(v) if v.filter => json!({"layer": v.layer.0, "mode": mode_name(Some(v)), "mask": "filter"}), Some(v) => json!({"layer": v.layer.0, "mode": mode_name(Some(v))}), None => Value::Null, } } -/// `{"layer":id?,"mode":"off"|"gray"|"overlay"|"toggleGray"|"toggleOverlay"="toggleGray"}`. +/// `{"layer":id?,"mode":"off"|"gray"|"overlay"|"toggleGray"|"toggleOverlay"="toggleGray","mask":"layer"|"filter"="layer"}`. fn set_view(s: &mut Session, p: &Value) -> Result { + let filter = match p.get("mask") { + None | Some(Value::Null) => false, + Some(v) => match v.as_str() { + Some("layer") => false, + Some("filter") => true, + _ => return Err(bad("`mask` must be \"layer\" or \"filter\"")), + }, + }; let mode = match p.get("mode") { None | Some(Value::Null) => "toggleGray", Some(v) => v.as_str().ok_or_else(|| bad("`mode` must be a string"))?, @@ -88,9 +114,9 @@ fn set_view(s: &mut Session, p: &Value) -> Result { Some(v) => LayerId(v.as_u64().ok_or_else(|| bad("`layer` must be a layer id"))?), }; let l = st.doc.layer(layer).ok_or(EngineError::NoLayer(layer))?; - let has_mask = l.mask.is_some(); + let has_mask = viewed_mask(l, filter).is_some(); let name = l.name.clone(); - let shown = current(st).filter(|v| v.layer == layer).map(|v| v.mode); + let shown = current(st).filter(|v| v.layer == layer && v.filter == filter).map(|v| v.mode); let want = match mode { "off" => None, "gray" => Some(MaskViewMode::Gray), @@ -100,14 +126,14 @@ fn set_view(s: &mut Session, p: &Value) -> Result { other => return Err(bad(format!("unknown mode `{other}` (off|gray|overlay|toggleGray|toggleOverlay)"))), }; if want.is_some() && !has_mask { - return Err(bad(format!("layer \"{name}\" has no layer mask"))); + return Err(bad(format!("layer \"{name}\" has no {}", if filter { "filter mask" } else { "layer mask" }))); } // ⌥-clicking another layer's mask selects that layer, as in Photoshop. if want.is_some() && s.active().and_then(|st| st.active_layer) != Some(layer) { s.select_layer(layer)?; } let st = s.active_mut().ok_or(EngineError::NoDocument)?; - let next = want.map(|mode| LayerMaskView { layer, mode }); + let next = want.map(|mode| LayerMaskView { layer, mode, filter }); // "off" for a layer whose mask isn't the one shown leaves the other view alone. let applies = next.is_some() || st.channel_view.layer_mask.is_some_and(|v| v.layer == layer); if applies && st.channel_view.layer_mask != next { @@ -121,7 +147,7 @@ fn set_view(s: &mut Session, p: &Value) -> Result { st.last_damage = Some(photocraft_geom::Rect::EMPTY); } let v = current(st); - Ok(json!({"layer": layer.0, "mode": mode_name(v.filter(|v| v.layer == layer))})) + Ok(json!({"layer": layer.0, "mode": mode_name(v.filter(|v| v.layer == layer && v.filter == filter)), "mask": if filter { "filter" } else { "layer" }})) } /// `\` needs a layer mask on the active layer; without one Photoshop's key does nothing. @@ -148,7 +174,7 @@ pub fn specs() -> Vec { label: "View Layer Mask", menu: &[], shortcut: None, - params: r##"{"layer":id?,"mode":"off"|"gray"|"overlay"|"toggleGray"|"toggleOverlay"="toggleGray"} (gray: the mask alone, ⌥-click its thumbnail; overlay: red rubylith over the composite, ⇧⌥-click or `\`; view state, not an undo step; painting while shown paints the mask)"##, + params: r##"{"layer":id?,"mode":"off"|"gray"|"overlay"|"toggleGray"|"toggleOverlay"="toggleGray","mask":"layer"|"filter"="layer" (filter: a smart object's filter mask)} (gray: the mask alone, ⌥-click its thumbnail; overlay: red rubylith over the composite, ⇧⌥-click or `\`; view state, not an undo step; painting while shown paints the mask)"##, enabled: has_doc, run: set_view, journal: false, diff --git a/crates/engine/src/paint_cmds.rs b/crates/engine/src/paint_cmds.rs index 7366758e93..90873dcd15 100644 --- a/crates/engine/src/paint_cmds.rs +++ b/crates/engine/src/paint_cmds.rs @@ -136,7 +136,7 @@ pub fn specs() -> Vec { label: "Paint Bucket", menu: &[], shortcut: None, - params: r##"{"x":px,"y":px,"tolerance":0..255=32,"contiguous":bool=true,"antiAlias":bool=true,"sampleAllLayers":bool=false,"contents":"foreground|pattern"="foreground","color":"#rrggbb"=foreground,"pattern":id|name (contents=pattern),"scale":%=100,"angle":deg,"opacity":1..100=100,"target":"pixels"|"mask"|"quickMask"|{"channel":i}=Channels panel target}"##, + params: r##"{"x":px,"y":px,"tolerance":0..255=32,"contiguous":bool=true,"antiAlias":bool=true,"sampleAllLayers":bool=false,"contents":"foreground|pattern"="foreground","color":"#rrggbb"=foreground,"pattern":id|name (contents=pattern),"scale":%=100,"angle":deg,"opacity":1..100=100,"target":"pixels"|"mask"|"filterMask"|"quickMask"|{"channel":i}=Channels panel target}"##, enabled: crate::commands::has_paintable, run: bucket, journal: true, @@ -146,7 +146,7 @@ pub fn specs() -> Vec { label: "Gradient", menu: &[], shortcut: None, - params: r##"{"from":[x,y],"to":[x,y],"style":"linear|radial|angle|reflected|diamond"="linear","colors":["#rrggbb",…]? (evenly spaced),"gradient":preset name?,"stops":[[t,"#rrggbb"|"foreground"|"background"],…]?,"transparency":[[t,0..100],…]? (default: the current gradient, see gradient.presets.select),"reverse":bool=false,"dither":bool=true,"opacity":1..100=100,"mode":"normal|multiply|…"="normal","target":"pixels"|"mask"|"quickMask"|{"channel":i}=Channels panel target}"##, + params: r##"{"from":[x,y],"to":[x,y],"style":"linear|radial|angle|reflected|diamond"="linear","colors":["#rrggbb",…]? (evenly spaced),"gradient":preset name?,"stops":[[t,"#rrggbb"|"foreground"|"background"],…]?,"transparency":[[t,0..100],…]? (default: the current gradient, see gradient.presets.select),"reverse":bool=false,"dither":bool=true,"opacity":1..100=100,"mode":"normal|multiply|…"="normal","target":"pixels"|"mask"|"filterMask"|"quickMask"|{"channel":i}=Channels panel target}"##, enabled: crate::commands::has_paintable, run: gradient, journal: true, diff --git a/crates/engine/src/redeye_cmds.rs b/crates/engine/src/redeye_cmds.rs index f6a71da407..eefd1a37ba 100644 --- a/crates/engine/src/redeye_cmds.rs +++ b/crates/engine/src/redeye_cmds.rs @@ -256,7 +256,7 @@ pub fn specs() -> Vec { label: "Red Eye", menu: &[], shortcut: None, - params: r#"{"x":px, "y":px} | {"points":[[x,y],…] (at most 64)},"pupilSize":1..100=50,"darken":0..100=50,"layer":id?=active,"target":"pixels"|"mask"|"quickMask"|{"channel":i} → {"damage":[x,y,w,h], "pixels":n}"#, + params: r#"{"x":px, "y":px} | {"points":[[x,y],…] (at most 64)},"pupilSize":1..100=50,"darken":0..100=50,"layer":id?=active,"target":"pixels"|"mask"|"filterMask"|"quickMask"|{"channel":i} → {"damage":[x,y,w,h], "pixels":n}"#, enabled, run: red_eye, journal: true, diff --git a/crates/engine/src/retouch_cmds.rs b/crates/engine/src/retouch_cmds.rs index 75eedc899d..f06e38d81a 100644 --- a/crates/engine/src/retouch_cmds.rs +++ b/crates/engine/src/retouch_cmds.rs @@ -1038,7 +1038,7 @@ impl<'a> AllLayers<'a> { /// The brush every retouching command shares, plus the tool's own params. macro_rules! brush_params { ($extra:literal) => { - concat!("{", r#""points":[[x,y,pressure?],…],"size":1..5000 px=tool size,"hardness":0..100=tool hardness,"opacity":1..100=100,"flow":1..100=100,"spacing":1..1000 (% of size)=Brush Settings spacing,"layer":id?=active,"target":"pixels"|"mask"|"quickMask"|{"channel":i}=Channels panel target"#, $extra, "}") + concat!("{", r#""points":[[x,y,pressure?],…],"size":1..5000 px=tool size,"hardness":0..100=tool hardness,"opacity":1..100=100,"flow":1..100=100,"spacing":1..1000 (% of size)=Brush Settings spacing,"layer":id?=active,"target":"pixels"|"mask"|"filterMask"|"quickMask"|{"channel":i}=Channels panel target"#, $extra, "}") }; } @@ -1096,7 +1096,7 @@ pub fn specs() -> Vec { label: "Patch", menu: &[], shortcut: None, - params: r#"{"offset":[dx,dy] (how far the selection was dragged),"mode":"source|destination"="source","contentAware":bool=false (fill the selection content-aware from the dragged-to place; a background job),"structure":1..7=4 (content-aware: 3..7 copy the middle exactly, 1..2 re-synthesise more of it),"color":0..10=0 (content-aware: how far the copy's level adapts to the selection's surroundings),"sampleAllLayers":bool=false (content-aware),"layer":id?=active,"target":"pixels"|"mask"|"quickMask"|{"channel":i}=Channels panel target} → {"damage","offset"}"#, + params: r#"{"offset":[dx,dy] (how far the selection was dragged),"mode":"source|destination"="source","contentAware":bool=false (fill the selection content-aware from the dragged-to place; a background job),"structure":1..7=4 (content-aware: 3..7 copy the middle exactly, 1..2 re-synthesise more of it),"color":0..10=0 (content-aware: how far the copy's level adapts to the selection's surroundings),"sampleAllLayers":bool=false (content-aware),"layer":id?=active,"target":"pixels"|"mask"|"filterMask"|"quickMask"|{"channel":i}=Channels panel target} → {"damage","offset"}"#, enabled: patch::enabled, run: patch::patch, journal: true, @@ -1106,7 +1106,7 @@ pub fn specs() -> Vec { label: "Content-Aware Move", menu: &[], shortcut: None, - params: r#"{"offset":[dx,dy] (how far the selection was dragged),"mode":"move|extend"="move","structure":1..7=4 (3..7 copy the content exactly but for a band about a patch wide along its edge; 2 widens the band, 1 re-synthesises the content too),"color":0..10=0 (0 keeps the content's level; higher values bring it towards its new place, by up to about 0.04 × color),"sampleAllLayers":bool=false,"layer":id?=active,"target":"pixels"|"mask"|"quickMask"|{"channel":i}=Channels panel target} → {"damage","offset","mode"} (a background job; the selection moves with the content)"#, + params: r#"{"offset":[dx,dy] (how far the selection was dragged),"mode":"move|extend"="move","structure":1..7=4 (3..7 copy the content exactly but for a band about a patch wide along its edge; 2 widens the band, 1 re-synthesises the content too),"color":0..10=0 (0 keeps the content's level; higher values bring it towards its new place, by up to about 0.04 × color),"sampleAllLayers":bool=false,"layer":id?=active,"target":"pixels"|"mask"|"filterMask"|"quickMask"|{"channel":i}=Channels panel target} → {"damage","offset","mode"} (a background job; the selection moves with the content)"#, enabled: content_aware_move::enabled, run: content_aware_move::content_aware_move, journal: true, diff --git a/crates/engine/src/smart_cmds.rs b/crates/engine/src/smart_cmds.rs index 6e0c043578..11d59bd886 100644 --- a/crates/engine/src/smart_cmds.rs +++ b/crates/engine/src/smart_cmds.rs @@ -520,6 +520,40 @@ fn smart_mut(doc: &mut Document, id: LayerId) -> Result<&mut SmartObject> { } } +/// Whether `l`'s filter mask can be painted (`"target":"filterMask"`): a smart object with smart +/// filters. Its filter mask need not exist yet: painting starts it white (Reveal All), the mask +/// Photoshop adds with the first smart filter. +pub(crate) fn filter_mask_paintable(l: &Layer) -> std::result::Result<(), String> { + match &l.content { + LayerContent::Smart(sm) if !sm.smart_filters.is_empty() => Ok(()), + LayerContent::Smart(_) => Err(format!("smart object \"{}\" has no smart filters, so no filter mask", l.name)), + other => Err(format!("the active layer is {} {} layer, not a smart object", other.article(), other.kind_name())), + } +} + +/// The filter mask surface of smart object `id` for painting into, made white (Reveal All) first +/// when the object has smart filters but no filter mask yet. The caller re-renders the object +/// afterwards ([`refresh_after_filter_mask_edit`]). +pub(crate) fn filter_mask_surface(doc: &mut Document, id: LayerId) -> Result<&mut Surface> { + let l = doc.layer_mut(id).ok_or(EngineError::NoLayer(id))?; + filter_mask_paintable(l).map_err(EngineError::Other)?; + let sm = smart_mut_of(l)?; + Ok(&mut sm.filter_mask.get_or_insert_with(LayerMask::reveal_all).surface) +} + +/// Re-renders smart object `id` after its filter mask was painted, filled or filtered, so the +/// stroke shows (where the mask is black the smart filters don't). Part of the same history step. +pub(crate) fn refresh_after_filter_mask_edit(doc: &mut Document, id: LayerId) -> Result<()> { + if matches!(doc.layer(id).map(|l| &l.content), Some(LayerContent::Smart(_))) { refresh_or_fail(doc, id) } else { Ok(()) } +} + +fn smart_mut_of(l: &mut Layer) -> Result<&mut SmartObject> { + match &mut l.content { + LayerContent::Smart(sm) => Ok(sm), + _ => Err(other("the layer is not a smart object")), + } +} + fn mask_from_selection(sel: &Surface) -> LayerMask { LayerMask { surface: sel.clone(), enabled: true, linked: true, density: 1.0, feather: 0.0 } } diff --git a/crates/engine/src/smart_cmds/tests.rs b/crates/engine/src/smart_cmds/tests.rs index 2ee54322bf..b36e6ef649 100644 --- a/crates/engine/src/smart_cmds/tests.rs +++ b/crates/engine/src/smart_cmds/tests.rs @@ -1,5 +1,6 @@ use super::*; +mod filter_mask_paint; mod selection; mod stack_cache; diff --git a/crates/engine/src/smart_cmds/tests/filter_mask_paint.rs b/crates/engine/src/smart_cmds/tests/filter_mask_paint.rs new file mode 100644 index 0000000000..b0061e7da9 --- /dev/null +++ b/crates/engine/src/smart_cmds/tests/filter_mask_paint.rs @@ -0,0 +1,79 @@ +//! FILE-215-3: painting a smart object's filter mask (`"target":"filterMask"`) hides the smart +//! filters where it is black, in one undo step, and the painted mask is saved. + +use super::*; + +/// A vertical black stroke over x = 8 into the filter mask, as the Brush tool sends it. +fn stroke(s: &mut Session, target: Option<&str>) -> Result { + let mut p = json!({"points": [[8, 2], [8, 46]], "size": 8, "hardness": 1, "color": "#000000"}); + if let Some(t) = target { + p["target"] = json!(t); + } + s.execute("paint.stroke", p) +} + +#[test] +fn painting_the_filter_mask_hides_the_filters_there_in_one_undo_step() { + for depth in DEPTHS { + let mut s = session(depth); + paint(&mut s); + let original = flat(&s); + convert(&mut s); + // Without smart filters there is no filter mask to paint. + assert!(matches!(stroke(&mut s, Some("filterMask")), Err(EngineError::Disabled(..))), "depth {depth}"); + s.execute("filter.blur.gaussianBlur", json!({"radius": 3})).unwrap(); + let blurred = flat(&s); + assert!(active_smart(&s).filter_mask.is_none()); + let steps = s.active().unwrap().history.past_len(); + + stroke(&mut s, Some("filterMask")).unwrap(); + let mask = active_smart(&s).filter_mask.expect("painting starts a white filter mask"); + assert_eq!((mask.value(8, 20), mask.value(30, 20)), (0.0, 1.0), "depth {depth}"); + let px = flat(&s); + let at = |v: &Vec<[f32; 4]>, x: i32, y: i32| v[(y * W + x) as usize]; + assert!(max_diff(&[at(&px, 8, 20)], &[at(&original, 8, 20)]) < 1e-6, "depth {depth}: black hides the blur"); + assert_eq!(at(&px, 30, 20), at(&blurred, 30, 20), "depth {depth}: white keeps it"); + assert!(active_smart(&s).smart_filters.len() == 1, "the stroke is no smart filter"); + + assert_eq!(s.active().unwrap().history.past_len(), steps + 1, "one step"); + s.execute("edit.undo", json!({})).unwrap(); + assert!(active_smart(&s).filter_mask.is_none()); + assert_eq!(flat(&s), blurred, "depth {depth}: undo brings the blur back"); + s.execute("edit.redo", json!({})).unwrap(); + assert_eq!(flat(&s), px); + + // The painted mask is saved: .pcraft and PSD give it back. + let doc = s.active().unwrap().doc.clone(); + let id = s.active().unwrap().active_layer.unwrap(); + let back = photocraft_format::load_from_bytes(&photocraft_format::save_to_bytes(&doc, &Default::default()).unwrap()).unwrap(); + assert_eq!(smart(&back, id).unwrap().filter_mask, smart(&doc, id).unwrap().filter_mask, "depth {depth}: .pcraft"); + let psd = photocraft_io::export(&doc, "psd", &Default::default()).unwrap(); + let back = photocraft_io::import("x.psd", &psd.bytes).unwrap().document; + let sm = back.walk().into_iter().find_map(|(_, _, l)| if let LayerContent::Smart(sm) = &l.content { Some(sm.clone()) } else { None }).unwrap(); + let (mut a, mut b) = (Vec::new(), Vec::new()); + sm.filter_mask.as_ref().unwrap().values_into(doc.bounds(), &mut a); + mask.values_into(doc.bounds(), &mut b); + assert_eq!(a, b, "depth {depth}: PSD"); + } +} + +/// ⌥-click on the filter mask thumbnail shows it; painting then goes into it without a target. +#[test] +fn a_shown_filter_mask_takes_the_paint() { + let mut s = session(8); + paint(&mut s); + convert(&mut s); + s.execute("filter.blur.gaussianBlur", json!({"radius": 3})).unwrap(); + assert!(s.execute("view.layerMask", json!({"mode": "gray", "mask": "filter"})).is_err(), "no filter mask yet"); + stroke(&mut s, Some("filterMask")).unwrap(); + let v = s.execute("view.layerMask", json!({"mode": "gray", "mask": "filter"})).unwrap(); + assert_eq!(v["mode"], "gray"); + assert!(s.active().unwrap().channel_view.shown_layer_mask(&s.active().unwrap().doc).is_some()); + s.execute("paint.stroke", json!({"points": [[30, 2], [30, 46]], "size": 8, "hardness": 1, "color": "#000000"})).unwrap(); + let mask = active_smart(&s).filter_mask.unwrap(); + assert_eq!(mask.value(30, 20), 0.0, "the stroke went into the filter mask"); + let d = s.active().unwrap(); + assert!(matches!(d.doc.layer(d.active_layer.unwrap()).unwrap().content, LayerContent::Smart(_)), "still a smart object"); + // Bad params are refused, not a panic. + assert!(s.execute("view.layerMask", json!({"mask": 3})).is_err()); +} diff --git a/crates/engine/src/transform_cmds.rs b/crates/engine/src/transform_cmds.rs index 88939fc7cd..0b0021ead8 100644 --- a/crates/engine/src/transform_cmds.rs +++ b/crates/engine/src/transform_cmds.rs @@ -156,6 +156,8 @@ pub fn lone_target<'a>(doc: &'a Document, layer: Option, p: &Value) -> let m = l.mask.as_ref().ok_or_else(|| EngineError::Other("layer has no mask".into()))?; Ok((!m.linked).then_some(&m.surface)) } + // A filter mask is not transformed on its own (it follows its smart object). + Target::FilterMask => Err(EngineError::Other("Free Transform can't transform a filter mask on its own".into())), Target::Alpha(i) => doc .channels .get(i) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index a1fcda0adb..1bf6dcd0ae 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -4794,9 +4794,13 @@ pub fn paint_target(app: &PhotocraftApp) -> serde_json::Value { ChannelTarget::Composite if st.doc.quick_mask.is_some() => return json!("quickMask"), _ => {} } + // A smart object's targeted (or shown) filter mask takes the paint (FILE-215-3). + if app.filter_mask_targeted() { + return json!("filterMask"); + } let has_mask = st.active_layer.and_then(|id| st.doc.layer(id)).is_some_and(|l| l.mask.is_some()); // Viewing the mask (⌥-click its thumbnail, #196) paints the mask. - let viewing = photocraft_engine::mask_view_cmds::current(st).is_some(); + let viewing = photocraft_engine::mask_view_cmds::current(st).is_some_and(|v| !v.filter); json!(if (app.ui.mask_target || viewing) && has_mask { "mask" } else { "pixels" }) } diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index 7710c228cd..642a4fc2b6 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -8,7 +8,7 @@ //! - `engine.commands`: list commands with enablement //! - `ui.inspect`: full UI state (tool, panels, views, dialogs, windows, window size); the menu //! tree is `ui.menu.list` -//! - `ui.set {tool?, panels?, dock?, dockTabs?, dockWidth?, colorPanel?, maskTarget?, vectorMaskTarget?, selectionMode?, zoom?, center?, rotation?, fit?, theme?, brushSection?, brushTab?, brushesView?, brushPicker?, brushPickerName?, brushPickerStroke?, brushPickerTip?, brushPickerScale?, brushSize?}`: +//! - `ui.set {tool?, panels?, dock?, dockTabs?, dockWidth?, colorPanel?, maskTarget?, vectorMaskTarget?, filterMaskTarget?, selectionMode?, zoom?, center?, rotation?, fit?, theme?, brushSection?, brushTab?, brushesView?, brushPicker?, brushPickerName?, brushPickerStroke?, brushPickerTip?, brushPickerScale?, brushSize?}`: //! change UI state; any other field is an error ([`UI_SET_FIELDS`]) //! - `ui.dialog.open {kind, fields?}` (kinds: newDocument, about, layerStyle {effect?}, colorPicker {target: foreground|background}, command {command}) / `ui.dialog.set {dialog, field, value}` / `ui.dialog.confirm {dialog, wait?}` / `ui.dialog.cancel {dialog}` //! - `ui.dialog.apply {dialog}`: commit Preferences changes without closing the dialog @@ -87,7 +87,7 @@ pub enum Outcome { /// field's value is validated before the first one is applied, so a typo, an unknown field, a /// bad value or a bad nested key can't reply with success while nothing — or only half of it — /// changed (#412). -pub const UI_SET_FIELDS: [&str; 33] = [ +pub const UI_SET_FIELDS: [&str; 34] = [ "tool", "panels", "dock", @@ -96,6 +96,7 @@ pub const UI_SET_FIELDS: [&str; 33] = [ "colorPanel", "maskTarget", "vectorMaskTarget", + "filterMaskTarget", "selectionMode", "zoom", "center", @@ -412,6 +413,8 @@ fn dispatch(app: &mut PhotocraftApp, ctx: &egui::Context, req: &ControlRequest) let panels = merged_object(&app.ui.panels, p.get("panels"), "panels")?; let mask_target = bool_field(p, "maskTarget")?; let vector_mask_target = bool_field(p, "vectorMaskTarget")?; + // Target the active smart object's filter mask (FILE-215-3). + let filter_mask_target = bool_field(p, "filterMaskTarget")?; let selection_mode = uint_field(p, "selectionMode")?; let dock_tabs = merged_object(&app.ui.dock_tabs, p.get("dockTabs"), "dockTabs")?; let dock = whole_object(&app.ui.dock, p.get("dock"), "dock")?; @@ -563,6 +566,14 @@ fn dispatch(app: &mut PhotocraftApp, ctx: &egui::Context, req: &ControlRequest) app.ui.mask_target &= !m; app.sync_mask_targets(); } + if let Some(m) = filter_mask_target { + app.ui.filter_mask_target = if m { app.session.active().and_then(|st| st.active_layer).map(|id| id.0) } else { None }; + if m { + app.ui.mask_target = false; + app.ui.vector_mask_target = false; + } + app.sync_mask_targets(); + } // Selection tools' options-bar mode: 0 New, 1 Add, 2 Subtract, 3 Intersect. if let Some(m) = selection_mode { app.ui.selection_mode = m.min(3) as u8; diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index c30796a5dd..5657c4655f 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1594,18 +1594,35 @@ impl PhotocraftApp { /// ⌘I then inverts the mask, as in Photoshop (#780). A targeted alpha channel or Quick Mask /// mode wins, as the engine routes those itself. pub fn with_mask_target(&self, id: &str, params: Value) -> Value { - if !photocraft_engine::channel_cmds::follows_target(id) || params.get("target").is_some() || !self.layer_mask_targeted() { + if !photocraft_engine::channel_cmds::follows_target(id) || params.get("target").is_some() { return params; } + // A filter mask is painted, filled and filtered in place; it doesn't float. + let target = if self.filter_mask_targeted() && id != "select.float" { + "filterMask" + } else if self.layer_mask_targeted() { + "mask" + } else { + return params; + }; match params { Value::Object(mut m) => { - m.insert("target".into(), Value::from("mask")); + m.insert("target".into(), Value::from(target)); Value::Object(m) } - _ => serde_json::json!({ "target": "mask" }), + _ => serde_json::json!({ "target": target }), } } + /// The Layers panel targets the active smart object's filter mask (FILE-215-3), and no alpha + /// channel or Quick Mask takes over. + pub fn filter_mask_targeted(&self) -> bool { + let Some(st) = self.session.active() else { return false }; + let Some(id) = st.active_layer.filter(|id| self.ui.filter_mask_target == Some(id.0)) else { return false }; + let composite = st.channel_view.target == photocraft_engine::channel_cmds::ChannelTarget::Composite && st.doc.quick_mask.is_none(); + composite && st.doc.layer(id).is_some_and(|l| matches!(&l.content, photocraft_doc::LayerContent::Smart(sm) if !sm.smart_filters.is_empty())) + } + /// The Layers panel targets the active layer's mask, and no alpha channel or Quick Mask /// takes over (the engine routes those itself). pub fn layer_mask_targeted(&self) -> bool { @@ -1619,9 +1636,21 @@ impl PhotocraftApp { /// pixels brings back that target's foreground/background pair, as in Photoshop (#2166). pub(crate) fn sync_mask_targets(&mut self) { if let Some(st) = self.session.active() { - if photocraft_engine::mask_view_cmds::current(st).is_some() { - self.ui.mask_target = true; - self.ui.vector_mask_target = false; + match photocraft_engine::mask_view_cmds::current(st) { + Some(v) if v.filter => { + self.ui.filter_mask_target = Some(v.layer.0); + self.ui.mask_target = false; + self.ui.vector_mask_target = false; + } + Some(_) => { + self.ui.mask_target = true; + self.ui.vector_mask_target = false; + self.ui.filter_mask_target = None; + } + None => {} + } + if self.ui.mask_target || self.ui.vector_mask_target { + self.ui.filter_mask_target = None; } if self.ui.vector_mask_target && !mask_thumbs_ui::has_vector_mask(st) { self.ui.vector_mask_target = false; @@ -1630,7 +1659,10 @@ impl PhotocraftApp { self.ui.mask_target = false; } } - let mask = self.layer_mask_targeted(); + if self.ui.filter_mask_target.is_some() && !self.filter_mask_targeted() { + self.ui.filter_mask_target = None; + } + let mask = self.layer_mask_targeted() || self.filter_mask_targeted(); self.session.tools.target_mask(mask); } diff --git a/crates/ui-egui/src/mask_thumbs_ui/tests.rs b/crates/ui-egui/src/mask_thumbs_ui/tests.rs index 3fd0904eb9..df404c3d1c 100644 --- a/crates/ui-egui/src/mask_thumbs_ui/tests.rs +++ b/crates/ui-egui/src/mask_thumbs_ui/tests.rs @@ -483,6 +483,7 @@ fn mask_view_gestures_fail_gracefully_without_a_mask() { h.state_mut().session.active_mut().unwrap().channel_view.layer_mask = Some(photocraft_engine::mask_view_cmds::LayerMaskView { layer: photocraft_doc::LayerId(987_654), mode: photocraft_engine::mask_view_cmds::MaskViewMode::Gray, + filter: false, }); assert!(canvas_px(&h).is_none()); h.run_steps(2); diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 444036c57f..30e627d7d6 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -2257,12 +2257,21 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) { if id == "ui.maskTarget" { app.ui.mask_target = p.as_bool().unwrap_or(false); app.ui.vector_mask_target = false; + app.ui.filter_mask_target = None; app.sync_mask_targets(); continue; } if id == "ui.vectorMaskTarget" { app.ui.vector_mask_target = p.as_bool().unwrap_or(false); app.ui.mask_target = false; + app.ui.filter_mask_target = None; + app.sync_mask_targets(); + continue; + } + if id == "ui.filterMaskTarget" { + app.ui.filter_mask_target = p.as_u64(); + app.ui.mask_target = false; + app.ui.vector_mask_target = false; app.sync_mask_targets(); continue; } @@ -2494,7 +2503,10 @@ fn layer_row( // Photoshop frames the targeted thumbnail (pixels, mask or vector mask) of the active layer // with corner brackets. if row.primary { - let target = if app.ui.vector_mask_target && vector_rect.is_some() { + let target = if app.ui.filter_mask_target == Some(l.id.0) && app.filter_mask_targeted() { + // The Smart Filters row's filter mask thumbnail carries the brackets. + None + } else if app.ui.vector_mask_target && vector_rect.is_some() { vector_rect } else if app.ui.mask_target { mask_rect.or(Some(thumb)) diff --git a/crates/ui-egui/src/smart_ui.rs b/crates/ui-egui/src/smart_ui.rs index 99deaa60fe..59124a2669 100644 --- a/crates/ui-egui/src/smart_ui.rs +++ b/crates/ui-egui/src/smart_ui.rs @@ -1,5 +1,7 @@ //! Layers-panel pieces for smart objects: the thumbnail badge and the Smart Filters sub-rows //! (eye toggles; double-click a filter to re-open its dialog with the recorded parameters). +//! The Smart Filters row carries the filter mask thumbnail: click it to paint the filter mask, +//! ⌥-click to view it, ⇧-click to disable it (FILE-215-3). use egui::{Align2, Color32, Rect, Sense, Stroke, pos2, vec2}; use photocraft_doc::{Layer, LayerContent, SmartObject}; @@ -72,8 +74,11 @@ pub fn filter_rows(app: &mut PhotocraftApp, ui: &mut egui::Ui, l: &Layer, depth: let x = rect.left() + indent + if index.is_none() { 0.0 } else { 16.0 }; if index.is_none() { let sw = Rect::from_center_size(pos2(x - 12.0, rect.center().y), vec2(14.0, 10.0)); - ui.painter().rect_filled(sw, 1.0, if sm.filter_mask.as_ref().is_some_and(|m| m.enabled) { Color32::from_gray(200) } else { Color32::WHITE }); - ui.painter().rect_stroke(sw, 1.0, Stroke::new(1.0, t.field_border), egui::StrokeKind::Inside); + paint_filter_mask_thumb(app, ui, sw, l, sm); + let sw_resp = ui.interact(sw.expand(2.0), ui.id().with(("sf-mask", l.id.0)), Sense::click()); + if sw_resp.clicked() { + actions.extend(filter_mask_click(l, sm, ui.input(|i| i.modifiers))); + } } ui.painter().text(pos2(x, rect.center().y), Align2::LEFT_CENTER, name, egui::FontId::proportional(11.5), if on { t.text_dim } else { t.text_faint }); if let Some(i) = index @@ -84,6 +89,64 @@ pub fn filter_rows(app: &mut PhotocraftApp, ui: &mut egui::Ui, l: &Layer, depth: } } +/// The filter mask thumbnail: the mask itself (white where the filters show), crossed out when +/// it is disabled, with the target brackets when painting goes into it. +fn paint_filter_mask_thumb(app: &PhotocraftApp, ui: &egui::Ui, sw: Rect, l: &Layer, sm: &SmartObject) { + let t = Tokens::get(ui.ctx()); + let p = ui.painter(); + p.rect_filled(sw, 1.0, Color32::WHITE); + if let Some((m, canvas)) = sm.filter_mask.as_ref().zip(app.session.active().map(|d| d.doc.bounds())) { + // A coarse sample of the canvas, one cell per thumbnail point, as a mesh (rectangles + // this small would be rounded away to nothing). + let (cols, rows) = (sw.width() as i32, sw.height() as i32); + let mut mesh = egui::Mesh::default(); + for j in 0..rows { + for i in 0..cols { + let x = canvas.x0 + (((i as f32 + 0.5) / cols as f32) * canvas.width() as f32) as i32; + let y = canvas.y0 + (((j as f32 + 0.5) / rows as f32) * canvas.height() as f32) as i32; + let v = m.surface.sample_channel(x, y, 0).clamp(0.0, 1.0); + if v < 1.0 { + let cell = Rect::from_min_size(pos2(sw.left() + i as f32, sw.top() + j as f32), vec2(1.0, 1.0)); + mesh.add_colored_rect(cell, Color32::from_gray((v * 255.0).round() as u8)); + } + } + } + p.add(egui::Shape::mesh(mesh)); + if !m.enabled { + p.line_segment([sw.left_top(), sw.right_bottom()], Stroke::new(1.5, Color32::from_rgb(200, 40, 40))); + p.line_segment([sw.left_bottom(), sw.right_top()], Stroke::new(1.5, Color32::from_rgb(200, 40, 40))); + } + } + p.rect_stroke(sw, 1.0, Stroke::new(1.0, t.field_border), egui::StrokeKind::Inside); + if app.ui.filter_mask_target == Some(l.id.0) && app.filter_mask_targeted() { + crate::mask_thumbs_ui::paint_brackets(p, sw, t.text); + } +} + +/// What a click on the filter mask thumbnail does: target it for painting (selecting the smart +/// object), ⌥ view it alone (⇧⌥ as an overlay), ⇧ disable or enable it. +fn filter_mask_click(l: &Layer, sm: &SmartObject, m: egui::Modifiers) -> Vec<(String, Value)> { + let layer = l.id.0; + if m.alt { + let mode = if m.shift { "toggleOverlay" } else { "toggleGray" }; + return sm + .filter_mask + .is_some() + .then(|| (photocraft_engine::mask_view_cmds::ID.to_string(), json!({"layer": layer, "mode": mode, "mask": "filter"}))) + .into_iter() + .collect(); + } + if m.shift { + return sm + .filter_mask + .as_ref() + .map(|f| ("layer.smartFilter.disableFilterMask".to_string(), json!({"layer": layer, "enabled": !f.enabled}))) + .into_iter() + .collect(); + } + vec![("layer.select".into(), json!({"layer": layer})), ("ui.filterMaskTarget".into(), json!(layer))] +} + /// Re-opens a smart filter's dialog with its recorded parameters; OK runs /// `layer.smartFilter.setParams` instead of adding another filter (see `dialogs::confirm`). pub fn open_editor(app: &mut PhotocraftApp, ctx: &egui::Context, layer: u64, sm: &SmartObject, index: usize) { @@ -121,3 +184,54 @@ pub fn confirm_command(fields: &serde_json::Map, command: String, None => (command, params), } } + +#[cfg(test)] +mod tests { + use photocraft_doc::LayerContent; + use photocraft_engine::Session; + use serde_json::json; + + use crate::{PhotocraftApp, Services}; + + fn smart(app: &PhotocraftApp) -> (photocraft_doc::Layer, photocraft_doc::SmartObject) { + let st = app.session.active().unwrap(); + let l = st.doc.layer(st.active_layer.unwrap()).unwrap().clone(); + let LayerContent::Smart(sm) = l.content.clone() else { panic!("not a smart object") }; + (l, sm) + } + + /// FILE-215-3: clicking the filter mask thumbnail targets it, the Brush paints into it (not + /// the layer mask, no rasterize prompt), and clicking the layer thumbnail goes back. + #[test] + fn the_filter_mask_thumbnail_targets_the_filter_mask() { + let mut app = PhotocraftApp::new(Session::new(), Services::default()); + app.run("file.new", json!({"width": 32, "height": 32})).unwrap(); + app.run("layer.new.layer", json!({})).unwrap(); + app.run("edit.fill", json!({"contents": "color", "color": "#ff0000"})).unwrap(); + app.run("layer.smartObjects.convertToSmartObject", json!({})).unwrap(); + app.run("filter.blur.gaussianBlur", json!({"radius": 2})).unwrap(); + let (l, sm) = smart(&app); + let actions = super::filter_mask_click(&l, &sm, egui::Modifiers::NONE); + assert_eq!(actions.last().unwrap().0, "ui.filterMaskTarget"); + assert!(super::filter_mask_click(&l, &sm, egui::Modifiers::ALT).is_empty(), "nothing to view yet"); + app.ui.filter_mask_target = Some(l.id.0); + app.sync_views(); + assert!(app.filter_mask_targeted()); + assert_eq!(crate::canvas::paint_target(&app), json!("filterMask")); + assert_eq!(app.with_mask_target("filter.blur.gaussianBlur", json!({}))["target"], "filterMask"); + assert!(crate::rasterize_prompt::needed(&app).is_none(), "painting the filter mask needs no rasterizing"); + app.run( + "paint.stroke", + json!({"points": [[4, 0], [4, 31]], "size": 4, "hardness": 1, "color": "#000000", "target": crate::canvas::paint_target(&app)}), + ) + .unwrap(); + let (l, sm) = smart(&app); + assert_eq!(sm.filter_mask.as_ref().unwrap().value(4, 16), 0.0); + assert!(l.mask.is_none(), "no layer mask"); + assert_eq!(super::filter_mask_click(&l, &sm, egui::Modifiers::ALT)[0].1["mask"], "filter"); + // Targeting a layer mask (or the pixels, `ui.maskTarget`) ends it. + app.ui.mask_target = true; + app.sync_views(); + assert_eq!(app.ui.filter_mask_target, None, "a layer mask target replaces it"); + } +} diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index deb82b7885..9b9b94c34d 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -920,6 +920,11 @@ pub struct UiState { /// tools edit it (#196). Never set together with `mask_target`. #[serde(default)] pub vector_mask_target: bool, + /// The smart object (layer id) whose filter mask is targeted (its thumbnail on the Smart + /// Filters row clicked): painting, fills, filters and adjustments edit that mask + /// (FILE-215-3). Never set together with `mask_target` or `vector_mask_target`. + #[serde(default)] + pub filter_mask_target: Option, /// Brush Preset picker opened by a right-click on the canvas or the options-bar brush chip: /// its screen position (points). #[serde(default)] @@ -1086,6 +1091,7 @@ impl Default for UiState { symmetry_transform: None, mask_target: false, vector_mask_target: false, + filter_mask_target: None, brush_picker: None, brush_picker_list: crate::brush_picker::list_state(), brush_picker_size: None, diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 1c69df465f..79b9a2b4a6 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -43,7 +43,7 @@ The transport is `apps/photocraft/src/control_server.rs`, and the handlers are i - `engine.execute {command, params}`: run any engine or UI command by id. Engine commands run directly with their default params and never open a dialog. Use `ui.menu.invoke` for menu-click behaviour, which opens a command's dialog when no params are given. `params` must be a JSON object (omit it or pass `null` for none); an array, string, number or boolean is an error naming the command, in every transport (control channel, `serve`, MCP and the CLI) - `engine.commands`: list commands with enablement - `ui.inspect`: full UI state (tool, panels, views, dialogs, windows, window size). The menu tree is not included; use `ui.menu.list`. `brushPicker` is `null` while closed and `{pos: [x, y], size: [w, h]?, list: {collapsed, filter, renaming, showName, showStroke, showTip, scale}}` while the Brush Preset picker is open (coordinates in screen points; `size` is the picker's content size once its corner grip was dragged, `null` before that, and the drag remembers both dimensions; the three `show*` flags pick the parts of each preset's card — at least one is always on; `scale` is the footer slider, 0.15–2 with 1 the standard, multiplying the cards' width and height — the heights stop at half size and the name and tip-size text hold their 1.0 size — and dropping the tips' size numbers at 0.40 and below; the parts and the scale are remembered across restarts, while the search, collapsed groups and a rename in progress are not). `view` holds the View/Window/Type preferences: `screen_mode`, `extras`, `show` and `snap_to` flags, `flip_horizontal`, `arrange` (Window › Arrange layout), pixel aspect, font preview size, language options. `perf.timings.gpuInfo` holds the graphics adapter, backend, driver, the backend chosen at launch and why, the canvas renderer (`gpu`/`cpu`) and, after a device loss, `lost` (`help.systemInfo` returns the same as `info`) -- `ui.set {tool?, panels?, dockTabs?, dock?, dockWidth?, colorPanel?, maskTarget?, vectorMaskTarget?, selectionMode?, zoom?, center?, rotation?, fit?, theme?, brushSize?, brushSection?, brushTab?, brushesView?, brushPicker?, brushPickerName?, brushPickerStroke?, brushPickerTip?, brushPickerScale?, gradientBlendMode?, gradientClassic?, shapeStroke?}`: change UI state; any other field is an error, checked before anything changes (`zoom` is the canvas zoom where 1 = 100%, one document pixel per physical display pixel, so a scaled display doesn't magnify the image; `theme` is `pro`, `proMedium`, `studio`, `studioLight` or `classic`; `selectionMode` is the selection tools' options-bar mode, 0 New, 1 Add, 2 Subtract, 3 Intersect; `brushSection` indexes the Brush Settings sections, `brushTab` 0 = Brush Settings, 1 = Brushes; `brushesView` is `list` or `grid` for the Brushes panel; `brushPickerName`, `brushPickerStroke` and `brushPickerTip` are the Brush Preset picker's card parts (booleans, at least one on), and `brushPickerScale` its footer card-scale slider (0.15 to 2, 1 the standard); `brushPicker` is `[x, y]` in screen points to open the Brush Preset picker there (as a right-click with a painting tool does) or `null` to close it, and picking a preset in it is `tools.setBrush {"preset": name}`; `dock` is `{order: ["layers", …], heights: {"properties": 180}, collapsed: ["color"], tabOrder: {"layers": ["Paths", "Layers", "Channels"]}}`, the right-dock groups top to bottom, their heights in points, the groups collapsed to their tab strip and each group's tab order left to right by panel name (a group left out keeps its default order, unknown names are ignored and tabs not listed follow in their default order; `dockTabs` keeps indexing tabs in their default order); `dockWidth` sets the right dock width in points, clamped to 250..520; `colorPanel` is `{background}`, whether the Color panel edits the background colour; `maskTarget` targets the active layer's mask, which, like Photoshop, swaps in the foreground/background pair kept for masks (white/black until one is picked) and swaps the pixels' pair back when the pixels are targeted again) +- `ui.set {tool?, panels?, dockTabs?, dock?, dockWidth?, colorPanel?, maskTarget?, vectorMaskTarget?, filterMaskTarget?, selectionMode?, zoom?, center?, rotation?, fit?, theme?, brushSize?, brushSection?, brushTab?, brushesView?, brushPicker?, brushPickerName?, brushPickerStroke?, brushPickerTip?, brushPickerScale?, gradientBlendMode?, gradientClassic?, shapeStroke?}`: change UI state; any other field is an error, checked before anything changes (`zoom` is the canvas zoom where 1 = 100%, one document pixel per physical display pixel, so a scaled display doesn't magnify the image; `theme` is `pro`, `proMedium`, `studio`, `studioLight` or `classic`; `selectionMode` is the selection tools' options-bar mode, 0 New, 1 Add, 2 Subtract, 3 Intersect; `brushSection` indexes the Brush Settings sections, `brushTab` 0 = Brush Settings, 1 = Brushes; `brushesView` is `list` or `grid` for the Brushes panel; `brushPickerName`, `brushPickerStroke` and `brushPickerTip` are the Brush Preset picker's card parts (booleans, at least one on), and `brushPickerScale` its footer card-scale slider (0.15 to 2, 1 the standard); `brushPicker` is `[x, y]` in screen points to open the Brush Preset picker there (as a right-click with a painting tool does) or `null` to close it, and picking a preset in it is `tools.setBrush {"preset": name}`; `dock` is `{order: ["layers", …], heights: {"properties": 180}, collapsed: ["color"], tabOrder: {"layers": ["Paths", "Layers", "Channels"]}}`, the right-dock groups top to bottom, their heights in points, the groups collapsed to their tab strip and each group's tab order left to right by panel name (a group left out keeps its default order, unknown names are ignored and tabs not listed follow in their default order; `dockTabs` keeps indexing tabs in their default order); `dockWidth` sets the right dock width in points, clamped to 250..520; `colorPanel` is `{background}`, whether the Color panel edits the background colour; `maskTarget` targets the active layer's mask, which, like Photoshop, swaps in the foreground/background pair kept for masks (white/black until one is picked) and swaps the pixels' pair back when the pixels are targeted again; `filterMaskTarget` targets the active smart object's filter mask, so painting, fills, filters and adjustments edit it (`"target":"filterMask"`)) - `typeTransform` is `null` outside a temporary Ctrl/Cmd Type-tool drag. During a drag it reports its source document/revision, original affine, oriented `frame` (layer, local bounds, document-space corners and pivot), and captured `gesture`. Drive it with `ui.pointer` and `command: true` at `down`; `move`/`up` may release the modifier. The document/history remain unchanged during preview, and `up` applies one `type.edit` within `textEdit`'s session. Pressing Escape during the drag cancels only the preview. This pointer state is never restored from saved UI state. - `ui.menu.invoke {id, params?, wait?}` / `ui.menu.list`: activate a menu item by id; list the menu tree. A menu item that starts a background job (a filter without a dialog, such as Blur More) replies with the job's result once it has been applied; with `"wait": false` the reply is `{job, pending: true}` at once - `ui.set` also accepts `gradientBlendMode` (a layer blend mode name, such as `Difference`) and `gradientClassic` (boolean) for the Gradient tool options bar. diff --git a/docs/scorecard.md b/docs/scorecard.md index 67789593e5..e3c2e41859 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -7,7 +7,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js | Area | Done | Partial | Missing | Key numbers | |---|---:|---:|---:|---| | [Performance](#performance) | 3 | 22 | 22 | 56 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 16 not run, 6 not measurable yet (baseline 2026-10-05) | -| [File compatibility](#file-compatibility) | 5 | 11 | 11 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 | +| [File compatibility](#file-compatibility) | 6 | 11 | 10 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 | | [Tools](#tools) | 21 | 17 | 4 | | | [Workspace and UI](#workspace-and-ui) | 6 | 7 | 10 | settings that do nothing: 43 of 151 (target 0) | | [Type](#type) | 0 | 3 | 6 | | @@ -100,7 +100,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t |---|---|---|---|---| | FILE-215-1 | Smart Objects export as embedded Smart Objects (SoLd + lnk2), not flat pixels | done | [#215](https://github.com/storytold/photocraft/issues/215) | psd_export.rs smart_blocks: PlLd + SoLd, source in lnk2 (.pcraft -> PSB); engine tests/smart_psd.rs; Photoshop 2026 opens 8/16-bit exports as live smart objects. Linked files are embedded | | FILE-215-2 | Smart Filters survive PSD save and re-open (filterFX descriptor read and written) | partial | [#215](https://github.com/storytold/photocraft/issues/215) | smart_map.rs: 14 filters plus a verified Camera Raw subset mapped both ways, others kept verbatim, mask in FEid; io tests/smart_corpus.rs. PhotoCraft-only filters (Twirl, Liquify…) and unmapped Camera Raw settings are left out of filterFX with a warning | -| FILE-215-3 | Filter mask can be painted directly, with undo | missing | [#215](https://github.com/storytold/photocraft/issues/215) | smart_cmds.rs:382 mask only from the selection | +| FILE-215-3 | Filter mask can be painted directly, with undo | done | [#215](https://github.com/storytold/photocraft/issues/215) | Clicking the filter mask thumbnail on the Smart Filters row targets it (ui.filterMaskTarget, smart_ui.rs). Painting, fills, filters and adjustments with "target":"filterMask" then edit it (a white mask starts on the first stroke) and re-render the smart object, one undo step per stroke (channel_cmds Target::FilterMask, Session::edit). ⌥-click shows it (view.layerMask "mask":"filter"), ⇧-click disables it. Kept through .pcraft and PSD FEid (smart_cmds/tests/filter_mask_paint.rs) | | FILE-215-4 | Adjustments (Hue/Sat + Colorize, Curves, Levels, Shadows/Highlights) apply as Smart Filters | done | [#215](https://github.com/storytold/photocraft/issues/215) | Image › Adjustments on a smart object records image.adjustments. as a smart filter (adjust_cmds.rs adjust_as_smart_filter; the selection becomes the filter mask), re-rendered from the source by adjust_as_filter and re-editable with layer.smartFilter.setParams; PSD maps Levels/Curves/Shadows-Highlights both ways (smart_map.rs). Opening the editor from the smart-filter row is FILE-215-5's row work | | FILE-215-5 | Smart Filter rows: collapse, mask thumb, blend icon, drag reorder, context menu, live preview | partial | [#215](https://github.com/storytold/photocraft/issues/215) | smart_ui.rs:31 rows + visibility + editor; no collapse, drag or context menu | | FILE-215-6 | Smart Object corner skew and perspective (quad or homography transform) | missing | [#215](https://github.com/storytold/photocraft/issues/215) | doc lib.rs:312 SmartObject.transform is an Affine | diff --git a/scorecard/file_compat.toml b/scorecard/file_compat.toml index 1c3d798e87..44424f26c4 100644 --- a/scorecard/file_compat.toml +++ b/scorecard/file_compat.toml @@ -22,9 +22,9 @@ note = "smart_map.rs: 14 filters plus a verified Camera Raw subset mapped both w [[item]] id = "FILE-215-3" target = "Filter mask can be painted directly, with undo" -status = "missing" +status = "done" issue = 215 -note = "smart_cmds.rs:382 mask only from the selection" +note = "Clicking the filter mask thumbnail on the Smart Filters row targets it (ui.filterMaskTarget, smart_ui.rs). Painting, fills, filters and adjustments with \"target\":\"filterMask\" then edit it (a white mask starts on the first stroke) and re-render the smart object, one undo step per stroke (channel_cmds Target::FilterMask, Session::edit). ⌥-click shows it (view.layerMask \"mask\":\"filter\"), ⇧-click disables it. Kept through .pcraft and PSD FEid (smart_cmds/tests/filter_mask_paint.rs)" [[item]] id = "FILE-215-4" From 15a3ce86f0b04b1177f9d6f025dc21bee5320dc5 Mon Sep 17 00:00:00 2001 From: Ratul Paul Date: Sun, 11 Oct 2026 13:32:17 +0600 Subject: [PATCH 015/649] Add intermediate UI scale presets between 100% and 125% --- contributors/people.toml | 3 ++ crates/engine/src/prefs.rs | 2 +- crates/engine/src/prefs/tests.rs | 15 ++++++++++ crates/ui-egui/src/i18n/cs.tsv | 4 +++ crates/ui-egui/src/i18n/de.tsv | 4 +++ crates/ui-egui/src/i18n/el.tsv | 4 +++ crates/ui-egui/src/i18n/es.tsv | 4 +++ crates/ui-egui/src/i18n/fr.tsv | 4 +++ crates/ui-egui/src/i18n/id.tsv | 4 +++ crates/ui-egui/src/i18n/it.tsv | 4 +++ crates/ui-egui/src/i18n/ja.tsv | 4 +++ crates/ui-egui/src/i18n/ko.tsv | 4 +++ crates/ui-egui/src/i18n/nl.tsv | 4 +++ crates/ui-egui/src/i18n/pl.tsv | 4 +++ crates/ui-egui/src/i18n/pt-br.tsv | 4 +++ crates/ui-egui/src/i18n/ru.tsv | 4 +++ crates/ui-egui/src/i18n/uk.tsv | 4 +++ crates/ui-egui/src/i18n/zh-hans.tsv | 4 +++ crates/ui-egui/src/i18n/zh-hant.tsv | 4 +++ crates/ui-egui/src/prefs_ui.rs | 43 +++++++++++++++++++++++++++-- docs/ui-design.md | 3 +- 21 files changed, 126 insertions(+), 4 deletions(-) diff --git a/contributors/people.toml b/contributors/people.toml index 0adfc2f4a1..062ac7f5f0 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -93,3 +93,6 @@ sync_github_name = true [people.FinnNk] sync_github_name = true + +[people.WebWork-rrs] +display_name = "Ratul Paul" diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index 7c7d3b8080..b5f4b8161e 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -61,7 +61,7 @@ choice!(DarkTheme { Pro = "pro", ProMedium = "proMedium", Studio = "studio", Sol choice!(LightTheme { StudioLight = "studioLight", Classic = "classic", Adwaita = "adwaita", BreezeLight = "breezeLight" } default StudioLight); choice!(CanvasColor { Default = "default", Black = "black", DarkGray = "darkGray", MediumGray = "mediumGray", LightGray = "lightGray", Custom = "custom" } default Default); choice!(CanvasBorder { DropShadow = "dropShadow", Line = "line", None = "none" } default DropShadow); -choice!(UiScale { Auto = "auto", P75 = "75", P80 = "80", P85 = "85", P90 = "90", P95 = "95", P100 = "100", P125 = "125", P150 = "150", P175 = "175", P200 = "200", P250 = "250", P300 = "300" } default Auto); +choice!(UiScale { Auto = "auto", P75 = "75", P80 = "80", P85 = "85", P90 = "90", P95 = "95", P100 = "100", P105 = "105", P110 = "110", P115 = "115", P120 = "120", P125 = "125", P150 = "150", P175 = "175", P200 = "200", P250 = "250", P300 = "300" } default Auto); choice!( /// Graphics backend of the desktop app's window and GPU canvas (applies at next launch). /// `auto` lets PhotoCraft pick (DX12 for Intel adapters on Windows); `cpu` composites on the diff --git a/crates/engine/src/prefs/tests.rs b/crates/engine/src/prefs/tests.rs index bc896f4efc..a3b6386204 100644 --- a/crates/engine/src/prefs/tests.rs +++ b/crates/engine/src/prefs/tests.rs @@ -22,6 +22,21 @@ fn defaults_match_photoshop() { } } +#[test] +fn intermediate_ui_scale_presets_survive_restart() { + let mut s = Session::new(); + assert_eq!(s.execute("prefs.get", json!({"path": "interface.uiScale"})).unwrap(), json!("auto")); + for scale in ["100", "105", "110", "115", "120", "125"] { + s.execute("prefs.set", json!({"path": "interface.uiScale", "value": scale})).unwrap(); + let mut restored = Session::new(); + restored.load_prefs_json(&s.prefs_to_json()).unwrap(); + assert_eq!(restored.execute("prefs.get", json!({"path": "interface.uiScale"})).unwrap(), json!(scale)); + } + // Presets remain discrete choices: arbitrary values must not silently replace a valid scale. + assert!(s.execute("prefs.set", json!({"path": "interface.uiScale", "value": "112"})).is_err()); + assert_eq!(s.execute("prefs.get", json!({"path": "interface.uiScale"})).unwrap(), json!("125")); +} + /// #2264: the Studio workspace dot pattern can be hidden without changing themes. #[test] fn canvas_dot_grid_can_be_disabled_persisted_and_reset() { diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 33f32c2d31..d52d1a6f64 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -600,6 +600,10 @@ Fit Layer(s) on Screen Přizpůsobit vrstvy obrazovce Fit Artboard on Screen Přizpůsobit kreslicí plochu obrazovce 100% 100 % + 105% 105 % + 110% 110 % + 115% 115 % + 120% 120 % 200% 200 % 75% 75 % 80% 80 % diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 27e71fe3fb..8190b5b20a 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -596,6 +596,10 @@ Fit Layer(s) on Screen Ebenen auf den Bildschirm einpassen Fit Artboard on Screen Zeichenbereich auf den Bildschirm einpassen 100% 100 % + 105% 105 % + 110% 110 % + 115% 115 % + 120% 120 % 200% 200 % Print Size Druckgröße Pixel Aspect Ratio Pixel-Seitenverhältnis diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 4821be08a8..a4b63fcfa5 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3288,6 +3288,10 @@ cameraRaw Yellow Κίτρινο # Labels added on main since the first batch 100% 100% + 105% 105% + 110% 110% + 115% 115% + 120% 120% 180° 180° 200% 200% 3 x 3 3 x 3 diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index bbaac744cf..2ca938ff43 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -592,6 +592,10 @@ Fit Layer(s) on Screen Encajar capas en pantalla Fit Artboard on Screen Encajar lienzo en pantalla 100% 100% + 105% 105% + 110% 110% + 115% 115% + 120% 120% 200% 200% 75% 75% 80% 80% diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 68a9dff4b4..b92f2877e6 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -583,6 +583,10 @@ Fit Layer(s) on Screen Adapter le(s) calque(s) à l'écran Fit Artboard on Screen Adapter le plan de travail à l'écran 100% 100 % + 105% 105 % + 110% 110 % + 115% 115 % + 120% 120 % 200% 200 % 75% 75 % 80% 80 % diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 9355f23685..22cdc7bfbf 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -576,6 +576,10 @@ Fit Layer(s) on Screen Pas Layer di Layar Fit Artboard on Screen Pas Artboard di Layar 100% 100% + 105% 105% + 110% 110% + 115% 115% + 120% 120% 200% 200% 75% 75% 80% 80% diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 43e52295ae..b40170da06 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -590,6 +590,10 @@ Fit Layer(s) on Screen Adatta livello/i a schermo Fit Artboard on Screen Adatta tavola a schermo 100% 100% + 105% 105% + 110% 110% + 115% 115% + 120% 120% 200% 200% 75% 75% 80% 80% diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 1c66b52c8a..683592b75e 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -595,6 +595,10 @@ Fit Layer(s) on Screen レイヤーを画面サイズに合わせる Fit Artboard on Screen アートボードを画面サイズに合わせる 100% 100% + 105% 105% + 110% 110% + 115% 115% + 120% 120% 200% 200% 75% 75% 80% 80% diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 8484888eed..299671b6db 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -578,6 +578,10 @@ Fit Layer(s) on Screen 레이어를 화면에 맞추기 Fit Artboard on Screen 아트보드를 화면에 맞추기 100% 100% + 105% 105% + 110% 110% + 115% 115% + 120% 120% 200% 200% Print Size 인쇄 크기 Pixel Aspect Ratio 픽셀 종횡비 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 173af2b176..c731776d73 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -587,6 +587,10 @@ Fit Layer(s) on Screen Laag/lagen passend in scherm Fit Artboard on Screen Tekengebied passend in scherm 100% 100% + 105% 105% + 110% 110% + 115% 115% + 120% 120% 200% 200% Print Size Afdrukgrootte Pixel Aspect Ratio Pixelverhouding diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 71b80b30bc..9413ad1765 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -593,6 +593,10 @@ Fit Layer(s) on Screen Dopasuj warstwy do ekranu Fit Artboard on Screen Dopasuj obszar roboczy do ekranu 100% 100% + 105% 105% + 110% 110% + 115% 115% + 120% 120% 200% 200% 75% 75% 80% 80% diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index ae367d5406..b6fabeeb11 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -580,6 +580,10 @@ Fit Layer(s) on Screen Ajustar camada(s) à tela Fit Artboard on Screen Ajustar prancheta à tela 100% 100% + 105% 105% + 110% 110% + 115% 115% + 120% 120% 200% 200% 75% 75% 80% 80% diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 27c8e43922..7217249bb7 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -393,6 +393,10 @@ Zoom Out Уменьшить Fit on Screen По размеру экрана 100% 100% + 105% 105% + 110% 110% + 115% 115% + 120% 120% 200% 200% 75% 75% 80% 80% diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 315a2b5fdb..375973cf00 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -372,6 +372,10 @@ Zoom Out Зменшити Fit on Screen Умістити на екрані 100% 100% + 105% 105% + 110% 110% + 115% 115% + 120% 120% 200% 200% 75% 75% 80% 80% diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 977736fc44..381e0f07ca 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -595,6 +595,10 @@ Fit Layer(s) on Screen 使图层适合屏幕 Fit Artboard on Screen 使画板适合屏幕 100% 100% + 105% 105% + 110% 110% + 115% 115% + 120% 120% 200% 200% 75% 75% 80% 80% diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 049194ed6a..e194d0bba9 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -600,6 +600,10 @@ Fit Layer(s) on Screen 使圖層符合螢幕 Fit Artboard on Screen 使工作區域符合螢幕 100% 100% + 105% 105% + 110% 110% + 115% 115% + 120% 120% 200% 200% 75% 75% 80% 80% diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs index c2def4db7d..e5d9e53bde 100644 --- a/crates/ui-egui/src/prefs_ui.rs +++ b/crates/ui-egui/src/prefs_ui.rs @@ -981,7 +981,7 @@ fn choice_label(v: &str) -> String { match v { "cm" => "Centimeters".into(), "mm" => "Millimeters".into(), - "75" | "80" | "85" | "90" | "95" | "100" | "125" | "150" | "175" | "200" | "250" | "300" => format!("{v}%"), + "75" | "80" | "85" | "90" | "95" | "100" | "105" | "110" | "115" | "120" | "125" | "150" | "175" | "200" | "250" | "300" => format!("{v}%"), "8" => "8 Bits/Channel".into(), "16" => "16 Bits/Channel".into(), "postScript" => "PostScript (72 points/inch)".into(), @@ -2445,7 +2445,21 @@ mod tests { step(vec2(2560.0, 1440.0), 1.75, 1.75); step(vec2(3840.0, 2160.0), 1.0, 2.0); } - for (pref, expected) in [("200", 2.0), ("125", 1.25), ("150", 1.5), ("100", 1.0), ("95", 0.95), ("90", 0.9), ("85", 0.85), ("80", 0.8), ("auto", 1.5)] { + for (pref, expected) in [ + ("200", 2.0), + ("125", 1.25), + ("150", 1.5), + ("100", 1.0), + ("105", 1.05), + ("110", 1.1), + ("115", 1.15), + ("120", 1.2), + ("95", 0.95), + ("90", 0.9), + ("85", 0.85), + ("80", 0.8), + ("auto", 1.5), + ] { app.run("prefs.set", json!({"values": {"interface.uiScale": pref}})).unwrap(); let mut input = egui::RawInput::default(); input.viewports.get_mut(&egui::ViewportId::ROOT).unwrap().native_pixels_per_point = Some(1.5); @@ -2455,6 +2469,31 @@ mod tests { } } + #[test] + fn intermediate_ui_scale_choices_can_be_applied_from_preferences() { + use egui_kittest::{Harness, kittest::Queryable}; + let (mut app, store) = app_with_store(); + app.run("prefs.set", json!({"path": "interface.uiScale", "value": "100"})).unwrap(); + open_preferences(&mut app, "interface"); + let mut h = Harness::builder().with_size(vec2(1400.0, 1100.0)).build_eframe(move |cc| { + PhotocraftApp::setup_context(&cc.egui_ctx, Default::default()); + app + }); + h.run_steps(4); + let mut current = "100%"; + for (label, value) in [("105%", "105"), ("110%", "110"), ("115%", "115"), ("120%", "120")] { + h.get_by_value(current).click(); + h.run_steps(2); + h.get_by_label(label).click(); + h.run_steps(2); + h.get_by_label("Apply").click(); + h.run_steps(4); + assert_eq!(h.state().session.prefs().interface.ui_scale.name(), value); + assert_eq!(stored(&store)["interface"]["uiScale"], value); + current = label; + } + } + #[test] fn ui_font_size_commands_follow_themes_and_dpi_and_reset_live() { let (mut app, _) = app_with_store(); diff --git a/docs/ui-design.md b/docs/ui-design.md index f897c83da0..e66fe92cbf 100644 --- a/docs/ui-design.md +++ b/docs/ui-design.md @@ -153,7 +153,8 @@ Wayland's fractional scale or X11's `Xft.dpi`). Only when the system reports no a 4K or larger monitor does Auto use 200%, so text and controls remain readable. Detection uses the current monitor, including portrait displays, and updates when the window moves between monitors. If monitor size is unavailable, Auto follows system DPI. The fixed choices (75% to 300%) set an absolute UI -scale, allowing large 4K displays to use smaller controls when desired. Canvas zoom shortcuts +scale, including 105%, 110%, 115% and 120% for finer control between 100% and 125%, allowing +large 4K displays to use smaller controls when desired. Canvas zoom shortcuts continue to control the document independently of UI scaling. Interface → UI Font Size changes interface text independently of UI Scale and canvas zoom. From 4af9f116e79aade1c2c3a435c4b6cef99127031d Mon Sep 17 00:00:00 2001 From: SBaksa Date: Sun, 11 Oct 2026 01:48:26 +1100 Subject: [PATCH 016/649] CMYK documents export as CMYK, mixing pixel layers on their ink values (#2220) A CMYK document with more than one plain layer went through the RGB compositor and was written to TIFF and JPEG as sRGB RGB. Flat export now always writes a CMYK document as CMYK with its own profile: - New compose::cmyk: a mode-native CMYK compositor for the stacks whose blending is the same in every colour model (Normal pixel layers with opacity, fill opacity, layer and vector masks; isolated and pass-through groups; clipping groups). Pixels are mixed on their ink values, so opaque pixels keep their exact inks (K-only black stays K-only). Tiles render in parallel on native targets. - Any other stack is composited in RGB and converted back through the document's CMYK profile, as PSD export's merged image is, with a warning that ink values can differ. TIFF keeps transparency (CMYK + alpha); JPEG is composited over blank paper (no ink) and written as CMYK; RGB-only formats still convert to sRGB through the profile. Fixes #2220. --- crates/compose/src/cmyk.rs | 325 ++++++++++++++++++++++ crates/compose/src/cmyk_tests.rs | 454 +++++++++++++++++++++++++++++++ crates/compose/src/lib.rs | 1 + crates/io/src/flat.rs | 77 +++++- crates/io/tests/cmyk_export.rs | 131 +++++++++ 5 files changed, 985 insertions(+), 3 deletions(-) create mode 100644 crates/compose/src/cmyk.rs create mode 100644 crates/compose/src/cmyk_tests.rs create mode 100644 crates/io/tests/cmyk_export.rs diff --git a/crates/compose/src/cmyk.rs b/crates/compose/src/cmyk.rs new file mode 100644 index 0000000000..c97b27d4e2 --- /dev/null +++ b/crates/compose/src/cmyk.rs @@ -0,0 +1,325 @@ +//! Mode-native CMYK compositing: a CMYK document's layers mixed on their ink values, so opaque +//! pixels keep their exact inks (K-only black stays K-only) instead of going through display RGB +//! and back through the profile. +//! +//! This path covers the layer stacks whose blending is the same in every colour model: Normal +//! pixel layers with opacity, fill opacity and masks, isolated and pass-through groups, and +//! clipping groups. [`supports`] says whether a document stays on it; anything else (type, +//! shapes, fills, effects, adjustments, other blend modes, knockouts, channel restrictions, +//! Blend If) is left to the RGB compositor, whose result callers convert back to CMYK. +//! +//! Buffers hold straight-alpha `[C, M, Y, K, A]` in 0..1 ink (0 = no ink). + +use photocraft_color::ColorMode; +use photocraft_color::blend::BlendMode; +use photocraft_doc::{Document, Knockout, Layer, LayerContent}; +use photocraft_geom::Rect; + +use super::{Ctx, RENDER_TILE, advanced, empty_in, mask_vals, pattern}; + +/// One straight-alpha CMYK pixel: C, M, Y, K (0..1 ink), alpha. +pub type Cmyka = [f32; 5]; + +/// Deepest group nesting this path composites (deeper documents use the RGB compositor). +pub const MAX_DEPTH: u32 = 64; + +/// Straight-alpha CMYK + alpha float buffer covering a rectangle. +#[derive(Clone, Debug, PartialEq)] +pub struct CmykBuffer { + pub rect: Rect, + pub px: Vec, +} + +impl CmykBuffer { + pub fn transparent(rect: Rect) -> Self { + Self { rect, px: vec![[0.0; 5]; rect.width() as usize * rect.height() as usize] } + } +} + +/// Whether [`render_cmyk`] composites `doc` natively (a CMYK document made only of layers this +/// path handles; invisible layers don't count). +pub fn supports(doc: &Document) -> bool { + doc.mode == ColorMode::Cmyk && stack_supported(&doc.layers, 0) +} + +/// The sibling list grouped as the compositor groups it: each base with the clipped layers above it. +fn clip_groups(layers: &[Layer]) -> impl Iterator { + let mut i = 0; + std::iter::from_fn(move || { + let base = layers.get(i)?; + let mut j = i + 1; + while layers.get(j).is_some_and(|l| l.clipped) && !base.clipped { + j += 1; + } + let clipped = layers.get(i + 1..j).unwrap_or(&[]); + i = j.max(i + 1); + Some((base, clipped)) + }) +} + +fn stack_supported(layers: &[Layer], depth: u32) -> bool { + if depth > MAX_DEPTH { + return false; + } + clip_groups(layers).all(|(base, clipped)| !base.visible || layer_supported(base, clipped, depth)) +} + +/// What every natively composited layer needs, whatever its content. +fn plain(l: &Layer) -> bool { + l.opacity.is_finite() + && l.fill_opacity.is_finite() + && !super::effects::has_effects(l) + && l.advanced.knockout == Knockout::None + && l.excluded_channels == 0 + && l.blend_if.is_default() +} + +fn cmyk_raster(l: &Layer) -> bool { + matches!(&l.content, LayerContent::Raster(s) if s.format().mode == ColorMode::Cmyk) +} + +fn layer_supported(l: &Layer, clipped: &[Layer], depth: u32) -> bool { + if !plain(l) || advanced::clips_individually(l, clipped) { + return false; + } + let content = match &l.content { + LayerContent::Raster(_) => cmyk_raster(l) && l.blend == BlendMode::Normal, + LayerContent::Group(g) => { + g.artboard.is_none() + && matches!(l.blend, BlendMode::Normal | BlendMode::PassThrough) + // A pass-through group with clipped layers mixes them through its isolated rendering. + && !(passes_through(l) && clipped.iter().any(|c| c.visible)) + && stack_supported(&g.children, depth + 1) + } + _ => false, + }; + content && clipped.iter().filter(|c| c.visible).all(|c| plain(c) && cmyk_raster(c) && c.blend == BlendMode::Normal) +} + +/// A group whose children composite straight into the backdrop (the compositor's rule). +fn passes_through(l: &Layer) -> bool { + matches!(l.content, LayerContent::Group(_)) && l.blend == BlendMode::PassThrough && l.fill_opacity >= 1.0 && !super::effects::has_effects(l) +} + +/// Normal compositing of straight-alpha `source` (alpha times `opacity`) over `backdrop`: the +/// compositor's Normal formula, on the four ink channels. +#[inline] +pub fn normal(backdrop: Cmyka, source: Cmyka, opacity: f32) -> Cmyka { + let ab = backdrop[4]; + let as_ = source[4] * opacity; + if as_ <= 0.0 { + return backdrop; + } + let ao = as_ + ab * (1.0 - as_); + if ao <= 0.0 { + return [0.0; 5]; + } + let kb = ab * (1.0 - as_); + let inv = 1.0 / ao; + let c = |i: usize| (kb * backdrop[i] + as_ * source[i]) * inv; + [c(0), c(1), c(2), c(3), ao] +} + +/// A finite sample in 0..1 (non-finite samples, possible in 32-bit documents, count as 0). +#[inline] +fn clean(v: f32) -> f32 { + if v.is_finite() { v } else { 0.0 } +} + +/// A CMYK pixel layer's own pixels over `rect`, masks applied. +fn raster_content(l: &Layer, rect: Rect, cx: &Ctx) -> CmykBuffer { + let mut out = CmykBuffer::transparent(rect); + if let LayerContent::Raster(s) = &l.content { + let ch = s.format().channels(); + let alpha = s.format().alpha; + let mut v = Vec::new(); + s.read_region_into(rect, &mut v); + for (o, p) in out.px.iter_mut().zip(v.chunks_exact(ch.max(1))) { + let a = if alpha { p.get(4).copied().map_or(0.0, clean) } else { 1.0 }; + *o = [ + p.first().copied().map_or(0.0, clean), + p.get(1).copied().map_or(0.0, clean), + p.get(2).copied().map_or(0.0, clean), + p.get(3).copied().map_or(0.0, clean), + a, + ]; + } + } + apply_mask(l, &mut out, cx); + out +} + +fn apply_mask(l: &Layer, buf: &mut CmykBuffer, cx: &Ctx) { + if let Some(m) = mask_vals(l, buf.rect, cx) { + for (p, k) in buf.px.iter_mut().zip(&m) { + p[4] *= clean(*k).max(0.0); + } + } +} + +/// Mask value `i` of `m` (1 where there is no mask or no value). +#[inline] +fn mask_at(m: &Option>, i: usize) -> f32 { + m.as_ref().and_then(|v| v.get(i)).copied().map_or(1.0, |k| clean(k).max(0.0)) +} + +/// Clipped layers onto their base's own rendering: each blends as if the base were opaque and +/// the base keeps its alpha. +fn composite_clipped(clipped: &[Layer], base: &mut CmykBuffer, cx: &Ctx) { + for c in clipped.iter().filter(|c| c.visible) { + let content = raster_content(c, base.rect, cx); + let opacity = c.opacity * c.fill_opacity; + for (p, s) in base.px.iter_mut().zip(&content.px) { + let alpha = p[4]; + if alpha <= 0.0 { + continue; + } + let r = normal([p[0], p[1], p[2], p[3], 1.0], *s, opacity); + *p = [r[0], r[1], r[2], r[3], alpha]; + } + } +} + +fn blend_into(backdrop: &mut CmykBuffer, src: &CmykBuffer, opacity: f32) { + for (b, s) in backdrop.px.iter_mut().zip(&src.px) { + if s[4] > 0.0 { + *b = normal(*b, *s, opacity); + } + } +} + +fn composite_stack(layers: &[Layer], backdrop: &mut CmykBuffer, cx: &Ctx) { + for (base, clipped) in clip_groups(layers) { + if base.visible { + composite_layer(base, clipped, backdrop, cx); + } + } +} + +fn composite_layer(l: &Layer, clipped: &[Layer], backdrop: &mut CmykBuffer, cx: &Ctx) { + let rect = backdrop.rect; + if empty_in(l, rect) { + return; + } + let opacity = l.opacity * l.fill_opacity; + if let LayerContent::Group(g) = &l.content { + if passes_through(l) { + let needs_mix = opacity < 1.0 || l.mask.is_some() || l.vector_mask.is_some(); + let before = needs_mix.then(|| backdrop.clone()); + composite_stack(&g.children, backdrop, cx); + if let Some(before) = &before { + // The compositor's pass-through mix: coverage mixes premultiplied colour. + let mv = mask_vals(l, rect, cx); + for (i, (p, a)) in backdrop.px.iter_mut().zip(&before.px).enumerate() { + let k = opacity * mask_at(&mv, i); + let b = *p; + let wa = a[4] * (1.0 - k); + let wb = b[4] * k; + let alpha = wa + wb; + *p = if alpha > 0.0 { + let c = |c: usize| (a[c] * wa + b[c] * wb) / alpha; + [c(0), c(1), c(2), c(3), alpha] + } else { + [0.0; 5] + }; + } + } + return; + } + let mut content = CmykBuffer::transparent(rect); + composite_stack(&g.children, &mut content, cx); + apply_mask(l, &mut content, cx); + composite_clipped(clipped, &mut content, cx); + blend_into(backdrop, &content, opacity); + return; + } + let mut content = raster_content(l, rect, cx); + composite_clipped(clipped, &mut content, cx); + blend_into(backdrop, &content, opacity); +} + +fn render_tile(doc: &Document, rect: Rect, cx: &Ctx) -> CmykBuffer { + let mut b = CmykBuffer::transparent(rect); + composite_stack(&doc.layers, &mut b, cx); + b +} + +/// The composite of `doc` over `rect` in CMYK + alpha, mixed on ink values; `None` when +/// [`supports`] is false. Tiles render in parallel on native targets (one at a time on wasm); +/// every tile is independent, so the result doesn't depend on the tiling or the thread count. +pub fn render_cmyk(doc: &Document, rect: Rect) -> Option { + render_cmyk_tiled(doc, rect, RENDER_TILE) +} + +/// [`render_cmyk`] with an explicit tile size (tests check tile independence). +pub fn render_cmyk_tiled(doc: &Document, rect: Rect, tile: i32) -> Option { + if !supports(doc) { + return None; + } + let patterns = pattern::PreparedPatterns::new(&doc.patterns, pattern::PREPARED_PATTERN_BYTES).in_mode(doc.pixel_format().mode); + let cx = Ctx::for_doc(doc, &patterns); + Some(render_with(doc, rect, tile, &cx)) +} + +fn render_with(doc: &Document, rect: Rect, tile: i32, cx: &Ctx) -> CmykBuffer { + let tile = tile.max(1); + let mut out = CmykBuffer::transparent(rect); + if rect.is_empty() { + return out; + } + let w = rect.width() as usize; + let mut tiles = Vec::new(); + let mut y = rect.y0; + while y < rect.y1 { + let y1 = y.saturating_add(tile).min(rect.y1); + let mut x = rect.x0; + while x < rect.x1 { + let x1 = x.saturating_add(tile).min(rect.x1); + tiles.push(Rect::new(x, y, x1, y1)); + x = x1; + } + y = y1; + } + #[cfg(not(target_arch = "wasm32"))] + let parts: Vec = { + use rayon::prelude::*; + tiles.par_iter().map(|t| render_tile(doc, *t, cx)).collect() + }; + #[cfg(target_arch = "wasm32")] + let parts: Vec = tiles.iter().map(|t| render_tile(doc, *t, cx)).collect(); + for part in &parts { + let pw = part.rect.width() as usize; + for (row, src) in part.px.chunks_exact(pw.max(1)).enumerate() { + let o = ((part.rect.y0 - rect.y0) as usize + row) * w + (part.rect.x0 - rect.x0) as usize; + if let Some(dst) = out.px.get_mut(o..o + pw) { + dst.copy_from_slice(src); + } + } + } + out +} + +/// [`render_cmyk`] in horizontal bands, top to bottom, handing each band to `sink` (so a huge +/// document is never held as one full-size float composite); `None` when [`supports`] is false. +/// `band_rows` as in [`super::render_bands`]. +pub fn render_cmyk_bands(doc: &Document, rect: Rect, band_rows: i32, mut sink: impl FnMut(CmykBuffer) -> Result<(), E>) -> Option> { + if !supports(doc) { + return None; + } + let patterns = pattern::PreparedPatterns::new(&doc.patterns, pattern::PREPARED_PATTERN_BYTES).in_mode(doc.pixel_format().mode); + let cx = Ctx::for_doc(doc, &patterns); + let rows = super::band_rows_for(rect.width(), band_rows); + let mut y = rect.y0; + while y < rect.y1 { + let y1 = y.saturating_add(rows).min(rect.y1); + if let Err(e) = sink(render_with(doc, Rect::new(rect.x0, y, rect.x1, y1), RENDER_TILE, &cx)) { + return Some(Err(e)); + } + y = y1; + } + Some(Ok(())) +} + +#[cfg(test)] +#[path = "cmyk_tests.rs"] +mod tests; diff --git a/crates/compose/src/cmyk_tests.rs b/crates/compose/src/cmyk_tests.rs new file mode 100644 index 0000000000..d9e25fded7 --- /dev/null +++ b/crates/compose/src/cmyk_tests.rs @@ -0,0 +1,454 @@ +use photocraft_color::blend::BlendMode; +use photocraft_color::{ColorMode, PixelFormat, SampleType}; +use photocraft_doc::{Adjustment, Document, Knockout, Layer, LayerContent, LayerMask}; +use photocraft_geom::{Rect, Size}; +use photocraft_raster::Surface; +use proptest::prelude::*; + +use super::*; + +const CMYKA8: PixelFormat = PixelFormat { mode: ColorMode::Cmyk, sample: SampleType::U8, alpha: true }; +const CMYK8: PixelFormat = PixelFormat { mode: ColorMode::Cmyk, sample: SampleType::U8, alpha: false }; + +fn doc(w: u32, h: u32) -> Document { + Document::new("c", Size::new(w, h), ColorMode::Cmyk, SampleType::U8) +} + +fn layer(rects: &[(Rect, Cmyka)]) -> Layer { + let mut l = Layer::raster("l", CMYKA8); + for (r, c) in rects { + if let Some(s) = l.surface_mut() { + s.fill_rect(*r, c); + } + } + l +} + +/// An opaque layer without alpha (as a flattened Background is). +fn paper(w: i32, h: i32, c: [f32; 4]) -> Layer { + let mut l = Layer::raster("bg", CMYK8); + if let Some(s) = l.surface_mut() { + s.fill_rect(Rect::new(0, 0, w, h), &c); + } + l +} + +fn mask(rects: &[(Rect, f32)], default: f32, density: f32, enabled: bool) -> LayerMask { + let mut surface = Surface::with_default(PixelFormat::GRAY8, &[default]); + for (r, v) in rects { + surface.fill_rect(*r, &[*v]); + } + LayerMask { surface, enabled, linked: true, density, feather: 0.0 } +} + +/// An 8-bit sample as stored. +fn q(v: f32) -> f32 { + (v.clamp(0.0, 1.0) * 255.0).round() / 255.0 +} + +// ---- an independent per-pixel reference ------------------------------------------------------- + +/// Porter-Duff source-over with straight alpha, written out separately from the compositor. +fn over(b: Cmyka, s: Cmyka, opacity: f32) -> Cmyka { + let sa = s[4] * opacity; + let a = sa + b[4] * (1.0 - sa); + if sa <= 0.0 { + return b; + } + if a <= 0.0 { + return [0.0; 5]; + } + let mut o = [0.0; 5]; + for i in 0..4 { + o[i] = (s[i] * sa + b[i] * b[4] * (1.0 - sa)) / a; + } + o[4] = a; + o +} + +fn ref_mask(l: &Layer, x: i32, y: i32) -> f32 { + l.mask.as_ref().map_or(1.0, |m| if m.enabled { 1.0 - m.density * (1.0 - m.surface.sample_channel(x, y, 0)) } else { 1.0 }) +} + +fn ref_own(l: &Layer, x: i32, y: i32) -> Cmyka { + let Some(s) = l.surface() else { return [0.0; 5] }; + let p = s.pixel(x, y); + let a = if s.format().alpha { p[4] } else { 1.0 }; + [p[0], p[1], p[2], p[3], a * ref_mask(l, x, y)] +} + +fn ref_stack(layers: &[Layer], x: i32, y: i32, mut b: Cmyka) -> Cmyka { + let mut i = 0; + while i < layers.len() { + let base = &layers[i]; + let mut j = i + 1; + while j < layers.len() && layers[j].clipped && !base.clipped { + j += 1; + } + if base.visible { + b = ref_layer(base, &layers[i + 1..j], x, y, b); + } + i = j; + } + b +} + +fn ref_layer(l: &Layer, clipped: &[Layer], x: i32, y: i32, b: Cmyka) -> Cmyka { + let op = l.opacity * l.fill_opacity; + let mut content = match &l.content { + LayerContent::Group(g) if l.blend == BlendMode::PassThrough && l.fill_opacity >= 1.0 => { + let r = ref_stack(&g.children, x, y, b); + if op >= 1.0 && l.mask.is_none() { + return r; + } + let k = op * ref_mask(l, x, y); + let (wa, wb) = (b[4] * (1.0 - k), r[4] * k); + let a = wa + wb; + if a <= 0.0 { + return [0.0; 5]; + } + let mut o = [0.0; 5]; + for c in 0..4 { + o[c] = (b[c] * wa + r[c] * wb) / a; + } + o[4] = a; + return o; + } + LayerContent::Group(g) => { + let mut c = ref_stack(&g.children, x, y, [0.0; 5]); + c[4] *= ref_mask(l, x, y); + c + } + _ => ref_own(l, x, y), + }; + for c in clipped.iter().filter(|c| c.visible) { + if content[4] > 0.0 { + let a = content[4]; + let r = over([content[0], content[1], content[2], content[3], 1.0], ref_own(c, x, y), c.opacity * c.fill_opacity); + content = [r[0], r[1], r[2], r[3], a]; + } + } + over(b, content, op) +} + +fn assert_matches_reference(d: &Document) { + let rect = Rect::new(-1, -1, d.size.width as i32 + 1, d.size.height as i32 + 1); + let Some(got) = render_cmyk(d, rect) else { panic!("supported") }; + let rgb = crate::render(d, rect); + for y in rect.y0..rect.y1 { + for x in rect.x0..rect.x1 { + let i = ((y - rect.y0) * rect.width() as i32 + (x - rect.x0)) as usize; + let (g, want) = (got.px[i], ref_stack(&d.layers, x, y, [0.0; 5])); + assert!(g.iter().all(|v| v.is_finite()), "({x},{y}) {g:?}"); + // Ink only means something where there is coverage. + let close = |a: f32, b: f32| (a - b).abs() <= 1e-5; + assert!(close(g[4], want[4]), "alpha ({x},{y}): {g:?} vs reference {want:?}"); + if want[4] > 1e-4 { + assert!((0..4).all(|c| close(g[c], want[c])), "ink ({x},{y}): {g:?} vs reference {want:?}"); + } + // Coverage doesn't depend on the colour model: the RGB compositor agrees. + assert!((g[4] - rgb.px[i][3]).abs() <= 1e-5, "alpha vs RGB ({x},{y}): {g:?} vs {:?}", rgb.px[i]); + } + } +} + +// ---- directed tests --------------------------------------------------------------------------- + +#[test] +fn opaque_pixels_keep_their_exact_inks() { + let mut d = doc(6, 4); + d.layers.push(paper(6, 4, [0.0, 0.0, 0.0, 0.0])); + // K-only black "type", a rich four-colour patch, then a half-covered patch on top. + d.layers.push(layer(&[(Rect::new(0, 0, 3, 4), [0.0, 0.0, 0.0, 1.0, 1.0])])); + d.layers.push(layer(&[(Rect::new(3, 0, 6, 2), [0.2, 0.4, 0.6, 0.1, 1.0])])); + let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported")); + let at = |x: i32, y: i32| got.px[(y * 6 + x) as usize]; + assert_eq!(at(1, 1), [0.0, 0.0, 0.0, 1.0, 1.0], "K stays K-only"); + assert_eq!(at(4, 1), [q(0.2), q(0.4), q(0.6), q(0.1), 1.0], "every ink kept as stored"); + assert_eq!(at(4, 3), [0.0, 0.0, 0.0, 0.0, 1.0], "paper: no ink"); +} + +#[test] +fn partial_coverage_mixes_ink_values() { + let mut d = doc(2, 1); + d.layers.push(paper(2, 1, [0.0, 0.0, 0.0, 0.0])); + let mut l = layer(&[(Rect::new(0, 0, 2, 1), [0.0, 0.0, 0.0, 1.0, 1.0])]); + l.opacity = 0.5; + l.fill_opacity = 0.5; + d.layers.push(l); + let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported")); + // 25% coverage of K100 over paper: K25 and no other ink. + assert!((got.px[0][3] - 0.25).abs() < 1e-6 && got.px[0][..3] == [0.0; 3], "{:?}", got.px[0]); +} + +#[test] +fn masks_groups_and_clipping_match_the_reference() { + let mut d = doc(8, 6); + d.layers.push(paper(8, 6, [0.1, 0.0, 0.0, 0.0])); + let mut base = layer(&[(Rect::new(1, 1, 7, 5), [0.0, 0.5, 0.0, 0.0, 0.8])]); + base.mask = Some(mask(&[(Rect::new(0, 0, 4, 6), 0.0)], 1.0, 0.75, true)); + let mut clip = layer(&[(Rect::new(0, 0, 8, 3), [0.0, 0.0, 1.0, 0.2, 1.0])]); + clip.clipped = true; + clip.opacity = 0.6; + let mut iso = Layer::group("iso", vec![layer(&[(Rect::new(2, 0, 5, 6), [0.3, 0.3, 0.3, 0.3, 0.5])])]); + iso.blend = BlendMode::Normal; + iso.opacity = 0.7; + iso.mask = Some(mask(&[(Rect::new(0, 3, 8, 6), 0.25)], 1.0, 1.0, true)); + let mut pass = Layer::group("pass", vec![layer(&[(Rect::new(5, 2, 8, 6), [1.0, 0.0, 0.0, 0.0, 1.0])])]); + pass.opacity = 0.5; + pass.mask = Some(mask(&[(Rect::new(6, 0, 8, 6), 0.0)], 1.0, 1.0, true)); + d.layers.extend([base, clip, iso, pass]); + assert_matches_reference(&d); +} + +#[test] +fn unsupported_documents_fall_back() { + let simple = || { + let mut d = doc(2, 2); + d.layers.push(layer(&[(Rect::new(0, 0, 2, 2), [0.0, 0.0, 0.0, 1.0, 1.0])])); + d + }; + assert!(supports(&simple())); + let check = |what: &str, f: &dyn Fn(&mut Layer)| { + let mut d = simple(); + let mut l = layer(&[(Rect::new(0, 0, 1, 1), [0.5; 5])]); + f(&mut l); + d.layers.push(l); + assert!(!supports(&d), "{what}"); + assert!(render_cmyk(&d, d.bounds()).is_none(), "{what}"); + // An invisible layer doesn't matter. + if let Some(l) = d.layers.last_mut() { + l.visible = false; + } + assert!(supports(&d), "hidden {what}"); + }; + check("multiply", &|l| l.blend = BlendMode::Multiply); + check("dissolve", &|l| l.blend = BlendMode::Dissolve); + check("knockout", &|l| l.advanced.knockout = Knockout::Shallow); + check("channels", &|l| l.excluded_channels = 1); + check("nan opacity", &|l| l.opacity = f32::NAN); + check("adjustment", &|l| l.content = LayerContent::Adjustment(Adjustment::Invert)); + check("rgb pixels", &|l| l.content = LayerContent::Raster(Surface::new(PixelFormat::RGBA8))); + // Not a CMYK document. + let mut rgb = simple(); + rgb.mode = ColorMode::Rgb; + assert!(!supports(&rgb)); + // Too deep: refused without recursing through every level. + let mut deep = layer(&[(Rect::new(0, 0, 1, 1), [0.5; 5])]); + for _ in 0..(MAX_DEPTH + 8) { + deep = Layer::group("g", vec![deep]); + } + let mut d = simple(); + d.layers.push(deep); + assert!(!supports(&d)); +} + +#[test] +fn non_finite_samples_never_reach_the_output() { + let fmt = PixelFormat { mode: ColorMode::Cmyk, sample: SampleType::F32, alpha: true }; + let mut d = Document::new("f", Size::new(4, 1), ColorMode::Cmyk, SampleType::F32); + let mut l = Layer::raster("bad", fmt); + if let Some(s) = l.surface_mut() { + s.write_region( + Rect::new(0, 0, 4, 1), + &[ + f32::NAN, + 0.0, + 0.0, + 0.0, + 1.0, // + 0.0, + f32::INFINITY, + 0.0, + 0.0, + 1.0, // + 0.0, + 0.0, + f32::NEG_INFINITY, + 0.0, + f32::NAN, // + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + ], + ); + } + d.layers.push(l); + let got = render_cmyk(&d, Rect::new(-2, -2, 6, 3)).unwrap_or_else(|| panic!("supported")); + assert!(got.px.iter().flatten().all(|v| v.is_finite()), "{:?}", got.px); +} + +#[test] +fn empty_and_off_canvas_rects() { + let mut d = doc(4, 4); + d.layers.push(layer(&[(Rect::new(0, 0, 4, 4), [0.0, 0.0, 0.0, 1.0, 1.0])])); + assert!(render_cmyk(&d, Rect::new(2, 2, 2, 2)).is_some_and(|b| b.px.is_empty())); + let far = render_cmyk(&d, Rect::new(1000, 1000, 1003, 1002)).unwrap_or_else(|| panic!("supported")); + assert_eq!(far.px, vec![[0.0; 5]; 6]); +} + +#[test] +fn bands_equal_the_whole_render() { + let mut d = doc(300, 700); + d.layers.push(paper(300, 700, [0.0, 0.1, 0.0, 0.0])); + d.layers.push(layer(&[(Rect::new(10, 20, 290, 690), [0.4, 0.0, 0.2, 0.9, 0.6])])); + let whole = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported")); + let mut joined = Vec::new(); + let r = render_cmyk_bands(&d, d.bounds(), 256, |b: CmykBuffer| -> Result<(), ()> { + joined.extend(b.px); + Ok(()) + }); + assert_eq!(r, Some(Ok(()))); + assert_eq!(joined, whole.px); +} + +// ---- random documents ------------------------------------------------------------------------- + +#[derive(Debug, Clone)] +struct Spec { + w: i32, + h: i32, + layers: Vec, +} + +#[derive(Debug, Clone)] +enum LayerSpec { + Pixels { fills: Vec<(Rect, Cmyka)>, opacity: f32, fill: f32, clipped: bool, visible: bool, mask: Option }, + Group { children: Vec, pass_through: bool, opacity: f32, fill: f32, mask: Option }, +} + +#[derive(Debug, Clone)] +struct MaskSpec { + rects: Vec<(Rect, f32)>, + default: f32, + density: f32, + enabled: bool, +} + +fn unit() -> impl Strategy { + prop_oneof![Just(0.0f32), Just(1.0f32), 0.0f32..=1.0] +} + +fn rect(w: i32, h: i32) -> impl Strategy { + (-1..w, -1..h, 1..w + 2, 1..h + 2).prop_map(|(x, y, rw, rh)| Rect::new(x, y, x + rw, y + rh)) +} + +fn mask_spec(w: i32, h: i32) -> impl Strategy> { + prop::option::of( + (prop::collection::vec((rect(w, h), unit()), 0..3), unit(), unit(), any::()).prop_map(|(rects, default, density, enabled)| MaskSpec { + rects, + default, + density, + enabled, + }), + ) +} + +fn pixels(w: i32, h: i32) -> impl Strategy { + ( + prop::collection::vec((rect(w, h), (unit(), unit(), unit(), unit(), unit())), 1..4), + unit(), + unit(), + any::(), + prop::bool::weighted(0.9), + mask_spec(w, h), + ) + .prop_map(|(fills, opacity, fill, clipped, visible, mask)| LayerSpec::Pixels { + fills: fills.into_iter().map(|(r, (c, m, y, k, a))| (r, [c, m, y, k, a])).collect(), + opacity, + fill, + clipped, + visible, + mask, + }) +} + +fn layer_spec(w: i32, h: i32) -> impl Strategy { + pixels(w, h).prop_recursive(3, 12, 4, move |inner| { + (prop::collection::vec(inner, 1..4), any::(), unit(), prop_oneof![Just(1.0f32), unit()], mask_spec(w, h)) + .prop_map(move |(children, pass_through, opacity, fill, mask)| LayerSpec::Group { children, pass_through, opacity, fill, mask }) + }) +} + +fn spec() -> impl Strategy { + (2i32..9, 2i32..7).prop_flat_map(|(w, h)| prop::collection::vec(layer_spec(w, h), 1..6).prop_map(move |layers| Spec { w, h, layers })) +} + +fn build(s: &LayerSpec) -> Layer { + let make_mask = |m: &MaskSpec| mask(&m.rects, m.default, m.density, m.enabled); + match s { + LayerSpec::Pixels { fills, opacity, fill, clipped, visible, mask } => { + let mut l = layer(fills); + (l.opacity, l.fill_opacity, l.clipped, l.visible) = (*opacity, *fill, *clipped, *visible); + l.mask = mask.as_ref().map(make_mask); + l + } + LayerSpec::Group { children, pass_through, opacity, fill, mask } => { + let mut g = Layer::group("g", children.iter().map(build).collect()); + g.blend = if *pass_through { BlendMode::PassThrough } else { BlendMode::Normal }; + (g.opacity, g.fill_opacity) = (*opacity, *fill); + g.mask = mask.as_ref().map(make_mask); + g + } + } +} + +/// Clipped layers onto a pass-through group take the RGB compositor's isolated-rendering path, +/// which this path leaves alone: such specs are filtered out. +fn clips_onto_pass_through(layers: &[LayerSpec]) -> bool { + layers.windows(2).any(|w| { + matches!(w[0], LayerSpec::Group { pass_through: true, fill, .. } if fill >= 1.0) + && matches!(w[1], LayerSpec::Pixels { clipped: true, visible: true, .. }) + }) || layers.iter().any(|l| matches!(l, LayerSpec::Group { children, .. } if clips_onto_pass_through(children))) +} + +proptest! { + #![proptest_config(ProptestConfig { cases: 400, ..ProptestConfig::default() })] + + /// Random stacks of pixel layers, masks, isolated and pass-through groups and clipping + /// groups: the native composite equals the independent per-pixel reference, and its + /// coverage equals the RGB compositor's. + #[test] + fn random_documents_match_the_reference(s in spec()) { + prop_assume!(!clips_onto_pass_through(&s.layers)); + let mut d = doc(s.w as u32, s.h as u32); + d.layers = s.layers.iter().map(build).collect(); + prop_assume!(supports(&d)); + assert_matches_reference(&d); + } + + /// Tiling never changes the result (tiles render independently, in any order). + #[test] + fn tiling_is_invisible(s in spec(), tile in 1i32..9) { + prop_assume!(!clips_onto_pass_through(&s.layers)); + let mut d = doc(s.w as u32, s.h as u32); + d.layers = s.layers.iter().map(build).collect(); + prop_assume!(supports(&d)); + let whole = render_cmyk_tiled(&d, d.bounds(), 1024); + prop_assert_eq!(render_cmyk_tiled(&d, d.bounds(), tile), whole); + } +} + +/// Where the composite is a single opaque layer's pixel (opaque, full opacity, binary masks), +/// the native ink, shown through the document's profile, is the colour the RGB compositor shows. +#[test] +fn opaque_results_look_the_same_as_the_rgb_compositor() { + let mut d = doc(8, 4); + d.layers.push(paper(8, 4, [0.0, 0.0, 0.0, 0.0])); + d.layers.push(layer(&[(Rect::new(0, 0, 4, 4), [0.0, 0.0, 0.0, 1.0, 1.0]), (Rect::new(4, 0, 8, 2), [0.7, 0.1, 0.0, 0.0, 1.0])])); + let mut top = layer(&[(Rect::new(2, 1, 7, 4), [0.0, 0.9, 0.9, 0.0, 1.0])]); + top.mask = Some(mask(&[(Rect::new(5, 0, 8, 4), 0.0)], 1.0, 1.0, true)); + d.layers.push(top); + let native = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported")); + let rgb = crate::render(&d, d.bounds()); + let space = crate::cmyk_space(&d); + let fmt = PixelFormat { mode: ColorMode::Cmyk, sample: SampleType::F32, alpha: true }; + photocraft_color::convert::with_cmyk_space(space.as_ref(), || { + for (n, r) in native.px.iter().zip(&rgb.px) { + let shown = photocraft_raster::to_rgba(&fmt, n); + assert!((0..4).all(|c| (shown[c] - r[c]).abs() <= 1e-4), "native {n:?} shows {shown:?}, RGB compositor {r:?}"); + } + }); +} diff --git a/crates/compose/src/lib.rs b/crates/compose/src/lib.rs index 712033e546..c9419e82b7 100644 --- a/crates/compose/src/lib.rs +++ b/crates/compose/src/lib.rs @@ -19,6 +19,7 @@ pub mod adjust; pub mod advanced; pub mod bounds; +pub mod cmyk; pub mod effects; pub mod fill_layout; pub mod gradient_fill; diff --git a/crates/io/src/flat.rs b/crates/io/src/flat.rs index a64af9c71d..c6529c6fd3 100644 --- a/crates/io/src/flat.rs +++ b/crates/io/src/flat.rs @@ -275,14 +275,20 @@ pub fn document_to_image(doc: &Document, warnings: &mut Vec) -> Result) -> Result) -> Result<(Vec, bool), IoError> { + let mut data = try_buffer(n, 5 * cs.bytes())?; + let mut opaque = true; + let put = |out: &mut Vec, v: f32| { + let v = if v.is_finite() { v } else { 0.0 }; + match cs { + CSample::U8 => out.push((v.clamp(0.0, 1.0) * 255.0).round() as u8), + CSample::U16 => out.extend_from_slice(&((v.clamp(0.0, 1.0) * 65535.0).round() as u16).to_ne_bytes()), + CSample::F16 | CSample::F32 => out.extend_from_slice(&v.to_ne_bytes()), + } + }; + let native = photocraft_compose::cmyk::render_cmyk_bands(doc, canvas, 0, |band| -> Result<(), ()> { + opaque &= band.px.iter().all(|p| p[4] >= 1.0); + let parts = crate::pixels::par_map(crate::pixels::bands(band.px.len()), |range| { + let mut out = Vec::with_capacity(range.len() * 5 * cs.bytes()); + for p in band.px.get(range).unwrap_or_default() { + for v in p { + put(&mut out, *v); + } + } + out + }); + for part in parts { + data.extend_from_slice(&part); + } + Ok(()) + }); + if native.is_none() { + // Through RGB and back: the colour model is kept, exact ink values are not. + warnings.push("CMYK composite converted back through the document's CMYK profile; ink values can differ from the layers'".to_string()); + let space = photocraft_compose::cmyk_space(doc); + let to = PixelFormat::new(ColorMode::Cmyk, SampleType::F32, true); + let _ = photocraft_compose::render_bands(doc, canvas, 0, |band| -> Result<(), ()> { + opaque &= band.px.iter().all(|p| p[3] >= 1.0); + let parts = crate::pixels::par_map(crate::pixels::bands(band.px.len()), |range| { + // The composite came through the document's CMYK profile: convert back through it. + photocraft_color::convert::with_cmyk_space(space.as_ref(), || { + let mut out = Vec::with_capacity(range.len() * 5 * cs.bytes()); + let mut v = [0.0f32; 5]; + for p in band.px.get(range).unwrap_or_default() { + photocraft_raster::from_rgba_into(&to, *p, &mut v); + for x in v { + put(&mut out, x); + } + } + out + }) + }); + for part in parts { + data.extend_from_slice(&part); + } + Ok(()) + }); + } + if opaque { + drop_alpha(&mut data, 4 * cs.bytes(), cs.bytes()); + } + Ok((data, opaque)) +} + /// An empty buffer with room for `pixels × bytes_per_pixel` bytes, or an error (not an abort) /// when that much memory can't be had. pub(crate) fn try_buffer(pixels: usize, bytes_per_pixel: usize) -> Result, IoError> { diff --git a/crates/io/tests/cmyk_export.rs b/crates/io/tests/cmyk_export.rs new file mode 100644 index 0000000000..44ecc4bba8 --- /dev/null +++ b/crates/io/tests/cmyk_export.rs @@ -0,0 +1,131 @@ +//! A CMYK document is written to flat formats as CMYK with its own profile whatever its layers +//! (#2220), mixing Normal pixel layers on their ink values so opaque pixels keep their exact inks. + +use std::sync::Arc; + +use photocraft_cms::Builtin; +use photocraft_codecs::ChannelLayout; +use photocraft_color::{BlendMode, ColorMode, PixelFormat, SampleType}; +use photocraft_doc::{Document, Layer}; +use photocraft_geom::{Rect, Size}; +use photocraft_io::*; + +fn cmyk_doc(depth: SampleType) -> Document { + let mut d = Document::new("c", Size::new(12, 8), ColorMode::Cmyk, depth); + d.icc_profile = Some(Arc::new(Builtin::CoatedCmyk.profile().to_bytes().to_vec())); + d +} + +fn fill(depth: SampleType, alpha: bool, rects: &[(Rect, [f32; 5])]) -> Layer { + let mut l = Layer::raster("l", PixelFormat::new(ColorMode::Cmyk, depth, alpha)); + if let Some(s) = l.surface_mut() { + for (r, c) in rects { + s.fill_rect(*r, &c[..if alpha { 5 } else { 4 }]); + } + } + l +} + +/// Paper (no ink), K-only black "type", and a four-colour patch, as separate layers. +fn layered(depth: SampleType) -> Document { + let mut d = cmyk_doc(depth); + d.layers.push(fill(depth, false, &[(Rect::new(0, 0, 12, 8), [0.0; 5])])); + d.layers.push(fill(depth, true, &[(Rect::new(0, 0, 6, 8), [0.0, 0.0, 0.0, 1.0, 1.0])])); + d.layers.push(fill(depth, true, &[(Rect::new(6, 0, 12, 4), [0.2, 0.4, 0.6, 0.1, 1.0])])); + d +} + +fn decode(bytes: &[u8]) -> photocraft_codecs::Image { + photocraft_codecs::decode(bytes).unwrap_or_else(|e| panic!("decode: {e}")) +} + +/// Normalized C, M, Y, K (and alpha) of pixel (x, y). +fn pixel(img: &photocraft_codecs::Image, x: u32, y: u32) -> Vec { + let n = img.layout().channels(); + let (w, _) = img.dimensions(); + let v = img.to_normalized(); + let i = ((y * w + x) as usize) * n; + v[i..i + n].to_vec() +} + +fn q8(v: f32) -> f32 { + (v * 255.0).round() / 255.0 +} + +#[test] +fn layered_cmyk_tiff_stays_cmyk_with_the_document_profile_and_exact_inks() { + for depth in [SampleType::U8, SampleType::U16, SampleType::F32] { + let d = layered(depth); + let r = export(&d, "a.tif", &ExportOptions::default()).unwrap_or_else(|e| panic!("{depth:?}: {e}")); + assert!(!r.warnings.iter().any(|w| w.contains("written as sRGB") || w.contains("converted back")), "{depth:?}: {:?}", r.warnings); + let img = decode(&r.bytes); + assert_eq!(img.layout(), ChannelLayout::Cmyk, "{depth:?}: opaque CMYK, no alpha"); + assert_eq!(img.icc.as_deref(), d.icc_profile.as_deref().map(|v| &v[..]), "{depth:?}: the document's own profile"); + // Exact inks: K-only black stays K-only, the four-colour patch keeps every ink, paper stays blank. + let (k, rich, paper) = (pixel(&img, 2, 3), pixel(&img, 8, 1), pixel(&img, 8, 6)); + let tol = if depth == SampleType::U8 { 0.0 } else { 1e-4 }; + let close = |a: &[f32], b: [f32; 4]| a.iter().zip(b).all(|(x, y)| (x - y).abs() <= tol); + let want_rich = if depth == SampleType::U8 { [q8(0.2), q8(0.4), q8(0.6), q8(0.1)] } else { [0.2, 0.4, 0.6, 0.1] }; + assert!(close(&k, [0.0, 0.0, 0.0, 1.0]), "{depth:?}: {k:?}"); + assert!(close(&rich, want_rich), "{depth:?}: {rich:?}"); + assert!(close(&paper, [0.0; 4]), "{depth:?}: {paper:?}"); + // And it reads back as a CMYK document. + let back = import("a.tif", &r.bytes).unwrap_or_else(|e| panic!("{e}")).document; + assert_eq!(back.mode, ColorMode::Cmyk, "{depth:?}"); + } +} + +#[test] +fn the_reported_case_an_empty_extra_layer() { + // #2220: one layer converted to CMYK plus an empty layer used to export as RGB. + let mut d = cmyk_doc(SampleType::U8); + d.layers.push(fill(SampleType::U8, false, &[(Rect::new(0, 0, 12, 8), [0.3, 0.2, 0.1, 0.0, 1.0])])); + d.layers.push(Layer::raster("empty", PixelFormat::new(ColorMode::Cmyk, SampleType::U8, true))); + for ext in ["tif", "jpg"] { + let r = export(&d, &format!("a.{ext}"), &ExportOptions::default()).unwrap_or_else(|e| panic!("{ext}: {e}")); + assert_eq!(decode(&r.bytes).layout(), ChannelLayout::Cmyk, "{ext}"); + } +} + +#[test] +fn transparency_is_kept_in_tiff_and_composited_over_paper_in_jpeg() { + let mut d = cmyk_doc(SampleType::U8); + d.layers.push(fill(SampleType::U8, true, &[(Rect::new(0, 0, 6, 8), [0.0, 0.0, 0.0, 1.0, 1.0])])); + d.layers.push(fill(SampleType::U8, true, &[(Rect::new(6, 0, 12, 4), [0.0, 1.0, 0.0, 0.0, 0.5])])); + let tif = decode(&export(&d, "a.tif", &ExportOptions::default()).unwrap_or_else(|e| panic!("{e}")).bytes); + assert_eq!(tif.layout(), ChannelLayout::CmykA); + assert_eq!(pixel(&tif, 8, 1), vec![0.0, 1.0, 0.0, 0.0, q8(0.5)], "straight ink and coverage"); + assert_eq!(pixel(&tif, 8, 6)[4], 0.0, "uncovered stays transparent"); + let r = export(&d, "a.jpg", &ExportOptions::default()).unwrap_or_else(|e| panic!("{e}")); + let jpg = decode(&r.bytes); + assert_eq!(jpg.layout(), ChannelLayout::Cmyk, "{:?}", r.warnings); + // JPEG is lossy: half-covered magenta over blank paper is about M50; uncovered paper has no ink. + let (half, blank, k) = (pixel(&jpg, 9, 1), pixel(&jpg, 9, 6), pixel(&jpg, 2, 3)); + assert!((half[1] - 0.5).abs() < 0.06 && half[0] < 0.06 && half[3] < 0.06, "{half:?}"); + assert!(blank.iter().all(|v| *v < 0.06), "{blank:?}"); + assert!(k[3] > 0.94 && k[..3].iter().all(|v| *v < 0.06), "{k:?}"); +} + +#[test] +fn other_stacks_stay_cmyk_through_the_profile() { + // A Multiply layer isn't composited on ink values (yet): the RGB composite is converted back. + let mut d = layered(SampleType::U8); + let mut m = fill(SampleType::U8, true, &[(Rect::new(0, 0, 12, 8), [0.0, 0.5, 0.0, 0.0, 1.0])]); + m.blend = BlendMode::Multiply; + d.layers.push(m); + let r = export(&d, "a.tif", &ExportOptions::default()).unwrap_or_else(|e| panic!("{e}")); + assert!(r.warnings.iter().any(|w| w.contains("converted back through the document's CMYK profile")), "{:?}", r.warnings); + let img = decode(&r.bytes); + assert_eq!(img.layout(), ChannelLayout::Cmyk); + assert_eq!(img.icc.as_deref(), d.icc_profile.as_deref().map(|v| &v[..])); + // Multiplying magenta over paper adds magenta ink; it doesn't empty the page. + assert!(pixel(&img, 8, 6)[1] > 0.3, "{:?}", pixel(&img, 8, 6)); +} + +#[test] +fn rgb_only_formats_still_get_rgb_through_the_profile() { + let r = export(&layered(SampleType::U8), "a.png", &ExportOptions::default()).unwrap_or_else(|e| panic!("{e}")); + let img = decode(&r.bytes); + assert!(matches!(img.layout(), ChannelLayout::Rgb | ChannelLayout::Rgba), "{:?}", img.layout()); + assert!(r.warnings.iter().any(|w| w.contains("CMYK converted to sRGB")), "{:?}", r.warnings); +} From 46c78f82fbddf2411afc01e5cca40acbe24580b7 Mon Sep 17 00:00:00 2001 From: SBaksa Date: Sun, 11 Oct 2026 02:01:43 +1100 Subject: [PATCH 017/649] CMYK compositing: type, shape, smart object and fill layers on their ink values Stage 2 of mode-native CMYK compositing (#2220). Type, shape and smart object layers are composited natively through their rendered pixels, which are drawn in the document's model (a colour given in CMYK is drawn with exactly those inks). Fill layers use the pixels they were rendered to when they carry them (as PSDs supply them), and otherwise the compositor's own CMYK rendering at the document's depth (solid colours and gradient ramps, #2628). Type layers mix their edges in the compositor's text gamma, on brightness (1 - ink), so K-only type gains no cyan, magenta or yellow at its edges; covered pixels, and channels both sides agree on, keep their exact inks instead of taking the gamma round trip. Still on the RGB compositor: pattern fills without rendered pixels, and stroked shapes with visible clipped layers. --- crates/compose/src/cmyk.rs | 110 +++++++++++++++--- crates/compose/src/cmyk_tests.rs | 188 +++++++++++++++++++++++++++++-- 2 files changed, 273 insertions(+), 25 deletions(-) diff --git a/crates/compose/src/cmyk.rs b/crates/compose/src/cmyk.rs index c97b27d4e2..281ff72294 100644 --- a/crates/compose/src/cmyk.rs +++ b/crates/compose/src/cmyk.rs @@ -3,10 +3,13 @@ //! and back through the profile. //! //! This path covers the layer stacks whose blending is the same in every colour model: Normal -//! pixel layers with opacity, fill opacity and masks, isolated and pass-through groups, and -//! clipping groups. [`supports`] says whether a document stays on it; anything else (type, -//! shapes, fills, effects, adjustments, other blend modes, knockouts, channel restrictions, -//! Blend If) is left to the RGB compositor, whose result callers convert back to CMYK. +//! layers with opacity, fill opacity and masks (pixel, type, shape and smart object layers +//! through their rendered pixels, solid colour fills, and fills carrying their rendered pixels), +//! isolated and pass-through groups, and clipping groups. Type layers mix their edges in the +//! compositor's text gamma, on brightness. [`supports`] says whether a document stays on it; +//! anything else (gradient and pattern fills without rendered pixels, effects, adjustments, +//! other blend modes, knockouts, channel restrictions, Blend If) is left to the RGB compositor, +//! whose result callers convert back to CMYK. //! //! Buffers hold straight-alpha `[C, M, Y, K, A]` in 0..1 ink (0 = no ink). @@ -74,8 +77,22 @@ fn plain(l: &Layer) -> bool { && l.blend_if.is_default() } -fn cmyk_raster(l: &Layer) -> bool { - matches!(&l.content, LayerContent::Raster(s) if s.format().mode == ColorMode::Cmyk) +/// A layer whose own pixels this path reads in CMYK: pixel layers, and type, shape and smart +/// object layers through their rendered pixels (rendered in the document's model, so a colour +/// given in CMYK is drawn with exactly those inks); solid colour fills, and fills carrying the +/// pixels they were rendered to. Gradient and pattern fills without those pixels aren't. +fn cmyk_pixels(l: &Layer) -> bool { + let cmyk = |s: &photocraft_raster::Surface| s.format().mode == ColorMode::Cmyk; + match &l.content { + LayerContent::Raster(s) => cmyk(s), + LayerContent::Text(_) | LayerContent::Shape(_) | LayerContent::Smart(_) => l.surface().is_none_or(cmyk), + LayerContent::Fill(f) => match &l.fill_cache { + Some(c) if c.fill == *f => cmyk(&c.surface), + // Solid colours and gradients render natively in CMYK; patterns don't. + _ => !matches!(f, photocraft_doc::Fill::Pattern { .. }), + }, + _ => false, + } } fn layer_supported(l: &Layer, clipped: &[Layer], depth: u32) -> bool { @@ -83,7 +100,12 @@ fn layer_supported(l: &Layer, clipped: &[Layer], depth: u32) -> bool { return false; } let content = match &l.content { - LayerContent::Raster(_) => cmyk_raster(l) && l.blend == BlendMode::Normal, + // A stroked shape with clipped layers draws its stroke above them (the compositor's + // split path), which this path doesn't do. + LayerContent::Shape(sh) if sh.stroke.is_some() && clipped.iter().any(|c| c.visible) => false, + LayerContent::Raster(_) | LayerContent::Text(_) | LayerContent::Shape(_) | LayerContent::Smart(_) | LayerContent::Fill(_) => { + cmyk_pixels(l) && l.blend == BlendMode::Normal + } LayerContent::Group(g) => { g.artboard.is_none() && matches!(l.blend, BlendMode::Normal | BlendMode::PassThrough) @@ -93,7 +115,7 @@ fn layer_supported(l: &Layer, clipped: &[Layer], depth: u32) -> bool { } _ => false, }; - content && clipped.iter().filter(|c| c.visible).all(|c| plain(c) && cmyk_raster(c) && c.blend == BlendMode::Normal) + content && clipped.iter().filter(|c| c.visible).all(|c| plain(c) && cmyk_pixels(c) && c.blend == BlendMode::Normal) } /// A group whose children composite straight into the backdrop (the compositor's rule). @@ -126,10 +148,61 @@ fn clean(v: f32) -> f32 { if v.is_finite() { v } else { 0.0 } } -/// A CMYK pixel layer's own pixels over `rect`, masks applied. -fn raster_content(l: &Layer, rect: Rect, cx: &Ctx) -> CmykBuffer { +/// [`normal`] with coverage mixed in the type-layer `gamma` space (1 = plain [`normal`]), as +/// the compositor mixes type edges. The space is one of light, so inks are mixed as their +/// brightness (1 − ink); fully covered pixels are the source's inks exactly. +#[inline] +pub fn normal_gamma(backdrop: Cmyka, source: Cmyka, opacity: f32, gamma: f32) -> Cmyka { + if gamma == 1.0 { + return normal(backdrop, source, opacity); + } + let ab = backdrop[4]; + let as_ = source[4] * opacity; + if as_ <= 0.0 { + return backdrop; + } + let ao = as_ + ab * (1.0 - as_); + if ao <= 0.0 { + return [0.0; 5]; + } + // Normal: the blended colour is the source's, so its weight joins the source's. + let (wb, ws) = ((1.0 - as_) * ab / ao, as_ / ao); + let g = |ink: f32| super::psblend::text_encode(1.0 - ink, gamma); + // A covered pixel, or a channel both sides agree on, is exactly that ink: the round trip + // through the gamma space would only add rounding (K-only type would gain a trace of CMY). + let c = |i: usize| { + if wb <= 0.0 || backdrop[i] == source[i] { source[i] } else { 1.0 - super::psblend::text_decode(wb * g(backdrop[i]) + ws * g(source[i]), gamma) } + }; + [c(0), c(1), c(2), c(3), ao] +} + +/// A layer's own CMYK pixels over `rect` (see [`cmyk_pixels`]), masks applied. +fn layer_content(l: &Layer, rect: Rect, cx: &Ctx) -> CmykBuffer { let mut out = CmykBuffer::transparent(rect); - if let LayerContent::Raster(s) = &l.content { + let rendered; + let surface = match &l.content { + LayerContent::Fill(f) => match &l.fill_cache { + Some(c) if c.fill == *f => Some(&c.surface), + _ => { + // The compositor's own CMYK rendering of the fill, at the document's depth (a + // colour given in CMYK keeps its inks); a solid colour is one pixel, spread out. + let solid = matches!(f, photocraft_doc::Fill::Solid(_)); + let at = if solid { Rect::new(0, 0, 1, 1) } else { rect }; + rendered = super::gradient_fill::render_cmyk_fill(f, at, super::fill_frame(l, cx.canvas), cx.depth); + match &rendered { + Some(s) if solid => { + let p = s.pixel(0, 0); + let v = |i: usize| p.get(i).copied().map_or(0.0, clean); + out.px.fill([v(0), v(1), v(2), v(3), v(4)]); + None + } + r => r.as_ref(), + } + } + }, + _ => l.surface(), + }; + if let Some(s) = surface { let ch = s.format().channels(); let alpha = s.format().alpha; let mut v = Vec::new(); @@ -167,23 +240,24 @@ fn mask_at(m: &Option>, i: usize) -> f32 { /// the base keeps its alpha. fn composite_clipped(clipped: &[Layer], base: &mut CmykBuffer, cx: &Ctx) { for c in clipped.iter().filter(|c| c.visible) { - let content = raster_content(c, base.rect, cx); + let content = layer_content(c, base.rect, cx); let opacity = c.opacity * c.fill_opacity; + let gamma = super::text_gamma(c); for (p, s) in base.px.iter_mut().zip(&content.px) { let alpha = p[4]; if alpha <= 0.0 { continue; } - let r = normal([p[0], p[1], p[2], p[3], 1.0], *s, opacity); + let r = normal_gamma([p[0], p[1], p[2], p[3], 1.0], *s, opacity, gamma); *p = [r[0], r[1], r[2], r[3], alpha]; } } } -fn blend_into(backdrop: &mut CmykBuffer, src: &CmykBuffer, opacity: f32) { +fn blend_into(backdrop: &mut CmykBuffer, src: &CmykBuffer, opacity: f32, gamma: f32) { for (b, s) in backdrop.px.iter_mut().zip(&src.px) { if s[4] > 0.0 { - *b = normal(*b, *s, opacity); + *b = normal_gamma(*b, *s, opacity, gamma); } } } @@ -230,12 +304,12 @@ fn composite_layer(l: &Layer, clipped: &[Layer], backdrop: &mut CmykBuffer, cx: composite_stack(&g.children, &mut content, cx); apply_mask(l, &mut content, cx); composite_clipped(clipped, &mut content, cx); - blend_into(backdrop, &content, opacity); + blend_into(backdrop, &content, opacity, 1.0); return; } - let mut content = raster_content(l, rect, cx); + let mut content = layer_content(l, rect, cx); composite_clipped(clipped, &mut content, cx); - blend_into(backdrop, &content, opacity); + blend_into(backdrop, &content, opacity, super::text_gamma(l)); } fn render_tile(doc: &Document, rect: Rect, cx: &Ctx) -> CmykBuffer { diff --git a/crates/compose/src/cmyk_tests.rs b/crates/compose/src/cmyk_tests.rs index d9e25fded7..089c0a4245 100644 --- a/crates/compose/src/cmyk_tests.rs +++ b/crates/compose/src/cmyk_tests.rs @@ -71,12 +71,50 @@ fn ref_mask(l: &Layer, x: i32, y: i32) -> f32 { } fn ref_own(l: &Layer, x: i32, y: i32) -> Cmyka { - let Some(s) = l.surface() else { return [0.0; 5] }; + let s = match &l.content { + LayerContent::Fill(f) => match &l.fill_cache { + Some(c) if c.fill == *f => Some(&c.surface), + _ => { + // A solid colour's inks and alpha, stored at the (8-bit) document's levels. + let photocraft_doc::Fill::Solid(color) = f else { return [0.0; 5] }; + let c = color.in_mode(ColorMode::Cmyk); + return [q(c.c[0]), q(c.c[1]), q(c.c[2]), q(c.c[3]), q(color.alpha) * ref_mask(l, x, y)]; + } + }, + _ => l.surface(), + }; + let Some(s) = s else { return [0.0; 5] }; let p = s.pixel(x, y); let a = if s.format().alpha { p[4] } else { 1.0 }; [p[0], p[1], p[2], p[3], a * ref_mask(l, x, y)] } +/// Source-over with coverage mixed in the type gamma, on brightness (1 − ink), worked out from +/// the colour transfer functions directly. +fn over_text(b: Cmyka, s: Cmyka, opacity: f32) -> Cmyka { + let gamma = crate::psblend::text_gamma(); + let sa = s[4] * opacity; + if sa <= 0.0 { + return b; + } + let a = sa + b[4] * (1.0 - sa); + if a <= 0.0 { + return [0.0; 5]; + } + let enc = |ink: f32| photocraft_color::convert::srgb_to_linear((1.0 - ink).max(0.0)).powf(1.0 / gamma); + let dec = |v: f32| 1.0 - photocraft_color::convert::linear_to_srgb(v.max(0.0).powf(gamma)); + let mut o = [0.0; 5]; + for i in 0..4 { + o[i] = dec((1.0 - sa) * b[4] / a * enc(b[i]) + sa / a * enc(s[i])); + } + o[4] = a; + o +} + +fn over_layer(l: &Layer, b: Cmyka, s: Cmyka, opacity: f32) -> Cmyka { + if matches!(l.content, LayerContent::Text(_)) { over_text(b, s, opacity) } else { over(b, s, opacity) } +} + fn ref_stack(layers: &[Layer], x: i32, y: i32, mut b: Cmyka) -> Cmyka { let mut i = 0; while i < layers.len() { @@ -124,11 +162,11 @@ fn ref_layer(l: &Layer, clipped: &[Layer], x: i32, y: i32, b: Cmyka) -> Cmyka { for c in clipped.iter().filter(|c| c.visible) { if content[4] > 0.0 { let a = content[4]; - let r = over([content[0], content[1], content[2], content[3], 1.0], ref_own(c, x, y), c.opacity * c.fill_opacity); + let r = over_layer(c, [content[0], content[1], content[2], content[3], 1.0], ref_own(c, x, y), c.opacity * c.fill_opacity); content = [r[0], r[1], r[2], r[3], a]; } } - over(b, content, op) + over_layer(l, b, content, op) } fn assert_matches_reference(d: &Document) { @@ -315,10 +353,20 @@ struct Spec { #[derive(Debug, Clone)] enum LayerSpec { - Pixels { fills: Vec<(Rect, Cmyka)>, opacity: f32, fill: f32, clipped: bool, visible: bool, mask: Option }, + Pixels { kind: Kind, fills: Vec<(Rect, Cmyka)>, opacity: f32, fill: f32, clipped: bool, visible: bool, mask: Option }, Group { children: Vec, pass_through: bool, opacity: f32, fill: f32, mask: Option }, } +/// What kind of layer a [`LayerSpec::Pixels`] becomes: its pixels as a pixel layer, as a type or +/// shape layer's rendered pixels, or a solid colour fill in the first fill's colour. +#[derive(Debug, Clone, Copy)] +enum Kind { + Raster, + Text, + Shape, + Solid, +} + #[derive(Debug, Clone)] struct MaskSpec { rects: Vec<(Rect, f32)>, @@ -354,8 +402,10 @@ fn pixels(w: i32, h: i32) -> impl Strategy { any::(), prop::bool::weighted(0.9), mask_spec(w, h), + prop_oneof![Just(Kind::Raster), Just(Kind::Text), Just(Kind::Shape), Just(Kind::Solid)], ) - .prop_map(|(fills, opacity, fill, clipped, visible, mask)| LayerSpec::Pixels { + .prop_map(|(fills, opacity, fill, clipped, visible, mask, kind)| LayerSpec::Pixels { + kind, fills: fills.into_iter().map(|(r, (c, m, y, k, a))| (r, [c, m, y, k, a])).collect(), opacity, fill, @@ -379,8 +429,18 @@ fn spec() -> impl Strategy { fn build(s: &LayerSpec) -> Layer { let make_mask = |m: &MaskSpec| mask(&m.rects, m.default, m.density, m.enabled); match s { - LayerSpec::Pixels { fills, opacity, fill, clipped, visible, mask } => { - let mut l = layer(fills); + LayerSpec::Pixels { kind, fills, opacity, fill, clipped, visible, mask } => { + let pixels = layer(fills); + let mut l = match kind { + Kind::Raster => pixels, + Kind::Text => Layer::new("t", LayerContent::Text(photocraft_doc::TextLayer { cache: pixels.surface().cloned(), ..Default::default() })), + Kind::Shape => Layer::new("s", LayerContent::Shape(photocraft_doc::ShapeLayer { cache: pixels.surface().cloned(), ..Default::default() })), + Kind::Solid => { + let [c, m, y, k, a] = fills.first().map_or([0.0; 5], |f| f.1); + let color = photocraft_color::Color { mode: ColorMode::Cmyk, c: [c, m, y, k], alpha: a }; + Layer::new("f", LayerContent::Fill(photocraft_doc::Fill::Solid(color))) + } + }; (l.opacity, l.fill_opacity, l.clipped, l.visible) = (*opacity, *fill, *clipped, *visible); l.mask = mask.as_ref().map(make_mask); l @@ -452,3 +512,117 @@ fn opaque_results_look_the_same_as_the_rgb_compositor() { } }); } + +// ---- stage 2: type, shape, smart object and fill layers ---------------------------------------- + +fn text_layer(rects: &[(Rect, Cmyka)]) -> Layer { + let cache = layer(rects).surface().cloned(); + Layer::new("t", LayerContent::Text(photocraft_doc::TextLayer { cache, ..Default::default() })) +} + +fn cmyk_color(c: [f32; 4], alpha: f32) -> photocraft_color::Color { + photocraft_color::Color { mode: ColorMode::Cmyk, c, alpha } +} + +/// K-only type keeps K-only glyphs: fully covered pixels are exactly K100, and anti-aliased edges +/// mix on brightness in the type gamma, adding no cyan, magenta or yellow. +#[test] +fn type_interiors_are_exact_and_edges_add_no_other_ink() { + let mut d = doc(3, 1); + d.layers.push(paper(3, 1, [0.0; 4])); + d.layers.push(text_layer(&[(Rect::new(0, 0, 1, 1), [0.0, 0.0, 0.0, 1.0, 1.0]), (Rect::new(1, 0, 2, 1), [0.0, 0.0, 0.0, 1.0, 0.5])])); + let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported")); + assert_eq!(got.px[0], [0.0, 0.0, 0.0, 1.0, 1.0], "glyph interior"); + let edge = got.px[1]; + assert_eq!(edge[..3], [0.0; 3], "an edge adds no CMY: {edge:?}"); + let want = over_text([0.0, 0.0, 0.0, 0.0, 1.0], [0.0, 0.0, 0.0, 1.0, q(0.5)], 1.0); + assert!((edge[3] - want[3]).abs() < 1e-6, "{edge:?} vs {want:?}"); + // The gamma lightens dark edges compared with plain mixing. + assert!(edge[3] < q(0.5), "{edge:?}"); + assert_eq!(got.px[2], [0.0, 0.0, 0.0, 0.0, 1.0], "paper"); +} + +#[test] +fn solid_and_rendered_fills_keep_their_inks() { + let mut d = doc(4, 1); + d.layers.push(paper(4, 1, [0.0; 4])); + let mut solid = Layer::new("f", LayerContent::Fill(photocraft_doc::Fill::Solid(cmyk_color([0.1, 0.2, 0.3, 0.4], 1.0)))); + solid.mask = Some(mask(&[(Rect::new(2, 0, 4, 1), 0.0)], 1.0, 1.0, true)); + d.layers.push(solid); + // A gradient fill carrying the pixels it was rendered to (as a PSD supplies them). + let gradient = photocraft_doc::Fill::gradient( + vec![(0.0, cmyk_color([1.0, 0.0, 0.0, 0.0], 1.0)), (1.0, cmyk_color([0.0, 0.0, 0.0, 1.0], 1.0))], + 0.0, + 1.0, + Default::default(), + false, + ); + let rendered = layer(&[(Rect::new(3, 0, 4, 1), [0.9, 0.0, 0.5, 0.0, 1.0])]); + let mut cached = Layer::new("g", LayerContent::Fill(gradient.clone())); + cached.fill_cache = rendered.surface().map(|s| photocraft_doc::FillCache { fill: gradient, surface: s.clone() }); + d.layers.push(cached); + let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported")); + assert_eq!(got.px[0], [q(0.1), q(0.2), q(0.3), q(0.4), 1.0], "the colour's own inks, at the document's levels"); + assert_eq!(got.px[2], [0.0, 0.0, 0.0, 0.0, 1.0], "masked out: paper"); + assert_eq!(got.px[3], [q(0.9), 0.0, q(0.5), 0.0, 1.0], "the fill's rendered pixels"); + assert_matches_reference(&d); +} + +#[test] +fn stage_two_layers_that_stay_on_the_rgb_compositor() { + let base = || { + let mut d = doc(2, 2); + d.layers.push(paper(2, 2, [0.0; 4])); + d + }; + // A pattern fill without rendered pixels. + let mut d = base(); + let p = photocraft_doc::Fill::Pattern { name: "p".into(), scale: 1.0, id: "p".into(), angle: 0.0, link: true, phase: (0.0, 0.0) }; + d.layers.push(Layer::new("p", LayerContent::Fill(p))); + assert!(!supports(&d), "uncached pattern fill"); + // Type rendered in RGB (not the document's model). + let mut d = base(); + let mut rgb = Layer::raster("x", PixelFormat::RGBA8); + if let Some(s) = rgb.surface_mut() { + s.fill_rect(Rect::new(0, 0, 1, 1), &[0.0, 0.0, 0.0, 1.0]); + } + d.layers.push(Layer::new("t", LayerContent::Text(photocraft_doc::TextLayer { cache: rgb.surface().cloned(), ..Default::default() }))); + assert!(!supports(&d), "RGB type pixels"); + // A stroked shape with a clipped layer (its stroke goes above the clipped layers). + let mut d = base(); + let shape = photocraft_doc::ShapeLayer { stroke: Some(Default::default()), cache: layer(&[]).surface().cloned(), ..Default::default() }; + d.layers.push(Layer::new("s", LayerContent::Shape(shape))); + let mut clip = layer(&[(Rect::new(0, 0, 2, 2), [0.5; 5])]); + clip.clipped = true; + d.layers.push(clip); + assert!(!supports(&d), "stroked shape with clipped layers"); + if let Some(c) = d.layers.last_mut() { + c.visible = false; + } + assert!(supports(&d), "without a visible clipped layer the stroked shape is plain pixels"); +} + +/// A gradient fill without rendered pixels is the compositor's own CMYK ramp: between cyan and +/// black it holds only those two inks, pixel for pixel as the compositor renders it. +#[test] +fn uncached_gradient_fills_are_cmyk_ramps() { + let mut d = doc(8, 2); + let g = photocraft_doc::Fill::gradient( + vec![(0.0, cmyk_color([1.0, 0.0, 0.0, 0.0], 1.0)), (1.0, cmyk_color([0.0, 0.0, 0.0, 1.0], 1.0))], + 0.0, + 1.0, + Default::default(), + false, + ); + d.layers.push(Layer::new("g", LayerContent::Fill(g.clone()))); + assert!(supports(&d)); + let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported")); + let frame = crate::fill_frame(&d.layers[0], d.bounds()); + let want = crate::gradient_fill::render_cmyk_fill(&g, d.bounds(), frame, SampleType::U8).unwrap_or_else(|| panic!("ramp")); + for (i, p) in got.px.iter().enumerate() { + let (x, y) = ((i % 8) as i32, (i / 8) as i32); + assert_eq!(p[1..3], [0.0, 0.0], "only cyan and black: {p:?}"); + assert_eq!(p.to_vec(), want.pixel(x, y), "({x},{y})"); + } + assert!(got.px[0][0] > got.px[7][0] && got.px[0][3] < got.px[7][3], "cyan to black"); +} From b6567bc37513883928f3f9c00ccebccacbfeb0c1 Mon Sep 17 00:00:00 2001 From: SBaksa Date: Sun, 11 Oct 2026 12:13:14 +1100 Subject: [PATCH 018/649] CMYK compositing: per-channel blend modes on ink values Every blend mode that works channel by channel (Multiply, Screen, the burns and dodges, the lights, Difference, Exclusion, Subtract, Divide, Dissolve and the rest) now mixes CMYK layers on their ink values: the mode acts on each ink's brightness, as the RGB compositor does on each channel, so K-only black under a Multiply layer stays K-only. For the special eight, Fill below 100% is part of the blend as on the RGB compositor (#2552). Modes that mix channels (Hue, Saturation, Color, Luminosity, Darker/Lighter Color) still composite in RGB and convert back through the document profile. Normal mixing onto nothing gives the source's ink exactly: a rounding error there (1 -> 0.99999994) was magnified by modes that jump at full ink, Reflect turning no ink into full K. --- crates/compose/src/cmyk.rs | 160 +++++++++++++++-- crates/compose/src/cmyk_tests.rs | 284 +++++++++++++++++++++++++++++-- crates/io/tests/cmyk_export.rs | 29 +++- 3 files changed, 436 insertions(+), 37 deletions(-) diff --git a/crates/compose/src/cmyk.rs b/crates/compose/src/cmyk.rs index 281ff72294..a457557dc2 100644 --- a/crates/compose/src/cmyk.rs +++ b/crates/compose/src/cmyk.rs @@ -2,14 +2,17 @@ //! pixels keep their exact inks (K-only black stays K-only) instead of going through display RGB //! and back through the profile. //! -//! This path covers the layer stacks whose blending is the same in every colour model: Normal -//! layers with opacity, fill opacity and masks (pixel, type, shape and smart object layers -//! through their rendered pixels, solid colour fills, and fills carrying their rendered pixels), -//! isolated and pass-through groups, and clipping groups. Type layers mix their edges in the +//! This path covers the layer stacks whose blending is per channel, so it means the same on ink +//! values as on display colour: every blend mode except the ones that mix channels (Hue, +//! Saturation, Color, Luminosity, Darker Color, Lighter Color), with opacity, fill opacity and +//! masks (pixel, type, shape and smart object layers through their rendered pixels, solid colour +//! fills, and fills carrying their rendered pixels), isolated and pass-through groups, and +//! clipping groups. Blend modes act on each ink's brightness (1 − ink), as the RGB compositor's +//! do on each channel, and Dissolve uses the same noise. Type layers mix their edges in the //! compositor's text gamma, on brightness. [`supports`] says whether a document stays on it; //! anything else (gradient and pattern fills without rendered pixels, effects, adjustments, -//! other blend modes, knockouts, channel restrictions, Blend If) is left to the RGB compositor, -//! whose result callers convert back to CMYK. +//! channel-mixing blend modes, knockouts, channel restrictions, Blend If) is left to the RGB +//! compositor, whose result callers convert back to CMYK. //! //! Buffers hold straight-alpha `[C, M, Y, K, A]` in 0..1 ink (0 = no ink). @@ -104,18 +107,18 @@ fn layer_supported(l: &Layer, clipped: &[Layer], depth: u32) -> bool { // split path), which this path doesn't do. LayerContent::Shape(sh) if sh.stroke.is_some() && clipped.iter().any(|c| c.visible) => false, LayerContent::Raster(_) | LayerContent::Text(_) | LayerContent::Shape(_) | LayerContent::Smart(_) | LayerContent::Fill(_) => { - cmyk_pixels(l) && l.blend == BlendMode::Normal + cmyk_pixels(l) && separable(l.blend) } LayerContent::Group(g) => { g.artboard.is_none() - && matches!(l.blend, BlendMode::Normal | BlendMode::PassThrough) + && (separable(l.blend) || l.blend == BlendMode::PassThrough) // A pass-through group with clipped layers mixes them through its isolated rendering. && !(passes_through(l) && clipped.iter().any(|c| c.visible)) && stack_supported(&g.children, depth + 1) } _ => false, }; - content && clipped.iter().filter(|c| c.visible).all(|c| plain(c) && cmyk_pixels(c) && c.blend == BlendMode::Normal) + content && clipped.iter().filter(|c| c.visible).all(|c| plain(c) && cmyk_pixels(c) && separable(c.blend)) } /// A group whose children composite straight into the backdrop (the compositor's rule). @@ -138,7 +141,99 @@ pub fn normal(backdrop: Cmyka, source: Cmyka, opacity: f32) -> Cmyka { } let kb = ab * (1.0 - as_); let inv = 1.0 / ao; - let c = |i: usize| (kb * backdrop[i] + as_ * source[i]) * inv; + // Over nothing, or where both sides agree, the result is exactly the source's ink (the mix + // would only add rounding, which modes that jump at 0 or 1 ink could magnify). + let c = |i: usize| if kb <= 0.0 || backdrop[i] == source[i] { source[i] } else { (kb * backdrop[i] + as_ * source[i]) * inv }; + [c(0), c(1), c(2), c(3), ao] +} + +/// Blend modes that work channel by channel, which this path applies to each ink (the others +/// mix the channels together: hue, saturation, colour, luminosity, darker and lighter colour). +pub fn separable(mode: BlendMode) -> bool { + !matches!( + mode, + BlendMode::PassThrough + | BlendMode::Hue + | BlendMode::Saturation + | BlendMode::Color + | BlendMode::Luminosity + | BlendMode::DarkerColor + | BlendMode::LighterColor + ) +} + +/// The blended inks of a separable `mode`: the compositor's blend function applied to each +/// channel's brightness (1 − ink), as CMYK channels are blended, so Multiply adds ink and Screen +/// takes it away. +pub fn blend_ink(mode: BlendMode, cb: [f32; 4], cs: [f32; 4]) -> [f32; 4] { + let b = |i: usize| 1.0 - cb[i]; + let s = |i: usize| 1.0 - cs[i]; + let cmy = super::psblend::blend_rgb(mode, [b(0), b(1), b(2)], [s(0), s(1), s(2)]); + let k = super::psblend::blend_rgb(mode, [b(3); 3], [s(3); 3]); + [1.0 - cmy[0], 1.0 - cmy[1], 1.0 - cmy[2], 1.0 - k[0]] +} + +/// [`composite_ink`] for a layer with separate `opacity` and `fill`, as the RGB compositor's +/// `psblend::composite_fill` does on each channel: for the special eight below 100% Fill the +/// source is blended at full strength pulled toward the mode's neutral colour +/// (`psblend::blend_rgb_fill`, on each ink's brightness), with Opacity as its coverage over the +/// backdrop; over transparency Fill stays coverage. +pub fn composite_ink_fill(mode: BlendMode, backdrop: Cmyka, source: Cmyka, opacity: f32, fill: f32, gamma: f32) -> Cmyka { + let f = fill.clamp(0.0, 1.0); + if f >= 1.0 || !super::psblend::fill_is_special(mode) { + return composite_ink(mode, backdrop, source, opacity * f, gamma); + } + let ab = backdrop[4]; + let over = source[4] * opacity; + let alone = over * f; + if over <= 0.0 { + return backdrop; + } + let ao = ab + (1.0 - ab) * alone; + if ao <= 0.0 { + return [0.0; 5]; + } + let b = |i: usize| 1.0 - backdrop[i]; + let s = |i: usize| 1.0 - source[i]; + let cmy = super::psblend::blend_rgb_fill(mode, [b(0), b(1), b(2)], [s(0), s(1), s(2)], f); + let k = super::psblend::blend_rgb_fill(mode, [b(3); 3], [s(3); 3], f); + let bl = [cmy[0], cmy[1], cmy[2], k[0]]; + let (wb, wbs, ws) = (ab * (1.0 - over) / ao, ab * over / ao, (1.0 - ab) * alone / ao); + // Mixed as brightness, in the type gamma when there is one. + let enc = |v: f32| if gamma == 1.0 { v } else { super::psblend::text_encode(v, gamma) }; + let dec = |v: f32| if gamma == 1.0 { v } else { super::psblend::text_decode(v, gamma) }; + let c = |i: usize| 1.0 - dec(wb * enc(b(i)) + wbs * enc(bl[i]) + ws * enc(s(i))); + [c(0), c(1), c(2), c(3), ao] +} + +/// Straight-alpha `source` (alpha times `opacity`) composited onto `backdrop` in a separable +/// `mode` (the general compositing formula, on inks), coverage mixed in the type `gamma` (1 = +/// none). Normal is [`normal_gamma`]. +pub fn composite_ink(mode: BlendMode, backdrop: Cmyka, source: Cmyka, opacity: f32, gamma: f32) -> Cmyka { + if mode == BlendMode::Normal { + return normal_gamma(backdrop, source, opacity, gamma); + } + let ab = backdrop[4]; + let as_ = source[4] * opacity; + if as_ <= 0.0 { + return backdrop; + } + let ao = as_ + ab * (1.0 - as_); + if ao <= 0.0 { + return [0.0; 5]; + } + let cb = [backdrop[0], backdrop[1], backdrop[2], backdrop[3]]; + let cs = [source[0], source[1], source[2], source[3]]; + let bl = blend_ink(mode, cb, cs); + let (wb, ws, wbs) = ((1.0 - as_) * ab / ao, (1.0 - ab) * as_ / ao, as_ * ab / ao); + let c = |i: usize| { + if gamma == 1.0 { + wb * cb[i] + ws * cs[i] + wbs * bl[i] + } else { + let g = |ink: f32| super::psblend::text_encode(1.0 - ink, gamma); + 1.0 - super::psblend::text_decode(wb * g(cb[i]) + ws * g(cs[i]) + wbs * g(bl[i]), gamma) + } + }; [c(0), c(1), c(2), c(3), ao] } @@ -248,17 +343,29 @@ fn composite_clipped(clipped: &[Layer], base: &mut CmykBuffer, cx: &Ctx) { if alpha <= 0.0 { continue; } - let r = normal_gamma([p[0], p[1], p[2], p[3], 1.0], *s, opacity, gamma); + let r = composite_ink(c.blend, [p[0], p[1], p[2], p[3], 1.0], *s, opacity, gamma); *p = [r[0], r[1], r[2], r[3], alpha]; } } } -fn blend_into(backdrop: &mut CmykBuffer, src: &CmykBuffer, opacity: f32, gamma: f32) { - for (b, s) in backdrop.px.iter_mut().zip(&src.px) { - if s[4] > 0.0 { - *b = normal_gamma(*b, *s, opacity, gamma); +/// A layer's isolated rendering onto the backdrop in its blend mode. Dissolve shows each pixel +/// fully or not at all, by the compositor's noise (the same pixels as on the RGB compositor). +fn blend_into(backdrop: &mut CmykBuffer, src: &CmykBuffer, mode: BlendMode, opacity: f32, gamma: f32) { + let rect = backdrop.rect; + let w = (rect.width() as usize).max(1); + for (i, (b, s)) in backdrop.px.iter_mut().zip(&src.px).enumerate() { + if s[4] <= 0.0 { + continue; } + if mode == BlendMode::Dissolve { + let x = rect.x0.saturating_add((i % w) as i32); + let y = rect.y0.saturating_add((i / w) as i32); + let shown = super::dissolve_noise(x, y) < s[4] * opacity; + *b = normal(*b, [s[0], s[1], s[2], s[3], if shown { 1.0 } else { 0.0 }], 1.0); + continue; + } + *b = composite_ink(mode, *b, *s, opacity, gamma); } } @@ -304,17 +411,34 @@ fn composite_layer(l: &Layer, clipped: &[Layer], backdrop: &mut CmykBuffer, cx: composite_stack(&g.children, &mut content, cx); apply_mask(l, &mut content, cx); composite_clipped(clipped, &mut content, cx); - blend_into(backdrop, &content, opacity, 1.0); + blend_into(backdrop, &content, l.blend, opacity, 1.0); return; } let mut content = layer_content(l, rect, cx); composite_clipped(clipped, &mut content, cx); - blend_into(backdrop, &content, opacity, super::text_gamma(l)); + blend_into_fill(backdrop, &content, l, super::text_gamma(l)); +} + +/// A layer's own rendering onto the backdrop with its opacity and fill: for Photoshop's special +/// eight ([`super::psblend::fill_is_special`]) Fill below 100% is part of the blend +/// ([`composite_ink_fill`]), as on the RGB compositor; otherwise both are coverage. +fn blend_into_fill(backdrop: &mut CmykBuffer, src: &CmykBuffer, l: &Layer, gamma: f32) { + if l.fill_opacity >= 1.0 || !super::psblend::fill_is_special(l.blend) { + return blend_into(backdrop, src, l.blend, l.opacity * l.fill_opacity, gamma); + } + for (b, s) in backdrop.px.iter_mut().zip(&src.px) { + if s[4] > 0.0 { + *b = composite_ink_fill(l.blend, *b, *s, l.opacity, l.fill_opacity, gamma); + } + } } fn render_tile(doc: &Document, rect: Rect, cx: &Ctx) -> CmykBuffer { let mut b = CmykBuffer::transparent(rect); - composite_stack(&doc.layers, &mut b, cx); + // Blends stay clipped to 0..1 whatever the depth: unclipped (HDR) blending would make + // brightness above 1, i.e. negative ink. Set explicitly, since a tile can run on a thread + // that is in the middle of an RGB composite of a 32-bit document. + super::in_blend_space(false, false, || composite_stack(&doc.layers, &mut b, cx)); b } diff --git a/crates/compose/src/cmyk_tests.rs b/crates/compose/src/cmyk_tests.rs index 089c0a4245..f8654bfda1 100644 --- a/crates/compose/src/cmyk_tests.rs +++ b/crates/compose/src/cmyk_tests.rs @@ -111,8 +111,72 @@ fn over_text(b: Cmyka, s: Cmyka, opacity: f32) -> Cmyka { o } -fn over_layer(l: &Layer, b: Cmyka, s: Cmyka, opacity: f32) -> Cmyka { - if matches!(l.content, LayerContent::Text(_)) { over_text(b, s, opacity) } else { over(b, s, opacity) } +/// The blended ink of one channel: the blend function on brightness, back to ink. +fn ref_blend(mode: BlendMode, b: f32, s: f32) -> f32 { + 1.0 - crate::psblend::blend_rgb(mode, [1.0 - b; 3], [1.0 - s; 3])[0] +} + +/// The general compositing formula (W3C / PDF), written out on each ink. +fn over_mode(mode: BlendMode, b: Cmyka, s: Cmyka, opacity: f32, text: bool) -> Cmyka { + if mode == BlendMode::Normal { + return if text { over_text(b, s, opacity) } else { over(b, s, opacity) }; + } + let sa = s[4] * opacity; + if sa <= 0.0 { + return b; + } + let a = sa + b[4] * (1.0 - sa); + if a <= 0.0 { + return [0.0; 5]; + } + let gamma = if text { crate::psblend::text_gamma() } else { 1.0 }; + let enc = |ink: f32| photocraft_color::convert::srgb_to_linear((1.0 - ink).max(0.0)).powf(1.0 / gamma); + let dec = |v: f32| 1.0 - photocraft_color::convert::linear_to_srgb(v.max(0.0).powf(gamma)); + let (wb, ws, wbs) = ((1.0 - sa) * b[4] / a, (1.0 - b[4]) * sa / a, sa * b[4] / a); + let mut o = [0.0; 5]; + for i in 0..4 { + let m = ref_blend(mode, b[i], s[i]); + o[i] = if text { dec(wb * enc(b[i]) + ws * enc(s[i]) + wbs * enc(m)) } else { wb * b[i] + ws * s[i] + wbs * m }; + } + o[4] = a; + o +} + +/// `l` onto the backdrop in its blend mode (Dissolve: every pixel shown fully or not at all). +fn over_layer(l: &Layer, b: Cmyka, s: Cmyka, opacity: f32, at: Option<(i32, i32)>) -> Cmyka { + if let (BlendMode::Dissolve, Some((x, y))) = (l.blend, at) { + let shown = crate::dissolve_noise(x, y) < s[4] * opacity; + return over(b, [s[0], s[1], s[2], s[3], if shown { 1.0 } else { 0.0 }], 1.0); + } + over_mode(l.blend, b, s, opacity, matches!(l.content, LayerContent::Text(_))) +} + +/// Photoshop's special eight below 100% Fill, written out on each ink: the source pulled toward +/// the mode's neutral colour is blended at full strength (`psblend::blend_rgb_fill`, on +/// brightness), Opacity is its coverage over the backdrop, Fill × Opacity over nothing. +fn over_special_fill(l: &Layer, b: Cmyka, s: Cmyka) -> Cmyka { + let f = l.fill_opacity.clamp(0.0, 1.0); + let over = s[4] * l.opacity; + if over <= 0.0 { + return b; + } + let a = b[4] + (1.0 - b[4]) * over * f; + if a <= 0.0 { + return [0.0; 5]; + } + let text = matches!(l.content, LayerContent::Text(_)); + let gamma = crate::psblend::text_gamma(); + let enc = |v: f32| if text { photocraft_color::convert::srgb_to_linear(v.max(0.0)).powf(1.0 / gamma) } else { v }; + let dec = |v: f32| if text { photocraft_color::convert::linear_to_srgb(v.max(0.0).powf(gamma)) } else { v }; + let (wb, wbs, ws) = (b[4] * (1.0 - over) / a, b[4] * over / a, (1.0 - b[4]) * over * f / a); + let mut o = [0.0; 5]; + for i in 0..4 { + let (bb, sb) = (1.0 - b[i], 1.0 - s[i]); + let m = crate::psblend::blend_rgb_fill(l.blend, [bb; 3], [sb; 3], f)[0]; + o[i] = 1.0 - dec(wb * enc(bb) + wbs * enc(m) + ws * enc(sb)); + } + o[4] = a; + o } fn ref_stack(layers: &[Layer], x: i32, y: i32, mut b: Cmyka) -> Cmyka { @@ -162,11 +226,15 @@ fn ref_layer(l: &Layer, clipped: &[Layer], x: i32, y: i32, b: Cmyka) -> Cmyka { for c in clipped.iter().filter(|c| c.visible) { if content[4] > 0.0 { let a = content[4]; - let r = over_layer(c, [content[0], content[1], content[2], content[3], 1.0], ref_own(c, x, y), c.opacity * c.fill_opacity); + let r = over_layer(c, [content[0], content[1], content[2], content[3], 1.0], ref_own(c, x, y), c.opacity * c.fill_opacity, None); content = [r[0], r[1], r[2], r[3], a]; } } - over_layer(l, b, content, op) + // A layer's own blend (not a group's) for the special eight below 100% Fill. + if l.fill_opacity < 1.0 && crate::psblend::fill_is_special(l.blend) && !matches!(l.content, LayerContent::Group(_)) { + return over_special_fill(l, b, content); + } + over_layer(l, b, content, op, Some((x, y))) } fn assert_matches_reference(d: &Document) { @@ -260,8 +328,9 @@ fn unsupported_documents_fall_back() { } assert!(supports(&d), "hidden {what}"); }; - check("multiply", &|l| l.blend = BlendMode::Multiply); - check("dissolve", &|l| l.blend = BlendMode::Dissolve); + check("hue", &|l| l.blend = BlendMode::Hue); + check("luminosity", &|l| l.blend = BlendMode::Luminosity); + check("lighter colour", &|l| l.blend = BlendMode::LighterColor); check("knockout", &|l| l.advanced.knockout = Knockout::Shallow); check("channels", &|l| l.excluded_channels = 1); check("nan opacity", &|l| l.opacity = f32::NAN); @@ -353,8 +422,8 @@ struct Spec { #[derive(Debug, Clone)] enum LayerSpec { - Pixels { kind: Kind, fills: Vec<(Rect, Cmyka)>, opacity: f32, fill: f32, clipped: bool, visible: bool, mask: Option }, - Group { children: Vec, pass_through: bool, opacity: f32, fill: f32, mask: Option }, + Pixels { kind: Kind, blend: BlendMode, fills: Vec<(Rect, Cmyka)>, opacity: f32, fill: f32, clipped: bool, visible: bool, mask: Option }, + Group { children: Vec, pass_through: bool, blend: BlendMode, opacity: f32, fill: f32, mask: Option }, } /// What kind of layer a [`LayerSpec::Pixels`] becomes: its pixels as a pixel layer, as a type or @@ -375,6 +444,14 @@ struct MaskSpec { enabled: bool, } +/// Every blend mode this path composites natively, Normal most often. +fn blend_mode() -> impl Strategy { + prop_oneof![ + 6 => Just(BlendMode::Normal), + 1 => prop::sample::select(SEPARABLE.to_vec()), + ] +} + fn unit() -> impl Strategy { prop_oneof![Just(0.0f32), Just(1.0f32), 0.0f32..=1.0] } @@ -403,9 +480,11 @@ fn pixels(w: i32, h: i32) -> impl Strategy { prop::bool::weighted(0.9), mask_spec(w, h), prop_oneof![Just(Kind::Raster), Just(Kind::Text), Just(Kind::Shape), Just(Kind::Solid)], + blend_mode(), ) - .prop_map(|(fills, opacity, fill, clipped, visible, mask, kind)| LayerSpec::Pixels { + .prop_map(|(fills, opacity, fill, clipped, visible, mask, kind, blend)| LayerSpec::Pixels { kind, + blend, fills: fills.into_iter().map(|(r, (c, m, y, k, a))| (r, [c, m, y, k, a])).collect(), opacity, fill, @@ -417,8 +496,8 @@ fn pixels(w: i32, h: i32) -> impl Strategy { fn layer_spec(w: i32, h: i32) -> impl Strategy { pixels(w, h).prop_recursive(3, 12, 4, move |inner| { - (prop::collection::vec(inner, 1..4), any::(), unit(), prop_oneof![Just(1.0f32), unit()], mask_spec(w, h)) - .prop_map(move |(children, pass_through, opacity, fill, mask)| LayerSpec::Group { children, pass_through, opacity, fill, mask }) + (prop::collection::vec(inner, 1..4), any::(), unit(), prop_oneof![Just(1.0f32), unit()], mask_spec(w, h), blend_mode()) + .prop_map(move |(children, pass_through, opacity, fill, mask, blend)| LayerSpec::Group { children, pass_through, blend, opacity, fill, mask }) }) } @@ -429,7 +508,7 @@ fn spec() -> impl Strategy { fn build(s: &LayerSpec) -> Layer { let make_mask = |m: &MaskSpec| mask(&m.rects, m.default, m.density, m.enabled); match s { - LayerSpec::Pixels { kind, fills, opacity, fill, clipped, visible, mask } => { + LayerSpec::Pixels { kind, blend, fills, opacity, fill, clipped, visible, mask } => { let pixels = layer(fills); let mut l = match kind { Kind::Raster => pixels, @@ -442,12 +521,13 @@ fn build(s: &LayerSpec) -> Layer { } }; (l.opacity, l.fill_opacity, l.clipped, l.visible) = (*opacity, *fill, *clipped, *visible); + l.blend = *blend; l.mask = mask.as_ref().map(make_mask); l } - LayerSpec::Group { children, pass_through, opacity, fill, mask } => { + LayerSpec::Group { children, pass_through, blend, opacity, fill, mask } => { let mut g = Layer::group("g", children.iter().map(build).collect()); - g.blend = if *pass_through { BlendMode::PassThrough } else { BlendMode::Normal }; + g.blend = if *pass_through { BlendMode::PassThrough } else { *blend }; (g.opacity, g.fill_opacity) = (*opacity, *fill); g.mask = mask.as_ref().map(make_mask); g @@ -626,3 +706,179 @@ fn uncached_gradient_fills_are_cmyk_ramps() { } assert!(got.px[0][0] > got.px[7][0] && got.px[0][3] < got.px[7][3], "cyan to black"); } + +// ---- stage 3: blend modes on ink values -------------------------------------------------------- + +const ALL_MODES: [BlendMode; 34] = [ + BlendMode::PassThrough, + BlendMode::Normal, + BlendMode::Dissolve, + BlendMode::Darken, + BlendMode::Multiply, + BlendMode::ColorBurn, + BlendMode::LinearBurn, + BlendMode::DarkerColor, + BlendMode::Lighten, + BlendMode::Screen, + BlendMode::ColorDodge, + BlendMode::LinearDodge, + BlendMode::LighterColor, + BlendMode::Overlay, + BlendMode::SoftLight, + BlendMode::HardLight, + BlendMode::VividLight, + BlendMode::LinearLight, + BlendMode::PinLight, + BlendMode::HardMix, + BlendMode::Difference, + BlendMode::Exclusion, + BlendMode::Subtract, + BlendMode::Divide, + BlendMode::Hue, + BlendMode::Saturation, + BlendMode::Color, + BlendMode::Luminosity, + BlendMode::Reflect, + BlendMode::Glow, + BlendMode::Negation, + BlendMode::Xor, + BlendMode::PaintNetColorBurn, + BlendMode::PaintNetColorDodge, +]; + +/// The modes [`separable`] accepts, besides Normal. +const SEPARABLE: [BlendMode; 27] = [ + BlendMode::Dissolve, + BlendMode::Darken, + BlendMode::Multiply, + BlendMode::ColorBurn, + BlendMode::LinearBurn, + BlendMode::Lighten, + BlendMode::Screen, + BlendMode::ColorDodge, + BlendMode::LinearDodge, + BlendMode::Overlay, + BlendMode::SoftLight, + BlendMode::HardLight, + BlendMode::VividLight, + BlendMode::LinearLight, + BlendMode::PinLight, + BlendMode::HardMix, + BlendMode::Difference, + BlendMode::Exclusion, + BlendMode::Subtract, + BlendMode::Divide, + BlendMode::Reflect, + BlendMode::Glow, + BlendMode::Negation, + BlendMode::Xor, + BlendMode::PaintNetColorBurn, + BlendMode::PaintNetColorDodge, + BlendMode::Normal, +]; + +/// Every mode treated as per-channel really is: a channel's result depends only on that +/// channel's values (checked on many inputs), so applying it to each ink is exact. The modes left +/// to the RGB compositor really do mix channels. +#[test] +fn separable_modes_are_channel_by_channel() { + let mut seed = 0x2545_f491_4f6c_dd1du64; + let mut r = || { + seed ^= seed << 13; + seed ^= seed >> 7; + seed ^= seed << 17; + (seed >> 40) as f32 / (1u64 << 24) as f32 + }; + for mode in ALL_MODES { + let mut mixes = false; + for _ in 0..2000 { + let (b, s) = ([r(), r(), r()], [r(), r(), r()]); + let (b2, s2) = ([b[0], r(), r()], [s[0], r(), r()]); + let (x, y) = (crate::psblend::blend_rgb(mode, b, s)[0], crate::psblend::blend_rgb(mode, b2, s2)[0]); + mixes |= (x - y).abs() > 1e-6 || x.is_nan() != y.is_nan(); + } + // Pass Through is a group behaviour (its pixel formula is Normal's); it's checked apart. + if mode != BlendMode::PassThrough { + assert_eq!(separable(mode), !mixes, "{mode:?}"); + } + assert_eq!(SEPARABLE.contains(&mode), separable(mode), "{mode:?} list"); + } +} + +/// Opaque layers over opaque paper in common modes give the inks worked out by hand. +#[test] +fn blend_modes_give_the_expected_inks() { + type Ink = fn(f32, f32) -> f32; + let cases: [(BlendMode, Ink); 7] = [ + (BlendMode::Multiply, |b, s| b + s - b * s), // darker: inks add up + (BlendMode::Screen, |b, s| b * s), // lighter: inks thin out + (BlendMode::Darken, f32::max), + (BlendMode::Lighten, f32::min), + (BlendMode::Difference, |b, s| 1.0 - (b - s).abs()), + (BlendMode::LinearBurn, |b, s| (b + s).min(1.0)), + (BlendMode::LinearDodge, |b, s| (b + s - 1.0).max(0.0)), + ]; + let inks = [0.0, 0.2, 0.5, 0.8, 1.0]; + for (mode, want) in cases { + for (bi, si) in inks.iter().flat_map(|b| inks.iter().map(move |s| (*b, *s))) { + let mut d = doc(1, 1); + d.layers.push(paper(1, 1, [bi, 0.0, bi, si])); + let mut l = layer(&[(Rect::new(0, 0, 1, 1), [si, si, 0.0, bi, 1.0])]); + l.blend = mode; + d.layers.push(l); + let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported"))[0]; + let (b, s) = (q(bi), q(si)); + let exp = [want(b, s), want(0.0, s), want(b, 0.0), want(s, b), 1.0]; + assert!(got.iter().zip(exp).all(|(g, e)| (g - e).abs() < 1e-5), "{mode:?} b={b} s={s}: {got:?} vs {exp:?}"); + } + } +} + +impl std::ops::Index for CmykBuffer { + type Output = Cmyka; + fn index(&self, i: usize) -> &Cmyka { + &self.px[i] + } +} + +/// Dissolve shows a pixel fully or not at all, with the RGB compositor's noise: coverage is +/// either the layer's full ink or untouched paper, and agrees pixel for pixel with the RGB one. +#[test] +fn dissolve_matches_the_rgb_compositors_pixels() { + let mut d = doc(16, 16); + d.layers.push(paper(16, 16, [0.0; 4])); + let mut l = layer(&[(Rect::new(0, 0, 16, 16), [0.0, 0.0, 0.0, 1.0, 0.4])]); + l.blend = BlendMode::Dissolve; + d.layers.push(l); + let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported")); + let rgb = crate::render(&d, d.bounds()); + let mut shown = 0; + for (c, r) in got.px.iter().zip(&rgb.px) { + assert!(*c == [0.0, 0.0, 0.0, 1.0, 1.0] || *c == [0.0, 0.0, 0.0, 0.0, 1.0], "{c:?}"); + // Paper is white on screen; a shown pixel is the K100's dark colour. + assert_eq!(c[3] == 1.0, r[0] < 0.5, "{c:?} vs {r:?}"); + shown += usize::from(c[3] == 1.0); + } + assert!((60..150).contains(&shown), "about 40% of 256 shown: {shown}"); +} + +/// Photoshop's special eight: Fill below 100% is part of the blend, not coverage. Difference at +/// 50% Fill subtracts half the source's brightness, where 50% coverage would mix the full +/// difference in by half (the RGB compositor does the same per channel). An ink neither side +/// has comes out at 50%: the half-pulled source differs from the paper by half. +#[test] +fn fill_is_part_of_the_blend_for_the_special_eight() { + let mut d = doc(1, 1); + d.layers.push(paper(1, 1, [0.7, 0.0, 0.0, 0.0])); + let mut l = layer(&[(Rect::new(0, 0, 1, 1), [0.1, 0.0, 0.0, 0.0, 1.0])]); + l.blend = BlendMode::Difference; + l.fill_opacity = 0.5; + d.layers.push(l); + let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported"))[0]; + let inside = |bi: f32, si: f32| 1.0 - ((1.0 - bi) - 0.5 * (1.0 - si)).abs(); + let want = [inside(q(0.7), q(0.1)), inside(0.0, 0.0), inside(0.0, 0.0), inside(0.0, 0.0), 1.0]; + assert!(got.iter().zip(want).all(|(g, w)| (g - w).abs() < 1e-5), "{got:?} vs {want:?}"); + let (b, s) = (1.0 - q(0.7), 1.0 - q(0.1)); + let as_coverage = 1.0 - (0.5 * b + 0.5 * (b - s).abs()); + assert!((want[0] - as_coverage).abs() > 0.2, "the two readings differ"); +} diff --git a/crates/io/tests/cmyk_export.rs b/crates/io/tests/cmyk_export.rs index 44ecc4bba8..66c2d22d42 100644 --- a/crates/io/tests/cmyk_export.rs +++ b/crates/io/tests/cmyk_export.rs @@ -1,5 +1,5 @@ //! A CMYK document is written to flat formats as CMYK with its own profile whatever its layers -//! (#2220), mixing Normal pixel layers on their ink values so opaque pixels keep their exact inks. +//! (#2220), mixing layers on their ink values so opaque pixels keep their exact inks. use std::sync::Arc; @@ -106,20 +106,39 @@ fn transparency_is_kept_in_tiff_and_composited_over_paper_in_jpeg() { assert!(k[3] > 0.94 && k[..3].iter().all(|v| *v < 0.06), "{k:?}"); } +#[test] +fn multiply_adds_inks_exactly() { + // Multiply darkens: each ink of the result is b + s − b·s, with no ink the layers don't have. + let mut d = layered(SampleType::U16); + let mut m = fill(SampleType::U16, true, &[(Rect::new(0, 0, 12, 8), [0.0, 0.5, 0.0, 0.0, 1.0])]); + m.blend = BlendMode::Multiply; + d.layers.push(m); + let r = export(&d, "a.tif", &ExportOptions::default()).unwrap_or_else(|e| panic!("{e}")); + assert!(!r.warnings.iter().any(|w| w.contains("converted back")), "{:?}", r.warnings); + let img = decode(&r.bytes); + assert_eq!(img.layout(), ChannelLayout::Cmyk); + let mul = |b: f32, s: f32| b + s - b * s; + let close = |a: &[f32], b: [f32; 4]| a.iter().zip(b).all(|(x, y)| (x - y).abs() <= 1e-4); + let (k, rich, paper) = (pixel(&img, 2, 3), pixel(&img, 8, 1), pixel(&img, 8, 6)); + assert!(close(&k, [0.0, 0.5, 0.0, 1.0]), "{k:?}"); + assert!(close(&rich, [0.2, mul(0.4, 0.5), 0.6, 0.1]), "{rich:?}"); + assert!(close(&paper, [0.0, 0.5, 0.0, 0.0]), "{paper:?}"); +} + #[test] fn other_stacks_stay_cmyk_through_the_profile() { - // A Multiply layer isn't composited on ink values (yet): the RGB composite is converted back. + // Hue mixes channels, so it isn't composited on ink values: the RGB composite is converted back. let mut d = layered(SampleType::U8); let mut m = fill(SampleType::U8, true, &[(Rect::new(0, 0, 12, 8), [0.0, 0.5, 0.0, 0.0, 1.0])]); - m.blend = BlendMode::Multiply; + m.blend = BlendMode::Hue; d.layers.push(m); let r = export(&d, "a.tif", &ExportOptions::default()).unwrap_or_else(|e| panic!("{e}")); assert!(r.warnings.iter().any(|w| w.contains("converted back through the document's CMYK profile")), "{:?}", r.warnings); let img = decode(&r.bytes); assert_eq!(img.layout(), ChannelLayout::Cmyk); assert_eq!(img.icc.as_deref(), d.icc_profile.as_deref().map(|v| &v[..])); - // Multiplying magenta over paper adds magenta ink; it doesn't empty the page. - assert!(pixel(&img, 8, 6)[1] > 0.3, "{:?}", pixel(&img, 8, 6)); + // Magenta's hue on the four-colour patch shifts its colour; the page still has ink. + assert!(pixel(&img, 2, 3)[3] > 0.5, "{:?}", pixel(&img, 2, 3)); } #[test] From 462d814c852316dbfcba77c148054bd5626fcb25 Mon Sep 17 00:00:00 2001 From: SBaksa Date: Sun, 11 Oct 2026 02:32:25 +1100 Subject: [PATCH 019/649] CMYK compositing: ink-by-ink adjustment layers on ink values Invert, Posterize, and Levels and Curves recorded on the CMYK channels now change a CMYK document's inks directly: each acts on the channel brightness the document stores (the composite record on all four inks, the black record on K only), mixed back by the layer's blend mode, opacity and mask, then rounded to the document's levels as adjustment layers are on the RGB compositor. Channels an adjustment leaves alone keep their inks bit for bit. Clipped adjustments and layers clipped onto an adjustment are covered. Adjustments that weigh the channels together (Threshold, Hue/Saturation, Channel Mixer, ...) still composite in RGB and convert back through the document profile. --- crates/compose/src/cmyk.rs | 126 +++++++++++++-- crates/compose/src/cmyk_tests.rs | 260 +++++++++++++++++++++++++++++-- crates/io/tests/cmyk_export.rs | 26 ++++ 3 files changed, 392 insertions(+), 20 deletions(-) diff --git a/crates/compose/src/cmyk.rs b/crates/compose/src/cmyk.rs index a457557dc2..1f7c9575de 100644 --- a/crates/compose/src/cmyk.rs +++ b/crates/compose/src/cmyk.rs @@ -9,16 +9,19 @@ //! fills, and fills carrying their rendered pixels), isolated and pass-through groups, and //! clipping groups. Blend modes act on each ink's brightness (1 − ink), as the RGB compositor's //! do on each channel, and Dissolve uses the same noise. Type layers mix their edges in the -//! compositor's text gamma, on brightness. [`supports`] says whether a document stays on it; -//! anything else (gradient and pattern fills without rendered pixels, effects, adjustments, -//! channel-mixing blend modes, knockouts, channel restrictions, Blend If) is left to the RGB -//! compositor, whose result callers convert back to CMYK. +//! compositor's text gamma, on brightness. Adjustment layers that are defined ink by ink (Invert, +//! Posterize, and Levels and Curves recorded on the CMYK channels) change the inks themselves, +//! rounded to the document's levels like the compositor's. [`supports`] says whether a document +//! stays on it; anything else (gradient and pattern fills without rendered pixels, effects, other +//! adjustments, channel-mixing blend modes, knockouts, channel restrictions, Blend If) is left to +//! the RGB compositor, whose result callers convert back to CMYK. //! //! Buffers hold straight-alpha `[C, M, Y, K, A]` in 0..1 ink (0 = no ink). -use photocraft_color::ColorMode; use photocraft_color::blend::BlendMode; -use photocraft_doc::{Document, Knockout, Layer, LayerContent}; +use photocraft_color::{ColorMode, SampleType}; +use photocraft_doc::adjust::ToneSpace; +use photocraft_doc::{Adjustment, Document, Knockout, Layer, LayerContent}; use photocraft_geom::Rect; use super::{Ctx, RENDER_TILE, advanced, empty_in, mask_vals, pattern}; @@ -116,9 +119,23 @@ fn layer_supported(l: &Layer, clipped: &[Layer], depth: u32) -> bool { && !(passes_through(l) && clipped.iter().any(|c| c.visible)) && stack_supported(&g.children, depth + 1) } - _ => false, + LayerContent::Adjustment(a) => ink_adjustment(a) && separable(l.blend), }; - content && clipped.iter().filter(|c| c.visible).all(|c| plain(c) && cmyk_pixels(c) && separable(c.blend)) + content && clipped.iter().filter(|c| c.visible).all(|c| plain(c) && (cmyk_pixels(c) || adjusts_inks(c)) && separable(c.blend)) +} + +/// Adjustments whose CMYK result is defined ink by ink, applied here on ink values: Invert and +/// Posterize (each channel on its own), and Levels and Curves recorded on the CMYK channels. +fn ink_adjustment(a: &Adjustment) -> bool { + match a { + Adjustment::Invert | Adjustment::Posterize { .. } => true, + Adjustment::Levels { space, .. } | Adjustment::Curves { space, .. } => *space == ToneSpace::Cmyk, + _ => false, + } +} + +fn adjusts_inks(l: &Layer) -> bool { + matches!(&l.content, LayerContent::Adjustment(a) if ink_adjustment(a)) } /// A group whose children composite straight into the backdrop (the compositor's rule). @@ -170,7 +187,17 @@ pub fn blend_ink(mode: BlendMode, cb: [f32; 4], cs: [f32; 4]) -> [f32; 4] { let s = |i: usize| 1.0 - cs[i]; let cmy = super::psblend::blend_rgb(mode, [b(0), b(1), b(2)], [s(0), s(1), s(2)]); let k = super::psblend::blend_rgb(mode, [b(3); 3], [s(3); 3]); - [1.0 - cmy[0], 1.0 - cmy[1], 1.0 - cmy[2], 1.0 - k[0]] + // A result that is one of the inputs (Normal, Darken, Lighten, ...) is that ink exactly. + let ink = |r: f32, i: usize| { + if r == s(i) { + cs[i] + } else if r == b(i) { + cb[i] + } else { + 1.0 - r + } + }; + [ink(cmy[0], 0), ink(cmy[1], 1), ink(cmy[2], 2), ink(k[0], 3)] } /// [`composite_ink`] for a layer with separate `opacity` and `fill`, as the RGB compositor's @@ -331,10 +358,80 @@ fn mask_at(m: &Option>, i: usize) -> f32 { m.as_ref().and_then(|v| v.get(i)).copied().map_or(1.0, |k| clean(k).max(0.0)) } +/// `table` (samples evenly over 0..1) at `v`, interpolated like the compositor's adjustment LUTs. +fn lut_at(table: &[f32], v: f32) -> f32 { + let Some(last) = table.len().checked_sub(1) else { return v }; + let x = clean(v).clamp(0.0, 1.0) * last as f32; + let i = (x.floor() as usize).min(last); + let f = x - i as f32; + let at = |k: usize| table.get(k).copied().unwrap_or(v); + at(i) * (1.0 - f) + at((i + 1).min(last)) * f +} + +/// Applies an [`ink_adjustment`] to every covered pixel. Like the document's channels, the +/// adjustment acts on each ink's brightness (1 − ink); Levels and Curves work on the whole levels +/// of a `depth` document as on the RGB compositor. +fn adjust_inks(adj: &Adjustment, buf: &mut CmykBuffer, depth: SampleType) { + let luts = matches!(adj, Adjustment::Levels { .. } | Adjustment::Curves { .. }).then(|| super::adjust::tone_luts_depth(adj, Some(depth))); + let tone = |ch: usize, v: f32| match adj { + Adjustment::Invert => 1.0 - v, + Adjustment::Posterize { levels } => super::adjust::posterize(v, *levels), + _ => luts.as_ref().and_then(|t| t.get(ch)).map_or(v, |t| lut_at(t, v)), + }; + for p in &mut buf.px { + if p[4] <= 0.0 { + continue; + } + for (ch, ink) in p.iter_mut().take(4).enumerate() { + // A channel the adjustment leaves alone keeps its ink exactly (1 − (1 − x) can differ). + let (v, r) = (1.0 - *ink, tone(ch, 1.0 - *ink)); + if r != v { + *ink = 1.0 - r; + } + } + } +} + +/// Mixes an adjustment's result back into `base` in the layer's blend mode, by its opacity and +/// mask; coverage is unchanged (the compositor's adjustment mix). +fn mix_adjusted(l: &Layer, base: &mut CmykBuffer, adjusted: &CmykBuffer, cx: &Ctx) { + let opacity = l.opacity * l.fill_opacity; + let mv = mask_vals(l, base.rect, cx); + for (i, (p, a)) in base.px.iter_mut().zip(&adjusted.px).enumerate() { + let k = opacity * mask_at(&mv, i); + if k <= 0.0 { + continue; + } + let bl = blend_ink(l.blend, [p[0], p[1], p[2], p[3]], [a[0], a[1], a[2], a[3]]); + for (v, b) in p.iter_mut().zip(bl) { + *v = if k >= 1.0 { b } else { *v + (b - *v) * k }; + } + } +} + +/// Rounds to the document's levels after an adjustment layer, as the compositor does (on the +/// channel brightness the document stores, and coverage). +fn quantize_inks(buf: &mut CmykBuffer, q: f32) { + let round = |v: f32| (v * q + 0.5).floor() / q; + for p in &mut buf.px { + for v in p.iter_mut().take(4) { + // Whole levels of ink: exactly the stored values, rounding ties as on brightness. + *v = (q - ((1.0 - *v) * q + 0.5).floor()) / q; + } + p[4] = round(p[4]); + } +} + /// Clipped layers onto their base's own rendering: each blends as if the base were opaque and /// the base keeps its alpha. fn composite_clipped(clipped: &[Layer], base: &mut CmykBuffer, cx: &Ctx) { for c in clipped.iter().filter(|c| c.visible) { + if let LayerContent::Adjustment(adj) = &c.content { + let mut adjusted = base.clone(); + adjust_inks(adj, &mut adjusted, cx.depth); + mix_adjusted(c, base, &adjusted, cx); + continue; + } let content = layer_content(c, base.rect, cx); let opacity = c.opacity * c.fill_opacity; let gamma = super::text_gamma(c); @@ -373,6 +470,9 @@ fn composite_stack(layers: &[Layer], backdrop: &mut CmykBuffer, cx: &Ctx) { for (base, clipped) in clip_groups(layers) { if base.visible { composite_layer(base, clipped, backdrop, cx); + if let (LayerContent::Adjustment(_), Some(q)) = (&base.content, super::adjustment_quantum(cx.depth)) { + quantize_inks(backdrop, q); + } } } } @@ -414,6 +514,14 @@ fn composite_layer(l: &Layer, clipped: &[Layer], backdrop: &mut CmykBuffer, cx: blend_into(backdrop, &content, l.blend, opacity, 1.0); return; } + // Adjustment layers transform the backdrop, then blend the result back in. + if let LayerContent::Adjustment(adj) = &l.content { + let mut adjusted = backdrop.clone(); + adjust_inks(adj, &mut adjusted, cx.depth); + composite_clipped(clipped, &mut adjusted, cx); + mix_adjusted(l, backdrop, &adjusted, cx); + return; + } let mut content = layer_content(l, rect, cx); composite_clipped(clipped, &mut content, cx); blend_into_fill(backdrop, &content, l, super::text_gamma(l)); diff --git a/crates/compose/src/cmyk_tests.rs b/crates/compose/src/cmyk_tests.rs index f8654bfda1..a677e6e1ad 100644 --- a/crates/compose/src/cmyk_tests.rs +++ b/crates/compose/src/cmyk_tests.rs @@ -105,7 +105,8 @@ fn over_text(b: Cmyka, s: Cmyka, opacity: f32) -> Cmyka { let dec = |v: f32| 1.0 - photocraft_color::convert::linear_to_srgb(v.max(0.0).powf(gamma)); let mut o = [0.0; 5]; for i in 0..4 { - o[i] = dec((1.0 - sa) * b[4] / a * enc(b[i]) + sa / a * enc(s[i])); + // Mixing an ink with itself (or with nothing) leaves it exactly as it is. + o[i] = if b[4] <= 0.0 || b[i] == s[i] { s[i] } else { dec((1.0 - sa) * b[4] / a * enc(b[i]) + sa / a * enc(s[i])) }; } o[4] = a; o @@ -179,6 +180,72 @@ fn over_special_fill(l: &Layer, b: Cmyka, s: Cmyka) -> Cmyka { o } +/// An adjustment on one pixel: each ink's brightness through the channel's table (Levels and +/// Curves: the compositor's tables for an 8-bit document, interpolated here), Invert and +/// Posterize written out. +fn ref_adjust(adj: &Adjustment, p: Cmyka) -> Cmyka { + if p[4] <= 0.0 { + return p; + } + let luts = crate::adjust::tone_luts_depth(adj, Some(SampleType::U8)); + let mut o = p; + for c in 0..4 { + let v = 1.0 - p[c]; + let r = match adj { + Adjustment::Invert => 1.0 - v, + Adjustment::Posterize { levels } => { + let n = (*levels).clamp(2, 255) as f32; + let bin = ((v * 255.0).round() * n / 256.0).floor().min(n - 1.0); + (bin * 255.0 / (n - 1.0)).floor() / 255.0 + } + _ => { + let t = &luts[c]; + let x = v.clamp(0.0, 1.0) * (t.len() - 1) as f32; + let i = x.floor() as usize; + let j = (i + 1).min(t.len() - 1); + t[i] + (t[j] - t[i]) * (x - i as f32) + } + }; + o[c] = 1.0 - r; + } + o +} + +/// An adjustment layer `l` (adjusting `p`, then `clipped` onto that) mixed into `p` in its blend +/// mode by its opacity and mask; coverage stays. +fn ref_adjusted(l: &Layer, adj: &Adjustment, clipped: &[Layer], p: Cmyka, x: i32, y: i32) -> Cmyka { + let mut a = ref_adjust(adj, p); + if p[4] > 0.0 { + a = ref_clip(clipped, a, x, y); + } + let k = l.opacity * l.fill_opacity * ref_mask(l, x, y); + let mut o = p; + for c in 0..4 { + o[c] = p[c] + (ref_blend(l.blend, p[c], a[c]) - p[c]) * k; + } + o +} + +/// `clipped` onto `content` (blending as if it were opaque; its coverage stays). +fn ref_clip(clipped: &[Layer], mut content: Cmyka, x: i32, y: i32) -> Cmyka { + for c in clipped.iter().filter(|c| c.visible) { + if let LayerContent::Adjustment(adj) = &c.content { + content = ref_adjusted(c, adj, &[], content, x, y); + } else if content[4] > 0.0 { + let a = content[4]; + let r = over_layer(c, [content[0], content[1], content[2], content[3], 1.0], ref_own(c, x, y), c.opacity * c.fill_opacity, None); + content = [r[0], r[1], r[2], r[3], a]; + } + } + content +} + +/// Rounding to an 8-bit document's levels: stored channel brightness, and coverage. +fn ref_round(p: Cmyka) -> Cmyka { + let r = |v: f32| (v * 255.0 + 0.5).floor() / 255.0; + [1.0 - r(1.0 - p[0]), 1.0 - r(1.0 - p[1]), 1.0 - r(1.0 - p[2]), 1.0 - r(1.0 - p[3]), r(p[4])] +} + fn ref_stack(layers: &[Layer], x: i32, y: i32, mut b: Cmyka) -> Cmyka { let mut i = 0; while i < layers.len() { @@ -189,6 +256,9 @@ fn ref_stack(layers: &[Layer], x: i32, y: i32, mut b: Cmyka) -> Cmyka { } if base.visible { b = ref_layer(base, &layers[i + 1..j], x, y, b); + if matches!(base.content, LayerContent::Adjustment(_)) { + b = ref_round(b); + } } i = j; } @@ -216,6 +286,7 @@ fn ref_layer(l: &Layer, clipped: &[Layer], x: i32, y: i32, b: Cmyka) -> Cmyka { o[4] = a; return o; } + LayerContent::Adjustment(adj) => return ref_adjusted(l, adj, clipped, b, x, y), LayerContent::Group(g) => { let mut c = ref_stack(&g.children, x, y, [0.0; 5]); c[4] *= ref_mask(l, x, y); @@ -223,13 +294,7 @@ fn ref_layer(l: &Layer, clipped: &[Layer], x: i32, y: i32, b: Cmyka) -> Cmyka { } _ => ref_own(l, x, y), }; - for c in clipped.iter().filter(|c| c.visible) { - if content[4] > 0.0 { - let a = content[4]; - let r = over_layer(c, [content[0], content[1], content[2], content[3], 1.0], ref_own(c, x, y), c.opacity * c.fill_opacity, None); - content = [r[0], r[1], r[2], r[3], a]; - } - } + content = ref_clip(clipped, content, x, y); // A layer's own blend (not a group's) for the special eight below 100% Fill. if l.fill_opacity < 1.0 && crate::psblend::fill_is_special(l.blend) && !matches!(l.content, LayerContent::Group(_)) { return over_special_fill(l, b, content); @@ -334,7 +399,13 @@ fn unsupported_documents_fall_back() { check("knockout", &|l| l.advanced.knockout = Knockout::Shallow); check("channels", &|l| l.excluded_channels = 1); check("nan opacity", &|l| l.opacity = f32::NAN); - check("adjustment", &|l| l.content = LayerContent::Adjustment(Adjustment::Invert)); + // Adjustments that weigh the channels together, or whose records name RGB channels. + check("threshold", &|l| l.content = LayerContent::Adjustment(Adjustment::Threshold { level: 0.5 })); + check("rgb levels", &|l| l.content = LayerContent::Adjustment(rgb_levels())); + check("invert in colour mode", &|l| { + l.content = LayerContent::Adjustment(Adjustment::Invert); + l.blend = BlendMode::Color; + }); check("rgb pixels", &|l| l.content = LayerContent::Raster(Surface::new(PixelFormat::RGBA8))); // Not a CMYK document. let mut rgb = simple(); @@ -428,12 +499,24 @@ enum LayerSpec { /// What kind of layer a [`LayerSpec::Pixels`] becomes: its pixels as a pixel layer, as a type or /// shape layer's rendered pixels, or a solid colour fill in the first fill's colour. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone)] enum Kind { Raster, Text, Shape, Solid, + /// An adjustment layer (its fills are unused). + Adjust(AdjSpec), +} + +/// The adjustments this path applies on ink values; `channel` 0..=3 is C, M, Y, K and 4 the +/// composite record. +#[derive(Debug, Clone)] +enum AdjSpec { + Invert, + Posterize(u32), + Levels { channel: usize, levels: [f32; 5] }, + Curves { channel: usize, points: Vec<(f32, f32)> }, } #[derive(Debug, Clone)] @@ -452,6 +535,38 @@ fn blend_mode() -> impl Strategy { ] } +fn adj_spec() -> impl Strategy { + prop_oneof![ + Just(AdjSpec::Invert), + (2u32..9).prop_map(AdjSpec::Posterize), + (0usize..5, 0.0f32..0.4, 0.6f32..=1.0, 0.3f32..3.0, 0.0f32..0.3, 0.7f32..=1.0) + .prop_map(|(channel, ib, iw, g, ob, ow)| AdjSpec::Levels { channel, levels: [ib, iw, g, ob, ow] }), + (0usize..5, prop::collection::vec((unit(), unit()), 2..5)).prop_map(|(channel, mut points)| { + points.sort_by(|a, b| a.0.total_cmp(&b.0)); + points.dedup_by(|a, b| (a.0 - b.0).abs() < 0.02); + AdjSpec::Curves { channel, points } + }), + ] +} + +fn make_adjustment(a: &AdjSpec) -> Adjustment { + use photocraft_doc::adjust::{CurvePoint, LevelsChannel, ToneSpace}; + match a { + AdjSpec::Invert => Adjustment::Invert, + AdjSpec::Posterize(levels) => Adjustment::Posterize { levels: *levels }, + AdjSpec::Levels { channel, levels: [in_black, in_white, gamma, out_black, out_white] } => { + let rec = LevelsChannel { in_black: *in_black, in_white: *in_white, gamma: *gamma, out_black: *out_black, out_white: *out_white }; + let pick = |c: usize| if c == *channel { rec.clone() } else { LevelsChannel::default() }; + Adjustment::Levels { master: pick(4), per_channel: [pick(0), pick(1), pick(2)], space: ToneSpace::Cmyk, black: pick(3) } + } + AdjSpec::Curves { channel, points } => { + let curve: Vec = points.iter().map(|(input, output)| CurvePoint { input: *input, output: *output }).collect(); + let pick = |c: usize| if c == *channel { curve.clone() } else { Vec::new() }; + Adjustment::Curves { master: pick(4), per_channel: [pick(0), pick(1), pick(2)], space: ToneSpace::Cmyk, black: pick(3) } + } + } +} + fn unit() -> impl Strategy { prop_oneof![Just(0.0f32), Just(1.0f32), 0.0f32..=1.0] } @@ -479,7 +594,10 @@ fn pixels(w: i32, h: i32) -> impl Strategy { any::(), prop::bool::weighted(0.9), mask_spec(w, h), - prop_oneof![Just(Kind::Raster), Just(Kind::Text), Just(Kind::Shape), Just(Kind::Solid)], + prop_oneof![ + 3 => prop_oneof![Just(Kind::Raster), Just(Kind::Text), Just(Kind::Shape), Just(Kind::Solid)], + 1 => adj_spec().prop_map(Kind::Adjust), + ], blend_mode(), ) .prop_map(|(fills, opacity, fill, clipped, visible, mask, kind, blend)| LayerSpec::Pixels { @@ -519,6 +637,7 @@ fn build(s: &LayerSpec) -> Layer { let color = photocraft_color::Color { mode: ColorMode::Cmyk, c: [c, m, y, k], alpha: a }; Layer::new("f", LayerContent::Fill(photocraft_doc::Fill::Solid(color))) } + Kind::Adjust(a) => Layer::new("a", LayerContent::Adjustment(make_adjustment(a))), }; (l.opacity, l.fill_opacity, l.clipped, l.visible) = (*opacity, *fill, *clipped, *visible); l.blend = *blend; @@ -882,3 +1001,122 @@ fn fill_is_part_of_the_blend_for_the_special_eight() { let as_coverage = 1.0 - (0.5 * b + 0.5 * (b - s).abs()); assert!((want[0] - as_coverage).abs() > 0.2, "the two readings differ"); } + +// ---- stage 4: adjustment layers on ink values -------------------------------------------------- + +fn rgb_levels() -> Adjustment { + use photocraft_doc::adjust::{LevelsChannel, ToneSpace}; + let d = LevelsChannel::default; + Adjustment::Levels { master: LevelsChannel { in_white: 0.5, ..d() }, per_channel: [d(), d(), d()], space: ToneSpace::Rgb, black: d() } +} + +fn cmyk_levels(master: photocraft_doc::adjust::LevelsChannel, black: photocraft_doc::adjust::LevelsChannel) -> Adjustment { + use photocraft_doc::adjust::{LevelsChannel, ToneSpace}; + let d = LevelsChannel::default; + Adjustment::Levels { master, per_channel: [d(), d(), d()], space: ToneSpace::Cmyk, black } +} + +fn adjustment(a: Adjustment) -> Layer { + Layer::new("a", LayerContent::Adjustment(a)) +} + +fn render1(d: &Document, x: i32, y: i32) -> Cmyka { + let got = render_cmyk(d, d.bounds()).unwrap_or_else(|| panic!("supported")); + got.px[(y * d.size.width as i32 + x) as usize] +} + +fn near(a: Cmyka, b: Cmyka, tol: f32) -> bool { + a.iter().zip(b).all(|(x, y)| (x - y).abs() <= tol) +} + +/// Invert turns every ink into its opposite, black included (blank paper becomes four-colour +/// black); Posterize steps each ink on its own. +#[test] +fn invert_and_posterize_work_ink_by_ink() { + let mut d = doc(2, 1); + d.layers.push(paper(2, 1, [0.0; 4])); + d.layers.push(layer(&[(Rect::new(1, 0, 2, 1), [0.0, 0.0, 0.0, 1.0, 1.0])])); + d.layers.push(adjustment(Adjustment::Invert)); + assert_eq!(render1(&d, 0, 0), [1.0, 1.0, 1.0, 1.0, 1.0], "paper"); + assert_eq!(render1(&d, 1, 0), [1.0, 1.0, 1.0, 0.0, 1.0], "K-only black"); + let mut d = doc(1, 1); + d.layers.push(paper(1, 1, [0.2, 0.45, 0.7, 0.9])); + d.layers.push(adjustment(Adjustment::Posterize { levels: 2 })); + // Two levels: brightness below half goes dark (full ink), above half light (no ink). + assert_eq!(render1(&d, 0, 0), [0.0, 0.0, 1.0, 1.0, 1.0]); +} + +/// Levels' composite record changes every ink, the black record only K; channels a record +/// leaves alone keep their exact inks. +#[test] +fn levels_records_address_their_inks() { + use photocraft_doc::adjust::LevelsChannel; + let d0 = LevelsChannel::default; + // Composite: input white at 50% doubles each ink's brightness. + let mut d = doc(1, 1); + d.layers.push(paper(1, 1, [0.2, 0.4, 0.6, 0.1])); + d.layers.push(adjustment(cmyk_levels(LevelsChannel { in_white: 0.5, ..d0() }, d0()))); + assert!(near(render1(&d, 0, 0), [0.0, 0.0, 0.2, 0.0, 1.0], 1.0 / 255.0), "{:?}", render1(&d, 0, 0)); + // Black: output white at 50% leaves at least half K, and no other ink. + let mut d = doc(2, 1); + d.layers.push(paper(2, 1, [0.0; 4])); + d.layers.push(layer(&[(Rect::new(1, 0, 2, 1), [0.4, 0.0, 0.0, 0.0, 1.0])])); + d.layers.push(adjustment(cmyk_levels(d0(), LevelsChannel { out_white: 0.5, ..d0() }))); + let (blank, cyan) = (render1(&d, 0, 0), render1(&d, 1, 0)); + assert_eq!(&blank[..3], &[0.0; 3], "{blank:?}"); + assert!((blank[3] - 0.5).abs() <= 1.0 / 255.0, "{blank:?}"); + assert_eq!(cyan[0], q(0.4), "cyan untouched: {cyan:?}"); +} + +/// Opacity, masks, blend modes, clipping onto adjustments and adjustments clipped onto a layer, +/// inside isolated and pass-through groups, against the reference. +#[test] +fn adjustment_stacks_match_the_reference() { + use photocraft_doc::adjust::LevelsChannel; + let d0 = LevelsChannel::default; + let mut d = doc(8, 6); + d.layers.push(paper(8, 6, [0.05, 0.1, 0.0, 0.0])); + d.layers.push(layer(&[(Rect::new(0, 0, 5, 6), [0.0, 0.0, 0.0, 1.0, 1.0]), (Rect::new(5, 0, 8, 3), [0.6, 0.2, 0.1, 0.3, 0.7])])); + let mut inv = adjustment(Adjustment::Invert); + inv.opacity = 0.4; + inv.mask = Some(mask(&[(Rect::new(0, 0, 3, 6), 0.0)], 1.0, 0.8, true)); + let mut onto = layer(&[(Rect::new(2, 2, 8, 6), [0.0, 0.7, 0.0, 0.0, 1.0])]); + onto.clipped = true; + onto.blend = BlendMode::Multiply; + let mut base = layer(&[(Rect::new(1, 1, 7, 5), [0.1, 0.1, 0.5, 0.0, 0.9])]); + base.blend = BlendMode::Screen; + let mut lv = adjustment(cmyk_levels(LevelsChannel { gamma: 1.8, ..d0() }, LevelsChannel { in_black: 0.2, ..d0() })); + lv.clipped = true; + lv.blend = BlendMode::Overlay; + let mut pass = Layer::group("pass", vec![adjustment(Adjustment::Posterize { levels: 4 })]); + pass.opacity = 0.6; + let mut iso = Layer::group("iso", vec![layer(&[(Rect::new(0, 3, 8, 6), [0.5, 0.0, 0.5, 0.0, 0.5])]), adjustment(Adjustment::Invert)]); + iso.blend = BlendMode::Normal; + d.layers.extend([inv, onto, base, lv, pass, iso]); + assert_matches_reference(&d); +} + +/// In a 32-bit document (no rounding to levels), inks an adjustment leaves alone come out +/// bit for bit, at full strength and through blend modes that pick an input. +#[test] +fn untouched_inks_stay_bit_exact() { + use photocraft_doc::adjust::LevelsChannel; + let d0 = LevelsChannel::default; + let fmt = PixelFormat { mode: ColorMode::Cmyk, sample: SampleType::F32, alpha: false }; + let inks = [0.123_456_7, 0.456_789_1, 0.789_123_4, 0.0]; + for blend in [BlendMode::Normal, BlendMode::Darken, BlendMode::Lighten] { + let mut d = Document::new("f", Size::new(1, 1), ColorMode::Cmyk, SampleType::F32); + let mut bg = Layer::raster("bg", fmt); + if let Some(s) = bg.surface_mut() { + s.fill_rect(Rect::new(0, 0, 1, 1), &inks); + } + d.layers.push(bg); + let mut a = adjustment(cmyk_levels(d0(), LevelsChannel { out_white: 0.5, ..d0() })); + a.blend = blend; + d.layers.push(a); + let got = render1(&d, 0, 0); + assert_eq!(&got[..3], &inks[..3], "{blend:?}"); + let want_k = if blend == BlendMode::Lighten { 0.0 } else { 0.5 }; + assert!((got[3] - want_k).abs() < 1e-6, "{blend:?}: {got:?}"); + } +} diff --git a/crates/io/tests/cmyk_export.rs b/crates/io/tests/cmyk_export.rs index 66c2d22d42..5f192700c8 100644 --- a/crates/io/tests/cmyk_export.rs +++ b/crates/io/tests/cmyk_export.rs @@ -148,3 +148,29 @@ fn rgb_only_formats_still_get_rgb_through_the_profile() { assert!(matches!(img.layout(), ChannelLayout::Rgb | ChannelLayout::Rgba), "{:?}", img.layout()); assert!(r.warnings.iter().any(|w| w.contains("CMYK converted to sRGB")), "{:?}", r.warnings); } + +#[test] +fn ink_adjustments_export_exact_inks() { + // Invert in CMYK turns every ink into its opposite: blank paper becomes four-colour black, + // K-only black loses its K and gains full C, M and Y. + let mut d = layered(SampleType::U8); + d.layers.push(Layer::new("inv", photocraft_doc::LayerContent::Adjustment(photocraft_doc::Adjustment::Invert))); + let r = export(&d, "a.tif", &ExportOptions::default()).unwrap_or_else(|e| panic!("{e}")); + assert!(!r.warnings.iter().any(|w| w.contains("converted back")), "{:?}", r.warnings); + let img = decode(&r.bytes); + assert_eq!(img.layout(), ChannelLayout::Cmyk); + assert_eq!(pixel(&img, 8, 6), vec![1.0, 1.0, 1.0, 1.0], "paper"); + assert_eq!(pixel(&img, 2, 3), vec![1.0, 1.0, 1.0, 0.0], "K-only black"); + let inv = |v: f32| (255.0 - (v * 255.0).round()) / 255.0; + assert_eq!(pixel(&img, 8, 1), vec![inv(0.2), inv(0.4), inv(0.6), inv(0.1)], "four-colour patch"); +} + +#[test] +fn channel_weighing_adjustments_go_through_the_profile() { + // Threshold weighs the channels together: it isn't an ink-by-ink edit. + let mut d = layered(SampleType::U8); + d.layers.push(Layer::new("t", photocraft_doc::LayerContent::Adjustment(photocraft_doc::Adjustment::Threshold { level: 0.5 }))); + let r = export(&d, "a.tif", &ExportOptions::default()).unwrap_or_else(|e| panic!("{e}")); + assert!(r.warnings.iter().any(|w| w.contains("converted back through the document's CMYK profile")), "{:?}", r.warnings); + assert_eq!(decode(&r.bytes).layout(), ChannelLayout::Cmyk); +} From 6ded412767d8733410907ead31d56408d2e77ed7 Mon Sep 17 00:00:00 2001 From: SBaksa Date: Sun, 11 Oct 2026 10:38:56 +1100 Subject: [PATCH 020/649] CMYK compositing: layer effects and knockouts ink by ink CMYK documents whose layers carry effects (drop and inner shadows, glows, strokes, colour and gradient overlays, satin, bevel and emboss) or knockouts now composite on their ink values too. The RGB compositor runs on two stand-in documents whose channels hold the brightness of cyan, magenta and yellow, then of black: everything allowed there works channel by channel (checked by rendering random effect stacks with the inks in different channels), so the result is each ink's own. Fill layers enter the stand-ins as the compositor renders them in CMYK (solid colours at the document's depth, gradients as its CMYK ramp), so both routes give the same inks. Pattern paints, bevel textures, effect modes that mix channels, Blend If and 32-bit documents still composite in RGB and convert back through the profile. Adds cmyk::render_display, the ink composite shown through the document's profile, for a canvas to draw. --- crates/compose/src/cmyk.rs | 100 +++++-- crates/compose/src/cmyk_split.rs | 313 +++++++++++++++++++ crates/compose/src/cmyk_tests.rs | 497 ++++++++++++++++++++++++++++++- crates/io/tests/cmyk_export.rs | 39 +++ 4 files changed, 923 insertions(+), 26 deletions(-) create mode 100644 crates/compose/src/cmyk_split.rs diff --git a/crates/compose/src/cmyk.rs b/crates/compose/src/cmyk.rs index 1f7c9575de..1e0f6c844c 100644 --- a/crates/compose/src/cmyk.rs +++ b/crates/compose/src/cmyk.rs @@ -26,6 +26,9 @@ use photocraft_geom::Rect; use super::{Ctx, RENDER_TILE, advanced, empty_in, mask_vals, pattern}; +#[path = "cmyk_split.rs"] +pub mod split; + /// One straight-alpha CMYK pixel: C, M, Y, K (0..1 ink), alpha. pub type Cmyka = [f32; 5]; @@ -550,30 +553,85 @@ fn render_tile(doc: &Document, rect: Rect, cx: &Ctx) -> CmykBuffer { b } -/// The composite of `doc` over `rect` in CMYK + alpha, mixed on ink values; `None` when -/// [`supports`] is false. Tiles render in parallel on native targets (one at a time on wasm); +/// Whether [`render_cmyk`] composites `doc` on ink values: on this module's exact path +/// ([`supports`]) or, for layer effects and knockouts, ink by ink through the RGB compositor +/// ([`split::supports`]). +pub fn renders_inks(doc: &Document) -> bool { + supports(doc) || split::supports(doc) +} + +/// The composite of `doc` over `rect` in CMYK + alpha, mixed on ink values; `None` unless +/// [`renders_inks`]. Tiles render in parallel on native targets (one at a time on wasm); /// every tile is independent, so the result doesn't depend on the tiling or the thread count. pub fn render_cmyk(doc: &Document, rect: Rect) -> Option { render_cmyk_tiled(doc, rect, RENDER_TILE) } -/// [`render_cmyk`] with an explicit tile size (tests check tile independence). -pub fn render_cmyk_tiled(doc: &Document, rect: Rect, tile: i32) -> Option { - if !supports(doc) { - return None; - } - let patterns = pattern::PreparedPatterns::new(&doc.patterns, pattern::PREPARED_PATTERN_BYTES).in_mode(doc.pixel_format().mode); - let cx = Ctx::for_doc(doc, &patterns); - Some(render_with(doc, rect, tile, &cx)) +/// [`render_cmyk`] as display RGB (straight alpha), each pixel's inks shown through the +/// document's CMYK profile as the RGB compositor reads CMYK pixels; `None` unless +/// [`renders_inks`]. What a canvas showing the ink composite would draw. +pub fn render_display(doc: &Document, rect: Rect) -> Option { + let inks = render_cmyk(doc, rect)?; + let space = super::cmyk_space(doc); + let show = |part: &[Cmyka]| -> Vec<[f32; 4]> { + photocraft_color::convert::with_cmyk_space(space.as_ref(), || { + part.iter() + .map(|p| { + let [r, g, b] = photocraft_color::convert::cmyk_to_rgb([p[0], p[1], p[2], p[3]]); + [r, g, b, p[4]] + }) + .collect() + }) + }; + // Rows of tiles at a time, on every core (the profile is set per worker thread). + let chunk = (rect.width() as usize).max(1) * RENDER_TILE as usize; + #[cfg(not(target_arch = "wasm32"))] + let px: Vec<[f32; 4]> = { + use rayon::prelude::*; + inks.px.par_chunks(chunk).flat_map_iter(show).collect() + }; + #[cfg(target_arch = "wasm32")] + let px: Vec<[f32; 4]> = inks.px.chunks(chunk).flat_map(show).collect(); + Some(super::Buffer { rect, px }) } -fn render_with(doc: &Document, rect: Rect, tile: i32, cx: &Ctx) -> CmykBuffer { +/// [`render_cmyk`] with an explicit tile size (tests check tile independence). +pub fn render_cmyk_tiled(doc: &Document, rect: Rect, tile: i32) -> Option { + if supports(doc) { + let patterns = pattern::PreparedPatterns::new(&doc.patterns, pattern::PREPARED_PATTERN_BYTES).in_mode(doc.pixel_format().mode); + let cx = Ctx::for_doc(doc, &patterns); + return Some(render_with(rect, tile, |t| render_tile(doc, t, &cx))); + } + if !split::supports(doc) { + return None; + } + let mut out = CmykBuffer::transparent(rect); + let done = split::render_bands(doc, rect, 0, tile, |band| { + place(&mut out, &band); + Ok::<(), ()>(()) + }); + done.ok().map(|()| out) +} + +/// Copies `part` into `out` where their rectangles overlap (`part` lies within `out`). +fn place(out: &mut CmykBuffer, part: &CmykBuffer) { + let (rect, w) = (out.rect, out.rect.width() as usize); + let pw = part.rect.width() as usize; + for (row, src) in part.px.chunks_exact(pw.max(1)).enumerate() { + let o = ((part.rect.y0 - rect.y0) as usize + row) * w + (part.rect.x0 - rect.x0) as usize; + if let Some(dst) = out.px.get_mut(o..o + pw) { + dst.copy_from_slice(src); + } + } +} + +/// `rect` rendered tile by tile by `render_tile`, tiles in parallel on native targets. +fn render_with(rect: Rect, tile: i32, render_tile: impl Fn(Rect) -> CmykBuffer + Sync) -> CmykBuffer { let tile = tile.max(1); let mut out = CmykBuffer::transparent(rect); if rect.is_empty() { return out; } - let w = rect.width() as usize; let mut tiles = Vec::new(); let mut y = rect.y0; while y < rect.y1 { @@ -589,28 +647,22 @@ fn render_with(doc: &Document, rect: Rect, tile: i32, cx: &Ctx) -> CmykBuffer { #[cfg(not(target_arch = "wasm32"))] let parts: Vec = { use rayon::prelude::*; - tiles.par_iter().map(|t| render_tile(doc, *t, cx)).collect() + tiles.par_iter().map(|t| render_tile(*t)).collect() }; #[cfg(target_arch = "wasm32")] - let parts: Vec = tiles.iter().map(|t| render_tile(doc, *t, cx)).collect(); + let parts: Vec = tiles.iter().map(|t| render_tile(*t)).collect(); for part in &parts { - let pw = part.rect.width() as usize; - for (row, src) in part.px.chunks_exact(pw.max(1)).enumerate() { - let o = ((part.rect.y0 - rect.y0) as usize + row) * w + (part.rect.x0 - rect.x0) as usize; - if let Some(dst) = out.px.get_mut(o..o + pw) { - dst.copy_from_slice(src); - } - } + place(&mut out, part); } out } /// [`render_cmyk`] in horizontal bands, top to bottom, handing each band to `sink` (so a huge -/// document is never held as one full-size float composite); `None` when [`supports`] is false. +/// document is never held as one full-size float composite); `None` unless [`renders_inks`]. /// `band_rows` as in [`super::render_bands`]. pub fn render_cmyk_bands(doc: &Document, rect: Rect, band_rows: i32, mut sink: impl FnMut(CmykBuffer) -> Result<(), E>) -> Option> { if !supports(doc) { - return None; + return split::supports(doc).then(|| split::render_bands(doc, rect, band_rows, RENDER_TILE, sink)); } let patterns = pattern::PreparedPatterns::new(&doc.patterns, pattern::PREPARED_PATTERN_BYTES).in_mode(doc.pixel_format().mode); let cx = Ctx::for_doc(doc, &patterns); @@ -618,7 +670,7 @@ pub fn render_cmyk_bands(doc: &Document, rect: Rect, band_rows: i32, mut sink let mut y = rect.y0; while y < rect.y1 { let y1 = y.saturating_add(rows).min(rect.y1); - if let Err(e) = sink(render_with(doc, Rect::new(rect.x0, y, rect.x1, y1), RENDER_TILE, &cx)) { + if let Err(e) = sink(render_with(Rect::new(rect.x0, y, rect.x1, y1), RENDER_TILE, |t| render_tile(doc, t, &cx))) { return Some(Err(e)); } y = y1; diff --git a/crates/compose/src/cmyk_split.rs b/crates/compose/src/cmyk_split.rs new file mode 100644 index 0000000000..89153b6366 --- /dev/null +++ b/crates/compose/src/cmyk_split.rs @@ -0,0 +1,313 @@ +//! CMYK documents with layer effects (and stack structures the ink path leaves alone, such as +//! knockouts), composited ink by ink through the RGB compositor itself. +//! +//! Everything allowed here works channel by channel: per-channel blend modes, effects built from +//! coverage and painted with colours or colour gradients, the ink-by-ink adjustments, masks, +//! groups, clipping and knockouts. So the RGB compositor run on a stand-in document whose red, +//! green and blue hold the brightness (1 − ink) of cyan, magenta and yellow gives exactly those +//! inks' result, and a second run with black's brightness in all three gives black. Blends stay +//! clipped to 0..1 (unclipped blending would make negative ink), as on the ink path. +//! +//! 32-bit documents stay on the RGB compositor (32-bit CMYK isn't a print mode, and 32-bit Levels +//! use their own float formula); so do pattern paints, bevel textures, effect blend modes that mix +//! channels, Blend If and channel restrictions, which don't work channel by channel. + +use photocraft_color::blend::BlendMode; +use photocraft_color::{Color, ColorMode, PixelFormat, SampleType}; +use photocraft_doc::adjust::ToneSpace; +use photocraft_doc::effects::{Effect, FxPaint}; +use photocraft_doc::{Adjustment, Document, Fill, Layer, LayerContent}; +use photocraft_geom::Rect; +use photocraft_raster::Surface; + +use super::{CmykBuffer, MAX_DEPTH, clean, cmyk_pixels, ink_adjustment, separable}; +use crate::{Buffer, Ctx, advanced, pattern}; + +/// Which ink (0..=3: C, M, Y, K) a stand-in document carries in its red, green and blue. +pub(super) type Planes = [usize; 3]; +const CMY: Planes = [0, 1, 2]; +const K: Planes = [3, 3, 3]; + +/// Whether `doc` composites ink by ink on this path. +pub fn supports(doc: &Document) -> bool { + doc.mode == ColorMode::Cmyk && doc.depth != SampleType::F32 && stack_supported(&doc.layers, 0) +} + +fn stack_supported(layers: &[Layer], depth: u32) -> bool { + depth <= MAX_DEPTH && layers.iter().filter(|l| l.visible).all(|l| layer_supported(l, depth)) +} + +fn layer_supported(l: &Layer, depth: u32) -> bool { + let plain = l.opacity.is_finite() && l.fill_opacity.is_finite() && l.excluded_channels == 0 && l.blend_if.is_default(); + // Effects on an adjustment layer (which has no pixels of its own to shape them) stay on the RGB + // compositor. + let effects = !crate::effects::has_effects(l) + || (!matches!(l.content, LayerContent::Adjustment(_)) && l.effects.items.iter().filter(|e| e.enabled()).all(effect_supported)); + let content = match &l.content { + LayerContent::Group(g) => g.artboard.is_none() && (separable(l.blend) || l.blend == BlendMode::PassThrough) && stack_supported(&g.children, depth + 1), + LayerContent::Adjustment(a) => ink_adjustment(a) && separable(l.blend), + // A stroked shape can draw its stroke from the vector, in its own colour. + LayerContent::Shape(sh) if sh.stroke.is_some() => false, + _ => cmyk_pixels(l) && separable(l.blend), + }; + // Effects and knockouts are laid out over the layer's bounds: they must be the same on the + // stand-ins (see [`stand_in_surface`]). + let shaped = crate::effects::has_effects(l) || l.advanced.knockout != photocraft_doc::Knockout::None; + plain && effects && content && (!shaped || transparent_outside(l)) +} + +/// Whether every surface `l` draws from has alpha and a transparent default pixel. +fn transparent_outside(l: &Layer) -> bool { + match &l.content { + LayerContent::Group(g) => g.children.iter().all(transparent_outside), + _ => l.surface().is_none_or(|s| s.format().alpha && s.default_pixel().last().is_some_and(|a| *a <= 0.0)), + } +} + +fn effect_supported(e: &Effect) -> bool { + let paint = |p: &FxPaint| !matches!(p, FxPaint::Pattern { .. }); + match e { + Effect::DropShadow(s) | Effect::InnerShadow(s) => separable(s.common.blend), + Effect::OuterGlow(g) | Effect::InnerGlow(g) => separable(g.common.blend) && paint(&g.paint), + Effect::Stroke(s) => separable(s.common.blend) && paint(&s.paint), + Effect::ColorOverlay { common, .. } | Effect::GradientOverlay { common, .. } => separable(common.blend), + Effect::Satin(s) => separable(s.common.blend), + Effect::BevelEmboss(b) => separable(b.highlight.blend) && separable(b.shadow.blend) && b.texture.is_none(), + Effect::PatternOverlay { .. } => false, + } +} + +/// The brightness (1 − ink) of ink `i` of a CMYK pixel or colour (0 for a missing or non-finite +/// value: no ink). +fn brightness(inks: &[f32], i: usize) -> f32 { + 1.0 - inks.get(i).copied().map_or(0.0, clean) +} + +fn stand_in_color(c: &Color, planes: Planes) -> Color { + let ink = c.in_mode(ColorMode::Cmyk).c; + Color { mode: ColorMode::Rgb, c: [brightness(&ink, planes[0]), brightness(&ink, planes[1]), brightness(&ink, planes[2]), 0.0], alpha: c.alpha } +} + +/// A CMYK surface as an RGB one (same depth and alpha) holding the planes' brightness. +fn stand_in_surface(s: &Surface, planes: Planes) -> Surface { + let from = s.format(); + if from.mode != ColorMode::Cmyk { + return s.clone(); + } + let to = PixelFormat { mode: ColorMode::Rgb, sample: from.sample, alpha: from.alpha }; + let n = from.channels().max(1); + let px = |p: &[f32], dst: &mut Vec| { + dst.extend(planes.iter().map(|&i| brightness(p, i))); + if from.alpha { + dst.push(p.get(4).copied().unwrap_or(0.0)); + } + }; + let source_default = s.default_pixel(); + let mut default = Vec::new(); + px(&source_default, &mut default); + let map = |src: &[f32], dst: &mut Vec| { + for p in src.chunks_exact(n) { + let start = dst.len(); + px(p, dst); + // Layer bounds count the pixels that differ from the default, transparent ones too: a + // transparent pixel whose other inks differ keeps a colour of its own here (it never + // shows), so the stand-in's bounds are the document's. + if from.alpha + && p.get(4) == Some(&0.0) + && *p != *source_default + && dst.get(start..) == Some(&default[..]) + && let Some(v) = dst.get_mut(start) + { + *v = if *v > 0.5 { 0.0 } else { 1.0 }; + } + } + }; + let mut out = Surface::with_default(to, &default); + let rects: Vec = s.tiles().map(|(c, _)| c.rect()).collect(); + let convert = |r: &Rect| { + let (mut src, mut dst) = (Vec::new(), Vec::new()); + s.read_region_into(*r, &mut src); + map(&src, &mut dst); + (*r, dst) + }; + #[cfg(not(target_arch = "wasm32"))] + let tiles: Vec<(Rect, Vec)> = { + use rayon::prelude::*; + rects.par_iter().map(convert).collect() + }; + #[cfg(target_arch = "wasm32")] + let tiles: Vec<(Rect, Vec)> = rects.iter().map(convert).collect(); + for (r, data) in &tiles { + out.write_region(*r, data); + } + out +} + +/// A fill's colours as stand-ins. A solid colour is first stored at the document's depth, as the +/// compositor renders CMYK solid fills (`gradient_fill::render_cmyk_fill`). +fn stand_in_fill(f: &mut Fill, planes: Planes, depth: SampleType) { + match f { + Fill::Solid(c) => { + let one = Rect::new(0, 0, 1, 1); + let stored = crate::gradient_fill::render_cmyk_fill(&Fill::Solid(*c), one, one, depth).map(|s| s.pixel(0, 0)); + let ink = stored.as_deref().map_or(c.in_mode(ColorMode::Cmyk).c, |p| std::array::from_fn(|i| p.get(i).copied().unwrap_or(0.0))); + let alpha = stored.as_deref().and_then(|p| p.get(4).copied()).unwrap_or(c.alpha); + *c = stand_in_color(&Color { mode: ColorMode::Cmyk, c: ink, alpha }, planes); + } + Fill::Gradient { stops, .. } => stops.iter_mut().for_each(|s| s.1 = stand_in_color(&s.1, planes)), + _ => {} + } +} + +/// Levels and Curves on the CMYK channels as RGB records of the planes' inks (the composite +/// record stays the composite). +fn stand_in_adjustment(a: &mut Adjustment, planes: Planes) { + match a { + Adjustment::Levels { per_channel, space, black, .. } if *space == ToneSpace::Cmyk => { + let ink = |i: usize| if i == 3 { black.clone() } else { per_channel.get(i).cloned().unwrap_or_default() }; + *per_channel = [ink(planes[0]), ink(planes[1]), ink(planes[2])]; + *black = Default::default(); + *space = ToneSpace::Rgb; + } + Adjustment::Curves { per_channel, space, black, .. } if *space == ToneSpace::Cmyk => { + let ink = |i: usize| if i == 3 { black.clone() } else { per_channel.get(i).cloned().unwrap_or_default() }; + *per_channel = [ink(planes[0]), ink(planes[1]), ink(planes[2])]; + *black = Vec::new(); + *space = ToneSpace::Rgb; + } + _ => {} + } +} + +fn stand_in_effect(e: &mut Effect, planes: Planes) { + let cc = |c: &mut Color| *c = stand_in_color(c, planes); + let paint = |p: &mut FxPaint| match p { + FxPaint::Color(c) => cc(c), + FxPaint::Gradient(g) => g.stops.iter_mut().for_each(|s| cc(&mut s.1)), + FxPaint::Pattern { .. } => {} + }; + match e { + Effect::DropShadow(s) | Effect::InnerShadow(s) => cc(&mut s.color), + Effect::OuterGlow(g) | Effect::InnerGlow(g) => paint(&mut g.paint), + Effect::Stroke(s) => paint(&mut s.paint), + Effect::ColorOverlay { color, .. } => cc(color), + Effect::GradientOverlay { gradient, .. } => gradient.stops.iter_mut().for_each(|s| cc(&mut s.1)), + Effect::Satin(s) => cc(&mut s.color), + Effect::BevelEmboss(b) => { + cc(&mut b.highlight_color); + cc(&mut b.shadow_color); + } + Effect::PatternOverlay { .. } => {} + } +} + +fn stand_in_layer(l: &mut Layer, planes: Planes, depth: SampleType, canvas: Rect) { + let cache = |c: &mut Option| { + if let Some(s) = c { + *s = stand_in_surface(s, planes); + } + }; + let frame = crate::fill_frame(l, canvas); + // A fill covers the canvas and beyond, where effects near its edges reach. + let reach = canvas.inflate(crate::effects::margin(l).saturating_add(1)); + match &mut l.content { + LayerContent::Raster(s) => *s = stand_in_surface(s, planes), + LayerContent::Text(t) => cache(&mut t.cache), + LayerContent::Shape(sh) => cache(&mut sh.cache), + LayerContent::Smart(sm) => cache(&mut sm.cache), + LayerContent::Fill(f) => { + // The cache stays valid: its fill is changed the same way. + if let Some(c) = l.fill_cache.as_mut().filter(|c| c.fill == *f) { + c.surface = stand_in_surface(&c.surface, planes); + stand_in_fill(&mut c.fill, planes, depth); + } else if matches!(f, Fill::Gradient { .. }) + && let Some(s) = crate::gradient_fill::render_cmyk_fill(f, reach, frame, depth) + { + // A gradient is the compositor's own CMYK ramp (an RGB ramp of the stand-in + // colours would interpolate differently), given as the fill's rendered pixels. + let mut fill = f.clone(); + stand_in_fill(&mut fill, planes, depth); + l.fill_cache = Some(photocraft_doc::FillCache { fill, surface: stand_in_surface(&s, planes) }); + } + stand_in_fill(f, planes, depth); + } + LayerContent::Adjustment(a) => stand_in_adjustment(a, planes), + LayerContent::Group(g) => g.children.iter_mut().for_each(|c| stand_in_layer(c, planes, depth, canvas)), + } + l.effects.items.iter_mut().for_each(|e| stand_in_effect(e, planes)); +} + +/// `doc` as an RGB document carrying the `planes` inks' brightness. +pub(super) fn stand_in(doc: &Document, planes: Planes) -> Document { + let mut d = doc.clone(); + d.mode = ColorMode::Rgb; + d.icc_profile = None; + d.layers.iter_mut().for_each(|l| stand_in_layer(l, planes, doc.depth, doc.bounds())); + d +} + +/// A stand-in document rendered over `rect` by the RGB compositor, blends clipped to 0..1. +struct StandIn<'a> { + doc: &'a Document, + cx: Ctx<'a>, +} + +impl<'a> StandIn<'a> { + /// Ready to render `rect` (effect maps built up front, as the RGB compositor does). + fn prepare(&self, rect: Rect) { + self.cx.set_fx_clip(rect); + crate::prepare_effects(&self.doc.layers, rect, &self.cx, |f| crate::in_blend_space(false, false, f)); + } + + fn tile(&self, rect: Rect) -> Buffer { + crate::in_blend_space(false, false, || { + let mut b = Buffer::transparent(rect); + crate::composite_stack_at(&self.doc.layers, &mut b, &self.cx, advanced::Scope::ROOT); + b + }) + } +} + +/// The CMY and K stand-ins' tiles as one CMYK tile. +fn combine(cmy: &Buffer, k: &Buffer) -> CmykBuffer { + let ink = |v: f32| if v.is_finite() { (1.0 - v).clamp(0.0, 1.0) } else { 0.0 }; + let px = cmy + .px + .iter() + .zip(&k.px) + .map(|(p, q)| { + let alpha = clean(p[3]).clamp(0.0, 1.0); + if alpha <= 0.0 { [0.0; 5] } else { [ink(p[0]), ink(p[1]), ink(p[2]), ink(q[0]), alpha] } + }) + .collect(); + CmykBuffer { rect: cmy.rect, px } +} + +/// Renders `doc` (which [`supports`]) band by band through the two stand-ins. +pub(super) fn render_bands(doc: &Document, rect: Rect, band_rows: i32, tile: i32, mut sink: impl FnMut(CmykBuffer) -> Result<(), E>) -> Result<(), E> { + let (cmy, k) = (stand_in(doc, CMY), stand_in(doc, K)); + let no_patterns = pattern::PreparedPatterns::new(&[], pattern::PREPARED_PATTERN_BYTES); + let a = StandIn { doc: &cmy, cx: Ctx::for_doc(&cmy, &no_patterns) }; + let b = StandIn { doc: &k, cx: Ctx::for_doc(&k, &no_patterns) }; + let rows = crate::band_rows_for(rect.width(), band_rows); + let mut y = rect.y0; + while y < rect.y1 { + let y1 = y.saturating_add(rows).min(rect.y1); + let band = Rect::new(rect.x0, y, rect.x1, y1); + a.prepare(band); + b.prepare(band); + sink(super::render_with(band, tile, |t| combine(&a.tile(t), &b.tile(t))))?; + y = y1; + } + Ok(()) +} + +/// `doc`'s `planes` stand-in rendered over `rect` (tests compare plane orders). +#[cfg(test)] +pub(super) fn render_planes(doc: &Document, rect: Rect, planes: Planes) -> Buffer { + let d = stand_in(doc, planes); + let no_patterns = pattern::PreparedPatterns::new(&[], pattern::PREPARED_PATTERN_BYTES); + let s = StandIn { doc: &d, cx: Ctx::for_doc(&d, &no_patterns) }; + s.prepare(rect); + s.tile(rect) +} diff --git a/crates/compose/src/cmyk_tests.rs b/crates/compose/src/cmyk_tests.rs index a677e6e1ad..0b73c25301 100644 --- a/crates/compose/src/cmyk_tests.rs +++ b/crates/compose/src/cmyk_tests.rs @@ -396,7 +396,6 @@ fn unsupported_documents_fall_back() { check("hue", &|l| l.blend = BlendMode::Hue); check("luminosity", &|l| l.blend = BlendMode::Luminosity); check("lighter colour", &|l| l.blend = BlendMode::LighterColor); - check("knockout", &|l| l.advanced.knockout = Knockout::Shallow); check("channels", &|l| l.excluded_channels = 1); check("nan opacity", &|l| l.opacity = f32::NAN); // Adjustments that weigh the channels together, or whose records name RGB channels. @@ -418,7 +417,14 @@ fn unsupported_documents_fall_back() { } let mut d = simple(); d.layers.push(deep); - assert!(!supports(&d)); + assert!(!supports(&d) && !renders_inks(&d)); + // Knockouts take the ink-by-ink route through the RGB compositor instead. + let mut d = simple(); + let mut l = layer(&[(Rect::new(0, 0, 1, 1), [0.5; 5])]); + l.advanced.knockout = Knockout::Shallow; + d.layers.push(l); + assert!(!supports(&d) && split::supports(&d)); + assert!(render_cmyk(&d, d.bounds()).is_some()); } #[test] @@ -1094,6 +1100,8 @@ fn adjustment_stacks_match_the_reference() { iso.blend = BlendMode::Normal; d.layers.extend([inv, onto, base, lv, pass, iso]); assert_matches_reference(&d); + // The black record and the rest go the same way through the stand-ins. + assert_routes_agree(&d); } /// In a 32-bit document (no rounding to levels), inks an adjustment leaves alone come out @@ -1120,3 +1128,488 @@ fn untouched_inks_stay_bit_exact() { assert!((got[3] - want_k).abs() < 1e-6, "{blend:?}: {got:?}"); } } + +// ---- stage 4: layer effects, ink by ink through the RGB compositor ----------------------------- + +use photocraft_doc::effects::{ + Bevel, BevelStyle, BevelTechnique, Contour, Effect, FxCommon, FxPaint, Glow, GlowSource, GlowTechnique, Gradient, Satin, Shadow, StrokeFx, StrokePosition, +}; + +fn ink_color(c: [f32; 4]) -> photocraft_color::Color { + photocraft_color::Color { mode: ColorMode::Cmyk, c, alpha: 1.0 } +} + +/// `d` over its canvas grown by a pixel, through the split route in 3-pixel tiles. +fn split_render(d: &Document) -> CmykBuffer { + let rect = Rect::new(-1, -1, d.size.width as i32 + 1, d.size.height as i32 + 1); + let mut out = CmykBuffer::transparent(rect); + let r = split::render_bands(d, rect, 0, 3, |b| { + super::place(&mut out, &b); + Ok::<(), ()>(()) + }); + assert!(r.is_ok()); + out +} + +#[derive(Debug, Clone)] +enum FxSpec { + Shadow { inner: bool, color: [f32; 4], blend: BlendMode, opacity: f32, distance: f32, size: f32, spread: f32, knocks_out: bool }, + Glow { inner: bool, color: [f32; 4], gradient: Option<[f32; 4]>, blend: BlendMode, opacity: f32, size: f32 }, + Stroke { color: [f32; 4], gradient: Option<[f32; 4]>, position: u8, size: f32, blend: BlendMode, opacity: f32 }, + Overlay { color: [f32; 4], blend: BlendMode, opacity: f32 }, + GradientOverlay { from: [f32; 4], to: [f32; 4], blend: BlendMode, opacity: f32 }, + Satin { color: [f32; 4], blend: BlendMode, opacity: f32, invert: bool }, + Bevel { style: u8, size: f32, up: bool, highlight: [f32; 4], shadow: [f32; 4] }, +} + +fn inks4() -> impl Strategy { + (unit(), unit(), unit(), unit()).prop_map(|(c, m, y, k)| [c, m, y, k]) +} + +fn fx_spec() -> impl Strategy { + prop_oneof![ + (any::(), inks4(), blend_mode(), unit(), 0.0f32..3.0, 0.0f32..3.0, unit(), any::()).prop_map( + |(inner, color, blend, opacity, distance, size, spread, knocks_out)| FxSpec::Shadow { + inner, + color, + blend, + opacity, + distance, + size, + spread, + knocks_out + } + ), + (any::(), inks4(), prop::option::of(inks4()), blend_mode(), unit(), 0.0f32..3.0) + .prop_map(|(inner, color, gradient, blend, opacity, size)| FxSpec::Glow { inner, color, gradient, blend, opacity, size }), + (inks4(), prop::option::of(inks4()), 0u8..3, 1.0f32..3.0, blend_mode(), unit()) + .prop_map(|(color, gradient, position, size, blend, opacity)| FxSpec::Stroke { color, gradient, position, size, blend, opacity }), + (inks4(), blend_mode(), unit()).prop_map(|(color, blend, opacity)| FxSpec::Overlay { color, blend, opacity }), + (inks4(), inks4(), blend_mode(), unit()).prop_map(|(from, to, blend, opacity)| FxSpec::GradientOverlay { from, to, blend, opacity }), + (inks4(), blend_mode(), unit(), any::()).prop_map(|(color, blend, opacity, invert)| FxSpec::Satin { color, blend, opacity, invert }), + (0u8..5, 1.0f32..3.0, any::(), inks4(), inks4()).prop_map(|(style, size, up, highlight, shadow)| FxSpec::Bevel { + style, + size, + up, + highlight, + shadow + }), + ] +} + +fn make_effect(f: &FxSpec) -> Effect { + let paint = |c: &[f32; 4], g: &Option<[f32; 4]>| match g { + Some(to) => FxPaint::Gradient(Gradient { stops: vec![(0.0, ink_color(*c)), (1.0, ink_color(*to))], ..Default::default() }), + None => FxPaint::Color(ink_color(*c)), + }; + match f { + FxSpec::Shadow { inner, color, blend, opacity, distance, size, spread, knocks_out } => { + let s = Shadow { + common: FxCommon::new(*blend, *opacity), + color: ink_color(*color), + angle: 120.0, + use_global_light: false, + distance: *distance, + spread: *spread, + size: *size, + contour: Contour::Linear, + anti_alias: false, + noise: 0.0, + knocks_out: *knocks_out, + }; + if *inner { Effect::InnerShadow(s) } else { Effect::DropShadow(s) } + } + FxSpec::Glow { inner, color, gradient, blend, opacity, size } => { + let g = Glow { + common: FxCommon::new(*blend, *opacity), + paint: paint(color, gradient), + technique: GlowTechnique::Softer, + spread: 0.0, + size: *size, + contour: Contour::Linear, + anti_alias: false, + range: 0.5, + jitter: 0.0, + noise: 0.0, + source: GlowSource::Edge, + }; + if *inner { Effect::InnerGlow(g) } else { Effect::OuterGlow(g) } + } + FxSpec::Stroke { color, gradient, position, size, blend, opacity } => Effect::Stroke(StrokeFx { + common: FxCommon::new(*blend, *opacity), + size: *size, + position: [StrokePosition::Outside, StrokePosition::Inside, StrokePosition::Center][usize::from(*position) % 3], + paint: paint(color, gradient), + }), + FxSpec::Overlay { color, blend, opacity } => Effect::ColorOverlay { common: FxCommon::new(*blend, *opacity), color: ink_color(*color) }, + FxSpec::GradientOverlay { from, to, blend, opacity } => Effect::GradientOverlay { + common: FxCommon::new(*blend, *opacity), + gradient: Gradient { stops: vec![(0.0, ink_color(*from)), (1.0, ink_color(*to))], ..Default::default() }, + dither: false, + }, + FxSpec::Satin { color, blend, opacity, invert } => Effect::Satin(Satin { + common: FxCommon::new(*blend, *opacity), + color: ink_color(*color), + angle: 19.0, + distance: 2.0, + size: 2.0, + contour: Contour::Linear, + anti_alias: false, + invert: *invert, + }), + FxSpec::Bevel { style, size, up, highlight, shadow } => Effect::BevelEmboss(Bevel { + enabled: true, + style: [BevelStyle::OuterBevel, BevelStyle::InnerBevel, BevelStyle::Emboss, BevelStyle::PillowEmboss, BevelStyle::StrokeEmboss] + [usize::from(*style) % 5], + technique: BevelTechnique::Smooth, + depth: 1.0, + up: *up, + size: *size, + soften: 0.0, + angle: 120.0, + altitude: 30.0, + use_global_light: false, + gloss_contour: Contour::Linear, + highlight: FxCommon::new(BlendMode::Screen, 0.75), + highlight_color: ink_color(*highlight), + shadow: FxCommon::new(BlendMode::Multiply, 0.75), + shadow_color: ink_color(*shadow), + contour: None, + texture: None, + }), + } +} + +/// A random document with effects on some of its layers (and a knockout now and then). +fn with_effects(s: &Spec, fx: &[(usize, FxSpec)], knockout: Option) -> Document { + let mut d = doc(s.w as u32, s.h as u32); + d.layers = s.layers.iter().map(build).collect(); + let n = d.layers.len().max(1); + for (i, f) in fx { + // Adjustment layers don't carry effects (see `split::supports`). + if let Some(l) = d.layers.get_mut(i % n).filter(|l| !matches!(l.content, LayerContent::Adjustment(_))) { + l.effects.enabled = true; + l.effects.items.push(make_effect(f)); + } + } + if let Some(l) = knockout.and_then(|i| d.layers.get_mut(i % n)) { + l.advanced.knockout = Knockout::Shallow; + } + d +} + +proptest! { + #![proptest_config(ProptestConfig { cases: 120, ..ProptestConfig::default() })] + + /// On every stack the exact path handles, the split route gives the same inks. + #[test] + fn the_split_route_agrees_with_the_exact_path(s in spec()) { + prop_assume!(!clips_onto_pass_through(&s.layers)); + let mut d = doc(s.w as u32, s.h as u32); + d.layers = s.layers.iter().map(build).collect(); + prop_assume!(supports(&d) && split::supports(&d)); + // Both are exact up to float rounding, which a mode that jumps can magnify (see [`jumps`]). + prop_assume!(!any_layer(&d.layers, &|l| jumps(l.blend))); + let via = split_render(&d); + let exact = render_cmyk(&d, via.rect).unwrap_or_else(|| panic!("supported")); + for (i, (g, w)) in via.px.iter().zip(&exact.px).enumerate() { + prop_assert!((g[4] - w[4]).abs() <= 1e-5, "alpha {i}: {g:?} vs {w:?}"); + if w[4] > 1e-4 { + prop_assert!((0..4).all(|c| (g[c] - w[c]).abs() <= 1e-5), "ink {i}: {g:?} vs {w:?}"); + } + } + } + + /// The RGB compositor treats every channel on its own for everything the split route + /// allows, effects included: which ink feeds which channel doesn't change any ink's result + /// (nor coverage). That is what makes running it on inks' brightness exact. + #[test] + fn effects_work_channel_by_channel( + s in spec(), + fx in prop::collection::vec((0usize..8, fx_spec()), 1..4), + knockout in prop::option::of(0usize..8), + ) { + let d = with_effects(&s, &fx, knockout); + prop_assume!(split::supports(&d)); + let rect = Rect::new(-2, -2, s.w + 2, s.h + 2); + let cmy = split::render_planes(&d, rect, [0, 1, 2]); + let rot = split::render_planes(&d, rect, [1, 2, 0]); + let k = split::render_planes(&d, rect, [3, 3, 3]); + let mix = split::render_planes(&d, rect, [3, 0, 3]); + let same = |a: f32, b: f32| (a - b).abs() <= 1e-6 || (a.is_nan() && b.is_nan()); + for i in 0..cmy.px.len() { + let (p, r, q, m) = (cmy.px[i], rot.px[i], k.px[i], mix.px[i]); + prop_assert!(same(p[3], r[3]) && same(p[3], q[3]) && same(p[3], m[3]), "coverage {i}: {p:?} {r:?} {q:?} {m:?}"); + prop_assert!(same(r[0], p[1]) && same(r[1], p[2]) && same(r[2], p[0]), "rotated {i}: {p:?} vs {r:?}"); + prop_assert!(same(q[0], q[1]) && same(q[1], q[2]), "black {i}: {q:?}"); + prop_assert!(same(m[0], q[0]) && same(m[1], p[0]) && same(m[2], q[0]), "mixed {i}: {m:?} vs {p:?} / {q:?}"); + } + } + + /// Effects don't depend on the tiling or banding (beyond the RGB compositor's own float + /// rounding, which can differ by an ulp between tilings). + #[test] + fn split_tiling_is_invisible(s in spec(), fx in prop::collection::vec((0usize..8, fx_spec()), 1..3), tile in 1i32..9) { + let d = with_effects(&s, &fx, None); + prop_assume!(split::supports(&d)); + let whole = render_cmyk_tiled(&d, d.bounds(), 1024).unwrap_or_else(|| panic!("supported")); + let tiled = render_cmyk_tiled(&d, d.bounds(), tile).unwrap_or_else(|| panic!("supported")); + for (p, q) in tiled.px.iter().zip(&whole.px) { + prop_assert!(p.iter().zip(q).all(|(a, b)| (a - b).abs() <= 1e-6), "{p:?} vs {q:?}"); + } + } +} + +/// A K-only drop shadow under K-only type on blank paper puts down black ink only. +#[test] +fn k_only_shadows_stay_k_only() { + let mut d = doc(12, 8); + d.layers.push(paper(12, 8, [0.0; 4])); + let mut t = layer(&[(Rect::new(2, 2, 6, 5), [0.0, 0.0, 0.0, 1.0, 1.0])]); + t.effects.enabled = true; + t.effects.items.push(Effect::DropShadow(Shadow { + common: FxCommon::new(BlendMode::Multiply, 0.75), + color: ink_color([0.0, 0.0, 0.0, 1.0]), + angle: 135.0, + use_global_light: false, + distance: 2.0, + spread: 0.0, + size: 0.0, + contour: Contour::Linear, + anti_alias: false, + noise: 0.0, + knocks_out: true, + })); + d.layers.push(t); + assert!(!supports(&d) && split::supports(&d)); + let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported")); + assert!(got.px.iter().all(|p| p[..3].iter().all(|v| *v <= 1e-6)), "no C, M or Y anywhere"); + // Light from the upper left: the shadow falls a pixel down and to the right of the type. + let at = |x: i32, y: i32| got.px[(y * 12 + x) as usize]; + assert!((at(6, 5)[3] - 0.75).abs() < 1e-5, "shadow: {:?}", at(6, 5)); + assert!((at(3, 3)[3] - 1.0).abs() < 1e-6, "type: {:?}", at(3, 3)); + assert!(at(10, 1)[3] <= 1e-6, "paper: {:?}", at(10, 1)); +} + +/// A colour overlay paints the layer in exactly its inks; an outside stroke in its own. +#[test] +fn overlays_and_strokes_paint_exact_inks() { + let mut d = doc(10, 8); + d.layers.push(paper(10, 8, [0.0; 4])); + let mut l = layer(&[(Rect::new(3, 3, 7, 6), [0.0, 0.0, 0.0, 1.0, 1.0])]); + l.effects.enabled = true; + l.effects.items.push(Effect::ColorOverlay { common: FxCommon::new(BlendMode::Normal, 1.0), color: ink_color([0.2, 0.4, 0.6, 0.1]) }); + l.effects.items.push(Effect::Stroke(StrokeFx { + common: FxCommon::new(BlendMode::Normal, 1.0), + size: 1.0, + position: StrokePosition::Outside, + paint: FxPaint::Color(ink_color([0.0, 1.0, 0.0, 0.0])), + })); + d.layers.push(l); + let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported")); + let at = |x: i32, y: i32| got.px[(y * 10 + x) as usize]; + let near = |a: Cmyka, b: Cmyka| a.iter().zip(b).all(|(x, y)| (x - y).abs() <= 1e-6); + assert!(near(at(4, 4), [0.2, 0.4, 0.6, 0.1, 1.0]), "overlay: {:?}", at(4, 4)); + assert!(near(at(2, 4), [0.0, 1.0, 0.0, 0.0, 1.0]), "stroke: {:?}", at(2, 4)); + assert!(near(at(0, 0), [0.0, 0.0, 0.0, 0.0, 1.0]), "paper: {:?}", at(0, 0)); +} + +/// Pattern paints and channel-mixing effect modes stay on the RGB compositor. +#[test] +fn effects_that_mix_channels_fall_back() { + let with = |e: Effect| { + let mut d = doc(2, 2); + let mut l = layer(&[(Rect::new(0, 0, 1, 1), [0.5; 5])]); + l.effects.enabled = true; + l.effects.items.push(e); + d.layers.push(l); + d + }; + let overlay = |blend| Effect::ColorOverlay { common: FxCommon::new(blend, 1.0), color: ink_color([0.5; 4]) }; + assert!(split::supports(&with(overlay(BlendMode::Multiply)))); + assert!(!renders_inks(&with(overlay(BlendMode::Color)))); + let pattern = Effect::PatternOverlay { + common: FxCommon::new(BlendMode::Normal, 1.0), + name: "p".into(), + id: "p".into(), + scale: 1.0, + angle: 0.0, + link: true, + phase: (0.0, 0.0), + }; + assert!(!renders_inks(&with(pattern))); + // Effects on an adjustment layer (it has no pixels of its own to shape them). + let mut adj = adjustment(Adjustment::Invert); + adj.effects.enabled = true; + adj.effects.items.push(overlay(BlendMode::Multiply)); + let mut d = doc(2, 2); + d.layers.push(adj); + assert!(!split::supports(&d)); + // 32-bit CMYK documents too. + let mut d = with(overlay(BlendMode::Multiply)); + d.depth = SampleType::F32; + assert!(!split::supports(&d)); +} + +/// Found by a long random run: Normal mixing onto nothing must give the source's ink exactly. A +/// rounding error (1 → 0.99999994) is magnified by modes that jump at full ink, here Reflect +/// turning no ink into full K. +#[test] +fn normal_onto_nothing_is_exact() { + let shape = LayerSpec::Pixels { + kind: Kind::Shape, + blend: BlendMode::Normal, + fills: vec![(Rect::new(0, 0, 1, 1), [0.0, 0.0, 0.0, 1.0, 1.0])], + opacity: 1.0, + fill: 1.0, + clipped: false, + visible: true, + mask: Some(MaskSpec { rects: vec![], default: 0.4949783, density: 1.0, enabled: true }), + }; + let inv = LayerSpec::Pixels { + kind: Kind::Adjust(AdjSpec::Invert), + blend: BlendMode::Reflect, + fills: vec![(Rect::new(0, 0, 1, 1), [0.0; 5])], + opacity: 1.0, + fill: 1.0, + clipped: false, + visible: true, + mask: None, + }; + let mut d = doc(4, 6); + d.layers = + vec![build(&LayerSpec::Group { children: vec![shape, inv], pass_through: false, blend: BlendMode::Normal, opacity: 1.0, fill: 1.0, mask: None })]; + assert_matches_reference(&d); + assert_eq!(render1(&d, 0, 0)[..4], [0.0; 4]); +} + +/// Found by a long random run: a transparent pixel with ink of its own counts towards the +/// layer's bounds, which lay out a gradient overlay; the stand-ins keep it counted whichever ink +/// they carry. +#[test] +fn transparent_inked_pixels_keep_their_bounds() { + let inner = LayerSpec::Pixels { + kind: Kind::Raster, + blend: BlendMode::Normal, + fills: vec![(Rect::new(0, -1, 1, 1), [0.0, 0.0, 0.0, 0.0, 1.0]), (Rect::new(0, 1, 1, 2), [0.0, 0.0, 1.0, 0.0, 0.0])], + opacity: 1.0, + fill: 1.0, + clipped: false, + visible: true, + mask: None, + }; + let g = |children: Vec, pass_through: bool| LayerSpec::Group { + children, + pass_through, + blend: BlendMode::Normal, + opacity: 1.0, + fill: 1.0, + mask: None, + }; + let s = Spec { w: 2, h: 2, layers: vec![g(vec![g(vec![g(vec![inner], false)], false)], true)] }; + let fx = [(0usize, FxSpec::GradientOverlay { from: [1.0, 0.0, 0.0, 0.0], to: [0.0; 4], blend: BlendMode::Normal, opacity: 1.0 })]; + let d = with_effects(&s, &fx, None); + let rect = Rect::new(-2, -2, 4, 4); + let cmy = split::render_planes(&d, rect, [0, 1, 2]); + for planes in [[3, 0, 3], [0, 0, 0], [0, 3, 3]] { + let other = split::render_planes(&d, rect, planes); + let at = planes.iter().position(|p| *p == 0).unwrap_or(0); + for (p, o) in cmy.px.iter().zip(&other.px) { + assert!((p[0] - o[at]).abs() <= 1e-6 && (p[3] - o[3]).abs() <= 1e-6, "{planes:?}: {p:?} vs {o:?}"); + } + } +} + +/// Blend modes that jump (at no ink or full ink): a rounding difference between two exact +/// computations can land on either side of the jump. +fn jumps(mode: BlendMode) -> bool { + use BlendMode as B; + matches!(mode, B::ColorBurn | B::ColorDodge | B::VividLight | B::HardMix | B::Divide | B::Reflect | B::Glow | B::PaintNetColorBurn | B::PaintNetColorDodge) +} + +fn any_layer(layers: &[Layer], f: &dyn Fn(&Layer) -> bool) -> bool { + layers.iter().any(|l| f(l) || matches!(&l.content, LayerContent::Group(g) if any_layer(&g.children, f))) +} + +/// The display form of the ink composite: where a single opaque layer's pixel shows, it is the +/// colour the RGB compositor shows (both read the inks through the document's profile). +#[test] +fn display_shows_the_inks_through_the_profile() { + let mut d = doc(8, 4); + d.layers.push(paper(8, 4, [0.0; 4])); + d.layers.push(layer(&[(Rect::new(0, 0, 4, 4), [0.0, 0.0, 0.0, 1.0, 1.0]), (Rect::new(4, 0, 8, 2), [0.7, 0.1, 0.0, 0.3, 1.0])])); + let shown = render_display(&d, d.bounds()).unwrap_or_else(|| panic!("supported")); + let rgb = crate::render(&d, d.bounds()); + for (s, r) in shown.px.iter().zip(&rgb.px) { + assert!(s.iter().zip(r).all(|(a, b)| (a - b).abs() <= 1e-4), "{s:?} vs {r:?}"); + } + // Unsupported documents have no ink composite to show. + let mut lum = layer(&[(Rect::new(0, 0, 1, 1), [0.5; 5])]); + lum.blend = BlendMode::Luminosity; + d.layers.push(lum); + assert!(render_display(&d, d.bounds()).is_none()); +} + +/// The split route gives the exact path's inks on `d` (which both handle). +fn assert_routes_agree(d: &Document) { + assert!(supports(d) && split::supports(d)); + let via = split_render(d); + let exact = render_cmyk(d, via.rect).unwrap_or_else(|| panic!("supported")); + for (g, w) in via.px.iter().zip(&exact.px) { + assert!((g[4] - w[4]).abs() <= 1e-5 && (w[4] <= 1e-4 || (0..4).all(|c| (g[c] - w[c]).abs() <= 1e-5)), "{g:?} vs {w:?}"); + } +} + +/// Black-only Levels and Curves through the stand-ins: K changes, nothing else does. +#[test] +fn black_records_reach_k_through_the_stand_ins() { + use photocraft_doc::adjust::{CurvePoint, LevelsChannel, ToneSpace}; + let d0 = LevelsChannel::default; + for adj in [ + cmyk_levels(d0(), LevelsChannel { out_white: 0.5, ..d0() }), + Adjustment::Curves { + master: Vec::new(), + per_channel: [Vec::new(), Vec::new(), Vec::new()], + space: ToneSpace::Cmyk, + black: vec![CurvePoint { input: 0.0, output: 0.0 }, CurvePoint { input: 1.0, output: 0.6 }], + }, + ] { + let mut d = doc(3, 1); + d.layers.push(paper(3, 1, [0.1, 0.2, 0.3, 0.0])); + d.layers.push(adjustment(adj)); + assert_routes_agree(&d); + assert!(split_render(&d).px.iter().filter(|p| p[4] > 0.0).all(|p| p[3] > 0.3), "K added"); + } +} + +/// Effects are laid out over the layer's bounds, which on a layer without transparency the +/// stand-ins can't keep (its pixels that differ only in other inks would match the default): +/// such a layer stays on the RGB compositor. +#[test] +fn effects_on_opaque_layers_fall_back() { + let mut d = doc(4, 4); + let mut bg = paper(4, 4, [0.0; 4]); + bg.effects.enabled = true; + bg.effects.items.push(Effect::ColorOverlay { common: FxCommon::new(BlendMode::Multiply, 0.5), color: ink_color([0.0, 0.0, 0.0, 1.0]) }); + d.layers.push(bg); + assert!(!split::supports(&d) && !renders_inks(&d)); +} + +/// Solid and gradient fills without rendered pixels give the same inks on both routes (both +/// stored at the document's levels, as the compositor renders CMYK fills). +#[test] +fn fills_agree_on_both_routes() { + let g = photocraft_doc::Fill::gradient( + vec![(0.0, cmyk_color([1.0, 0.2, 0.0, 0.0], 1.0)), (1.0, cmyk_color([0.0, 0.0, 0.7, 1.0], 0.6))], + 30.0, + 1.0, + Default::default(), + false, + ); + for fill in [g, photocraft_doc::Fill::Solid(cmyk_color([0.13, 0.0, 0.9375, 0.0], 0.55))] { + let mut d = doc(9, 5); + d.layers.push(paper(9, 5, [0.0, 0.1, 0.0, 0.0])); + d.layers.push(Layer::new("f", LayerContent::Fill(fill))); + assert_routes_agree(&d); + } +} diff --git a/crates/io/tests/cmyk_export.rs b/crates/io/tests/cmyk_export.rs index 5f192700c8..67d5ed77e3 100644 --- a/crates/io/tests/cmyk_export.rs +++ b/crates/io/tests/cmyk_export.rs @@ -174,3 +174,42 @@ fn channel_weighing_adjustments_go_through_the_profile() { assert!(r.warnings.iter().any(|w| w.contains("converted back through the document's CMYK profile")), "{:?}", r.warnings); assert_eq!(decode(&r.bytes).layout(), ChannelLayout::Cmyk); } + +#[test] +fn layer_effects_export_their_inks() { + // K-only type with a K-only drop shadow on blank paper: the TIFF has black ink only. + use photocraft_doc::effects::{Contour, Effect, FxCommon, Shadow}; + let mut d = cmyk_doc(SampleType::U8); + d.layers.push(fill(SampleType::U8, false, &[(Rect::new(0, 0, 12, 8), [0.0; 5])])); + let mut t = fill(SampleType::U8, true, &[(Rect::new(2, 2, 6, 5), [0.0, 0.0, 0.0, 1.0, 1.0])]); + t.effects.enabled = true; + t.effects.items.push(Effect::DropShadow(Shadow { + common: FxCommon::new(BlendMode::Multiply, 0.75), + color: photocraft_color::Color { mode: ColorMode::Cmyk, c: [0.0, 0.0, 0.0, 1.0], alpha: 1.0 }, + angle: 135.0, + use_global_light: false, + distance: 2.0, + spread: 0.0, + size: 1.0, + contour: Contour::Linear, + anti_alias: false, + noise: 0.0, + knocks_out: true, + })); + d.layers.push(t); + let r = export(&d, "a.tif", &ExportOptions::default()).unwrap_or_else(|e| panic!("{e}")); + assert!(!r.warnings.iter().any(|w| w.contains("converted back")), "{:?}", r.warnings); + let img = decode(&r.bytes); + assert_eq!(img.layout(), ChannelLayout::Cmyk); + let mut shadow = 0; + for y in 0..8 { + for x in 0..12 { + let p = pixel(&img, x, y); + assert_eq!(&p[..3], &[0.0; 3], "({x},{y}) {p:?}"); + shadow += usize::from(p[3] > 0.0 && p[3] < 1.0); + } + } + assert!(shadow > 0, "a soft shadow"); + assert_eq!(pixel(&img, 3, 3), vec![0.0, 0.0, 0.0, 1.0], "type"); +} + From d500c0361cef7eeb512daaf482bb81873301c3ee Mon Sep 17 00:00:00 2001 From: SBaksa Date: Sun, 11 Oct 2026 10:38:57 +1100 Subject: [PATCH 021/649] PSD export: CMYK merged image mixed on ink values The merged image of a CMYK PSD (what other applications show and print) comes from the ink composite whenever the document's layers mix on their ink values, so K-only black stays K-only there as in TIFF and JPEG exports. Other documents keep the RGB composite converted through the document's profile. --- crates/io/src/psd_export.rs | 48 ++++++++++++++++++++++++++++++++++ crates/io/tests/cmyk_export.rs | 22 ++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/crates/io/src/psd_export.rs b/crates/io/src/psd_export.rs index b872019c90..d861022e60 100644 --- a/crates/io/src/psd_export.rs +++ b/crates/io/src/psd_export.rs @@ -1076,6 +1076,9 @@ fn cmyk_of(fmt: &PixelFormat) -> bool { /// The merged image's planes (colour channels, then alpha), big-endian, matted against white /// when `matte`; with whether any pixel needs the alpha channel and whether any is below 1. fn merged_planes(doc: &Document, fmt: &PixelFormat, cmyk: bool, matte: bool) -> (Vec, bool, bool) { + if cmyk && let Some(planes) = merged_ink_planes(doc, fmt.sample, matte) { + return planes; + } let sample = fmt.sample; let cc = fmt.mode.color_channels(); let bps = sample.bytes(); @@ -1128,6 +1131,51 @@ fn merged_planes(doc: &Document, fmt: &PixelFormat, cmyk: bool, matte: bool) -> (planes, has_alpha, translucent) } +/// [`merged_planes`] of a CMYK document whose layers are mixed on their ink values +/// (`photocraft_compose::cmyk`), so opaque pixels keep their exact inks; `None` for documents +/// that composite in RGB. +fn merged_ink_planes(doc: &Document, sample: SampleType, matte: bool) -> Option<(Vec, bool, bool)> { + let bps = sample.bytes(); + let n = doc.size.area() as usize; + let plane = n * bps; + let mut planes = vec![0u8; plane * 5]; + let (mut has_alpha, mut translucent) = (false, false); + let canvas = doc.bounds(); + let w = canvas.width() as usize; + let done = photocraft_compose::cmyk::render_cmyk_bands(doc, canvas, 0, |band| -> Result<(), ()> { + // Retain alpha whenever it differs from opaque at the stored precision. + has_alpha |= band.px.iter().any(|p| match sample { + SampleType::U8 => q255(p[4]) < 255, + SampleType::U16 => (p[4].clamp(0.0, 1.0) * 65535.0 + 0.5) as u16 != u16::MAX, + SampleType::F32 => p[4] != 1.0, + }); + translucent |= band.px.iter().any(|p| p[4] < 1.0); + let start = (band.rect.y0 - canvas.y0) as usize * w; + let parts = crate::pixels::par_map(crate::pixels::bands(band.px.len()), |range| { + let mut out: Vec> = (0..5).map(|_| Vec::with_capacity(range.len() * bps)).collect(); + for p in band.px.get(range.clone()).unwrap_or(&[]) { + for (c, o) in out.iter_mut().enumerate() { + // Inks matted against white paper (no ink) like Photoshop (see + // `pixels::matte`), and stored inverted as PSD's CMYK is. + let v = if c < 4 { 1.0 - if matte { crate::pixels::matte(p[c], p[4], 0.0) } else { p[c] } } else { p[4] }; + encode_be(v, sample, o); + } + } + (range.start, out) + }); + for (at, part) in parts { + for (c, src) in part.iter().enumerate() { + let o = c * plane + (start + at) * bps; + if let Some(dst) = planes.get_mut(o..o + src.len()) { + dst.copy_from_slice(src); + } + } + } + Ok(()) + })?; + done.ok().map(|()| (planes, has_alpha, translucent)) +} + /// Converts a document to a PSD file model (see [`document_to_psd_with`]). pub fn document_to_psd(doc: &Document) -> PsdFile { document_to_psd_with(doc, &PsdExportOptions::default()).0 diff --git a/crates/io/tests/cmyk_export.rs b/crates/io/tests/cmyk_export.rs index 67d5ed77e3..6d0b0c88a3 100644 --- a/crates/io/tests/cmyk_export.rs +++ b/crates/io/tests/cmyk_export.rs @@ -213,3 +213,25 @@ fn layer_effects_export_their_inks() { assert_eq!(pixel(&img, 3, 3), vec![0.0, 0.0, 0.0, 1.0], "type"); } +#[test] +fn psd_merged_image_keeps_exact_inks() { + // The PSD's merged image (what other apps show and print) is mixed on the inks too: K-only + // black under a Multiply layer stays K-only, and the four-colour patch keeps its inks. + let mut d = layered(SampleType::U8); + let mut m = fill(SampleType::U8, true, &[(Rect::new(0, 0, 12, 8), [0.0, 0.4, 0.0, 0.0, 1.0])]); + m.blend = BlendMode::Multiply; + d.layers.push(m); + let r = export(&d, "a.psd", &ExportOptions::default()).unwrap_or_else(|e| panic!("{e}")); + let f = photocraft_psd::PsdFile::from_bytes(&r.bytes).unwrap_or_else(|e| panic!("{e}")); + let planes = f.decode_merged().unwrap_or_else(|e| panic!("{e}")); + let n = 12 * 8; + // Planar, inverted (255 = no ink). + let ink = |c: usize, x: usize, y: usize| 255 - i32::from(planes.get(c * n + y * 12 + x).copied().unwrap_or(0)); + let q = |v: f32| (v * 255.0).round() as i32; + assert_eq!([ink(0, 2, 3), ink(1, 2, 3), ink(2, 2, 3), ink(3, 2, 3)], [0, q(0.4), 0, 255], "K-only black with magenta multiplied in"); + let mul = |b: f32, s: f32| b + s - b * s; + let qb = |v: f32| ((v * 255.0).round()) / 255.0; + let want = [q(0.2), q(mul(qb(0.4), qb(0.4))), q(0.6), q(0.1)]; + let got = [ink(0, 8, 1), ink(1, 8, 1), ink(2, 8, 1), ink(3, 8, 1)]; + assert!(got.iter().zip(want).all(|(g, w)| (g - w).abs() <= 1), "{got:?} vs {want:?}"); +} From 06341463831f3ddfb788f5c9d2ea87c59f7d6af1 Mon Sep 17 00:00:00 2001 From: SBaksa Date: Sun, 11 Oct 2026 14:03:01 +1100 Subject: [PATCH 022/649] Flatten Image, Stamp Visible and Copy Merged keep a CMYK document's inks flatten_to_surface (Flatten Image, Merge/Stamp Visible, Copy Merged) composited a CMYK document in RGB and converted it back, turning K-only black into four-colour black (K100 became C18 M11 Y12 K91) and shifting other inks. Documents whose layers mix on their ink values are now flattened from that composite (over white paper, no ink, for Flatten Image); others are converted back through the document's own profile, the one their layers were read through, rather than the built-in one. --- crates/compose/src/cmyk_tests.rs | 19 ++++++++++++++++ crates/compose/src/lib.rs | 39 ++++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/crates/compose/src/cmyk_tests.rs b/crates/compose/src/cmyk_tests.rs index 0b73c25301..de07424dd0 100644 --- a/crates/compose/src/cmyk_tests.rs +++ b/crates/compose/src/cmyk_tests.rs @@ -1613,3 +1613,22 @@ fn fills_agree_on_both_routes() { assert_routes_agree(&d); } } + +/// Flatten Image, Stamp Visible and Copy Merged (all [`crate::flatten_to_surface`]) keep a CMYK +/// document's inks: K-only black stays K-only instead of turning four-colour. +#[test] +fn flattening_keeps_exact_inks() { + let mut d = doc(3, 1); + d.layers.push(layer(&[ + (Rect::new(0, 0, 1, 1), [0.0, 0.0, 0.0, 1.0, 1.0]), + (Rect::new(1, 0, 2, 1), [0.2, 0.4, 0.6, 0.1, 1.0]), + (Rect::new(2, 0, 3, 1), [0.0, 0.0, 0.0, 1.0, 0.4]), + ])); + // Over white paper (Flatten Image) and kept transparent (Stamp Visible). + let flat = crate::flatten_to_surface(&d, CMYK8, Some([1.0; 3])); + assert_eq!(flat.pixel(0, 0), vec![0.0, 0.0, 0.0, 1.0]); + assert_eq!(flat.pixel(1, 0), vec![q(0.2), q(0.4), q(0.6), q(0.1)]); + assert_eq!(flat.pixel(2, 0), vec![0.0, 0.0, 0.0, q(0.4)], "40% K over paper"); + let stamp = crate::flatten_to_surface(&d, CMYKA8, None); + assert_eq!(stamp.pixel(2, 0), vec![0.0, 0.0, 0.0, 1.0, q(0.4)]); +} diff --git a/crates/compose/src/lib.rs b/crates/compose/src/lib.rs index c9419e82b7..7ab47a39da 100644 --- a/crates/compose/src/lib.rs +++ b/crates/compose/src/lib.rs @@ -232,11 +232,40 @@ pub fn band_rows_for(width: u32, requested: i32) -> i32 { /// The document's composite as a pixel surface in `fmt` (straight RGBA converted to its model /// and depth), optionally flattened over an opaque `background`; rendered and written in bands, -/// so no full-size float composite is held. Tiles equal to the default pixel are pruned. +/// so no full-size float composite is held. Tiles equal to the default pixel are pruned. A CMYK +/// document flattened to CMYK keeps its inks where its layers mix on them ([`cmyk`]); otherwise +/// its composite goes back to CMYK through its own profile, the one its layers were read through. pub fn flatten_to_surface(doc: &Document, fmt: photocraft_color::PixelFormat, background: Option<[f32; 3]>) -> Surface { let mut s = Surface::new(fmt); let n = fmt.channels(); let mut data = Vec::new(); + let space = cmyk_space(doc); + let to_cmyk = fmt.mode == photocraft_color::ColorMode::Cmyk && doc.mode == photocraft_color::ColorMode::Cmyk; + if to_cmyk && cmyk::renders_inks(doc) { + // White paper is no ink; another background colour goes through the profile. + let paper = background.map(|bg| { + if bg == [1.0; 3] { [0.0; 4] } else { photocraft_color::convert::with_cmyk_space(space.as_ref(), || photocraft_color::convert::rgb_to_cmyk(bg)) } + }); + let _ = cmyk::render_cmyk_bands(doc, doc.bounds(), 0, |band| -> Result<(), ()> { + data.clear(); + data.reserve(band.px.len() * n); + for p in &band.px { + // Over the paper (fully covered pixels keep their inks exactly), or straight. + let ink = |c: usize| match paper { + Some(bg) if p[4] < 1.0 => p[c] * p[4] + bg[c] * (1.0 - p[4]), + _ => p[c], + }; + data.extend((0..4).map(ink)); + if fmt.alpha { + data.push(if paper.is_some() { 1.0 } else { p[4] }); + } + } + s.write_region(band.rect, &data); + Ok(()) + }); + s.prune(); + return s; + } let _ = render_bands(doc, doc.bounds(), 0, |band| -> Result<(), ()> { let band = match background { Some(bg) => band.over_background(bg), @@ -244,9 +273,11 @@ pub fn flatten_to_surface(doc: &Document, fmt: photocraft_color::PixelFormat, ba }; data.clear(); data.resize(band.px.len() * n, 0.0); - for (p, out) in band.px.iter().zip(data.chunks_exact_mut(n)) { - photocraft_raster::from_rgba_into(&fmt, *p, out); - } + photocraft_color::convert::with_cmyk_space(space.as_ref(), || { + for (p, out) in band.px.iter().zip(data.chunks_exact_mut(n)) { + photocraft_raster::from_rgba_into(&fmt, *p, out); + } + }); s.write_region(band.rect, &data); Ok(()) }); From 6c9ec00fa80adc34e10461083be4675e901f205e Mon Sep 17 00:00:00 2001 From: durtyrobbin Date: Sun, 11 Oct 2026 12:40:20 -0400 Subject: [PATCH 023/649] studio: live mixer foundation Preserve validated painting-studio phase 1 as its own source commit. Content tree: 371bfeb4cdc79f3e2e9357047141a393811ec1a5 Qualification details and remaining gates are retained in the phase documentation. Local commit authorized by durtyrobbin; no publication or upstream merge. --- crates/engine/examples/mixer_probe.rs | 66 +++ crates/engine/src/brush_cmds.rs | 63 +-- crates/engine/src/brush_cmds/mixer_live.rs | 402 ++++++++++++++++++ .../engine/src/brush_cmds/mixer_live_tests.rs | 226 ++++++++++ crates/engine/src/float_cmds.rs | 3 +- crates/engine/src/lib.rs | 2 + crates/paint/src/mixer.rs | 174 +++++--- crates/ui-egui/src/alt_click_tests.rs | 30 ++ crates/ui-egui/src/alt_grab.rs | 2 +- crates/ui-egui/src/brush_panel_tests.rs | 6 +- crates/ui-egui/src/canvas.rs | 201 ++++++++- crates/ui-egui/src/panels.rs | 26 ++ crates/ui-egui/src/shortcuts.rs | 3 + docs/mixer-live.md | 147 +++++++ 14 files changed, 1241 insertions(+), 110 deletions(-) create mode 100644 crates/engine/examples/mixer_probe.rs create mode 100644 crates/engine/src/brush_cmds/mixer_live.rs create mode 100644 crates/engine/src/brush_cmds/mixer_live_tests.rs create mode 100644 docs/mixer-live.md diff --git a/crates/engine/examples/mixer_probe.rs b/crates/engine/examples/mixer_probe.rs new file mode 100644 index 0000000000..d39b297661 --- /dev/null +++ b/crates/engine/examples/mixer_probe.rs @@ -0,0 +1,66 @@ +//! Reproducible CPU-engine latency probe; not a hardware pointer-to-display qualification. +use photocraft_engine::{Session, brush_cmds::mixer_live::LiveMixer}; +use photocraft_geom::Rect; +use photocraft_paint::{ + BrushSettings, Stroke, StrokePoint, + mixer::{MixerState, apply_mixer_stroke}, +}; +use photocraft_raster::Surface; +use serde_json::json; +use std::time::Instant; + +fn main() -> Result<(), Box> { + let mut results = Vec::new(); + for size in [16.0, 64.0, 256.0] { + let mut s = Session::new(); + s.execute("file.new", json!({"width":6000,"height":4000,"background":"#808080"}))?; + s.execute("layer.new.layer", json!({"name":"Source"}))?; + s.edit("fixture", |doc, id| { + if let Some(layer) = id.and_then(|id| doc.layer_mut(id)) + && let Some(surface) = layer.surface_mut() + { + surface.fill_rect(Rect::new(0, 0, 500, 800), &[1.0, 0.0, 0.0, 1.0]); + surface.fill_rect(Rect::new(500, 0, 1000, 800), &[0.0, 1.0, 0.0, 1.0]); + } + Ok(()) + })?; + s.execute("layer.new.layer", json!({"name":"Paint"}))?; + let baseline_doc = s.active().ok_or("no document")?.doc.clone(); + let params = json!({"points":[[200,400]],"size":size,"seed":42,"wet":100,"mix":85,"brush":{"pressureSize":false,"spacing":0.25}}); + let start = Instant::now(); + let mut live = LiveMixer::begin(&s, ¶ms)?; + let begin_ms = start.elapsed().as_secs_f64() * 1000.0; + let mut times = Vec::new(); + let mut points = vec![StrokePoint::new(200.0, 400.0, 1.0)]; + for i in 1..=60 { + let point = StrokePoint::new(200.0 + 10.0 * f64::from(i), 400.0 + 20.0 * (f64::from(i) / 10.0).sin(), 1.0); + let start = Instant::now(); + live.push(&[point])?; + times.push(start.elapsed().as_secs_f64() * 1000.0); + points.push(point); + } + let area = live.bounds(); + let commit = live.prepare_commit(&mut s)?; + let start = Instant::now(); + s.execute("paint.mixerBrush", commit)?; + let commit_ms = start.elapsed().as_secs_f64() * 1000.0; + let mut baseline = Surface::new(photocraft_color::PixelFormat::RGBA8); + let mut state = MixerState::default(); + state.load(s.tools.foreground); + let stroke = Stroke { brush: BrushSettings { size, pressure_size: false, spacing: 0.25, ..Default::default() }, points }; + let settings = photocraft_paint::MixerSettings { wet: 1.0, mix: 0.85, ..Default::default() }; + // Baseline's historical frozen-composite path, including its one source composition. + let start = Instant::now(); + let buffer = photocraft_compose::render(&baseline_doc, area); + let mut source = Surface::new(photocraft_color::PixelFormat::RGBA32F); + source.write_region(area, &buffer.px.iter().flatten().copied().collect::>()); + apply_mixer_stroke(&mut baseline, Some(&source), &stroke, &settings, &mut state, None, false); + let baseline_ms = start.elapsed().as_secs_f64() * 1000.0; + times.sort_by(f64::total_cmp); + results.push(json!({"size":size,"document":[6000,4000],"layers":3,"moves":60,"begin_ms":begin_ms, + "move_median_ms":times.get(30),"move_p95_ms":times.get(57),"move_max_ms":times.last(), + "prepared_commit_ms":commit_ms,"baseline_frozen_composite_full_stroke_ms":baseline_ms})); + } + println!("{}", serde_json::to_string_pretty(&json!({"scope":"CPU engine only; no OS, tablet, display, or GPU latency claim","results":results}))?); + Ok(()) +} diff --git a/crates/engine/src/brush_cmds.rs b/crates/engine/src/brush_cmds.rs index a0a217c303..d984363bca 100644 --- a/crates/engine/src/brush_cmds.rs +++ b/crates/engine/src/brush_cmds.rs @@ -8,7 +8,7 @@ use photocraft_doc::LayerContent; use photocraft_geom::Rect; -use photocraft_paint::mixer::{MixerSettings, apply_mixer_stroke}; +use photocraft_paint::mixer::MixerSettings; use photocraft_paint::replace::{Limits, ReplaceMode, ReplaceSettings, Sampling, apply_color_replacement}; use photocraft_paint::{BrushPreset, BrushSettings, GrayTile, Stroke, StrokePoint, StrokeRenderer, TipShape, render_stroke}; use photocraft_raster::Surface; @@ -546,51 +546,9 @@ fn pct(p: &Value, k: &str, d: f32) -> f32 { num(p, k).unwrap_or(d).clamp(0.0, 100.0) / 100.0 } +pub mod mixer_live; fn mixer_brush(s: &mut Session, p: &Value) -> Result { - let cmd = "paint.mixerBrush"; - let pts = parse_points(p, cmd)?; - let brush = resolve_brush(s, p, cmd)?; - // The brush's Mixer Brush options, overridden by the scalar params. - let bm = &brush.mixer; - let m = MixerSettings { - wet: pct(p, "wet", bm.wet * 100.0), - load: pct(p, "load", bm.load * 100.0), - mix: pct(p, "mix", bm.mix * 100.0), - flow: pct(p, "flow", bm.flow * 100.0), - sample_all_layers: flag(p, "sampleAllLayers", bm.sample_all_layers), - }; - let sample_all = m.sample_all_layers; - let (clean, load_after) = (flag(p, "cleanAfterStroke", true), flag(p, "loadAfterStroke", true)); - let mut state = s.tools.mixer.clone(); - if load_after || state.reservoir.is_none() { - state.load(color(p.get("color"), s.tools.foreground)); - } - let id = if crate::channel_cmds::is_channel_target(p) { None } else { Some(layer_id(s, p)?) }; - let stroke = Stroke { brush, points: pts }; - let dmg = s.edit("Mixer Brush", |doc, _| { - let sel = doc.selection.clone(); - let sample = if sample_all { - let ds = photocraft_paint::dabs(&stroke); - let ctx = photocraft_paint::BrushContext::new(&stroke.brush); - let area = ds.iter().fold(Rect::EMPTY, |r, d| r.union(&ctx.dab_rect(d, false))); - let buf = photocraft_compose::render(doc, area); - let mut surf = Surface::new(photocraft_color::PixelFormat::RGBA32F); - let flat: Vec = buf.px.iter().flatten().copied().collect(); - if !area.is_empty() { - surf.write_region(area, &flat); - } - Some(surf) - } else { - None - }; - let (surf, lock) = crate::channel_cmds::target_surface(doc, id, p)?; - Ok(apply_mixer_stroke(surf, sample.as_ref(), &stroke, &m, &mut state, sel.as_ref(), lock)) - })?; - if clean { - state.clean(); - } - s.tools.mixer = state; - Ok(damage_json(s, dmg)) + mixer_live::run(s, p) } fn color_replacement(s: &mut Session, p: &Value) -> Result { @@ -918,6 +876,16 @@ macro_rules! spec { /// Brush command specs. pub fn specs() -> Vec { vec![ + spec!( + "brush.mixer.sample", + "Sample Mixer Brush", + r#"{"points":[[x,y,pressure?,tiltX?,tiltY?,rotation?]],"sampleAllLayers":bool=brush setting,"size":px?,"target":"pixels"|"mask"|"quickMask"|{"channel":i}}"#, + |s| s.active().map(|_| ()).ok_or_else(|| "no document".into()), + mixer_live::sample, + true + ), + spec!("brush.mixer.load", "Load Mixer Brush", r##"{"color":"#rrggbb"?=foreground}"##, always, mixer_live::load, true), + spec!("brush.mixer.clean", "Clean Mixer Brush", "{}", always, mixer_live::clean, true), spec!( "paint.pencil", "Pencil", @@ -929,7 +897,7 @@ pub fn specs() -> Vec { spec!( "paint.mixerBrush", "Mixer Brush", - r##"{"points":[…],"brush":{…}?,"preset":name?,"size":0.5..5000 px?,"wet":0..100=brush.mixer.wet,"load":0..100=brush.mixer.load,"mix":0..100=brush.mixer.mix,"flow":0..100=brush.mixer.flow,"color":"#rrggbb"?=foreground,"sampleAllLayers":bool=brush.mixer.sampleAllLayers,"cleanAfterStroke":bool=true,"loadAfterStroke":bool=true,"seed":u64?}"##, + r##"{"points":[…] (max 65536 samples, 2048px per segment),"brush":{…}?,"preset":name?,"size":0.5..512 px?,"wet":0..100=brush.mixer.wet,"load":0..100=brush.mixer.load,"mix":0..100=brush.mixer.mix,"flow":0..100=brush.mixer.flow,"color":"#rrggbb"?=foreground,"sampleAllLayers":bool=brush.mixer.sampleAllLayers,"cleanAfterStroke":bool=brush.mixer.cleanAfterStroke,"loadAfterStroke":bool=brush.mixer.reloadAfterStroke,"seed":u64?,"mixerState":{reservoir,amount,pickup,spatial} (optional captured replay state; spatial is null or 4096 RGBA colors)}"##, has_paintable, mixer_brush, true @@ -962,3 +930,6 @@ pub fn specs() -> Vec { #[cfg(test)] mod tests; + +#[cfg(test)] +mod mixer_live_tests; diff --git a/crates/engine/src/brush_cmds/mixer_live.rs b/crates/engine/src/brush_cmds/mixer_live.rs new file mode 100644 index 0000000000..21f4c7e99e --- /dev/null +++ b/crates/engine/src/brush_cmds/mixer_live.rs @@ -0,0 +1,402 @@ +//! Incremental Mixer Brush transaction. Source pixels are composed before each dab; +//! only the selected target changes. Dropping the transaction cancels it. +use super::*; +use photocraft_color::{PixelFormat, SampleType}; +use photocraft_doc::{Document, LayerId}; +use photocraft_paint::dynamics::DabGenerator; +use photocraft_paint::mixer::{MixerState, apply_mixer_dab}; +use photocraft_paint::retouch::{Region, mix_back}; +use photocraft_paint::{BrushContext, Dab}; +use std::collections::BTreeSet; +use std::sync::Arc; + +const CMD: &str = "paint.mixerBrush"; +const MAX_TILES: usize = 256; +const TILE: i32 = 256; + +fn valid_color(color: &[f32; 4]) -> bool { + color.iter().all(|v| v.is_finite() && v.abs() <= 1_000_000.0) +} + +fn valid_state(state: &MixerState) -> bool { + state.amount.is_finite() + && state.reservoir.as_ref().is_none_or(valid_color) + && state.pickup.as_ref().is_none_or(valid_color) + && state.spatial.as_ref().is_none_or(|colors| colors.len() == 4096 && colors.iter().all(valid_color)) +} + +#[derive(Clone)] +struct Core { + doc: Arc, + generator: DabGenerator, + ctx: BrushContext, + pre: Surface, + work: Surface, + tiles: BTreeSet<(i32, i32)>, + state: MixerState, + settings: MixerSettings, + layer: Option, + params: Value, + selection: Option, + lock: bool, + color_restrict: Option, + count: usize, + last: Option, + bounds: Rect, +} + +impl Core { + fn apply(&mut self, dabs: &[Dab]) -> Result { + if self.count.saturating_add(dabs.len()) > 250_000 { + return Err(bad(CMD, "stroke exceeds 250000 dabs; start another stroke")); + } + let mut damage = Rect::EMPTY; + for dab in dabs { + let index = self.count; + self.count += 1; + let r = self.ctx.dab_rect(dab, false); + if r.is_empty() { + continue; + } + let full = self.ctx.dab_rect(dab, false); + if u64::from(full.width()).saturating_mul(u64::from(full.height())) > 1_048_576 { + return Err(bad(CMD, "Mixer Brush footprint exceeds 1048576 pixels")); + } + // Float working tiles avoid repeated integer-depth quantization. Initialize only + // touched tiles, keeping unchanged source tiles shared by the document snapshots. + for ty in r.y0.div_euclid(TILE)..=(r.y1 - 1).div_euclid(TILE) { + for tx in r.x0.div_euclid(TILE)..=(r.x1 - 1).div_euclid(TILE) { + if !self.tiles.contains(&(tx, ty)) { + if self.tiles.len() >= MAX_TILES { + return Err(bad(CMD, "Mixer Brush stroke working set exceeds 256 tiles")); + } + let tile = Rect::new(tx * TILE, ty * TILE, (tx + 1) * TILE, (ty + 1) * TILE); + self.work.write_region(tile, &self.pre.read_region(tile)); + self.tiles.insert((tx, ty)); + } + } + } + // Render the visible document including the active layer exactly once, before + // deposition. Masks, transforms, blend modes and adjustments use the compositor. + let sample = self.settings.sample_all_layers.then(|| { + let buf = photocraft_compose::render(&self.doc, r); + let mut sample = Surface::new(PixelFormat::RGBA32F); + sample.write_region(r, &buf.px.iter().flatten().copied().collect::>()); + sample + }); + let fp = self.ctx.footprint(dab, index); + let mut region = Region::read(&self.work, r); + apply_mixer_dab(&mut region, &fp, self.pre.format(), sample.as_ref(), &self.settings, &mut self.state, self.lock); + region.write(&mut self.work); + let original = Region::read(&self.pre, r); + let (target, _) = crate::channel_cmds::target_surface(Arc::make_mut(&mut self.doc), self.layer, &self.params)?; + mix_back(target, &original, ®ion, r, 1.0, self.selection.as_ref(), self.lock); + if let Some(k) = self.color_restrict { + let n = target.channels(); + let mut values = target.read_region(r); + let before = self.pre.read_region(r); + for (new, old) in values.chunks_exact_mut(n).zip(before.chunks_exact(n)) { + for (c, (new, old)) in new.iter_mut().zip(old).enumerate() { + if c != k { + *new = *old; + } + } + } + target.write_region(r, &values); + } + damage = damage.union(&r); + } + self.bounds = self.bounds.union(&damage); + Ok(damage) + } +} + +/// A real, cancellable paint result, displayed by the existing damage-aware canvas. +pub struct LiveMixer { + pub doc: Arc, + pub seed: u64, + core: Core, + state: MixerState, + tail: Rect, + cmyk: Option>, + original: Arc, + points: Vec, + original_state: MixerState, +} + +impl LiveMixer { + pub fn begin(s: &Session, p: &Value) -> Result { + has_paintable(s).map_err(EngineError::Other)?; + if p.get("points").and_then(Value::as_array).is_some_and(|v| v.len() > 65_536) { + return Err(bad(CMD, "stroke exceeds 65536 recorded input samples")); + } + let points = parse_points(p, CMD)?; + let brush = resolve_brush(s, p, CMD)?; + // Reject unsupported sizes before allocating a dense brush footprint. + if brush.size > 512.0 { + return Err(bad(CMD, "live Mixer Brush size is limited to 512 pixels")); + } + let bm = &brush.mixer; + let settings = MixerSettings { + wet: pct(p, "wet", bm.wet * 100.0), + load: pct(p, "load", bm.load * 100.0), + mix: pct(p, "mix", bm.mix * 100.0), + flow: pct(p, "flow", bm.flow * 100.0), + sample_all_layers: flag(p, "sampleAllLayers", bm.sample_all_layers) && crate::channel_cmds::target_of(p) == crate::channel_cmds::Target::Pixels, + clean_after_stroke: flag(p, "cleanAfterStroke", bm.clean_after_stroke), + reload_after_stroke: flag(p, "loadAfterStroke", bm.reload_after_stroke), + }; + let initial_state = if let Some(value) = p.get("mixerState") { + if value.get("spatial").and_then(Value::as_array).is_some_and(|v| v.len() != 4096) { + return Err(bad(CMD, "spatial reservoir must contain exactly 4096 colors")); + } + serde_json::from_value::(value.clone()).map_err(|e| bad(CMD, e.to_string()))? + } else { + s.tools.mixer.clone() + }; + let mut state = initial_state; + if !valid_state(&state) { + return Err(bad(CMD, "loaded paint must be finite and color magnitudes at most 1000000")); + } + if state.spatial.is_none() && settings.reload_after_stroke { + let color = color(p.get("color"), s.tools.foreground); + if !valid_color(&color) { + return Err(bad(CMD, "loaded color must be finite and magnitudes at most 1000000")); + } + state.load(color); + } + let layer = if crate::channel_cmds::is_channel_target(p) { None } else { Some(layer_id(s, p)?) }; + let mut doc = (*s.active().ok_or(EngineError::NoDocument)?.doc).clone(); + let selection = doc.selection.clone(); + let (target, lock) = crate::channel_cmds::target_surface(&mut doc, layer, p)?; + let pre = target.clone(); + let work = Surface::new(PixelFormat { sample: SampleType::F32, ..pre.format() }); + let core = Core { + doc: Arc::new(doc), + generator: DabGenerator::new(&brush, num(p, "zoom").unwrap_or(1.0)), + ctx: BrushContext::new(&brush), + pre, + work, + tiles: BTreeSet::new(), + state: state.clone(), + settings, + layer, + params: p.clone(), + selection, + lock, + color_restrict: crate::channel_cmds::color_restriction(s, CMD, p), + count: 0, + last: None, + bounds: Rect::EMPTY, + }; + let mut live = Self { + doc: core.doc.clone(), + seed: brush.seed, + core, + state, + tail: Rect::EMPTY, + cmyk: doc_cmyk_space(s), + original: s.active().ok_or(EngineError::NoDocument)?.doc.clone(), + points: Vec::new(), + original_state: s.tools.mixer.clone(), + }; + live.push(&points)?; + Ok(live) + } + + pub fn bounds(&self) -> Rect { + self.core.bounds.union(&self.tail) + } + pub fn wants_time(&self) -> bool { + self.core.generator.wants_time() + } + + /// Batches and individual input samples produce identical results. The speculative end + /// dab / smoothing tail is displayed but never fed into the next accepted input. + pub fn push(&mut self, points: &[StrokePoint]) -> Result { + check_coords(points, CMD)?; + if self.points.len().saturating_add(points.len()) > 65_536 { + return Err(bad(CMD, "stroke exceeds 65536 recorded input samples")); + } + let mut last = self.core.last; + for point in points { + if last.is_some_and(|p| (point.x - p.x).hypot(point.y - p.y) > 2048.0) { + return Err(bad(CMD, "input segment exceeds 2048 pixels; supply interpolated input")); + } + last = Some(*point); + } + let cmyk = self.cmyk.clone(); + photocraft_color::convert::with_cmyk_space(cmyk.as_ref(), || { + let old_tail = self.tail; + let mut damage = Rect::EMPTY; + for point in points { + let (mut dabs, mut dual) = (Vec::new(), Vec::new()); + self.core.generator.push(&[*point], &mut dabs, &mut dual); + damage = damage.union(&self.core.apply(&dabs)?); + self.core.last = Some(*point); + } + let mut finished = self.core.clone(); + let (mut dabs, mut dual) = (Vec::new(), Vec::new()); + finished.generator.finish(&mut dabs, &mut dual); + self.tail = finished.apply(&dabs)?; + self.doc = finished.doc; + self.state = finished.state; + self.points.extend_from_slice(points); + Ok(damage.union(&old_tail).union(&self.tail)) + }) + } + + fn commit_params(&self) -> Result { + let mut params = self.core.params.clone(); + params["points"] = serde_json::to_value(&self.points).map_err(|e| bad(CMD, e.to_string()))?; + params["brush"] = serde_json::to_value(&self.core.ctx.brush).map_err(|e| bad(CMD, e.to_string()))?; + params["seed"] = json!(self.seed); + params["color"] = json!(self.core.ctx.brush.color); + if params.get("mixerState").is_none() { + params["mixerState"] = serde_json::to_value(&self.original_state).map_err(|e| bad(CMD, e.to_string()))?; + } + Ok(params) + } + + /// Stage the already rendered pixels for the ordinary journaled command. Refuse stale + /// document/tool state. The command consumes this single-use cache only for identical params. + pub fn prepare_commit(self, session: &mut Session) -> Result { + if !session.active().is_some_and(|st| Arc::ptr_eq(&st.doc, &self.original) && (self.core.layer.is_none() || st.active_layer == self.core.layer)) + || session.tools.mixer != self.original_state + { + return Err(bad(CMD, "document or loaded paint changed during the stroke")); + } + let params = self.commit_params()?; + session.prepared_mixer = Some(self); + Ok(params) + } +} + +pub(super) fn run(s: &mut Session, p: &Value) -> Result { + let cached = s.prepared_mixer.take().filter(|live| { + s.active().is_some_and(|st| Arc::ptr_eq(&st.doc, &live.original)) + && s.tools.mixer == live.original_state + && live.commit_params().is_ok_and(|params| params == *p) + }); + let live = match cached { + Some(live) => live, + None => LiveMixer::begin(s, p)?, + }; + let damage = live.bounds(); + s.edit("Mixer Brush", |doc, _| { + *doc = (*live.doc).clone(); + Ok(()) + })?; + let mut state = live.state; + if live.core.settings.clean_after_stroke { + state.clean(); + } + if live.core.settings.reload_after_stroke && state.reservoir.is_some() { + state.amount = 1.0; + } + s.tools.mixer = state; + Ok(damage_json(s, damage)) +} + +/// Sampling changes only session tool state, never document pixels or document Undo. +pub(super) fn sample(s: &mut Session, p: &Value) -> Result { + if p.get("points").and_then(Value::as_array).is_some_and(|v| v.len() != 1) { + return Err(bad("brush.mixer.sample", "exactly one sample point is required")); + } + let points = parse_points(p, "brush.mixer.sample")?; + if points.len() != 1 { + return Err(bad("brush.mixer.sample", "exactly one sample point is required")); + } + let mut brush = resolve_brush(s, p, "brush.mixer.sample")?; + if brush.size > 512.0 { + return Err(bad("brush.mixer.sample", "sampling size is limited to 512 pixels")); + } + brush.flow = 1.0; + let dabs = photocraft_paint::dabs(&Stroke { brush: brush.clone(), points }); + let dab = dabs.first().ok_or_else(|| bad("brush.mixer.sample", "brush has no contact"))?; + let ctx = BrushContext::new(&brush); + let rect = ctx.dab_rect(dab, false); + if u64::from(rect.width()).saturating_mul(u64::from(rect.height())) > 1_048_576 { + return Err(bad("brush.mixer.sample", "sampling footprint is too large")); + } + let fp = ctx.footprint(dab, 0); + let st = s.active().ok_or(EngineError::NoDocument)?; + let mut doc = crate::float_cmds::displayed(st, (0, 0)).unwrap_or_else(|| (*st.doc).clone()); + let id = if crate::channel_cmds::is_channel_target(p) { None } else { Some(layer_id(s, p)?) }; + let cmyk = doc_cmyk_space(s); + let load = photocraft_color::convert::with_cmyk_space(cmyk.as_ref(), || -> Result> { + let surface = if flag(p, "sampleAllLayers", brush.mixer.sample_all_layers) && crate::channel_cmds::target_of(p) == crate::channel_cmds::Target::Pixels { + let buf = photocraft_compose::render(&doc, rect); + let mut surface = Surface::new(PixelFormat::RGBA32F); + surface.write_region(rect, &buf.px.iter().flatten().copied().collect::>()); + surface + } else if crate::channel_cmds::target_of(p) == crate::channel_cmds::Target::Pixels { + id.and_then(|id| doc.layer(id)) + .and_then(|layer| layer.surface()) + .cloned() + .ok_or_else(|| bad("brush.mixer.sample", "current layer has no raster pixels to sample"))? + } else { + crate::channel_cmds::target_surface(&mut doc, id, p)?.0.clone() + }; + let mut load = Vec::with_capacity(4096); + let (sin, cos) = dab.angle.sin_cos(); + for row in 0..64 { + for col in 0..64 { + let mut u = ((col as f32 + 0.5) / 32.0 - 1.0) * dab.radius; + let mut v = ((row as f32 + 0.5) / 32.0 - 1.0) * (dab.radius * dab.roundness).max(0.5); + if dab.flip_x { + u = -u; + } + if dab.flip_y { + v = -v; + } + let (mut dx, mut up) = (u * cos + v * sin, u * sin - v * cos); + if dab.proj_scale < 0.999 { + let (sin, cos) = dab.proj_angle.sin_cos(); + let along = (dx * cos + up * sin) * (dab.proj_scale.max(0.05) - 1.0); + dx += along * cos; + up += along * sin; + } + let x = (dab.center.x as f32 + dx).floor() as i32; + let y = (dab.center.y as f32 - up).floor() as i32; + let mut color = surface.rgba(x, y); + color[3] *= fp.at(x, y).clamp(0.0, 1.0); + load.push(color); + } + } + Ok(load) + })?; + let mut average = [0.0f32; 4]; + for c in &load { + for k in 0..3 { + average[k] += c[k] * c[3]; + } + average[3] += c[3]; + } + if average[3] > 0.0 { + for k in 0..3 { + average[k] /= average[3]; + } + } + average[3] = 1.0; + s.tools.mixer.load(average); + s.tools.mixer.spatial = Some(load); + s.tools.mixer.clean(); + Ok(json!({"width":64,"height":64,"color":average})) +} + +pub(super) fn load(s: &mut Session, p: &Value) -> Result { + let color = color(p.get("color"), s.tools.foreground); + if !valid_color(&color) { + return Err(bad("brush.mixer.load", "loaded color must be finite and magnitudes at most 1000000")); + } + s.tools.mixer.load(color); + Ok(json!({"loaded":true})) +} + +pub(super) fn clean(s: &mut Session, _: &Value) -> Result { + s.tools.mixer = MixerState::default(); + // Cleaning is an explicit empty-brush choice, so do not silently reload the next stroke. + s.tools.brush.mixer.reload_after_stroke = false; + Ok(json!({"loaded":false})) +} diff --git a/crates/engine/src/brush_cmds/mixer_live_tests.rs b/crates/engine/src/brush_cmds/mixer_live_tests.rs new file mode 100644 index 0000000000..b13dc6ed3e --- /dev/null +++ b/crates/engine/src/brush_cmds/mixer_live_tests.rs @@ -0,0 +1,226 @@ +use super::mixer_live::LiveMixer; +use super::*; +use photocraft_color::PixelFormat; + +fn fixture(fmt: PixelFormat) -> Session { + let mut s = Session::new(); + s.execute("file.new", json!({"width":192,"height":96,"background":"#808080"})).unwrap(); + s.execute("layer.new.layer", json!({"name":"Source"})).unwrap(); + s.edit("fixture", |doc, id| { + let (surface, _) = crate::channel_cmds::target_surface(doc, *id, &json!({}))?; + *surface = Surface::new(fmt); + surface.fill_rect(Rect::new(0, 0, 96, 96), &[1.0, 0.0, 0.0, 1.0]); + surface.fill_rect(Rect::new(96, 0, 192, 96), &[0.0, 1.0, 0.0, 1.0]); + Ok(()) + }) + .unwrap(); + s.execute("layer.new.layer", json!({"name":"Paint"})).unwrap(); + s.edit("depth", |doc, id| { + *crate::channel_cmds::target_surface(doc, *id, &json!({}))?.0 = Surface::new(fmt); + Ok(()) + }) + .unwrap(); + s +} + +fn target(s: &Session) -> Surface { + let st = s.active().unwrap(); + st.doc.layer(st.active_layer.unwrap()).unwrap().surface().unwrap().clone() +} + +#[test] +fn mixer_live_empty_layer_exact_commit_undo_source_preservation_and_chunking() { + for fmt in [PixelFormat::RGBA8, PixelFormat::RGBA16, PixelFormat::RGBA32F] { + let mut s = fixture(fmt); + assert!(s.tools.brush.mixer.sample_all_layers); + let before = s.active().unwrap().doc.clone(); + let params = json!({"points":[[40,48]],"seed":47,"size":24,"wet":100,"mix":100,"cleanAfterStroke":false}); + let mut live = LiveMixer::begin(&s, ¶ms).unwrap(); + let id = s.active().unwrap().active_layer.unwrap(); + assert!(live.doc.layer(id).unwrap().surface().unwrap().rgba(40, 48)[3] > 0.0); + assert_eq!(target(&s).rgba(40, 48)[3], 0.0, "preview must not edit the session"); + let mut points = vec![StrokePoint::new(40.0, 48.0, 1.0)]; + for x in [56.0, 72.0, 88.0, 104.0, 120.0, 136.0, 152.0] { + let p = StrokePoint::new(x, 48.0, 1.0); + live.push(&[p]).unwrap(); + points.push(p); + } + let preview = live.doc.layer(id).unwrap().surface().unwrap().clone(); + let mut full = params.clone(); + full["points"] = json!(points); + s.execute("paint.mixerBrush", full).unwrap(); + assert_eq!(preview.read_region(before.bounds()), target(&s).read_region(before.bounds()), "live/replay tolerance is exactly zero"); + for old in &before.layers { + if old.id != id { + assert_eq!( + old.surface().unwrap().read_region(before.bounds()), + s.active().unwrap().doc.layer(old.id).unwrap().surface().unwrap().read_region(before.bounds()) + ); + } + } + s.execute("edit.undo", json!({})).unwrap(); + assert_eq!(target(&s).read_region(before.bounds()), before.layer(id).unwrap().surface().unwrap().read_region(before.bounds())); + s.execute("edit.redo", json!({})).unwrap(); + assert_eq!(target(&s).read_region(before.bounds()), preview.read_region(before.bounds())); + } +} + +#[test] +fn mixer_live_current_layer_matches_reference_and_cancels() { + let mut s = fixture(PixelFormat::RGBA32F); + let p = json!({"points":[[30,30],[60,34],[100,60]],"seed":9,"size":16,"sampleAllLayers":false,"wet":65,"mix":70,"load":90}); + let mut expected = target(&s); + let brush = resolve_brush(&s, &p, "paint.mixerBrush").unwrap(); + let mut state = photocraft_paint::mixer::MixerState::default(); + state.load(s.tools.foreground); + photocraft_paint::mixer::apply_mixer_stroke( + &mut expected, + None, + &Stroke { brush, points: parse_points(&p, "paint.mixerBrush").unwrap() }, + &MixerSettings { wet: 0.65, mix: 0.70, load: 0.90, sample_all_layers: false, ..Default::default() }, + &mut state, + None, + false, + ); + let live = LiveMixer::begin(&s, &p).unwrap(); + let id = s.active().unwrap().active_layer.unwrap(); + let actual = live.doc.layer(id).unwrap().surface().unwrap().read_region(s.active().unwrap().doc.bounds()); + let expected = expected.read_region(s.active().unwrap().doc.bounds()); + let max = actual.iter().zip(expected).map(|(a, b)| (a - b).abs()).fold(0.0f32, f32::max); + assert!(max <= 1e-6, "reference error {max}"); + drop(live); + assert_eq!(target(&s).rgba(30, 30)[3], 0.0); + s.execute("brush.mixer.clean", json!({})).unwrap(); + s.execute("paint.mixerBrush", json!({"points":[[30,30],[60,30]],"sampleAllLayers":false,"wet":0})).unwrap(); + assert_eq!(target(&s).rgba(30, 30)[3], 0.0, "clean brush must stay empty"); +} + +#[test] +fn mixer_sample_is_spatial_and_never_edits_document() { + let mut s = fixture(PixelFormat::RGBA8); + let before = s.active().unwrap().doc.clone(); + s.execute("brush.mixer.sample", json!({"points":[[96,48]],"size":40,"brush":{"hardness":1.0,"pressureSize":false}})).unwrap(); + assert!(std::sync::Arc::ptr_eq(&before, &s.active().unwrap().doc)); + let load = s.tools.mixer.spatial.as_ref().unwrap(); + assert_eq!(load.len(), 4096); + assert!(load.iter().any(|p| p[0] > 0.9 && p[1] < 0.1 && p[3] > 0.9)); + assert!(load.iter().any(|p| p[1] > 0.9 && p[0] < 0.1 && p[3] > 0.9)); + s.execute("paint.mixerBrush", json!({"points":[[48,48]],"size":40,"wet":0,"mix":0,"brush":{"hardness":1.0,"pressureSize":false}})).unwrap(); + assert!(target(&s).rgba(40, 48)[0] > 0.9); + assert!(target(&s).rgba(56, 48)[1] > 0.9); + assert!(s.tools.mixer.spatial.is_some(), "sample persists across strokes"); +} + +#[test] +fn mixer_live_smoothing_tail_and_invalid_input() { + let mut s = fixture(PixelFormat::RGBA16); + let p = json!({"points":[[20,40]],"size":12,"seed":42,"brush":{"smoothing":{"amount":0.6,"catchUpOnEnd":true}}}); + let mut live = LiveMixer::begin(&s, &p).unwrap(); + live.push(&[StrokePoint::new(60.0, 40.0, 0.6)]).unwrap(); + live.push(&[StrokePoint::new(100.0, 48.0, 1.0)]).unwrap(); + let before = live.doc.clone(); + assert!(live.push(&[StrokePoint::new(f64::NAN, 0.0, 1.0)]).is_err()); + assert!(std::sync::Arc::ptr_eq(&before, &live.doc)); + let mut commit = p.clone(); + commit["points"] = json!([[20, 40, 1], [60, 40, 0.6], [100, 48, 1]]); + s.execute("paint.mixerBrush", commit).unwrap(); + let id = s.active().unwrap().active_layer.unwrap(); + assert_eq!( + live.doc.layer(id).unwrap().surface().unwrap().read_region(s.active().unwrap().doc.bounds()), + target(&s).read_region(s.active().unwrap().doc.bounds()) + ); + assert!(s.execute("paint.mixerBrush", json!({"points":[[0,0]],"size":5000})).is_err()); + assert!(s.execute("brush.mixer.sample", json!({"points":[[0,0],[1,1]]})).is_err()); +} + +#[test] +fn mixer_sampling_obeys_masks_opacity_blend_and_current_layer_switch() { + let mut s = fixture(PixelFormat::RGBA8); + let source = s.active().unwrap().doc.layers.iter().find(|l| l.name == "Source").unwrap().id; + s.edit("source composition", |doc, _| { + let layer = doc.layer_mut(source).unwrap(); + layer.opacity = 0.4; + layer.blend = photocraft_color::BlendMode::Multiply; + layer.mask = Some(photocraft_doc::LayerMask::hide_all()); + Ok(()) + }) + .unwrap(); + let expected = photocraft_compose::render(&s.active().unwrap().doc, Rect::new(39, 39, 40, 40)).px[0]; + s.execute("brush.mixer.sample", json!({"points":[[40,40]],"size":8})).unwrap(); + let actual = s.tools.mixer.reservoir.unwrap(); + for c in 0..3 { + assert!((actual[c] - expected[c]).abs() < 1e-5); + } + s.execute("brush.mixer.clean", json!({})).unwrap(); + s.execute("paint.mixerBrush", json!({"points":[[40,40],[80,40]],"size":8,"wet":100,"mix":100,"sampleAllLayers":false})).unwrap(); + assert_eq!(target(&s).rgba(50, 40)[3], 0.0, "current empty layer provides no paint"); + s.execute("paint.mixerBrush", json!({"points":[[40,40],[80,40]],"size":8,"wet":100,"mix":100,"sampleAllLayers":true})).unwrap(); + assert!(target(&s).rgba(50, 40)[3] > 0.9, "all layers supplies the visible composite"); +} + +#[test] +fn mixer_overlapping_dabs_resample_the_evolving_composite() { + let mut s = fixture(PixelFormat::RGBA32F); + s.execute("tools.setColors", json!({"foreground":"#0000ff"})).unwrap(); + let params = json!({"points":[[50,48]],"size":20,"seed":1,"wet":100,"mix":50,"cleanAfterStroke":false}); + let mut live = LiveMixer::begin(&s, ¶ms).unwrap(); + live.push(&[StrokePoint::new(54.0, 48.0, 1.0), StrokePoint::new(50.0, 48.0, 1.0)]).unwrap(); + let id = s.active().unwrap().active_layer.unwrap(); + let pixel = live.doc.layer(id).unwrap().surface().unwrap().rgba(50, 48); + assert!(pixel[2] > 0.5, "deposited blue feeds back into later pickups: {pixel:?}"); +} + +#[test] +fn mixer_prepared_commit_uses_displayed_pixels_and_rejects_stale_documents() { + let mut s = fixture(PixelFormat::RGBA8); + let p = json!({"points":[[20,40]],"size":16,"target":"pixels","seed":55}); + let mut live = LiveMixer::begin(&s, &p).unwrap(); + live.push(&[StrokePoint::new(80.0, 40.0, 0.6)]).unwrap(); + let shown = live.doc.clone(); + let id = s.active().unwrap().active_layer.unwrap(); + let steps = s.active().unwrap().history.past_len(); + let commit = live.prepare_commit(&mut s).unwrap(); + assert!(s.prepared_mixer.is_some()); + s.execute("paint.mixerBrush", commit.clone()).unwrap(); + assert!(s.prepared_mixer.is_none()); + assert_eq!(s.active().unwrap().history.past_len(), steps + 1); + assert_eq!(target(&s).read_region(shown.bounds()), shown.layer(id).unwrap().surface().unwrap().read_region(shown.bounds())); + s.execute("edit.undo", json!({})).unwrap(); + s.execute("paint.mixerBrush", commit).unwrap(); + assert_eq!(target(&s).read_region(shown.bounds()), shown.layer(id).unwrap().surface().unwrap().read_region(shown.bounds())); + let stale = LiveMixer::begin(&s, &p).unwrap(); + s.execute("layer.new.layer", json!({})).unwrap(); + assert!(stale.prepare_commit(&mut s).is_err()); +} + +#[test] +fn mixer_load_commands_preserve_floating_selection_and_history() { + let mut s = fixture(PixelFormat::RGBA8); + s.execute("select.all", json!({})).unwrap(); + s.execute("select.float", json!({"dx":8,"dy":0,"copy":true})).unwrap(); + let doc = s.active().unwrap().doc.clone(); + let steps = s.active().unwrap().history.past_len(); + for (command, params) in [("brush.mixer.sample", json!({"points":[[96,48]],"size":24})), ("brush.mixer.load", json!({})), ("brush.mixer.clean", json!({}))] + { + s.execute(command, params).unwrap(); + assert!(std::sync::Arc::ptr_eq(&doc, &s.active().unwrap().doc)); + assert_eq!(s.active().unwrap().history.past_len(), steps); + assert!(crate::float_cmds::floating(s.active().unwrap()).is_some()); + } +} + +#[test] +fn mixer_rejects_malformed_load_and_retains_or_reloads_paint() { + let mut s = fixture(PixelFormat::RGBA8); + let before = s.active().unwrap().doc.clone(); + for state in [json!({"spatial":[]}), json!({"spatial":[[1,0,0,1]]}), json!({"amount":"bad"}), json!({"reservoir":[1e300,0,0,1]})] { + assert!(s.execute("paint.mixerBrush", json!({"points":[[40,40]],"mixerState":state})).is_err()); + assert!(std::sync::Arc::ptr_eq(&before, &s.active().unwrap().doc)); + } + assert!(s.execute("brush.mixer.load", json!({"color":[1e300,0,0,1]})).is_err()); + s.execute("brush.mixer.load", json!({"color":"#ff0000"})).unwrap(); + s.execute("paint.mixerBrush", json!({"points":[[40,40],[80,40]],"size":10,"loadAfterStroke":false,"load":10})).unwrap(); + assert!(s.tools.mixer.amount > 0.0 && s.tools.mixer.amount < 1.0); + s.execute("paint.mixerBrush", json!({"points":[[40,40],[80,40]],"size":10,"loadAfterStroke":true,"load":10})).unwrap(); + assert_eq!(s.tools.mixer.amount, 1.0); +} diff --git a/crates/engine/src/float_cmds.rs b/crates/engine/src/float_cmds.rs index 892f754748..645d761fd5 100644 --- a/crates/engine/src/float_cmds.rs +++ b/crates/engine/src/float_cmds.rs @@ -205,7 +205,8 @@ pub fn drop_floating(s: &mut Session) -> Result { /// Commands that leave a floating piece floating: its own, and ones that don't touch documents. fn keeps_floating(id: &str) -> bool { - matches!(id, "select.float" | "select.drop") || ["view.", "window.", "help.", "prefs."].iter().any(|p| id.starts_with(p)) + matches!(id, "select.float" | "select.drop" | "brush.mixer.sample" | "brush.mixer.load" | "brush.mixer.clean") + || ["view.", "window.", "help.", "prefs."].iter().any(|p| id.starts_with(p)) } /// Before any command (`Session::dispatch`): Undo puts a floating piece back (and is used up: diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index ca09663707..a802cf1607 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -325,6 +325,8 @@ pub struct Session { docs: Vec, active: Option, pub tools: ToolState, + /// One validated Mixer Brush result awaiting its normal command dispatch. Never persisted. + pub(crate) prepared_mixer: Option, /// Log of executed commands (for action recording and debugging). pub journal: Vec<(String, Value)>, /// Coalescing key of the command being executed. diff --git a/crates/paint/src/mixer.rs b/crates/paint/src/mixer.rs index afb8092cd2..4c35019cba 100644 --- a/crates/paint/src/mixer.rs +++ b/crates/paint/src/mixer.rs @@ -26,11 +26,13 @@ pub struct MixerSettings { pub flow: f32, /// Pick up colour from all visible layers instead of the target layer only. pub sample_all_layers: bool, + pub clean_after_stroke: bool, + pub reload_after_stroke: bool, } impl Default for MixerSettings { fn default() -> Self { - Self { wet: 0.5, load: 0.5, mix: 0.5, flow: 1.0, sample_all_layers: false } + Self { wet: 0.5, load: 0.5, mix: 0.5, flow: 1.0, sample_all_layers: true, clean_after_stroke: true, reload_after_stroke: true } } } @@ -44,11 +46,14 @@ pub struct MixerState { pub amount: f32, /// Colour picked up from the canvas (straight RGBA), None = clean. pub pickup: Option<[f32; 4]>, + /// A bounded 64 x 64 spatial load in tip-local coordinates. Empty cells carry no paint. + pub spatial: Option>, } impl MixerState { /// Load the reservoir with a colour (full). pub fn load(&mut self, color: [f32; 4]) { + self.spatial = None; self.reservoir = Some(color); self.amount = 1.0; } @@ -58,6 +63,34 @@ impl MixerState { } } +/// Sample a spatial load at a dab pixel using the dab's rotation, aspect and flips. +/// Keeping the reservoir in tip coordinates lets it follow subsequent brush poses. +pub fn load_at(load: &[[f32; 4]], dab: &crate::Dab, x: f32, y: f32) -> [f32; 4] { + let mut dx = x - dab.center.x as f32; + let mut dy = y - dab.center.y as f32; + if dab.proj_scale < 0.999 { + let (sin, cos) = dab.proj_angle.sin_cos(); + let along = (dx * cos - dy * sin) * (1.0 / dab.proj_scale.max(0.05) - 1.0); + dx += along * cos; + dy -= along * sin; + } + let (sin, cos) = dab.angle.sin_cos(); + let mut u = (dx * cos - dy * sin) / dab.radius.max(0.01); + let mut v = (dx * sin + dy * cos) / (dab.radius * dab.roundness).max(0.5); + if dab.flip_x { + u = -u; + } + if dab.flip_y { + v = -v; + } + if !(-1.0..1.0).contains(&u) || !(-1.0..1.0).contains(&v) { + return [0.0; 4]; + } + let col = ((u + 1.0) * 32.0) as usize; + let row = ((v + 1.0) * 32.0) as usize; + load.get(row * 64 + col).copied().unwrap_or([0.0; 4]) +} + /// Paint a Mixer Brush stroke. `sample` is the surface colour is picked up from (the layer itself /// when None; a flattened composite for Sample All Layers). Returns the damaged rectangle. pub fn apply_mixer_stroke( @@ -70,6 +103,23 @@ pub fn apply_mixer_stroke( lock_transparency: bool, ) -> Rect { let fmt = target.format(); + let mut st = stroke.clone(); + st.brush.opacity = 1.0; + apply_dab_stroke(target, &st, selection, lock_transparency, 0, |work, fp| { + apply_mixer_dab(work, fp, fmt, sample, m, state, lock_transparency); + }) +} + +/// One incremental wet-paint dab, shared by recorded strokes and the live document transaction. +pub fn apply_mixer_dab( + work: &mut crate::retouch::Region, + fp: &crate::retouch::Footprint, + fmt: photocraft_color::PixelFormat, + sample: Option<&Surface>, + m: &MixerSettings, + state: &mut MixerState, + lock_transparency: bool, +) { let n = fmt.channels(); let a = alpha_index(&fmt); let nc = fmt.mode.color_channels(); @@ -84,70 +134,86 @@ pub fn apply_mixer_stroke( let mut amount = if res.is_some() { state.amount.clamp(0.0, 1.0) } else { 0.0 }; let mut pickup: Option> = state.pickup.map(native); let (wet, mix, flow, load) = (m.wet.clamp(0.0, 1.0), m.mix.clamp(0.0, 1.0), m.flow.clamp(0.0, 1.0), m.load.clamp(0.0, 1.0)); - let mut st = stroke.clone(); - st.brush.opacity = 1.0; let mut acc = vec![0.0f32; n]; let mut paint = vec![0.0f32; n]; - let dmg = apply_dab_stroke(target, &st, selection, lock_transparency, 0, |work, fp| { - // Transfer › Wetness / Mix Jitter scale the settings per dab. - let (wet, mix) = (wet * fp.dab.wet.clamp(0.0, 1.0), mix * fp.dab.mix.clamp(0.0, 1.0)); - // Sample the canvas under the dab. - acc.iter_mut().for_each(|v| *v = 0.0); - let (mut wsum, mut asum) = (0.0f32, 0.0f32); - let r = fp.rect.intersect(&work.rect); + // Transfer › Wetness / Mix Jitter scale the settings per dab. + let (wet, mix) = (wet * fp.dab.wet.clamp(0.0, 1.0), mix * fp.dab.mix.clamp(0.0, 1.0)); + // Sample the canvas under the dab. + acc.iter_mut().for_each(|v| *v = 0.0); + let (mut wsum, mut asum) = (0.0f32, 0.0f32); + let r = fp.rect.intersect(&work.rect); + for y in r.y0..r.y1 { + for x in r.x0..r.x1 { + let w = fp.at(x, y); + if w <= 0.0 { + continue; + } + let px: Vec = match sample { + Some(s) => { + let v = s.pixel(x, y); + if s.format() == fmt { v } else { from_rgba(&fmt, s.rgba(x, y)) } + } + None => work.px(x, y).to_vec(), + }; + let al = a.map_or(1.0, |ai| px[ai]); + for c in 0..nc { + acc[c] += px[c] * w * al; + } + wsum += w; + asum += w * al; + } + } + if asum > 1e-6 && wet > 0.0 { + let ca = asum / wsum.max(1e-6); + let canvas: Vec = (0..n).map(|c| if c < nc { acc[c] / asum } else { 1.0 }).collect(); + pickup = Some(match pickup.take() { + None => canvas, + Some(p) => p.iter().zip(&canvas).map(|(p, c)| p + (c - p) * PICKUP_RATE * wet * ca).collect(), + }); + } + let wr = if res.is_some() { amount * (1.0 - mix * wet) } else { 0.0 }; + let wp = if pickup.is_some() { mix * wet } else { 0.0 }; + let total = wr + wp; + if total > 1e-6 { + for c in 0..n { + let rv = res.as_ref().map_or(0.0, |v| v[c]); + let pv = pickup.as_ref().map_or(0.0, |v| v[c]); + paint[c] = (rv * wr + pv * wp) / total; + } + let dep = total.min(1.0) * flow; for y in r.y0..r.y1 { for x in r.x0..r.x1 { - let w = fp.at(x, y); - if w <= 0.0 { - continue; - } - let px: Vec = match sample { - Some(s) => { - let v = s.pixel(x, y); - if s.format() == fmt { v } else { from_rgba(&fmt, s.rgba(x, y)) } - } - None => work.px(x, y).to_vec(), - }; - let al = a.map_or(1.0, |ai| px[ai]); - for c in 0..nc { - acc[c] += px[c] * w * al; - } - wsum += w; - asum += w * al; - } - } - if asum > 1e-6 && wet > 0.0 { - let ca = asum / wsum.max(1e-6); - let canvas: Vec = (0..n).map(|c| if c < nc { acc[c] / asum } else { 1.0 }).collect(); - pickup = Some(match pickup.take() { - None => canvas, - Some(p) => p.iter().zip(&canvas).map(|(p, c)| p + (c - p) * PICKUP_RATE * wet * ca).collect(), - }); - } - let wr = if res.is_some() { amount * (1.0 - mix * wet) } else { 0.0 }; - let wp = if pickup.is_some() { mix * wet } else { 0.0 }; - let total = wr + wp; - if total > 1e-6 { - for c in 0..n { - let rv = res.as_ref().map_or(0.0, |v| v[c]); - let pv = pickup.as_ref().map_or(0.0, |v| v[c]); - paint[c] = (rv * wr + pv * wp) / total; - } - let dep = total.min(1.0) * flow; - for y in r.y0..r.y1 { - for x in r.x0..r.x1 { - let k = fp.at(x, y) * dep; - if k > 0.0 { + let k = fp.at(x, y) * dep; + if k > 0.0 { + if let Some(load) = &state.spatial { + let loaded = load_at(load, &fp.dab, x as f32 + 0.5, y as f32 + 0.5); + let local = from_rgba(&fmt, loaded); + let local_wr = wr * loaded[3]; + let local_total = local_wr + wp; + if local_total > 1e-6 { + let mut mixed = paint.clone(); + for (c, value) in mixed.iter_mut().enumerate() { + *value = (local.get(c).copied().unwrap_or(0.0) * local_wr + + pickup.as_ref().and_then(|p| p.get(c)).copied().unwrap_or(0.0) * wp) + / local_total; + } + if let Some(ai) = a + && let Some(alpha) = mixed.get_mut(ai) + { + *alpha = 1.0; + } + over_native(&fmt, work.px_mut(x, y), &mixed, fp.at(x, y) * local_total.min(1.0) * flow, lock_transparency); + } + } else { over_native(&fmt, work.px_mut(x, y), &paint, k, lock_transparency); } } } } - amount *= 1.0 - 0.08 * (1.0 - load); - }); + } + amount *= 1.0 - 0.08 * (1.0 - load); state.amount = amount; state.pickup = pickup.map(|p| to_rgba(&fmt, &p)); - dmg } #[cfg(test)] diff --git a/crates/ui-egui/src/alt_click_tests.rs b/crates/ui-egui/src/alt_click_tests.rs index d4a20b04ae..b027c3bf7f 100644 --- a/crates/ui-egui/src/alt_click_tests.rs +++ b/crates/ui-egui/src/alt_click_tests.rs @@ -111,6 +111,36 @@ fn alt_click_with_the_brush_samples_the_foreground() { assert_eq!(h.state().session.tools.foreground, [0.0, 1.0, 0.0, 1.0], "⌥-click sampled green"); } +#[test] +fn mixer_alt_click_samples_the_tip_through_zoomed_rotated_canvas_input() { + for (zoom, rotation) in [(0.5, 0.0), (1.0, 0.0), (2.0, 30.0)] { + let mut app = two_colours(); + app.run("layer.new.layer", json!({})).unwrap(); + app.run("tools.setBrush", json!({"brush":{"size":24,"roundness":0.4,"hardness":1.0,"pressureSize":false,"mixer":{"wet":0.0,"mix":0.0}}})).unwrap(); + let mut h = harness(app); + h.state_mut().ui.tool = Tool::MixerBrush; + h.state_mut().ui.views[0].zoom = zoom; + h.state_mut().ui.views[0].rotation = rotation; + h.run_steps(2); + let before = h.state().session.active().unwrap().doc.clone(); + let steps = h.state().session.active().unwrap().history.past_len(); + click(&mut h, 100.0, 50.0, Modifiers::ALT); + let state = &h.state().session.tools.mixer; + let load = state.spatial.as_ref().expect("Alt loads a spatial brush tip"); + assert!(load.iter().any(|c| c[0] > 0.9 && c[1] < 0.1 && c[3] > 0.9)); + assert!(load.iter().any(|c| c[1] > 0.9 && c[0] < 0.1 && c[3] > 0.9)); + assert!(std::sync::Arc::ptr_eq(&before, &h.state().session.active().unwrap().doc)); + assert_eq!(h.state().session.active().unwrap().history.past_len(), steps); + click(&mut h, 40.0, 50.0, Modifiers::NONE); + let st = h.state().session.active().unwrap(); + let surface = st.doc.layer(st.active_layer.unwrap()).unwrap().surface().unwrap(); + assert!(surface.rgba(34, 50)[0] > 0.9 && surface.rgba(46, 50)[1] > 0.9, "loaded halves follow document coordinates at {zoom}x/{rotation}°"); + assert_eq!(st.history.past_len(), steps + 1); + assert!(crate::alt_grab::alt_click_tool(Tool::MixerBrush, Modifiers::ALT)); + assert!(!crate::alt_grab::alt_click_tool(Tool::MixerBrush, Modifiers::ALT | Modifiers::CTRL)); + } +} + #[test] fn alt_click_sets_the_clone_source_and_a_drag_paints_it() { let mut h = harness(two_colours()); diff --git a/crates/ui-egui/src/alt_grab.rs b/crates/ui-egui/src/alt_grab.rs index 0ba09bad7a..bd1efea422 100644 --- a/crates/ui-egui/src/alt_grab.rs +++ b/crates/ui-egui/src/alt_grab.rs @@ -29,7 +29,7 @@ struct Watch { /// Tools whose ⌥-click does something: the ⌥ Eyedropper and the clone source point. pub(crate) fn alt_click_tool(tool: Tool, mods: egui::Modifiers) -> bool { - crate::canvas::alt_samples(tool, mods) || (mods.alt && !mods.ctrl && matches!(tool, Tool::CloneStamp | Tool::Healing)) + crate::canvas::alt_samples(tool, mods) || (mods.alt && !mods.ctrl && matches!(tool, Tool::MixerBrush | Tool::CloneStamp | Tool::Healing)) } /// The status-bar message for an ⌥-click the desktop took. diff --git a/crates/ui-egui/src/brush_panel_tests.rs b/crates/ui-egui/src/brush_panel_tests.rs index c61b48c1be..c599a5a093 100644 --- a/crates/ui-egui/src/brush_panel_tests.rs +++ b/crates/ui-egui/src/brush_panel_tests.rs @@ -97,7 +97,7 @@ fn edit_section(i: usize, b: &mut BrushSettings) { b.transfer.flow = dynamic(0.25, Control::Fade, 0.3); b.transfer.wetness = dynamic(0.35, Control::PenPressure, 0.1); b.transfer.mix = dynamic(0.45, Control::Fade, 0.2); - b.mixer = paint::MixerSettings { wet: 0.9, load: 0.15, mix: 0.7, flow: 0.8, sample_all_layers: true }; + b.mixer = paint::MixerSettings { wet: 0.9, load: 0.15, mix: 0.7, flow: 0.8, sample_all_layers: true, ..Default::default() }; } 7 => { let p = &mut b.pose; @@ -391,11 +391,11 @@ fn mixer_brush_options_update_the_persisted_mixer_settings() { h.drop_at(at); h.run_steps(2); - assert!(h.state().session.tools.brush.mixer.sample_all_layers); + assert!(!h.state().session.tools.brush.mixer.sample_all_layers); assert_eq!(h.state().session.journal.len(), initial + 1); let (id, params) = h.state().session.journal.last().unwrap(); assert_eq!(id, "tools.setBrush"); - assert_eq!(params["brush"]["mixer"]["sampleAllLayers"], true); + assert_eq!(params["brush"]["mixer"]["sampleAllLayers"], false); } #[test] diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index a04e299f19..55ec7c4397 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -353,6 +353,7 @@ enum EngineStroke { Brush(Box), Retouch(photocraft_engine::retouch_cmds::LiveRetouch), Dab(photocraft_engine::retouch_cmds::LiveDab), + Mixer(Box), } impl EngineStroke { @@ -361,6 +362,7 @@ impl EngineStroke { fn wants_time(&self) -> bool { match self { EngineStroke::Brush(l) => l.wants_time(), + EngineStroke::Mixer(l) => l.wants_time(), EngineStroke::Retouch(_) | EngineStroke::Dab(_) => false, } } @@ -370,6 +372,7 @@ impl EngineStroke { Self::Brush(s) => &s.doc, Self::Retouch(s) => &s.doc, Self::Dab(s) => &s.doc, + Self::Mixer(s) => &s.doc, } } fn bounds(&self) -> DRect { @@ -377,6 +380,7 @@ impl EngineStroke { Self::Brush(s) => s.bounds(), Self::Retouch(s) => s.bounds(), Self::Dab(s) => s.bounds(), + Self::Mixer(s) => s.bounds(), } } fn push(&mut self, pts: &[photocraft_engine::paint::StrokePoint]) -> photocraft_engine::Result { @@ -384,12 +388,14 @@ impl EngineStroke { Self::Brush(s) => s.push(pts), Self::Retouch(s) => s.push(pts), Self::Dab(s) => s.push(pts), + Self::Mixer(s) => s.push(pts), } } /// The jitter seed the commit must reuse (the Clone Stamp's comes from the session brush). fn seed(&self) -> Option { match self { Self::Brush(s) => Some(s.seed), + Self::Mixer(s) => Some(s.seed), Self::Retouch(_) => None, Self::Dab(_) => None, } @@ -444,8 +450,10 @@ fn stroke_params(app: &PhotocraftApp, tool: Tool, erase: bool, points: &[Vec bool { - matches!(tool, Tool::Brush | Tool::Pencil | Tool::Eraser | Tool::Blur | Tool::Sharpen | Tool::Smudge | Tool::Dodge | Tool::Burn | Tool::Sponge) - || live_retouch_command(tool).is_some() + matches!( + tool, + Tool::Brush | Tool::Pencil | Tool::MixerBrush | Tool::Eraser | Tool::Blur | Tool::Sharpen | Tool::Smudge | Tool::Dodge | Tool::Burn | Tool::Sponge + ) || live_retouch_command(tool).is_some() } /// The retouching tools drawn live (`LiveRetouch`), by the command their live stroke previews. @@ -561,7 +569,10 @@ fn begin_live_stroke(app: &PhotocraftApp) -> Option { static STROKES: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0); let st = app.session.active()?; let d = app.drag.as_ref()?; - let stroke = if let Some((cmd, mut p)) = crate::retouch_ui::dab_params(app, d.tool) { + let stroke = if d.tool == Tool::MixerBrush { + let p = stroke_params(app, d.tool, false, &app.stylus.stroke_points(&d.points)); + EngineStroke::Mixer(Box::new(photocraft_engine::brush_cmds::mixer_live::LiveMixer::begin(&app.session, &p).ok()?)) + } else if let Some((cmd, mut p)) = crate::retouch_ui::dab_params(app, d.tool) { // The params `retouch_ui::finish_stroke` commits; Sample All Layers isn't previewed. p["points"] = json!(d.points); p["target"] = paint_target(app); @@ -583,6 +594,20 @@ fn begin_live_stroke(app: &PhotocraftApp) -> Option { /// Render the drag points the live stroke hasn't seen yet, with the pen pressure, tilt and /// rotation the commit's `paint.stroke` gets for them. +pub(crate) fn cancel_mixer_on_context_change(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool { + if !app.drag.as_ref().is_some_and(|drag| drag.tool == Tool::MixerBrush) { + return false; + } + let changed = app.ui.tool != Tool::MixerBrush + || app.live_stroke.as_ref().is_some_and(|live| !app.session.active().is_some_and(|st| st.doc.id == live.doc && st.revision == live.revision)); + if changed || ctx.input(|input| !input.focused) || ctx.input_mut(|input| input.consume_key(egui::Modifiers::NONE, egui::Key::Escape)) { + app.drag = None; + app.live_stroke = None; + return true; + } + false +} + fn feed_live_stroke(app: &mut PhotocraftApp) { // A batched move replays several samples in one frame and calls this once at the end, so the // per-sample calls from `tool_event` are skipped (see `canvas_view`). @@ -609,7 +634,15 @@ fn feed_live_stroke(app: &mut PhotocraftApp) { l.fed = d.points.len(); match l.stroke.push(&pts) { Ok(r) => l.damage.push(r), - Err(_) => app.live_stroke = None, + Err(e) => { + let mixer = d.tool == Tool::MixerBrush; + app.live_stroke = None; + if mixer { + app.drag = None; + app.ui.status = e.to_string(); + app.ui.status_error = true; + } + } } } @@ -621,9 +654,16 @@ fn tap_at_peak_pressure(app: &mut PhotocraftApp) { return; } let peak = f64::from(app.stylus.tap_pressure()); - if let Some(p) = app.drag.as_mut().filter(|d| d.points.len() == 1).and_then(|d| d.points.first_mut()) { + let mut refresh_mixer = false; + if let Some(d) = app.drag.as_mut().filter(|d| d.points.len() == 1) + && let Some(p) = d.points.first_mut() + { + refresh_mixer = d.tool == Tool::MixerBrush && peak > p[2]; p[2] = p[2].max(peak); } + if refresh_mixer { + app.live_stroke = begin_live_stroke(app); + } } /// While a stroke is held still, its point repeats this often (in ms) so time-based brush @@ -3959,6 +3999,17 @@ pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers) return; } // View › Snap / Snap To and smart guides (snap_ui.rs). + if app.ui.tool == Tool::MixerBrush && mods.alt && !mods.ctrl && app.drag.is_none() { + if let ToolEvent::Down { x, y, pressure } = ev { + let pen = app.stylus.sample().unwrap_or_default(); + let p = json!({"points":[[x,y,pressure,pen.tilt_x,pen.tilt_y,pen.rotation]],"target":paint_target(app)}); + if let Err(e) = app.run("brush.mixer.sample", p) { + app.ui.status = e; + app.ui.status_error = true; + } + } + return; + } let raw = ev; // A press anywhere but on the floating piece (or with ⇧ / ⌥, to draw) drops it first; the // Move tool (⌘ with a painting tool too, `event_tool`) drags it from anywhere. @@ -4231,6 +4282,18 @@ pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers) app.stylus.record_point(); } app.live_stroke = if strokes_live(tool) { begin_live_stroke(app) } else { None }; + if tool == Tool::MixerBrush && app.live_stroke.is_none() { + // A refused mixer stroke must never fall back to a stand-in trail and paint + // unexpectedly on release. Surface the engine's concrete error immediately. + if let Some(d) = app.drag.as_ref() { + let p = stroke_params(app, tool, false, &app.stylus.stroke_points(&d.points)); + if let Err(e) = photocraft_engine::brush_cmds::mixer_live::LiveMixer::begin(&app.session, &p) { + app.ui.status = e.to_string(); + app.ui.status_error = true; + } + } + app.drag = None; + } } ToolEvent::Move { x, y, pressure } => { // Polygonal Lasso: ⌥ held while the button is down draws freehand into the polygon; @@ -4456,6 +4519,36 @@ pub(crate) fn finish_gesture(app: &mut PhotocraftApp, d: Drag) { { app.last_stroke_end = Some((st.doc.id, [end[0], end[1]])); } + if d.tool == Tool::MixerBrush { + // The release can carry a new endpoint, including moves deferred in this frame. + // Feed those samples before offering the already-rendered document for commit. + app.drag = Some(d); + let deferred = std::mem::replace(&mut app.defer_live_stroke, false); + feed_live_stroke(app); + app.defer_live_stroke = deferred; + let Some(d) = app.drag.take() else { return }; + let live = app.live_stroke.take(); + if let Some(l) = live { + let (doc, key, steps) = (l.doc, l.key, l.damage.len() as u64); + if let EngineStroke::Mixer(mixer) = l.stroke { + match mixer.prepare_commit(&mut app.session) { + Ok(p) => { + if app.run("paint.mixerBrush", p).is_ok() { + shown_as_document(app, doc, |k| k == 0 || (key..=key + steps).contains(&k)); + } + } + Err(e) => { + app.ui.status = e.to_string(); + app.ui.status_error = true; + } + } + } + } else { + let p = stroke_params(app, d.tool, false, &app.stylus.stroke_points(&d.points)); + let _ = app.run("paint.mixerBrush", p); + } + return; + } // A live Clone Stamp preview ends here; the commit below replaces it. if live_retouch_command(d.tool).is_some() || crate::retouch_ui::dab_params(app, d.tool).is_some() { app.live_stroke = None; @@ -5591,6 +5684,104 @@ mod tests { } } + #[test] + fn mixer_drag_shows_actual_mixed_paint_before_release_and_alt_never_paints() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width":120,"height":60,"background":"#00ff00"})).unwrap(); + app.run("layer.new.layer", json!({})).unwrap(); + app.run("tools.setColors", json!({"foreground":"#ff0000"})).unwrap(); + app.run("tools.setBrush", json!({"brush":{"size":16,"mixer":{"wet":1.0,"mix":0.7},"smoothing":{"amount":0.0}}})).unwrap(); + app.ui.tool = Tool::MixerBrush; + let before = app.session.active().unwrap().doc.clone(); + let count = app.session.active().unwrap().history.past_len(); + let alt = egui::Modifiers { alt: true, ..Default::default() }; + tool_event(&mut app, ToolEvent::Down { x: 30.0, y: 30.0, pressure: 1.0 }, alt); + tool_event(&mut app, ToolEvent::Move { x: 35.0, y: 30.0, pressure: 1.0 }, egui::Modifiers::NONE); + tool_event(&mut app, ToolEvent::Up { x: 35.0, y: 30.0 }, egui::Modifiers::NONE); + assert!(app.drag.is_none()); + assert!(app.session.tools.mixer.spatial.is_some()); + assert!(std::sync::Arc::ptr_eq(&before, &app.session.active().unwrap().doc)); + app.run("brush.mixer.load", json!({})).unwrap(); + tool_event(&mut app, ToolEvent::Down { x: 20.0, y: 30.0, pressure: 1.0 }, egui::Modifiers::NONE); + tool_event(&mut app, ToolEvent::Move { x: 70.0, y: 30.0, pressure: 0.6 }, egui::Modifiers::NONE); + assert!(app.live_stroke.is_some()); + let shown = display_doc(&mut app, 0).0; + let id = app.session.active().unwrap().active_layer.unwrap(); + let pixel = shown.layer(id).unwrap().surface().unwrap().rgba(45, 30); + assert!(pixel[0] > 0.0 && pixel[1] > 0.0 && pixel[3] > 0.0, "actual red/green mixture {pixel:?}"); + assert!(std::sync::Arc::ptr_eq(&before, &app.session.active().unwrap().doc)); + assert_eq!(app.session.active().unwrap().history.past_len(), count); + tool_event(&mut app, ToolEvent::Up { x: 70.0, y: 30.0 }, egui::Modifiers::NONE); + let st = app.session.active().unwrap(); + assert_eq!(st.history.past_len(), count + 1); + assert_eq!( + shown.layer(id).unwrap().surface().unwrap().read_region(before.bounds()), + st.doc.layer(id).unwrap().surface().unwrap().read_region(before.bounds()) + ); + app.session.undo(); + assert_eq!(app.session.active().unwrap().doc.layer(id).unwrap().surface().unwrap().rgba(45, 30)[3], 0.0); + } + + #[test] + fn mixer_release_includes_a_new_endpoint_and_deferred_frame_samples() { + for deferred in [false, true] { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width":120,"height":60,"background":"#00ff00"})).unwrap(); + app.run("layer.new.layer", json!({})).unwrap(); + app.run("tools.setBrush", json!({"size":12,"pressureSize":false})).unwrap(); + app.ui.tool = Tool::MixerBrush; + let before = app.session.active().unwrap().doc.clone(); + let m = egui::Modifiers::NONE; + tool_event(&mut app, ToolEvent::Down { x: 20.0, y: 30.0, pressure: 1.0 }, m); + app.defer_live_stroke = deferred; + tool_event(&mut app, ToolEvent::Move { x: 50.0, y: 30.0, pressure: 1.0 }, m); + tool_event(&mut app, ToolEvent::Up { x: 95.0, y: 30.0 }, m); + let doc = app.session.active().unwrap().doc.clone(); + let id = app.session.active().unwrap().active_layer.unwrap(); + assert!(doc.layer(id).unwrap().surface().unwrap().rgba(92, 30)[3] > 0.0); + let params = app.session.journal.iter().rev().find(|(name, _)| name == "paint.mixerBrush").unwrap().1.clone(); + app.run("edit.undo", json!({})).unwrap(); + assert_eq!(*app.session.active().unwrap().doc, *before); + app.run("paint.mixerBrush", params).unwrap(); + assert_eq!(*app.session.active().unwrap().doc, *doc); + } + } + + #[test] + fn mixer_escape_focus_loss_and_tool_switch_cancel_without_an_edit() { + for mode in 0..3 { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width":120,"height":60,"background":"#00ff00"})).unwrap(); + app.run("layer.new.layer", json!({})).unwrap(); + app.ui.tool = Tool::MixerBrush; + let before = app.session.active().unwrap().doc.clone(); + let steps = app.session.active().unwrap().history.past_len(); + tool_event(&mut app, ToolEvent::Down { x: 30.0, y: 30.0, pressure: 1.0 }, egui::Modifiers::NONE); + assert!(app.live_stroke.is_some()); + let ctx = egui::Context::default(); + let mut raw = egui::RawInput { focused: mode != 1, ..Default::default() }; + if mode == 0 { + raw.events.push(egui::Event::Key { + key: egui::Key::Escape, + physical_key: None, + pressed: true, + repeat: false, + modifiers: egui::Modifiers::NONE, + }); + } + if mode == 2 { + app.ui.tool = Tool::Brush; + } + ctx.begin_pass(raw); + assert!(cancel_mixer_on_context_change(&mut app, &ctx)); + let _ = ctx.end_pass(); + tool_event(&mut app, ToolEvent::Up { x: 30.0, y: 30.0 }, egui::Modifiers::NONE); + assert!(app.drag.is_none() && app.live_stroke.is_none()); + assert!(std::sync::Arc::ptr_eq(&before, &app.session.active().unwrap().doc)); + assert_eq!(app.session.active().unwrap().history.past_len(), steps); + } + } + #[test] fn brush_drag_shows_the_real_stroke_and_commits_it() { // The drag used to draw a hard, flat stand-in and only showed the soft brush on release. diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 444036c57f..b3ba2472b2 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -973,6 +973,32 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { } widgets::vline(ui, 22.0); widgets::checkbox(ui, &mut b.mixer.sample_all_layers, tl!("Sample All Layers")); + ui.menu_button(tl!("Paint Load"), |ui| { + ui.label(tl!("Alt-click the canvas to load the brush tip")); + if ui.button(tl!("Load Brush")).clicked() { let _ = app.run("brush.mixer.load", json!({})); } + if ui.button(tl!("Clean Brush")).clicked() { + let _ = app.run("brush.mixer.clean", json!({})); + b.mixer.reload_after_stroke = false; + } + widgets::checkbox(ui, &mut b.mixer.clean_after_stroke, tl!("Clean pickup after stroke")); + widgets::checkbox(ui, &mut b.mixer.reload_after_stroke, tl!("Reload after stroke")); + let (rect, _) = ui.allocate_exact_size(egui::vec2(64.0, 64.0), egui::Sense::hover()); + ui.painter().rect_filled(rect, 0.0, t.canvas); + let state = &app.session.tools.mixer; + let mut buffer = photocraft_compose::Buffer::transparent(photocraft_geom::Rect::new(0, 0, 32, 32)); + for (i, pixel) in buffer.px.iter_mut().enumerate() { + *pixel = state.spatial.as_ref().and_then(|v| v.get((i / 32) * 128 + (i % 32) * 2)).copied() + .or(state.reservoir).unwrap_or([0.0; 4]); + pixel[3] *= state.amount; + } + let display = app.session.active().and_then(|st| app.session.color.canvas_display_for(&st.doc, app.session.color.main_display).ok()); + let image = display.map_or_else(|| buffer.to_rgba8(), |display| display.to_rgba8(&buffer)); + for y in 0..32 { for x in 0..32 { + let c = image.pixels.get((y * 32 + x) * 4..(y * 32 + x + 1) * 4).unwrap_or(&[0; 4]); + let color = Color32::from_rgba_unmultiplied(c[0],c[1],c[2],c[3]); + ui.painter().rect_filled(egui::Rect::from_min_size(rect.min + egui::vec2(x as f32 * 2.0,y as f32 * 2.0),egui::vec2(2.0,2.0)),0.0,color); + }} + }); } Tool::RectMarquee | Tool::EllipseMarquee | Tool::SingleRowMarquee | Tool::SingleColumnMarquee if t.pro => { ui.spacing_mut().item_spacing.x = 2.0; diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rs index 6584dfa042..ec88de0db1 100644 --- a/crates/ui-egui/src/shortcuts.rs +++ b/crates/ui-egui/src/shortcuts.rs @@ -276,6 +276,9 @@ pub fn clipboard_keys(ctx: &egui::Context, typing: bool, raw: &mut egui::RawInpu } pub fn handle(app: &mut PhotocraftApp, ctx: &egui::Context) { + if crate::canvas::cancel_mixer_on_context_change(app, ctx) { + return; + } // However the tool was picked (toolbar, flyout, shortcut, automation), its group's key brings // it back later (#2608). app.ui.remember_group_tool(); diff --git a/docs/mixer-live.md b/docs/mixer-live.md new file mode 100644 index 0000000000..46dd923b68 --- /dev/null +++ b/docs/mixer-live.md @@ -0,0 +1,147 @@ +# Incremental Mixer Brush + +This change is the foundation of the requested Mixer Brush 2.0 work. It does not +implement the floating palette, harmony wheel, physical brush rack or bristle workshop. +Those must follow qualification of the painting and sampling foundation. These +original studio features do not change Photoshop parity counts. + +## Traced cause + +Baseline: upstream main `29f1ff9e90f2581ea2964e3276d85c71ab7e79a0`. +`ui-egui/src/canvas.rs::strokes_live` excludes Mixer Brush. `retouch_ui::finish_stroke` +dispatches `paint.mixerBrush` on pointer release. The engine's `mixer_brush` builds +all dabs and calls `apply_mixer_stroke` inside one document edit. The translucent +trail is therefore not the mixed result. This is deferred tool execution, not an +observed GPU invalidation failure. + +The old Sample All Layers path also rendered a single frozen composite spanning +the complete stroke. Later dabs could not sample the paint they just deposited. + +## Implemented path + +`brush_cmds::mixer_live::LiveMixer` uses the existing `DabGenerator`, `BrushContext`, +copy-on-write document/surfaces and native-channel Mixer Brush algorithm. Its float +working tiles avoid quantizing paint after every dab. The canvas displays that real +document copy and uses the existing damage rectangles and texture updates. + +An uncommitted smoothing/end-point tail is calculated on a copy of the incremental +state. It is displayed immediately and never contaminates the next input sample. +Dropping the live transaction cancels painting. Failed live strokes cancel rather +than reverting to a placeholder trail. The recorded command uses the same path and +creates one Undo edit. Release stages the already rendered document for the normal +command dispatcher, guarded by the original document and loaded-paint identity and +exact captured parameters. That one-use cache avoids repainting on release. Recorded +commands include the brush, seed, input samples and initial reservoir for deterministic +replay through the same incremental algorithm. Escape, focus loss, tool changes and +stale document context cancel the UI transaction. + +## Sampling semantics + +* Sample All Layers defaults on for new Mixer settings. Existing explicit false + preferences remain false. +* With it on, each dab reads the CPU compositor's visible document immediately + before depositing paint, including the active layer once. This includes visible + layers above the target as well as below it. Masks, adjustments, transforms, + opacity and blend modes follow the CPU compositor. Only the target surface changes. +* With it off, dabs read the evolving target working pixels. An empty target supplies + no pickup color. Masks/channels always use current-target semantics. +* Selection coverage is applied when the float working result is written to the + preview target. The next all-layer sample sees that selection-constrained result. +* Alt/Option + primary press loads a 64 x 64 spatial tip reservoir in document + coordinates. It does not create a document edit, rasterize a layer, or start a + paint drag. Coverage, tip shape, rotation, flips, aspect and projection are sampled. + The normalized spatial load follows subsequent dab poses. Resolution is bounded; + subpixel gaps smaller than a reservoir cell are not losslessly represented. +* Load Brush replaces the spatial load with foreground paint. Clean Brush empties + it and disables automatic reload. The pickup-clean and reload settings are part + of the existing serialized brush settings. The loaded reservoir persists during + the application session, including tool switches; restart persistence is not added. +* Native pixel conversion enters the document's CMYK profile scope, as the existing + brush engine does. The loaded-tip preview uses the document-to-monitor canvas + transform. Cross-document reservoir color-profile conversion is not implemented; + reload/sample in the destination document before painting between profiles. + +Commands: `brush.mixer.sample`, `brush.mixer.load`, `brush.mixer.clean`, +and the existing `paint.mixerBrush`. UI text uses the existing localization system; +new translations are not supplied for every catalog yet. + +## Resource envelope and limitations + +Live mixer size is limited to 512 pixels; dense footprints to 1,048,576 pixels; +one input segment to 2,048 pixels; one stroke to 250,000 dabs and 256 working tiles +(256 x 256 pixels each). Requests beyond these limits return errors. A spatial load +uses 64 KiB of float color data. Document snapshots share untouched tiles. These +limits are explicit initial engineering bounds, not hardware qualification. + +No fluid solver or grouped-bristle deformation model is introduced. Existing brush +tip/dynamics support is reused. Windows pen tilt/rotation remain limited by the +existing winit input path. Native Linux Wayland, X11/Wacom, macOS and WebAssembly +hardware interaction must be tested on those systems; simulated pen events do not +establish hardware qualification. + +## Verification + +`brush_cmds/mixer_live_tests.rs` covers live output, exact commit equivalence at +8/16/32-bit depth, reference-algorithm comparison, cancellation, Undo/Redo, spatial +loading, composite sampling, current-layer behavior, overlap feedback, floating +selection preservation, malformed reservoirs, depletion and reload. +`canvas.rs` covers the pointer-down/move/release and Alt-sampling routes. The existing +Mixer options test verifies the new default and persistence through `tools.setBrush`. + +`cargo run --release -p photocraft-engine --example mixer_probe` measures CPU engine +begin/move/prepared-commit costs on a 24 MP three-layer document. It is not an OS pointer-to- +display latency test. Run it under a recorded machine/build configuration and keep +its actual JSON results with the review evidence. + +## Upstream compatibility + +No PDF Binder #2011 or PDF integration #2751 code is modified. This branch starts +from upstream main, not the PDF branch. Relevant open work inspected on 2026-10-11: +#2131 (precomputed stroke commit), #3098/#2885/#2379 (brush performance), #2902 +(GPU tiles), #1911 (Windows pen input), #2516 (tip outline/persistence), #3039 +(Stroke Path), #3111 (mask locks). No upstream merge, force push or deployment is +performed. These PRs can change shared canvas/brush code and must be checked again +before integration. The private sibling craftrules checkout was not available. + +## Initial measured envelope (2026-10-11) + +Windows x64, Intel Core i7-9700K (8 cores), rustc 1.97.1, release with LTO disabled +and 16 codegen units. Synthetic 6000 x 4000 RGB8 document, three layers, 60 input +moves of roughly 10 pixels, spacing 25%, round brush, no simulated bristles. +Initial CPU-only results (milliseconds): + +| Brush | Begin | Move median | Move p95 | Move max | Prepared commit | Historical frozen-composite full stroke | +|---|---:|---:|---:|---:|---:|---:| +| 16 px | 1.83 | 0.43 | 1.43 | 2.85 | 0.58 | 12.00 | +| 64 px | 2.73 | 1.36 | 2.37 | 2.62 | 0.64 | 39.22 | +| 256 px | 24.88 | 0.003 | 24.70 | 24.97 | 0.95 | 164.46 | + +At 256 px, many 10 px moves emit no dab at 25% spacing, explaining the low median; +the p95/max matter for interaction. The baseline is the historical algorithm's +whole-stroke cost, not baseline frame latency. New live work is distributed over +input updates, so the commit column is not a claim of total algorithm speedup. +The 256 px p95 already exceeds a 16.67 ms / 60 Hz frame budget before GPU presentation. +These measurements do not qualify pen hardware or establish a worst-case memory bound. +The realtime mixer remains PARTIAL as a release qualification, despite the tested +functional slice. The expanded Creative Painting Studio task continues with dense +2K/4K/8K benchmarks, mixer optimization, then a dynamic stamp editor and procedural +tools. Palette, rack, AI guidance/result/comparison and grouped-bristle capabilities +are NOT IMPLEMENTED in this foundation commit. Expensive bristle simulation remains +gated on measured fast-mode performance. Larger brush optimization, full hardware +input qualification, reservoir profile tagging and restart persistence remain open. + +Native qualification: 1,207 engine, 84 paint and 1,828 UI unit tests passed, together +with the engine integration tests, command panic hunt, layering, Clippy and WASM +checks. The broad native run stopped at a concurrent GPU rotation-test access +violation on WARP, matching upstream #3212; serial isolation is recorded separately. +`xtask perf --quick` completed but reported over-budget existing canvas scenarios; +successful execution is not a painting-performance PASS. Photoshop menu parity +stays unchanged. + +Upstream refreshed on 2026-10-11 to `e44d96e1d4671b8d9fd64fbabdf88fa8abf0441e`. +Ordinary-brush prepared commits (#2131) have now landed and must be preserved on +integration. Open AI PRs #2878 (provider interface / Gemini), #730 (OpenAI), #2879 +(options UI), #2995 (subject selection) and #2649 (background removal) were identified. +Provider work must reconcile those existing contributions. No external AI provider +has been invoked, and publishing advanced palette/bristle/AI components requires +the owner's separate release approval after licensing review. From 92891b5908e3dd678629452c32831884c201924f Mon Sep 17 00:00:00 2001 From: durtyrobbin Date: Sun, 11 Oct 2026 12:40:22 -0400 Subject: [PATCH 024/649] studio: mixer optimization and baseline Preserve validated painting-studio phase 2 as its own source commit. Content tree: 803549d0cc3a688753c3561116cf3e7ccc76c107 Qualification details and remaining gates are retained in the phase documentation. Local commit authorized by durtyrobbin; no publication or upstream merge. --- crates/engine/examples/painting_baseline.rs | 111 +++++++++++++ crates/engine/examples/painting_live.rs | 126 +++++++++++++++ crates/engine/src/brush_cmds.rs | 2 +- crates/engine/src/brush_cmds/mixer_live.rs | 27 ++-- .../engine/src/brush_cmds/mixer_live_tests.rs | 16 ++ crates/paint/src/mixer.rs | 46 ++++-- crates/paint/src/mixer_reference_tests.rs | 152 ++++++++++++++++++ docs/creative-studio-validation.md | 123 ++++++++++++++ 8 files changed, 580 insertions(+), 23 deletions(-) create mode 100644 crates/engine/examples/painting_baseline.rs create mode 100644 crates/engine/examples/painting_live.rs create mode 100644 crates/paint/src/mixer_reference_tests.rs create mode 100644 docs/creative-studio-validation.md diff --git a/crates/engine/examples/painting_baseline.rs b/crates/engine/examples/painting_baseline.rs new file mode 100644 index 0000000000..a31c5375e1 --- /dev/null +++ b/crates/engine/examples/painting_baseline.rs @@ -0,0 +1,111 @@ +//! CPU baseline, one case per process: `painting_baseline `. +//! Run against the pinned upstream checkout too. Timings exclude fixture construction. +use photocraft_engine::{Session, brush_cmds::LiveStroke}; +use photocraft_geom::Rect; +use photocraft_paint::{BrushSettings, Stroke, StrokePoint}; +use serde_json::json; +use std::time::Instant; + +fn ms(start: Instant) -> f64 { + start.elapsed().as_secs_f64() * 1000.0 +} + +fn stats(mut times: Vec) -> serde_json::Value { + if times.is_empty() { + return serde_json::Value::Null; + } + times.sort_by(f64::total_cmp); + let len = times.len(); + json!({"mean_ms":times.iter().sum::() / len as f64, + "p50_ms":times.get((len as f64 * 0.5).ceil() as usize - 1), + "p95_ms":times.get((len as f64 * 0.95).ceil() as usize - 1), + "p99_ms":times.get((len as f64 * 0.99).ceil() as usize - 1),"max_ms":times.last(),"samples":len}) +} + +fn main() -> Result<(), Box> { + let args: Vec<_> = std::env::args().collect(); + let dim: i32 = args.get(1).ok_or("missing dimension")?.parse()?; + let size: f32 = args.get(2).ok_or("missing diameter")?.parse()?; + let speed = args.get(3).ok_or("missing speed")?; + let mode = args.get(4).ok_or("missing mode")?; + if ![2048, 4096, 8192].contains(&dim) + || ![16.0, 64.0, 256.0, 1024.0].contains(&size) + || !["slow", "rapid"].contains(&speed.as_str()) + || !["stamp", "mixer"].contains(&mode.as_str()) + { + return Err("unsupported benchmark case".into()); + } + let mut s = Session::new(); + s.execute("file.new", json!({"width":dim,"height":dim,"background":"#808080"}))?; + s.execute("layer.new.layer", json!({"name":"Dense synthetic source"}))?; + s.edit("Fixture", |doc, id| { + if let Some(surface) = id.and_then(|id| doc.layer_mut(id)).and_then(|l| l.surface_mut()) { + let mut pixels = vec![0.0; 256 * 256 * 4]; + for ty in (0..dim).step_by(256) { + for tx in (0..dim).step_by(256) { + for (i, p) in pixels.chunks_exact_mut(4).enumerate() { + let x = tx + (i % 256) as i32; + let y = ty + (i / 256) as i32; + p.copy_from_slice(&[(x % 257) as f32 / 256.0, (y % 251) as f32 / 250.0, ((x ^ y) % 239) as f32 / 238.0, 0.85]); + } + surface.write_region(Rect::new(tx, ty, tx + 256, ty + 256), &pixels); + } + } + } + Ok(()) + })?; + s.execute("layer.new.layer", json!({"name":"Paint"}))?; + let source = s.active().ok_or("no document")?.doc.clone(); + let count = 96; + let step = if speed == "slow" { 4.0 } else { 48.0 }; + // A bounded out-and-back path exercises many interpolated dabs without a huge bounding box. + let points: Vec<_> = (0..=count) + .map(|i| { + let distance = i as f64 * step; + let phase = distance % 1600.0; + let x = if phase < 800.0 { phase } else { 1600.0 - phase }; + StrokePoint::new(dim as f64 / 2.0 - 400.0 + x, dim as f64 / 2.0 + (i as f64 * 0.17).sin() * 24.0, 1.0) + }) + .collect(); + let brush = BrushSettings { size, pressure_size: false, spacing: 0.25, seed: 42, ..Default::default() }; + let dab_count = photocraft_paint::dabs(&Stroke { brush: brush.clone(), points: points.clone() }).len(); + let mut params = json!({"points":[[points[0].x,points[0].y,1.0]],"brush":brush,"seed":42,"sampleAllLayers":true}); + let mut moves = Vec::new(); + let mut begin_ms = None; + let render_start = Instant::now(); + if mode == "stamp" { + let start = Instant::now(); + let mut live = LiveStroke::begin(&s, ¶ms)?; + begin_ms = Some(ms(start)); + for point in points.iter().skip(1) { + let start = Instant::now(); + live.push(&[*point])?; + moves.push(ms(start)); + } + std::hint::black_box(&live.doc); + } + let live_ms = ms(render_start); + params["points"] = json!(points.iter().map(|p| [p.x, p.y, 1.0]).collect::>()); + let start = Instant::now(); + s.execute(if mode == "stamp" { "paint.stroke" } else { "paint.mixerBrush" }, params)?; + let commit_ms = ms(start); + let painted = s.active().ok_or("no document")?.doc.clone(); + let start = Instant::now(); + s.execute("edit.undo", json!({}))?; + let undo_ms = ms(start); + let undo_exact = *s.active().ok_or("no document")?.doc == *source; + let start = Instant::now(); + s.execute("edit.redo", json!({}))?; + let redo_ms = ms(start); + let redo_exact = *s.active().ok_or("no document")?.doc == *painted; + println!( + "{}", + json!({"dimension":dim,"diameter":size,"speed":speed,"mode":mode,"input":"synthetic pressure=1, 97 samples", + "source":"dense synthetic RGBA8, three composited layers","begin_ms":begin_ms,"engine_updates":stats(moves), + "commit_ms":commit_ms,"undo_ms":undo_ms,"redo_ms":redo_ms,"undo_exact":undo_exact,"redo_exact":redo_exact, + "dabs":dab_count,"dabs_per_second":dab_count as f64 / (if mode == "stamp" {live_ms} else {commit_ms} / 1000.0), + "pointer_to_visible_ms":null,"display_frame_times":null,"gpu_peak_percent":null, + "scope":"CPU engine only; baseline stamp commit replays the recorded stroke; mixer has no live preview"}) + ); + Ok(()) +} diff --git a/crates/engine/examples/painting_live.rs b/crates/engine/examples/painting_live.rs new file mode 100644 index 0000000000..2e94d0ac4f --- /dev/null +++ b/crates/engine/examples/painting_live.rs @@ -0,0 +1,126 @@ +//! CPU baseline, one case per process: `painting_baseline `. +//! Run against the pinned upstream checkout too. Timings exclude fixture construction. +use photocraft_engine::{ + Session, + brush_cmds::{LiveStroke, mixer_live::LiveMixer}, +}; +use photocraft_geom::Rect; +use photocraft_paint::{BrushSettings, Stroke, StrokePoint}; +use serde_json::json; +use std::time::Instant; + +fn ms(start: Instant) -> f64 { + start.elapsed().as_secs_f64() * 1000.0 +} + +fn stats(mut times: Vec) -> serde_json::Value { + if times.is_empty() { + return serde_json::Value::Null; + } + times.sort_by(f64::total_cmp); + let len = times.len(); + json!({"mean_ms":times.iter().sum::() / len as f64, + "p50_ms":times.get((len as f64 * 0.5).ceil() as usize - 1), + "p95_ms":times.get((len as f64 * 0.95).ceil() as usize - 1), + "p99_ms":times.get((len as f64 * 0.99).ceil() as usize - 1),"max_ms":times.last(),"samples":len}) +} + +fn main() -> Result<(), Box> { + let args: Vec<_> = std::env::args().collect(); + let dim: i32 = args.get(1).ok_or("missing dimension")?.parse()?; + let size: f32 = args.get(2).ok_or("missing diameter")?.parse()?; + let speed = args.get(3).ok_or("missing speed")?; + let mode = args.get(4).ok_or("missing mode")?; + if ![2048, 4096, 8192].contains(&dim) + || ![16.0, 64.0, 256.0, 1024.0].contains(&size) + || !["slow", "rapid"].contains(&speed.as_str()) + || !["stamp", "mixer"].contains(&mode.as_str()) + { + return Err("unsupported benchmark case".into()); + } + let mut s = Session::new(); + s.execute("file.new", json!({"width":dim,"height":dim,"background":"#808080"}))?; + s.execute("layer.new.layer", json!({"name":"Dense synthetic source"}))?; + s.edit("Fixture", |doc, id| { + if let Some(surface) = id.and_then(|id| doc.layer_mut(id)).and_then(|l| l.surface_mut()) { + let mut pixels = vec![0.0; 256 * 256 * 4]; + for ty in (0..dim).step_by(256) { + for tx in (0..dim).step_by(256) { + for (i, p) in pixels.chunks_exact_mut(4).enumerate() { + let x = tx + (i % 256) as i32; + let y = ty + (i / 256) as i32; + p.copy_from_slice(&[(x % 257) as f32 / 256.0, (y % 251) as f32 / 250.0, ((x ^ y) % 239) as f32 / 238.0, 0.85]); + } + surface.write_region(Rect::new(tx, ty, tx + 256, ty + 256), &pixels); + } + } + } + Ok(()) + })?; + s.execute("layer.new.layer", json!({"name":"Paint"}))?; + let source = s.active().ok_or("no document")?.doc.clone(); + let count = 96; + let step = if speed == "slow" { 4.0 } else { 48.0 }; + // A bounded out-and-back path exercises many interpolated dabs without a huge bounding box. + let points: Vec<_> = (0..=count) + .map(|i| { + let distance = i as f64 * step; + let phase = distance % 1600.0; + let x = if phase < 800.0 { phase } else { 1600.0 - phase }; + StrokePoint::new(dim as f64 / 2.0 - 400.0 + x, dim as f64 / 2.0 + (i as f64 * 0.17).sin() * 24.0, 1.0) + }) + .collect(); + let brush = BrushSettings { size, pressure_size: false, spacing: 0.25, seed: 42, ..Default::default() }; + let dab_count = photocraft_paint::dabs(&Stroke { brush: brush.clone(), points: points.clone() }).len(); + let mut params = json!({"points":[[points[0].x,points[0].y,1.0]],"brush":brush,"seed":42,"sampleAllLayers":true}); + let mut moves = Vec::new(); + let mut begin_ms = None; + let mut prepared = None; + let render_start = Instant::now(); + if mode == "stamp" { + let start = Instant::now(); + let mut live = LiveStroke::begin(&s, ¶ms)?; + begin_ms = Some(ms(start)); + for point in points.iter().skip(1) { + let start = Instant::now(); + live.push(&[*point])?; + moves.push(ms(start)); + } + std::hint::black_box(&live.doc); + } + if mode == "mixer" { + let start = Instant::now(); + let mut live = LiveMixer::begin(&s, ¶ms)?; + begin_ms = Some(ms(start)); + for point in points.iter().skip(1) { + let start = Instant::now(); + live.push(&[*point])?; + moves.push(ms(start)); + } + prepared = Some(live.prepare_commit(&mut s)?); + } + let live_ms = ms(render_start); + params["points"] = json!(points.iter().map(|p| [p.x, p.y, 1.0]).collect::>()); + let start = Instant::now(); + s.execute(if mode == "stamp" { "paint.stroke" } else { "paint.mixerBrush" }, prepared.unwrap_or(params))?; + let commit_ms = ms(start); + let painted = s.active().ok_or("no document")?.doc.clone(); + let start = Instant::now(); + s.execute("edit.undo", json!({}))?; + let undo_ms = ms(start); + let undo_exact = *s.active().ok_or("no document")?.doc == *source; + let start = Instant::now(); + s.execute("edit.redo", json!({}))?; + let redo_ms = ms(start); + let redo_exact = *s.active().ok_or("no document")?.doc == *painted; + println!( + "{}", + json!({"dimension":dim,"diameter":size,"speed":speed,"mode":mode,"input":"synthetic pressure=1, 97 samples", + "source":"dense synthetic RGBA8, three composited layers","begin_ms":begin_ms,"engine_updates":stats(moves), + "commit_ms":commit_ms,"undo_ms":undo_ms,"redo_ms":redo_ms,"undo_exact":undo_exact,"redo_exact":redo_exact, + "dabs":dab_count,"dabs_per_second":dab_count as f64 / (live_ms / 1000.0), + "pointer_to_visible_ms":null,"display_frame_times":null,"gpu_peak_percent":null, + "scope":"CPU engine only; stamp commit replays the recorded stroke; mixer commits prepared live pixels"}) + ); + Ok(()) +} diff --git a/crates/engine/src/brush_cmds.rs b/crates/engine/src/brush_cmds.rs index d984363bca..270fb8eb70 100644 --- a/crates/engine/src/brush_cmds.rs +++ b/crates/engine/src/brush_cmds.rs @@ -897,7 +897,7 @@ pub fn specs() -> Vec { spec!( "paint.mixerBrush", "Mixer Brush", - r##"{"points":[…] (max 65536 samples, 2048px per segment),"brush":{…}?,"preset":name?,"size":0.5..512 px?,"wet":0..100=brush.mixer.wet,"load":0..100=brush.mixer.load,"mix":0..100=brush.mixer.mix,"flow":0..100=brush.mixer.flow,"color":"#rrggbb"?=foreground,"sampleAllLayers":bool=brush.mixer.sampleAllLayers,"cleanAfterStroke":bool=brush.mixer.cleanAfterStroke,"loadAfterStroke":bool=brush.mixer.reloadAfterStroke,"seed":u64?,"mixerState":{reservoir,amount,pickup,spatial} (optional captured replay state; spatial is null or 4096 RGBA colors)}"##, + r##"{"points":[…] (max 65536 samples, 2048px per segment),"brush":{…}?,"preset":name?,"size":0.5..1024 px?,"wet":0..100=brush.mixer.wet,"load":0..100=brush.mixer.load,"mix":0..100=brush.mixer.mix,"flow":0..100=brush.mixer.flow,"color":"#rrggbb"?=foreground,"sampleAllLayers":bool=brush.mixer.sampleAllLayers,"cleanAfterStroke":bool=brush.mixer.cleanAfterStroke,"loadAfterStroke":bool=brush.mixer.reloadAfterStroke,"seed":u64?,"mixerState":{reservoir,amount,pickup,spatial} (optional captured replay state; spatial is null or 4096 RGBA colors)}"##, has_paintable, mixer_brush, true diff --git a/crates/engine/src/brush_cmds/mixer_live.rs b/crates/engine/src/brush_cmds/mixer_live.rs index 21f4c7e99e..21bed7d414 100644 --- a/crates/engine/src/brush_cmds/mixer_live.rs +++ b/crates/engine/src/brush_cmds/mixer_live.rs @@ -4,7 +4,7 @@ use super::*; use photocraft_color::{PixelFormat, SampleType}; use photocraft_doc::{Document, LayerId}; use photocraft_paint::dynamics::DabGenerator; -use photocraft_paint::mixer::{MixerState, apply_mixer_dab}; +use photocraft_paint::mixer::{MixerState, apply_mixer_dab_region}; use photocraft_paint::retouch::{Region, mix_back}; use photocraft_paint::{BrushContext, Dab}; use std::collections::BTreeSet; @@ -59,8 +59,8 @@ impl Core { continue; } let full = self.ctx.dab_rect(dab, false); - if u64::from(full.width()).saturating_mul(u64::from(full.height())) > 1_048_576 { - return Err(bad(CMD, "Mixer Brush footprint exceeds 1048576 pixels")); + if u64::from(full.width()).saturating_mul(u64::from(full.height())) > 4_194_304 { + return Err(bad(CMD, "Mixer Brush footprint exceeds 4194304 pixels")); } // Float working tiles avoid repeated integer-depth quantization. Initialize only // touched tiles, keeping unchanged source tiles shared by the document snapshots. @@ -80,13 +80,16 @@ impl Core { // deposition. Masks, transforms, blend modes and adjustments use the compositor. let sample = self.settings.sample_all_layers.then(|| { let buf = photocraft_compose::render(&self.doc, r); - let mut sample = Surface::new(PixelFormat::RGBA32F); - sample.write_region(r, &buf.px.iter().flatten().copied().collect::>()); + let fmt = self.pre.format(); + let mut sample = Region::new(r, fmt.channels()); + for (src, dst) in buf.px.iter().zip(sample.data.chunks_exact_mut(sample.ch)) { + photocraft_raster::from_rgba_into(&fmt, *src, dst); + } sample }); let fp = self.ctx.footprint(dab, index); let mut region = Region::read(&self.work, r); - apply_mixer_dab(&mut region, &fp, self.pre.format(), sample.as_ref(), &self.settings, &mut self.state, self.lock); + apply_mixer_dab_region(&mut region, &fp, self.pre.format(), sample.as_ref(), &self.settings, &mut self.state, self.lock); region.write(&mut self.work); let original = Region::read(&self.pre, r); let (target, _) = crate::channel_cmds::target_surface(Arc::make_mut(&mut self.doc), self.layer, &self.params)?; @@ -133,8 +136,8 @@ impl LiveMixer { let points = parse_points(p, CMD)?; let brush = resolve_brush(s, p, CMD)?; // Reject unsupported sizes before allocating a dense brush footprint. - if brush.size > 512.0 { - return Err(bad(CMD, "live Mixer Brush size is limited to 512 pixels")); + if brush.size > 1024.0 { + return Err(bad(CMD, "live Mixer Brush size is limited to 1024 pixels; choose Brush for larger tips")); } let bm = &brush.mixer; let settings = MixerSettings { @@ -274,7 +277,7 @@ impl LiveMixer { pub(super) fn run(s: &mut Session, p: &Value) -> Result { let cached = s.prepared_mixer.take().filter(|live| { - s.active().is_some_and(|st| Arc::ptr_eq(&st.doc, &live.original)) + s.active().is_some_and(|st| Arc::ptr_eq(&st.doc, &live.original) && (live.core.layer.is_none() || st.active_layer == live.core.layer)) && s.tools.mixer == live.original_state && live.commit_params().is_ok_and(|params| params == *p) }); @@ -308,15 +311,15 @@ pub(super) fn sample(s: &mut Session, p: &Value) -> Result { return Err(bad("brush.mixer.sample", "exactly one sample point is required")); } let mut brush = resolve_brush(s, p, "brush.mixer.sample")?; - if brush.size > 512.0 { - return Err(bad("brush.mixer.sample", "sampling size is limited to 512 pixels")); + if brush.size > 1024.0 { + return Err(bad("brush.mixer.sample", "sampling size is limited to 1024 pixels")); } brush.flow = 1.0; let dabs = photocraft_paint::dabs(&Stroke { brush: brush.clone(), points }); let dab = dabs.first().ok_or_else(|| bad("brush.mixer.sample", "brush has no contact"))?; let ctx = BrushContext::new(&brush); let rect = ctx.dab_rect(dab, false); - if u64::from(rect.width()).saturating_mul(u64::from(rect.height())) > 1_048_576 { + if u64::from(rect.width()).saturating_mul(u64::from(rect.height())) > 4_194_304 { return Err(bad("brush.mixer.sample", "sampling footprint is too large")); } let fp = ctx.footprint(dab, 0); diff --git a/crates/engine/src/brush_cmds/mixer_live_tests.rs b/crates/engine/src/brush_cmds/mixer_live_tests.rs index b13dc6ed3e..bac3a97446 100644 --- a/crates/engine/src/brush_cmds/mixer_live_tests.rs +++ b/crates/engine/src/brush_cmds/mixer_live_tests.rs @@ -224,3 +224,19 @@ fn mixer_rejects_malformed_load_and_retains_or_reloads_paint() { s.execute("paint.mixerBrush", json!({"points":[[40,40],[80,40]],"size":10,"loadAfterStroke":true,"load":10})).unwrap(); assert_eq!(s.tools.mixer.amount, 1.0); } + +#[test] +fn mixer_large_tip_retains_off_canvas_paint_and_commits_the_live_result() { + let mut s = fixture(PixelFormat::RGBA8); + let source = s.active().unwrap().doc.clone(); + let params = json!({"points":[[96,48]],"size":1024,"wet":0,"mix":0,"color":"#1122ee","brush":{"pressureSize":false}}); + let live = LiveMixer::begin(&s, ¶ms).unwrap(); + let id = s.active().unwrap().active_layer.unwrap(); + let shown = live.doc.layer(id).unwrap().surface().unwrap().clone(); + assert!(shown.rgba(-100, 48)[3] > 0.99, "off-canvas layer pixels remain paintable"); + let params = live.prepare_commit(&mut s).unwrap(); + s.execute("paint.mixerBrush", params).unwrap(); + assert_eq!(target(&s), shown); + s.execute("edit.undo", json!({})).unwrap(); + assert_eq!(*s.active().unwrap().doc, *source); +} diff --git a/crates/paint/src/mixer.rs b/crates/paint/src/mixer.rs index 4c35019cba..6682e83f6b 100644 --- a/crates/paint/src/mixer.rs +++ b/crates/paint/src/mixer.rs @@ -6,7 +6,7 @@ //! weight. The reservoir amount drains per dab unless `load` is 100 %, so low Load strokes dry out. //! A dry brush (`wet = 0`) paints only reservoir colour; an empty, wet brush smears canvas colour. -use photocraft_raster::{Surface, from_rgba, to_rgba}; +use photocraft_raster::{Surface, from_rgba, from_rgba_into, to_rgba}; use serde::{Deserialize, Serialize}; use crate::Stroke; @@ -119,6 +119,33 @@ pub fn apply_mixer_dab( m: &MixerSettings, state: &mut MixerState, lock_transparency: bool, +) { + let sample = sample.map(|surface| { + let source = crate::retouch::Region::read(surface, work.rect); + if surface.format().mode == fmt.mode && surface.format().alpha == fmt.alpha { + source + } else { + let mut native = crate::retouch::Region::new(work.rect, fmt.channels()); + for (src, dst) in source.data.chunks_exact(source.ch).zip(native.data.chunks_exact_mut(native.ch)) { + from_rgba_into(&fmt, to_rgba(&surface.format(), src), dst); + } + native + } + }); + apply_mixer_dab_region(work, fp, fmt, sample.as_ref(), m, state, lock_transparency); +} + +/// Contiguous native-channel sample variant. `sample` must have the same rectangle and +/// channel layout as `work`. The live compositor supplies it directly, avoiding a tiled +/// temporary surface and a heap allocation for every sampled/deposited pixel. +pub fn apply_mixer_dab_region( + work: &mut crate::retouch::Region, + fp: &crate::retouch::Footprint, + fmt: photocraft_color::PixelFormat, + sample: Option<&crate::retouch::Region>, + m: &MixerSettings, + state: &mut MixerState, + lock_transparency: bool, ) { let n = fmt.channels(); let a = alpha_index(&fmt); @@ -148,13 +175,7 @@ pub fn apply_mixer_dab( if w <= 0.0 { continue; } - let px: Vec = match sample { - Some(s) => { - let v = s.pixel(x, y); - if s.format() == fmt { v } else { from_rgba(&fmt, s.rgba(x, y)) } - } - None => work.px(x, y).to_vec(), - }; + let px = sample.unwrap_or(work).px(x, y); let al = a.map_or(1.0, |ai| px[ai]); for c in 0..nc { acc[c] += px[c] * w * al; @@ -181,17 +202,18 @@ pub fn apply_mixer_dab( paint[c] = (rv * wr + pv * wp) / total; } let dep = total.min(1.0) * flow; + let mut local = vec![0.0; n]; + let mut mixed = vec![0.0; n]; for y in r.y0..r.y1 { for x in r.x0..r.x1 { let k = fp.at(x, y) * dep; if k > 0.0 { if let Some(load) = &state.spatial { let loaded = load_at(load, &fp.dab, x as f32 + 0.5, y as f32 + 0.5); - let local = from_rgba(&fmt, loaded); + from_rgba_into(&fmt, loaded, &mut local); let local_wr = wr * loaded[3]; let local_total = local_wr + wp; if local_total > 1e-6 { - let mut mixed = paint.clone(); for (c, value) in mixed.iter_mut().enumerate() { *value = (local.get(c).copied().unwrap_or(0.0) * local_wr + pickup.as_ref().and_then(|p| p.get(c)).copied().unwrap_or(0.0) * wp) @@ -304,3 +326,7 @@ mod tests { assert!(run(1.0).is_some_and(|p| p[2] > 0.2)); } } + +#[cfg(test)] +#[path = "mixer_reference_tests.rs"] +mod reference_tests; diff --git a/crates/paint/src/mixer_reference_tests.rs b/crates/paint/src/mixer_reference_tests.rs new file mode 100644 index 0000000000..cdd86e2a48 --- /dev/null +++ b/crates/paint/src/mixer_reference_tests.rs @@ -0,0 +1,152 @@ +// Frozen pre-optimization dab kernel. Keep independent of the optimized implementation. +use super::*; +fn reference( + work: &mut crate::retouch::Region, + fp: &crate::retouch::Footprint, + fmt: photocraft_color::PixelFormat, + sample: Option<&Surface>, + m: &MixerSettings, + state: &mut MixerState, + lock_transparency: bool, +) { + let n = fmt.channels(); + let a = alpha_index(&fmt); + let nc = fmt.mode.color_channels(); + let native = |c: [f32; 4]| { + let mut v = from_rgba(&fmt, c); + if let Some(ai) = a { + v[ai] = 1.0; + } + v + }; + let res = state.reservoir.map(native); + let mut amount = if res.is_some() { state.amount.clamp(0.0, 1.0) } else { 0.0 }; + let mut pickup: Option> = state.pickup.map(native); + let (wet, mix, flow, load) = (m.wet.clamp(0.0, 1.0), m.mix.clamp(0.0, 1.0), m.flow.clamp(0.0, 1.0), m.load.clamp(0.0, 1.0)); + let mut acc = vec![0.0f32; n]; + let mut paint = vec![0.0f32; n]; + // Transfer › Wetness / Mix Jitter scale the settings per dab. + let (wet, mix) = (wet * fp.dab.wet.clamp(0.0, 1.0), mix * fp.dab.mix.clamp(0.0, 1.0)); + // Sample the canvas under the dab. + acc.iter_mut().for_each(|v| *v = 0.0); + let (mut wsum, mut asum) = (0.0f32, 0.0f32); + let r = fp.rect.intersect(&work.rect); + for y in r.y0..r.y1 { + for x in r.x0..r.x1 { + let w = fp.at(x, y); + if w <= 0.0 { + continue; + } + let px: Vec = match sample { + Some(s) => { + let v = s.pixel(x, y); + if s.format() == fmt { v } else { from_rgba(&fmt, s.rgba(x, y)) } + } + None => work.px(x, y).to_vec(), + }; + let al = a.map_or(1.0, |ai| px[ai]); + for c in 0..nc { + acc[c] += px[c] * w * al; + } + wsum += w; + asum += w * al; + } + } + if asum > 1e-6 && wet > 0.0 { + let ca = asum / wsum.max(1e-6); + let canvas: Vec = (0..n).map(|c| if c < nc { acc[c] / asum } else { 1.0 }).collect(); + pickup = Some(match pickup.take() { + None => canvas, + Some(p) => p.iter().zip(&canvas).map(|(p, c)| p + (c - p) * PICKUP_RATE * wet * ca).collect(), + }); + } + let wr = if res.is_some() { amount * (1.0 - mix * wet) } else { 0.0 }; + let wp = if pickup.is_some() { mix * wet } else { 0.0 }; + let total = wr + wp; + if total > 1e-6 { + for c in 0..n { + let rv = res.as_ref().map_or(0.0, |v| v[c]); + let pv = pickup.as_ref().map_or(0.0, |v| v[c]); + paint[c] = (rv * wr + pv * wp) / total; + } + let dep = total.min(1.0) * flow; + for y in r.y0..r.y1 { + for x in r.x0..r.x1 { + let k = fp.at(x, y) * dep; + if k > 0.0 { + if let Some(load) = &state.spatial { + let loaded = load_at(load, &fp.dab, x as f32 + 0.5, y as f32 + 0.5); + let local = from_rgba(&fmt, loaded); + let local_wr = wr * loaded[3]; + let local_total = local_wr + wp; + if local_total > 1e-6 { + let mut mixed = paint.clone(); + for (c, value) in mixed.iter_mut().enumerate() { + *value = (local.get(c).copied().unwrap_or(0.0) * local_wr + + pickup.as_ref().and_then(|p| p.get(c)).copied().unwrap_or(0.0) * wp) + / local_total; + } + if let Some(ai) = a + && let Some(alpha) = mixed.get_mut(ai) + { + *alpha = 1.0; + } + over_native(&fmt, work.px_mut(x, y), &mixed, fp.at(x, y) * local_total.min(1.0) * flow, lock_transparency); + } + } else { + over_native(&fmt, work.px_mut(x, y), &paint, k, lock_transparency); + } + } + } + } + } + amount *= 1.0 - 0.08 * (1.0 - load); + state.amount = amount; + state.pickup = pickup.map(|p| to_rgba(&fmt, &p)); +} + +#[test] +fn contiguous_mixer_matches_frozen_kernel_across_models_depths_and_spatial_loads() { + use crate::retouch::Region; + use crate::{BrushContext, BrushSettings, Stroke, StrokePoint}; + use photocraft_color::{ColorMode, PixelFormat, SampleType}; + let rect = Rect::new(-16, -16, 32, 32); + for mode in [ColorMode::Rgb, ColorMode::Grayscale, ColorMode::Cmyk, ColorMode::Lab] { + for depth in [SampleType::U8, SampleType::U16, SampleType::F32] { + for alpha in [false, true] { + let fmt = PixelFormat::new(mode, depth, alpha); + let mut surface = Surface::new(fmt); + let values: Vec<_> = (0..rect.width() * rect.height()).flat_map(|i| from_rgba(&fmt, [(i % 31) as f32 / 30.0, 0.3, 0.7, 0.6])).collect(); + surface.write_region(rect, &values); + let mut source = Surface::new(PixelFormat::RGBA32F); + source.fill_rect(rect, &[0.8, 0.2, 0.1, 0.75]); + let brush = BrushSettings { size: 24.0, angle: 33.0, roundness: 0.6, pressure_size: false, ..Default::default() }; + let dabs = crate::dabs(&Stroke { brush: brush.clone(), points: vec![StrokePoint::new(4.0, 4.0, 1.0)] }); + let ctx = BrushContext::new(&brush); + for spatial in [false, true] { + for sample in [None, Some(&source), Some(&surface)] { + for lock in [false, true] { + let mut state = MixerState::default(); + state.load([0.1, 0.8, 0.2, 1.0]); + if spatial { + state.spatial = + Some((0..4096).map(|i| [if i % 64 < 32 { 1.0 } else { 0.0 }, 0.2, 0.8, if i % 7 == 0 { 0.0 } else { 1.0 }]).collect()); + } + let mut expected_state = state.clone(); + let mut actual = Region::read(&surface, rect); + let mut expected = actual.clone(); + let settings = MixerSettings::default(); + for (index, dab) in dabs.iter().enumerate() { + let fp = ctx.footprint(dab, index); + reference(&mut expected, &fp, fmt, sample, &settings, &mut expected_state, lock); + apply_mixer_dab(&mut actual, &fp, fmt, sample, &settings, &mut state, lock); + } + assert_eq!(actual, expected, "{mode:?} {depth:?} alpha={alpha} spatial={spatial} lock={lock}"); + assert_eq!(state, expected_state); + } + } + } + } + } + } +} diff --git a/docs/creative-studio-validation.md b/docs/creative-studio-validation.md new file mode 100644 index 0000000000..07f3957f8f --- /dev/null +++ b/docs/creative-studio-validation.md @@ -0,0 +1,123 @@ +# Creative Painting Studio: validation ledger + +This branch contains independently scoped local work. It is not a completed studio +or a release. Original PhotoCraft additions do not change Photoshop parity counts. + +## Source and upstream coordination + +The mixer foundation started from `29f1ff9e90f2581ea2964e3276d85c71ab7e79a0`. +The 2026-10-11 upstream refresh resolved to +`e44d96e1d4671b8d9fd64fbabdf88fa8abf0441e`. The original baseline remains pinned. +Upstream #2131 now supplies prepared commits for ordinary Brush/Pencil and should +be retained when this branch integrates current main. #3098, #2885 and #2379 contain +overlapping brush performance work; no speedups from those branches are attributed +to this work. PDF Binder #2011 and PDF integration #2751 are untouched. + +Open #2878 supplies an `ImageProvider`/`HttpTransport` interface, bounded encoded +sRGB image/mask interchange and cancellable engine jobs. Its inspected head is +`4754d3c6edb9b37a7ad8516f15425abeca84987d`. #730 offers the OpenAI backend; +#2879 is dependent UI; #2995 and #2649 concern local segmentation. No provider or +network-generation functionality is added by this painting foundation. Later AI +result/guidance work must reconcile these existing contributions. + +## Gate 0 fixture and measurement scope + +`crates/engine/examples/painting_baseline.rs` is intentionally compatible with the +pinned original source. Copy this example into a detached checkout of the baseline +and build it there. `painting_live.rs` uses the same fixture and path for the new +live mixer. Do not compare the old full-stroke commit timer to a new individual +update as though they measure the same amount of work. + +Each case is a fresh process with three layers: a uniform background, a fully +allocated synthetic RGBA8 source with varying RGB and alpha, and an empty paint +layer. Dimensions are 2048², 4096² and 8192². Diameters are 16, 64, 256 and 1024 px; +spacing is 25%, seed 42, pressure one, smoothing off. Each path has 97 points, with +4 px or 48 px horizontal travel per update and a small sinusoidal vertical motion. +The rapid path travels back and forth, retaining a bounded painted region while +generating many interpolated dabs. Fixture construction is outside engine timers. + +The process runner records observed peak working set and host CPU utilization at +100 ms intervals. Those process metrics include fixture construction and validation; +brief peaks can be missed. JSON engine timers record begin, average/p50/p95/p99/max +input-update costs, completion, dab throughput and Undo/Redo. Exact Undo/Redo document +comparisons are outside those timers. These are CPU-engine measurements, not UI frame +times, OS pointer-to-display latency or tablet measurements. GPU utilization and +display timings remain explicitly null. No FPS performance gate passes from these +measurements alone. + +Build configuration used on Windows: rustc 1.97.1, release, LTO disabled, 16 codegen +units, four compiler jobs. Intel i7-9700K, eight logical processors. Avoid concurrent +compilation or other benchmarks when collecting comparative timings. + +```powershell +cargo build -p photocraft-engine --example painting_baseline --release --locked --offline -j4 --config profile.release.lto=false --config profile.release.codegen-units=16 +cargo build -p photocraft-engine --example painting_live --release --locked --offline -j4 --config profile.release.lto=false --config profile.release.codegen-units=16 +# One example case; repeat all dimension / diameter / speed combinations. +target/release/examples/painting_baseline.exe 4096 256 rapid mixer +target/release/examples/painting_live.exe 4096 256 rapid mixer +``` + +The original ordinary-stamp benchmark replays the command on release. It does not +include upstream's subsequently merged #2131 optimization. Its baseline must remain +labeled with its actual source revision. + +## Mixer optimization + +The original incremental implementation built a tiled RGBA32F sample Surface per +dab and allocated temporary pixel vectors in both sampling and spatial deposition. +The optimized path feeds the compositor's contiguous pixels into a native-channel +Region, borrows sampled slices, and reuses deposition scratch vectors. It preserves +the original arithmetic and full-resolution coverage; it does not reduce quality. +An independent frozen pre-optimization kernel checks exact pixels and reservoir +state across RGB/Gray/CMYK/Lab, 8/16/F32, alpha/no-alpha, spatial/uniform paint, +current/composite sampling and transparency lock. + +The size envelope now accepts 1024 px tips with at most 4,194,304 pixels per dense +footprint. The 256-tile working-set and input/dab limits remain. Larger sizes fail +explicitly with a suggestion to choose Brush; there is no silent mid-stroke quality +change. Acceptance of a size is not a responsiveness claim. + +## Measured CPU matrix + +All 96 baseline/live cases completed with exact Undo/Redo validation. The table gives +the worst mean/p95/p99 input-update times across the three canvas sizes and two +movement speeds in the new live implementation, in milliseconds. + +| Diameter | Stamp mean / p95 / p99 | Mixer mean / p95 / p99 | +|---|---|---| +| 16 | 0.112 / 0.173 / 0.207 | 0.582 / 1.218 / 2.002 | +| 64 | 0.371 / 0.463 / 1.005 | 1.417 / 1.856 / 3.076 | +| 256 | 1.337 / 1.940 / 2.374 | 6.193 / 9.491 / 10.480 | +| 1024 | 4.654 / 24.169 / 38.489 | 20.845 / 108.355 / 162.528 | + +Prepared mixer completion ranged from 0.674 to 3.451 ms. The original full-stroke +completion ranged from 9.451 to 4,085.397 ms; these completion measurements cover +different work because live rendering has moved that work into input updates. +Observed peak process working set was at most 400.6 MiB for the live matrix. +These results do not qualify 1024 px tips for the stated responsiveness targets. +Even the smaller engine-only timings do not prove display FPS or physical pen latency. + +## Functional and platform gates + +The mixer foundation unit/integration checks, live/committed screenshots and exact +pixel comparison are described in `mixer-live.md`. The first broad native test run +hit `0xc0000005` in concurrent `arbitrary_rotation_preview` tests on WARP. Both tests +passed serially. This matches the independently reported upstream #3212 issue; +no driver settings or host configuration were changed. Offscreen evidence uses the +Microsoft Basic Render Driver, not a verified physical RTX path. + +Relevant reproducible checks: + +```powershell +cargo test -p photocraft-paint -p photocraft-engine -p photocraft-ui-egui --lib --tests -- --test-threads=1 +cargo clippy -p photocraft-paint -p photocraft-engine -p photocraft-ui-egui --all-targets -- -D warnings +cargo xtask layers +cargo xtask wasm +cargo xtask parity +cargo test -p photocraft-engine --test panic_hunt -- --ignored +cargo xtask perf --quick +``` + +Native Linux/Wayland/X11, macOS, physical Wacom/Windows pen input, physical GPU +presentation and real pointer-to-display latency remain unqualified on this host. +WASM compile success is not browser interaction qualification. From a564ea2c76e29c1f07e9411d9df935d523d39d5c Mon Sep 17 00:00:00 2001 From: itsF4LCON <107556180+itsF4LCON@users.noreply.github.com> Date: Sun, 11 Oct 2026 16:43:05 +0200 Subject: [PATCH 025/649] History panel: snapshots (camera button, snapshot rows) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Part of #2966. The History panel's camera button takes a named snapshot of the document ("Snapshot N", not a history state). Snapshots are listed under the opening state with a thumbnail and scroll with the states; clicking one returns the document to it as one new, undoable state named after it. A double-click or right-click › Rename… renames it in place, and right-click › Delete removes it. Snapshots live for the session only, as in Photoshop. For agents: history.newSnapshot {name?, from?: fullDocument | mergedLayers | currentLayer}, history.selectSnapshot, renameSnapshot and deleteSnapshot, addressed by ids that are never reused, and doc.inspect reports snapshots. --- crates/engine/src/history_cmds.rs | 269 +++++++++++++++++++++++++++++- crates/engine/src/inspect.rs | 1 + crates/engine/src/lib.rs | 7 + crates/ui-egui/src/lib.rs | 27 +++ crates/ui-egui/src/panels.rs | 217 +++++++++++++++++++++++- docs/control-protocol.md | 2 +- docs/ui-parity.md | 4 +- 7 files changed, 517 insertions(+), 10 deletions(-) diff --git a/crates/engine/src/history_cmds.rs b/crates/engine/src/history_cmds.rs index d9ca98f962..bb9cb34391 100644 --- a/crates/engine/src/history_cmds.rs +++ b/crates/engine/src/history_cmds.rs @@ -2,14 +2,34 @@ //! "Create new document from current state" button). Stepping to a state is Edit › Undo / Redo. //! //! States are indexed like [`photocraft_ops::History::entries`]: 0 is the oldest state still -//! held, the last index is the current document. Snapshots are not implemented. +//! held, the last index is the current document. +//! +//! Snapshots (#2966, the camera button) are named copies of the document that outlive the +//! states: `history.newSnapshot` takes one, `history.selectSnapshot` brings it back as a new, +//! undoable state. They live on [`crate::DocState::snapshots`] for the session only, as in +//! Photoshop, and are addressed by an id that is never reused. Their tiles are shared +//! copy-on-write with the document and its history, and are not counted in the history's pixel +//! budget. +use std::sync::Arc; + +use photocraft_doc::{Document, Layer, LayerContent}; +use photocraft_ops::LayerTarget; use serde_json::{Value, json}; use crate::commands::{CommandSpec, int}; use crate::image_cmds::reidentify_copied_layers; use crate::{EngineError, Result, Session}; +/// A History panel snapshot: the document as it was when taken, and the layers it targeted. +#[derive(Clone, Debug)] +pub struct Snapshot { + pub id: u64, + pub name: String, + pub doc: Arc, + pub layers: LayerTarget, +} + fn bad(cmd: &str, msg: impl Into) -> EngineError { EngineError::BadParams { cmd: cmd.into(), msg: msg.into() } } @@ -72,6 +92,105 @@ fn new_document(s: &mut Session, p: &Value) -> Result { Ok(json!({ "document": index, "name": name })) } +/// The `snapshot` param: the index of the active document's snapshot with that id. +fn snapshot_index(s: &Session, cmd: &str, p: &Value) -> Result { + let st = s.active().ok_or(EngineError::NoDocument)?; + let id = p.get("snapshot").and_then(Value::as_u64).ok_or_else(|| bad(cmd, "`snapshot` must be a snapshot id"))?; + st.snapshots.iter().position(|snap| snap.id == id).ok_or_else(|| bad(cmd, format!("no snapshot {id}"))) +} + +/// A non-blank `name` param, trimmed; `None` when absent. +fn name_param(cmd: &str, p: &Value) -> Result> { + match p.get("name") { + None | Some(Value::Null) => Ok(None), + Some(Value::String(n)) if !n.trim().is_empty() => Ok(Some(n.trim().to_string())), + Some(_) => Err(bad(cmd, "`name` must be a non-empty string")), + } +} + +/// History panel › Create new snapshot (the camera button): a named copy of the document, +/// "Snapshot N" by default. `from` is the New Snapshot dialog's From: the full document (default), +/// its layers merged into one, or only the active layer. Not a history state. +fn new_snapshot(s: &mut Session, p: &Value) -> Result { + const CMD: &str = "history.newSnapshot"; + let name = name_param(CMD, p)?; + let from = match p.get("from") { + None | Some(Value::Null) => "fullDocument", + Some(Value::String(f)) if matches!(f.as_str(), "fullDocument" | "mergedLayers" | "currentLayer") => f.as_str(), + Some(_) => return Err(bad(CMD, "`from` must be \"fullDocument\", \"mergedLayers\" or \"currentLayer\"")), + }; + let st = s.active().ok_or(EngineError::NoDocument)?; + let one_layer = |doc: &Document, layer: Layer| { + let mut doc = doc.clone(); + let id = layer.id; + doc.layers = vec![layer]; + (Arc::new(doc), LayerTarget { active: Some(id), selected: vec![id] }) + }; + let (doc, layers) = match from { + "mergedLayers" => { + let fmt = st.doc.pixel_format(); + one_layer(&st.doc, Layer::new("Merged Layers", LayerContent::Raster(crate::file_cmds::flattened(&st.doc, fmt)))) + } + "currentLayer" => { + let layer = st.active_layer.and_then(|id| st.doc.layer(id)).ok_or_else(|| bad(CMD, "no active layer"))?; + one_layer(&st.doc, layer.clone()) + } + _ => (st.doc.clone(), st.layer_target()), + }; + let st = s.active_mut().ok_or(EngineError::NoDocument)?; + let id = st.next_snapshot; + st.next_snapshot = id.saturating_add(1); + let name = name.unwrap_or_else(|| format!("Snapshot {id}")); + st.snapshots.push(Snapshot { id, name: name.clone(), doc, layers }); + Ok(json!({ "snapshot": id, "name": name })) +} + +/// Clicking a snapshot: the document returns to it as one new, undoable state named after it. +fn select_snapshot(s: &mut Session, p: &Value) -> Result { + const CMD: &str = "history.selectSnapshot"; + let i = snapshot_index(s, CMD, p)?; + // A background job is computing from the current state: it must not move under it. + if s.active_job().is_some() { + return Err(EngineError::Other("the document is busy with a background job".into())); + } + let snap = s.active().and_then(|st| st.snapshots.get(i).cloned()).ok_or(EngineError::NoDocument)?; + s.edit(&snap.name, |doc, active| { + // Keep the identity (colour state, views and caches are keyed by it) and the tab name. + let (id, name) = (doc.id, doc.name.clone()); + *doc = (*snap.doc).clone(); + doc.id = id; + doc.name = name; + *active = snap.layers.active.filter(|l| doc.layer(*l).is_some()).or_else(|| doc.top_layer()); + Ok(()) + })?; + let st = s.active_mut().ok_or(EngineError::NoDocument)?; + if st.active_layer == snap.layers.active { + st.selected_layers.clone_from(&snap.layers.selected); + crate::fix_selection(st); + } + Ok(json!({ "snapshot": snap.id, "name": snap.name })) +} + +/// Renaming a snapshot (double-click its name). +fn rename_snapshot(s: &mut Session, p: &Value) -> Result { + const CMD: &str = "history.renameSnapshot"; + let i = snapshot_index(s, CMD, p)?; + let name = name_param(CMD, p)?.ok_or_else(|| bad(CMD, "`name` is required"))?; + let st = s.active_mut().ok_or(EngineError::NoDocument)?; + let snap = st.snapshots.get_mut(i).ok_or_else(|| bad(CMD, "no such snapshot"))?; + snap.name.clone_from(&name); + Ok(json!({ "snapshot": snap.id, "name": name })) +} + +/// Deleting a snapshot; the document and its history are unchanged. +fn delete_snapshot(s: &mut Session, p: &Value) -> Result { + const CMD: &str = "history.deleteSnapshot"; + let i = snapshot_index(s, CMD, p)?; + let st = s.active_mut().ok_or(EngineError::NoDocument)?; + let snap = st.snapshots.remove(i); + Ok(json!({ "snapshot": snap.id, "snapshots": st.snapshots.len() })) +} + fn can_delete(s: &Session) -> std::result::Result<(), String> { s.active().filter(|d| d.history.can_undo()).map(|_| ()).ok_or_else(|| "the oldest state can't be deleted".into()) } @@ -102,6 +221,46 @@ pub fn specs() -> Vec { run: new_document, journal: true, }, + CommandSpec { + id: "history.newSnapshot", + label: "New Snapshot", + menu: &[], + shortcut: None, + params: r##"{"name":str?="Snapshot N","from":"fullDocument"|"mergedLayers"|"currentLayer"="fullDocument"} → {snapshot,name}: a named copy of the document for the session (not a history state)"##, + enabled: has_doc, + run: new_snapshot, + journal: true, + }, + CommandSpec { + id: "history.selectSnapshot", + label: "Select Snapshot", + menu: &[], + shortcut: None, + params: r##"{"snapshot":id} → {snapshot,name}: the document returns to the snapshot as a new history state named after it"##, + enabled: has_doc, + run: select_snapshot, + journal: true, + }, + CommandSpec { + id: "history.renameSnapshot", + label: "Rename Snapshot", + menu: &[], + shortcut: None, + params: r##"{"snapshot":id,"name":str} → {snapshot,name}"##, + enabled: has_doc, + run: rename_snapshot, + journal: true, + }, + CommandSpec { + id: "history.deleteSnapshot", + label: "Delete Snapshot", + menu: &[], + shortcut: None, + params: r##"{"snapshot":id} → {snapshot,snapshots}: the document and its history are unchanged"##, + enabled: has_doc, + run: delete_snapshot, + journal: true, + }, ] } @@ -193,6 +352,114 @@ mod tests { assert_eq!(entries(&s), before); } + /// The top layer's pixel at (1, 1). + fn top_pixel(s: &Session) -> [f32; 4] { + s.active().unwrap().doc.layers.last().unwrap().surface().unwrap().rgba(1, 1) + } + + fn snapshots(s: &Session) -> Value { + crate::inspect::document(s.active().unwrap())["snapshots"].clone() + } + + #[test] + fn new_snapshot_keeps_the_document_and_is_not_a_history_state() { + let mut s = session(); + let before = entries(&s); + let r = s.execute("history.newSnapshot", json!({})).unwrap(); + assert_eq!(r, json!({"snapshot": 1, "name": "Snapshot 1"})); + assert_eq!(entries(&s), before, "taking a snapshot is not a step"); + let r = s.execute("history.newSnapshot", json!({"name": "Before green"})).unwrap(); + assert_eq!(r, json!({"snapshot": 2, "name": "Before green"})); + assert_eq!(snapshots(&s), json!([{"id": 1, "name": "Snapshot 1"}, {"id": 2, "name": "Before green"}])); + } + + #[test] + fn select_snapshot_returns_to_it_as_one_undoable_state() { + let mut s = session(); + s.execute("history.newSnapshot", json!({})).unwrap(); + let green = top_pixel(&s); + let id = s.active().unwrap().doc.id; + s.execute("edit.fill", json!({"color": "#0000ff"})).unwrap(); + let blue = top_pixel(&s); + let before = entries(&s); + s.execute("history.selectSnapshot", json!({"snapshot": 1})).unwrap(); + assert_eq!(top_pixel(&s), green); + assert_eq!(entries(&s).len(), before.len() + 1, "one new state"); + assert_eq!(entries(&s).last().map(String::as_str), Some("Snapshot 1")); + assert_eq!(s.active().unwrap().doc.id, id, "the same document"); + assert!(s.active().unwrap().active_layer.is_some()); + s.execute("edit.undo", json!({})).unwrap(); + assert_eq!(top_pixel(&s), blue, "undo leaves the snapshot"); + assert_eq!(snapshots(&s).as_array().unwrap().len(), 1, "snapshots are not history"); + } + + #[test] + fn snapshots_from_merged_layers_or_the_current_layer() { + let mut s = session(); + assert_eq!(s.active().unwrap().doc.layers.len(), 2); + s.execute("history.newSnapshot", json!({"from": "mergedLayers"})).unwrap(); + s.execute("history.newSnapshot", json!({"from": "currentLayer"})).unwrap(); + s.execute("history.newSnapshot", json!({"from": "fullDocument"})).unwrap(); + s.execute("history.selectSnapshot", json!({"snapshot": 1})).unwrap(); + let doc = s.active().unwrap().doc.clone(); + assert_eq!(doc.layers.len(), 1, "merged into one layer"); + assert_eq!(doc.layers[0].surface().unwrap().rgba(1, 1), [0.0, 1.0, 0.0, 1.0], "the visible result"); + s.execute("history.selectSnapshot", json!({"snapshot": 2})).unwrap(); + assert_eq!(s.active().unwrap().doc.layers.len(), 1, "only the active layer"); + s.execute("history.selectSnapshot", json!({"snapshot": 3})).unwrap(); + assert_eq!(s.active().unwrap().doc.layers.len(), 2); + } + + #[test] + fn rename_and_delete_snapshots_keep_the_other_ids() { + let mut s = session(); + for _ in 0..3 { + s.execute("history.newSnapshot", json!({})).unwrap(); + } + s.execute("history.renameSnapshot", json!({"snapshot": 2, "name": "Lesson start"})).unwrap(); + s.execute("history.deleteSnapshot", json!({"snapshot": 1})).unwrap(); + assert_eq!(snapshots(&s), json!([{"id": 2, "name": "Lesson start"}, {"id": 3, "name": "Snapshot 3"}])); + let r = s.execute("history.newSnapshot", json!({})).unwrap(); + assert_eq!(r["snapshot"], json!(4), "ids are never reused"); + } + + #[test] + fn snapshot_commands_refuse_bad_params() { + let mut s = Session::new(); + for (cmd, p) in [ + ("history.newSnapshot", json!({})), + ("history.selectSnapshot", json!({"snapshot": 1})), + ("history.renameSnapshot", json!({"snapshot": 1, "name": "x"})), + ("history.deleteSnapshot", json!({"snapshot": 1})), + ] { + assert!(s.execute(cmd, p).is_err(), "{cmd}: no document"); + } + let mut s = session(); + s.execute("history.newSnapshot", json!({})).unwrap(); + let (before, snaps) = (entries(&s), snapshots(&s)); + for (cmd, p) in [ + ("history.newSnapshot", json!({"from": "everything"})), + ("history.newSnapshot", json!({"from": 3})), + ("history.newSnapshot", json!({"name": 7})), + ("history.selectSnapshot", json!({})), + ("history.selectSnapshot", json!({"snapshot": 99})), + ("history.selectSnapshot", json!({"snapshot": -1})), + ("history.selectSnapshot", json!({"snapshot": "1"})), + ("history.selectSnapshot", json!({"snapshot": f64::MAX})), + ("history.renameSnapshot", json!({"snapshot": 1})), + ("history.renameSnapshot", json!({"snapshot": 1, "name": " "})), + ("history.renameSnapshot", json!({"snapshot": 99, "name": "x"})), + ("history.deleteSnapshot", json!({"snapshot": 99})), + ("history.deleteSnapshot", json!({"snapshot": [1]})), + ] { + assert!(s.execute(cmd, p.clone()).is_err(), "{cmd} {p}"); + assert_eq!((entries(&s), snapshots(&s)), (before.clone(), snaps.clone()), "{cmd} {p} changed nothing"); + } + // Current Layer needs an active layer. + s.execute("select.deselectLayers", json!({})).unwrap(); + assert!(s.execute("history.newSnapshot", json!({"from": "currentLayer"})).is_err()); + } + #[test] fn new_document_refuses_bad_params() { let mut s = Session::new(); diff --git a/crates/engine/src/inspect.rs b/crates/engine/src/inspect.rs index 1d1c7e0c72..acfebc7f9f 100644 --- a/crates/engine/src/inspect.rs +++ b/crates/engine/src/inspect.rs @@ -39,6 +39,7 @@ pub fn document(d: &DocState) -> Value { "selectionBounds": doc.selection.as_ref().map(|s| { let r = s.content_bounds(); [r.x0, r.y0, r.width() as i32, r.height() as i32] }), "layers": doc.layers.iter().rev().map(|l| layer_sel(l, &selected)).collect::>(), "history": d.history.entries(), + "snapshots": d.snapshots.iter().map(|snap| json!({"id": snap.id, "name": snap.name})).collect::>(), "canUndo": d.history.can_undo(), "canRedo": d.history.can_redo(), "revision": d.revision, diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 1fffd0bdc1..9a926f86f1 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -213,6 +213,11 @@ pub struct DocState { /// pixel coordinates. Per-document view state: discarded when the document closes, never saved /// to `.pcraft` or PSD, and not a history step. pub color_samplers: Vec<[f64; 2]>, + /// History panel snapshots, oldest first (`history.newSnapshot`, #2966). Kept for the + /// session only, as in Photoshop: not history states, and not saved with the document. + pub snapshots: Vec, + /// The id the next snapshot gets; ids are never reused, so deleting one keeps the others. + next_snapshot: u64, } impl DocState { @@ -239,6 +244,8 @@ impl DocState { show_only: None, floating: None, color_samplers: Vec::new(), + snapshots: Vec::new(), + next_snapshot: 1, } } /// The selected layers in bottom-to-top document order, always including the active layer. diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 49a0332bcb..4beb2a8c35 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -548,6 +548,9 @@ pub struct PhotocraftApp { pub fps: f32, last_frame_time: f64, thumbs: HashMap<(photocraft_doc::LayerId, u8), (u64, egui::TextureHandle)>, + /// History snapshot thumbnails by (document, snapshot id): a snapshot never changes, so each + /// is made once (`snapshot_thumb`, #2966). + snapshot_thumbs: HashMap<(DocId, u64), egui::TextureHandle>, /// Snapshots whose live layer/mask keys were last used to prune thumbnail handles. thumb_documents: Vec<(DocId, std::sync::Weak)>, /// Content bounds cached per (key, revision): scanning a 36 MP layer every frame cost ~77 ms. @@ -722,6 +725,7 @@ impl PhotocraftApp { fps: 0.0, last_frame_time: 0.0, thumbs: HashMap::new(), + snapshot_thumbs: HashMap::new(), thumb_documents: Vec::new(), bounds_cache: HashMap::new(), proxy: None, @@ -1814,6 +1818,29 @@ impl PhotocraftApp { self.store_thumb(ctx, key, rev, img) } + /// The History panel thumbnail of snapshot `snap` of document `doc` (#2966): its composite, + /// centred in a square. Thumbnails of `doc`'s snapshots not in `live` are dropped. + pub fn snapshot_thumb(&mut self, ctx: &egui::Context, doc: DocId, snap: &photocraft_engine::history_cmds::Snapshot, live: &[u64]) -> egui::TextureId { + self.snapshot_thumbs.retain(|(d, id), _| *d != doc || live.contains(id)); + if let Some(tex) = self.snapshot_thumbs.get(&(doc, snap.id)) { + return tex.id(); + } + let comp = photocraft_compose::thumbnail(&snap.doc, 56); + let (w, h) = (comp.width as usize, comp.height as usize); + let side = w.max(h); + let (ox, oy) = ((side - w) / 2, (side - h) / 2); + let mut px = vec![egui::Color32::TRANSPARENT; side * side]; + for (i, &[r, g, b, a]) in comp.pixels.as_chunks::<4>().0.iter().enumerate() { + if let Some(out) = px.get_mut((i / w + oy) * side + i % w + ox) { + *out = egui::Color32::from_rgba_unmultiplied(r, g, b, a); + } + } + let tex = ctx.load_texture(format!("snapshot-{}", snap.id), egui::ColorImage::new([side, side], px), egui::TextureOptions::LINEAR); + let id = tex.id(); + self.snapshot_thumbs.insert((doc, snap.id), tex); + id + } + pub fn mask_thumb(&mut self, ctx: &egui::Context, doc: &Document, id: photocraft_doc::LayerId, mask: &photocraft_doc::LayerMask) -> egui::TextureId { let rev = surface_fingerprint(&mask.surface) ^ (doc.size.width as u64) << 40; let key = (id, mask_thumbs_ui::THUMB_MASK); diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index b893521aa5..e85f5aa8db 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -2840,12 +2840,16 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) { ui.painter().text(pos2(thumb.right() + 8.0, rect.center().y), Align2::LEFT_CENTER, &doc.name, egui::FontId::proportional(12.0), t.text); ui.painter().line_segment([rect.left_bottom(), rect.right_bottom()], Stroke::new(1.0, t.separator)); } + let mut snap_cmd = None; let mut target: Option = None; let all = entries.iter().map(|e| (e.clone(), false)).chain(redo.iter().map(|e| (e.clone(), true))); // The dock gives History a fixed height: the rows scroll above the footer. let footer = if t.pro { widgets::footer_height(ui) + ui.spacing().item_spacing.y } else { 0.0 }; let max_h = (ui.available_height() - footer).max(40.0); egui::ScrollArea::vertical().id_salt("history-rows").max_height(max_h).auto_shrink([false, false]).show(ui, |ui| { + // Snapshots head the list and scroll with the states, so many of them never push the + // footer out of a short dock. + snap_cmd = snapshot_rows(app, ui); for (i, (e, is_redo)) in all.enumerate() { let (rect, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 24.0), Sense::click()); if i == current { @@ -2883,8 +2887,10 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) { if ui.add_enabled_ui(can_delete, |ui| icons::button(ui, "trash", 26.0, false, tl!("Delete current state"))).inner.clicked() { footer_cmd = Some("history.deleteState"); } - // Snapshots are not implemented yet: shown greyed, as Photoshop's footer has the button. - ui.add_enabled_ui(false, |ui| icons::button(ui, "scan", 26.0, false, tl!("Create new snapshot"))); + let can_snap = app.session.is_enabled("history.newSnapshot"); + if ui.add_enabled_ui(can_snap, |ui| icons::button(ui, "scan", 26.0, false, tl!("Create new snapshot"))).inner.clicked() { + footer_cmd = Some("history.newSnapshot"); + } if ui.add_enabled_ui(can_new, |ui| icons::button(ui, "file-plus", 26.0, false, tl!("Create new document from current state"))).inner.clicked() { footer_cmd = Some("history.newDocument"); } @@ -2892,8 +2898,10 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) { } // An open Free Transform owns Undo (transform_tool::intercept): stepping the document's history under // its box would leave it transforming pixels that changed. - if let Some(cmd) = footer_cmd.filter(|_| app.ui.transform.is_none()) - && let Err(e) = app.run(cmd, json!({})) + // Selecting a snapshot changes the document, so it waits for an open transform like the rows. + let snap_cmd = snap_cmd.filter(|(cmd, _)| *cmd != "history.selectSnapshot" || app.ui.transform.is_none()); + if let Some((cmd, p)) = footer_cmd.map(|c| (c, json!({}))).filter(|_| app.ui.transform.is_none()).or(snap_cmd) + && let Err(e) = app.run(cmd, p) { app.ui.status = e; app.ui.status_error = true; @@ -2908,6 +2916,79 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) { } } +/// The History panel's snapshot rows (#2966), under the opening row, each with its thumbnail and +/// name: a click returns to the snapshot (a new state), a double-click or right-click › Rename… +/// edits the name in place (Enter or a click elsewhere keeps it, Escape cancels), and +/// right-click › Delete removes it. Returns the command a row asks for. +fn snapshot_rows(app: &mut PhotocraftApp, ui: &mut egui::Ui) -> Option<(&'static str, Value)> { + let t = Tokens::get(ui.ctx()); + let st = app.session.active()?; + let (doc_id, snaps) = (st.doc.id, st.snapshots.clone()); + let live: Vec = snaps.iter().map(|s| s.id).collect(); + // Per document: snapshot ids restart in each, and a tab switch must not carry the edit over. + let rename_id = egui::Id::new(("history-snapshot-rename", doc_id)); + let mut renaming: Option<(u64, String)> = ui.data(|d| d.get_temp(rename_id)).flatten(); + let mut cmd = None; + let ctx = ui.ctx().clone(); + for snap in &snaps { + let (rect, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 38.0), Sense::click()); + resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, &snap.name)); + if resp.hovered() { + ui.painter().rect_filled(rect, 0.0, t.hover.gamma_multiply(0.5)); + } + let thumb = Rect::from_min_size(pos2(rect.left() + 28.0, rect.center().y - 14.0), vec2(28.0, 28.0)); + widgets::checker(ui.painter(), thumb, 4.0); + let tex = app.snapshot_thumb(&ctx, doc_id, snap, &live); + ui.painter().image(tex, thumb, Rect::from_min_max(egui::Pos2::ZERO, pos2(1.0, 1.0)), Color32::WHITE); + ui.painter().rect_stroke(thumb, 0.0, Stroke::new(1.0, t.separator), StrokeKind::Outside); + match renaming.as_mut().filter(|(id, _)| *id == snap.id) { + Some((_, text)) => { + let field = Rect::from_min_max(pos2(thumb.right() + 6.0, rect.center().y - 10.0), pos2(rect.right() - 6.0, rect.center().y + 10.0)); + let r = ui.put(field, egui::TextEdit::singleline(text)); + if r.lost_focus() { + if !ui.input(|i| i.key_pressed(egui::Key::Escape)) { + cmd = Some(("history.renameSnapshot", json!({"snapshot": snap.id, "name": text.clone()}))); + } + renaming = None; + } else if !r.has_focus() { + // Starting to rename: focus the field with the whole name selected, so typing + // replaces it (Photoshop). + r.request_focus(); + if let Some(mut state) = egui::TextEdit::load_state(ui.ctx(), r.id) { + let all = egui::text::CCursorRange::two(egui::text::CCursor::new(0), egui::text::CCursor::new(text.chars().count())); + state.cursor.set_char_range(Some(all)); + state.store(ui.ctx(), r.id); + } + } + } + None => { + ui.painter().text(pos2(thumb.right() + 8.0, rect.center().y), Align2::LEFT_CENTER, &snap.name, egui::FontId::proportional(12.0), t.text); + } + } + if resp.double_clicked() { + renaming = Some((snap.id, snap.name.clone())); + } else if resp.clicked() { + cmd = Some(("history.selectSnapshot", json!({"snapshot": snap.id}))); + } + resp.context_menu(|ui| { + if ui.button(tl!("Rename…")).clicked() { + renaming = Some((snap.id, snap.name.clone())); + ui.close(); + } + if ui.button(tl!("Delete")).clicked() { + cmd = Some(("history.deleteSnapshot", json!({"snapshot": snap.id}))); + ui.close(); + } + }); + } + if !snaps.is_empty() { + let y = ui.cursor().top(); + ui.painter().hline(ui.max_rect().x_range(), y, Stroke::new(1.0, t.separator)); + } + ui.data_mut(|d| d.insert_temp(rename_id, renaming)); + cmd +} + // ----------------------------------------------------------------------------- properties /// Floating Properties card anchored to the canvas' top-right corner. @@ -4102,8 +4183,8 @@ mod history_transform_tests { } } - /// The Photoshop-theme footer (#1117): trash deletes the current state, file-plus makes a - /// new document from it, and the snapshot button is greyed (snapshots aren't implemented). + /// The Photoshop-theme footer (#1117): trash deletes the current state, the camera takes a + /// snapshot (#2966), and file-plus makes a new document from the current state. #[test] fn history_footer_buttons_run_their_commands() { let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); @@ -4124,7 +4205,12 @@ mod history_transform_tests { }; let b = buttons(&h); assert_eq!(b.len(), 3, "trash, snapshot, new document: {b:?}"); - assert!(b[0].1 && !b[1].1 && b[2].1, "only the snapshot button is disabled: {b:?}"); + assert!(b.iter().all(|b| b.1), "all enabled: {b:?}"); + let steps = h.state().session.active().unwrap().history.entries().len(); + click(&mut h, b[1].0.center()); + let st = h.state().session.active().unwrap(); + assert_eq!(st.snapshots.len(), 1, "the camera takes a snapshot"); + assert_eq!(st.history.entries().len(), steps, "which is not a history state"); let docs = h.state().session.documents().len(); click(&mut h, b[2].0.center()); assert_eq!(h.state().session.documents().len(), docs + 1, "file-plus makes a new document"); @@ -4139,6 +4225,123 @@ mod history_transform_tests { } } +#[cfg(test)] +mod snapshot_row_tests { + use egui::vec2; + use egui_kittest::Harness; + use egui_kittest::kittest::Queryable; + use serde_json::json; + + use super::*; + + fn top_pixel(h: &Harness<'static, PhotocraftApp>) -> [f32; 4] { + h.state().session.active().unwrap().doc.layers.last().unwrap().surface().unwrap().rgba(1, 1) + } + + fn snapshot_names(h: &Harness<'static, PhotocraftApp>) -> Vec { + h.state().session.active().unwrap().snapshots.iter().map(|s| s.name.clone()).collect() + } + + /// Snapshot rows (#2966) sit under the opening row: clicking one returns to it as a new + /// state, and its right-click menu renames or deletes it. + #[test] + fn snapshot_rows_select_rename_and_delete() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 200, "height": 150})).unwrap(); + app.run("layer.new.layer", json!({})).unwrap(); + app.run("edit.fill", json!({"color": "#ff0000"})).unwrap(); + app.run("history.newSnapshot", json!({})).unwrap(); + app.run("edit.fill", json!({"color": "#0000ff"})).unwrap(); + // 60 fps steps, so two clicks a frame apart count as a double-click. + let mut h = + Harness::builder().with_size(vec2(300.0, 400.0)).with_step_dt(1.0 / 60.0).build_ui_state(|ui, app: &mut PhotocraftApp| history(app, ui), app); + h.run_steps(3); + let steps = h.state().session.active().unwrap().history.entries().len(); + h.get_by_label("Snapshot 1").click(); + h.run_steps(2); + let st = h.state().session.active().unwrap(); + assert_eq!(st.history.entries().len(), steps + 1); + assert_eq!(st.history.entries().last().map(String::as_str), Some("Snapshot 1")); + assert_eq!(top_pixel(&h), [1.0, 0.0, 0.0, 1.0], "back to red"); + // Right-click › Rename…: type a name, Enter. + h.get_by_label("Snapshot 1").click_secondary(); + h.run_steps(2); + h.get_by_label("Rename…").click(); + h.run_steps(2); + h.get_by_role(egui::accesskit::Role::TextInput).type_text("Lesson start"); + h.key_press(egui::Key::Enter); + h.run_steps(2); + assert_eq!(snapshot_names(&h), ["Lesson start"]); + // A double-click renames too; Escape keeps the old name. + let steps_now = h.state().session.active().unwrap().history.entries().len(); + // A real double-click (accessibility clicks are single clicks). + let p = h.get_by_label("Lesson start").rect().center(); + let p = egui::pos2(p.x as f32, p.y as f32); + h.event(egui::Event::PointerMoved(p)); + // Wait out the double-click window of the earlier clicks. + h.run_steps(30); + for pressed in [true, false, true, false] { + h.event(egui::Event::PointerButton { pos: p, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE }); + h.step(); + } + h.run_steps(3); + h.get_by_role(egui::accesskit::Role::TextInput).type_text("Oops"); + h.key_press(egui::Key::Escape); + h.run_steps(2); + assert_eq!(snapshot_names(&h), ["Lesson start"], "Escape cancels"); + assert_eq!(h.state().session.active().unwrap().history.entries().len(), steps_now + 1, "the click selected it once"); + // Right-click › Delete. + h.get_by_label("Lesson start").click_secondary(); + h.run_steps(2); + h.get_by_label("Delete").click(); + h.run_steps(2); + assert!(snapshot_names(&h).is_empty()); + assert_eq!(h.state().session.active().unwrap().history.entries().len(), steps + 2, "deleting leaves the history alone"); + } + + /// Snapshot rows scroll with the states: many snapshots in a short dock leave the footer and + /// its camera button in view. + #[test] + fn many_snapshots_keep_the_footer_in_a_short_panel() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 200, "height": 150})).unwrap(); + for _ in 0..6 { + app.run("history.newSnapshot", json!({})).unwrap(); + } + let mut h = Harness::builder().with_size(vec2(300.0, 250.0)).build_ui_state(|ui, app: &mut PhotocraftApp| history(app, ui), app); + PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::ProMedium); + h.state_mut().ui.theme = crate::theme::ThemeKind::ProMedium; + h.run_steps(3); + let view = h.ctx.input(|i| i.viewport_rect()); + let buttons: Vec = h + .ctx + .viewport(|v| v.prev_pass.widgets.layers().flat_map(|(_, w)| w.iter()).filter(|w| w.rect.size() == vec2(26.0, 26.0)).map(|w| w.rect).collect()); + assert_eq!(buttons.len(), 3, "{buttons:?}"); + assert!(buttons.iter().all(|b| view.contains_rect(*b)), "footer in view: {buttons:?} in {view:?}"); + } + + /// Renaming belongs to one document: snapshot ids restart in each, so switching tabs must not + /// carry the edit over to the other document's snapshot with the same id. + #[test] + fn a_rename_in_progress_stays_with_its_document() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + for _ in 0..2 { + app.run("file.new", json!({"width": 200, "height": 150})).unwrap(); + app.run("history.newSnapshot", json!({})).unwrap(); + } + let mut h = Harness::builder().with_size(vec2(300.0, 400.0)).build_ui_state(|ui, app: &mut PhotocraftApp| history(app, ui), app); + h.run_steps(3); + h.get_by_label("Snapshot 1").click_secondary(); + h.run_steps(2); + h.get_by_label("Rename…").click(); + h.run_steps(2); + assert!(h.query_by_role(egui::accesskit::Role::TextInput).is_some(), "renaming in document 2"); + h.state_mut().session.set_active(0); + h.run_steps(2); + assert!(h.query_by_role(egui::accesskit::Role::TextInput).is_none(), "not in document 1"); + } +} + #[cfg(test)] #[path = "layer_pct_slider_tests.rs"] mod layer_pct_slider_tests; diff --git a/docs/control-protocol.md b/docs/control-protocol.md index b8d38b558a..db2251dfdc 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -101,7 +101,7 @@ store expose and persist the same setting; scripts keep using canonical command | `layer.newAdjustmentLayer.hueSaturation` | `{"hue":30,"saturation":10}` | | `paint.stroke` | `{"points":[[x,y,pressure],…],"size":20,"color":"#ff0000"}` | | `select.rect` | `{"x":0,"y":0,"width":100,"height":50,"mode":"add","ellipse":false}` | -| `document.inspect` | `{}`: layer tree, history, selection bounds | +| `document.inspect` | `{}`: layer tree, history, snapshots (`[{id, name}]`, for `history.selectSnapshot`), selection bounds | | `document.pixel` | `{"x":10,"y":10}`: composite RGBA | | `document.presets.list` | `{}` → `{presets:[{name,settings}]}`: saved New Document configurations | | `document.presets.save` | `{"name":"Product square","settings":{"width":1600,"height":1600,"background":"transparent"}}`: save a snapshot; names are trimmed, 1–255 characters, and ASCII case-insensitive duplicates are rejected | diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 270214e1f9..af0992b6af 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI parity: tools, handles, modifiers and feel -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-11 · **Change:** minor (Hand-tool flick panning) · **Target:** Adobe Photoshop 2026 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-11 · **Change:** minor (History snapshots) · **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, @@ -198,6 +198,7 @@ Paragraph; the rest open as in-app floating windows. | Command palette with recents | done | UI-217-7 | | Every preference takes effect | partial | 46 of 149 do nothing (scorecard) | | UI scale presets | missing | UI-217-9, #2492 | +| History snapshots: camera button, snapshot rows (click returns, rename, delete), `history.*Snapshot` commands | partial | `history_cmds.rs`, `snapshot_rows` in `panels.rs`; New Snapshot dialog, first snapshot and History Options to come (#2966) | | Themes: Photoshop's four greys | partial | five themes; #2661 | | Document tabs: overflow, context menu, reorder | done | UI-217-6; middle-click close #2570 | | Layers panel: wheel steps blend modes, drop on New/Trash | partial | UI-217-14 | @@ -209,3 +210,4 @@ Paragraph; the rest open as in-app floating windows. | 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 | | 2026-10-11 | minor | Flick panning done: releasing a moving Hand drag (tool, Space or middle button) glides and decays, gated by Enable Flick Panning | +| 2026-10-11 | minor | History snapshots: the camera button takes one, snapshot rows return to it as a new state, rename and delete it (#2966) | From b00adf4287d963b8ec43baad4ea1ef49fa61eefd Mon Sep 17 00:00:00 2001 From: itsF4LCON <107556180+itsF4LCON@users.noreply.github.com> Date: Sun, 11 Oct 2026 17:17:06 +0200 Subject: [PATCH 026/649] History panel: New Snapshot dialog and the first snapshot Part of #2966. Every document starts with a snapshot of itself as opened, named after it, as Photoshop does: the History panel's top row is now that snapshot, so clicking it brings the opened document back as one new state, even after History has dropped its oldest states. Option-click on the camera button opens New Snapshot: Name (suggested "Snapshot N", selected) and From (Full Document, Merged Layers, Current Layer). "From:", "Full Document" and "Merged Layers" are translated in all 16 catalogs, and "New Snapshot" in the 7 that lacked it. --- crates/engine/src/history_cmds.rs | 35 ++++++++- crates/engine/src/lib.rs | 16 ++-- crates/ui-egui/src/dialogs.rs | 2 + crates/ui-egui/src/i18n/cs.tsv | 4 + crates/ui-egui/src/i18n/de.tsv | 4 + crates/ui-egui/src/i18n/el.tsv | 3 + crates/ui-egui/src/i18n/es.tsv | 4 + crates/ui-egui/src/i18n/fr.tsv | 3 + crates/ui-egui/src/i18n/id.tsv | 3 + crates/ui-egui/src/i18n/it.tsv | 4 + crates/ui-egui/src/i18n/ja.tsv | 3 + crates/ui-egui/src/i18n/ko.tsv | 4 + crates/ui-egui/src/i18n/nl.tsv | 3 + crates/ui-egui/src/i18n/pl.tsv | 3 + crates/ui-egui/src/i18n/pt-br.tsv | 3 + crates/ui-egui/src/i18n/ru.tsv | 3 + crates/ui-egui/src/i18n/uk.tsv | 3 + crates/ui-egui/src/i18n/zh-hans.tsv | 4 + crates/ui-egui/src/i18n/zh-hant.tsv | 4 + crates/ui-egui/src/lib.rs | 1 + crates/ui-egui/src/panels.rs | 105 +++++++++++++++++++++----- crates/ui-egui/src/snapshot_dialog.rs | 71 +++++++++++++++++ docs/control-protocol.md | 2 +- docs/ui-parity.md | 3 +- 24 files changed, 260 insertions(+), 30 deletions(-) create mode 100644 crates/ui-egui/src/snapshot_dialog.rs diff --git a/crates/engine/src/history_cmds.rs b/crates/engine/src/history_cmds.rs index bb9cb34391..e49633e324 100644 --- a/crates/engine/src/history_cmds.rs +++ b/crates/engine/src/history_cmds.rs @@ -99,6 +99,12 @@ fn snapshot_index(s: &Session, cmd: &str, p: &Value) -> Result { st.snapshots.iter().position(|snap| snap.id == id).ok_or_else(|| bad(cmd, format!("no snapshot {id}"))) } +/// The name `history.newSnapshot` gives a snapshot without one: "Snapshot N" (the New Snapshot +/// dialog suggests it too). +pub fn next_snapshot_name(st: &crate::DocState) -> String { + format!("Snapshot {}", st.next_snapshot) +} + /// A non-blank `name` param, trimmed; `None` when absent. fn name_param(cmd: &str, p: &Value) -> Result> { match p.get("name") { @@ -138,9 +144,9 @@ fn new_snapshot(s: &mut Session, p: &Value) -> Result { _ => (st.doc.clone(), st.layer_target()), }; let st = s.active_mut().ok_or(EngineError::NoDocument)?; + let name = name.unwrap_or_else(|| next_snapshot_name(st)); let id = st.next_snapshot; st.next_snapshot = id.saturating_add(1); - let name = name.unwrap_or_else(|| format!("Snapshot {id}")); st.snapshots.push(Snapshot { id, name: name.clone(), doc, layers }); Ok(json!({ "snapshot": id, "name": name })) } @@ -370,7 +376,8 @@ mod tests { assert_eq!(entries(&s), before, "taking a snapshot is not a step"); let r = s.execute("history.newSnapshot", json!({"name": "Before green"})).unwrap(); assert_eq!(r, json!({"snapshot": 2, "name": "Before green"})); - assert_eq!(snapshots(&s), json!([{"id": 1, "name": "Snapshot 1"}, {"id": 2, "name": "Before green"}])); + let first = json!({"id": 0, "name": s.active().unwrap().doc.name}); + assert_eq!(snapshots(&s), json!([first, {"id": 1, "name": "Snapshot 1"}, {"id": 2, "name": "Before green"}])); } #[test] @@ -390,7 +397,7 @@ mod tests { assert!(s.active().unwrap().active_layer.is_some()); s.execute("edit.undo", json!({})).unwrap(); assert_eq!(top_pixel(&s), blue, "undo leaves the snapshot"); - assert_eq!(snapshots(&s).as_array().unwrap().len(), 1, "snapshots are not history"); + assert_eq!(snapshots(&s).as_array().unwrap().len(), 2, "snapshots are not history"); } #[test] @@ -418,11 +425,31 @@ mod tests { } s.execute("history.renameSnapshot", json!({"snapshot": 2, "name": "Lesson start"})).unwrap(); s.execute("history.deleteSnapshot", json!({"snapshot": 1})).unwrap(); - assert_eq!(snapshots(&s), json!([{"id": 2, "name": "Lesson start"}, {"id": 3, "name": "Snapshot 3"}])); + s.execute("history.deleteSnapshot", json!({"snapshot": 0})).unwrap(); + assert_eq!(snapshots(&s), json!([{"id": 2, "name": "Lesson start"}, {"id": 3, "name": "Snapshot 3"}]), "the first snapshot can go too"); let r = s.execute("history.newSnapshot", json!({})).unwrap(); assert_eq!(r["snapshot"], json!(4), "ids are never reused"); } + /// Photoshop's first snapshot (#2966): every document starts with a snapshot of itself as + /// opened, named after it, so the opening state can always be brought back, even after + /// History has dropped its oldest states. + #[test] + fn a_document_starts_with_a_first_snapshot_of_itself() { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 20, "height": 10})).unwrap(); + let name = s.active().unwrap().doc.name.clone(); + assert_eq!(snapshots(&s), json!([{"id": 0, "name": name}])); + let opened = top_pixel(&s); + for _ in 0..3 { + s.execute("edit.fill", json!({"color": "#ff0000"})).unwrap(); + } + s.active_mut().unwrap().history.purge_last(); + s.execute("history.selectSnapshot", json!({"snapshot": 0})).unwrap(); + assert_eq!(top_pixel(&s), opened, "back to the document as opened"); + assert_eq!(entries(&s).last(), Some(&name), "a state named after the document"); + } + #[test] fn snapshot_commands_refuse_bad_params() { let mut s = Session::new(); diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 9a926f86f1..4390575479 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -213,8 +213,9 @@ pub struct DocState { /// pixel coordinates. Per-document view state: discarded when the document closes, never saved /// to `.pcraft` or PSD, and not a history step. pub color_samplers: Vec<[f64; 2]>, - /// History panel snapshots, oldest first (`history.newSnapshot`, #2966). Kept for the - /// session only, as in Photoshop: not history states, and not saved with the document. + /// History panel snapshots, oldest first (`history.newSnapshot`, #2966): the first (id 0) is + /// the document as opened. Kept for the session only, as in Photoshop: not history states, + /// and not saved with the document. pub snapshots: Vec, /// The id the next snapshot gets; ids are never reused, so deleting one keeps the others. next_snapshot: u64, @@ -224,9 +225,14 @@ impl DocState { pub fn new(doc: Document, path: Option) -> Self { let active_layer = doc.top_layer(); let mut history = History::default(); - history.set_current_layers(LayerTarget { active: active_layer, selected: active_layer.into_iter().collect() }); + let target = LayerTarget { active: active_layer, selected: active_layer.into_iter().collect() }; + history.set_current_layers(target.clone()); + let doc = Arc::new(doc); + // Photoshop's first snapshot: the document as opened, named after it, so the History + // panel's top row can always bring it back (#2966). + let first = history_cmds::Snapshot { id: 0, name: doc.name.clone(), doc: doc.clone(), layers: target }; Self { - doc: Arc::new(doc), + doc, history, active_layer, selected_layers: active_layer.into_iter().collect(), @@ -244,7 +250,7 @@ impl DocState { show_only: None, floating: None, color_samplers: Vec::new(), - snapshots: Vec::new(), + snapshots: vec![first], next_snapshot: 1, } } diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index e57c01b4c9..2f8215655f 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -229,6 +229,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) { DialogKind::Command if crate::fill_ui::owns(&fields) => crate::fill_ui::body(app, ui, &mut fields), DialogKind::Command if crate::pattern_fill_ui::owns(&fields) => crate::pattern_fill_ui::body(app, ui, &mut fields), DialogKind::Command if crate::stroke_ui::owns(&fields) => crate::stroke_ui::body(ui, &mut fields), + DialogKind::Command if crate::snapshot_dialog::owns(&fields) => crate::snapshot_dialog::body(ui, &mut fields), DialogKind::Command if crate::shape_dialog::owns(&fields) => crate::shape_dialog::body(app, ui, &mut fields), DialogKind::Command if crate::delete_layer_prompt::owns(&fields) => crate::delete_layer_prompt::body(ui, &mut fields), DialogKind::Command if crate::rasterize_prompt::owns(&fields) => crate::rasterize_prompt::body(ui, &fields), @@ -464,6 +465,7 @@ pub fn confirm(app: &mut PhotocraftApp, id: u64) -> Result { DialogKind::Command if crate::fill_ui::owns(&d.fields) => crate::fill_ui::confirm(app, &d.fields), DialogKind::Command if crate::pattern_fill_ui::owns(&d.fields) => crate::pattern_fill_ui::confirm(app, &d.fields), DialogKind::Command if crate::stroke_ui::owns(&d.fields) => crate::stroke_ui::confirm(app, &d.fields), + DialogKind::Command if crate::snapshot_dialog::owns(&d.fields) => crate::snapshot_dialog::confirm(app, &d.fields), DialogKind::Command if crate::shape_dialog::owns(&d.fields) => crate::shape_dialog::confirm(app, &d.fields), DialogKind::Command if crate::delete_layer_prompt::owns(&d.fields) => crate::delete_layer_prompt::confirm(app, &d.fields), DialogKind::Command if crate::rasterize_prompt::owns(&d.fields) => crate::rasterize_prompt::confirm(app, &d.fields), diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 93f8fd5956..60068225a1 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -974,6 +974,10 @@ Create new pattern from the selection Vytvořit nový vzorek z výběru Create new shape from the current path Vytvořit nový tvar z aktuální cesty Create new snapshot Vytvořit nový snímek + From: Z: + Full Document Celý dokument + Merged Layers Sloučené vrstvy + New Snapshot Nový snímek Create new tool preset Vytvořit nové přednastavení nástroje Crop Factor Crop faktor Ctrl Ctrl diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 26871a1e68..b325827b05 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -952,6 +952,10 @@ Create new pattern from the selection Neues Muster aus der Auswahl erstellen Create new shape from the current path Neue Form aus dem aktuellen Pfad erstellen Create new snapshot Neuen Snapshot erstellen + From: Von: + Full Document Gesamtes Dokument + Merged Layers Zusammengefügte Ebenen + New Snapshot Neuer Snapshot Create new style (from the selected type) Neuen Stil erstellen (aus dem ausgewählten Text) Create new style from the selected layer Neuen Stil aus der ausgewählten Ebene erstellen Create new tool preset Neue Werkzeugvorgabe erstellen diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index dc39a34150..22b56a00f9 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -719,6 +719,9 @@ Create new pattern from the selection Δημιουργία μοτίβου από την επιλογή Create new shape from the current path Δημιουργία σχήματος από την τρέχουσα διαδρομή Create new snapshot Δημιουργία νέου στιγμιότυπου + From: Από: + Full Document Ολόκληρο έγγραφο + Merged Layers Συγχωνευμένα επίπεδα Create new style (from the selected type) Δημιουργία στυλ από τον επιλεγμένο τύπο Create new style from the selected layer Δημιουργία στυλ από το επιλεγμένο επίπεδο Current & Below Τρέχον και υποκείμενα diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index c65d4dd089..52a7f5799c 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -960,6 +960,10 @@ Create new pattern from the selection Crear un motivo nuevo a partir de la selección Create new shape from the current path Crear una forma nueva a partir del trazado actual Create new snapshot Crear una instantánea nueva + From: De: + Full Document Documento completo + Merged Layers Capas combinadas + New Snapshot Instantánea nueva Create new tool preset Crear un ajuste preestablecido de herramienta nuevo Crop Factor Factor de recorte Ctrl Ctrl diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 6a20c3521b..a4a6d86563 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -948,6 +948,9 @@ Create new pattern from the selection Créer un nouveau motif à partir de la sélection Create new shape from the current path Créer une nouvelle forme à partir du tracé actif Create new snapshot Créer un nouvel instantané + From: À partir de : + Full Document Document entier + Merged Layers Calques fusionnés Create new tool preset Créer un nouveau préréglage d'outil Crop Factor Facteur de recadrage Ctrl Ctrl diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 9f1b970db2..061b2c7e11 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -942,6 +942,9 @@ Create new pattern from the selection Buat pola baru dari seleksi Create new shape from the current path Buat bentuk baru dari path saat ini Create new snapshot Buat snapshot baru + From: Dari: + Full Document Seluruh Dokumen + Merged Layers Layer Gabungan Create new tool preset Buat preset alat baru Crop Factor Faktor Crop Ctrl Ctrl diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 4924ecfc71..83bfe28abf 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -959,6 +959,10 @@ Create new pattern from the selection Crea nuovo pattern dalla selezione Create new shape from the current path Crea nuova forma dal tracciato corrente Create new snapshot Crea nuova istantanea + From: Da: + Full Document Documento intero + Merged Layers Livelli uniti + New Snapshot Nuova istantanea Create new style (from the selected type) Crea nuovo stile (dal testo selezionato) Create new style from the selected layer Crea nuovo stile dal livello selezionato Create new tool preset Crea nuovo predefinito strumento diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index be6169e806..dbef0bf2e5 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -961,6 +961,9 @@ Create new pattern from the selection 選択範囲から新規パターンを作成 Create new shape from the current path 現在のパスから新規シェイプを作成 Create new snapshot 新規スナップショットを作成 + From: 作成元: + Full Document ドキュメント全体 + Merged Layers 結合されたレイヤー Create new tool preset 新規ツールプリセットを作成 Crop Factor 切り抜き係数 Ctrl Ctrl diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index b9ee70a4e1..87937ad59e 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -934,6 +934,10 @@ Create new pattern from the selection 선택 영역으로 새 패턴 만들기 Create new shape from the current path 현재 패스로 새 모양 만들기 Create new snapshot 새 스냅샷 만들기 + From: 원본: + Full Document 전체 문서 + Merged Layers 병합된 레이어 + New Snapshot 새 스냅샷 Create new style (from the selected type) 새 스타일 만들기(선택한 문자에서) Create new style from the selected layer 선택한 레이어로 새 스타일 만들기 Create new tool preset 새 도구 사전 설정 만들기 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 00d793cbf5..908f761495 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -942,6 +942,9 @@ Create new pattern from the selection Nieuw patroon maken van de selectie Create new shape from the current path Nieuwe vorm maken van het huidige pad Create new snapshot Nieuwe momentopname maken + From: Van: + Full Document Volledig document + Merged Layers Samengevoegde lagen Create new style (from the selected type) Nieuwe stijl maken (van de geselecteerde tekst) Create new style from the selected layer Nieuwe stijl maken van de geselecteerde laag Create new tool preset Nieuwe gereedschapsvoorinstelling maken diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index d6018ec9a3..1681a8156c 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -958,6 +958,9 @@ Create new pattern from the selection Utwórz nowy wzór z zaznaczenia Create new shape from the current path Utwórz nowy kształt z bieżącej ścieżki Create new snapshot Utwórz nową migawkę + From: Z: + Full Document Cały dokument + Merged Layers Scalone warstwy Create new style (from the selected type) Utwórz nowy styl (z zaznaczonego tekstu) Create new style from the selected layer Utwórz nowy styl z zaznaczonej warstwy Create new tool preset Utwórz nowe ustawienie wstępne narzędzia diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 7373a3a8a3..1896c8fddb 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -944,6 +944,9 @@ Create new pattern from the selection Criar novo padrão a partir da seleção Create new shape from the current path Criar nova forma a partir do demarcador atual Create new snapshot Criar novo instantâneo + From: De: + Full Document Documento inteiro + Merged Layers Camadas mescladas Create new style (from the selected type) Criar novo estilo (a partir do texto selecionado) Create new style from the selected layer Criar novo estilo a partir da camada selecionada Create new tool preset Criar nova predefinição de ferramenta diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 25e240377b..4a0fcb8530 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -2799,6 +2799,9 @@ fontWeight Italic Курсив Create new document from current state Создать новый документ из текущего состояния Create new fill or adjustment layer Создать новый слой-заливку или корректирующий слой Create new snapshot Создать новый снимок + From: Из: + Full Document Весь документ + Merged Layers Объединённые слои Delete Cropped Pixels Удалить отсечённые пикселы Delete current state Удалить текущее состояние Delete layer Удалить слой diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index a28efb4a5f..c583cc9d99 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -2656,6 +2656,9 @@ fontWeight Italic Курсивний Create new document from current state Створити новий документ із поточного стану Create new fill or adjustment layer Створити новий шар заливки або корекції Create new snapshot Створити новий знімок стану + From: З: + Full Document Увесь документ + Merged Layers Об'єднані шари Delete Cropped Pixels Видаляти обрізані пікселі Delete current state Видалити поточний стан diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 5c7caba0f8..6515a4aba7 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -962,6 +962,10 @@ Create new pattern from the selection 从选区创建图案 Create new shape from the current path 从当前路径创建形状 Create new snapshot 创建快照 + From: 自: + Full Document 完整文档 + Merged Layers 合并的图层 + New Snapshot 新建快照 Create new tool preset 创建工具预设 Crop Factor 裁切系数 Ctrl Ctrl diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 08a7c3bee8..752c3ca44b 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -965,6 +965,10 @@ Create new pattern from the selection 從選取範圍建立新圖樣 Create new shape from the current path 從目前路徑建立新形狀 Create new snapshot 建立新快照 + From: 自: + Full Document 完整文件 + Merged Layers 合併的圖層 + New Snapshot 新增快照 Create new tool preset 建立新工具預設集 Crop Factor 裁切係數 Ctrl Ctrl diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 4beb2a8c35..496c68588c 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -161,6 +161,7 @@ mod sizing; pub mod slice_ui; pub mod smart_ui; pub mod snap_ui; +pub mod snapshot_dialog; pub(crate) mod solid_fill_ui; pub mod state; pub mod stroke_constraint; diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index e85f5aa8db..5c0992bfa5 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -2822,24 +2822,9 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) { empty(ui, tl!("No document")); return; }; - let doc = st.doc.clone(); let entries = st.history.entries(); let current = entries.len() - 1; let redo: Vec = st.history.redo_labels().map(str::to_string).collect(); - // Snapshot row (Photoshop shows the document's opening state with a thumbnail). - { - let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width(), 38.0), Sense::hover()); - let thumb = Rect::from_min_size(pos2(rect.left() + 28.0, rect.center().y - 14.0), vec2(28.0, 28.0)); - let ctx = ui.ctx().clone(); - if let Some(layer) = doc.layers.first() { - widgets::checker(ui.painter(), thumb, 4.0); - let tex = app.layer_thumb(&ctx, &doc, layer); - ui.painter().image(tex, thumb, Rect::from_min_max(egui::Pos2::ZERO, pos2(1.0, 1.0)), Color32::WHITE); - } - ui.painter().rect_stroke(thumb, 0.0, Stroke::new(1.0, t.separator), StrokeKind::Outside); - ui.painter().text(pos2(thumb.right() + 8.0, rect.center().y), Align2::LEFT_CENTER, &doc.name, egui::FontId::proportional(12.0), t.text); - ui.painter().line_segment([rect.left_bottom(), rect.right_bottom()], Stroke::new(1.0, t.separator)); - } let mut snap_cmd = None; let mut target: Option = None; let all = entries.iter().map(|e| (e.clone(), false)).chain(redo.iter().map(|e| (e.clone(), true))); @@ -2880,6 +2865,7 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) { } }); let mut footer_cmd: Option<&str> = None; + let mut snapshot_dialog = false; if t.pro { let can_delete = app.session.is_enabled("history.deleteState"); let can_new = app.session.is_enabled("history.newDocument"); @@ -2888,8 +2874,13 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) { footer_cmd = Some("history.deleteState"); } let can_snap = app.session.is_enabled("history.newSnapshot"); + // ⌥-click opens New Snapshot (name, From) instead, as in Photoshop. if ui.add_enabled_ui(can_snap, |ui| icons::button(ui, "scan", 26.0, false, tl!("Create new snapshot"))).inner.clicked() { - footer_cmd = Some("history.newSnapshot"); + if ui.input(|i| i.modifiers.alt) { + snapshot_dialog = true; + } else { + footer_cmd = Some("history.newSnapshot"); + } } if ui.add_enabled_ui(can_new, |ui| icons::button(ui, "file-plus", 26.0, false, tl!("Create new document from current state"))).inner.clicked() { footer_cmd = Some("history.newDocument"); @@ -2898,6 +2889,9 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) { } // An open Free Transform owns Undo (transform_tool::intercept): stepping the document's history under // its box would leave it transforming pixels that changed. + if snapshot_dialog { + crate::snapshot_dialog::open(app); + } // Selecting a snapshot changes the document, so it waits for an open transform like the rows. let snap_cmd = snap_cmd.filter(|(cmd, _)| *cmd != "history.selectSnapshot" || app.ui.transform.is_none()); if let Some((cmd, p)) = footer_cmd.map(|c| (c, json!({}))).filter(|_| app.ui.transform.is_none()).or(snap_cmd) @@ -4209,7 +4203,7 @@ mod history_transform_tests { let steps = h.state().session.active().unwrap().history.entries().len(); click(&mut h, b[1].0.center()); let st = h.state().session.active().unwrap(); - assert_eq!(st.snapshots.len(), 1, "the camera takes a snapshot"); + assert_eq!(st.snapshots.len(), 2, "the camera takes a snapshot, after the first one"); assert_eq!(st.history.entries().len(), steps, "which is not a history state"); let docs = h.state().session.documents().len(); click(&mut h, b[2].0.center()); @@ -4229,7 +4223,7 @@ mod history_transform_tests { mod snapshot_row_tests { use egui::vec2; use egui_kittest::Harness; - use egui_kittest::kittest::Queryable; + use egui_kittest::kittest::{NodeT, Queryable}; use serde_json::json; use super::*; @@ -4238,8 +4232,9 @@ mod snapshot_row_tests { h.state().session.active().unwrap().doc.layers.last().unwrap().surface().unwrap().rgba(1, 1) } + /// The names of the snapshots taken after the first one (the document as opened). fn snapshot_names(h: &Harness<'static, PhotocraftApp>) -> Vec { - h.state().session.active().unwrap().snapshots.iter().map(|s| s.name.clone()).collect() + h.state().session.active().unwrap().snapshots.iter().skip(1).map(|s| s.name.clone()).collect() } /// Snapshot rows (#2966) sit under the opening row: clicking one returns to it as a new @@ -4320,6 +4315,78 @@ mod snapshot_row_tests { assert!(buttons.iter().all(|b| view.contains_rect(*b)), "footer in view: {buttons:?} in {view:?}"); } + /// The top row is the first snapshot, the document as opened: clicking it brings that back + /// (the Discord report on #2966: "History original file click does not work"). + #[test] + fn the_top_row_returns_to_the_document_as_opened() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 200, "height": 150})).unwrap(); + let opened = app.session.active().unwrap().doc.layers[0].surface().unwrap().rgba(1, 1); + app.run("edit.fill", json!({"color": "#ff0000"})).unwrap(); + let name = app.session.active().unwrap().doc.name.clone(); + let mut h = Harness::builder().with_size(vec2(300.0, 400.0)).build_ui_state(|ui, app: &mut PhotocraftApp| history(app, ui), app); + h.run_steps(3); + h.get_by_label(&name).click(); + h.run_steps(2); + let st = h.state().session.active().unwrap(); + assert_eq!(st.doc.layers[0].surface().unwrap().rgba(1, 1), opened); + assert_eq!(st.history.entries().last(), Some(&name)); + } + + /// ⌥-click on the camera opens New Snapshot (#2966): the name, selected so typing replaces + /// it, and From (Full Document, Merged Layers, Current Layer); OK takes the snapshot. + #[test] + fn alt_click_on_the_camera_opens_new_snapshot() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 200, "height": 150})).unwrap(); + app.run("layer.new.layer", json!({})).unwrap(); + app.run("edit.fill", json!({"color": "#ff0000"})).unwrap(); + let mut h = Harness::builder().with_size(vec2(900.0, 700.0)).build_ui_state( + |ui, app: &mut PhotocraftApp| { + let ctx = ui.ctx().clone(); + if !ctx.fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { + return; + } + history(app, ui); + crate::dialogs::show(app, &ctx); + }, + app, + ); + PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::ProMedium); + h.state_mut().ui.theme = crate::theme::ThemeKind::ProMedium; + h.run_steps(4); + let mut buttons: Vec = h + .ctx + .viewport(|v| v.prev_pass.widgets.layers().flat_map(|(_, w)| w.iter()).filter(|w| w.rect.size() == vec2(26.0, 26.0)).map(|w| w.rect).collect()); + buttons.sort_by(|a, b| b.center().x.total_cmp(&a.center().x)); + let camera = buttons[1].center(); + let alt = egui::Modifiers::ALT; + h.event(egui::Event::ModifiersChanged(alt)); + h.event(egui::Event::PointerMoved(camera)); + h.run_steps(1); + for pressed in [true, false] { + h.event(egui::Event::PointerButton { pos: camera, button: egui::PointerButton::Primary, pressed, modifiers: alt }); + h.run_steps(1); + } + h.event(egui::Event::ModifiersChanged(egui::Modifiers::NONE)); + h.run_steps(3); + assert_eq!(h.state().session.active().unwrap().snapshots.len(), 1, "⌥-click opens the dialog instead"); + assert!(h.state().ui.dialogs.last().is_some_and(|d| crate::snapshot_dialog::owns(&d.fields))); + h.get_by_role(egui::accesskit::Role::TextInput).type_text("Red layer only"); + h.run_steps(1); + h.get_all_by_role(egui::accesskit::Role::ComboBox).find(|n| n.accesskit_node().value().as_deref() == Some("Full Document")).unwrap().click(); + h.run_steps(3); + h.get_by_label("Current Layer").click(); + h.run_steps(3); + h.get_by_label("OK").click(); + h.run_steps(3); + let st = h.state().session.active().unwrap(); + let snap = st.snapshots.last().unwrap(); + assert_eq!(snap.name, "Red layer only"); + assert_eq!(snap.doc.layers.len(), 1, "only the current layer"); + assert!(h.state().ui.dialogs.is_empty()); + } + /// Renaming belongs to one document: snapshot ids restart in each, so switching tabs must not /// carry the edit over to the other document's snapshot with the same id. #[test] diff --git a/crates/ui-egui/src/snapshot_dialog.rs b/crates/ui-egui/src/snapshot_dialog.rs new file mode 100644 index 0000000000..3ee7553b84 --- /dev/null +++ b/crates/ui-egui/src/snapshot_dialog.rs @@ -0,0 +1,71 @@ +//! History › New Snapshot (⌥-click the History panel's camera button, #2966): Photoshop's dialog +//! for `history.newSnapshot`, with the snapshot's Name and what it is taken From (the full +//! document, its layers merged, or only the current layer). The command stays directly callable +//! with the same params by agents and Actions. + +use egui::{Align2, Sense, pos2, vec2}; +use serde_json::{Map, Value, json}; + +use crate::PhotocraftApp; +use crate::theme::Tokens; + +pub const COMMAND: &str = "history.newSnapshot"; +const MARK: &str = "__newSnapshot"; + +pub fn owns(fields: &Map) -> bool { + fields.contains_key(MARK) +} + +/// Open the dialog on the active document, suggesting the name the camera button would give. +pub fn open(app: &mut PhotocraftApp) -> Option { + let name = photocraft_engine::history_cmds::next_snapshot_name(app.session.active()?); + let mut f = Map::new(); + f.insert(MARK.into(), json!(true)); + f.insert("__command".into(), json!(COMMAND)); + f.insert("__label".into(), json!("New Snapshot")); + f.insert("name".into(), json!(name)); + f.insert("from".into(), json!("fullDocument")); + Some(app.ui.open_dialog(crate::state::DialogKind::Command, f)) +} + +pub fn confirm(app: &mut PhotocraftApp, f: &Map) -> Result { + app.run(COMMAND, json!({"name": f.get("name"), "from": f.get("from")})) +} + +fn label(ui: &mut egui::Ui, text: &str) { + let t = Tokens::get(ui.ctx()); + let (r, _) = ui.allocate_exact_size(vec2(64.0, 22.0), Sense::hover()); + ui.painter().text(pos2(r.right() - 6.0, r.center().y), Align2::RIGHT_CENTER, text, egui::FontId::proportional(12.0), t.text_dim); +} + +pub fn body(ui: &mut egui::Ui, f: &mut Map) { + ui.spacing_mut().item_spacing.y = 6.0; + ui.horizontal(|ui| { + label(ui, tl!("Name:")); + let mut name = f.get("name").and_then(Value::as_str).unwrap_or_default().to_string(); + let r = ui.add(egui::TextEdit::singleline(&mut name).desired_width(260.0)); + // Opens on the name, selected, so typing replaces it (Photoshop). + if !ui.is_sizing_pass() && !f.contains_key("__named") { + r.request_focus(); + if let Some(mut state) = egui::TextEdit::load_state(ui.ctx(), r.id) { + let all = egui::text::CCursorRange::two(egui::text::CCursor::new(0), egui::text::CCursor::new(name.chars().count())); + state.cursor.set_char_range(Some(all)); + state.store(ui.ctx(), r.id); + } + f.insert("__named".into(), json!(true)); + } + f.insert("name".into(), json!(name)); + }); + ui.horizontal(|ui| { + label(ui, tl!("From:")); + let mut from = f.get("from").and_then(Value::as_str).unwrap_or("fullDocument").to_string(); + let opts = [ + ("fullDocument".to_string(), tl!("Full Document")), + ("mergedLayers".to_string(), tl!("Merged Layers")), + ("currentLayer".to_string(), tl!("Current Layer")), + ]; + if crate::widgets::dropdown(ui, "new-snapshot-from", &mut from, &opts, 170.0) { + f.insert("from".into(), json!(from)); + } + }); +} diff --git a/docs/control-protocol.md b/docs/control-protocol.md index db2251dfdc..0ebf13f340 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -101,7 +101,7 @@ store expose and persist the same setting; scripts keep using canonical command | `layer.newAdjustmentLayer.hueSaturation` | `{"hue":30,"saturation":10}` | | `paint.stroke` | `{"points":[[x,y,pressure],…],"size":20,"color":"#ff0000"}` | | `select.rect` | `{"x":0,"y":0,"width":100,"height":50,"mode":"add","ellipse":false}` | -| `document.inspect` | `{}`: layer tree, history, snapshots (`[{id, name}]`, for `history.selectSnapshot`), selection bounds | +| `document.inspect` | `{}`: layer tree, history, snapshots (`[{id, name}]`, for `history.selectSnapshot`; id 0 is the document as opened), selection bounds | | `document.pixel` | `{"x":10,"y":10}`: composite RGBA | | `document.presets.list` | `{}` → `{presets:[{name,settings}]}`: saved New Document configurations | | `document.presets.save` | `{"name":"Product square","settings":{"width":1600,"height":1600,"background":"transparent"}}`: save a snapshot; names are trimmed, 1–255 characters, and ASCII case-insensitive duplicates are rejected | diff --git a/docs/ui-parity.md b/docs/ui-parity.md index af0992b6af..544cf381b4 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -198,7 +198,7 @@ Paragraph; the rest open as in-app floating windows. | Command palette with recents | done | UI-217-7 | | Every preference takes effect | partial | 46 of 149 do nothing (scorecard) | | UI scale presets | missing | UI-217-9, #2492 | -| History snapshots: camera button, snapshot rows (click returns, rename, delete), `history.*Snapshot` commands | partial | `history_cmds.rs`, `snapshot_rows` in `panels.rs`; New Snapshot dialog, first snapshot and History Options to come (#2966) | +| History snapshots: camera button, New Snapshot dialog (⌥-click: Name, From), the first snapshot (the document as opened), snapshot rows (click returns, rename, delete), `history.*Snapshot` commands | partial | `history_cmds.rs`, `snapshot_rows` in `panels.rs`, `snapshot_dialog.rs`; the snapshot History Options and History Brush sources to come (#2966) | | Themes: Photoshop's four greys | partial | five themes; #2661 | | Document tabs: overflow, context menu, reorder | done | UI-217-6; middle-click close #2570 | | Layers panel: wheel steps blend modes, drop on New/Trash | partial | UI-217-14 | @@ -211,3 +211,4 @@ Paragraph; the rest open as in-app floating windows. | 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 | | 2026-10-11 | minor | Flick panning done: releasing a moving Hand drag (tool, Space or middle button) glides and decays, gated by Enable Flick Panning | | 2026-10-11 | minor | History snapshots: the camera button takes one, snapshot rows return to it as a new state, rename and delete it (#2966) | +| 2026-10-11 | minor | History snapshots: the New Snapshot dialog (⌥-click the camera), and the first snapshot of the document as opened as the panel's top row (#2966) | From 0fcce4a1486feba87d3b5550856aacc9d6863e44 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Mon, 12 Oct 2026 09:12:47 +0200 Subject: [PATCH 027/649] fmt Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/channel_cmds.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/channel_cmds.rs b/crates/engine/src/channel_cmds.rs index ca28a449ed..8c6cae1f35 100644 --- a/crates/engine/src/channel_cmds.rs +++ b/crates/engine/src/channel_cmds.rs @@ -572,7 +572,10 @@ pub(crate) fn read_target_surface<'a>(doc: &'a Document, layer: Option, } Target::FilterMask => { let id = layer.ok_or_else(|| EngineError::Other("no active layer".into()))?; - doc.layer(id).and_then(|l| crate::mask_view_cmds::viewed_mask(l, true)).map(|m| &m.surface).ok_or_else(|| EngineError::Other("the layer has no filter mask".into())) + doc.layer(id) + .and_then(|l| crate::mask_view_cmds::viewed_mask(l, true)) + .map(|m| &m.surface) + .ok_or_else(|| EngineError::Other("the layer has no filter mask".into())) } } } From 42519bb32dd5803b6174fb5d3bb7e09643e8d190 Mon Sep 17 00:00:00 2001 From: Erica Franco Date: Mon, 12 Oct 2026 04:50:56 -0600 Subject: [PATCH 028/649] Integrations: wire Allow Agent Control and Control Port (#204) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both fields were in Preferences › Integrations and in prefs::HIDDEN_UNTIL_IMPLEMENTED: nothing read them, so the only way to open the control channel was --control (or PHOTOCRAFT_CONTROL_PORT). They now do what their doc comments describe. Control Port, when it is not 0, is the port this launch listens on; --control still wins over it. Allow Agent Control off refuses both, and when --control asked for a port it says so on stderr instead of dropping the flag silently — an ignored --control with no message is the shape #2449 was about. A port outside 1..=65535, which only a hand-edited file can hold, is refused and named the same way. integrations() reads the saved preferences before the window opens, the way custom_titlebar() already does for System Title Bar; a missing or unreadable file keeps the defaults. The defaults are unchanged (allow on, port 0), so a launch that touches neither preference behaves exactly as before. Checked against a release build, each case with its own PHOTOCRAFT_CONFIG_DIR: preferences --control listens on (none) - nothing controlPort 7878 - 7878 controlPort 7878 9000 9000 allowAgentControl false 9000 nothing, with the warning allowAgentControl false, port 7878 - nothing controlPort 70000 - nothing, with the warning Two tests cover the decision table and the file reading (absent, unparseable, valid). docs/scorecard.md regenerated: settings that do nothing, 30 -> 28. --- apps/photocraft/src/main.rs | 81 +++++++++++++++++++++++++++++++++++++ crates/engine/src/prefs.rs | 2 - docs/scorecard.md | 6 +-- 3 files changed, 84 insertions(+), 5 deletions(-) diff --git a/apps/photocraft/src/main.rs b/apps/photocraft/src/main.rs index aee9eabca1..9aedda2a62 100644 --- a/apps/photocraft/src/main.rs +++ b/apps/photocraft/src/main.rs @@ -69,6 +69,36 @@ fn custom_titlebar(prefs_file: Option<&std::path::Path>) -> bool { CUSTOM_TITLEBAR && !prefs.interface.system_title_bar } +/// Preferences › Integrations, read before the window opens the way [`custom_titlebar`] is: +/// whether agents may drive this launch at all, and the port to listen on when no `--control` +/// was given (0 = only with `--control`). A missing or unreadable file keeps the defaults. +fn integrations(prefs_file: Option<&std::path::Path>) -> photocraft_engine::prefs::Integrations { + let prefs: photocraft_engine::prefs::Preferences = + prefs_file.and_then(|p| std::fs::read_to_string(p).ok()).and_then(|t| serde_json::from_str(&t).ok()).unwrap_or_default(); + prefs.integrations +} + +/// The control port this launch listens on, and the warning to print when a request was refused. +/// `--control` (or `PHOTOCRAFT_CONTROL_PORT`) wins over the preference; Allow Agent Control off +/// refuses both, and says so rather than ignoring the flag silently. A preferred port outside +/// 1..=65535 is refused the same way. +fn control_port_for(cli: Option, prefs: &photocraft_engine::prefs::Integrations) -> (Option, Option) { + if !prefs.allow_agent_control { + let warning = cli.map(|p| format!("photocraft: Preferences › Integrations › Allow Agent Control is off: not listening on port {p}\n")); + return (None, warning); + } + if let Some(port) = cli { + return (Some(port), None); + } + match prefs.control_port { + 0 => (None, None), + p => match u16::try_from(p).ok().filter(|p| *p != 0) { + Some(port) => (Some(port), None), + None => (None, Some(format!("photocraft: Preferences › Integrations › Control Port {p} is not a usable port: not listening\n"))), + }, + } +} + /// The main window: 1440 × 900 (shrunk to fit the monitor, and maximized on the first frame /// when it still doesn't fit, `work_area::fit_window`), centred on the main monitor. Without /// `centered`, Windows cascades each new window from the top-left corner, so it opened at a @@ -256,6 +286,10 @@ fn main() -> eframe::Result { std::process::exit(1); } + let (control_port, control_pref_warning) = control_port_for(control_port, &integrations(services::prefs_file().as_deref())); + if let Some(warning) = &control_pref_warning { + eprint!("{warning}"); + } let control = if let Some(port) = control_port { let (supplied, token_file) = photocraft_automation::security::token_inputs(control_token, control_token_file); let token = match photocraft_automation::security::server_token(supplied.as_deref(), token_file.as_deref()) { @@ -645,6 +679,53 @@ mod tests { let _ = std::fs::remove_dir_all(&dir); } + #[test] + fn integrations_preferences_decide_the_control_port() { + use photocraft_engine::prefs::Integrations; + let off = Integrations { allow_agent_control: false, control_port: 0 }; + let on = Integrations { allow_agent_control: true, control_port: 0 }; + let preferred = Integrations { allow_agent_control: true, control_port: 7878 }; + + // Nothing asked for, nothing listening. + assert_eq!(super::control_port_for(None, &on), (None, None)); + // --control wins over the preference. + assert_eq!(super::control_port_for(Some(9000), &preferred), (Some(9000), None)); + // The preference opens the port when --control is absent. + assert_eq!(super::control_port_for(None, &preferred), (Some(7878), None)); + + // Allow Agent Control off refuses both, and says so when --control asked for one + // rather than ignoring the flag. + assert_eq!(super::control_port_for(None, &off), (None, None)); + let (port, warning) = super::control_port_for(Some(9000), &off); + assert_eq!(port, None); + assert!(warning.is_some_and(|w| w.contains("Allow Agent Control") && w.contains("9000")), "the refusal names the port"); + let off_with_port = Integrations { allow_agent_control: false, control_port: 7878 }; + assert_eq!(super::control_port_for(None, &off_with_port), (None, None), "off beats a preferred port"); + + // A port a hand-edited file could hold, outside 1..=65535, is refused and named. + let huge = Integrations { allow_agent_control: true, control_port: 70_000 }; + let (port, warning) = super::control_port_for(None, &huge); + assert_eq!(port, None); + assert!(warning.is_some_and(|w| w.contains("70000")), "the refusal names the value"); + } + + #[test] + fn integrations_fall_back_to_the_defaults_without_a_readable_file() { + let dir = std::env::temp_dir().join(format!("pc-integrations-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let file = dir.join("prefs.json"); + let default = photocraft_engine::prefs::Integrations::default(); + + assert_eq!(super::integrations(None), default, "no preferences file"); + std::fs::write(&file, "not json").unwrap(); + assert_eq!(super::integrations(Some(&file)), default, "an unreadable file"); + std::fs::write(&file, r#"{"integrations":{"allowAgentControl":false,"controlPort":7878}}"#).unwrap(); + let read = super::integrations(Some(&file)); + assert!(!read.allow_agent_control); + assert_eq!(read.control_port, 7878); + let _ = std::fs::remove_dir_all(&dir); + } + /// X11 startup notification and docks match a window to its launcher by `StartupWMClass`, /// so it has to be the class the window carries: the app id, on Wayland and X11 alike. #[test] diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index 93a52d2d10..e7ded41e12 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -1058,8 +1058,6 @@ pub const HIDDEN_UNTIL_IMPLEMENTED: &[&str] = &[ "rawDefaults.applyAutoTone", // Agent access is governed by the launch flags (`--control`, the automation roots), not // by these yet. - "integrations.allowAgentControl", - "integrations.controlPort", ]; /// Is the preference at `path` (`"section.key"`) hidden from the Preferences dialog? diff --git a/docs/scorecard.md b/docs/scorecard.md index 80cb52faae..71c9799a76 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -9,7 +9,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) | 6 | 13 | 8 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 | | [Tools](#tools) | 28 | 14 | 1 | | -| [Workspace and UI](#workspace-and-ui) | 13 | 5 | 5 | settings that do nothing: 30 of 155 (target 0) | +| [Workspace and UI](#workspace-and-ui) | 13 | 5 | 5 | settings that do nothing: 28 of 155 (target 0) | | [Type](#type) | 4 | 2 | 3 | | | [Automation](#automation) | 4 | 2 | 5 | 631 of 631 menu items live (100.0%) | | [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present | @@ -176,9 +176,9 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t ## Workspace and UI -**Settings that do nothing: 30 of 155** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. +**Settings that do nothing: 28 of 155** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. -Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_collapse_icon_panels`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `workspace.enable_narrow_options_bar`, `file_handling.save_in_background`, `file_handling.maximize_psd_compatibility`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.missing_glyph_protection`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`. +Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_collapse_icon_panels`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `workspace.enable_narrow_options_bar`, `file_handling.save_in_background`, `file_handling.maximize_psd_compatibility`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.missing_glyph_protection`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`. | Id | Target | Status | Issue | Note | |---|---|---|---|---| From ab0b4080f557f1476db11b7a320da86905e49a69 Mon Sep 17 00:00:00 2001 From: itsF4LCON <107556180+itsF4LCON@users.noreply.github.com> Date: Mon, 12 Oct 2026 14:01:20 +0200 Subject: [PATCH 029/649] CLI orientation test: the first snapshot is named after the document The .pcraft round trip compares document.inspect of a.pcraft and b.pcraft with the per-file fields removed. The first snapshot (#2966) is named after the document, so it differs in the same way as the name: check each one's name, then compare the rest. --- apps/photocraft-cli/tests/orientation.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/photocraft-cli/tests/orientation.rs b/apps/photocraft-cli/tests/orientation.rs index 101195581f..3895df367a 100644 --- a/apps/photocraft-cli/tests/orientation.rs +++ b/apps/photocraft-cli/tests/orientation.rs @@ -125,7 +125,8 @@ fn orientation_6_jpeg_converts_upright_and_rotates_back() { let (a, b) = (d.join("a.pcraft"), d.join("b.pcraft")); ok(bin().arg("convert").arg(&jpg).arg(&a)); ok(bin().arg("convert").arg(&a).arg(&b)); - // Everything but the file's own path and saved document name must match. + // Everything but the file's own path and saved document name (which the first snapshot is + // named after) must match. let info = |p: &Path| { let mut v = serde_json::from_str::(&ok(bin().arg("info").arg(p))).unwrap(); v.as_object_mut().unwrap().remove("file"); @@ -136,8 +137,12 @@ fn orientation_6_jpeg_converts_upright_and_rotates_back() { assert_eq!((ia["width"].as_u64(), ia["height"].as_u64()), (Some(16), Some(32))); assert_eq!(ia["name"], "a.pcraft"); assert_eq!(ib["name"], "b.pcraft"); - ia.as_object_mut().unwrap().remove("name"); - ib.as_object_mut().unwrap().remove("name"); + assert_eq!(ia["snapshots"][0]["name"], "a.pcraft"); + assert_eq!(ib["snapshots"][0]["name"], "b.pcraft"); + for v in [&mut ia, &mut ib] { + v.as_object_mut().unwrap().remove("name"); + v["snapshots"][0].as_object_mut().unwrap().remove("name"); + } assert_eq!(ia, ib); let (pa, pb) = (d.join("a.png"), d.join("b.png")); ok(bin().arg("convert").arg(&a).arg(&pa)); From c7f4596a741495714cc7f8e404ae4e3ea44fd676 Mon Sep 17 00:00:00 2001 From: DeWarePeb <68034923+DeWarePeb@users.noreply.github.com> Date: Mon, 12 Oct 2026 15:26:52 +0200 Subject: [PATCH 030/649] Options bar: the same tool options in every theme (#4178) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switching from Pro (Dark) or Pro (Medium Gray) to Adwaita, Studio, Classic, Solarized or Breeze removed tool options. With the Crop tool the bar shrank to the sentence "Drag a crop box · drag inside to move · …" where the Pro themes show the ratio preset, the W/H fields, Clear, Straighten, the overlay and shield menus, Delete Cropped Pixels and the commit/cancel buttons. `panels::options_bar` matched the tool twice: `Tool::Crop if t.pro` drew Photoshop's options and a guard-less `Tool::Crop` arm drew a hint for every other theme. The Marquee (4), Lasso (3), Paint Bucket, Crop, Perspective Crop and Move tools all had such a pair. Drop the guards and the hint arms, as #1275, #1387 and #3601 did for Auto-Select, Type and Gradient. Sizes and colours still come from `theme::Tokens`. The crop test that skipped the non-Pro themes now covers them too. Co-Authored-By: Claude Fable 5.1 --- crates/ui-egui/src/panels.rs | 74 +++++------------------------------- 1 file changed, 9 insertions(+), 65 deletions(-) diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 0f6a1b83bf..e4be7928eb 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -1040,7 +1040,10 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { widgets::vline(ui, 22.0); widgets::checkbox(ui, &mut b.mixer.sample_all_layers, tl!("Sample All Layers")); } - Tool::RectMarquee | Tool::EllipseMarquee | Tool::SingleRowMarquee | Tool::SingleColumnMarquee if t.pro => { + // Every theme gets Photoshop's tool options (#4178): outside the Pro themes the + // Marquee, Lasso, Paint Bucket, Crop, Perspective Crop and Move tools used to + // show a one-line hint instead, so switching theme "removed" their options. + Tool::RectMarquee | Tool::EllipseMarquee | Tool::SingleRowMarquee | Tool::SingleColumnMarquee => { ui.spacing_mut().item_spacing.x = 2.0; for (i, (icon, tip)) in [ ("square", tl!("New selection").to_string()), @@ -1093,7 +1096,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({})); } } - Tool::Lasso | Tool::PolygonLasso | Tool::MagneticLasso if t.pro => { + Tool::Lasso | Tool::PolygonLasso | Tool::MagneticLasso => { selection_mode_buttons(app, ui); widgets::vline(ui, 22.0); opt_label(ui, tl!("Feather")); @@ -1157,7 +1160,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({})); } } - Tool::PaintBucket if t.pro => { + Tool::PaintBucket => { opt_label(ui, tl!("Fill")); let mut src = u8::from(app.ui.tool_options.bucket_fill_pattern); if widgets::dropdown(ui, "bucket-src", &mut src, &[(0u8, tl!("Foreground")), (1, tl!("Pattern"))], 100.0) { @@ -1209,8 +1212,8 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { // Live mode: the options also change a selected gradient fill layer. crate::gradient_ui::options_changed(app, &before); } - Tool::PerspectiveCrop if t.pro => crate::perspective_crop_ui::options_bar(app, ui), - Tool::Crop if t.pro => { + Tool::PerspectiveCrop => crate::perspective_crop_ui::options_bar(app, ui), + Tool::Crop => { let before_ratio = crate::crop_ui::preset_ratio(app); let doc_size = app.session.active().map_or((0.0, 0.0), |s| (f64::from(s.doc.size.width), f64::from(s.doc.size.height))); // Ratios, sizes, saved presets, New / Delete Crop Preset… (#2443, #1919). @@ -1269,7 +1272,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { } // Every theme gets the font, style and size controls (#1387), as with Auto-Select (#1275). Tool::Type | Tool::VerticalType | Tool::HorizontalTypeMask | Tool::VerticalTypeMask => crate::type_tool::options_bar(app, ui), - Tool::Move if t.pro => { + Tool::Move => { let o = &mut app.ui.tool_options; widgets::checkbox(ui, &mut o.move_auto_select, tl!("Auto-Select:")); widgets::dropdown( @@ -1311,29 +1314,6 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { section(ui, tl!("Distribute"), "layer.distribute."); }); } - Tool::RectMarquee | Tool::EllipseMarquee => hint( - ui, - &format!( - "Drag to select · {} add · {} subtract · {} intersect · click to deselect", - crate::shortcuts::pretty("Shift"), - crate::shortcuts::pretty("Alt"), - crate::shortcuts::pretty("Shift+Alt") - ), - ), - Tool::SingleRowMarquee | Tool::SingleColumnMarquee => hint( - ui, - &format!( - "Click to select a one-pixel line · {} add · {} subtract · {} intersect", - crate::shortcuts::pretty("Shift"), - crate::shortcuts::pretty("Alt"), - crate::shortcuts::pretty("Shift+Alt") - ), - ), - Tool::Move => { - // The Studio themes keep Photoshop's Auto-Select toggle too (#1275). - widgets::checkbox(ui, &mut app.ui.tool_options.move_auto_select, tl!("Auto-Select:")); - hint(ui, tl!("Drag to move the active layer")); - } Tool::Eyedropper => crate::eyedropper_ui::options(app, ui), Tool::Zoom => { widgets::checkbox(ui, &mut app.ui.tool_options.zoom_scrubby, tl!("Scrubby Zoom")); @@ -1394,39 +1374,6 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { app.ui.views[i].fit_pending = false; } } - Tool::Lasso | Tool::PolygonLasso => hint( - ui, - &crate::i18n::fmt( - tl!("Drag or click polygon points · hold Alt during lasso for straight segments · {add} add · {sub} before drawing subtracts"), - &[("add", &crate::shortcuts::pretty("Shift")), ("sub", &crate::shortcuts::pretty("Alt"))], - ), - ), - Tool::MagneticLasso => hint( - ui, - &crate::i18n::fmt( - tl!("Click, then move along an edge · click to fasten a point · {alt}-click for a straight segment · double-click to close"), - &[("alt", &crate::shortcuts::pretty("Alt"))], - ), - ), - Tool::Crop => hint( - ui, - &crate::i18n::fmt( - tl!("Drag a crop box · drag inside to move · edges resize ({ratio} ratio, {centre} centre) · Space moves while drawing · arrows nudge · X swaps orientation · {commit} commits · Esc cancels"), - &[ - ("ratio", &crate::shortcuts::pretty("Shift")), - ("centre", &crate::shortcuts::pretty("Alt")), - ("commit", &crate::shortcuts::pretty("Enter")), - ], - ), - ), - Tool::PerspectiveCrop => hint( - ui, - &crate::i18n::fmt( - tl!("Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels"), - &[("commit", &crate::shortcuts::pretty("Enter"))], - ), - ), - Tool::PaintBucket => hint(ui, tl!("Click to fill similar colours")), // Retouching and smart-selection tools draw their bar in `retouch_ui::options_bar`. _ => {} } @@ -5521,9 +5468,6 @@ mod compact_visual_regressions { crate::theme::install_fonts(&ctx); crate::theme::apply(&ctx, kind); let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); - if !Tokens::get(&ctx).pro { - continue; - } app.ui.tool = Tool::Crop; app.ui.tool_options.crop_ratio = mode.into(); let screen = Rect::from_min_size(egui::Pos2::ZERO, vec2(1600.0, 120.0)); From f86356e61c4e39a089da77fc74a48a4b7acb855d Mon Sep 17 00:00:00 2001 From: DeWarePeb <68034923+DeWarePeb@users.noreply.github.com> Date: Mon, 12 Oct 2026 15:27:28 +0200 Subject: [PATCH 031/649] Options bar: rustfmt reindent after removing the hint strings Formatting only: `git diff -w` shows nothing but rustfmt re-wrapping one `if` condition. The hint arms held string literals longer than `max_width`, which made rustfmt leave the whole options-bar closure chain unformatted; with them gone, `cargo fmt` indents the chain as it always wanted to, and CI's `cargo fmt --check` requires it. Co-Authored-By: Claude Fable 5.1 --- crates/ui-egui/src/panels.rs | 986 ++++++++++++++++++----------------- 1 file changed, 494 insertions(+), 492 deletions(-) diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index e4be7928eb..ca1573dba2 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -872,520 +872,522 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { .show(ui, |ui| { ui.style_mut().spacing.scroll = egui::style::ScrollStyle { bar_width: 4.0, ..egui::style::ScrollStyle::floating() }; egui::ScrollArea::horizontal().id_salt("tool-options").auto_shrink([false, false]).show(ui, |ui| { - // Font ink can extend beyond its advance width at fractional positions. - // Include its gutter in the container layout, including right-aligned actions. - egui::Frame::NONE.inner_margin(egui::Margin { right: 2, ..Default::default() }).show(ui, |ui| { - crate::direction::horizontal_centered(ui, |ui| { - if t.pro { - crate::chrome_ui::home_button(app, ui); - widgets::vline(ui, 22.0); - } - let tool_icon = icons::button(ui, icons::tool_icon(app.ui.tool), if t.pro { 26.0 } else { 28.0 }, !t.pro, tl!(app.ui.tool.label())); - // Photoshop: right-click the tool icon for Reset Tool / Reset All Tools (#2825). - let mut reset = None; - tool_icon.context_menu(|ui| { - if ui.button(tl!("Reset Tool")).clicked() { - reset = Some("tool.reset"); - ui.close(); - } - if ui.button(tl!("Reset All Tools")).clicked() { - reset = Some("tool.resetAll"); - ui.close(); - } - }); - if let Some(id) = reset - && let Err(e) = crate::menus::invoke(app, ui.ctx(), id, json!({})) - { - app.ui.status = e; - } - if t.pro { - let (r, _) = ui.allocate_exact_size(vec2(10.0, 20.0), Sense::hover()); - icons::paint(ui, r, "chevron-down", 10.0, t.text_faint); - } - widgets::vline(ui, 22.0); - if app.ui.transform.is_some() { - crate::transform_tool::options_bar(app, ui); - return; - } - if crate::distort_ui::options_bar(app, ui) { - return; - } - let tool = app.ui.tool; - // The options bar shows the active tool's brush: switch it in before drawing the - // chip, so a tool change swaps the brush with it (Photoshop keeps one per tool). - crate::paint_mouse::sync_tool_brush(app); - // Brush edits here go through `tools.setBrush`, one journal entry per gesture (Rule 1). - if (tool.is_brushlike() && !matches!(tool, Tool::Brush | Tool::Pencil | Tool::MixerBrush | Tool::Eraser)) || tool == Tool::QuickSelection { - brush_preset_chip(ui, &app.session.tools.brush, &mut app.ui); - crate::brush_picker::settings_toggle(app, ui); - widgets::vline(ui, 22.0); - } - if tool == Tool::CloneStamp { - let before = app.session.tools.brush.clone(); - let mut brush = before.clone(); - let width = if t.pro { 62.0 } else { 66.0 }; - percent_field(ui, tl!("Opacity"), &mut brush.opacity, 1.0..=100.0, width); - percent_field(ui, tl!("Flow"), &mut brush.flow, 1.0..=100.0, width); - crate::brush_panel::commit_gesture(app, ui.ctx(), &before, &brush); - widgets::vline(ui, 22.0); - } - if crate::eraser_ui::options_bar(app, ui, tool) - || crate::retouch_ui::options_bar(app, ui, tool) - || crate::vector_ui::options_bar(app, ui, tool) - || crate::analysis_ui::options_bar(app, ui, tool) - || crate::slice_ui::options_bar(app, ui, tool) - || crate::frame_tool::options_bar(app, ui, tool) - || crate::artboard_tool::options_bar(app, ui, tool) - { - return; - } - let brush_before = app.session.tools.brush.clone(); - let mut brush = brush_before.clone(); - let b = &mut brush; - match app.ui.tool { - Tool::Brush | Tool::Eraser if t.pro => { - // A Block-mode Eraser has a fixed size, opacity and flow (Photoshop, #2770). - let block = crate::eraser_ui::block_mode(app, app.ui.tool); - ui.add_enabled_ui(!block, |ui| { - brush_preset_chip(ui, b, &mut app.ui); - crate::brush_picker::settings_toggle(app, ui); - }); - widgets::vline(ui, 22.0); - // The Eraser has no blend mode: its Mode is Brush, Pencil or Block (#2662). - if app.ui.tool == Tool::Eraser { - crate::eraser_ui::mode_dropdown(ui, &mut app.ui.tool_options.eraser_mode); - } else { - opt_label(ui, tl!("Mode")); - let held = app.held_erase; - paint_mode_dropdown(ui, "brush-mode", b, &mut app.ui.tool_options.brush_clear, held); - } - ui.add_enabled_ui(!block, |ui| { - percent_field(ui, tl!("Opacity"), &mut b.opacity, 0.0..=100.0, 62.0); - if icons::button(ui, "circle-dot", 24.0, b.pressure_opacity, tl!("Always use pressure for opacity")).clicked() { - b.pressure_opacity = !b.pressure_opacity; - } - }); - // A Pencil- or Block-mode Eraser is always full flow, without build-up (Photoshop). - ui.add_enabled_ui(!block && !crate::eraser_ui::pencil_mode(app, app.ui.tool), |ui| { - percent_field(ui, tl!("Flow"), &mut b.flow, 1.0..=100.0, 62.0); - let airbrush = icons::button(ui, "sparkles", 24.0, b.build_up, tl!("Enable airbrush-style build-up effects")); - if crate::brush_picker::named(airbrush, "Enable airbrush-style build-up effects").clicked() { - b.build_up = !b.build_up; - } - }); - opt_label(ui, tl!("Smoothing")); - smoothing_field(ui, b, 58.0); - smoothing_options(ui, b); - widgets::vline(ui, 22.0); - if icons::button(ui, "circle-dot", 24.0, b.pressure_size, tl!("Always use pressure for size")).clicked() { - b.pressure_size = !b.pressure_size; - } - } - // Pencil: Photoshop's options (no hardness or flow: the pencil is always hard). - Tool::Pencil => { - brush_preset_chip(ui, b, &mut app.ui); - crate::brush_picker::settings_toggle(app, ui); - widgets::vline(ui, 22.0); - if !t.pro { - opt_label(ui, tl!("Size")); - widgets::value_field(ui, &mut b.size, 1.0..=photocraft_engine::paint::MAX_BRUSH_SIZE, "px", 76.0); + // Font ink can extend beyond its advance width at fractional positions. + // Include its gutter in the container layout, including right-aligned actions. + egui::Frame::NONE.inner_margin(egui::Margin { right: 2, ..Default::default() }).show(ui, |ui| { + crate::direction::horizontal_centered(ui, |ui| { + if t.pro { + crate::chrome_ui::home_button(app, ui); widgets::vline(ui, 22.0); } - opt_label(ui, tl!("Mode")); - let held = app.held_erase; - paint_mode_dropdown(ui, "pencil-mode", b, &mut app.ui.tool_options.pencil_clear, held); - percent_field(ui, tl!("Opacity"), &mut b.opacity, 0.0..=100.0, if t.pro { 62.0 } else { 66.0 }); - opt_label(ui, tl!("Smoothing")); - smoothing_field(ui, b, if t.pro { 58.0 } else { 66.0 }); - widgets::vline(ui, 22.0); - widgets::checkbox(ui, &mut app.ui.tool_options.pencil_auto_erase, tl!("Auto Erase")); - } - Tool::Brush | Tool::Eraser => { - brush_preset_chip(ui, b, &mut app.ui); - crate::brush_picker::settings_toggle(app, ui); - widgets::vline(ui, 22.0); - // A Block-mode Eraser has a fixed size, opacity and flow (Photoshop, #2770). - let block = crate::eraser_ui::block_mode(app, app.ui.tool); - ui.add_enabled_ui(!block, |ui| { - opt_label(ui, tl!("Size")); - widgets::value_field(ui, &mut b.size, 1.0..=2500.0, "px", 76.0); + let tool_icon = icons::button(ui, icons::tool_icon(app.ui.tool), if t.pro { 26.0 } else { 28.0 }, !t.pro, tl!(app.ui.tool.label())); + // Photoshop: right-click the tool icon for Reset Tool / Reset All Tools (#2825). + let mut reset = None; + tool_icon.context_menu(|ui| { + if ui.button(tl!("Reset Tool")).clicked() { + reset = Some("tool.reset"); + ui.close(); + } + if ui.button(tl!("Reset All Tools")).clicked() { + reset = Some("tool.resetAll"); + ui.close(); + } }); - widgets::vline(ui, 22.0); - if app.ui.tool == Tool::Eraser { - crate::eraser_ui::mode_dropdown(ui, &mut app.ui.tool_options.eraser_mode); - } - // A Pencil-mode Eraser is always hard and at full flow (Photoshop). - let fixed = block || crate::eraser_ui::pencil_mode(app, app.ui.tool); - ui.add_enabled_ui(!fixed, |ui| percent_field(ui, tl!("Hardness"), &mut b.hardness, 0.0..=100.0, 66.0)); - ui.add_enabled_ui(!block, |ui| percent_field(ui, tl!("Opacity"), &mut b.opacity, 0.0..=100.0, 66.0)); - ui.add_enabled_ui(!fixed, |ui| percent_field(ui, tl!("Flow"), &mut b.flow, 1.0..=100.0, 66.0)); - opt_label(ui, tl!("Smoothing")); - smoothing_field(ui, b, 66.0); - widgets::vline(ui, 22.0); - widgets::toggle(ui, &mut b.pressure_size, tl!("Pressure for Size")); - widgets::toggle(ui, &mut b.pressure_opacity, tl!("Pressure for Opacity")); - } - Tool::MixerBrush => { - brush_preset_chip(ui, b, &mut app.ui); - crate::brush_picker::settings_toggle(app, ui); - widgets::vline(ui, 22.0); - for (label, value) in [ - (tl!("Wet"), &mut b.mixer.wet), - (tl!("Load"), &mut b.mixer.load), - (tl!("Mix"), &mut b.mixer.mix), - (tl!("Flow"), &mut b.mixer.flow), - ] { - percent_field(ui, label, value, 0.0..=100.0, 62.0); - } - widgets::vline(ui, 22.0); - widgets::checkbox(ui, &mut b.mixer.sample_all_layers, tl!("Sample All Layers")); - } - // Every theme gets Photoshop's tool options (#4178): outside the Pro themes the - // Marquee, Lasso, Paint Bucket, Crop, Perspective Crop and Move tools used to - // show a one-line hint instead, so switching theme "removed" their options. - Tool::RectMarquee | Tool::EllipseMarquee | Tool::SingleRowMarquee | Tool::SingleColumnMarquee => { - ui.spacing_mut().item_spacing.x = 2.0; - for (i, (icon, tip)) in [ - ("square", tl!("New selection").to_string()), - ("plus", crate::i18n::fmt(tl!("Add to selection ({key})"), &[("key", &crate::shortcuts::pretty("Shift"))])), - ("minus", crate::i18n::fmt(tl!("Subtract from selection ({key})"), &[("key", &crate::shortcuts::pretty("Alt"))])), - ( - "squares-subtract", - crate::i18n::fmt(tl!("Intersect with selection ({key})"), &[("key", &crate::shortcuts::pretty("Shift+Alt"))]), - ), - ] - .iter() - .enumerate() + if let Some(id) = reset + && let Err(e) = crate::menus::invoke(app, ui.ctx(), id, json!({})) { - if icons::button(ui, icon, 24.0, app.ui.selection_mode == i as u8, tip).clicked() { - app.ui.selection_mode = i as u8; - } + app.ui.status = e; } - ui.spacing_mut().item_spacing.x = 8.0; - widgets::vline(ui, 22.0); - let o = &mut app.ui.tool_options; - opt_label(ui, tl!("Feather")); - widgets::value_field(ui, &mut o.feather, 0.0..=1000.0, "px", 62.0); - // Photoshop greys Anti-alias for the Rectangular Marquee (its edges are always hard). - ui.add_enabled_ui(app.ui.tool == Tool::EllipseMarquee, |ui| widgets::checkbox(ui, &mut o.anti_alias, tl!("Anti-alias"))); - widgets::vline(ui, 22.0); - // A single row or column has no style or size: Photoshop greys them. - let sized = matches!(app.ui.tool, Tool::RectMarquee | Tool::EllipseMarquee); - ui.add_enabled_ui(sized, |ui| opt_label(ui, tl!("Style"))); - let styles = [ - ("normal".to_string(), tl!("Normal")), - ("fixedRatio".to_string(), tl!("Fixed Ratio")), - ("fixedSize".to_string(), tl!("Fixed Size")), - ]; - if ui.add_enabled_ui(sized, |ui| widgets::dropdown(ui, "marquee-style", &mut o.marquee_style, &styles, 96.0)).inner { - (o.marquee_width, o.marquee_height) = if o.marquee_style == "fixedSize" { (64.0, 64.0) } else { (1.0, 1.0) }; + if t.pro { + let (r, _) = ui.allocate_exact_size(vec2(10.0, 20.0), Sense::hover()); + icons::paint(ui, r, "chevron-down", 10.0, t.text_faint); } - let fixed = sized && o.marquee_style != "normal"; - let (unit, range) = if o.marquee_style == "fixedSize" { ("px", 1.0..=300_000.0) } else { ("", 0.001..=999.0) }; - ui.add_enabled_ui(fixed, |ui| { - opt_label(ui, tl!("Width")); - widgets::value_field(ui, &mut o.marquee_width, range.clone(), unit, 62.0); - if icons::button(ui, "arrow-left-right", 22.0, false, tl!("Swaps height and width")).clicked() { - std::mem::swap(&mut o.marquee_width, &mut o.marquee_height); - } - opt_label(ui, tl!("Height")); - widgets::value_field(ui, &mut o.marquee_height, range, unit, 62.0); - }); widgets::vline(ui, 22.0); - if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() { - let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({})); + if app.ui.transform.is_some() { + crate::transform_tool::options_bar(app, ui); + return; } - } - Tool::Lasso | Tool::PolygonLasso | Tool::MagneticLasso => { - selection_mode_buttons(app, ui); - widgets::vline(ui, 22.0); - opt_label(ui, tl!("Feather")); - widgets::value_field(ui, &mut app.ui.tool_options.feather, 0.0..=1000.0, "px", 62.0); - widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias")); - widgets::vline(ui, 22.0); - if app.ui.tool == Tool::MagneticLasso { - let o = &mut app.ui.tool_options; - opt_label(ui, tl!("Width")); - widgets::value_field(ui, &mut o.magnetic_width, 1.0..=256.0, "px", 58.0) - .on_hover_text(tl!("Follows only edges this close to the pointer ([ and ] change it)")); - opt_label(ui, tl!("Contrast")); - widgets::value_field(ui, &mut o.magnetic_contrast, 1.0..=100.0, "%", 58.0) - .on_hover_text(tl!("Higher values follow only edges that contrast sharply with their surroundings")); - opt_label(ui, tl!("Frequency")); - widgets::value_field(ui, &mut o.magnetic_frequency, 0.0..=100.0, "", 50.0) - .on_hover_text(tl!("How often fastening points are placed by themselves")); - if icons::button(ui, "circle-dot", 24.0, o.magnetic_pressure, tl!("Use tablet pressure to change pen width")).clicked() { - o.magnetic_pressure = !o.magnetic_pressure; - } + if crate::distort_ui::options_bar(app, ui) { + return; + } + let tool = app.ui.tool; + // The options bar shows the active tool's brush: switch it in before drawing the + // chip, so a tool change swaps the brush with it (Photoshop keeps one per tool). + crate::paint_mouse::sync_tool_brush(app); + // Brush edits here go through `tools.setBrush`, one journal entry per gesture (Rule 1). + if (tool.is_brushlike() && !matches!(tool, Tool::Brush | Tool::Pencil | Tool::MixerBrush | Tool::Eraser)) + || tool == Tool::QuickSelection + { + brush_preset_chip(ui, &app.session.tools.brush, &mut app.ui); + crate::brush_picker::settings_toggle(app, ui); widgets::vline(ui, 22.0); } - if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() { - let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({})); + if tool == Tool::CloneStamp { + let before = app.session.tools.brush.clone(); + let mut brush = before.clone(); + let width = if t.pro { 62.0 } else { 66.0 }; + percent_field(ui, tl!("Opacity"), &mut brush.opacity, 1.0..=100.0, width); + percent_field(ui, tl!("Flow"), &mut brush.flow, 1.0..=100.0, width); + crate::brush_panel::commit_gesture(app, ui.ctx(), &before, &brush); + widgets::vline(ui, 22.0); } - if crate::lasso_ui::active(app) || (app.ui.tool == Tool::PolygonLasso && !app.ui.polygon.is_empty()) { - hint( - ui, - &crate::i18n::fmt( - tl!("Click the first point or press {key} to close · Esc cancels"), - &[("key", &crate::shortcuts::pretty("Enter"))], - ), - ); - } else if app.ui.tool == Tool::Lasso { - hint(ui, tl!("Hold Alt while drawing for straight segments")); + if crate::eraser_ui::options_bar(app, ui, tool) + || crate::retouch_ui::options_bar(app, ui, tool) + || crate::vector_ui::options_bar(app, ui, tool) + || crate::analysis_ui::options_bar(app, ui, tool) + || crate::slice_ui::options_bar(app, ui, tool) + || crate::frame_tool::options_bar(app, ui, tool) + || crate::artboard_tool::options_bar(app, ui, tool) + { + return; } - if app.ui.tool == Tool::MagneticLasso && app.ui.magnetic.active() { - hint( - ui, - &crate::i18n::fmt( - tl!("Click the first point or press {key} to close · {del} removes a point · Esc cancels"), - &[("key", &crate::shortcuts::pretty("Enter")), ("del", &crate::shortcuts::pretty("Backspace"))], - ), - ); - } - } - Tool::MagicWand => { - selection_mode_buttons(app, ui); - widgets::vline(ui, 22.0); - opt_label(ui, tl!("Tolerance")); - widgets::value_field(ui, &mut app.ui.tool_options.tolerance, 0.0..=255.0, "", 58.0); - widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias")); - widgets::checkbox(ui, &mut app.ui.tool_options.contiguous, tl!("Contiguous")); - widgets::checkbox(ui, &mut app.ui.tool_options.sample_all_layers, tl!("Sample All Layers")); - widgets::vline(ui, 22.0); - if widgets::secondary_button(ui, tl!("Select Subject"), 0.0).clicked() { - let r = app.run("select.subject", json!({})); - crate::retouch_ui::report_smart_result(app, r, tl!("No subject found — try Object Selection or the Lasso")); - } - if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() { - let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({})); - } - } - Tool::PaintBucket => { - opt_label(ui, tl!("Fill")); - let mut src = u8::from(app.ui.tool_options.bucket_fill_pattern); - if widgets::dropdown(ui, "bucket-src", &mut src, &[(0u8, tl!("Foreground")), (1, tl!("Pattern"))], 100.0) { - app.ui.tool_options.bucket_fill_pattern = src == 1; - } - opt_label(ui, tl!("Opacity")); - widgets::value_field(ui, &mut app.ui.tool_options.fill_opacity, 1.0..=100.0, "%", 62.0); - opt_label(ui, tl!("Tolerance")); - widgets::value_field(ui, &mut app.ui.tool_options.tolerance, 0.0..=255.0, "", 58.0); - widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias")); - widgets::checkbox(ui, &mut app.ui.tool_options.contiguous, tl!("Contiguous")); - widgets::checkbox(ui, &mut app.ui.tool_options.sample_all_layers, tl!("All Layers")); - } - Tool::Gradient => { - // Live "Gradient" (a Gradient Fill layer) or "Classic gradient" (pixels). - let mut classic = app.ui.tool_options.gradient_classic; - if widgets::dropdown(ui, "gradient-mode", &mut classic, &[(false, "Gradient"), (true, "Classic gradient")], 118.0) { - app.ui.tool_options.gradient_classic = classic; - } - // Live "Gradient" (a Gradient Fill layer) or "Classic gradient" (pixels): - // both paint with the same engine-owned preset (#1651), and either swatch - // click opens the Gradient Editor window, as in Photoshop. - if crate::gradient_ui::preset_swatch(app, ui) { - app.ui.panels.gradient_editor = true; - } - widgets::vline(ui, 22.0); - ui.spacing_mut().item_spacing.x = 2.0; - let before = app.ui.tool_options.clone(); - for (style, icon, tip) in [ - ("linear", "blend", tl!("Linear Gradient")), - ("radial", "circle", tl!("Radial Gradient")), - ("angle", "rotate-cw", tl!("Angle Gradient")), - ("reflected", "arrow-left-right", tl!("Reflected Gradient")), - ("diamond", "diamond", tl!("Diamond Gradient")), - ] { - if icons::button(ui, icon, 24.0, app.ui.tool_options.gradient_style == style, tip).clicked() { - app.ui.tool_options.gradient_style = style.into(); + let brush_before = app.session.tools.brush.clone(); + let mut brush = brush_before.clone(); + let b = &mut brush; + match app.ui.tool { + Tool::Brush | Tool::Eraser if t.pro => { + // A Block-mode Eraser has a fixed size, opacity and flow (Photoshop, #2770). + let block = crate::eraser_ui::block_mode(app, app.ui.tool); + ui.add_enabled_ui(!block, |ui| { + brush_preset_chip(ui, b, &mut app.ui); + crate::brush_picker::settings_toggle(app, ui); + }); + widgets::vline(ui, 22.0); + // The Eraser has no blend mode: its Mode is Brush, Pencil or Block (#2662). + if app.ui.tool == Tool::Eraser { + crate::eraser_ui::mode_dropdown(ui, &mut app.ui.tool_options.eraser_mode); + } else { + opt_label(ui, tl!("Mode")); + let held = app.held_erase; + paint_mode_dropdown(ui, "brush-mode", b, &mut app.ui.tool_options.brush_clear, held); + } + ui.add_enabled_ui(!block, |ui| { + percent_field(ui, tl!("Opacity"), &mut b.opacity, 0.0..=100.0, 62.0); + if icons::button(ui, "circle-dot", 24.0, b.pressure_opacity, tl!("Always use pressure for opacity")).clicked() { + b.pressure_opacity = !b.pressure_opacity; + } + }); + // A Pencil- or Block-mode Eraser is always full flow, without build-up (Photoshop). + ui.add_enabled_ui(!block && !crate::eraser_ui::pencil_mode(app, app.ui.tool), |ui| { + percent_field(ui, tl!("Flow"), &mut b.flow, 1.0..=100.0, 62.0); + let airbrush = icons::button(ui, "sparkles", 24.0, b.build_up, tl!("Enable airbrush-style build-up effects")); + if crate::brush_picker::named(airbrush, "Enable airbrush-style build-up effects").clicked() { + b.build_up = !b.build_up; + } + }); + opt_label(ui, tl!("Smoothing")); + smoothing_field(ui, b, 58.0); + smoothing_options(ui, b); + widgets::vline(ui, 22.0); + if icons::button(ui, "circle-dot", 24.0, b.pressure_size, tl!("Always use pressure for size")).clicked() { + b.pressure_size = !b.pressure_size; + } } - } - ui.spacing_mut().item_spacing.x = 8.0; - widgets::vline(ui, 22.0); - opt_label(ui, tl!("Mode")); - let opts: Vec<(BlendMode, &str)> = BlendMode::LAYER_MODES.iter().map(|m| (*m, m.label())).collect(); - widgets::dropdown(ui, "gradient-blend-mode", &mut app.ui.tool_options.gradient_blend_mode, &opts, 96.0); - opt_label(ui, tl!("Opacity")); - widgets::value_field(ui, &mut app.ui.tool_options.fill_opacity, 1.0..=100.0, "%", 62.0); - widgets::checkbox(ui, &mut app.ui.tool_options.gradient_reverse, tl!("Reverse")); - widgets::checkbox(ui, &mut app.ui.tool_options.gradient_dither, tl!("Dither")); - // Live mode: the options also change a selected gradient fill layer. - crate::gradient_ui::options_changed(app, &before); - } - Tool::PerspectiveCrop => crate::perspective_crop_ui::options_bar(app, ui), - Tool::Crop => { - let before_ratio = crate::crop_ui::preset_ratio(app); - let doc_size = app.session.active().map_or((0.0, 0.0), |s| (f64::from(s.doc.size.width), f64::from(s.doc.size.height))); - // Ratios, sizes, saved presets, New / Delete Crop Preset… (#2443, #1919). - crate::crop_presets::dropdown(app, ui); - let o = &mut app.ui.tool_options; - if o.crop_ratio == crate::crop_size::WHR { - crate::crop_size::fields(o, ui); - } else { - // Keep partial edits in ToolOptions so the first side survives a frame; - // Original Ratio shows the document's numbers, as Photoshop does. - let (mut rw, mut rh) = crate::crop_size::custom_ratio_fields(o, doc_size); - let cw = widgets::value_field(ui, &mut rw, 0.0..=99_999.0, "", 54.0).changed(); - let swap = icons::button(ui, "arrow-left-right", 22.0, false, tl!("Swaps height and width")).clicked(); - let ch = widgets::value_field(ui, &mut rh, 0.0..=99_999.0, "", 54.0).changed(); - if swap { - std::mem::swap(&mut rw, &mut rh); + // Pencil: Photoshop's options (no hardness or flow: the pencil is always hard). + Tool::Pencil => { + brush_preset_chip(ui, b, &mut app.ui); + crate::brush_picker::settings_toggle(app, ui); + widgets::vline(ui, 22.0); + if !t.pro { + opt_label(ui, tl!("Size")); + widgets::value_field(ui, &mut b.size, 1.0..=photocraft_engine::paint::MAX_BRUSH_SIZE, "px", 76.0); + widgets::vline(ui, 22.0); + } + opt_label(ui, tl!("Mode")); + let held = app.held_erase; + paint_mode_dropdown(ui, "pencil-mode", b, &mut app.ui.tool_options.pencil_clear, held); + percent_field(ui, tl!("Opacity"), &mut b.opacity, 0.0..=100.0, if t.pro { 62.0 } else { 66.0 }); + opt_label(ui, tl!("Smoothing")); + smoothing_field(ui, b, if t.pro { 58.0 } else { 66.0 }); + widgets::vline(ui, 22.0); + widgets::checkbox(ui, &mut app.ui.tool_options.pencil_auto_erase, tl!("Auto Erase")); } - if cw || ch || swap { - crate::crop_size::set_custom_ratio_fields(o, rw, rh); + Tool::Brush | Tool::Eraser => { + brush_preset_chip(ui, b, &mut app.ui); + crate::brush_picker::settings_toggle(app, ui); + widgets::vline(ui, 22.0); + // A Block-mode Eraser has a fixed size, opacity and flow (Photoshop, #2770). + let block = crate::eraser_ui::block_mode(app, app.ui.tool); + ui.add_enabled_ui(!block, |ui| { + opt_label(ui, tl!("Size")); + widgets::value_field(ui, &mut b.size, 1.0..=2500.0, "px", 76.0); + }); + widgets::vline(ui, 22.0); + if app.ui.tool == Tool::Eraser { + crate::eraser_ui::mode_dropdown(ui, &mut app.ui.tool_options.eraser_mode); + } + // A Pencil-mode Eraser is always hard and at full flow (Photoshop). + let fixed = block || crate::eraser_ui::pencil_mode(app, app.ui.tool); + ui.add_enabled_ui(!fixed, |ui| percent_field(ui, tl!("Hardness"), &mut b.hardness, 0.0..=100.0, 66.0)); + ui.add_enabled_ui(!block, |ui| percent_field(ui, tl!("Opacity"), &mut b.opacity, 0.0..=100.0, 66.0)); + ui.add_enabled_ui(!fixed, |ui| percent_field(ui, tl!("Flow"), &mut b.flow, 1.0..=100.0, 66.0)); + opt_label(ui, tl!("Smoothing")); + smoothing_field(ui, b, 66.0); + widgets::vline(ui, 22.0); + widgets::toggle(ui, &mut b.pressure_size, tl!("Pressure for Size")); + widgets::toggle(ui, &mut b.pressure_opacity, tl!("Pressure for Opacity")); } - } - widgets::vline(ui, 22.0); - if widgets::secondary_button(ui, tl!("Clear"), 0.0).clicked() { - if o.crop_ratio == crate::crop_size::WHR { - crate::crop_size::clear(o); - } else { - o.crop_ratio.clear(); + Tool::MixerBrush => { + brush_preset_chip(ui, b, &mut app.ui); + crate::brush_picker::settings_toggle(app, ui); + widgets::vline(ui, 22.0); + for (label, value) in [ + (tl!("Wet"), &mut b.mixer.wet), + (tl!("Load"), &mut b.mixer.load), + (tl!("Mix"), &mut b.mixer.mix), + (tl!("Flow"), &mut b.mixer.flow), + ] { + percent_field(ui, label, value, 0.0..=100.0, 62.0); + } + widgets::vline(ui, 22.0); + widgets::checkbox(ui, &mut b.mixer.sample_all_layers, tl!("Sample All Layers")); } - } - crate::crop_straighten::options_button(&mut app.crop.straighten, ui); - crate::crop_overlay::options_button(o, ui); - let pick_shield_color = crate::crop_shield::options_button(&mut o.crop_shield, ui); - widgets::checkbox(ui, &mut o.crop_delete, tl!("Delete Cropped Pixels")); - if crate::crop_ui::preset_ratio(app) != before_ratio { - crate::crop_ui::apply_ratio(app); - } - if pick_shield_color { - crate::crop_shield::pick_custom_color(app); - } - ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - if icons::button( - ui, - "check", - 26.0, - false, - &crate::i18n::fmt(tl!("Commit current crop operation ({key})"), &[("key", &crate::shortcuts::pretty("Enter"))]), - ) - .clicked() - { - crate::canvas::commit_crop(app); - } - if icons::button(ui, "ban", 26.0, false, tl!("Cancel current crop operation (Esc)")).clicked() { - crate::crop_ui::cancel(app); - } - }); - } - // Every theme gets the font, style and size controls (#1387), as with Auto-Select (#1275). - Tool::Type | Tool::VerticalType | Tool::HorizontalTypeMask | Tool::VerticalTypeMask => crate::type_tool::options_bar(app, ui), - Tool::Move => { - let o = &mut app.ui.tool_options; - widgets::checkbox(ui, &mut o.move_auto_select, tl!("Auto-Select:")); - widgets::dropdown( - ui, - "move-target", - &mut o.move_target, - &[("layer".to_string(), tl!("Layer")), ("group".to_string(), tl!("Group"))], - 76.0, - ); - widgets::vline(ui, 22.0); - widgets::checkbox(ui, &mut o.move_show_transform, tl!("Show Transform Controls")); - widgets::vline(ui, 22.0); - ui.spacing_mut().item_spacing.x = 0.0; - for (icon, tip, cmd) in [ - ("panels-top-left", tl!("Align left edges"), "layer.align.leftEdges"), - ("app-window", tl!("Align horizontal centers"), "layer.align.horizontalCenters"), - ("panel-right", tl!("Align right edges"), "layer.align.rightEdges"), - ] { - let on = app.session.is_enabled(cmd); - if ui.add_enabled_ui(on, |ui| icons::button(ui, icon, 24.0, false, tip)).inner.clicked() { - let _ = app.run(cmd, json!({})); - } - } - ui.add_space(6.0); - let more = icons::button(ui, "ellipsis", 24.0, false, tl!("Align and distribute")); - egui::Popup::menu(&more).show(|ui| { - ui.set_min_width(200.0); - let mut section = |ui: &mut egui::Ui, title: &str, prefix: &str| { - ui.label(egui::RichText::new(tl!(&title)).small().color(t.text_dim)); - for c in photocraft_engine::command_specs().iter().filter(|c| c.id.starts_with(prefix)) { - if ui.add_enabled(app.session.is_enabled(c.id), egui::Button::new(tl!(c.label))).clicked() { - let _ = app.run(c.id, json!({})); - ui.close(); + // Every theme gets Photoshop's tool options (#4178): outside the Pro themes the + // Marquee, Lasso, Paint Bucket, Crop, Perspective Crop and Move tools used to + // show a one-line hint instead, so switching theme "removed" their options. + Tool::RectMarquee | Tool::EllipseMarquee | Tool::SingleRowMarquee | Tool::SingleColumnMarquee => { + ui.spacing_mut().item_spacing.x = 2.0; + for (i, (icon, tip)) in [ + ("square", tl!("New selection").to_string()), + ("plus", crate::i18n::fmt(tl!("Add to selection ({key})"), &[("key", &crate::shortcuts::pretty("Shift"))])), + ("minus", crate::i18n::fmt(tl!("Subtract from selection ({key})"), &[("key", &crate::shortcuts::pretty("Alt"))])), + ( + "squares-subtract", + crate::i18n::fmt(tl!("Intersect with selection ({key})"), &[("key", &crate::shortcuts::pretty("Shift+Alt"))]), + ), + ] + .iter() + .enumerate() + { + if icons::button(ui, icon, 24.0, app.ui.selection_mode == i as u8, tip).clicked() { + app.ui.selection_mode = i as u8; } } - }; - section(ui, tl!("Align"), "layer.align."); - ui.separator(); - section(ui, tl!("Distribute"), "layer.distribute."); - }); - } - Tool::Eyedropper => crate::eyedropper_ui::options(app, ui), - Tool::Zoom => { - widgets::checkbox(ui, &mut app.ui.tool_options.zoom_scrubby, tl!("Scrubby Zoom")); - hint( - ui, - &crate::i18n::fmt( - tl!("Click to zoom in · {key}-click to zoom out · drag right/left to zoom in/out"), - &[("key", &crate::shortcuts::pretty("Alt"))], - ), - ); - if widgets::secondary_button(ui, tl!("Fit Screen"), 0.0).clicked() - && let Some(i) = app.session.active_index() - { - app.ui.views[i].fit_pending = true; - } - if widgets::secondary_button(ui, "100%", 0.0).clicked() - && let Some(i) = app.session.active_index() - { - app.ui.views[i].zoom = 1.0; - } - } - Tool::RotateView => { - hint(ui, tl!("Drag around the centre to rotate the view · Shift constrains to 15°")); - if let Some(i) = app.session.active_index() { - ui.label(tl!("Angle")); - let mut angle = app.ui.views.get(i).map(|v| v.rotation).unwrap_or(0.0); - if widgets::value_field(ui, &mut angle, -180.0..=180.0, "°", 56.0).changed() - && let Some(v) = app.ui.views.get_mut(i) - { - v.rotation = crate::rotate_view::wrap_deg(angle); + ui.spacing_mut().item_spacing.x = 8.0; + widgets::vline(ui, 22.0); + let o = &mut app.ui.tool_options; + opt_label(ui, tl!("Feather")); + widgets::value_field(ui, &mut o.feather, 0.0..=1000.0, "px", 62.0); + // Photoshop greys Anti-alias for the Rectangular Marquee (its edges are always hard). + ui.add_enabled_ui(app.ui.tool == Tool::EllipseMarquee, |ui| widgets::checkbox(ui, &mut o.anti_alias, tl!("Anti-alias"))); + widgets::vline(ui, 22.0); + // A single row or column has no style or size: Photoshop greys them. + let sized = matches!(app.ui.tool, Tool::RectMarquee | Tool::EllipseMarquee); + ui.add_enabled_ui(sized, |ui| opt_label(ui, tl!("Style"))); + let styles = [ + ("normal".to_string(), tl!("Normal")), + ("fixedRatio".to_string(), tl!("Fixed Ratio")), + ("fixedSize".to_string(), tl!("Fixed Size")), + ]; + if ui.add_enabled_ui(sized, |ui| widgets::dropdown(ui, "marquee-style", &mut o.marquee_style, &styles, 96.0)).inner { + (o.marquee_width, o.marquee_height) = if o.marquee_style == "fixedSize" { (64.0, 64.0) } else { (1.0, 1.0) }; + } + let fixed = sized && o.marquee_style != "normal"; + let (unit, range) = if o.marquee_style == "fixedSize" { ("px", 1.0..=300_000.0) } else { ("", 0.001..=999.0) }; + ui.add_enabled_ui(fixed, |ui| { + opt_label(ui, tl!("Width")); + widgets::value_field(ui, &mut o.marquee_width, range.clone(), unit, 62.0); + if icons::button(ui, "arrow-left-right", 22.0, false, tl!("Swaps height and width")).clicked() { + std::mem::swap(&mut o.marquee_width, &mut o.marquee_height); + } + opt_label(ui, tl!("Height")); + widgets::value_field(ui, &mut o.marquee_height, range, unit, 62.0); + }); + widgets::vline(ui, 22.0); + if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() { + let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({})); + } } - if widgets::secondary_button(ui, tl!("Reset View"), 0.0).clicked() - && let Some(v) = app.ui.views.get_mut(i) - { - v.rotation = 0.0; + Tool::Lasso | Tool::PolygonLasso | Tool::MagneticLasso => { + selection_mode_buttons(app, ui); + widgets::vline(ui, 22.0); + opt_label(ui, tl!("Feather")); + widgets::value_field(ui, &mut app.ui.tool_options.feather, 0.0..=1000.0, "px", 62.0); + widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias")); + widgets::vline(ui, 22.0); + if app.ui.tool == Tool::MagneticLasso { + let o = &mut app.ui.tool_options; + opt_label(ui, tl!("Width")); + widgets::value_field(ui, &mut o.magnetic_width, 1.0..=256.0, "px", 58.0) + .on_hover_text(tl!("Follows only edges this close to the pointer ([ and ] change it)")); + opt_label(ui, tl!("Contrast")); + widgets::value_field(ui, &mut o.magnetic_contrast, 1.0..=100.0, "%", 58.0) + .on_hover_text(tl!("Higher values follow only edges that contrast sharply with their surroundings")); + opt_label(ui, tl!("Frequency")); + widgets::value_field(ui, &mut o.magnetic_frequency, 0.0..=100.0, "", 50.0) + .on_hover_text(tl!("How often fastening points are placed by themselves")); + if icons::button(ui, "circle-dot", 24.0, o.magnetic_pressure, tl!("Use tablet pressure to change pen width")).clicked() { + o.magnetic_pressure = !o.magnetic_pressure; + } + widgets::vline(ui, 22.0); + } + if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() { + let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({})); + } + if crate::lasso_ui::active(app) || (app.ui.tool == Tool::PolygonLasso && !app.ui.polygon.is_empty()) { + hint( + ui, + &crate::i18n::fmt( + tl!("Click the first point or press {key} to close · Esc cancels"), + &[("key", &crate::shortcuts::pretty("Enter"))], + ), + ); + } else if app.ui.tool == Tool::Lasso { + hint(ui, tl!("Hold Alt while drawing for straight segments")); + } + if app.ui.tool == Tool::MagneticLasso && app.ui.magnetic.active() { + hint( + ui, + &crate::i18n::fmt( + tl!("Click the first point or press {key} to close · {del} removes a point · Esc cancels"), + &[("key", &crate::shortcuts::pretty("Enter")), ("del", &crate::shortcuts::pretty("Backspace"))], + ), + ); + } } + Tool::MagicWand => { + selection_mode_buttons(app, ui); + widgets::vline(ui, 22.0); + opt_label(ui, tl!("Tolerance")); + widgets::value_field(ui, &mut app.ui.tool_options.tolerance, 0.0..=255.0, "", 58.0); + widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias")); + widgets::checkbox(ui, &mut app.ui.tool_options.contiguous, tl!("Contiguous")); + widgets::checkbox(ui, &mut app.ui.tool_options.sample_all_layers, tl!("Sample All Layers")); + widgets::vline(ui, 22.0); + if widgets::secondary_button(ui, tl!("Select Subject"), 0.0).clicked() { + let r = app.run("select.subject", json!({})); + crate::retouch_ui::report_smart_result(app, r, tl!("No subject found — try Object Selection or the Lasso")); + } + if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() { + let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({})); + } + } + Tool::PaintBucket => { + opt_label(ui, tl!("Fill")); + let mut src = u8::from(app.ui.tool_options.bucket_fill_pattern); + if widgets::dropdown(ui, "bucket-src", &mut src, &[(0u8, tl!("Foreground")), (1, tl!("Pattern"))], 100.0) { + app.ui.tool_options.bucket_fill_pattern = src == 1; + } + opt_label(ui, tl!("Opacity")); + widgets::value_field(ui, &mut app.ui.tool_options.fill_opacity, 1.0..=100.0, "%", 62.0); + opt_label(ui, tl!("Tolerance")); + widgets::value_field(ui, &mut app.ui.tool_options.tolerance, 0.0..=255.0, "", 58.0); + widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias")); + widgets::checkbox(ui, &mut app.ui.tool_options.contiguous, tl!("Contiguous")); + widgets::checkbox(ui, &mut app.ui.tool_options.sample_all_layers, tl!("All Layers")); + } + Tool::Gradient => { + // Live "Gradient" (a Gradient Fill layer) or "Classic gradient" (pixels). + let mut classic = app.ui.tool_options.gradient_classic; + if widgets::dropdown(ui, "gradient-mode", &mut classic, &[(false, "Gradient"), (true, "Classic gradient")], 118.0) { + app.ui.tool_options.gradient_classic = classic; + } + // Live "Gradient" (a Gradient Fill layer) or "Classic gradient" (pixels): + // both paint with the same engine-owned preset (#1651), and either swatch + // click opens the Gradient Editor window, as in Photoshop. + if crate::gradient_ui::preset_swatch(app, ui) { + app.ui.panels.gradient_editor = true; + } + widgets::vline(ui, 22.0); + ui.spacing_mut().item_spacing.x = 2.0; + let before = app.ui.tool_options.clone(); + for (style, icon, tip) in [ + ("linear", "blend", tl!("Linear Gradient")), + ("radial", "circle", tl!("Radial Gradient")), + ("angle", "rotate-cw", tl!("Angle Gradient")), + ("reflected", "arrow-left-right", tl!("Reflected Gradient")), + ("diamond", "diamond", tl!("Diamond Gradient")), + ] { + if icons::button(ui, icon, 24.0, app.ui.tool_options.gradient_style == style, tip).clicked() { + app.ui.tool_options.gradient_style = style.into(); + } + } + ui.spacing_mut().item_spacing.x = 8.0; + widgets::vline(ui, 22.0); + opt_label(ui, tl!("Mode")); + let opts: Vec<(BlendMode, &str)> = BlendMode::LAYER_MODES.iter().map(|m| (*m, m.label())).collect(); + widgets::dropdown(ui, "gradient-blend-mode", &mut app.ui.tool_options.gradient_blend_mode, &opts, 96.0); + opt_label(ui, tl!("Opacity")); + widgets::value_field(ui, &mut app.ui.tool_options.fill_opacity, 1.0..=100.0, "%", 62.0); + widgets::checkbox(ui, &mut app.ui.tool_options.gradient_reverse, tl!("Reverse")); + widgets::checkbox(ui, &mut app.ui.tool_options.gradient_dither, tl!("Dither")); + // Live mode: the options also change a selected gradient fill layer. + crate::gradient_ui::options_changed(app, &before); + } + Tool::PerspectiveCrop => crate::perspective_crop_ui::options_bar(app, ui), + Tool::Crop => { + let before_ratio = crate::crop_ui::preset_ratio(app); + let doc_size = app.session.active().map_or((0.0, 0.0), |s| (f64::from(s.doc.size.width), f64::from(s.doc.size.height))); + // Ratios, sizes, saved presets, New / Delete Crop Preset… (#2443, #1919). + crate::crop_presets::dropdown(app, ui); + let o = &mut app.ui.tool_options; + if o.crop_ratio == crate::crop_size::WHR { + crate::crop_size::fields(o, ui); + } else { + // Keep partial edits in ToolOptions so the first side survives a frame; + // Original Ratio shows the document's numbers, as Photoshop does. + let (mut rw, mut rh) = crate::crop_size::custom_ratio_fields(o, doc_size); + let cw = widgets::value_field(ui, &mut rw, 0.0..=99_999.0, "", 54.0).changed(); + let swap = icons::button(ui, "arrow-left-right", 22.0, false, tl!("Swaps height and width")).clicked(); + let ch = widgets::value_field(ui, &mut rh, 0.0..=99_999.0, "", 54.0).changed(); + if swap { + std::mem::swap(&mut rw, &mut rh); + } + if cw || ch || swap { + crate::crop_size::set_custom_ratio_fields(o, rw, rh); + } + } + widgets::vline(ui, 22.0); + if widgets::secondary_button(ui, tl!("Clear"), 0.0).clicked() { + if o.crop_ratio == crate::crop_size::WHR { + crate::crop_size::clear(o); + } else { + o.crop_ratio.clear(); + } + } + crate::crop_straighten::options_button(&mut app.crop.straighten, ui); + crate::crop_overlay::options_button(o, ui); + let pick_shield_color = crate::crop_shield::options_button(&mut o.crop_shield, ui); + widgets::checkbox(ui, &mut o.crop_delete, tl!("Delete Cropped Pixels")); + if crate::crop_ui::preset_ratio(app) != before_ratio { + crate::crop_ui::apply_ratio(app); + } + if pick_shield_color { + crate::crop_shield::pick_custom_color(app); + } + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + if icons::button( + ui, + "check", + 26.0, + false, + &crate::i18n::fmt(tl!("Commit current crop operation ({key})"), &[("key", &crate::shortcuts::pretty("Enter"))]), + ) + .clicked() + { + crate::canvas::commit_crop(app); + } + if icons::button(ui, "ban", 26.0, false, tl!("Cancel current crop operation (Esc)")).clicked() { + crate::crop_ui::cancel(app); + } + }); + } + // Every theme gets the font, style and size controls (#1387), as with Auto-Select (#1275). + Tool::Type | Tool::VerticalType | Tool::HorizontalTypeMask | Tool::VerticalTypeMask => crate::type_tool::options_bar(app, ui), + Tool::Move => { + let o = &mut app.ui.tool_options; + widgets::checkbox(ui, &mut o.move_auto_select, tl!("Auto-Select:")); + widgets::dropdown( + ui, + "move-target", + &mut o.move_target, + &[("layer".to_string(), tl!("Layer")), ("group".to_string(), tl!("Group"))], + 76.0, + ); + widgets::vline(ui, 22.0); + widgets::checkbox(ui, &mut o.move_show_transform, tl!("Show Transform Controls")); + widgets::vline(ui, 22.0); + ui.spacing_mut().item_spacing.x = 0.0; + for (icon, tip, cmd) in [ + ("panels-top-left", tl!("Align left edges"), "layer.align.leftEdges"), + ("app-window", tl!("Align horizontal centers"), "layer.align.horizontalCenters"), + ("panel-right", tl!("Align right edges"), "layer.align.rightEdges"), + ] { + let on = app.session.is_enabled(cmd); + if ui.add_enabled_ui(on, |ui| icons::button(ui, icon, 24.0, false, tip)).inner.clicked() { + let _ = app.run(cmd, json!({})); + } + } + ui.add_space(6.0); + let more = icons::button(ui, "ellipsis", 24.0, false, tl!("Align and distribute")); + egui::Popup::menu(&more).show(|ui| { + ui.set_min_width(200.0); + let mut section = |ui: &mut egui::Ui, title: &str, prefix: &str| { + ui.label(egui::RichText::new(tl!(&title)).small().color(t.text_dim)); + for c in photocraft_engine::command_specs().iter().filter(|c| c.id.starts_with(prefix)) { + if ui.add_enabled(app.session.is_enabled(c.id), egui::Button::new(tl!(c.label))).clicked() { + let _ = app.run(c.id, json!({})); + ui.close(); + } + } + }; + section(ui, tl!("Align"), "layer.align."); + ui.separator(); + section(ui, tl!("Distribute"), "layer.distribute."); + }); + } + Tool::Eyedropper => crate::eyedropper_ui::options(app, ui), + Tool::Zoom => { + widgets::checkbox(ui, &mut app.ui.tool_options.zoom_scrubby, tl!("Scrubby Zoom")); + hint( + ui, + &crate::i18n::fmt( + tl!("Click to zoom in · {key}-click to zoom out · drag right/left to zoom in/out"), + &[("key", &crate::shortcuts::pretty("Alt"))], + ), + ); + if widgets::secondary_button(ui, tl!("Fit Screen"), 0.0).clicked() + && let Some(i) = app.session.active_index() + { + app.ui.views[i].fit_pending = true; + } + if widgets::secondary_button(ui, "100%", 0.0).clicked() + && let Some(i) = app.session.active_index() + { + app.ui.views[i].zoom = 1.0; + } + } + Tool::RotateView => { + hint(ui, tl!("Drag around the centre to rotate the view · Shift constrains to 15°")); + if let Some(i) = app.session.active_index() { + ui.label(tl!("Angle")); + let mut angle = app.ui.views.get(i).map(|v| v.rotation).unwrap_or(0.0); + if widgets::value_field(ui, &mut angle, -180.0..=180.0, "°", 56.0).changed() + && let Some(v) = app.ui.views.get_mut(i) + { + v.rotation = crate::rotate_view::wrap_deg(angle); + } + if widgets::secondary_button(ui, tl!("Reset View"), 0.0).clicked() + && let Some(v) = app.ui.views.get_mut(i) + { + v.rotation = 0.0; + } + } + } + Tool::Hand => { + hint(ui, tl!("Drag to pan · hold Space with any tool")); + if widgets::secondary_button(ui, "100%", 0.0).clicked() + && let Some(i) = app.session.active_index() + { + app.ui.views[i].zoom = 1.0; + app.ui.views[i].fit_pending = false; + app.ui.views[i].fill_pending = false; + } + if widgets::secondary_button(ui, tl!("Fit Screen"), 0.0).clicked() + && let Some(i) = app.session.active_index() + { + app.ui.views[i].fit_pending = true; + app.ui.views[i].fill_pending = false; + } + if widgets::secondary_button(ui, tl!("Fill Screen"), 0.0).clicked() + && let Some(i) = app.session.active_index() + { + app.ui.views[i].fill_pending = true; + app.ui.views[i].fit_pending = false; + } + } + // Retouching and smart-selection tools draw their bar in `retouch_ui::options_bar`. + _ => {} } - } - Tool::Hand => { - hint(ui, tl!("Drag to pan · hold Space with any tool")); - if widgets::secondary_button(ui, "100%", 0.0).clicked() - && let Some(i) = app.session.active_index() - { - app.ui.views[i].zoom = 1.0; - app.ui.views[i].fit_pending = false; - app.ui.views[i].fill_pending = false; + // Painting symmetry is independent of visual theme. Keep the options-bar + // action available for Brush, Pencil and Eraser in every palette (#2659). + if matches!(tool, Tool::Brush | Tool::Pencil | Tool::Eraser) { + crate::symmetry_ui::menu(app, ui); } - if widgets::secondary_button(ui, tl!("Fit Screen"), 0.0).clicked() - && let Some(i) = app.session.active_index() - { - app.ui.views[i].fit_pending = true; - app.ui.views[i].fill_pending = false; - } - if widgets::secondary_button(ui, tl!("Fill Screen"), 0.0).clicked() - && let Some(i) = app.session.active_index() - { - app.ui.views[i].fill_pending = true; - app.ui.views[i].fit_pending = false; - } - } - // Retouching and smart-selection tools draw their bar in `retouch_ui::options_bar`. - _ => {} - } - // Painting symmetry is independent of visual theme. Keep the options-bar - // action available for Brush, Pencil and Eraser in every palette (#2659). - if matches!(tool, Tool::Brush | Tool::Pencil | Tool::Eraser) { - crate::symmetry_ui::menu(app, ui); - } - crate::brush_panel::commit_gesture(app, ui.ctx(), &brush_before, &brush); - }); - reveal_focused_control(ui); - }); + crate::brush_panel::commit_gesture(app, ui.ctx(), &brush_before, &brush); + }); + reveal_focused_control(ui); + }); }); }); } From 371ede51a05c2d2ab9e569410fd520d51bca9ca8 Mon Sep 17 00:00:00 2001 From: DeWarePeb <68034923+DeWarePeb@users.noreply.github.com> Date: Mon, 12 Oct 2026 15:26:55 +0200 Subject: [PATCH 032/649] Options bar: regression tests for the tool options per theme (#4178) `tool_options_theme_tests`: for each of the eleven tools, the labelled controls of the options bar in every theme must include everything Pro (Medium Gray) shows; and the issue's example, the Crop bar's Delete Cropped Pixels checkbox and Clear button, must exist and work in all twelve themes. Both tests fail on main (Adwaita showed only the hint). Co-Authored-By: Claude Fable 5.1 --- crates/ui-egui/src/lib.rs | 2 + .../ui-egui/src/tool_options_theme_tests.rs | 97 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 crates/ui-egui/src/tool_options_theme_tests.rs diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 1ba0bce83d..f5104ec74f 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -2289,6 +2289,8 @@ mod color_replacement_tests; mod layer_shortcut_tests; #[cfg(test)] mod pencil_tests; +#[cfg(test)] +mod tool_options_theme_tests; #[cfg(test)] mod pixel_aspect_tests; diff --git a/crates/ui-egui/src/tool_options_theme_tests.rs b/crates/ui-egui/src/tool_options_theme_tests.rs new file mode 100644 index 0000000000..3d7b5784fc --- /dev/null +++ b/crates/ui-egui/src/tool_options_theme_tests.rs @@ -0,0 +1,97 @@ +//! Issue #4178: switching from a Pro theme to any other theme (Adwaita, Studio, Classic, Solarized, +//! Breeze) removed the options bar's controls for the Marquee, Lasso, Paint Bucket, Crop, +//! Perspective Crop and Move tools, leaving a one-line hint. A theme changes sizes and colours +//! (`theme::Tokens`), never which options a tool has. + +use egui_kittest::Harness; +use egui_kittest::kittest::{NodeT, Queryable}; +use serde_json::json; + +use crate::PhotocraftApp; +use crate::state::Tool; +use crate::theme::ThemeKind; + +/// The tools whose options bar used to be a hint outside the Pro themes. +const TOOLS: [Tool; 11] = [ + Tool::Crop, + Tool::PerspectiveCrop, + Tool::RectMarquee, + Tool::EllipseMarquee, + Tool::SingleRowMarquee, + Tool::SingleColumnMarquee, + Tool::Lasso, + Tool::PolygonLasso, + Tool::MagneticLasso, + Tool::PaintBucket, + Tool::Move, +]; + +/// The options bar for `tool` under `theme`, with a document open, after a few settled frames. +fn options_bar(theme: ThemeKind, tool: Tool) -> Harness<'static, PhotocraftApp> { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.session.execute("file.new", json!({"width": 64, "height": 64})).unwrap(); + app.sync_views(); + app.ui.tool = tool; + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 60.0)).build_ui_state( + |ui, app: &mut PhotocraftApp| { + if !ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { + return; + } + crate::panels::options_bar(app, ui); + }, + app, + ); + PhotocraftApp::setup_context(&h.ctx, theme); + h.run_steps(4); + h +} + +/// Every labelled node in the bar as `role label`, sorted. The Pro themes end option labels with +/// a colon and start the bar with a Home button; both are chrome, not tool options. +fn controls(h: &Harness<'_, PhotocraftApp>) -> Vec { + let mut v: Vec = h + .root() + .children_recursive() + .filter_map(|n| { + let node = n.accesskit_node(); + let label = node.label().or_else(|| node.value())?; + let label = label.trim_end_matches(':'); + (label != "Home").then(|| format!("{:?} {label}", node.role())) + }) + .collect(); + v.sort(); + v.dedup(); + v +} + +#[test] +fn every_theme_shows_the_same_tool_options() { + for tool in TOOLS { + let reference = controls(&options_bar(ThemeKind::ProMedium, tool)); + assert!(reference.len() > 2, "{tool:?}: the Pro bar has options: {reference:?}"); + for theme in ThemeKind::ALL { + let found = controls(&options_bar(theme, tool)); + let missing: Vec<&String> = reference.iter().filter(|c| !found.contains(c)).collect(); + assert!(missing.is_empty(), "{theme:?} {tool:?}: the options bar lacks {missing:?}; it shows {found:?}"); + } + } +} + +#[test] +fn every_theme_shows_the_crop_options() { + // The issue's example: in Adwaita the Crop tool had no ratio, Clear, overlay or Delete Cropped + // Pixels controls, only "Drag a crop box · …". + for theme in ThemeKind::ALL { + let mut h = options_bar(theme, Tool::Crop); + assert!(h.query_by_label_contains("Drag a crop box").is_none(), "{theme:?}: the hint replaced the options"); + assert!(h.state().ui.tool_options.crop_delete); + h.get_by_label("Delete Cropped Pixels").click(); + h.run_steps(2); + assert!(!h.state().ui.tool_options.crop_delete, "{theme:?}: the checkbox turns Delete Cropped Pixels off"); + h.state_mut().ui.tool_options.crop_ratio = "1:1".into(); + h.run_steps(2); + h.get_by_label("Clear").click(); + h.run_steps(2); + assert!(h.state().ui.tool_options.crop_ratio.is_empty(), "{theme:?}: Clear empties the ratio"); + } +} From 31e523a0f43c342944aa0c02eb57b1358e12fc3d Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Mon, 12 Oct 2026 04:36:29 -0400 Subject: [PATCH 033/649] feat(styles): import and export .asl layer style libraries (#1051) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Styles panel's Import Styles… / Export Styles… read and write Photoshop version-3 style libraries (8BSL): embedded patterns, each style's Lefx effects tree and its blending options. - photocraft-psd: asl reader/writer (panic-free, hostile input → Err) - photocraft-io: asl_map onto effects via the shared lfx2 descriptor code - engine: style.presets.importAsl / style.presets.exportAsl; StylePreset keeps opacity; apply copies stroke/bevel texture patterns - UI: Styles panel menu, .asl through File › Open and drag and drop - automation: import/export paths follow the filesystem policy - asl fuzz target Refs #1693 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 1 + apps/photocraft-web/src/web.rs | 4 +- apps/photocraft/src/services.rs | 4 +- crates/automation/src/workspace.rs | 11 +- crates/engine/src/commands.rs | 1 + crates/engine/src/lib.rs | 1 + crates/engine/src/presets/styles.rs | 20 +- crates/engine/src/presets/tests.rs | 1 + crates/engine/src/style_asl_cmds.rs | 310 +++++++++++++++++++++ crates/io/src/asl_map.rs | 372 ++++++++++++++++++++++++++ crates/io/src/effects_map.rs | 31 ++- crates/io/src/lib.rs | 1 + crates/psd/fuzz/Cargo.toml | 7 + crates/psd/fuzz/fuzz_targets/asl.rs | 15 ++ crates/psd/src/asl.rs | 276 +++++++++++++++++++ crates/psd/src/lib.rs | 1 + crates/ui-egui/src/i18n/cs.tsv | 6 + crates/ui-egui/src/i18n/de.tsv | 6 + crates/ui-egui/src/i18n/el.tsv | 6 + crates/ui-egui/src/i18n/es.tsv | 6 + crates/ui-egui/src/i18n/fr.tsv | 6 + crates/ui-egui/src/i18n/hu.tsv | 6 + crates/ui-egui/src/i18n/id.tsv | 6 + crates/ui-egui/src/i18n/it.tsv | 6 + crates/ui-egui/src/i18n/ja.tsv | 6 + crates/ui-egui/src/i18n/ko.tsv | 6 + crates/ui-egui/src/i18n/nl.tsv | 6 + crates/ui-egui/src/i18n/pl.tsv | 6 + crates/ui-egui/src/i18n/pt-br.tsv | 6 + crates/ui-egui/src/i18n/ru.tsv | 6 + crates/ui-egui/src/i18n/tr.tsv | 6 + crates/ui-egui/src/i18n/uk.tsv | 6 + crates/ui-egui/src/i18n/vi.tsv | 6 + crates/ui-egui/src/i18n/zh-hans.tsv | 6 + crates/ui-egui/src/i18n/zh-hant.tsv | 6 + crates/ui-egui/src/preset_files_ui.rs | 18 +- crates/ui-egui/src/preset_panels.rs | 63 +++++ docs/file-format-parity.md | 5 +- docs/gaps.md | 7 +- 39 files changed, 1236 insertions(+), 27 deletions(-) create mode 100644 crates/engine/src/style_asl_cmds.rs create mode 100644 crates/io/src/asl_map.rs create mode 100644 crates/psd/fuzz/fuzz_targets/asl.rs create mode 100644 crates/psd/src/asl.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 094c1f3893..4541f09df4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -265,6 +265,7 @@ jobs: - { crate: psd, name: metadata } - { crate: psd, name: tagged } - { crate: psd, name: resources } + - { crate: psd, name: asl } - { crate: codecs, name: decode_any } - { crate: codecs, name: decode_png } - { crate: codecs, name: decode_jpeg } diff --git a/apps/photocraft-web/src/web.rs b/apps/photocraft-web/src/web.rs index 6c9939607d..fcb43c0a65 100644 --- a/apps/photocraft-web/src/web.rs +++ b/apps/photocraft-web/src/web.rs @@ -15,11 +15,11 @@ use wasm_bindgen::JsCast as _; type Inbox = Arc)>>>; /// Everything File › Open reads: PhotoCraft, Photoshop, OpenRaster and Affinity documents, flat images, and -/// Photoshop brushes (.abr), gradients (.grd) and swatches (.aco, .ase), which go to the preset libraries. +/// Photoshop brushes (.abr), gradients (.grd), layer styles (.asl) and swatches (.aco, .ase), which go to the preset libraries. const OPEN_EXTS: &[&str] = &[ "pcraft", "pdn", "ora", "psd", "psb", "psdt", "png", "jpg", "jpeg", "tif", "tiff", "webp", "gif", "bmp", "tga", "ico", "qoi", "exr", "hdr", "pbm", "pgm", "ppm", "pam", "pfm", "fits", "fit", "fts", "heic", "heif", "hif", "dng", "cr2", "cr3", "nef", "nrw", "arw", "pef", "orf", "rw2", "raf", "abr", "grd", - "svg", "svgz", "aco", "ase", "af", "afdesign", "afphoto", "afpub", + "asl", "svg", "svgz", "aco", "ase", "af", "afdesign", "afphoto", "afpub", ]; const SVG_EXTS: &[&str] = &["svg", "svgz"]; const CANVAS_ID: &str = "photocraft_canvas"; diff --git a/apps/photocraft/src/services.rs b/apps/photocraft/src/services.rs index f6695717be..3289e63070 100644 --- a/apps/photocraft/src/services.rs +++ b/apps/photocraft/src/services.rs @@ -17,12 +17,12 @@ use std::sync::Arc; mod recovery_tests; /// Everything File › Open reads: PhotoCraft, Photoshop, OpenRaster and Affinity documents, flat images, and -/// Photoshop brushes (.abr), gradients (.grd), swatches (.aco, .ase) and keyboard shortcut sets +/// Photoshop brushes (.abr), gradients (.grd), layer styles (.asl), swatches (.aco, .ase) and keyboard shortcut sets /// (.kys), which go to the preset libraries and Edit › Keyboard Shortcuts. const OPEN_EXTS: &[&str] = &[ "pcraft", "pdn", "ora", "kra", "psd", "psb", "psdt", "png", "jpg", "jpeg", "tif", "tiff", "webp", "gif", "bmp", "tga", "ico", "qoi", "exr", "hdr", "pbm", "pgm", "ppm", "pam", "pfm", "pcx", "fits", "fit", "fts", "heic", "heif", "hif", "dng", "cr2", "cr3", "nef", "nrw", "arw", "pef", "orf", "rw2", "raf", - "abr", "grd", "svg", "svgz", "aco", "ase", "kys", "af", "afdesign", "afphoto", "afpub", + "abr", "grd", "asl", "svg", "svgz", "aco", "ase", "kys", "af", "afdesign", "afphoto", "afpub", ]; const SVG_EXTS: &[&str] = &["svg", "svgz"]; diff --git a/crates/automation/src/workspace.rs b/crates/automation/src/workspace.rs index 76a14c6e34..1bbc3e6da9 100644 --- a/crates/automation/src/workspace.rs +++ b/crates/automation/src/workspace.rs @@ -362,12 +362,12 @@ fn preference_uses_ambient_filesystem(path: &str) -> bool { fn command_uses_ambient_path(id: &str, params: &Value) -> bool { match id { - "brush.presets.importAbr" | "gradient.presets.importGrd" | "plugin.install" | "swatches.import" => { + "brush.presets.importAbr" | "gradient.presets.importGrd" | "plugin.install" | "swatches.import" | "style.presets.importAsl" => { // `data` wins over `path` in these commands; any `path` without it reads the filesystem. params.get("data").is_none() && params.get("path").is_some() } // With a `path` the file is written there; without one the bytes come back as `data`. - "swatches.export" => params.get("path").is_some(), + "swatches.export" | "style.presets.exportAsl" => params.get("path").is_some(), "plugin.reload" => true, _ => false, } @@ -762,6 +762,9 @@ mod tests { ("plugin.install", serde_json::json!({"path": " "})), ("swatches.import", serde_json::json!({"path": "/outside/set.aco"})), ("swatches.export", serde_json::json!({"path": "/outside/set.ase"})), + ("style.presets.importAsl", serde_json::json!({"path": "/outside/set.asl"})), + ("style.presets.exportAsl", serde_json::json!({"path": "/outside/set.asl"})), + ("style.presets.exportAsl", serde_json::json!({"path": 5})), ] { assert!(authorize_engine_command(id, ¶ms).is_err(), "{id}: {params}"); } @@ -771,6 +774,8 @@ mod tests { ("plugin.install", serde_json::json!({"data": "QUJD"})), ("swatches.import", serde_json::json!({"data": "QUJD"})), ("swatches.export", serde_json::json!({"format": "ase"})), + ("style.presets.importAsl", serde_json::json!({"data": "QUJD"})), + ("style.presets.exportAsl", serde_json::json!({"group": "Basics"})), ] { assert!(authorize_engine_command(id, ¶ms).is_ok(), "{id}: {params}"); } @@ -896,6 +901,8 @@ mod tests { ("gradient.presets.importGrd", serde_json::json!({"path": "/outside/set.grd"})), ("plugin.install", serde_json::json!({"path": "/outside/plugin.wasm"})), ("plugin.reload", serde_json::json!({"path": "/outside/plugins"})), + ("style.presets.importAsl", serde_json::json!({"path": "/outside/set.asl"})), + ("style.presets.exportAsl", serde_json::json!({"path": "/outside/set.asl"})), ("prefs.set", serde_json::json!({"path": "historyLog.filePath", "value": "/outside/log"})), ("prefs.set", serde_json::json!({"values": {"interface.language": "fr", "historyLog.filePath": "/outside/log"}})), ] { diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs index 5524388c71..ae505ce8db 100644 --- a/crates/engine/src/commands.rs +++ b/crates/engine/src/commands.rs @@ -1200,6 +1200,7 @@ fn build() -> Vec { v.extend(crate::brush_preset_cmds::specs()); v.extend(crate::eraser_cmds::specs()); v.extend(crate::preset_import_cmds::specs()); + v.extend(crate::style_asl_cmds::specs()); v.extend(crate::swatch_cmds::specs()); v.extend(crate::retouch_cmds::specs()); v.extend(crate::redeye_cmds::specs()); diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index c9cb725518..6134ef29ea 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -102,6 +102,7 @@ pub mod smartselect_cmds; pub mod snap; pub mod solid_fill_cmds; pub mod stamp_cmds; +pub mod style_asl_cmds; pub mod swatch_cmds; pub mod symmetry_cmds; mod timeline_cmds; diff --git a/crates/engine/src/presets/styles.rs b/crates/engine/src/presets/styles.rs index ee4607cf86..04e4c831ce 100644 --- a/crates/engine/src/presets/styles.rs +++ b/crates/engine/src/presets/styles.rs @@ -25,6 +25,9 @@ pub struct StylePreset { pub blend: Option, #[serde(default)] pub fill_opacity: Option, + /// Layer opacity saved with the blending options (0..1). + #[serde(default)] + pub opacity: Option, } impl Named for StylePreset { @@ -43,7 +46,7 @@ impl StylePreset { .as_array() .map(|a| a.iter().filter_map(|e| effect_from_params(e.get(0)?.as_str()?, e.get(1).unwrap_or(&Value::Null))).collect()) .unwrap_or_default(); - StylePreset { name: name.into(), effects, blend: None, fill_opacity: fill } + StylePreset { name: name.into(), effects, blend: None, fill_opacity: fill, opacity: None } } pub fn to_json(&self) -> Value { @@ -52,6 +55,7 @@ impl StylePreset { "effects": self.effects.iter().map(|e| e.label()).collect::>(), "blend": self.blend.map(|b| b.label()), "fillOpacity": self.fill_opacity.map(|f| (f * 100.0).round()), + "opacity": self.opacity.map(|f| (f * 100.0).round()), }) } } @@ -182,6 +186,12 @@ fn apply(s: &mut Session, p: &Value) -> Result { effects.push(fx); pats.extend(pat); } + // Pattern strokes and bevel textures name their pattern too: copy it when the library has it. + for (name, id) in photocraft_io::asl_map::referenced_patterns(&effects) { + if let Some(pat) = crate::pattern_cmds::resolve(s, if id.is_empty() { &name } else { &id }).filter(|_| !(id.is_empty() && name.is_empty())) { + pats.push(pat); + } + } let label = format!("Apply Style: {}", style.name); s.edit(&label, |doc, _| { for pat in &pats { @@ -211,6 +221,9 @@ fn apply(s: &mut Session, p: &Value) -> Result { } else if !add { l.fill_opacity = 1.0; } + if let Some(o) = style.opacity { + l.opacity = o; + } } } Ok(()) @@ -256,6 +269,7 @@ fn new_preset(s: &mut Session, p: &Value) -> Result { }, blend: p.get("blend").and_then(Value::as_str).and_then(crate::commands::blend_from_str).or_else(|| with_blend.then_some(l.blend)), fill_opacity: p.get("fillOpacity").and_then(Value::as_f64).map(|v| (v / 100.0).clamp(0.0, 1.0) as f32).or_else(|| with_blend.then_some(l.fill_opacity)), + opacity: p.get("opacity").and_then(Value::as_f64).map(|v| (v / 100.0).clamp(0.0, 1.0) as f32).or_else(|| with_blend.then_some(l.opacity)), }; let gi = group_index(&mut s.presets.styles, str_param(p, "group")); let out = json!({"name": style.name, "group": s.presets.styles[gi].name, "effects": style.effects.len()}); @@ -336,7 +350,7 @@ pub fn specs() -> Vec { label: "Style Presets", menu: &[], shortcut: None, - params: "{} → {groups:[{name,presets:[{name,effects,blend,fillOpacity}]}]}", + params: "{} → {groups:[{name,presets:[{name,effects,blend,fillOpacity,opacity}]}]}", enabled: always, run: list, journal: false, @@ -356,7 +370,7 @@ pub fn specs() -> Vec { label: "New Style…", menu: &[], shortcut: None, - params: r##"{"name":str="Style","group":name?,"layer":id?,"includeEffects":bool=true,"includeBlending":bool=true,"effects":[[kind, params]]? (explicit list, e.g. the Layer Style dialog's pending state; overrides includeEffects),"blend":str?,"fillOpacity":0..100? (override the layer's blending options)}"##, + params: r##"{"name":str="Style","group":name?,"layer":id?,"includeEffects":bool=true,"includeBlending":bool=true,"effects":[[kind, params]]? (explicit list, e.g. the Layer Style dialog's pending state; overrides includeEffects),"blend":str?,"fillOpacity":0..100?,"opacity":0..100? (override the layer's blending options)}"##, enabled: has_layer, run: new_preset, journal: true, diff --git a/crates/engine/src/presets/tests.rs b/crates/engine/src/presets/tests.rs index 7ebf2145b1..6643bd24af 100644 --- a/crates/engine/src/presets/tests.rs +++ b/crates/engine/src/presets/tests.rs @@ -433,6 +433,7 @@ fn styles_with_pattern_overlay_copy_the_pattern() { effects: vec![crate::layer_style::effect_from_params("patternOverlay", &json!({"pattern": "Bricks"})).unwrap()], blend: None, fill_opacity: None, + opacity: None, }); s.execute("style.presets.apply", json!({"preset": "Bricky", "layer": id.0})).unwrap(); assert!(s.active().unwrap().doc.patterns.iter().any(|p| p.name == "Bricks")); diff --git a/crates/engine/src/style_asl_cmds.rs b/crates/engine/src/style_asl_cmds.rs new file mode 100644 index 0000000000..e942df7d35 --- /dev/null +++ b/crates/engine/src/style_asl_cmds.rs @@ -0,0 +1,310 @@ +//! Styles panel › Import Styles… / Export Styles…: Photoshop layer style libraries (`.asl`). +//! +//! - `style.presets.importAsl` adds every style of an `.asl` file to the Styles library as one +//! group (named after the file), and the patterns embedded in the file to the pattern library so +//! the styles' Pattern Overlays, pattern strokes and bevel textures render. A malformed file +//! changes nothing. +//! - `style.presets.exportAsl` writes styles (all, one group or named ones) as an `.asl`, with the +//! patterns their effects use. +//! +//! The container lives in `photocraft-psd` (`asl`), the mapping onto effects in `photocraft-io` +//! (`asl_map`). + +use serde_json::{Value, json}; + +use crate::commands::CommandSpec; +use crate::presets::styles::StylePreset; +use crate::presets::{Group, find, unique_name}; +use crate::{EngineError, Result, Session}; +use photocraft_io::asl_map::{self, AslStyle}; + +fn bad(cmd: &str, msg: impl Into) -> EngineError { + EngineError::BadParams { cmd: cmd.into(), msg: msg.into() } +} + +fn always(_: &Session) -> std::result::Result<(), String> { + Ok(()) +} + +fn has_styles(s: &Session) -> std::result::Result<(), String> { + if s.presets.styles.iter().any(|g| !g.items.is_empty()) { Ok(()) } else { Err("no styles".into()) } +} + +const IMPORT: &str = "style.presets.importAsl"; +const EXPORT: &str = "style.presets.exportAsl"; + +fn import(s: &mut Session, p: &Value) -> Result { + let (bytes, stem) = crate::preset_import_cmds::file_bytes(p, IMPORT, ".asl file")?; + let group = match p.get("group") { + Some(v) => v.as_str().map(str::trim).filter(|g| !g.is_empty()).ok_or_else(|| bad(IMPORT, "`group` must be a non-empty string"))?.to_string(), + None if !stem.trim().is_empty() => stem.trim().to_string(), + None => "Imported Styles".to_string(), + }; + let replace = match p.get("replace") { + None => true, + Some(v) => v.as_bool().ok_or_else(|| bad(IMPORT, "`replace` must be a boolean"))?, + }; + let imp = asl_map::read_asl(&bytes).map_err(|e| bad(IMPORT, e))?; + if imp.styles.is_empty() { + return Err(bad(IMPORT, "the file holds no styles")); + } + // Everything is checked: change the library. + let mut pattern_ids = Vec::new(); + for pat in imp.patterns { + pattern_ids.push(pat.id.clone()); + match s.patterns.items.iter_mut().find(|q| q.id == pat.id) { + Some(q) => *q = pat, + None => s.patterns.items.push(pat), + } + } + let styles = &mut s.presets.styles; + if replace { + styles.retain(|g| g.name != group); + } + let gi = match styles.iter().position(|g| g.name == group) { + Some(i) => i, + None => { + styles.push(Group::new(&group, Vec::new())); + styles.len() - 1 + } + }; + let mut names = Vec::with_capacity(imp.styles.len()); + for st in imp.styles { + // Agents address styles by name: keep names unique across the library. + let name = unique_name(styles, &st.name); + names.push(name.clone()); + let preset = StylePreset { name, effects: st.effects, blend: st.blend, fill_opacity: st.fill_opacity, opacity: st.opacity }; + if let Some(g) = styles.get_mut(gi) { + g.items.push(preset); + } + } + s.presets_changed(); + Ok(json!({"group": group, "imported": names, "count": names.len(), "patterns": pattern_ids, "warnings": imp.warnings})) +} + +fn export(s: &mut Session, p: &Value) -> Result { + let group = match p.get("group") { + None => None, + Some(v) => Some(v.as_str().ok_or_else(|| bad(EXPORT, "`group` must be a string"))?), + }; + let chosen: Vec = match p.get("styles") { + Some(v) => { + let list = v.as_array().ok_or_else(|| bad(EXPORT, "`styles` must be a list of style names"))?; + list.iter() + .map(|n| { + let name = n.as_str().ok_or_else(|| bad(EXPORT, "`styles` must be a list of style names"))?; + let (gi, ii) = find(&s.presets.styles, name, group).ok_or_else(|| bad(EXPORT, format!("no style \"{name}\" (see style.presets.list)")))?; + s.presets.styles.get(gi).and_then(|g| g.items.get(ii)).cloned().ok_or_else(|| bad(EXPORT, format!("no style \"{name}\""))) + }) + .collect::>()? + } + None => match group { + Some(g) => s.presets.styles.iter().find(|x| x.name == g).ok_or_else(|| bad(EXPORT, format!("no style group \"{g}\"")))?.items.clone(), + None => s.presets.styles.iter().flat_map(|g| g.items.iter().cloned()).collect(), + }, + }; + if chosen.is_empty() { + return Err(bad(EXPORT, "no styles to export")); + } + // The patterns the styles use, from the open document or the library. + let all_fx: Vec = chosen.iter().flat_map(|st| st.effects.iter().cloned()).collect(); + let mut patterns: Vec = Vec::new(); + let mut warnings = Vec::new(); + for (name, id) in asl_map::referenced_patterns(&all_fx) { + let key = if id.is_empty() { &name } else { &id }; + match crate::pattern_cmds::resolve(s, key).filter(|_| !key.is_empty()) { + Some(pat) if !patterns.iter().any(|q| q.id == pat.id) => patterns.push(pat), + Some(_) => {} + None => warnings.push(format!("pattern \"{}\" was not found and is not included", if name.is_empty() { &id } else { &name })), + } + } + let styles: Vec = chosen + .iter() + .map(|st| AslStyle { name: st.name.clone(), effects: st.effects.clone(), blend: st.blend, opacity: st.opacity, fill_opacity: st.fill_opacity }) + .collect(); + let bytes = asl_map::write_asl(&styles, &patterns).map_err(|e| bad(EXPORT, e))?; + let mut out = json!({"count": styles.len(), "bytes": bytes.len(), "patterns": patterns.len(), "warnings": warnings}); + match p.get("path") { + Some(v) => { + let path = v.as_str().filter(|x| !x.trim().is_empty()).ok_or_else(|| bad(EXPORT, "`path` must be a non-empty string"))?; + crate::file_cmds::write_file(path, &bytes)?; + out["path"] = json!(path); + } + None => out["data"] = json!(photocraft_paint::tile::b64_encode(&bytes)), + } + Ok(out) +} + +/// `.asl` command specs. +pub fn specs() -> Vec { + vec![ + CommandSpec { + id: IMPORT, + label: "Import Styles…", + menu: &[], + shortcut: None, + params: r##"{"path":".asl file"?,"data":base64 bytes?,"group":string?=file name,"replace":bool=true (replace a group of the same name)} → {group, imported, count, patterns (ids added to the pattern library), warnings}"##, + enabled: always, + run: import, + journal: true, + }, + CommandSpec { + id: EXPORT, + label: "Export Styles…", + menu: &[], + shortcut: None, + params: r##"{"group":name? (only that group),"styles":[names]? (only these),"path":".asl file"? (else the bytes come back as base64 `data`)} → {count, bytes, patterns, warnings, path|data}"##, + enabled: has_styles, + run: export, + journal: true, + }, + ] +} + +#[cfg(test)] +mod tests { + use super::*; + use photocraft_paint::tile::{b64_decode, b64_encode}; + + fn session() -> Session { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 16, "height": 16})).unwrap(); + s.execute("layer.new.layer", json!({})).unwrap(); + s + } + + #[test] + fn export_then_import_round_trips_a_group() { + let mut s = session(); + let before = s.presets.styles.clone(); + let r = s.execute(EXPORT, json!({"group": "Text Effects"})).unwrap(); + let n = before.iter().find(|g| g.name == "Text Effects").unwrap().items.len(); + assert_eq!(r["count"], n); + let data = r["data"].as_str().unwrap().to_string(); + let r = s.execute(IMPORT, json!({"data": data, "group": "Back"})).unwrap(); + assert_eq!(r["count"], n); + let back = s.presets.styles.iter().find(|g| g.name == "Back").unwrap().items.clone(); + let orig = &before.iter().find(|g| g.name == "Text Effects").unwrap().items; + for (a, b) in back.iter().zip(orig) { + // Names stay unique across the library: "Gold" comes back as "Gold 2". + assert!(a.name.starts_with(&b.name), "{} vs {}", a.name, b.name); + assert_eq!(a.effects.len(), b.effects.len(), "{}", b.name); + assert_eq!(a.fill_opacity, b.fill_opacity, "{}", b.name); + } + // The imported copy applies like the original. + s.execute("style.presets.apply", json!({"preset": back[0].name})).unwrap(); + let fx = &s.active().unwrap().doc.layers.last().unwrap().effects.items; + assert_eq!(fx.len(), orig[0].effects.len()); + // Re-import replaces the group instead of adding another. + let groups = s.presets.styles.len(); + s.execute(IMPORT, json!({"data": data, "group": "Back"})).unwrap(); + assert_eq!(s.presets.styles.len(), groups); + } + + #[test] + fn blending_options_survive_and_apply() { + let mut s = session(); + let id = s.active().unwrap().active_layer.unwrap(); + s.execute("layer.layerStyle.blendingOptions", json!({"layer": id.0, "opacity": 40, "blend": "multiply", "fillOpacity": 30})).unwrap(); + let l = s.active().unwrap().doc.layer(id).unwrap().clone(); + assert_eq!(l.blend, photocraft_color::BlendMode::Multiply); + s.execute("style.presets.new", json!({"name": "Blended", "group": "Mine", "layer": id.0})).unwrap(); + let data = s.execute(EXPORT, json!({"styles": ["Blended"]})).unwrap()["data"].as_str().unwrap().to_string(); + s.execute(IMPORT, json!({"data": data, "group": "Again"})).unwrap(); + let st = s.presets.styles.iter().find(|g| g.name == "Again").unwrap().items[0].clone(); + assert_eq!(st.blend, Some(l.blend)); + assert!((st.opacity.unwrap() - l.opacity).abs() < 1e-4); + assert!((st.fill_opacity.unwrap() - l.fill_opacity).abs() < 1e-4); + // Applying it to a fresh layer sets the blending options. + s.execute("layer.new.layer", json!({})).unwrap(); + let fresh = s.active().unwrap().active_layer.unwrap(); + s.execute("style.presets.apply", json!({"preset": st.name, "layer": fresh.0})).unwrap(); + let f = s.active().unwrap().doc.layer(fresh).unwrap(); + assert_eq!(f.blend, l.blend); + assert!((f.opacity - l.opacity).abs() < 1e-4); + } + + #[test] + fn embedded_patterns_reach_the_library_and_the_document() { + let mut s = session(); + let pat = s.patterns.items[0].clone(); + let fx = crate::layer_style::effect_from_params("patternOverlay", &json!({"pattern": pat.id})).unwrap(); + let (fx, _) = crate::pattern_cmds::resolve_effect(&s, fx).unwrap(); + let mut renamed = pat.clone(); + renamed.id = "asl-test-pattern".into(); + renamed.name = "Asl Test".into(); + let fx = match fx { + photocraft_doc::Effect::PatternOverlay { common, scale, angle, link, phase, .. } => { + photocraft_doc::Effect::PatternOverlay { common, name: renamed.name.clone(), id: renamed.id.clone(), scale, angle, link, phase } + } + other => other, + }; + let style = AslStyle { name: "Pat".into(), effects: vec![fx], blend: None, opacity: None, fill_opacity: None }; + let bytes = asl_map::write_asl(&[style], std::slice::from_ref(&renamed)).unwrap(); + let r = s.execute(IMPORT, json!({"data": b64_encode(&bytes), "group": "Pats"})).unwrap(); + assert_eq!(r["patterns"], json!(["asl-test-pattern"])); + assert!(s.patterns.items.iter().any(|p| p.id == "asl-test-pattern")); + s.execute("style.presets.apply", json!({"preset": "Pat", "group": "Pats"})).unwrap(); + assert!(s.active().unwrap().doc.patterns.iter().any(|p| p.id == "asl-test-pattern")); + // Export embeds it again. + let r = s.execute(EXPORT, json!({"group": "Pats"})).unwrap(); + assert_eq!(r["patterns"], 1); + let back = asl_map::read_asl(&b64_decode(r["data"].as_str().unwrap()).unwrap()).unwrap(); + assert_eq!(back.patterns.len(), 1); + } + + #[test] + fn files_on_disk() { + let mut s = session(); + let dir = std::env::temp_dir().join(format!("pc-asl-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let path = dir.join("My Styles.asl"); + let r = s.execute(EXPORT, json!({"group": "Basics", "path": path.to_string_lossy()})).unwrap(); + assert!(r.get("data").is_none()); + let r = s.execute(IMPORT, json!({"path": path.to_string_lossy()})).unwrap(); + assert_eq!(r["group"], "My Styles"); + std::fs::remove_dir_all(&dir).ok(); + } + + #[test] + fn bad_params_fail_gracefully_and_change_nothing() { + let mut s = session(); + let good = s.execute(EXPORT, json!({"group": "Basics"})).unwrap()["data"].as_str().unwrap().to_string(); + let raw = b64_decode(&good).unwrap(); + let styles = s.presets.styles.clone(); + let pats = s.patterns.items.len(); + let empty = b64_encode(&asl_map::write_asl(&[], &[]).unwrap()); + for p in [ + json!({}), + json!({"path": ""}), + json!({"path": "/nonexistent/styles.asl"}), + json!({"data": 42}), + json!({"data": "%%%not base64"}), + json!({"data": ""}), + json!({"data": b64_encode(b"8BPS\0\x01junk")}), + json!({"data": b64_encode(&raw[..raw.len() / 2])}), + json!({"data": empty}), + json!({"data": good, "group": 5}), + json!({"data": good, "group": " "}), + json!({"data": good, "replace": "yes"}), + ] { + assert!(s.execute(IMPORT, p.clone()).is_err(), "{p}"); + } + assert_eq!(s.presets.styles, styles); + assert_eq!(s.patterns.items.len(), pats); + for p in [ + json!({"group": "No Such Group"}), + json!({"group": 7}), + json!({"styles": "Gold"}), + json!({"styles": [3]}), + json!({"styles": ["Nope"]}), + json!({"styles": []}), + json!({"path": 9}), + json!({"path": " "}), + ] { + assert!(s.execute(EXPORT, p.clone()).is_err(), "{p}"); + } + s.presets.styles.clear(); + assert!(s.execute(EXPORT, json!({})).is_err()); + } +} diff --git a/crates/io/src/asl_map.rs b/crates/io/src/asl_map.rs new file mode 100644 index 0000000000..7c254099a9 --- /dev/null +++ b/crates/io/src/asl_map.rs @@ -0,0 +1,372 @@ +//! Layer style libraries (`.asl`) ⇄ PhotoCraft styles. +//! +//! The container is parsed by [`photocraft_psd::asl`]. Each style's `Lefx` is the same effects +//! tree as a layer's `lfx2` block ([`crate::effects_map`]); `blendOptions` ("Include Layer +//! Blending Options") carries the blend mode, opacity and fill opacity; the file's patterns feed +//! the styles' Pattern Overlays, pattern strokes and bevel textures. +//! +//! What PhotoCraft doesn't model (an effect kind it doesn't know, advanced blending keys, an +//! effects scale other than 100 %) is left out with a warning naming the style, and the rest of +//! the file still imports. + +use std::collections::BTreeSet; + +use photocraft_color::BlendMode; +use photocraft_doc::{Effect, FxPaint, Pattern}; +use photocraft_psd::asl::{self, AslFile}; +use photocraft_psd::descriptor::{Descriptor, Value}; + +use crate::blocks::{enum_of, get_desc, num}; +use crate::effects_map::{blend_from_id, blend_value, effects_descriptor, effects_from_descriptor, is_known_effects_key}; +use crate::pattern_map::{from_psd, to_psd}; + +/// One style as PhotoCraft keeps it. +#[derive(Clone, Debug, PartialEq)] +pub struct AslStyle { + /// Unique within the file (empty names get "Style N", repeats get "Name 2"). + pub name: String, + /// The effects (switched off when the style's effects were). + pub effects: Vec, + /// Blending options, when the style was saved with them. + pub blend: Option, + /// 0..1. + pub opacity: Option, + /// 0..1. + pub fill_opacity: Option, +} + +/// The result of reading a library. +#[derive(Clone, Debug, Default, PartialEq)] +pub struct AslImport { + pub styles: Vec, + /// Patterns embedded in the file. + pub patterns: Vec, + /// What was left out, for the user. + pub warnings: Vec, +} + +/// Patterns an effect list refers to: `(name, id)` in first-use order, without repeats. +pub fn referenced_patterns(effects: &[Effect]) -> Vec<(String, String)> { + let mut out: Vec<(String, String)> = Vec::new(); + let mut push = |name: &str, id: &str| { + if !out.iter().any(|(n, i)| if id.is_empty() { n == name } else { i == id }) { + out.push((name.to_string(), id.to_string())); + } + }; + for e in effects { + match e { + Effect::PatternOverlay { name, id, .. } => push(name, id), + Effect::Stroke(s) => { + if let FxPaint::Pattern { name, id, .. } = &s.paint { + push(name, id); + } + } + Effect::BevelEmboss(b) => { + if let Some(t) = &b.texture { + push(&t.name, &t.id); + } + } + _ => {} + } + } + out +} + +fn pct(d: &Descriptor, key: &str) -> Option { + num(d.get(key)).filter(|v| v.is_finite()).map(|v| (v as f32 / 100.0).clamp(0.0, 1.0)) +} + +fn unique(name: &str, taken: &[String]) -> String { + let free = |n: &str| !taken.iter().any(|t| t.eq_ignore_ascii_case(n)); + if free(name) { + return name.to_string(); + } + (2..).map(|i| format!("{name} {i}")).find(|n| free(n)).unwrap_or_else(|| name.to_string()) +} + +/// Reads an `.asl` style library. +pub fn read_asl(bytes: &[u8]) -> Result { + let file = asl::parse(bytes).map_err(|e| format!("not a readable style library (.asl): {e}"))?; + let mut out = AslImport { patterns: file.patterns.iter().filter_map(from_psd).collect(), ..Default::default() }; + if let Some(e) = &file.pattern_error { + out.warnings.push(format!("the file's patterns could not be read and were skipped ({e})")); + } + let skipped_patterns = file.patterns.len().saturating_sub(out.patterns.len()); + if skipped_patterns > 0 { + out.warnings.push(format!("{skipped_patterns} empty or unreadable patterns were skipped")); + } + let mut taken: Vec = Vec::new(); + let mut missing: BTreeSet = BTreeSet::new(); + for (i, s) in file.styles.iter().enumerate() { + let base = if s.name.trim().is_empty() { format!("Style {}", i + 1) } else { s.name.trim().to_string() }; + let name = unique(&base, &taken); + taken.push(name.clone()); + let mut style = AslStyle { name: name.clone(), effects: Vec::new(), blend: None, opacity: None, fill_opacity: None }; + let mut left_out: Vec = Vec::new(); + if let Some(fx) = get_desc(&s.style, "Lefx") { + let (master, mut effects) = effects_from_descriptor(fx); + if !master { + effects.iter_mut().for_each(|e| e.set_enabled(false)); + } + for (k, _) in &fx.items { + if !is_known_effects_key(k.as_bytes()) { + left_out.push(String::from_utf8_lossy(k.as_bytes()).trim().to_string()); + } + } + if let Some(scale) = num(fx.get("Scl ")).filter(|v| v.is_finite() && (v - 100.0).abs() > 0.01) { + left_out.push(format!("effects scale {scale:.0} %")); + } + style.effects = effects; + } + if let Some(b) = get_desc(&s.style, "blendOptions") { + style.blend = enum_of(b, "Md ").and_then(blend_from_id); + style.opacity = pct(b, "Opct"); + style.fill_opacity = pct(b, "fillOpacity"); + for (k, _) in &b.items { + if !matches!(k.as_bytes(), b"Md " | b"Opct" | b"fillOpacity") { + left_out.push(format!("blending option {}", String::from_utf8_lossy(k.as_bytes()).trim())); + } + } + } + for (pname, pid) in referenced_patterns(&style.effects) { + if !out.patterns.iter().any(|p| if pid.is_empty() { p.name == pname } else { p.id == pid }) { + missing.insert(if pname.is_empty() { pid } else { pname }); + } + } + if !left_out.is_empty() { + out.warnings.push(format!("\"{name}\": left out {}", left_out.join(", "))); + } + out.styles.push(style); + } + if !missing.is_empty() { + let list: Vec = missing.into_iter().collect(); + out.warnings.push(format!("patterns not in the file (they must be in the pattern library to render): {}", list.join(", "))); + } + Ok(out) +} + +/// A stable UUID-shaped id for a style (Photoshop gives every style one). +fn style_id(index: usize, name: &str) -> String { + // FNV-1a over the name, mixed with the index: deterministic output for deterministic tests. + let mut h: u128 = 0x6c62_272e_07bb_0142_62b8_2175_6295_c58d; + for b in name.bytes().chain(index.to_le_bytes()) { + h ^= u128::from(b); + h = h.wrapping_mul(0x0000_0000_0100_0000_0000_0000_0000_013b); + } + let x = format!("{h:032x}"); + let p = |a: usize, b: usize| x.get(a..b).unwrap_or("0"); + format!("{}-{}-{}-{}-{}", p(0, 8), p(8, 12), p(12, 16), p(16, 20), p(20, 32)) +} + +/// Writes styles (and the patterns their effects use) as an `.asl` style library. +pub fn write_asl(styles: &[AslStyle], patterns: &[Pattern]) -> Result, String> { + let pct = |v: f32| Value::UnitFloat { unit: *b"#Prc", value: f64::from(v.clamp(0.0, 1.0)) * 100.0 }; + let file = AslFile { + patterns: patterns.iter().map(to_psd).collect(), + pattern_error: None, + styles: styles + .iter() + .enumerate() + .map(|(i, s)| { + let mut d = Descriptor::new("Styl") + .with("documentMode", Value::Descriptor(Descriptor::new("documentMode"))) + .with("Lefx", Value::Descriptor(effects_descriptor(true, &s.effects))); + if s.blend.is_some() || s.opacity.is_some() || s.fill_opacity.is_some() { + d = d.with( + "blendOptions", + Value::Descriptor( + Descriptor::new("blendOptions") + .with("Md ", blend_value(s.blend.unwrap_or(BlendMode::Normal))) + .with("Opct", pct(s.opacity.unwrap_or(1.0))) + .with("fillOpacity", pct(s.fill_opacity.unwrap_or(1.0))), + ), + ); + } + asl::AslStyle { name: s.name.clone(), id: style_id(i, &s.name), style: d } + }) + .collect(), + }; + asl::write(&file).map_err(|e| e.to_string()) +} + +#[cfg(test)] +mod tests { + use super::*; + use photocraft_color::{Color, ColorMode, PixelFormat, SampleType}; + use photocraft_doc::{BevelTexture, FxCommon, StrokePosition}; + use photocraft_psd::descriptor::{Id, UnicodeString}; + use photocraft_raster::Surface; + + fn pattern(id: &str, s: SampleType) -> Pattern { + let fmt = PixelFormat::new(ColorMode::Rgb, s, true); + let mut surf = Surface::new(fmt); + for y in 0..3 { + for x in 0..4 { + surf.write_pixel(x, y, &[x as f32 / 4.0, y as f32 / 3.0, 0.5, 1.0]); + } + } + let mut p = Pattern::new("Grid", surf, 4, 3); + p.id = id.into(); + p + } + + /// Every effect kind with its descriptor defaults (the reader fills in what's absent). + fn defaults() -> Vec { + let d = |k: &str| Value::Descriptor(Descriptor::new(k)); + let lefx = Descriptor::new("null") + .with("DrSh", d("DrSh")) + .with("IrSh", d("IrSh")) + .with("OrGl", d("OrGl")) + .with("IrGl", d("IrGl")) + .with("ebbl", d("ebbl")) + .with("ChFX", d("ChFX")) + .with("SoFi", d("SoFi")) + .with("GrFl", d("GrFl")) + .with("FrFX", d("FrFX")); + effects_from_descriptor(&lefx).1 + } + + fn styles() -> Vec { + let mut fx = defaults(); + assert_eq!(fx.len(), 9); + for e in &mut fx { + match e { + Effect::DropShadow(s) => (s.distance, s.size, s.color) = (7.0, 9.0, Color::rgb(0.2, 0.1, 0.0)), + Effect::Stroke(s) => (s.size, s.position, s.paint) = (4.0, StrokePosition::Inside, FxPaint::Color(Color::rgb(0.0, 0.0, 1.0))), + Effect::ColorOverlay { common, color } => (*common, *color) = (FxCommon::new(BlendMode::Multiply, 0.5), Color::rgb(1.0, 0.5, 0.0)), + _ => {} + } + } + let mut bevel = defaults().into_iter().find(|e| matches!(e, Effect::BevelEmboss(_))).unwrap(); + if let Effect::BevelEmboss(b) = &mut bevel { + b.size = 6.0; + b.texture = Some(BevelTexture { name: "Grid".into(), id: "pat-2".into(), scale: 0.5, depth: 1.0, invert: false, link: true, phase: (0.0, 0.0) }); + } + vec![ + AslStyle { name: "Gold".into(), effects: fx, blend: Some(BlendMode::Screen), opacity: Some(0.8), fill_opacity: Some(0.25) }, + AslStyle { + name: "Textured".into(), + effects: vec![ + bevel, + Effect::PatternOverlay { + common: FxCommon { enabled: true, blend: BlendMode::Normal, opacity: 1.0 }, + name: "Grid".into(), + id: "pat-1".into(), + scale: 2.0, + angle: 0.0, + link: true, + phase: (0.0, 0.0), + }, + ], + blend: None, + opacity: None, + fill_opacity: None, + }, + ] + } + + #[test] + fn round_trip_keeps_effects_blending_and_patterns() { + let pats = vec![pattern("pat-1", SampleType::U8), pattern("pat-2", SampleType::U16)]; + let bytes = write_asl(&styles(), &pats).unwrap(); + let back = read_asl(&bytes).unwrap(); + assert!(back.warnings.is_empty(), "{:?}", back.warnings); + assert_eq!(back.patterns, pats); + assert_eq!(back.styles.len(), 2); + let (a, b) = (&back.styles[0], &styles()[0]); + assert_eq!((a.blend, a.opacity, a.fill_opacity), (b.blend, b.opacity, b.fill_opacity)); + // Effects go through the same descriptor writer and reader as PSD `lfx2`. + let via_lfx2 = |fx: &[Effect]| effects_from_descriptor(&effects_descriptor(true, fx)).1; + for (x, y) in back.styles.iter().zip(styles()) { + assert_eq!(x.name, y.name); + assert_eq!(x.effects, via_lfx2(&y.effects)); + assert_eq!(x.effects.len(), y.effects.len()); + } + assert_eq!(referenced_patterns(&back.styles[1].effects), vec![("Grid".to_string(), "pat-2".to_string()), ("Grid".to_string(), "pat-1".to_string())]); + } + + /// A library as Photoshop lays it out, built by hand from descriptors. + fn synthetic(lefx: Descriptor, blend: Option, names: &[&str]) -> Vec { + let mut style = Descriptor::new("Styl").with("documentMode", Value::Descriptor(Descriptor::new("documentMode"))).with("Lefx", Value::Descriptor(lefx)); + if let Some(b) = blend { + style = style.with("blendOptions", Value::Descriptor(b)); + } + let file = AslFile { + patterns: vec![], + pattern_error: None, + styles: names.iter().map(|n| asl::AslStyle { name: (*n).into(), id: "x".into(), style: style.clone() }).collect(), + }; + asl::write(&file).unwrap() + } + + #[test] + fn blend_options_names_and_warnings() { + let en = |t: &str, v: &str| Value::Enumerated { type_id: Id::new(t), value: Id::new(v) }; + let pc = |v: f64| Value::UnitFloat { unit: *b"#Prc", value: v }; + let lefx = Descriptor::new("null") + .with("Scl ", pc(100.0)) + .with("masterFXSwitch", Value::Boolean(false)) + .with( + "SoFi", + Value::Descriptor(Descriptor::new("SoFi").with("enab", Value::Boolean(true)).with("Md ", en("BlnM", "Nrml")).with("Opct", pc(100.0)).with( + "Clr ", + Value::Descriptor( + Descriptor::new("RGBC").with("Rd ", Value::Double(255.0)).with("Grn ", Value::Double(0.0)).with("Bl ", Value::Double(0.0)), + ), + )), + ) + .with("futureFX", Value::Descriptor(Descriptor::new("futureFX"))); + let blend = Descriptor::new("blendOptions") + .with("Md ", en("BlnM", "multiply")) + .with("Opct", pc(40.0)) + .with("fillOpacity", pc(0.0)) + .with("knockout", Value::Integer(1)); + let bytes = synthetic(lefx, Some(blend), &["Red", "", "red", " "]); + let imp = read_asl(&bytes).unwrap(); + let names: Vec<&str> = imp.styles.iter().map(|s| s.name.as_str()).collect(); + assert_eq!(names, ["Red", "Style 2", "red 2", "Style 4"]); + let s = &imp.styles[0]; + assert_eq!((s.blend, s.opacity, s.fill_opacity), (Some(BlendMode::Multiply), Some(0.4), Some(0.0))); + assert_eq!(s.effects.len(), 1); + // The style's effects were switched off. + assert!(!s.effects[0].enabled()); + assert!(imp.warnings.iter().any(|w| w.contains("futureFX") && w.contains("knockout")), "{:?}", imp.warnings); + } + + #[test] + fn missing_patterns_are_reported() { + let po = Descriptor::new("patternFill").with("enab", Value::Boolean(true)).with( + "Ptrn", + Value::Descriptor( + Descriptor::new("Ptrn").with("Nm ", Value::Text(UnicodeString::new_nul("Bubbles"))).with("Idnt", Value::Text(UnicodeString::new_nul("b-1"))), + ), + ); + let bytes = synthetic(Descriptor::new("null").with("patternFill", Value::Descriptor(po)), None, &["P"]); + let imp = read_asl(&bytes).unwrap(); + assert_eq!(imp.styles[0].effects.len(), 1); + assert_eq!(imp.styles[0].blend, None); + assert!(imp.warnings.iter().any(|w| w.contains("Bubbles")), "{:?}", imp.warnings); + } + + #[test] + fn hostile_bytes_are_errors() { + let bytes = write_asl(&styles(), &[pattern("pat-1", SampleType::U8)]).unwrap(); + for cut in 0..bytes.len() { + assert!(read_asl(&bytes[..cut]).is_err(), "cut {cut}"); + } + for i in 0..bytes.len() { + let mut c = bytes.clone(); + c[i] ^= 0xa5; + let _ = read_asl(&c); + } + assert!(read_asl(b"").is_err()); + assert!(read_asl(&photocraft_psd::grd::write(&[])).is_err()); + } + + #[test] + fn style_ids_are_uuid_shaped() { + let id = style_id(3, "Gold"); + assert_eq!(id.len(), 36); + assert_ne!(id, style_id(4, "Gold")); + } +} diff --git a/crates/io/src/effects_map.rs b/crates/io/src/effects_map.rs index 00815e2c83..bbeed5b5ee 100644 --- a/crates/io/src/effects_map.rs +++ b/crates/io/src/effects_map.rs @@ -85,7 +85,7 @@ pub(crate) fn blend_long_value(m: BlendMode) -> Value { Value::Enumerated { type_id: Id::new("BlnM"), value: Id::new(n) } } -fn blend_value(m: BlendMode) -> Value { +pub(crate) fn blend_value(m: BlendMode) -> Value { let n = BLEND_NAMES.iter().find(|(b, _)| *b == m).map_or("Nrml", |(_, n)| n); Value::Enumerated { type_id: Id::new("BlnM"), value: Id::new(n) } } @@ -301,7 +301,19 @@ const KINDS: [(&str, &str); 10] = [ /// Parses `lfx2` block data: `(master switch, effects)`. pub fn parse_lfx2(data: &[u8]) -> Option<(bool, Vec)> { let (vd, _) = VersionedDescriptor::parse_prefix(data.get(4..)?).ok()?; - let d = vd.descriptor; + Some(effects_from_descriptor(&vd.descriptor)) +} + +/// Keys of an effects descriptor (`lfx2`, a style library's `Lefx`) that +/// [`effects_from_descriptor`] reads, or that carry no effect of their own. +pub fn is_known_effects_key(key: &[u8]) -> bool { + KINDS.iter().any(|(single, multi)| single.as_bytes() == key || (!multi.is_empty() && multi.as_bytes() == key)) + || matches!(key, b"masterFXSwitch" | b"Scl " | b"numModifyingFX") +} + +/// The effects of an effects descriptor (the body of `lfx2`, a style library's `Lefx`): +/// `(master switch, effects)`. +pub fn effects_from_descriptor(d: &Descriptor) -> (bool, Vec) { let master = !matches!(d.get("masterFXSwitch"), Some(Value::Boolean(false))); let mut out = Vec::new(); for (single, multi) in KINDS { @@ -317,7 +329,7 @@ pub fn parse_lfx2(data: &[u8]) -> Option<(bool, Vec)> { } } _ => { - if let Some(x) = get_desc(&d, single) + if let Some(x) = get_desc(d, single) && let Some(e) = parse_one(single, x) { out.push(e); @@ -325,7 +337,7 @@ pub fn parse_lfx2(data: &[u8]) -> Option<(bool, Vec)> { } } } - Some((master, out)) + (master, out) } fn unit(u: &[u8; 4], v: f32) -> Value { @@ -511,6 +523,13 @@ fn write_one(e: &Effect) -> (&'static str, Descriptor) { /// Serializes effects as `lfx2` block data. pub fn write_lfx2(master: bool, items: &[Effect]) -> Vec { + let mut out = 0u32.to_be_bytes().to_vec(); + out.extend(VersionedDescriptor::new(effects_descriptor(master, items)).to_bytes()); + out +} + +/// Effects as an effects descriptor (the body of `lfx2`, a style library's `Lefx`). +pub fn effects_descriptor(master: bool, items: &[Effect]) -> Descriptor { let mut d = Descriptor::new("null").with("Scl ", unit(b"#Prc", 100.0)).with("masterFXSwitch", Value::Boolean(master)); for (single, multi) in KINDS { let of_kind: Vec = items.iter().map(write_one).filter(|(k, _)| *k == single).map(|(_, d)| d).collect(); @@ -522,9 +541,7 @@ pub fn write_lfx2(master: bool, items: &[Effect]) -> Vec { _ => d = d.with(single, Value::Descriptor(of_kind.into_iter().next().unwrap_or_default())), } } - let mut out = 0u32.to_be_bytes().to_vec(); - out.extend(VersionedDescriptor::new(d).to_bytes()); - out + d } fn fixed(v: u32) -> f32 { diff --git a/crates/io/src/lib.rs b/crates/io/src/lib.rs index 0a9acbc19a..533fd75b47 100644 --- a/crates/io/src/lib.rs +++ b/crates/io/src/lib.rs @@ -35,6 +35,7 @@ pub mod abr_map; mod adjust_map; pub mod affinity; pub mod annotations_map; +pub mod asl_map; pub mod blocks; mod channel_map; pub mod comps_map; diff --git a/crates/psd/fuzz/Cargo.toml b/crates/psd/fuzz/Cargo.toml index 86f0f51c0c..260fb16c1c 100644 --- a/crates/psd/fuzz/Cargo.toml +++ b/crates/psd/fuzz/Cargo.toml @@ -36,6 +36,13 @@ test = false doc = false bench = false +[[bin]] +name = "asl" +path = "fuzz_targets/asl.rs" +test = false +doc = false +bench = false + [[bin]] name = "image_source_data" path = "fuzz_targets/image_source_data.rs" diff --git a/crates/psd/fuzz/fuzz_targets/asl.rs b/crates/psd/fuzz/fuzz_targets/asl.rs new file mode 100644 index 0000000000..cbf2c9169c --- /dev/null +++ b/crates/psd/fuzz/fuzz_targets/asl.rs @@ -0,0 +1,15 @@ +//! Fuzz the `.asl` style library parser: any input must return `Ok` or `Err`, never panic, and +//! anything that parses must write back and parse to the same number of styles. +#![no_main] + +use libfuzzer_sys::fuzz_target; +use photocraft_psd::asl; + +fuzz_target!(|data: &[u8]| { + if let Ok(f) = asl::parse(data) + && let Ok(bytes) = asl::write(&f) + { + let back = asl::parse(&bytes).expect("a written library parses"); + assert_eq!(back.styles.len(), f.styles.len()); + } +}); diff --git a/crates/psd/src/asl.rs b/crates/psd/src/asl.rs new file mode 100644 index 0000000000..26cd27b9bc --- /dev/null +++ b/crates/psd/src/asl.rs @@ -0,0 +1,276 @@ +//! Photoshop layer style libraries (`.asl`, the Styles panel's Import Styles… / Export Styles…). +//! +//! Layout of a version 3 style library: +//! +//! ```text +//! file := u16 2, "8BSL", u16 3 (sub-version), +//! u32 pattern section length, patterns (the `Patt` block record format), +//! u32 style count, style × count +//! style := u32 length, then that many bytes: identity, style descriptor, zero padding +//! identity:= versioned descriptor (class `null`): `Nm ` name, `Idnt` id (Unicode strings) +//! style descriptor := versioned descriptor (class `Styl`): `documentMode`, `Lefx` (the same +//! tree as a layer's `lfx2` block), optional `blendOptions` (`Md `, `Opct`, +//! `fillOpacity`) +//! ``` +//! +//! The reader skips up to three padding bytes after each style record whatever its length says, +//! so it reads files whose record length counts the padding and files whose length does not. +//! The writer counts the padding in the record length, which reads correctly either way. +//! +//! Malformed input is an error, never a panic. A pattern section that doesn't decode is reported +//! in [`AslFile::pattern_error`] and skipped (its length is known), so the styles still load. + +use crate::descriptor::{Descriptor, UnicodeString, Value, VersionedDescriptor}; +use crate::error::{PsdError, Result}; +use crate::patterns::{PsdPattern, parse_pattern_block, write_pattern_block}; + +/// Most styles read from one file. +pub const MAX_STYLES: usize = 10_000; + +/// One style of a library. +#[derive(Debug, Clone, PartialEq)] +pub struct AslStyle { + /// The name shown in the Styles panel (may be empty or repeated). + pub name: String, + /// The style's unique id (usually a UUID). + pub id: String, + /// The style descriptor (class `Styl`): `Lefx`, `blendOptions`, `documentMode`. + pub style: Descriptor, +} + +/// A parsed style library. +#[derive(Debug, Clone, PartialEq, Default)] +pub struct AslFile { + /// Patterns embedded for the styles' Pattern Overlays, pattern strokes and bevel textures. + pub patterns: Vec, + /// Why the pattern section was skipped, if it didn't decode (read only). + pub pattern_error: Option, + /// Styles in file order. + pub styles: Vec, +} + +struct Rd<'a> { + b: &'a [u8], + p: usize, +} + +impl<'a> Rd<'a> { + fn take(&mut self, n: usize) -> Result<&'a [u8]> { + let end = self.p.checked_add(n).filter(|&e| e <= self.b.len()).ok_or(PsdError::UnexpectedEof { offset: self.p, needed: n })?; + let s = self.b.get(self.p..end).ok_or(PsdError::UnexpectedEof { offset: self.p, needed: n })?; + self.p = end; + Ok(s) + } + fn u16(&mut self) -> Result { + let b = self.take(2)?; + Ok(u16::from_be_bytes([b[0], b[1]])) + } + fn u32(&mut self) -> Result { + let b = self.take(4)?; + Ok(u32::from_be_bytes([b[0], b[1], b[2], b[3]])) + } + fn remaining(&self) -> usize { + self.b.len().saturating_sub(self.p) + } +} + +fn text(d: &Descriptor, key: &str) -> String { + match d.get(key) { + Some(Value::Text(t)) => t.to_string_lossy(), + _ => String::new(), + } +} + +fn read_style(body: &[u8]) -> Result { + let (identity, used) = VersionedDescriptor::parse_prefix(body)?; + let rest = body.get(used..).ok_or(PsdError::UnexpectedEof { offset: used, needed: 4 })?; + let (style, _) = VersionedDescriptor::parse_prefix(rest)?; + let id = &identity.descriptor; + Ok(AslStyle { name: text(id, "Nm "), id: text(id, "Idnt"), style: style.descriptor }) +} + +/// Parses an `.asl` style library. +pub fn parse(data: &[u8]) -> Result { + let mut r = Rd { b: data, p: 0 }; + let version = r.u16()?; + let sig = r.take(4)?; + if sig != b"8BSL" { + return Err(PsdError::InvalidSignature { expected: "8BSL", found: [sig[0], sig[1], sig[2], sig[3]] }); + } + let sub = r.u16()?; + if version != 2 || sub != 3 { + return Err(PsdError::Unsupported(format!("style library version {version}.{sub} (only 2.3, Photoshop 6 and later)"))); + } + let plen = r.u32()? as usize; + let section = r.take(plen)?; + let (patterns, pattern_error) = match parse_pattern_block(section) { + Ok(p) => (p, None), + Err(e) => (Vec::new(), Some(e.to_string())), + }; + let count = r.u32()? as usize; + // Every style needs at least its own length word. + if count > r.remaining() / 4 { + return Err(PsdError::invalid(format!("{count} styles cannot fit in the remaining {} bytes", r.remaining()))); + } + if count > MAX_STYLES { + return Err(PsdError::LimitExceeded("too many styles in one library")); + } + let mut styles = Vec::with_capacity(count); + for _ in 0..count { + let len = r.u32()? as usize; + let body = r.take(len)?; + styles.push(read_style(body)?); + let pad = (4 - len % 4) % 4; + r.p = r.p.saturating_add(pad).min(data.len()); + } + Ok(AslFile { patterns, pattern_error: pattern_error.filter(|_| !section.is_empty()), styles }) +} + +/// Writes a version 3 `.asl` style library. +pub fn write(file: &AslFile) -> Result> { + let mut out = Vec::new(); + out.extend_from_slice(&2u16.to_be_bytes()); + out.extend_from_slice(b"8BSL"); + out.extend_from_slice(&3u16.to_be_bytes()); + let patterns = write_pattern_block(&file.patterns)?; + let plen = u32::try_from(patterns.len()).map_err(|_| PsdError::LimitExceeded("pattern section larger than 4 GB"))?; + out.extend_from_slice(&plen.to_be_bytes()); + out.extend_from_slice(&patterns); + let count = u32::try_from(file.styles.len()).map_err(|_| PsdError::LimitExceeded("too many styles"))?; + out.extend_from_slice(&count.to_be_bytes()); + for s in &file.styles { + let identity = + Descriptor::new("null").with("Nm ", Value::Text(UnicodeString::new_nul(&s.name))).with("Idnt", Value::Text(UnicodeString::new_nul(&s.id))); + let mut body = VersionedDescriptor::new(identity).to_bytes(); + body.extend(VersionedDescriptor::new(s.style.clone()).to_bytes()); + body.resize(body.len().div_ceil(4) * 4, 0); + let len = u32::try_from(body.len()).map_err(|_| PsdError::LimitExceeded("style larger than 4 GB"))?; + out.extend_from_slice(&len.to_be_bytes()); + out.extend_from_slice(&body); + } + Ok(out) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::descriptor::Id; + + fn pattern() -> PsdPattern { + PsdPattern { + mode: 3, + width: 3, + height: 2, + name: "Dots".into(), + id: "a1b2".into(), + palette: None, + depth: 8, + channels: vec![vec![1, 2, 3, 4, 5, 6], vec![9; 6], vec![200; 6]], + alpha: None, + } + } + + fn style(name: &str) -> AslStyle { + let lefx = Descriptor::new("null").with("masterFXSwitch", Value::Boolean(true)).with( + "SoFi", + Value::Descriptor(Descriptor::new("SoFi").with("enab", Value::Boolean(true)).with("Opct", Value::UnitFloat { unit: *b"#Prc", value: 50.0 })), + ); + let blend = Descriptor::new("blendOptions") + .with("Md ", Value::Enumerated { type_id: Id::new("BlnM"), value: Id::new("Mltp") }) + .with("fillOpacity", Value::UnitFloat { unit: *b"#Prc", value: 25.0 }); + AslStyle { + name: name.into(), + id: format!("id-{name}"), + style: Descriptor::new("Styl") + .with("documentMode", Value::Descriptor(Descriptor::new("documentMode"))) + .with("Lefx", Value::Descriptor(lefx)) + .with("blendOptions", Value::Descriptor(blend)), + } + } + + fn sample() -> AslFile { + AslFile { patterns: vec![pattern()], pattern_error: None, styles: vec![style("Gold"), style(""), style("Ünïcode ✓")] } + } + + #[test] + fn round_trip() { + let f = sample(); + let b = write(&f).unwrap(); + assert_eq!(&b[..8], b"\0\x028BSL\0\x03"); + assert_eq!(b.len() % 4, 0); + assert_eq!(parse(&b).unwrap(), f); + let empty = AslFile::default(); + assert_eq!(parse(&write(&empty).unwrap()).unwrap(), empty); + } + + #[test] + fn record_lengths_without_padding_also_read() { + // A writer that leaves the padding out of each record length. + let f = sample(); + let mut out = write(&AslFile { styles: vec![], ..f.clone() }).unwrap(); + out.truncate(out.len() - 4); + out.extend_from_slice(&(f.styles.len() as u32).to_be_bytes()); + for s in &f.styles { + let identity = + Descriptor::new("null").with("Nm ", Value::Text(UnicodeString::new_nul(&s.name))).with("Idnt", Value::Text(UnicodeString::new_nul(&s.id))); + let mut body = VersionedDescriptor::new(identity).to_bytes(); + body.extend(VersionedDescriptor::new(s.style.clone()).to_bytes()); + body.push(7); // odd length + out.extend_from_slice(&(body.len() as u32).to_be_bytes()); + let pad = (4 - body.len() % 4) % 4; + out.extend_from_slice(&body); + out.extend(std::iter::repeat_n(0, pad)); + } + assert_eq!(parse(&out).unwrap().styles, f.styles); + } + + #[test] + fn bad_pattern_section_is_skipped() { + let mut b = write(&AslFile { patterns: vec![], pattern_error: None, styles: vec![style("A")] }).unwrap(); + // Replace the empty pattern section with 8 bytes of garbage. + let tail = b.split_off(12); + b.truncate(8); + b.extend_from_slice(&8u32.to_be_bytes()); + b.extend_from_slice(&[0, 0, 0, 4, 0xff, 0xff, 0xff, 0xff]); + b.extend(tail); + let f = parse(&b).unwrap(); + assert!(f.pattern_error.is_some()); + assert_eq!(f.styles.len(), 1); + } + + #[test] + fn hostile_input_errors() { + assert!(parse(b"").is_err()); + assert!(parse(b"\0\x028BSL\0\x02").is_err()); + assert!(parse(b"\0\x028BPS\0\x03").is_err()); + // A count far beyond the data. + let mut b = b"\0\x028BSL\0\x03\0\0\0\0".to_vec(); + b.extend_from_slice(&u32::MAX.to_be_bytes()); + assert!(parse(&b).is_err()); + // A pattern length beyond the data. + assert!(parse(b"\0\x028BSL\0\x03\xff\xff\xff\xff").is_err()); + let b = write(&sample()).unwrap(); + for cut in 0..b.len() { + assert!(parse(&b[..cut]).is_err(), "cut at {cut}"); + } + for i in 0..b.len() { + for x in [0x5a, 0xff, 0x01] { + let mut c = b.clone(); + c[i] ^= x; + let _ = parse(&c); + } + } + // Seeded random noise after a valid header. + let mut seed = 0x1234_5678u32; + for _ in 0..500 { + let mut c = b"\0\x028BSL\0\x03".to_vec(); + for _ in 0..(seed % 200) { + seed ^= seed << 13; + seed ^= seed >> 17; + seed ^= seed << 5; + c.push(seed as u8); + } + let _ = parse(&c); + } + } +} diff --git a/crates/psd/src/lib.rs b/crates/psd/src/lib.rs index 16d539b948..70ee913e72 100644 --- a/crates/psd/src/lib.rs +++ b/crates/psd/src/lib.rs @@ -43,6 +43,7 @@ pub mod abr; pub mod aco; pub mod ase; +pub mod asl; pub mod blend; pub mod builder; pub mod compression; diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index e7de3409af..b1f141b4d5 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -3665,3 +3665,9 @@ navigator Zoom Zvětšení Remove after each stroke Odstranit po každém tahu Apply the removal ({key}) Použít odstranění ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) Tahy k odstranění: {n} (Enter použije, Esc zruší) + Import Styles… Importovat styly… + Export Selected Styles… Exportovat vybrané styly… + Export Styles… Exportovat styly… + {file} is not a style library (.asl) {file} není knihovna stylů (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} Importován {n} styl ze souboru {file}|Importovány {n} styly ze souboru {file}|Importováno {n} stylů ze souboru {file} +@plural Exported {n} style to {file}|Exported {n} styles to {file} Exportován {n} styl do souboru {file}|Exportovány {n} styly do souboru {file}|Exportováno {n} stylů do souboru {file} diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index ac313154db..5d5dc303de 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -2691,3 +2691,9 @@ curves Smooth Glätten Remove after each stroke Nach jedem Strich entfernen Apply the removal ({key}) Entfernen anwenden ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) Striche zum Entfernen: {n} (Eingabe wendet an, Esc bricht ab) + Import Styles… Stile importieren… + Export Selected Styles… Ausgewählte Stile exportieren… + Export Styles… Stile exportieren… + {file} is not a style library (.asl) {file} ist keine Stilbibliothek (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} {n} Stil aus {file} importiert|{n} Stile aus {file} importiert +@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} Stil nach {file} exportiert|{n} Stile nach {file} exportiert diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index e5be105597..4b84f79722 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3749,3 +3749,9 @@ curves Smooth Εξομάλυνση Remove after each stroke Αφαίρεση μετά από κάθε πινελιά Apply the removal ({key}) Εφαρμογή της αφαίρεσης ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) Πινελιές προς αφαίρεση: {n} (Enter εφαρμόζει, Esc ακυρώνει) + Import Styles… Εισαγωγή στιλ… + Export Selected Styles… Εξαγωγή επιλεγμένων στιλ… + Export Styles… Εξαγωγή στιλ… + {file} is not a style library (.asl) Το {file} δεν είναι βιβλιοθήκη στιλ (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} Εισήχθη {n} στιλ από το {file}|Εισήχθησαν {n} στιλ από το {file} +@plural Exported {n} style to {file}|Exported {n} styles to {file} Εξήχθη {n} στιλ στο {file}|Εξήχθησαν {n} στιλ στο {file} diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index b986956544..843f0af201 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2732,3 +2732,9 @@ curves Smooth Suavizar Remove after each stroke Eliminar después de cada trazo Apply the removal ({key}) Aplicar la eliminación ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) Trazos por eliminar: {n} (Intro aplica, Esc cancela) + Import Styles… Importar estilos… + Export Selected Styles… Exportar estilos seleccionados… + Export Styles… Exportar estilos… + {file} is not a style library (.asl) {file} no es una biblioteca de estilos (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} Se importó {n} estilo de {file}|Se importaron {n} estilos de {file} +@plural Exported {n} style to {file}|Exported {n} styles to {file} Se exportó {n} estilo a {file}|Se exportaron {n} estilos a {file} diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index f426b28c56..7c9ac011a8 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -3052,3 +3052,9 @@ curves Smooth Lisser Remove after each stroke Supprimer après chaque trait Apply the removal ({key}) Appliquer la suppression ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) Traits à supprimer : {n} (Entrée applique, Échap annule) + Import Styles… Importer des styles… + Export Selected Styles… Exporter les styles sélectionnés… + Export Styles… Exporter les styles… + {file} is not a style library (.asl) {file} n’est pas une bibliothèque de styles (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} {n} style importé depuis {file}|{n} styles importés depuis {file} +@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} style exporté vers {file}|{n} styles exportés vers {file} diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 080e204aaa..0a130efdf8 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -43,6 +43,8 @@ @plural {n} step|{n} steps {n} lépés @plural {warning} (+{n} more brush preset warning)|{warning} (+{n} more brush preset warnings) {warning} (+{n} további figyelmeztetés az ecset-előbeállításokról) @plural {what} with {n} warning|{what} with {n} warnings {what} ({n} figyelmeztetés) +@plural Imported {n} style from {file}|Imported {n} styles from {file} {n} stílus importálva. Forrás: {file} +@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} stílus exportálva. Cél: {file} @id file.close Bezárás @id layer.layerMask.apply Alkalmazás @id edit.clear Kiürítés @@ -3970,3 +3972,7 @@ cameraRaw Yellow Sárga Transform On Drop Átalakítás elengedéskor Vanishing Point is not active Az Enyészpont nem aktív Vanishing Point: click four corners to create a plane Enyészpont: sík létrehozásához kattintson a négy sarokra + Import Styles… Stílusok importálása… + Export Selected Styles… Kijelölt stílusok exportálása… + Export Styles… Stílusok exportálása… + {file} is not a style library (.asl) {file} nem stíluskönyvtár (.asl) diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 420600cf3f..9cb9b3ed50 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -3039,3 +3039,9 @@ curves Smooth Haluskan Remove after each stroke Hapus setelah setiap goresan Apply the removal ({key}) Terapkan penghapusan ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) Goresan untuk dihapus: {n} (Enter menerapkan, Esc membatalkan) + Import Styles… Impor Gaya… + Export Selected Styles… Ekspor Gaya Terpilih… + Export Styles… Ekspor Gaya… + {file} is not a style library (.asl) {file} bukan pustaka gaya (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} {n} gaya diimpor dari {file} +@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} gaya diekspor ke {file} diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 410ab8f609..c527dc3735 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -4015,3 +4015,9 @@ navigator Zoom Zoom Remove after each stroke Rimuovi dopo ogni tratto Apply the removal ({key}) Applica la rimozione ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) Tratti da rimuovere: {n} (Invio applica, Esc annulla) + Import Styles… Importa stili… + Export Selected Styles… Esporta stili selezionati… + Export Styles… Esporta stili… + {file} is not a style library (.asl) {file} non è una libreria di stili (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} {n} stile importato da {file}|{n} stili importati da {file} +@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} stile esportato in {file}|{n} stili esportati in {file} diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 7e5e65a639..67e03eebba 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3661,3 +3661,9 @@ curves Smooth スムーズ Remove after each stroke ストロークごとに削除 Apply the removal ({key}) 削除を適用 ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) 削除するストローク: {n}(Enter で適用、Esc で取り消し) + Import Styles… スタイルを読み込み… + Export Selected Styles… 選択したスタイルを書き出し… + Export Styles… スタイルを書き出し… + {file} is not a style library (.asl) {file} はスタイルライブラリ (.asl) ではありません +@plural Imported {n} style from {file}|Imported {n} styles from {file} {file} からスタイル {n} 個を読み込みました +@plural Exported {n} style to {file}|Exported {n} styles to {file} {file} にスタイル {n} 個を書き出しました diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index f48633c2cb..d3fe30587f 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3221,3 +3221,9 @@ curves Smooth 매끄럽게 Remove after each stroke 획마다 제거 Apply the removal ({key}) 제거 적용 ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) 제거할 획: {n} (Enter 적용, Esc 취소) + Import Styles… 스타일 가져오기… + Export Selected Styles… 선택한 스타일 내보내기… + Export Styles… 스타일 내보내기… + {file} is not a style library (.asl) {file}은(는) 스타일 라이브러리(.asl)가 아닙니다 +@plural Imported {n} style from {file}|Imported {n} styles from {file} {file}에서 스타일 {n}개를 가져왔습니다 +@plural Exported {n} style to {file}|Exported {n} styles to {file} 스타일 {n}개를 {file}(으)로 내보냈습니다 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 3778a8a1de..dfa30438e8 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -3811,3 +3811,9 @@ curves Smooth Vloeiend maken Remove after each stroke Verwijderen na elke streek Apply the removal ({key}) Verwijdering toepassen ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) Streken om te verwijderen: {n} (Enter past toe, Esc annuleert) + Import Styles… Stijlen importeren… + Export Selected Styles… Geselecteerde stijlen exporteren… + Export Styles… Stijlen exporteren… + {file} is not a style library (.asl) {file} is geen stijlbibliotheek (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} {n} stijl geïmporteerd uit {file}|{n} stijlen geïmporteerd uit {file} +@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} stijl geëxporteerd naar {file}|{n} stijlen geëxporteerd naar {file} diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index ce9387b623..d40e8d702a 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3648,3 +3648,9 @@ curves Smooth Wygładź Remove after each stroke Usuwaj po każdym pociągnięciu Apply the removal ({key}) Zastosuj usuwanie ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) Pociągnięcia do usunięcia: {n} (Enter stosuje, Esc anuluje) + Import Styles… Importuj style… + Export Selected Styles… Eksportuj zaznaczone style… + Export Styles… Eksportuj style… + {file} is not a style library (.asl) {file} nie jest biblioteką stylów (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} Zaimportowano {n} styl z {file}|Zaimportowano {n} style z {file}|Zaimportowano {n} stylów z {file} +@plural Exported {n} style to {file}|Exported {n} styles to {file} Wyeksportowano {n} styl do {file}|Wyeksportowano {n} style do {file}|Wyeksportowano {n} stylów do {file} diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 92e9c238b1..30bc901ec4 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -3841,3 +3841,9 @@ layerLabel No Color Sem cor Remove after each stroke Remover após cada traço Apply the removal ({key}) Aplicar a remoção ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) Traços a remover: {n} (Enter aplica, Esc cancela) + Import Styles… Importar estilos… + Export Selected Styles… Exportar estilos selecionados… + Export Styles… Exportar estilos… + {file} is not a style library (.asl) {file} não é uma biblioteca de estilos (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} {n} estilo importado de {file}|{n} estilos importados de {file} +@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} estilo exportado para {file}|{n} estilos exportados para {file} diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 7e1d12bbb1..6f8c318fd7 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -2996,3 +2996,9 @@ curves Smooth Сгладить Remove after each stroke Удалять после каждого штриха Apply the removal ({key}) Применить удаление ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) Штрихов к удалению: {n} (Enter применяет, Esc отменяет) + Import Styles… Импортировать стили… + Export Selected Styles… Экспортировать выбранные стили… + Export Styles… Экспортировать стили… + {file} is not a style library (.asl) {file} не является библиотекой стилей (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} Импортирован {n} стиль из {file}|Импортировано {n} стиля из {file}|Импортировано {n} стилей из {file} +@plural Exported {n} style to {file}|Exported {n} styles to {file} Экспортирован {n} стиль в {file}|Экспортировано {n} стиля в {file}|Экспортировано {n} стилей в {file} diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 617ad81fd9..797f631f20 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -3782,3 +3782,9 @@ cameraData Lens Lens @plural {n} step|{n} steps {n} adım @plural {warning} (+{n} more brush preset warning)|{warning} (+{n} more brush preset warnings) {warning} (+{n} fırça ön ayarı uyarısı daha) @plural {what} with {n} warning|{what} with {n} warnings {what}, {n} uyarı ile +@plural Imported {n} style from {file}|Imported {n} styles from {file} {file} dosyasından {n} stil içe aktarıldı +@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} stil {file} dosyasına dışa aktarıldı + Import Styles… Stilleri İçe Aktar… + Export Selected Styles… Seçili Stilleri Dışa Aktar… + Export Styles… Stilleri Dışa Aktar… + {file} is not a style library (.asl) {file} bir stil kitaplığı değil (.asl) diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 11a4caa9cf..dae143facc 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3749,3 +3749,9 @@ curves Smooth Згладити Remove after each stroke Видаляти після кожного штриха Apply the removal ({key}) Застосувати видалення ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) Штрихів для видалення: {n} (Enter застосовує, Esc скасовує) + Import Styles… Імпортувати стилі… + Export Selected Styles… Експортувати вибрані стилі… + Export Styles… Експортувати стилі… + {file} is not a style library (.asl) {file} не є бібліотекою стилів (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} Імпортовано {n} стиль з {file}|Імпортовано {n} стилі з {file}|Імпортовано {n} стилів з {file} +@plural Exported {n} style to {file}|Exported {n} styles to {file} Експортовано {n} стиль до {file}|Експортовано {n} стилі до {file}|Експортовано {n} стилів до {file} diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index ca091c14d8..75d134ba16 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3535,3 +3535,9 @@ curves Smooth Làm mượt Remove after each stroke Xóa sau mỗi nét vẽ Apply the removal ({key}) Áp dụng việc xóa ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) Nét vẽ cần xóa: {n} (Enter áp dụng, Esc hủy) + Import Styles… Nhập kiểu… + Export Selected Styles… Xuất các kiểu đã chọn… + Export Styles… Xuất kiểu… + {file} is not a style library (.asl) {file} không phải là thư viện kiểu (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} Đã nhập {n} kiểu từ {file} +@plural Exported {n} style to {file}|Exported {n} styles to {file} Đã xuất {n} kiểu sang {file} diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index d0309166ce..91e10cdafc 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2656,3 +2656,9 @@ curves Smooth 平滑 Remove after each stroke 每次描边后移除 Apply the removal ({key}) 应用移除 ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) 待移除的描边:{n}(Enter 应用,Esc 取消) + Import Styles… 导入样式… + Export Selected Styles… 导出所选样式… + Export Styles… 导出样式… + {file} is not a style library (.asl) {file} 不是样式库 (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} 已从 {file} 导入 {n} 个样式 +@plural Exported {n} style to {file}|Exported {n} styles to {file} 已将 {n} 个样式导出到 {file} diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 8698dfc078..35b53ee6be 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2641,3 +2641,9 @@ curves Smooth 平滑 Remove after each stroke 每次描邊後移除 Apply the removal ({key}) 套用移除 ({key}) Strokes to remove: {n} (Enter applies, Esc cancels) 待移除的描邊:{n}(Enter 套用,Esc 取消) + Import Styles… 匯入樣式… + Export Selected Styles… 匯出所選樣式… + Export Styles… 匯出樣式… + {file} is not a style library (.asl) {file} 不是樣式庫 (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} 已從 {file} 匯入 {n} 個樣式 +@plural Exported {n} style to {file}|Exported {n} styles to {file} 已將 {n} 個樣式匯出至 {file} diff --git a/crates/ui-egui/src/preset_files_ui.rs b/crates/ui-egui/src/preset_files_ui.rs index e58961d9b5..58d72447a5 100644 --- a/crates/ui-egui/src/preset_files_ui.rs +++ b/crates/ui-egui/src/preset_files_ui.rs @@ -1,7 +1,8 @@ //! Preset files opened like documents (File › Open, drag-and-drop, the Brushes panel's //! Import Brushes…, the Preset Manager's Load…): Photoshop brushes (`.abr`) go to the brush //! library through `brush.presets.importAbr`, gradients (`.grd`) to the Gradients panel through -//! `gradient.presets.importGrd`, swatches (`.aco`, `.ase`) to the Swatches panel through +//! `gradient.presets.importGrd`, layer styles (`.asl`) to the Styles panel through +//! `style.presets.importAsl`, swatches (`.aco`, `.ase`) to the Swatches panel through //! `swatches.import`, keyboard shortcut sets (`.kys`) to Edit › Keyboard Shortcuts through //! [`crate::kys_import`], instead of opening as documents. @@ -13,7 +14,7 @@ use crate::PhotocraftApp; /// the Swatches panel through [`crate::swatches_ui::import_bytes`]). /// `.psp` is Photoshop's live `Keyboard Shortcuts.psp` (the same XML as a `.kys`); other `.psp` /// settings files are refused with a clear message. -pub const PRESET_EXTS: &[&str] = &["abr", "grd", "aco", "ase", "kys", "psp"]; +pub const PRESET_EXTS: &[&str] = &["abr", "grd", "asl", "aco", "ase", "kys", "psp"]; fn ext(name: &str) -> String { std::path::Path::new(name).extension().map(|e| e.to_string_lossy().to_ascii_lowercase()).unwrap_or_default() @@ -39,6 +40,7 @@ pub fn open(app: &mut PhotocraftApp, name: &str, bytes: &[u8]) -> Option ("brush.presets.importAbr", "brushes"), "grd" => ("gradient.presets.importGrd", "gradients"), + "asl" => ("style.presets.importAsl", "styles"), "aco" | "ase" => return Some(crate::swatches_ui::import_bytes(app, name, bytes, false).map(|_| ())), "kys" | "psp" => return Some(crate::kys_import::open_bytes(app, name, bytes).map(|_| ())), _ => return None, @@ -60,10 +62,10 @@ pub fn open(app: &mut PhotocraftApp, name: &str, bytes: &[u8]) -> Option = r.get("warnings").and_then(|w| serde_json::from_value(w.clone()).ok()).unwrap_or_default(); app.ui.status_error = false; - let (one, other) = if what == "brushes" { - ("Imported {n} brush from {file}", "Imported {n} brushes from {file}") - } else { - ("Imported {n} gradient from {file}", "Imported {n} gradients from {file}") + let (one, other) = match what { + "brushes" => ("Imported {n} brush from {file}", "Imported {n} brushes from {file}"), + "styles" => ("Imported {n} style from {file}", "Imported {n} styles from {file}"), + _ => ("Imported {n} gradient from {file}", "Imported {n} gradients from {file}"), }; let imported = crate::i18n::fmt(&crate::i18n::trn(crate::i18n::current(), n, one, other), &[("file", &stem)]); app.ui.status = match warnings.first() { @@ -78,6 +80,9 @@ pub fn open(app: &mut PhotocraftApp, name: &str, bytes: &[u8]) -> Option = None; + if ui.button(tl!("Import Styles…")).clicked() { + act = Some("import"); + } + if ui.add_enabled(selected.is_some(), egui::Button::new(tl!("Export Selected Styles…"))).clicked() { + act = Some("selected"); + } + if ui.add_enabled(any, egui::Button::new(tl!("Export Styles…"))).clicked() { + act = Some("all"); + } + let Some(a) = act else { return }; + ui.close(); + let r = match a { + "import" => app.pick_file_bytes_filtered(&["asl"], |app, name, bytes| match crate::preset_files_ui::open(app, &name, &bytes) { + Some(r) => r.map(|()| Value::Null), + None => Err(crate::i18n::fmt(tl!("{file} is not a style library (.asl)"), &[("file", &crate::file_open::display_name(&name))])), + }), + "selected" => match selected { + Some(name) => export_styles(app, json!({"styles": [name.clone()]}), &name), + None => Ok(Value::Null), + }, + _ => export_styles(app, json!({}), "Styles"), + }; + if let Err(e) = r + && e != "cancelled" + { + app.ui.status = e; + app.ui.status_error = true; + } +} + +/// Builds the `.asl` through `style.presets.exportAsl`, then asks where to save it. +fn export_styles(app: &mut PhotocraftApp, params: Value, suggested: &str) -> Result { + let r = app.run("style.presets.exportAsl", params)?; + let bytes = r["data"].as_str().and_then(photocraft_engine::paint::tile::b64_decode).ok_or("the export returned no data")?; + let n = r["count"].as_u64().unwrap_or(0); + let stem: String = suggested.chars().filter(|c| !matches!(c, '/' | '\\' | ':' | '*' | '?' | '"' | '<' | '>' | '|')).collect(); + let stem = if stem.trim().is_empty() { "Styles".to_string() } else { stem.trim().to_string() }; + app.pick_save(&format!("{stem}.asl"), move |app, path| { + let write = app.services.write.as_mut().ok_or("no writer configured")?; + write(&path, &bytes)?; + app.ui.status_error = false; + app.ui.status = crate::i18n::fmt( + &crate::i18n::trn(crate::i18n::current(), n, "Exported {n} style to {file}", "Exported {n} styles to {file}"), + &[("file", &crate::file_open::display_name(&path))], + ); + Ok(json!({"path": path, "count": n})) + }) +} + // ------------------------------------------------------------------ Shapes pub fn shapes_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) { diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 024d596f1e..402f0c702f 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File-format parity -> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-12 · **Change:** minor (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-12 · **Change:** minor (indexed BMP palette mode; `.asl` layer style libraries read and written; 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 @@ -131,7 +131,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings. | Keyboard shortcuts `.kys` | R/W | R | `engine/src/kys.rs` | | ICC profiles | R | R | Own CMS | | Actions `.atn` | R/W | no | AUTO-219-2 | -| Styles `.asl` | R/W | no | #1693 | +| Styles `.asl` | R/W | R/W | `psd/src/asl.rs`, `io/src/asl_map.rs`; Styles panel Import/Export Styles…, `style.presets.importAsl`/`exportAsl` (#1051) | | Contours `.shc`, custom shapes `.csh`, tool presets `.tpl` | R/W | no | FILE-215-15 | | Curves `.acv`, Levels `.alv`, other adjustment presets | R/W | not audited | | | C2PA Content Credentials | R/W | no | #1050 | @@ -141,6 +141,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings. | Date | Change | Summary | |---|---|---| | 2026-10-12 | minor | Palette BMPs open in Indexed Color mode (#3802) | +| 2026-10-12 | minor | `.asl` layer style libraries: import and export with embedded patterns and blending options | | 2026-10-12 | minor | Save writes a JPEG at its own estimated quality and a WebP lossy or lossless as opened (#2399) | | 2026-10-11 | minor | D5100 image area and fitted-look preservation in Camera Raw tuning | | 2026-10-10 | major | First version: Photoshop 2026 27.11.0's formats from its bundle, against our codecs; Affinity notes moved from `roadmap.md` | diff --git a/docs/gaps.md b/docs/gaps.md index 2ceba09952..528d984e23 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where PhotoCraft falls short of Photoshop -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-11 · **Change:** minor (G8: Character panel OpenType buttons landed, TYPE-218-5 stays partial; G8: triple-, quadruple- and five-click type selection landed, TYPE-218-8 done; Czech UI localization evidence added to G13; G14: D5100 crop and Camera Raw tuning validation) · **Target:** Adobe Photoshop 2026 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (G10: `.asl` style libraries landed; G8: Character panel OpenType buttons landed, TYPE-218-5 stays partial; G8: triple-, quadruple- and five-click type selection landed, TYPE-218-8 done; Czech UI localization evidence added to G13; G14: D5100 crop and Camera Raw tuning validation) · **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 @@ -183,8 +183,8 @@ what an agent can't finish alone. - **Missing:** JPEG Options dialog (FILE-215-19), Photoshop PDF read and write and multi-page PDF (FILE-215-10, #2541), AVIF read (#463) and default-build AVIF write, JPEG XL, JPEG 2000 (#1047), DPX/Cineon (#1049), DICOM, EPS/DCS, PCX, Pixar, IFF, WBMP, MPO/JPS, PICT, Scitex CT, Photoshop - Raw; layered TIFF extra alpha channels (FILE-215-7); spot plates (FILE-215-17); .atn, .asl, - .shc, .csh presets (FILE-215-15); TGA/PNG alpha channels on open (#2225); C2PA (#1050). + Raw; layered TIFF extra alpha channels (FILE-215-7); spot plates (FILE-215-17); .atn, + .shc, .csh presets (.asl landed 2026-10-12) (FILE-215-15); TGA/PNG alpha channels on open (#2225); C2PA (#1050). - **Detail:** [`file-format-parity.md`](file-format-parity.md). - **Estimate:** 120–220 h. @@ -225,6 +225,7 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| +| 2026-10-12 | minor | G10: `.asl` layer style library import and export landed | | 2026-10-11 | minor | D5100 image area and Camera Raw tuning validation; G14 remains open | | 2026-10-11 | minor | G13: Czech dynamic UI text localized; engine messages and native review remain open | | 2026-10-11 | minor | G8: triple/quadruple/five-click type selection done (TYPE-218-8, #3493); Type evidence recounted | From 7db426981d8af28e9e02b7ef9f3dcd2de63f7d6c Mon Sep 17 00:00:00 2001 From: vangel76 Date: Mon, 12 Oct 2026 18:40:45 +0200 Subject: [PATCH 034/649] i18n: hu/tr translations for vanishing point clone strings Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/i18n/hu.tsv | 2 ++ crates/ui-egui/src/i18n/tr.tsv | 2 ++ 2 files changed, 4 insertions(+) diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 080e204aaa..8c30877039 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -3954,6 +3954,8 @@ cameraRaw Yellow Sárga Draw to modify the curve Rajzoljon a görbe módosításához Edit points to modify the curve Szerkessze a pontokat a görbe módosításához Fix the red plane first: its corners must form a convex quad Először javítsa a piros síkot: sarkainak konvex négyszöget kell alkotniuk + Alt-click a plane to set the clone source Alt-kattintás egy síkra a klónforrás beállításához + Too many clone strokes: apply Vanishing Point first Túl sok klónvonás: először alkalmazza az Enyészpontot Grid Size: Rácsméret: Light Blue Világoskék Light Red Világospiros diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 617ad81fd9..16202a85ed 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -3751,6 +3751,8 @@ cameraData Lens Lens Draw to modify the curve Eğriyi değiştirmek için çiz Edit points to modify the curve Eğriyi değiştirmek için noktaları düzenle Fix the red plane first: its corners must form a convex quad Önce kırmızı düzlemi düzeltin: köşeleri dışbükey bir dörtgen oluşturmalı + Alt-click a plane to set the clone source Klon kaynağını ayarlamak için bir düzleme Alt+tıklayın + Too many clone strokes: apply Vanishing Point first Çok fazla klon darbesi: önce Kaybolma Noktası'nı uygulayın Grid Size: Izgara Boyutu: Light Blue Açık Mavi Light Gray Açık Gri From 1a0e9972218927fa0f8829245eeb04fe5f91130c Mon Sep 17 00:00:00 2001 From: itsF4LCON <107556180+itsF4LCON@users.noreply.github.com> Date: Mon, 12 Oct 2026 21:15:29 +0200 Subject: [PATCH 035/649] i18n: New Snapshot dialog strings in the Hungarian and Turkish catalogs (#2966) --- crates/ui-egui/src/i18n/hu.tsv | 3 +++ crates/ui-egui/src/i18n/tr.tsv | 3 +++ 2 files changed, 6 insertions(+) diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 080e204aaa..39fdea0e2f 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -3820,6 +3820,9 @@ cameraRaw Yellow Sárga New document… ⌘N Új dokumentum… ⌘N New Layer from Brush Új réteg ecsetből New Path Új útvonal + From: Forrás: + Full Document Teljes dokumentum + Merged Layers Egyesített rétegek New Snapshot Új pillanatkép New Video Group Új videócsoport Newspaper Újságpapír diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 617ad81fd9..49cce672fb 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -2639,6 +2639,9 @@ cameraRaw Color Renk Color indicates Renk şunu gösterir: Create Snapshot Anlık Görüntü Oluştur Delete Snapshot Anlık Görüntüyü Sil + From: Kaynak: + Full Document Tam Belge + Merged Layers Birleştirilmiş Katmanlar New Snapshot Yeni Anlık Görüntü Snapshot 1 Anlık Görüntü 1 Nonlinear History Doğrusal Olmayan Geçmiş From dc8d468b6fedebd26b89872bc41d5817d808e240 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Mon, 12 Oct 2026 23:49:53 +0200 Subject: [PATCH 036/649] docs: regenerate scorecard after merging main Co-Authored-By: Claude Opus 5.5 --- docs/scorecard.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/scorecard.md b/docs/scorecard.md index 2d653afce6..745886de04 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -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) | 6 | 13 | 8 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 | -| [Tools](#tools) | 28 | 14 | 1 | | +| [Tools](#tools) | 26 | 15 | 2 | | | [Workspace and UI](#workspace-and-ui) | 13 | 5 | 5 | settings that do nothing: 27 of 156 (target 0) | | [Type](#type) | 4 | 2 | 3 | | | [Automation](#automation) | 4 | 2 | 5 | 631 of 631 menu items live (100.0%) | @@ -133,11 +133,11 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t | TOOL-213-1 | Pencil tool: aliased 1 px painting, square pixel-aligned cursor | done | [#213](https://github.com/storytold/photocraft/issues/213) | Tool::Pencil (B group): live aliased strokes on the pixel grid, square cursor, Auto Erase; pencil_tests.rs | | TOOL-213-2 | Mixer Brush tool on the toolbar | done | [#213](https://github.com/storytold/photocraft/issues/213) | Tool::MixerBrush in the Brush (B) flyout; Wet/Load/Mix/Flow/Sample All Layers options, command/control dispatch and selection-clipping tests | | TOOL-213-3 | Patch tool with a live preview of the patched area | done | [#213](https://github.com/storytold/photocraft/issues/213) | paint.patch (retouch_cmds/patch.rs, source/destination) + Tool::Patch (J group: lasso, then drag the selection); the drag shows the heal live (patch_preview.rs, coarse colour fit: 1000x1000 in 52 ms) | -| TOOL-213-4 | Content-Aware Move tool reusing inpaint completion | partial | [#213](https://github.com/storytold/photocraft/issues/213) | paint.contentAwareMove (retouch_cmds/content_aware_move.rs: move/extend, Structure 1-7, Color 0-10, Sample All Layers, Transform On Drop's scaleX/scaleY/rotate; background job) + Tool::ContentAwareMove (J group: lasso, then drag; Transform On Drop puts a scale/rotate box on the dropped patch, cam_transform.rs: Enter commits as one step, Esc cancels). Missing: a live preview of the result (the drag and the box show the outline only) | +| TOOL-213-4 | Content-Aware Move tool reusing inpaint completion | partial | [#213](https://github.com/storytold/photocraft/issues/213) | paint.contentAwareMove (retouch_cmds/content_aware_move.rs: move/extend, Structure 1-7, Color 0-10, Sample All Layers; background job) + Tool::ContentAwareMove (J group: lasso, then drag). Missing: Transform On Drop, a live preview of the result (the drag shows the outline only) | | TOOL-213-5 | Painting a type/shape/smart/fill layer offers to rasterize, then continues the stroke | done | [#213](https://github.com/storytold/photocraft/issues/213) | rasterize_prompt.rs: OK rasterizes then paints (two history states), Cancel does nothing; drivable via ui.dialog.confirm | | TOOL-213-6 | Fill dialog: contents, blend, opacity, preserve transparency; remembered; Shift+Backspace | done | [#213](https://github.com/storytold/photocraft/issues/213) | fill_ui.rs dialog over edit.fill (fill_cmds.rs): all contents, mode, opacity, preserve; remembered in prefs; Shift+F5 / Shift+Backspace | | TOOL-213-7 | Live stroke preview for every brush-based retouch tool | partial | [#213](https://github.com/storytold/photocraft/issues/213) | Live (canvas.rs strokes_live): Brush, Pencil, Eraser, Blur, Sharpen, Smudge, Dodge, Burn, Sponge, Clone Stamp, Healing Brush, History Brush (#1026, #1040); the release commits the live stroke's pixels (P32). Not yet live: Spot Healing Brush, Mixer Brush, Background Eraser, Pattern Stamp | -| TOOL-213-8 | Clone Source: W/H link, drawn overlay (opacity/blend/clip/auto-hide), Alt target cursor | partial | [#213](https://github.com/storytold/photocraft/issues/213) | Clone Source overlay drawn with opacity, inversion, circular clipping, auto-hide and the Normal/Darken/Lighten/Difference blend against the image under the brush (canvas.rs draw_clone_preview, clone_source::overlay_blend); W/H link (cloneSource.set linked, panel chain button, #3298); custom-tip clipping remains missing | +| TOOL-213-8 | Clone Source: W/H link, drawn overlay (opacity/blend/clip/auto-hide), Alt target cursor | partial | [#213](https://github.com/storytold/photocraft/issues/213) | Clone Source overlay drawn with opacity, inversion, circular clipping and auto-hide; W/H link, custom-tip clipping and overlay blend modes remain missing | | TOOL-213-9 | Eyedropper comparison ring (new colour above, current below) while sampling | done | [#213](https://github.com/storytold/photocraft/issues/213) | eyedropper_ring (canvas.rs): the sampled colour on the upper arc, the foreground below, drawn for the Eyedropper and Alt-sampling while the button is held; the Precise-cursor preference keeps the crosshair | | TOOL-213-10 | Ctrl+Alt drag resizes brush size/hardness with an on-canvas readout | done | [#213](https://github.com/storytold/photocraft/issues/213) | brush_resize.rs (#297, #370): Alt+right-drag, or Control+Option-drag on macOS (Control+Alt everywhere), sets diameter horizontally and hardness vertically, circle plus Diameter/Hardness readout, one coalesced tools.setBrush, no paint or history; 9 tests there | | TOOL-213-11 | Editable pressure curve, global and per control | partial | [#213](https://github.com/storytold/photocraft/issues/213) | Global: Preferences › Tools › Pressure Curve (prefs tools.pressureCurve; monotone cubic, engine prefs::PressureCurve; applied to every pen sample in ui-egui stylus.rs before any brush; editor pressure_curve_ui.rs with Linear/Soft/Hard presets). Missing: per-control curves (each brush dynamic's own response to pressure, tilt, rotation) | @@ -150,15 +150,15 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t | 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-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) | -| TOOL-214-7 | Content-Aware Scale through the Free Transform box with a live proxy preview | done | [#214](https://github.com/storytold/photocraft/issues/214) | Edit > Content-Aware Scale opens a scale-only Free Transform box (cas_transform.rs) with Amount, Protect and Protect Skin Tones in the options bar; edit.contentAwareScale carves a 384 px copy in the background for the live preview, and Enter runs it with the box's size and x/y as one step (#3096) | +| TOOL-214-6 | Puppet Warp mesh follows the object outline (constrained triangulation) | missing | [#214](https://github.com/storytold/photocraft/issues/214) | algo/puppet.rs:136 builds a block-grid mesh | +| TOOL-214-7 | Content-Aware Scale through the Free Transform box with a live proxy preview | partial | [#214](https://github.com/storytold/photocraft/issues/214) | edit.contentAwareScale (edit_menu_cmds.rs:899) behind a parameter dialog | | TOOL-214-8 | A measured ruler angle prefills Image Rotation > Arbitrary (0.01 deg) | done | [#214](https://github.com/storytold/photocraft/issues/214) | analysis_ui.rs: image.rotation.arbitrary opens seeded with the ruler angle and the direction that straightens it; arbitrary_rotation_starts_at_the_ruler_angle checks 5.7106 deg within 1e-3 and cw/ccw for three measured lines | | TOOL-214-9 | Crop: W x H x Resolution with units, saved crop presets, Straighten in the options bar | done | [#214](https://github.com/storytold/photocraft/issues/214) | Ratio dropdown and fields, Straighten (TOOL-214-21); W x H x Resolution with units, built-in size presets and Front Image (crop_size.rs, image.crop targetWidth/targetHeight/resolution, #2443); New / Delete Crop Preset save and delete crop tool presets (crop_presets.rs, tool.presets.* with tool crop, persisted with the preferences) | | TOOL-214-10 | Pen: Alt breaks a handle, Shift 45 deg, Ctrl direct-selects, Backspace, close-drag handle | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Ctrl/Cmd = Direct Selection and Alt = Convert Point on existing paths (direct_select.rs, #790); Backspace/Delete retracts the last point while drawing (#1466); Alt during a drag breaks the handle pair, Alt-drag turns the last anchor's outgoing handle alone, and dragging on the first anchor closes with that anchor's handles (vector_ui.rs, #3306); no Shift 45 deg | -| TOOL-214-11 | Stroke Path dialog: pick any brush-based tool, Simulate Pressure | done | [#214](https://github.com/storytold/photocraft/issues/214) | path.stroke tool: Brush, Pencil, Eraser and every other brush-based tool (Background Eraser, Clone/Pattern Stamp, Healing/Spot Healing Brush, History Brush, Blur, Sharpen, Smudge, Dodge, Burn, Sponge, Color Replacement, Mixer Brush: their paint.* command along the path, one step) plus simulatePressure (taper both ends); Stroke Path dialog from the Pen menu, the Paths panel menu and Alt-click on its Stroke button (#2978) | +| TOOL-214-11 | Stroke Path dialog: pick any brush-based tool, Simulate Pressure | partial | [#214](https://github.com/storytold/photocraft/issues/214) | path.stroke brush, pencil, eraser (vector_cmds.rs:1170); brush-only button, no dialog | | TOOL-214-12 | Shapes: on-canvas corner radius handles, shape feather, selection to shape with tolerance | partial | [#214](https://github.com/storytold/photocraft/issues/214) | select.convertToShape with tolerance (vector_cmds.rs:1256); radius as a field only | | TOOL-214-13 | Mask Properties: Density and Feather controls | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Vector-mask density/feather in the engine (vector_cmds.rs:948); no UI controls | -| TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | partial | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15); on-canvas plane editor (vp_ui.rs: Create/Edit Plane, edge nodes, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane on OK); clone stamp, marquee and tear-off planes in the window still missing | +| TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | done | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15); on-canvas window (vp_ui.rs: Create/Edit Plane, edge nodes, Ctrl/Cmd-drag tear-off planes with depth and Alt-drag angle, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane, Stamp tool cloning in perspective with live preview, all applied on OK as one step); the window's Marquee tool and the Stamp's Heal modes are still missing | | TOOL-214-15 | Content-Aware Fill workspace: paint the sampling area, preview, rotate/scale/mirror, new layer | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Engine sampling auto, rect, custom (edit_menu_cmds.rs:324); generic dialog | | TOOL-214-16 | Liquify: redo (Cmd+Shift+Z) | done | [#214](https://github.com/storytold/photocraft/issues/214) | liquify_ui.rs supports bounded redo through Cmd+Shift+Z and the control channel; new strokes clear redo | | TOOL-213-17 | Red Eye tool: click a pupil to neutralize the red reflection | done | [#213](https://github.com/storytold/photocraft/issues/213) | paint.redEye (redeye_cmds.rs) + Tool::RedEye in the J flyout; Pupil Size and Darken Amount; catchlights kept; a miss is an error | From e494464a8c5316bf782c5161093d952e1c459741 Mon Sep 17 00:00:00 2001 From: Jeremy Yao Date: Mon, 12 Oct 2026 19:00:50 -0400 Subject: [PATCH 037/649] Interface: Animation Effects follows the system setting, or is on or off MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Preferences › Interface › Animation effects replaces the Enable animations checkbox with three choices: Use system setting (the default), On and Off (interface.animationEffects: system, on, off). A saved enableAnimations: false loads as off; prefs.set interface.enableAnimations is now an unknown preference. Use system setting reads the OS through the new Services::system_animations (no answer keeps animations on): - Windows: UISettings.AnimationsEnabled (Settings › Accessibility › Visual effects › Animation effects), a safe WinRT call through the windows crate already in Cargo.lock. - macOS: NSWorkspace.accessibilityDisplayShouldReduceMotion. - Linux: the settings portal (reduced-motion, then GNOME enable-animations and KDE AnimationDurationFactor), followed live through SettingChanged. - Linux without the portal, FreeBSD and the other BSDs: kdeglobals, gsettings (GNOME, MATE) and GTK settings.ini, read at start-up and when the window regains focus. - Web: prefers-reduced-motion. Off now also stops the mouse wheel glide. egui spreads a wheel notch over about 0.2 s with no switch, which the old checkbox never touched (only fades and scroll_to). wheel_nav::unsmooth, called from PhotocraftApp::logic, replaces the frame's smoothed scroll with what its wheel events add up to; trackpad gestures with begin and end phases are left to egui. The label and its choices are translated in all 19 catalogs, replacing the Enable animations entry. The scorecard row UI-217-10 note is updated. The Windows reader was run on a machine with Animation effects off. The macOS and Linux code is compile-checked and linted by cross-target builds only, and FreeBSD not at all locally (a variant without the portal module lints clean). Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 1 + apps/photocraft-web/Cargo.toml | 2 +- apps/photocraft-web/src/web.rs | 6 + apps/photocraft/Cargo.toml | 13 +- apps/photocraft/src/animations.rs | 444 ++++++++++++++++++++++++++++ apps/photocraft/src/appearance.rs | 3 +- apps/photocraft/src/main.rs | 1 + apps/photocraft/src/services.rs | 1 + crates/engine/src/prefs.rs | 23 +- crates/engine/src/prefs/tests.rs | 40 +++ crates/ui-egui/src/i18n/cs.tsv | 3 +- crates/ui-egui/src/i18n/de.tsv | 4 +- crates/ui-egui/src/i18n/el.tsv | 3 +- crates/ui-egui/src/i18n/es.tsv | 4 +- crates/ui-egui/src/i18n/fr.tsv | 4 +- crates/ui-egui/src/i18n/hu.tsv | 3 +- crates/ui-egui/src/i18n/id.tsv | 4 +- crates/ui-egui/src/i18n/it.tsv | 3 +- crates/ui-egui/src/i18n/ja.tsv | 4 +- crates/ui-egui/src/i18n/ko.tsv | 4 +- crates/ui-egui/src/i18n/nl.tsv | 3 +- crates/ui-egui/src/i18n/pl.tsv | 4 +- crates/ui-egui/src/i18n/pt-br.tsv | 3 +- crates/ui-egui/src/i18n/ru.tsv | 4 +- crates/ui-egui/src/i18n/tr.tsv | 3 +- crates/ui-egui/src/i18n/uk.tsv | 4 +- crates/ui-egui/src/i18n/vi.tsv | 4 +- crates/ui-egui/src/i18n/zh-hans.tsv | 4 +- crates/ui-egui/src/i18n/zh-hant.tsv | 4 +- crates/ui-egui/src/input_tests.rs | 25 ++ crates/ui-egui/src/lib.rs | 13 + crates/ui-egui/src/prefs_ui.rs | 117 +++++++- crates/ui-egui/src/wheel_nav.rs | 228 +++++++++++++- docs/scorecard.md | 2 +- scorecard/ui.toml | 2 +- 35 files changed, 940 insertions(+), 50 deletions(-) create mode 100644 apps/photocraft/src/animations.rs diff --git a/Cargo.lock b/Cargo.lock index a0499ca1c8..2cf28244f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4223,6 +4223,7 @@ dependencies = [ "rfd", "ron", "serde_json", + "windows", "winit", "winresource", "winsafe", diff --git a/apps/photocraft-web/Cargo.toml b/apps/photocraft-web/Cargo.toml index a4ded64181..8653b5878b 100644 --- a/apps/photocraft-web/Cargo.toml +++ b/apps/photocraft-web/Cargo.toml @@ -34,7 +34,7 @@ rfd = { workspace = true } wasm-bindgen = "0.2" wasm-bindgen-futures = "0.4" js-sys = "0.3" -web-sys = { version = "0.3", features = ["Window", "Document", "Element", "HtmlElement", "HtmlCanvasElement", "HtmlAnchorElement", "Blob", "BlobPropertyBag", "Url", "Location", "CssStyleDeclaration", "Storage", "Event", "EventTarget", "MouseEvent", "PointerEvent", "BeforeUnloadEvent", "AbortController", "AbortSignal", "DomException", "Response", "IdbFactory", "IdbOpenDbRequest", "IdbDatabase", "IdbRequest", "IdbTransaction", "IdbTransactionMode", "IdbObjectStore", "IdbCursor", "IdbCursorWithValue", "RequestInit", "Navigator"] } +web-sys = { version = "0.3", features = ["Window", "Document", "Element", "HtmlElement", "HtmlCanvasElement", "HtmlAnchorElement", "Blob", "BlobPropertyBag", "Url", "Location", "CssStyleDeclaration", "Storage", "Event", "EventTarget", "MouseEvent", "PointerEvent", "BeforeUnloadEvent", "AbortController", "AbortSignal", "DomException", "Response", "IdbFactory", "IdbOpenDbRequest", "IdbDatabase", "IdbRequest", "IdbTransaction", "IdbTransactionMode", "IdbObjectStore", "IdbCursor", "IdbCursorWithValue", "RequestInit", "Navigator", "MediaQueryList"] } [dev-dependencies] serde_json = { workspace = true } diff --git a/apps/photocraft-web/src/web.rs b/apps/photocraft-web/src/web.rs index 16781e42bb..6012c0658d 100644 --- a/apps/photocraft-web/src/web.rs +++ b/apps/photocraft-web/src/web.rs @@ -395,6 +395,12 @@ fn services(inbox: Inbox) -> Services { // Preferences live in the browser's localStorage. load_prefs: Some(Box::new(|| local_storage()?.get_item(PREFS_KEY).ok().flatten())), save_prefs: Some(Box::new(|text: &str| local_storage().ok_or("no localStorage")?.set_item(PREFS_KEY, text).map_err(|e| format!("{e:?}")))), + // Animation Effects › Use System Setting: the browser passes on the system's setting. One + // live query, so `matches` follows a change. + system_animations: Some({ + let reduce = web_sys::window().and_then(|w| w.match_media("(prefers-reduced-motion: reduce)").ok().flatten()); + Box::new(move |_| reduce.as_ref().map(|query| !query.matches())) + }), ..Default::default() } } diff --git a/apps/photocraft/Cargo.toml b/apps/photocraft/Cargo.toml index 57b537931c..556f32feec 100644 --- a/apps/photocraft/Cargo.toml +++ b/apps/photocraft/Cargo.toml @@ -49,12 +49,13 @@ core-graphics2 = { version = "=0.6.1", default-features = false, features = ["di # registers the handler (Objective-C interop needs unsafe, which our workspace forbids) behind a # safe API. Pinned exactly: review the diff before bumping. fmv-macos-events = "=0.1.0" -# Safe AppKit calls only: turn off AppKit's title bar dragging (mac_window.rs) and find where the -# pointer is when files are dropped (cursor.rs; winit 0.30 drops carry no position). Already in -# Cargo.lock (winit, photocraft-tablet); pinned exactly to the same versions. +# Safe AppKit calls only: turn off AppKit's title bar dragging (mac_window.rs), find where the +# pointer is when files are dropped (cursor.rs; winit 0.30 drops carry no position) and read +# Reduce Motion (animations.rs: NSWorkspace, NSAccessibility). Already in Cargo.lock (winit, +# photocraft-tablet); pinned exactly to the same versions. objc2 = "=0.6.4" objc2-foundation = { version = "=0.3.2", default-features = false, features = ["std", "NSArray", "NSEnumerator", "NSGeometry"] } -objc2-app-kit = { version = "=0.3.2", default-features = false, features = ["std", "NSApplication", "NSApplicationScripting", "NSEvent", "NSResponder", "NSView", "NSWindow"] } +objc2-app-kit = { version = "=0.3.2", default-features = false, features = ["std", "NSAccessibility", "NSApplication", "NSApplicationScripting", "NSEvent", "NSResponder", "NSView", "NSWindow", "NSWorkspace"] } # The macOS menu bar (mac_menu.rs): a standalone native menu crate (from the tauri-apps org, but # not Tauri: no webview, no JS), AppKit menus behind a safe API (no GTK with default features off). Pinned exactly: review the diff before bumping. muda = { version = "=0.21.1", default-features = false } @@ -82,6 +83,10 @@ winit = { version = "=0.30.13", default-features = false, features = ["x11"] } # Safe Windows screen-capture bindings; Linux uses the pure-Rust X11 client/portal. xcap = "=0.9.8" winsafe = { version = "=0.0.29", default-features = false, features = ["user"] } +# The system's Animation effects setting (animations.rs): `UISettings.AnimationsEnabled`, a safe +# WinRT call (winsafe's `SystemParametersInfo` is unsafe). Already in Cargo.lock (wgpu, xcap, +# accesskit); pinned exactly to the same version. +windows = { version = "=0.62.2", default-features = false, features = ["std", "UI_ViewManagement"] } # tests/mac_menu_appkit.rs: reads AppKit's menu bar back and sends it real key events. [target.'cfg(target_os = "macos")'.dev-dependencies] diff --git a/apps/photocraft/src/animations.rs b/apps/photocraft/src/animations.rs new file mode 100644 index 0000000000..62d138e756 --- /dev/null +++ b/apps/photocraft/src/animations.rs @@ -0,0 +1,444 @@ +//! The operating system's animation setting, for Preferences › Interface › Animation Effects › +//! Use System Setting (`Services::system_animations`). +//! +//! - **Windows**: Settings › Accessibility › Visual effects › Animation effects, through +//! `UISettings.AnimationsEnabled`. It answers for the session, so a Remote Desktop connection +//! that turns animations off counts too. +//! - **macOS**: System Settings › Accessibility › Display › Reduce motion +//! (`NSWorkspace.accessibilityDisplayShouldReduceMotion`). +//! - **Linux**: the settings portal: `reduced-motion`, then GNOME's `enable-animations` and KDE's +//! `AnimationDurationFactor` as the portal passes them on. Its change signal keeps the value +//! current, and it works inside a Flatpak sandbox. +//! - **Linux without the portal, FreeBSD and the other BSDs**: the desktop's setting where it is +//! stored: KDE's `kdeglobals`, GNOME's or MATE's `enable-animations` (`gsettings`), then GTK's +//! `gtk-enable-animations`. There is no change signal to follow, so it is read at start-up and +//! again whenever the window gets the focus back. +//! +//! `None` means the platform gave no answer; the shell then keeps animations on. +//! +//! No `unsafe`: every OS call goes through a safe binding. + +pub use platform::service; + +/// Windows and macOS answer at once, so the setting is simply asked for again: at most this +/// often, and only on frames that run anyway (coming back from the system's settings is one). +#[cfg(any(target_os = "windows", target_os = "macos"))] +const POLL: std::time::Duration = std::time::Duration::from_secs(1); + +#[cfg(any(target_os = "windows", target_os = "macos"))] +fn polled(read: fn() -> Option) -> photocraft_ui_egui::SystemAnimationsFn { + let last = std::cell::Cell::new(None::<(std::time::Instant, Option)>); + Box::new(move |_| { + if let Some((at, animations)) = last.get() + && at.elapsed() < POLL + { + return animations; + } + let animations = read(); + last.set(Some((std::time::Instant::now(), animations))); + animations + }) +} + +#[cfg(target_os = "windows")] +mod platform { + use photocraft_ui_egui::SystemAnimationsFn; + + pub fn service() -> Option { + Some(super::polled(read)) + } + + pub(super) fn read() -> Option { + windows::UI::ViewManagement::UISettings::new().and_then(|settings| settings.AnimationsEnabled()).ok() + } +} + +#[cfg(target_os = "macos")] +mod platform { + use photocraft_ui_egui::SystemAnimationsFn; + + pub fn service() -> Option { + Some(super::polled(read)) + } + + fn read() -> Option { + Some(!objc2_app_kit::NSWorkspace::sharedWorkspace().accessibilityDisplayShouldReduceMotion()) + } +} + +#[cfg(not(any(unix, target_os = "windows")))] +mod platform { + pub fn service() -> Option { + None + } +} + +#[cfg(all(unix, not(target_os = "macos")))] +mod platform { + use std::sync::atomic::{AtomicU8, Ordering}; + use std::sync::{Arc, OnceLock, mpsc}; + + use photocraft_ui_egui::SystemAnimationsFn; + + /// Follows the desktop's setting on a worker thread, so a slow session bus or `gsettings` + /// never holds up a frame. Until the first answer lands the setting is unknown. + pub fn service() -> Option { + let value = Arc::new(AtomicU8::new(super::code_of(None))); + let wake: Arc> = Arc::new(OnceLock::new()); + let (refresh, refreshes) = mpsc::channel::<()>(); + let publisher = Publisher { value: Arc::clone(&value), wake: Arc::clone(&wake) }; + std::thread::Builder::new().name("animations-setting".into()).spawn(move || worker(&publisher, &refreshes)).ok()?; + let focused = std::cell::Cell::new(true); + Some(Box::new(move |ctx| { + let _ = wake.set(ctx.clone()); + let now = ctx.input(|i| i.focused); + let was = focused.replace(now); + // Back from the desktop's settings, perhaps: the worker reads again unless it has + // the portal's change signal (then nobody listens, and the send fails quietly). + if now && !was { + let _ = refresh.send(()); + } + super::decode(value.load(Ordering::Relaxed)) + })) + } + + fn worker(publisher: &Publisher, refreshes: &mpsc::Receiver<()>) { + #[cfg(target_os = "linux")] + if portal::follow(publisher) { + return; + } + publisher.publish(desktop::read()); + for () in refreshes { + publisher.publish(desktop::read()); + } + } + + /// The worker's handle on the shared value. A change wakes the registered UI. + struct Publisher { + value: Arc, + wake: Arc>, + } + + impl Publisher { + fn publish(&self, animations: Option) { + let code = super::code_of(animations); + if self.value.swap(code, Ordering::Relaxed) != code + && let Some(ctx) = self.wake.get() + { + ctx.request_repaint(); + } + } + } + + #[cfg(target_os = "linux")] + mod portal { + use zbus::zvariant::{OwnedValue, Value}; + + use super::super::{duration_factor, enabled, reduced_motion}; + + /// Whether animations are on according to a setting's value. + type Reads = fn(&str) -> Option; + + /// The settings the portal may answer for and how each one's value reads, most general + /// first: the cross-desktop one, then the two desktops' own that older portals pass on. + const SETTINGS: [(&str, &str, Reads); 3] = [ + ("org.freedesktop.appearance", "reduced-motion", reduced_motion), + ("org.gnome.desktop.interface", "enable-animations", enabled), + ("org.kde.kdeglobals.KDE", "AnimationDurationFactor", duration_factor), + ]; + + /// Publishes the portal's answer, then every change to it. `false` when the portal has + /// none: no session bus, no portal, or one that knows none of the settings. + pub fn follow(publisher: &super::Publisher) -> bool { + let Some(proxy) = crate::appearance::portal_proxy() else { return false }; + // Subscribe before the first read, so a change during start-up isn't lost. + let signals = proxy.receive_signal("SettingChanged").ok(); + let Some(first) = read(&proxy) else { return false }; + publisher.publish(Some(first)); + for message in signals.into_iter().flatten() { + let Ok((namespace, key, _)) = message.body().deserialize::<(String, String, OwnedValue)>() else { + continue; + }; + // Read them all again: which setting answers first may have changed too. + if SETTINGS.iter().any(|(ns, k, _)| *ns == namespace && *k == key) { + publisher.publish(read(&proxy)); + } + } + true + } + + fn read(proxy: &zbus::blocking::Proxy<'_>) -> Option { + SETTINGS.iter().find_map(|(namespace, key, animations)| { + let value: OwnedValue = proxy.call("Read", &(*namespace, *key)).ok()?; + animations(&text(value)?) + }) + } + + /// A setting's value as the text a settings file would hold. + fn text(value: OwnedValue) -> Option { + let mut value: Value<'_> = value.into(); + // The Settings.Read result is a variant; some portals nest another variant inside it. + for _ in 0..4 { + match value { + Value::Value(inner) => value = *inner, + Value::Bool(on) => return Some(on.to_string()), + Value::U32(n) => return Some(n.to_string()), + Value::I32(n) => return Some(n.to_string()), + Value::F64(n) => return Some(n.to_string()), + Value::Str(text) => return Some(text.to_string()), + _ => return None, + } + } + None + } + + #[cfg(test)] + mod tests { + use super::*; + + fn owned(value: Value<'_>) -> OwnedValue { + OwnedValue::try_from(value).unwrap() + } + + #[test] + fn portal_values_read_as_text() { + let nested = Value::Value(Box::new(Value::Value(Box::new(Value::U32(1))))); + assert_eq!(text(owned(nested)).as_deref(), Some("1")); + assert_eq!(text(owned(Value::from(false))).as_deref(), Some("false")); + assert_eq!(text(owned(Value::from("0.5"))).as_deref(), Some("0.5")); + assert_eq!(text(owned(Value::from(vec![1u32, 2]))), None); + // Each setting reads its own type of value, the cross-desktop one first. + let [(_, motion, reduced), (_, _, on), (_, _, factor)] = SETTINGS; + assert_eq!(motion, "reduced-motion"); + assert_eq!(reduced(&text(owned(Value::U32(1))).unwrap()), Some(false)); + assert_eq!(reduced(&text(owned(Value::U32(0))).unwrap()), Some(true)); + assert_eq!(on(&text(owned(Value::from(false))).unwrap()), Some(false)); + assert_eq!(factor(&text(owned(Value::from("0"))).unwrap()), Some(false)); + assert_eq!(factor(&text(owned(Value::F64(0.5))).unwrap()), Some(true)); + } + } + } + + mod desktop { + use std::path::PathBuf; + + /// A settings file is a few kilobytes; a larger one isn't read. + const MAX_CONFIG_BYTES: u64 = 1 << 20; + + pub fn read() -> Option { + let desktop = std::env::var("XDG_CURRENT_DESKTOP").unwrap_or_default(); + super::super::desktop_setting(&desktop, &config_file, &gsettings) + } + + fn config_home() -> Option { + let dir = |key: &str| std::env::var_os(key).filter(|v| !v.is_empty()).map(PathBuf::from); + dir("XDG_CONFIG_HOME").filter(|path| path.is_absolute()).or_else(|| dir("HOME").map(|home| home.join(".config"))) + } + + fn config_file(name: &str) -> Option { + use std::io::Read as _; + let mut text = String::new(); + std::fs::File::open(config_home()?.join(name)).ok()?.take(MAX_CONFIG_BYTES).read_to_string(&mut text).ok()?; + Some(text) + } + + /// `gsettings get`, by absolute path (`/usr/local` and `/usr/pkg` are where the BSDs + /// install it). + fn gsettings(schema: &str, key: &str) -> Option { + let exe = ["/usr/bin/gsettings", "/bin/gsettings", "/usr/local/bin/gsettings", "/usr/pkg/bin/gsettings"] + .into_iter() + .find(|path| std::path::Path::new(path).is_file())?; + let output = std::process::Command::new(exe).args(["get", schema, key]).output().ok()?; + if !output.status.success() { + return None; + } + String::from_utf8(output.stdout).ok() + } + } +} + +/// `true` or `false` (GSettings, the portal), `1` or `0` (a GTK settings file): animations are on. +#[cfg(any(test, all(unix, not(target_os = "macos"))))] +fn enabled(value: &str) -> Option { + match value.trim().to_ascii_lowercase().as_str() { + "true" | "1" => Some(true), + "false" | "0" => Some(false), + _ => None, + } +} + +/// KDE's animation speed factor: 0 turns animations off. +#[cfg(any(test, all(unix, not(target_os = "macos"))))] +fn duration_factor(value: &str) -> Option { + value.trim().parse::().ok().filter(|factor| factor.is_finite()).map(|factor| factor > 0.0) +} + +/// The portal's `reduced-motion`: 1 asks for less motion; 0 and the values it may grow don't. +#[cfg(any(test, target_os = "linux"))] +fn reduced_motion(value: &str) -> Option { + value.trim().parse::().ok().map(|code| code != 1) +} + +/// The last value of `key` in `[section]` of an INI-style file (KDE's config, GTK's settings). +#[cfg(any(test, all(unix, not(target_os = "macos"))))] +fn ini_value<'a>(text: &'a str, section: &str, key: &str) -> Option<&'a str> { + let mut inside = false; + let mut found = None; + for line in text.lines() { + let line = line.trim(); + if let Some(name) = line.strip_prefix('[').and_then(|rest| rest.strip_suffix(']')) { + inside = name == section; + } else if inside && let Some((name, value)) = line.split_once('=') { + // KDE marks an entry the user may not change as `Key[$i]=value`. + let name = name.split_once('[').map_or(name, |(name, _)| name); + if name.trim() == key { + found = Some(value.trim()); + } + } + } + found +} + +/// The desktop's setting without the portal. `desktop` is `XDG_CURRENT_DESKTOP`, `file` reads a +/// file under the user's config directory and `gsettings` runs `gsettings get `. +#[cfg(any(test, all(unix, not(target_os = "macos"))))] +fn desktop_setting(desktop: &str, file: &dyn Fn(&str) -> Option, gsettings: &dyn Fn(&str, &str) -> Option) -> Option { + let running = |name: &str| desktop.split(':').any(|part| part.eq_ignore_ascii_case(name)); + let in_file = |name: &str, section: &str, key: &str, animations: fn(&str) -> Option| animations(ini_value(&file(name)?, section, key)?); + if running("KDE") + && let Some(animations) = in_file("kdeglobals", "KDE", "AnimationDurationFactor", duration_factor) + { + return Some(animations); + } + let schema = if running("MATE") { "org.mate.interface" } else { "org.gnome.desktop.interface" }; + let shell = gsettings(schema, "enable-animations").and_then(|out| enabled(&out)); + if shell == Some(false) { + return shell; + } + // `true` may only be the schema's default on a desktop that doesn't use it. GTK's own file + // is what a bare window manager's user writes, and what KDE keeps in step with its setting. + ["gtk-4.0/settings.ini", "gtk-3.0/settings.ini"].iter().find_map(|name| in_file(name, "Settings", "gtk-enable-animations", enabled)).or(shell) +} + +#[cfg(any(test, all(unix, not(target_os = "macos"))))] +fn code_of(animations: Option) -> u8 { + match animations { + None => 0, + Some(true) => 1, + Some(false) => 2, + } +} + +#[cfg(any(test, all(unix, not(target_os = "macos"))))] +fn decode(code: u8) -> Option { + match code { + 1 => Some(true), + 2 => Some(false), + _ => None, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn each_setting_reads_its_own_values() { + for (s, animations) in + [("true\n", Some(true)), ("false\n", Some(false)), ("1", Some(true)), ("0", Some(false)), ("FALSE", Some(false)), ("", None), ("maybe", None)] + { + assert_eq!(enabled(s), animations, "{s:?}"); + } + for (s, animations) in [ + ("0", Some(false)), + ("0.0", Some(false)), + ("0.5", Some(true)), + ("1", Some(true)), + ("-1", Some(false)), + ("", None), + ("fast", None), + ("NaN", None), + ("inf", None), + ] { + assert_eq!(duration_factor(s), animations, "{s:?}"); + } + // reduced-motion: only 1 asks for less motion; unknown values mean no preference. + for (s, animations) in [("0", Some(true)), ("1", Some(false)), ("2", Some(true)), ("true", None), ("-1", None), ("", None)] { + assert_eq!(reduced_motion(s), animations, "{s:?}"); + } + // The shared value round-trips, and a stray code is "unknown". + for animations in [None, Some(true), Some(false)] { + assert_eq!(decode(code_of(animations)), animations); + } + assert_eq!(decode(9), None); + } + + #[test] + fn ini_values_come_from_their_own_section() { + let kde = "[General]\nAnimationDurationFactor=3\n\n[KDE]\nSingleClick=false\n AnimationDurationFactor = 0 \n[KDE][Sub]\nAnimationDurationFactor=7\n"; + assert_eq!(ini_value(kde, "KDE", "AnimationDurationFactor"), Some("0")); + assert_eq!(ini_value(kde, "KDE", "Missing"), None); + assert_eq!(ini_value("[KDE]\nAnimationDurationFactor[$i]=0.5\n", "KDE", "AnimationDurationFactor"), Some("0.5"), "an immutable entry"); + assert_eq!( + ini_value("[Settings]\ngtk-enable-animations=1\ngtk-enable-animations=0\n", "Settings", "gtk-enable-animations"), + Some("0"), + "the last one wins" + ); + // Hostile text: no section, no `=`, stray brackets, non-ASCII. + for junk in ["", "AnimationDurationFactor=0", "[KDE", "[KDE]\n=\n[]\n]]][[[\n", "[KDE]\nклавиша=значение\n\u{0}\u{feff}"] { + assert_eq!(ini_value(junk, "KDE", "AnimationDurationFactor"), None, "{junk:?}"); + } + } + + #[test] + fn the_desktop_setting_is_read_where_each_desktop_keeps_it() { + let files = |kde: Option<&'static str>, gtk: Option<&'static str>| { + move |name: &str| match name { + "kdeglobals" => kde.map(String::from), + "gtk-3.0/settings.ini" => gtk.map(String::from), + _ => None, + } + }; + let none = |_: &str, _: &str| -> Option { None }; + let gnome = |on: &'static str| { + move |schema: &str, key: &str| (schema == "org.gnome.desktop.interface" && key == "enable-animations").then(|| format!("{on}\n")) + }; + let kde_off = Some("[KDE]\nAnimationDurationFactor=0\n"); + let gtk_off = Some("[Settings]\ngtk-enable-animations=false\n"); + + // KDE Plasma: its own file, only when Plasma is the desktop running. + assert_eq!(desktop_setting("KDE", &files(kde_off, None), &none), Some(false)); + assert_eq!(desktop_setting("KDE", &files(Some("[KDE]\nAnimationDurationFactor=0.5\n"), gtk_off), &none), Some(true)); + assert_eq!(desktop_setting("ubuntu:GNOME", &files(kde_off, None), &gnome("true")), Some(true), "a leftover kdeglobals is not GNOME's setting"); + // Plasma without the entry (animations at their default speed) falls through to GTK's file. + assert_eq!(desktop_setting("KDE", &files(Some("[KDE]\nSingleClick=false\n"), gtk_off), &none), Some(false)); + // GNOME and the desktops that share its schema. + assert_eq!(desktop_setting("GNOME", &files(None, None), &gnome("false")), Some(false)); + assert_eq!(desktop_setting("GNOME", &files(None, None), &gnome("true")), Some(true)); + // MATE keeps the same key in its own schema. + let mate = |schema: &str, _: &str| (schema == "org.mate.interface").then(|| "false\n".to_string()); + assert_eq!(desktop_setting("MATE", &files(None, None), &mate), Some(false)); + assert_eq!(desktop_setting("GNOME", &files(None, None), &mate), None); + // A bare window manager: GTK's settings file, which also outranks a schema default. + assert_eq!(desktop_setting("sway", &files(None, gtk_off), &none), Some(false)); + assert_eq!(desktop_setting("", &files(None, gtk_off), &gnome("true")), Some(false)); + assert_eq!(desktop_setting("", &files(None, Some("[Settings]\ngtk-enable-animations=1\n")), &none), Some(true)); + // Nothing to read, or nothing readable: unknown, never a panic. + assert_eq!(desktop_setting("", &files(None, None), &none), None); + assert_eq!( + desktop_setting("KDE:\u{0}::", &files(Some("\u{0}[[[=]]]"), Some("=\n[Settings]\ngtk-enable-animations=perhaps")), &|_, _| Some("\u{fffd}".into())), + None + ); + } + + /// The real setting of the machine the tests run on: whatever it is, reading it doesn't + /// panic and the service passes it on (`--nocapture` shows it). + #[cfg(target_os = "windows")] + #[test] + fn windows_reports_its_animation_setting() { + let animations = platform::read(); + println!("UISettings.AnimationsEnabled: {animations:?}"); + let service = platform::service().expect("service"); + assert_eq!(service(&egui::Context::default()), animations); + } +} diff --git a/apps/photocraft/src/appearance.rs b/apps/photocraft/src/appearance.rs index 8389ee83eb..e4c1e89e08 100644 --- a/apps/photocraft/src/appearance.rs +++ b/apps/photocraft/src/appearance.rs @@ -5,8 +5,9 @@ const PORTAL_NAMESPACE: &str = "org.freedesktop.appearance"; #[cfg(target_os = "linux")] const PORTAL_KEY: &str = "color-scheme"; +/// The settings portal, also asked for the animation setting (`animations.rs`). #[cfg(target_os = "linux")] -fn portal_proxy() -> Option> { +pub(crate) fn portal_proxy() -> Option> { let conn = zbus::blocking::connection::Builder::session().ok()?.method_timeout(std::time::Duration::from_secs(2)).build().ok()?; zbus::blocking::Proxy::new(&conn, "org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop", "org.freedesktop.portal.Settings").ok() } diff --git a/apps/photocraft/src/main.rs b/apps/photocraft/src/main.rs index aee9eabca1..32b43e2bca 100644 --- a/apps/photocraft/src/main.rs +++ b/apps/photocraft/src/main.rs @@ -20,6 +20,7 @@ #![cfg_attr(all(windows, not(debug_assertions)), windows_subsystem = "windows")] #![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] +mod animations; mod app_dirs; mod app_icon; mod appearance; diff --git a/apps/photocraft/src/services.rs b/apps/photocraft/src/services.rs index fea0d34541..c75c2ac694 100644 --- a/apps/photocraft/src/services.rs +++ b/apps/photocraft/src/services.rs @@ -433,6 +433,7 @@ pub fn native(automation: Option) -> photoshop_shortcuts: Some(Box::new(|| crate::photoshop_settings::live_keyboard_shortcuts(&|k| std::env::var_os(k)))), save_prefs: Some(Box::new(|text: &str| write_atomic(&prefs_file().ok_or("no config directory")?, text.as_bytes()))), system_theme: crate::appearance::service(), + system_animations: crate::animations::service(), append_text: Some(Box::new(|path: &str, text: &str| { use std::io::Write; let mut f = std::fs::OpenOptions::new().create(true).append(true).open(path).map_err(|e| e.to_string())?; diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index 3a8b7ce695..3d20f784ab 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -83,6 +83,12 @@ choice!( LinuxDisplayServer { Auto = "auto", X11 = "x11" } default Auto ); choice!(UiFontSize { Tiny = "tiny", Small = "small", Medium = "medium", Large = "large" } default Small); +choice!( + /// Interface animations: `system` follows the operating system's animation setting (Windows + /// "Animation effects", macOS "Reduce motion", the desktop's setting on Linux and the BSDs, + /// `prefers-reduced-motion` in a browser) and keeps them on where it cannot be read. + AnimationEffects { System = "system", On = "on", Off = "off" } default System +); choice!(LogDestination { Metadata = "metadata", TextFile = "textFile", Both = "both" } default Metadata); choice!(LogDetail { SessionsOnly = "sessionsOnly", Concise = "concise", Detailed = "detailed" } default Concise); choice!(Ask { Always = "always", Never = "never", Ask = "ask" } default Always); @@ -270,9 +276,9 @@ pub struct Interface { /// Draw menu item colours set with Edit › Menus. pub show_menu_colors: bool, pub show_tooltips: bool, - /// Menus, popups and collapsing sections fade and slide, and scroll areas glide to a new - /// position. Off, everything changes at once (a reduced-motion mode; #1218, #3273). - pub enable_animations: bool, + /// Menus, popups, dialogs and collapsing sections fade and slide, and scrolling glides to + /// its new position. Off, everything changes at once (a reduced-motion mode; #1218, #3273). + pub animation_effects: AnimationEffects, /// Move tool drags show only the layer's outline and an arrow, leaving its pixels in place /// until release. Off (the default), the pixels follow the pointer live inside the outline. pub show_bounding_box_when_dragging_layer: bool, @@ -306,7 +312,7 @@ impl Default for Interface { dynamic_color_sliders: true, show_menu_colors: true, show_tooltips: true, - enable_animations: true, + animation_effects: AnimationEffects::System, show_bounding_box_when_dragging_layer: false, system_title_bar: false, notification_auto_hide: true, @@ -1101,6 +1107,7 @@ pub fn choices(path: &str) -> Option<&'static [&'static str]> { "interface.canvasBorder" => CanvasBorder::NAMES, "interface.uiScale" => UiScale::NAMES, "interface.uiFontSize" => UiFontSize::NAMES, + "interface.animationEffects" => AnimationEffects::NAMES, "historyLog.destination" => LogDestination::NAMES, "historyLog.detail" => LogDetail::NAMES, "fileHandling.imagePreviews" | "fileHandling.maximizePsdCompatibility" => Ask::NAMES, @@ -1548,6 +1555,14 @@ impl Session { interface.insert("appearanceMode".into(), json!(mode)); interface.insert(slot.into(), json!(theme.name())); } + // Animation Effects was the Enable Animations checkbox (on by default) before it could + // follow the system: a saved "off" stays off. + if let Some(interface) = v.get_mut("interface").and_then(Value::as_object_mut) + && !interface.contains_key("animationEffects") + && interface.get("enableAnimations").and_then(Value::as_bool) == Some(false) + { + interface.insert("animationEffects".into(), json!(AnimationEffects::Off.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")); let prefs: Preferences = serde_json::from_value(v).map_err(|e| format!("preferences: {e}"))?; diff --git a/crates/engine/src/prefs/tests.rs b/crates/engine/src/prefs/tests.rs index 6bb34a9706..46646c57f3 100644 --- a/crates/engine/src/prefs/tests.rs +++ b/crates/engine/src/prefs/tests.rs @@ -67,6 +67,46 @@ fn appearance_defaults_and_legacy_theme_migrate() { } } +/// Interface › Animation Effects: the system's setting by default, validated like any choice, and +/// the Enable Animations checkbox it replaced still means what it was saved as. +#[test] +fn animation_effects_default_to_the_system_and_keep_a_saved_off() { + assert_eq!(Preferences::default().interface.animation_effects, AnimationEffects::System); + assert_eq!(choices("interface.animationEffects"), Some(AnimationEffects::NAMES)); + assert_eq!(AnimationEffects::NAMES, ["system", "on", "off"]); + let mut s = Session::new(); + for (value, effects) in [("off", AnimationEffects::Off), ("on", AnimationEffects::On), ("system", AnimationEffects::System)] { + s.execute("prefs.set", json!({"path": "interface.animationEffects", "value": value})).unwrap(); + assert_eq!(s.prefs().interface.animation_effects, effects); + assert_eq!(s.execute("prefs.get", json!({"path": "interface.animationEffects"})).unwrap(), json!(value)); + let mut restarted = Session::new(); + restarted.load_prefs_json(&s.prefs_to_json()).unwrap(); + assert_eq!(restarted.prefs().interface.animation_effects, effects, "{value} survives a restart"); + } + // A value that is no choice is an error and changes nothing. + s.execute("prefs.set", json!({"path": "interface.animationEffects", "value": "off"})).unwrap(); + for bad in [json!("sometimes"), json!("Off"), json!(""), json!(true), json!(0), json!(null), json!(["off"]), json!({})] { + assert!(s.execute("prefs.set", json!({"path": "interface.animationEffects", "value": bad})).is_err(), "{bad}"); + assert_eq!(s.prefs().interface.animation_effects, AnimationEffects::Off); + } + s.execute("prefs.reset", json!({"path": "interface.animationEffects"})).unwrap(); + assert_eq!(s.prefs().interface.animation_effects, AnimationEffects::System); + // The checkbox was on by default: a saved "off" stays off, "on" now follows the system, and + // a choice made since wins over the old key left in the file. + for (saved, effects) in [ + (json!({"enableAnimations": false}), AnimationEffects::Off), + (json!({"enableAnimations": true}), AnimationEffects::System), + (json!({"enableAnimations": false, "animationEffects": "on"}), AnimationEffects::On), + (json!({"enableAnimations": "nope"}), AnimationEffects::System), + (json!({}), AnimationEffects::System), + ] { + let mut old = Session::new(); + old.load_prefs_json(&json!({"interface": saved}).to_string()).unwrap(); + assert_eq!(old.prefs().interface.animation_effects, effects, "{saved}"); + } + assert!(s.execute("prefs.set", json!({"path": "interface.enableAnimations", "value": false})).is_err(), "the old path is gone"); +} + #[test] fn appearance_choices_validate_and_legacy_theme_still_selects() { let mut s = Session::new(); diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 36fc380769..1adb5b86e3 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -1981,7 +1981,8 @@ Show only crosshair while painting Při malování zobrazit jen nitkový kříž Show slice numbers Zobrazit čísla řezů Show tooltips Zobrazit popisky nástrojů - Enable animations Povolit animace + Animation effects Efekty animace + Use system setting Použít nastavení systému Show highlight on rollover Zobrazit zvýraznění při přejetí Show bounding box when dragging layer Při přetahování vrstvy zobrazit ohraničovací rámeček System title bar Systémové záhlaví okna diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index dc366b4553..f1b676ed9d 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -1952,7 +1952,9 @@ Show only crosshair while painting Beim Malen nur Fadenkreuz zeigen Show slice numbers Slice-Nummern anzeigen Show tooltips Tooltips anzeigen - Enable animations Animationen aktivieren + Animation effects Animationseffekte + Use system setting Systemeinstellung verwenden + On Ein Show highlight on rollover Hervorhebung bei Rollover anzeigen Show bounding box when dragging layer Begrenzungsrahmen beim Ziehen einer Ebene anzeigen System title bar System-Titelleiste diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 3f693d543f..e23f2de96f 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -1468,7 +1468,8 @@ Show only crosshair while painting Εμφάνιση μόνο σταυρονήματος κατά τη ζωγραφική Show slice numbers Εμφάνιση αριθμών τομών Show tooltips Εμφάνιση επεξηγήσεων - Enable animations Ενεργοποίηση κινούμενων εφέ + Animation effects Εφέ κίνησης + Use system setting Χρήση ρύθμισης συστήματος Show highlight on rollover Εμφάνιση επισήμανσης κατά την κατάδειξη Show bounding box when dragging layer Εμφάνιση πλαισίου οριοθέτησης κατά τη μετακίνηση επιπέδου Show transformation values Εμφάνιση τιμών μετασχηματισμού diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 3f001c478b..2c745d4a05 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -1965,7 +1965,9 @@ Show only crosshair while painting Mostrar solo la retícula al pintar Show slice numbers Mostrar los números de sector Show tooltips Mostrar las descripciones emergentes - Enable animations Activar las animaciones + Animation effects Efectos de animación + Use system setting Usar la configuración del sistema + On Activado Show highlight on rollover Mostrar resaltado al pasar el cursor Show bounding box when dragging layer Mostrar el cuadro delimitador al arrastrar la capa System title bar Barra de título del sistema diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 4dd927500c..48ba8375df 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -1936,7 +1936,9 @@ Show only crosshair while painting N'afficher que le réticule pendant la peinture Show slice numbers Afficher les numéros de tranche Show tooltips Afficher les info-bulles - Enable animations Activer les animations + Animation effects Effets d'animation + Use system setting Utiliser le réglage du système + On Activé Show highlight on rollover Afficher la mise en surbrillance au survol Show transformation values Afficher les valeurs de transformation Slice color Couleur des tranches diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index a84d19458b..3b46122e02 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -2927,6 +2927,8 @@ cameraRaw Yellow Sárga Show rulers Vonalzók megjelenítése Show Rulers Vonalzók megjelenítése Show tooltips Eszköztippek megjelenítése + Animation effects Animációs effektusok + Use system setting Rendszerbeállítás használata Software Szoftver Solarized dark Solarized sötét Sort Rendezés @@ -3162,7 +3164,6 @@ cameraRaw Yellow Sárga Ellipse Tool Ellipszis Elliptical Marquee Tool Ellipszis-kijelölés Enable Bekapcsolás - Enable animations Animációk engedélyezése Enable flick panning Lendítéses pásztázás engedélyezése Enable floating document window docking Lebegő dokumentumablakok dokkolásának engedélyezése Enable narrow options bar Keskeny beállítósáv engedélyezése diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index ea51c03775..1a01ea5c3d 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -1930,7 +1930,9 @@ Show only crosshair while painting Tampilkan crosshair saja saat melukis Show slice numbers Tampilkan nomor slice Show tooltips Tampilkan tooltip - Enable animations Aktifkan animasi + Animation effects Efek animasi + Use system setting Gunakan pengaturan sistem + On Hidup Show highlight on rollover Tampilkan sorotan saat kursor melintas Show transformation values Tampilkan nilai transformasi Slice color Warna slice diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 1aa22cc2aa..89b7f2455f 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -1963,7 +1963,8 @@ Show only crosshair while painting Mostra solo mirino durante pittura Show slice numbers Mostra numeri sezioni Show tooltips Mostra tooltip - Enable animations Attiva animazioni + Animation effects Effetti di animazione + Use system setting Usa impostazione di sistema Show highlight on rollover Mostra evidenziazione al passaggio del mouse Show bounding box when dragging layer Mostra riquadro selezione al trascinamento livello System title bar Barra del titolo di sistema diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 40749c2d0b..cb3cf18a56 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -1964,7 +1964,9 @@ Show only crosshair while painting 描画中は十字線のみ表示 Show slice numbers スライス番号を表示 Show tooltips ツールチップを表示 - Enable animations アニメーションを有効にする + Animation effects アニメーション効果 + Use system setting システム設定を使用 + On オン Show highlight on rollover ロールオーバー時にハイライトを表示 Show bounding box when dragging layer レイヤーのドラッグ中にバウンディングボックスを表示 System title bar システムのタイトルバー diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index a93a20be59..04fb2944ea 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -1927,7 +1927,9 @@ Show only crosshair while painting 칠하는 동안 십자선만 표시 Show slice numbers 분할 영역 번호 표시 Show tooltips 도구 설명 표시 - Enable animations 애니메이션 사용 + Animation effects 애니메이션 효과 + Use system setting 시스템 설정 사용 + On 켬 Show highlight on rollover 롤오버 시 강조 표시 Show transformation values 변형 값 표시 Slice color 분할 영역 색상 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index fc5809033c..4654b8196d 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -1937,7 +1937,8 @@ Show only crosshair while painting Alleen dradenkruis tonen tijdens schilderen Show slice numbers Segmentnummers tonen Show tooltips Knopinfo tonen - Enable animations Animaties inschakelen + Animation effects Animatie-effecten + Use system setting Systeeminstelling gebruiken Show highlight on rollover Markering bij aanwijzen tonen Show bounding box when dragging layer Selectiekader tonen bij slepen van laag System title bar Titelbalk van systeem diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 9d3ecd9433..124e3ab6f3 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -1957,7 +1957,9 @@ Show only crosshair while painting Podczas malowania pokaż tylko celownik Show slice numbers Pokaż numery plasterków Show tooltips Pokaż podpowiedzi - Enable animations Włącz animacje + Animation effects Efekty animacji + Use system setting Użyj ustawienia systemowego + On Włączone Show highlight on rollover Pokaż podświetlenie po najechaniu Show bounding box when dragging layer Pokaż ramkę ograniczającą podczas przeciągania warstwy Show transformation values Pokaż wartości przekształcenia diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index b26e9fd07e..86840fc789 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -1932,7 +1932,8 @@ Show only crosshair while painting Mostrar apenas a mira ao pintar Show slice numbers Mostrar números das fatias Show tooltips Mostrar dicas de ferramentas - Enable animations Ativar animações + Animation effects Efeitos de animação + Use system setting Usar configuração do sistema Show highlight on rollover Mostrar realce ao passar o mouse Show transformation values Mostrar valores de transformação Slice color Cor das fatias diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index e57d0686b9..f97672f416 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -2380,7 +2380,9 @@ Show only crosshair while painting Только перекрестье при рисовании Show slice numbers Показывать номера фрагментов Show tooltips Показывать подсказки - Enable animations Включить анимацию + Animation effects Эффекты анимации + Use system setting Использовать системную настройку + On Вкл Show highlight on rollover Показывать подсветку при наведении Show bounding box when dragging layer Показывать рамку при перетаскивании слоя System title bar Системная строка заголовка diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 3f552460ca..d0bbf40504 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -1929,6 +1929,8 @@ Show only crosshair while painting Boyama sırasında yalnızca artı işaretini göster Show slice numbers Dilim numaralarını göster Show tooltips Araç ipuçlarını göster + Animation effects Animasyon efektleri + Use system setting Sistem ayarını kullan Show highlight on rollover Rollover sırasında vurgulamayı göster Show bounding box when dragging layer Katmanı sürüklerken sınırlayıcı kutuyu göster System title bar Sistem başlık çubuğu @@ -2423,7 +2425,6 @@ cameraRaw Color Renk Remove All Tümünü Kaldır Unlock Kilidi aç Enable Etkinleştir - Enable animations Animasyonları etkinleştir Disable Devre dışı bırak On Açık Selected Seçilen diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index f7feba19a7..eeec2df648 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -2355,7 +2355,9 @@ Show only crosshair while painting Показувати лише перехрестя під час малювання Show slice numbers Показувати номери фрагментів Show tooltips Показувати підказки - Enable animations Увімкнути анімацію + Animation effects Ефекти анімації + Use system setting Використовувати системне налаштування + On Увімкнено Show highlight on rollover Показувати підсвічування під час наведення Show bounding box when dragging layer Показувати рамку під час перетягування шару System title bar Системний рядок заголовка diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 890533bab2..096eb66b7a 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3512,7 +3512,9 @@ cameraData Lens Ống kính New Document With Mask Tài liệu mới có mặt nạ New Layer With Mask Lớp mới có mặt nạ Convert Point Tool Công cụ Chuyển đổi điểm - Enable animations Bật hiệu ứng chuyển động + Animation effects Hiệu ứng chuyển động + Use system setting Dùng cài đặt hệ thống + On Bật Gloss Contour Đường bao bóng Cone - Inverted Hình nón - Đảo ngược Cove - Deep Lõm - Sâu diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 2f13bc3bfb..485b3a3bc4 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -1974,7 +1974,9 @@ Show only crosshair while painting 绘画时仅显示十字线 Show slice numbers 显示切片编号 Show tooltips 显示工具提示 - Enable animations 启用动画 + Animation effects 动画效果 + Use system setting 使用系统设置 + On 开启 Show highlight on rollover 鼠标悬停时显示高亮 Show bounding box when dragging layer 拖动图层时显示边界框 System title bar 系统标题栏 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index b72aa4509b..7dd463cf3c 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -1967,7 +1967,9 @@ Show only crosshair while painting 繪圖時僅顯示十字線 Show slice numbers 顯示切片編號 Show tooltips 顯示工具提示 - Enable animations 啟用動畫 + Animation effects 動畫效果 + Use system setting 使用系統設定 + On 開 Show highlight on rollover 滑鼠懸停時顯示醒目提示 Show bounding box when dragging layer 拖曳圖層時顯示邊界框 System title bar 系統標題列 diff --git a/crates/ui-egui/src/input_tests.rs b/crates/ui-egui/src/input_tests.rs index 956a9de9ba..1120aa41d8 100644 --- a/crates/ui-egui/src/input_tests.rs +++ b/crates/ui-egui/src/input_tests.rs @@ -389,6 +389,31 @@ fn the_wheel_reaches_12800_percent_and_stops_dead_there() { assert!((d2[0] - d0[0]).abs() < 0.02 && (d2[1] - d0[1]).abs() < 0.02, "{d0:?} -> {d2:?}"); } +/// Preferences › Interface › Animation Effects (#3273): on, a wheel notch glides the canvas to +/// its new place over the frames that follow; off, it is there on the frame the notch arrives. +#[test] +fn animation_effects_off_pans_a_wheel_notch_at_once() { + for (choice, at_once) in [("on", false), ("off", true)] { + let mut h = app_window(); + h.state_mut().run("prefs.set", json!({"path": "interface.animationEffects", "value": choice})).unwrap(); + { + let v = &mut h.state_mut().ui.views[0]; + (v.zoom, v.center, v.fit_pending) = (8.0, [200.0, 150.0], false); + } + h.run_steps(4); + h.hover_at(h.state().last_canvas_rect.center()); + h.run_steps(2); + let c0 = h.state().ui.views[0].center; + wheel(&h, -1.0, Modifiers::NONE); + h.run_steps(1); + let c1 = h.state().ui.views[0].center; + h.run_steps(40); + let c2 = h.state().ui.views[0].center; + assert!((c2[1] - c0[1] - 5.0).abs() < 0.01 && c2[0] == c0[0], "{choice}: one notch is 40 points, 5 px at 800%: {c0:?} -> {c2:?}"); + assert_eq!(c1 == c2, at_once, "{choice}: {c0:?} -> {c1:?} -> {c2:?}"); + } +} + #[test] fn alt_scroll_zooms_in_steps_around_the_pointer() { let mut h = harness(); diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index a144477cdb..57579e2654 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -334,6 +334,10 @@ pub type LoadTextFn = Box Option>; pub type SaveTextFn = Box Result<(), String>>; /// Platform appearance when egui cannot detect it (for example, Wayland without a theme event). pub type SystemThemeFn = Box Option>; +/// Whether the operating system animates its interface (Windows "Animation effects", macOS +/// "Reduce motion", the desktop's setting on Linux and the BSDs, `prefers-reduced-motion` in a +/// browser): `Some(false)` when the user turned animations off there, `None` when it can't tell. +pub type SystemAnimationsFn = Box Option>; /// Autosave a document snapshot for crash recovery: (snapshot, revision, original path). pub type AutosaveFn = Box, u64, Option<&str>) -> Result<(), String>>; /// Poll successful or failed background writes: (document id, revision, result). @@ -423,6 +427,10 @@ pub struct Services { /// Photoshop's live keyboard shortcut set, imported once at first launch (`kys_import`). pub photoshop_shortcuts: Option, pub system_theme: Option, + /// The system's animation setting, for Preferences › Interface › Animation Effects › Use + /// System Setting. Read every frame while that is the choice, so it must be cheap; without + /// it (or without an answer) animations stay on. + pub system_animations: Option, /// The native window is connected directly to a Wayland compositor. pub is_wayland: bool, /// On Wayland, the shell command that starts this install under XWayland, where native file @@ -1603,6 +1611,11 @@ impl eframe::App for PhotocraftApp { self.collect_screenshots(ctx); self.issue_screenshots(ctx); prefs_ui::tick(self, ctx); + // Animation Effects off: the wheel scrolls its whole distance at once, before anything + // reads this frame's scroll (wheel_nav.rs). + if self.prefs_rt.reduce_motion { + wheel_nav::unsmooth(ctx); + } monitor_status::poll_frame(self, ctx, frame); // Control requests and persisted preferences can change the language in this frame. i18n::sync_context(ctx, &self.session.prefs().interface.language); diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs index 202944b58a..84c4c03e78 100644 --- a/crates/ui-egui/src/prefs_ui.rs +++ b/crates/ui-egui/src/prefs_ui.rs @@ -52,6 +52,8 @@ pub struct Runtime { show_rulers: Option, /// Tool options as last remembered in the preferences (see `tool_memory`). pub(crate) tool_options: Option, + /// Interface › Animation Effects came out as off this frame (see `sync_animations`). + pub(crate) reduce_motion: bool, } /// The GPU canvas colours from Preferences › Transparency & Gamut. @@ -384,11 +386,23 @@ fn sync_tooltips(app: &PhotocraftApp, ctx: &egui::Context) { } } -/// Interface › Enable Animations: off, egui's fades and slides take no time and scroll areas jump -/// straight to their target (#3273). Re-checked every frame because a theme change rebuilds the -/// style; both the dark and light styles are set, so a system appearance switch keeps it. -fn sync_animations(app: &PhotocraftApp, ctx: &egui::Context) { - let on = app.session.prefs().interface.enable_animations; +/// Interface › Animation Effects, resolved: on or off as chosen, or the operating system's own +/// setting for Use System Setting (on where the platform cannot tell). +fn animations_on(app: &PhotocraftApp, ctx: &egui::Context) -> bool { + match app.session.prefs().interface.animation_effects { + prefs::AnimationEffects::On => true, + prefs::AnimationEffects::Off => false, + prefs::AnimationEffects::System => app.services.system_animations.as_ref().and_then(|read| read(ctx)).unwrap_or(true), + } +} + +/// Interface › Animation Effects: off, egui's fades and slides take no time and scroll areas jump +/// straight to their target (#3273); the wheel's own glide is taken out by `wheel_nav::unsmooth`. +/// Re-checked every frame because a theme change rebuilds the style and the system's setting can +/// change; both the dark and light styles are set, so a system appearance switch keeps it. +fn sync_animations(app: &mut PhotocraftApp, ctx: &egui::Context) { + let on = animations_on(app, ctx); + app.prefs_rt.reduce_motion = !on; let time = if on { egui::Style::default().animation_time } else { 0.0 }; if ctx.global_style().animation_time != time { let scroll = if on { egui::style::ScrollAnimation::default() } else { egui::style::ScrollAnimation::none() }; @@ -1077,6 +1091,15 @@ fn choice_label(v: &str) -> String { } } +/// The label of choice `v` of the preference at `path`. Most choices read the same wherever +/// they appear; Animation Effects' `system` says what it does. +fn pref_choice_label(path: &str, v: &str) -> String { + match (path, v) { + ("interface.animationEffects", "system") => "Use system setting".into(), + _ => choice_label(v), + } +} + /// An editable `#rrggbb` field beside a colour swatch (#668): typing a valid value sets the /// colour; while it's being typed a partial value is kept, and it shows the colour otherwise. fn hex_field(ui: &mut egui::Ui, key: &str, rgb: &mut [u8; 3]) { @@ -1497,7 +1520,7 @@ fn section_fields( Value::String(s) if prefs::choices(&path).is_some() => { ui.label(RichText::new(tl!(&label)).color(t.text_dim)); let opts = prefs::choices(&path).unwrap_or(&[]); - let labels: Vec = opts.iter().map(|o| choice_label(o)).collect(); + let labels: Vec = opts.iter().map(|o| pref_choice_label(&path, o)).collect(); let pairs: Vec<(String, &str)> = opts.iter().map(|o| o.to_string()).zip(labels.iter().map(String::as_str)).collect(); let mut cur = s.clone(); crate::widgets::dropdown(ui, &format!("pref-{path}"), &mut cur, &pairs, 220.0); @@ -2350,7 +2373,8 @@ mod tests { continue; // Rendered as star controls beside the theme choices. } let mut labels = vec![humanize(k)]; - labels.extend(prefs::choices(&format!("{sec}.{k}")).into_iter().flatten().map(|c| choice_label(c))); + let path = format!("{sec}.{k}"); + labels.extend(prefs::choices(&path).into_iter().flatten().map(|c| pref_choice_label(&path, c))); missing.extend(labels.into_iter().filter(|l| !crate::i18n::has(lang, l))); } } @@ -2700,28 +2724,89 @@ mod tests { } #[test] - fn enable_animations_off_stops_fades_and_scroll_glides_and_is_remembered() { + fn animation_effects_follow_the_choice_or_the_system_and_are_remembered() { + use std::{cell::Cell, rc::Rc}; let on = egui::Style::default().animation_time; let both = |ctx: &egui::Context| [egui::Theme::Dark, egui::Theme::Light].map(|t| ctx.style_of(t).animation_time); // Saved off: the first frame after a restart applies it to both appearance styles. - let (mut app, _) = app_with_saved(Some(json!({"interface": {"enableAnimations": false}}).to_string())); + let (mut app, _) = app_with_saved(Some(json!({"interface": {"animationEffects": "off"}}).to_string())); let ctx = egui::Context::default(); tick(&mut app, &ctx); assert_eq!(both(&ctx), [0.0, 0.0]); assert_eq!(ctx.global_style().scroll_animation.duration.max, 0.0); + assert!(app.prefs_rt.reduce_motion); // A theme change rebuilds the style; the next frame turns animations off again. app.apply_theme(&ctx, crate::theme::ThemeKind::StudioLight); tick(&mut app, &ctx); assert_eq!(both(&ctx), [0.0, 0.0]); - app.run("prefs.set", json!({"values": {"interface.enableAnimations": true}})).unwrap(); + app.run("prefs.set", json!({"values": {"interface.animationEffects": "on"}})).unwrap(); tick(&mut app, &ctx); assert_eq!(both(&ctx), [on, on]); - assert!(on > 0.0 && ctx.global_style().scroll_animation.duration.max > 0.0); - // A hand-edited value of the wrong type doesn't crash: the defaults (animations on) stay. - let (mut bad, _) = app_with_saved(Some(json!({"interface": {"enableAnimations": "nope"}}).to_string())); - let ctx2 = egui::Context::default(); - tick(&mut bad, &ctx2); - assert_eq!(both(&ctx2), [on, on]); + assert!(on > 0.0 && ctx.global_style().scroll_animation.duration.max > 0.0 && !app.prefs_rt.reduce_motion); + + // Use System Setting, the default, follows the platform as it changes. + let system = Rc::new(Cell::new(Some(false))); + let (mut app, _) = app_with_store(); + assert_eq!(app.session.prefs().interface.animation_effects, prefs::AnimationEffects::System); + let read = system.clone(); + app.services.system_animations = Some(Box::new(move |_| read.get())); + let ctx = egui::Context::default(); + for (answer, time) in [(Some(false), 0.0), (Some(true), on), (None, on), (Some(false), 0.0)] { + system.set(answer); + tick(&mut app, &ctx); + assert_eq!(both(&ctx), [time, time], "the system says {answer:?}"); + assert_eq!(app.prefs_rt.reduce_motion, time == 0.0); + } + // On and Off hold whatever the system says. + for (answer, choice, time) in [(Some(false), "on", on), (Some(true), "off", 0.0), (Some(true), "system", on)] { + system.set(answer); + app.run("prefs.set", json!({"values": {"interface.animationEffects": choice}})).unwrap(); + tick(&mut app, &ctx); + assert_eq!(both(&ctx), [time, time], "{choice} while the system says {answer:?}"); + } + // A platform that can't tell (no service): Use System Setting keeps animations on. + let (mut plain, _) = app_with_store(); + let ctx = egui::Context::default(); + tick(&mut plain, &ctx); + assert_eq!(both(&ctx), [on, on]); + // The Enable Animations checkbox this replaced: a saved "off" is still off. + let (mut old, _) = app_with_saved(Some(json!({"interface": {"enableAnimations": false}}).to_string())); + let ctx = egui::Context::default(); + tick(&mut old, &ctx); + assert_eq!(both(&ctx), [0.0, 0.0]); + // A hand-edited value that is no choice doesn't crash: the defaults stay. + for junk in [json!("nope"), json!(7), json!(null)] { + let (mut bad, _) = app_with_saved(Some(json!({"interface": {"animationEffects": junk}}).to_string())); + let ctx = egui::Context::default(); + tick(&mut bad, &ctx); + assert_eq!(both(&ctx), [on, on]); + } + } + + /// Interface › Animation Effects is a dropdown of three choices, the system's first. + #[test] + fn animation_effects_is_a_three_way_choice_in_the_interface_section() { + use egui::accesskit::Role; + use egui_kittest::{Harness, kittest::Queryable}; + assert_eq!(humanize("animationEffects"), "Animation effects"); + let labels: Vec = + prefs::choices("interface.animationEffects").unwrap().iter().map(|c| pref_choice_label("interface.animationEffects", c)).collect(); + assert_eq!(labels, ["Use system setting", "On", "Off"]); + assert_eq!(pref_choice_label("general.colorPicker", "system"), "System", "elsewhere `system` keeps its plain label"); + let obj = json!({"animationEffects": "system"}).as_object().unwrap().clone(); + let mut h = Harness::builder() + .with_size(egui::vec2(700.0, 700.0)) + .build_ui_state(|ui, obj: &mut Map| section_fields(ui, "interface", obj, &[], crate::i18n::Lang::from_pref("en"), None, ""), obj); + h.run_steps(4); + assert!(h.get_by_label("Animation effects").rect().is_positive()); + h.get_all_by_role(Role::ComboBox).last().unwrap().click(); + h.run_steps(4); + for choice in ["Use system setting", "On", "Off"] { + assert!(h.query_all_by_label(choice).any(|item| item.rect().is_positive()), "{choice} is offered"); + } + h.get_by_label("Off").click(); + h.run_steps(4); + assert_eq!(h.state()["animationEffects"], "off"); } #[test] diff --git a/crates/ui-egui/src/wheel_nav.rs b/crates/ui-egui/src/wheel_nav.rs index 4d07537df1..3735f53b7d 100644 --- a/crates/ui-egui/src/wheel_nav.rs +++ b/crates/ui-egui/src/wheel_nav.rs @@ -20,8 +20,11 @@ //! frames, so zooming reads the wheel events themselves and ignores that smoothed tail; panning //! keeps the smoothed delta. The Alt state is taken from the wheel events and kept until the next //! wheel event: releasing Alt while the tail is still settling must not turn it into a pan. +//! +//! Preferences › Interface › Animation Effects off takes that smoothing out everywhere, panels +//! and lists included: [`unsmooth`] scrolls a notch's whole distance the frame it arrives. -use egui::{Context, Event, Id, Modifiers, MouseWheelUnit, RawInput, Vec2}; +use egui::{Context, Event, Id, Modifiers, MouseWheelUnit, RawInput, TouchPhase, Vec2}; /// Zoom factor of one wheel notch: every step is exactly ×1.1. pub const NOTCH: f32 = 1.1; @@ -132,6 +135,67 @@ pub fn fold_legacy_pinch(ctx: &Context, raw: &mut RawInput) { } } +fn touch_id() -> Id { + Id::new("pc-wheel-touch") +} + +/// What this frame's wheel events scroll in all, in points: each one in its unit and folded +/// sideways or upright by its modifiers, as egui does before it smooths them. `touch` follows +/// trackpad gestures (the ones with a begin and an end phase). `None` leaves egui's own value +/// alone: for a frame with part of such a gesture, which egui applies as it arrives (and whose +/// modifiers it holds from the start), for a wheel event that zooms, and for a hostile sum. +fn arrived(events: &[Event], options: &egui::InputOptions, page: f32, touch: &mut bool) -> Option { + let mut gesture = *touch; + let mut sum = Vec2::ZERO; + for event in events { + let Event::MouseWheel { unit, delta, phase, modifiers } = event else { continue }; + match phase { + TouchPhase::Start => (*touch, gesture) = (true, true), + TouchPhase::End | TouchPhase::Cancel => (*touch, gesture) = (false, true), + TouchPhase::Move => { + if modifiers.matches_any(options.zoom_modifier) { + return None; + } + let delta = *delta + * match unit { + MouseWheelUnit::Point => 1.0, + MouseWheelUnit::Line => options.line_scroll_speed, + MouseWheelUnit::Page => page, + }; + let sideways = modifiers.matches_any(options.horizontal_scroll_modifier); + let upright = modifiers.matches_any(options.vertical_scroll_modifier); + sum += match (sideways, upright) { + (true, false) => Vec2::new(delta.x + delta.y, 0.0), + (false, true) => Vec2::new(0.0, delta.x + delta.y), + _ => delta, + }; + } + } + } + (!gesture && sum.x.is_finite() && sum.y.is_finite()).then_some(sum) +} + +/// Interface › Animation Effects off: scroll the whole distance of a wheel notch in the frame +/// it arrives. egui spreads a notch over the next several frames (a glide of about 0.2 s, with +/// no setting to turn it off), so this replaces the frame's smoothed scroll with everything its +/// wheel events add up to; the frames after it carry only the rest of that glide and no wheel +/// events, and so scroll nothing. Call it once a frame before anything reads the scroll +/// (`PhotocraftApp::logic`). Zooming already reads the wheel events themselves ([`read`]). +pub fn unsmooth(ctx: &Context) { + let options = ctx.options(|o| o.input_options); + let was = ctx.data(|d| d.get_temp::(touch_id())).unwrap_or(false); + let mut touch = was; + ctx.input_mut(|i| { + let page = i.viewport_rect().height(); + if let Some(scroll) = arrived(&i.events, &options, page, &mut touch) { + i.smooth_scroll_delta = scroll; + } + }); + if touch != was { + ctx.data_mut(|d| d.insert_temp(touch_id(), touch)); + } +} + fn alt_id() -> Id { Id::new("pc-wheel-alt") } @@ -180,8 +244,6 @@ pub fn read(ctx: &Context, zoom_with_wheel: bool, pinch_zooms: bool) -> Option Input { @@ -362,6 +424,166 @@ mod tests { assert!(matches!(ev[0], Event::MouseWheel { .. })); } + /// `smooth_scroll_delta` as the UI reads it on each of 30 frames at 60 fps, in a context set + /// up like the app's; `off` is Animation Effects off ([`unsmooth`] at the start of the frame). + fn scrolled(frames: Vec>, off: bool) -> Vec { + let ctx = Context::default(); + configure(&ctx); + let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(800.0, 600.0)); + let mut frames = frames.into_iter(); + (0..30) + .map(|n| { + let events = frames.next().unwrap_or_default(); + let raw = RawInput { time: Some(f64::from(n) / 60.0), predicted_dt: 1.0 / 60.0, screen_rect: Some(screen), events, ..Default::default() }; + let mut seen = Vec2::ZERO; + let mut out = ctx.run_ui(raw, |ui| { + if off { + unsmooth(ui.ctx()); + } + seen = ui.input(|i| i.smooth_scroll_delta); + }); + out.textures_delta.clear(); + seen + }) + .collect() + } + + fn total(frames: &[Vec2]) -> Vec2 { + frames.iter().fold(Vec2::ZERO, |sum, d| sum + *d) + } + + /// Animation Effects off: a wheel notch scrolls its whole distance the frame it arrives, + /// instead of gliding there over the frames that follow. + #[test] + fn animations_off_scrolls_a_wheel_notch_at_once() { + let notch = || vec![vec![], vec![wheel(Vec2::new(0.0, -1.0), Modifiers::NONE)]]; + // egui by itself: part of the notch on the frame it arrives, the rest over the next ones. + let glide = scrolled(notch(), false); + assert!(glide[1].y < 0.0 && glide[1].y > -30.0, "the notch starts gliding: {:?}", glide[1]); + assert!(glide[2..8].iter().all(|d| d.y < 0.0), "and keeps gliding: {:?}", &glide[2..8]); + assert!(near(total(&glide), Vec2::new(0.0, -40.0)), "{:?}", total(&glide)); + // Off: all of it at once, and nothing after. + let jump = scrolled(notch(), true); + assert_eq!(jump[1], Vec2::new(0.0, -40.0)); + assert!(jump.iter().enumerate().all(|(n, d)| n == 1 || *d == Vec2::ZERO), "{jump:?}"); + // Sideways (⇧ or ⌘/Ctrl + wheel), two notches in one frame, a fraction of a notch each + // way, a page and a coarse pixel step (a wheel on Wayland or the web) jump the same way. + let sent = |unit, y: f32| Event::MouseWheel { unit, delta: Vec2::new(0.0, y), phase: TouchPhase::Move, modifiers: Modifiers::NONE }; + for (events, want) in [ + (vec![wheel(Vec2::new(0.0, 1.0), Modifiers::SHIFT)], Vec2::new(40.0, 0.0)), + (vec![wheel(Vec2::new(0.0, 1.0), CTRL)], Vec2::new(40.0, 0.0)), + (vec![wheel(Vec2::new(0.0, 1.0), Modifiers::NONE), wheel(Vec2::new(0.0, 1.0), Modifiers::NONE)], Vec2::new(0.0, 80.0)), + (vec![wheel(Vec2::new(-0.5, 0.25), Modifiers::NONE)], Vec2::new(-20.0, 10.0)), + (vec![sent(MouseWheelUnit::Page, -1.0)], Vec2::new(0.0, -600.0)), + (vec![sent(MouseWheelUnit::Point, 53.0)], Vec2::new(0.0, 53.0)), + ] { + let jump = scrolled(vec![events.clone()], true); + assert!(near(jump[0], want) && jump[1..].iter().all(|d| *d == Vec2::ZERO), "{events:?}: {jump:?}"); + let glide = total(&scrolled(vec![events.clone()], false)); + assert!((glide - want).length() < 1.0, "the same distance as with animations on: {events:?}: {glide:?}"); + } + // The canvas pans by all of it on that frame too, and Alt + wheel still zooms one step. + let ctx = Context::default(); + configure(&ctx); + let mut seen = None; + for (time, modifiers) in [(0.0, Modifiers::NONE), (1.0, Modifiers::ALT)] { + let raw = RawInput { time: Some(time), predicted_dt: 1.0 / 60.0, events: vec![wheel(Vec2::new(0.0, 1.0), modifiers)], ..Default::default() }; + let mut out = ctx.run_ui(raw, |ui| { + unsmooth(ui.ctx()); + seen = read(ui.ctx(), false, true); + }); + out.textures_delta.clear(); + if modifiers.alt { + assert!(matches!(seen, Some(Wheel::Zoom(f)) if (f - 1.1).abs() < 1e-4), "{seen:?}"); + } else { + assert_eq!(seen, Some(Wheel::Pan(Vec2::new(0.0, 40.0)))); + } + } + } + + /// What the setting is for: an egui scroll area (panels, lists, long menus) is at its new + /// place on the frame the notch arrives, where it otherwise glides there. + #[test] + fn animations_off_scroll_areas_jump() { + let offsets = |off: bool| -> Vec { + let ctx = Context::default(); + configure(&ctx); + let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(300.0, 200.0)); + (0..40) + .map(|n| { + let mut events = vec![Event::PointerMoved(egui::pos2(100.0, 100.0))]; + if n == 3 { + events.push(wheel(Vec2::new(0.0, -1.0), Modifiers::NONE)); + } + let raw = RawInput { time: Some(f64::from(n) / 60.0), predicted_dt: 1.0 / 60.0, screen_rect: Some(screen), events, ..Default::default() }; + let mut offset = 0.0; + let mut out = ctx.run_ui(raw, |ui| { + if off { + unsmooth(ui.ctx()); + } + let area = egui::ScrollArea::vertical().show(ui, |ui| ui.allocate_space(egui::vec2(100.0, 2000.0))); + offset = area.state.offset.y; + }); + out.textures_delta.clear(); + offset + }) + .collect() + }; + let (glide, jump) = (offsets(false), offsets(true)); + assert!(glide[3] > 0.0 && glide[3] < 30.0 && glide[4] > glide[3], "it glides: {:?}", &glide[..8]); + assert!((glide[39] - 40.0).abs() < 0.01, "to one notch down: {}", glide[39]); + assert_eq!(jump[..3], [0.0; 3]); + assert!(jump[3..].iter().all(|y| *y == 40.0), "off, it is there at once: {:?}", &jump[..8]); + } + + /// A trackpad gesture (begin and end phases) is already applied as it arrives, with its + /// modifiers held from the start: off leaves it exactly as egui has it. + #[test] + fn animations_off_leaves_trackpad_gestures_to_egui() { + let touch = |phase, y: f32, modifiers| Event::MouseWheel { unit: MouseWheelUnit::Point, delta: Vec2::new(0.0, y), phase, modifiers }; + let gesture = || { + vec![ + vec![touch(TouchPhase::Start, 0.0, Modifiers::SHIFT)], + vec![touch(TouchPhase::Move, 3.0, Modifiers::SHIFT)], + // Shift let go mid-gesture: egui keeps scrolling sideways. + vec![touch(TouchPhase::Move, 30.0, Modifiers::NONE)], + vec![touch(TouchPhase::Move, 2.0, Modifiers::NONE), touch(TouchPhase::End, 0.0, Modifiers::NONE)], + vec![], + // The wheel afterwards jumps again. + vec![wheel(Vec2::new(0.0, 1.0), Modifiers::NONE)], + ] + }; + let (on, off) = (scrolled(gesture(), false), scrolled(gesture(), true)); + assert_eq!(on[..5], off[..5], "the gesture reads the same"); + assert_eq!(on[2], Vec2::new(30.0, 0.0), "sideways for the whole gesture"); + assert_eq!(off[5], Vec2::new(0.0, 40.0)); + assert!(off[6..].iter().all(|d| *d == Vec2::ZERO)); + } + + /// A wheel event that zooms (egui's own zoom modifier, which the app turns off) and hostile + /// deltas leave the frame's scroll as egui computed it. + #[test] + fn unsmoothing_skips_zoom_and_hostile_numbers() { + let options = egui::InputOptions::default(); + let mut touch = false; + let zoom = [wheel(Vec2::new(0.0, 1.0), CTRL)]; + assert_eq!(arrived(&zoom, &options, 600.0, &mut touch), None, "egui's default: ⌘/Ctrl + wheel zooms"); + let plain = [wheel(Vec2::new(0.0, 1.0), Modifiers::NONE)]; + assert_eq!(arrived(&plain, &options, 600.0, &mut touch), Some(Vec2::new(0.0, options.line_scroll_speed))); + assert_eq!(arrived(&[], &options, 600.0, &mut touch), Some(Vec2::ZERO), "no wheel event: the rest of a glide is dropped"); + for bad in [f32::NAN, f32::INFINITY, -f32::INFINITY, f32::MAX] { + for page in [600.0, f32::NAN, f32::INFINITY, 0.0, -1.0] { + for unit in [MouseWheelUnit::Point, MouseWheelUnit::Line, MouseWheelUnit::Page] { + let events = [Event::MouseWheel { unit, delta: Vec2::new(bad, bad), phase: TouchPhase::Move, modifiers: Modifiers::SHIFT }]; + if let Some(sum) = arrived(&events, &options, page, &mut touch) { + assert!(sum.x.is_finite() && sum.y.is_finite(), "{sum:?} from {bad} {page} {unit:?}"); + } + } + } + } + assert!(!touch, "no gesture phase was seen"); + } + #[test] fn hostile_numbers_never_produce_a_bad_zoom() { for s in [f32::NAN, f32::INFINITY, -f32::INFINITY, 1e30, -1e30] { diff --git a/docs/scorecard.md b/docs/scorecard.md index d2ee641b1e..c6c93f46f6 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -191,7 +191,7 @@ Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_w | UI-217-7 | Command palette shows recently run commands on an empty query | done | [#217](https://github.com/storytold/photocraft/issues/217) | palette.rs: note_recent from menus::invoke keeps the last 8 commands (dedup, newest first); an empty query lists them via recent_hits; the_palette_records_and_replays_recent_commands_on_an_empty_query covers record -> empty query -> replay | | UI-217-8 | Tool-specific canvas right-click menu; right-click spelling suggestions in text fields | partial | [#217](https://github.com/storytold/photocraft/issues/217) | paint_mouse.rs brush picker and canvas_tool_menu.rs selection actions; text_field_menu.rs gives every text field its right-click Undo/Cut/Copy/Paste/Delete/Select All menu (#2921); other tools missing; spelling suggestions (edit.checkSpelling suggest) not in the text-field menu yet | | UI-217-9 | UI scale presets 100/115/125/150/200 % through zoom_factor, remembered | done | [#217](https://github.com/storytold/photocraft/issues/217) | prefs::UiScale offers Auto plus 75 to 300 percent (13 presets, more than the five this row lists); prefs_ui.rs display_scale resolves it (Auto follows the system scale, fractional and unscaled 4K included, #1072/#1278) and sync_display_scale applies it with ctx.set_zoom_factor. It is a preference, so it is remembered. The zoom_factor assert in input_tests.rs is about canvas zoom not scaling the interface, not about this setting | -| UI-217-10 | Appearance: animation toggle, canvas pattern toggle per theme, start-screen recents | partial | [#217](https://github.com/storytold/photocraft/issues/217) | interface.enableAnimations (prefs_ui.rs sync_animations, #3273) zeroes egui animation_time and scroll animation in both styles; the Home screen lists recent files (canvas.rs home_recent, #2691); no canvas pattern toggle yet (#2264) and no option to hide the Home screen recents | +| UI-217-10 | Appearance: animation toggle, canvas pattern toggle per theme, start-screen recents | partial | [#217](https://github.com/storytold/photocraft/issues/217) | interface.animationEffects (system, on, off; prefs_ui.rs sync_animations, #3273) zeroes egui animation_time and scroll animation in both styles, and wheel_nav::unsmooth takes out egui's wheel glide; system, the default, follows the OS animation setting through Services::system_animations (apps/photocraft/src/animations.rs for Windows, macOS, Linux and the BSDs; prefers-reduced-motion on the web); the Home screen lists recent files (canvas.rs home_recent, #2691); no canvas pattern toggle yet (#2264) and no option to hide the Home screen recents | | UI-217-11 | Soft dark and soft light themes with picker previews; outlined knobs in light themes | missing | [#217](https://github.com/storytold/photocraft/issues/217) | theme.rs ThemeKind has twelve themes (the four Pro brightness levels, Studio and Studio Light, Classic, Adwaita and Adwaita Dark, Solarized Dark, Breeze Light and Breeze Dark); no Soft dark or Soft light, and no outlined knobs in the light themes | | UI-217-12 | Save custom New Document presets; a real Recent category | done | [#217](https://github.com/storytold/photocraft/issues/217) | document_preset_cmds.rs and new_doc_ui.rs: named presets save/select/delete through preferences; Recent lists Clipboard, the last 20 documents created in the dialog (document.recent.*, persisted with the presets, newest first, deduplicated) and the uncovered defaults (#3131); created_documents_fill_the_recent_category | | UI-217-13 | Numeric fields accept arithmetic and units; scrubby labels; double-click resets a slider | done | [#217](https://github.com/storytold/photocraft/issues/217) | widgets::value_field: arithmetic plus units (1in, 5mm, 72pt, 50%) converted at the document resolution (#3099); widgets::scrub_label makes options-bar, slider-row and Character labels scrubby (Shift x10, Alt fine); slider rows with a known default reset on double-click | diff --git a/scorecard/ui.toml b/scorecard/ui.toml index 3fa79b59fa..2542c2f16c 100644 --- a/scorecard/ui.toml +++ b/scorecard/ui.toml @@ -73,7 +73,7 @@ id = "UI-217-10" target = "Appearance: animation toggle, canvas pattern toggle per theme, start-screen recents" status = "partial" issue = 217 -note = "interface.enableAnimations (prefs_ui.rs sync_animations, #3273) zeroes egui animation_time and scroll animation in both styles; the Home screen lists recent files (canvas.rs home_recent, #2691); no canvas pattern toggle yet (#2264) and no option to hide the Home screen recents" +note = "interface.animationEffects (system, on, off; prefs_ui.rs sync_animations, #3273) zeroes egui animation_time and scroll animation in both styles, and wheel_nav::unsmooth takes out egui's wheel glide; system, the default, follows the OS animation setting through Services::system_animations (apps/photocraft/src/animations.rs for Windows, macOS, Linux and the BSDs; prefers-reduced-motion on the web); the Home screen lists recent files (canvas.rs home_recent, #2691); no canvas pattern toggle yet (#2264) and no option to hide the Home screen recents" [[item]] id = "UI-217-11" From 051a4d6778b6f0a7e85491f77d863dbe3b7452df Mon Sep 17 00:00:00 2001 From: itsF4LCON <107556180+itsF4LCON@users.noreply.github.com> Date: Tue, 13 Oct 2026 05:00:20 +0200 Subject: [PATCH 038/649] History panel: the snapshot strings in the Serbian catalog (#2966) --- crates/ui-egui/src/i18n/sr.tsv | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsv index 9d8aebef63..54567192ce 100644 --- a/crates/ui-egui/src/i18n/sr.tsv +++ b/crates/ui-egui/src/i18n/sr.tsv @@ -2236,6 +2236,9 @@ Create Snapshot Napravi snimak stanja Delete Snapshot Obriši snimak stanja New Snapshot Novi snimak stanja + From: Od: + Full Document Ceo dokument + Merged Layers Spojeni slojevi Snapshot 1 Snimak stanja 1 Step Forward Korak napred Step Backward Korak nazad From a128094e93e76732f247824b9cdd386f26754cae Mon Sep 17 00:00:00 2001 From: Jeremy Yao Date: Tue, 13 Oct 2026 04:26:42 -0400 Subject: [PATCH 039/649] chore: opt JeremyYao into public profile credit Co-Authored-By: Claude Opus 5.5 --- contributors/people.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contributors/people.toml b/contributors/people.toml index bbda6719ec..d360d5525e 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -154,3 +154,6 @@ sync_github_name = true [people.VanTan666] display_name = "VanTan" sync_github_name = false + +[people.JeremyYao] +sync_github_name = true From 7f4a5e37a9eb6fa84ddeeb50f1ee81088904be23 Mon Sep 17 00:00:00 2001 From: mighty-programmer <83077551+mighty-programmer@users.noreply.github.com> Date: Tue, 13 Oct 2026 13:33:07 +0300 Subject: [PATCH 040/649] Wrap optional model guidance in translated preferences --- crates/ui-egui/src/prefs_ui.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs index 6bad4fee6f..f6f90efd04 100644 --- a/crates/ui-egui/src/prefs_ui.rs +++ b/crates/ui-egui/src/prefs_ui.rs @@ -1253,10 +1253,10 @@ fn local_model_rows(app: &mut PhotocraftApp, ui: &mut egui::Ui, obj: &mut Map Date: Tue, 13 Oct 2026 13:56:51 +0300 Subject: [PATCH 041/649] Retain channel composite allocation across visibility changes --- crates/ui-egui/src/channel_view.rs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/channel_view.rs b/crates/ui-egui/src/channel_view.rs index 38116e58e1..c1df3f5562 100644 --- a/crates/ui-egui/src/channel_view.rs +++ b/crates/ui-egui/src/channel_view.rs @@ -22,6 +22,7 @@ const MAX_SIDE: u32 = 4096; const MAX_COMPOSITE_CACHE_PIXELS: usize = 8 * 1024 * 1024; struct SampledComposite { + doc: std::sync::Weak, revision: u64, preview_key: u64, factor: u32, @@ -273,9 +274,20 @@ pub fn ensure(app: &mut PhotocraftApp, ctx: &egui::Context, idx: usize) -> Optio // A live preview can mutate the same Arc in place. Revision and preview_key, not // pointer identity, determine whether these flattened pixels are still current. if let Some(c) = app.channel_views.get_mut(&id) - && c.source.as_ref().is_some_and(|s| s.factor != factor || s.revision != revision || s.preview_key != preview_key) + && let Some(source) = c.source.as_mut() { - c.source = None; + // Channel visibility bumps the view revision without replacing the committed document. + // Keep its sampled pixels. Pixel edits replace the COW snapshot; live previews also + // require an unchanged revision/key because they can mutate a snapshot in place. + let same = source.factor == factor + && source.preview_key == preview_key + && source.doc.ptr_eq(&std::sync::Arc::downgrade(&doc)) + && (preview_key == 0 || source.revision == revision); + if same { + source.revision = revision; + } else { + c.source = None; + } } if let Some(c) = app.channel_views.get(&id) && c.key == key @@ -325,12 +337,12 @@ pub fn ensure(app: &mut PhotocraftApp, ctx: &egui::Context, idx: usize) -> Optio c.factor = factor; c.valid = true; if let Some(pixels) = fresh.take() { - c.source = Some(SampledComposite { revision, preview_key, factor, pixels }); + c.source = Some(SampledComposite { doc: std::sync::Arc::downgrade(&doc), revision, preview_key, factor, pixels }); } } _ => { let tex = ctx.load_texture(format!("channel-view-{id}"), img, TextureOptions::LINEAR); - let source = fresh.map(|pixels| SampledComposite { revision, preview_key, factor, pixels }); + let source = fresh.map(|pixels| SampledComposite { doc: std::sync::Arc::downgrade(&doc), revision, preview_key, factor, pixels }); app.channel_views.insert(id, Cache { revision, key, preview_key, factor, valid: true, tex, source }); } } @@ -391,6 +403,11 @@ mod tests { app.run("channel.setVisible", json!({"channel": "red", "visible": false})).unwrap(); assert!(ensure(&mut app, &ctx, 0).is_some()); let id = app.session.active().unwrap().doc.id.0; + // Give the existing allocation spare capacity. Recomputing could accidentally reuse + // its freed address, but a fresh composite cannot retain this capacity. + let first = app.channel_views.get_mut(&id).unwrap().source.as_mut().unwrap(); + first.pixels.reserve_exact(1); + let capacity = first.pixels.capacity(); let first = app.channel_views.get(&id).unwrap().source.as_ref().unwrap(); let original_sample = first.pixels[0]; let ptr = first.pixels.as_ptr(); @@ -398,6 +415,7 @@ mod tests { app.run("channel.setVisible", json!({"channel": "green", "visible": false})).unwrap(); assert!(ensure(&mut app, &ctx, 0).is_some()); let reused = app.channel_views.get(&id).unwrap().source.as_ref().unwrap(); + assert_eq!(capacity, reused.pixels.capacity(), "visibility must retain the composite allocation"); assert_eq!(ptr, reused.pixels.as_ptr(), "visibility does not recompose the pixels"); app.run("edit.fill", json!({"color": "#e02010"})).unwrap(); From 42a03e2c97a21a6bea54f9ed3bd16a2c0f9a131e Mon Sep 17 00:00:00 2001 From: mighty-programmer <83077551+mighty-programmer@users.noreply.github.com> Date: Tue, 13 Oct 2026 14:13:00 +0300 Subject: [PATCH 042/649] Constrain model guidance to the visible Preferences pane --- crates/ui-egui/src/prefs_ui.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs index f6f90efd04..672c4f0873 100644 --- a/crates/ui-egui/src/prefs_ui.rs +++ b/crates/ui-egui/src/prefs_ui.rs @@ -1248,6 +1248,16 @@ fn prefs_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map) { + // The Preferences grid can leave a wider layout than its visible scroll area. Bound this + // child to the clip rectangle so long translations wrap inside the actual dialog. + let width = ui.available_width().min((ui.clip_rect().right() - ui.next_widget_position().x - 8.0).max(1.0)); + ui.scope(|ui| { + ui.set_max_width(width); + local_model_rows_inner(app, ui, obj); + }); +} + +fn local_model_rows_inner(app: &mut PhotocraftApp, ui: &mut egui::Ui, obj: &mut Map) { let t = Tokens::get(ui.ctx()); let status = app.session.local_model_status(); let available = status["available"].as_bool().unwrap_or(false); From ce94ac430df12d301308d4068b5fda4d7f948bd9 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 13 Oct 2026 14:24:55 +0000 Subject: [PATCH 043/649] test(algo): pin seam carving's tall-image output; bench_seam timing example The reduced-height seam search for tall images (P28's path) had no bit-exact test: output_bits_are_pinned and carver_matches_reference only cover images under 2048 rows. Pin five proxy-path carves (widths and, through the transposed pass, heights; with and without protection) from the current code, so the speed work that follows can't change which seams are chosen. bench_seam times the carver alone on a synthetic 24 MP photo (P28's width change, its height change) and two exact-path sizes, and prints a hash of each output. Before (4 cores, release): 2279 ms, 4872 ms, 1542 ms and 658 ms p50. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LELc5BQzgV5dA7dxdMejkK --- crates/algo/examples/bench_seam.rs | 78 ++++++++++++++++++++++++++++++ crates/algo/src/seam.rs | 29 +++++++++++ 2 files changed, 107 insertions(+) create mode 100644 crates/algo/examples/bench_seam.rs diff --git a/crates/algo/examples/bench_seam.rs b/crates/algo/examples/bench_seam.rs new file mode 100644 index 0000000000..e427a6b270 --- /dev/null +++ b/crates/algo/examples/bench_seam.rs @@ -0,0 +1,78 @@ +//! Timing of Content-Aware Scale's seam carving alone (no document plumbing), on a synthetic +//! photo-like RGBA image: perf scenario P28's 24 MP width change (#211), the same image's height +//! (the transposed pass) and two images short enough for the exact full-resolution seam search. +//! Prints an FNV-1a hash of each output's bits, so a speed-up can be checked to choose exactly the +//! same seams. +//! `cargo run --release -p photocraft-algo --example bench_seam [reps] [case filter]` +use std::time::Instant; + +use photocraft_algo::seam::carve; + +/// Smooth gradients, a few hard-edged shapes and fine noise: enough structure that seams are +/// steered by content, as in a photo. +fn photo(w: usize, h: usize) -> Vec { + let mut seed = 0x9e37_79b9u32; + let mut noise = move || { + seed ^= seed << 13; + seed ^= seed >> 17; + seed ^= seed << 5; + (seed % 1000) as f32 / 1000.0 - 0.5 + }; + let mut img = Vec::with_capacity(w * h * 4); + for y in 0..h { + for x in 0..w { + let (u, v) = (x as f32 / w as f32, y as f32 / h as f32); + let sky = 0.35 + 0.4 * v; + let disc = ((u - 0.3).powi(2) + (v - 0.55).powi(2)) < 0.02; + let bar = (0.62..0.66).contains(&u) && v > 0.3; + let hill = v > 0.7 + 0.08 * (u * 11.0).sin(); + let (r, g, b) = if disc { + (0.85, 0.3, 0.2) + } else if bar { + (0.1, 0.1, 0.12) + } else if hill { + (0.2, 0.45 + 0.1 * (u * 40.0).sin(), 0.15) + } else { + (sky * 0.6, sky * 0.8, sky) + }; + let n = noise() * 0.02; + img.extend_from_slice(&[r + n, g + n, b + n, 1.0]); + } + } + img +} + +fn fnv(v: &[f32]) -> u64 { + v.iter().fold(0xcbf2_9ce4_8422_2325u64, |h, f| (h ^ u64::from(f.to_bits())).wrapping_mul(0x0100_0000_01b3)) +} + +fn main() { + let args: Vec = std::env::args().collect(); + let reps = args.get(1).and_then(|s| s.parse::().ok()).unwrap_or(1).clamp(1, 20); + let only = args.get(2).cloned(); + // (name, w, h, new w, new h) + let cases = [ + ("24 MP to 90 % width (P28, proxy rows)", 6000, 4000, 5400, 4000), + ("24 MP to 90 % height (transposed, proxy rows)", 6000, 4000, 6000, 3600), + ("5.4 MP to 90 % width (exact)", 3000, 1800, 2700, 1800), + ("1.5 MP to 70 % width (exact)", 1500, 1000, 1050, 1000), + ]; + for (name, w, h, nw, nh) in cases { + if only.as_ref().is_some_and(|o| !name.contains(o.as_str())) { + continue; + } + let img = photo(w, h); + let mut times = Vec::with_capacity(reps); + let mut hash = 0; + for _ in 0..reps { + let t = Instant::now(); + let out = carve(w, h, 4, &img, None, nw, nh); + times.push(t.elapsed().as_secs_f64() * 1000.0); + hash = fnv(&out); + } + times.sort_by(f64::total_cmp); + let p50 = times[times.len() / 2]; + let max = times[times.len() - 1]; + println!("{name:<48} p50 {p50:>9.1} ms max {max:>9.1} ms output {hash:016x}"); + } +} diff --git a/crates/algo/src/seam.rs b/crates/algo/src/seam.rs index 97619c7406..498e84a414 100644 --- a/crates/algo/src/seam.rs +++ b/crates/algo/src/seam.rs @@ -852,6 +852,35 @@ mod tests { 0x2157_9f86_27d6_b835, ]; + /// [`output_bits_are_pinned`] for the reduced-height seam search of tall images (rows at + /// least [`PROXY_SHRINK_MIN_HEIGHT`], at least [`PROXY_SHRINK_MIN_SEAMS`] seams): widths and, + /// through the transposed pass, heights, with and without protection, on tie-heavy and + /// fine-grained noise. + #[test] + fn tall_proxy_output_bits_are_pinned() { + let cases: [(usize, usize, usize, u32, bool, usize, usize); 5] = [ + (96, PROXY_SHRINK_MIN_HEIGHT, 3, 2, false, 30, PROXY_SHRINK_MIN_HEIGHT), + (130, 2_100, 4, 255, true, 64, 2_100), + (80, 2_600, 1, 65_536, false, 16, 2_600), + (PROXY_SHRINK_MIN_HEIGHT, 90, 3, 5, false, PROXY_SHRINK_MIN_HEIGHT, 20), + (2_050, 100, 4, 1000, true, 2_050, 36), + ]; + let got: Vec = cases + .iter() + .enumerate() + .map(|(i, &(w, h, ch, levels, prot, nw, nh))| { + let img = noise(w * h * ch, levels, 31 + i as u32); + let protect = prot.then(|| noise(w * h, 3, 131 + i as u32)); + let out = carve(w, h, ch, &img, protect.as_deref(), nw, nh); + assert_eq!(out.len(), nw * nh * ch); + fnv(&out) + }) + .collect(); + assert_eq!(got, TALL_PINNED); + } + + const TALL_PINNED: [u64; 5] = [0x5657_83ac_cb26_56a5, 0x81a6_b5f7_e299_fdfb, 0xcdf2_9df9_9b83_def5, 0xa713_544a_4dcc_d8d8, 0x3557_de9f_ffb0_881e]; + #[test] fn one_pixel_lines_enlarge_by_repeating() { // Width 1 has no seam to spare: its one column is repeated. Height 1 likewise (through From 67d32bcab592c27282cb60020553fefe8d905516 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 13 Oct 2026 15:09:45 +0000 Subject: [PATCH 044/649] perf(algo): Content-Aware Scale keeps its seam search and moves no pixels (#211) Seam carving recomputed the whole dynamic programme for every seam (about 1.8 G serial cell updates for P28's 600 seams) and shifted every buffer, the image included, over each removed pixel. - The seam search keeps its path-cost map across seams. After a removal only the pixels near the seam and those whose parents' costs actually changed are recomputed, row by row; nothing else can change, so the map is bit-identical to a full pass (incremental_dp_matches_ full_dp checks it after every removal). The direction buffer is gone: the seam is traced back from the costs with the same tie rules. - The carver no longer copies or moves pixels: it keeps each remaining pixel's source column (u32) and reads energy neighbours and the output through it. A removal shifts the shorter side of each row in three 4-byte buffers instead of the longer tail in up to four, 16-byte pixels included. - The tall-image proxy build, its full-resolution rebuild (runs copied between removed columns), the height pass's transposes (blocked) and the plain resample run in parallel over rows. Output is unchanged: the pinned hashes (small and tall images), the 400-case reference comparison and bench_seam's hashes of 24 MP results all match. bench_seam, interleaved A/B over 5 rounds on 4 cores: 24 MP to 90 % width (P28) 2292 -> 612 ms, 24 MP to 90 % height 2795 -> 1076 ms, 5.4 MP exact path 1912 -> 797 ms, 1.5 MP 782 -> 428 ms. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LELc5BQzgV5dA7dxdMejkK --- crates/algo/src/seam.rs | 580 +++++++++++++++++++++++++++++----------- 1 file changed, 424 insertions(+), 156 deletions(-) diff --git a/crates/algo/src/seam.rs b/crates/algo/src/seam.rs index 498e84a414..8b5befda80 100644 --- a/crates/algo/src/seam.rs +++ b/crates/algo/src/seam.rs @@ -33,7 +33,7 @@ pub fn energy(w: usize, h: usize, ch: usize, img: &[f32]) -> Vec { } let row = |(y, out): (usize, &mut [f32])| { for (x, v) in out.iter_mut().enumerate() { - *v = energy_at(img, w, w, h, ch, x, y); + *v = energy_at(img, w, w, h, ch, x, y, |xx, _| xx); } }; #[cfg(not(target_arch = "wasm32"))] @@ -46,18 +46,21 @@ pub fn energy(w: usize, h: usize, ch: usize, img: &[f32]) -> Vec { e } -/// [`energy`] of one pixel of a `cw`-wide image whose rows are `stride` pixels apart. Shared by -/// the full map and the per-seam updates so both give bit-identical values. +/// [`energy`] of pixel `x` of row `y` of a `cw`-wide, `h`-tall image whose pixel `xx` of row `yy` +/// is column `col(xx, yy)` of `img` (`w` pixels per row). Shared by the full map and the carver's +/// per-seam updates, so both give bit-identical values. +#[allow(clippy::too_many_arguments)] #[inline] -fn energy_at(img: &[f32], stride: usize, cw: usize, h: usize, ch: usize, x: usize, y: usize) -> f32 { +fn energy_at(img: &[f32], w: usize, cw: usize, h: usize, ch: usize, x: usize, y: usize, col: impl Fn(usize, usize) -> usize) -> f32 { let (xl, xr) = (x.saturating_sub(1), (x + 1).min(cw - 1)); let (yu, yd) = (y.saturating_sub(1), (y + 1).min(h - 1)); - let at = |xx: usize, yy: usize, c: usize| img[(yy * stride + xx) * ch + c]; + let at = |xx: usize, yy: usize| (yy * w + col(xx, yy)) * ch; + let (centre, right, left, down, up) = (at(x, y), at(xr, y), at(xl, y), at(x, yd), at(x, yu)); let mut s = 0.0; for c in 0..ch { - let v = at(x, y, c); - s += (at(xr, y, c) - v).abs() + (v - at(xl, y, c)).abs(); - s += (at(x, yd, c) - v).abs() + (v - at(x, yu, c)).abs(); + let v = img[centre + c]; + s += (img[right + c] - v).abs() + (v - img[left + c]).abs(); + s += (img[down + c] - v).abs() + (v - img[up + c]).abs(); } s * 0.5 } @@ -67,57 +70,177 @@ pub fn find_seam(w: usize, h: usize, energy: &[f32]) -> Vec { if w == 0 || h == 0 || energy.len() < w * h { return vec![0; h]; } - Dp::default().seam(w, w, h, energy) + let off = vec![0; h]; + let rows = Rows { stride: w, cw: w, off: &off }; + let mut dp = Dp::default(); + dp.full(rows, energy); + dp.seam(rows) } -/// Scratch buffers for the seam search, reused across seams. +/// Where the `cw` pixels in use of each of a carver's rows are, in buffers whose rows are +/// `stride` apart: row y's are `off[y]..off[y] + cw` of its `stride` slots. +#[derive(Clone, Copy)] +struct Rows<'o> { + stride: usize, + cw: usize, + off: &'o [usize], +} + +impl Rows<'_> { + fn h(&self) -> usize { + self.off.len() + } + + /// Row y's pixels in use, as a range of its buffers. + #[inline] + fn of(&self, y: usize) -> std::ops::Range { + let start = y * self.stride + self.off[y]; + start..start + self.cw + } +} + +/// The seam search's dynamic programme over an energy map laid out as [`Rows`] (the carver's own +/// layout, so a removal shifts it like the other buffers): for every pixel, the cost of the +/// cheapest 8-connected path down to it from the top row. [`Carver`] keeps it across seams and +/// recomputes only what each removal changed ([`Dp::update`]). #[derive(Default)] struct Dp { + /// Cost of the cheapest path from the top row to each pixel. cost: Vec, - next: Vec, - /// Per pixel, where the cheapest path came from: 0 = up-left, 1 = up, 2 = up-right. - from: Vec, +} + +/// Pixel `x` of a `cw`-wide row with energy `e`, given the path costs of the row above (`up`): +/// its path cost and where that path came from (0 = up-left, 1 = up, 2 = up-right). Ties go to +/// the pixel straight up, then up-left, then up-right. The cost doesn't depend on the tie-break +/// and the direction doesn't depend on `e`, so the seam can be traced back from the costs alone. +/// The full pass's edges, [`Dp::update`] and [`Dp::seam`] use it, and the full pass's interior +/// repeats it exactly, so every way of filling the map gives the same bits. +#[inline] +fn cell(up: &[f32], cw: usize, x: usize, e: f32) -> (f32, u8) { + let (b, d) = if x == 0 { + if cw > 1 && up[1] < up[0] { (up[1], 2) } else { (up[0], 1) } + } else if x + 1 == cw { + if up[x - 1] < up[x] { (up[x - 1], 0) } else { (up[x], 1) } + } else { + let (b, d) = if up[x - 1] < up[x] { (up[x - 1], 0) } else { (up[x], 1) }; + if up[x + 1] < b { (up[x + 1], 2) } else { (b, d) } + }; + (b + e, d) +} + +/// Path costs of pixels `lo..lo + out.len()` of a `cw`-wide row with energies `e` (the whole +/// row's), from the path costs of the row above (`up`), into `out`. [`cell`] at the ends of the +/// row; in between, the same selection without edge tests or directions, so it vectorises. +#[inline] +fn row_costs(up: &[f32], e: &[f32], cw: usize, lo: usize, out: &mut [f32]) { + let Some(last) = (lo + out.len()).checked_sub(1) else { return }; + let (mut a, mut b) = (lo, last); + if a == 0 { + out[0] = cell(up, cw, 0, e[0]).0; + a = 1; + } + if b + 1 == cw && b >= a { + out[b - lo] = cell(up, cw, b, e[b]).0; + b -= 1; + } + if a > b { + return; + } + // Every pixel in a..=b has all three parents: up-left, up and up-right. + let parents = up[a - 1..b].iter().zip(&up[a..=b]).zip(&up[a + 1..=b + 1]); + for ((n, &ev), ((&l, &u), &r)) in out[a - lo..=b - lo].iter_mut().zip(&e[a..=b]).zip(parents) { + let m = if l < u { l } else { u }; + let m = if r < m { r } else { m }; + *n = m + ev; + } } impl Dp { - /// The lowest-energy seam of a `cw`-wide, `h`-tall energy map with rows `stride` apart. - /// Ties go to the pixel straight up, then up-left, then up-right; at the bottom, to the - /// leftmost end. - fn seam(&mut self, stride: usize, cw: usize, h: usize, energy: &[f32]) -> Vec { - self.cost.clear(); - self.cost.extend_from_slice(&energy[..cw]); - self.next.resize(cw, 0.0); - self.from.resize(cw * h, 0); - for y in 1..h { - let (cost, next) = (&self.cost[..cw], &mut self.next[..cw]); - let e = &energy[y * stride..y * stride + cw]; - let from = &mut self.from[y * cw..(y + 1) * cw]; - if cw == 1 { - (next[0], from[0]) = (cost[0] + e[0], 1); - } else { - let (b, d) = if cost[1] < cost[0] { (cost[1], 2) } else { (cost[0], 1) }; - (next[0], from[0]) = (b + e[0], d); - // The interior has all three parents: no edge tests in the hot loop. - let inner = next[1..cw - 1].iter_mut().zip(&mut from[1..cw - 1]).zip(&e[1..cw - 1]).zip(cost.windows(3)); - for (((n, f), &ev), c) in inner { - let (b, d) = if c[0] < c[1] { (c[0], 0) } else { (c[1], 1) }; - let (b, d) = if c[2] < b { (c[2], 2) } else { (b, d) }; - (*n, *f) = (b + ev, d); - } - let (b, d) = if cost[cw - 2] < cost[cw - 1] { (cost[cw - 2], 0) } else { (cost[cw - 1], 1) }; - (next[cw - 1], from[cw - 1]) = (b + e[cw - 1], d); - } - std::mem::swap(&mut self.cost, &mut self.next); + /// Fill the map for the pixels in use of every row of `energy`. + fn full(&mut self, rows: Rows, energy: &[f32]) { + let (cw, h) = (rows.cw, rows.h()); + self.cost.resize(rows.stride * h, 0.0); + if cw == 0 || h == 0 { + return; } - let cost = &self.cost[..cw]; - let mut x = (0..cw).min_by(|a, b| cost[*a].total_cmp(&cost[*b])).unwrap_or(0); + let first = rows.of(0); + self.cost[first.clone()].copy_from_slice(&energy[first]); + for y in 1..h { + let (above, rest) = self.cost.split_at_mut(y * rows.stride); + let (r, base) = (rows.of(y), y * rows.stride); + row_costs(&above[rows.of(y - 1)], &energy[r.clone()], cw, 0, &mut rest[r.start - base..r.end - base]); + } + } + + /// Bring the map up to date after `seam` (one x per row, counted before the removal) was + /// removed from every row of the map and of `energy`, leaving `rows.cw` pixels per row. + /// + /// A pixel's path cost depends only on its energy and on the costs of its parents in the row + /// above. Where a pixel and all its parents are on the same side of the seam in their rows, + /// the removal moved them together; that leaves, in row y, only the pixels from one left of + /// min(seam[y-1], seam[y]) to max(seam[y-1], seam[y]) with new parents. The energy changed + /// only where [`Carver::update_energy`] recomputed it: from one left of the leftmost of + /// `seam[y-1..=y+1]` to the rightmost, which covers those pixels too. Every other pixel needs + /// recomputing only if a parent's cost changed, so the work follows the changed costs down + /// the map and narrows wherever they settle, instead of covering the whole map. Recomputed + /// pixels go through [`cell`], so the map matches a [`Dp::full`] pass over the same energy + /// bit for bit. + fn update(&mut self, rows: Rows, energy: &[f32], seam: &[usize]) { + let (cw, h) = (rows.cw, rows.h()); + if cw == 0 || h == 0 || seam.len() < h { + return; + } + // Pixels of the row above whose cost changed: `lo..=hi`, or none when `lo > hi`. + let (mut changed_lo, mut changed_hi) = (usize::MAX, 0); + let mut fresh = Vec::new(); + for y in 0..h { + let near = &seam[y.saturating_sub(1)..(y + 2).min(h)]; + let mut lo = near.iter().min().map_or(0, |&s| s.saturating_sub(1)); + let mut hi = near.iter().max().map_or(0, |&s| s.min(cw - 1)); + if changed_lo <= changed_hi { + lo = lo.min(changed_lo.saturating_sub(1)); + hi = hi.max((changed_hi + 1).min(cw - 1)); + } + let (above, rest) = self.cost.split_at_mut(y * rows.stride); + let (r, base) = (rows.of(y), y * rows.stride); + let e = &energy[r.clone()]; + if fresh.len() < hi + 1 - lo { + fresh.resize(hi + 1 - lo, 0.0); + } + let fresh = &mut fresh[..hi + 1 - lo]; + match y.checked_sub(1) { + Some(u) => row_costs(&above[rows.of(u)], e, cw, lo, fresh), + None => fresh.copy_from_slice(&e[lo..=hi]), + } + // Store only what changed, and remember where that was for the row below. + let row = &mut rest[r.start - base + lo..r.start - base + hi + 1]; + let differs = |(a, b): (&f32, &f32)| a.to_bits() != b.to_bits(); + (changed_lo, changed_hi) = (usize::MAX, 0); + if let Some(first) = fresh.iter().zip(row.iter()).position(differs) { + let last = fresh.iter().zip(row.iter()).rposition(differs).unwrap_or(first); + row[first..=last].copy_from_slice(&fresh[first..=last]); + (changed_lo, changed_hi) = (lo + first, lo + last); + } + } + } + + /// The lowest-energy seam of the map: one x per row. At the bottom, ties go to the leftmost + /// end; going up, [`cell`] tells where each pixel's path came from. + fn seam(&self, rows: Rows) -> Vec { + let (cw, h) = (rows.cw, rows.h()); let mut seam = vec![0usize; h]; + if cw == 0 || h == 0 { + return seam; + } + let last = &self.cost[rows.of(h - 1)]; + let mut x = (0..cw).min_by(|a, b| last[*a].total_cmp(&last[*b])).unwrap_or(0); for y in (0..h).rev() { seam[y] = x; if y > 0 { - x = match self.from[y * cw + x] { - 0 => x - 1, - 2 => x + 1, + // `cell` never points past either end of the row; saturate rather than trust it. + x = match cell(&self.cost[rows.of(y - 1)], cw, x, 0.0).1 { + 0 => x.saturating_sub(1), + 2 => (x + 1).min(cw - 1), _ => x, }; } @@ -126,118 +249,212 @@ impl Dp { } } -/// Shrinks an image one seam at a time in place. Rows keep their original stride, so removing a -/// seam shifts only the rest of each row (in parallel), and the energy map is updated only next -/// to the removed seam instead of being recomputed: the gradient of a pixel changes only when a -/// neighbour does, which happens within a pixel of the seam in its own row and the rows around it. -struct Carver { - stride: usize, - cw: usize, +/// Shrinks an image one seam at a time without moving its pixels: the carver keeps which source +/// column each remaining pixel is (`idx`) and reads pixels through it. A removal shifts, in each +/// row, whichever side of the seam is shorter in the three per-pixel buffers (in parallel over +/// rows), and nothing is recomputed in full: the gradient of a pixel changes only when a +/// neighbour does, which happens within a pixel of the seam in its own row and the rows around +/// it, and the seam search's path costs are updated from there down ([`Dp::update`]). +struct Carver<'a> { + /// The image, `w × h × ch`, and the protection, one value per pixel: as given, never moved. + src: &'a [f32], + prot: Option<&'a [f32]>, + w: usize, h: usize, ch: usize, - img: Vec, - prot: Option>, + /// Pixels left per row. + cw: usize, + /// Where each row's first remaining pixel is in the per-pixel buffers (see [`Rows`]). + off: Vec, + /// Source column of each remaining pixel (rows `w` apart; layer areas are at most i32::MAX + /// wide, so `u32` holds any column). + idx: Vec, /// Energy plus protection, as the seam search sees it. e: Vec, - /// Original column of each pixel, when the caller needs to know which ones were removed. - idx: Option>, + /// The seam search over `e`, kept up to date. dp: Dp, } -impl Carver { - fn new(w: usize, h: usize, ch: usize, img: Vec, prot: Option>, track: bool) -> Self { - let mut e = energy(w, h, ch, &img); - if let Some(p) = &prot { +impl<'a> Carver<'a> { + fn new(w: usize, h: usize, ch: usize, src: &'a [f32], prot: Option<&'a [f32]>) -> Self { + let mut e = energy(w, h, ch, src); + if let Some(p) = prot { for (e, p) in e.iter_mut().zip(p) { *e += p.clamp(0.0, 1.0) * PROTECT_ENERGY; } } - let idx = track.then(|| (0..h).flat_map(|_| 0..w).collect()); - Carver { stride: w, cw: w, h, ch, img, prot, e, idx, dp: Dp::default() } + let idx = (0..h).flat_map(|_| (0..w).map(|x| u32::try_from(x).unwrap_or(u32::MAX))).collect(); + let off = vec![0; h]; + let mut dp = Dp::default(); + dp.full(Rows { stride: w, cw: w, off: &off }, &e); + Carver { src, prot, w, h, ch, cw: w, off, idx, e, dp } } - /// Remove the lowest-energy seam. Returns, per row, the removed column (the original column - /// when tracking). + /// Remove the lowest-energy seam. Returns, per row, the source column removed. fn remove_seam(&mut self) -> Vec { - let (stride, cw, h, ch) = (self.stride, self.cw, self.h, self.ch); - let seam = self.dp.seam(stride, cw, h, &self.e); - let removed = match &self.idx { - Some(idx) => seam.iter().enumerate().map(|(y, &x)| idx[y * stride + x]).collect(), - None => seam.clone(), - }; - shift_rows(&mut self.img, stride * ch, &seam, ch, cw); - shift_rows(&mut self.e, stride, &seam, 1, cw); - if let Some(p) = &mut self.prot { - shift_rows(p, stride, &seam, 1, cw); - } - if let Some(idx) = &mut self.idx { - shift_rows(idx, stride, &seam, 1, cw); + if self.cw == 0 { + return Vec::new(); } + let rows = Rows { stride: self.w, cw: self.cw, off: &self.off }; + let seam = self.dp.seam(rows); + let removed = seam.iter().enumerate().map(|(y, &x)| self.idx[rows.of(y).start + x] as usize).collect(); + self.shift(&seam); self.cw -= 1; self.update_energy(&seam); + self.dp.update(Rows { stride: self.w, cw: self.cw, off: &self.off }, &self.e, &seam); removed } + /// Remove `seam[y]` from each row of the per-pixel buffers. + fn shift(&mut self, seam: &[usize]) { + let (w, cw) = (self.w, self.cw); + #[cfg(not(target_arch = "wasm32"))] + { + use rayon::prelude::*; + self.e + .par_chunks_mut(w) + .zip(self.idx.par_chunks_mut(w)) + .zip(self.dp.cost.par_chunks_mut(w)) + .zip(self.off.par_iter_mut()) + .zip(seam.par_iter()) + .for_each(|((((e, idx), cost), off), &x)| shift_row(e, idx, cost, off, x, cw)); + } + #[cfg(target_arch = "wasm32")] + self.e + .chunks_mut(w) + .zip(self.idx.chunks_mut(w)) + .zip(self.dp.cost.chunks_mut(w)) + .zip(self.off.iter_mut()) + .zip(seam) + .for_each(|((((e, idx), cost), off), &x)| shift_row(e, idx, cost, off, x, cw)); + } + /// Recompute the energy of the pixels whose neighbours changed when `seam` was removed: in /// row y, from one left of the leftmost of the seam's x in rows y-1..=y+1 to the rightmost. fn update_energy(&mut self, seam: &[usize]) { - let (stride, cw, h, ch) = (self.stride, self.cw, self.h, self.ch); + let (w, cw, h, ch) = (self.w, self.cw, self.h, self.ch); if cw == 0 { return; } - let (img, prot) = (&self.img, self.prot.as_deref()); + let (src, prot, off, idx) = (self.src, self.prot, &self.off, &self.idx); + let col = |xx: usize, yy: usize| idx[yy * w + off[yy] + xx] as usize; let row = |(y, e): (usize, &mut [f32])| { let near = &seam[y.saturating_sub(1)..(y + 2).min(h)]; let lo = near.iter().min().map_or(0, |&s| s.saturating_sub(1)); let hi = near.iter().max().map_or(0, |&s| s.min(cw - 1)); for x in lo..=hi { - let mut v = energy_at(img, stride, cw, h, ch, x, y); + let mut v = energy_at(src, w, cw, h, ch, x, y, col); if let Some(p) = prot { - v += p[y * stride + x].clamp(0.0, 1.0) * PROTECT_ENERGY; + v += p[y * w + col(x, y)].clamp(0.0, 1.0) * PROTECT_ENERGY; } - e[x] = v; + e[off[y] + x] = v; + } + }; + // A few pixels per row (seams move at most one column per row), but each waits on reads + // from three rows of the source: rows in parallel overlap the waits. + #[cfg(not(target_arch = "wasm32"))] + { + use rayon::prelude::*; + self.e.par_chunks_mut(w).enumerate().for_each(row); + } + #[cfg(target_arch = "wasm32")] + self.e.chunks_mut(w).enumerate().for_each(row); + } + + /// The carved pixels, `cw × h × ch`, rows packed. + fn into_pixels(self) -> Vec { + let (w, cw, ch) = (self.w, self.cw, self.ch); + let mut out = vec![0.0f32; cw * self.h * ch]; + if cw == 0 { + return out; + } + let (src, off, idx) = (self.src, &self.off, &self.idx); + let row = |(y, out): (usize, &mut [f32])| { + let cols = &idx[y * w + off[y]..y * w + off[y] + cw]; + for (px, &x) in out.chunks_exact_mut(ch).zip(cols) { + let s = (y * w + x as usize) * ch; + px.copy_from_slice(&src[s..s + ch]); } }; #[cfg(not(target_arch = "wasm32"))] { use rayon::prelude::*; - self.e.par_chunks_mut(stride).enumerate().for_each(row); + out.par_chunks_mut(cw * ch).enumerate().for_each(row); } #[cfg(target_arch = "wasm32")] - self.e.chunks_mut(stride).enumerate().for_each(row); - } - - /// The carved pixels, `cw × h × ch`, rows packed. - fn into_pixels(self) -> Vec { - let (row, used) = (self.stride * self.ch, self.cw * self.ch); - if row == used { - return self.img; - } - self.img.chunks(row).flat_map(|r| &r[..used]).copied().collect() + out.chunks_mut(cw * ch).enumerate().for_each(row); + out } } -/// Remove pixel `seam[y]` (of `n` values) from each `row_len`-long row whose first `cw` pixels -/// are in use, by shifting the rest of the row left. -fn shift_rows(buf: &mut [T], row_len: usize, seam: &[usize], n: usize, cw: usize) { - let shift = |(r, &x): (&mut [T], &usize)| r.copy_within((x + 1) * n..cw * n, x * n); - #[cfg(not(target_arch = "wasm32"))] - { - use rayon::prelude::*; - buf.par_chunks_mut(row_len).zip(seam.par_iter()).for_each(shift); +/// Remove pixel `x` of the `cw` in use, from `off` on, of one row of a carver's per-pixel +/// buffers, moving whichever side of it holds fewer pixels (the row then starts one later when +/// that is the left side). +fn shift_row(e: &mut [f32], idx: &mut [u32], cost: &mut [f32], off: &mut usize, x: usize, cw: usize) { + let o = *off; + if x < cw - 1 - x { + e.copy_within(o..o + x, o + 1); + idx.copy_within(o..o + x, o + 1); + cost.copy_within(o..o + x, o + 1); + *off = o + 1; + } else { + e.copy_within(o + x + 1..o + cw, o + x); + idx.copy_within(o + x + 1..o + cw, o + x); + cost.copy_within(o + x + 1..o + cw, o + x); } - #[cfg(target_arch = "wasm32")] - buf.chunks_mut(row_len).zip(seam).for_each(shift); } fn transpose(w: usize, h: usize, ch: usize, img: &[f32]) -> Vec { let mut out = vec![0.0f32; img.len()]; - for y in 0..h { - for x in 0..w { - let (s, d) = ((y * w + x) * ch, (x * h + y) * ch); - out[d..d + ch].copy_from_slice(&img[s..s + ch]); - } + if w == 0 || h == 0 || ch == 0 { + return out; } + // Output rows (source columns) in blocks, so each source cache line serves several of them. + const BLOCK: usize = 16; + let block = |(b, out): (usize, &mut [f32])| { + let x0 = b * BLOCK; + let n = out.len() / (h * ch); + for y in 0..h { + for i in 0..n { + let (s, d) = ((y * w + x0 + i) * ch, (i * h + y) * ch); + out[d..d + ch].copy_from_slice(&img[s..s + ch]); + } + } + }; + #[cfg(not(target_arch = "wasm32"))] + { + use rayon::prelude::*; + out.par_chunks_mut(BLOCK * h * ch).enumerate().for_each(block); + } + #[cfg(target_arch = "wasm32")] + out.chunks_mut(BLOCK * h * ch).enumerate().for_each(block); + out +} + +/// Each `step` rows of `src` (`h` rows of `row_len` values) averaged into one, the last group +/// possibly shorter: `h.div_ceil(step)` rows. +fn average_rows(src: &[f32], row_len: usize, h: usize, step: usize) -> Vec { + let mut out = vec![0.0; h.div_ceil(step) * row_len]; + if row_len == 0 { + return out; + } + let group = |(py, out_row): (usize, &mut [f32])| { + let y0 = py * step; + let y1 = (y0 + step).min(h); + let divisor = (y1 - y0) as f32; + for y in y0..y1 { + for (out, &sample) in out_row.iter_mut().zip(&src[y * row_len..(y + 1) * row_len]) { + *out += sample / divisor; + } + } + }; + #[cfg(not(target_arch = "wasm32"))] + { + use rayon::prelude::*; + out.par_chunks_exact_mut(row_len).enumerate().for_each(group); + } + #[cfg(target_arch = "wasm32")] + out.chunks_exact_mut(row_len).enumerate().for_each(group); out } @@ -250,7 +467,8 @@ pub fn carve_width(w: usize, h: usize, ch: usize, img: &[f32], protect: Option<& /// [`carve_width`] that checks `ctl` before every seam and reports progress per seam. pub fn carve_width_with(w: usize, h: usize, ch: usize, img: &[f32], protect: Option<&[f32]>, new_w: usize, ctl: &Interrupt) -> Result, Cancelled> { let new_w = new_w.max(1); - if new_w == w || w == 0 || h == 0 { + // No channels: nothing to carve (and no pixels to size the work by). + if new_w == w || w == 0 || h == 0 || ch == 0 { return Ok(img.to_vec()); } let seams = new_w.abs_diff(w).max(1) as f32; @@ -258,7 +476,7 @@ pub fn carve_width_with(w: usize, h: usize, ch: usize, img: &[f32], protect: Opt if h >= PROXY_SHRINK_MIN_HEIGHT && w - new_w >= PROXY_SHRINK_MIN_SEAMS { return carve_width_proxy_height(w, h, ch, img, protect, new_w, ctl); } - let mut carver = Carver::new(w, h, ch, img.to_vec(), protect.map(<[f32]>::to_vec), false); + let mut carver = Carver::new(w, h, ch, img, protect); while carver.cw > new_w { ctl.check()?; ctl.progress((w - carver.cw) as f32 / seams); @@ -272,7 +490,7 @@ pub fn carve_width_with(w: usize, h: usize, ch: usize, img: &[f32], protect: Opt while cw < new_w { let k = (new_w - cw).min((cw / 2).max(1)); // Find k seams on a shrinking copy, mapping each back to original columns. - let mut carver = Carver::new(cw, h, ch, cur.clone(), prot.clone(), true); + let mut carver = Carver::new(cw, h, ch, &cur, prot.as_deref()); let mut dup: Vec> = vec![Vec::with_capacity(k); h]; for _ in 0..k { // A 1 px wide image's only seam is its one column: take it, so it is duplicated. @@ -329,37 +547,11 @@ fn carve_width_proxy_height(w: usize, h: usize, ch: usize, img: &[f32], protect: let step = h.div_ceil(SEAM_SEARCH_MAX_HEIGHT); let proxy_h = h.div_ceil(step); let row_len = w * ch; - let proxy_row_len = proxy_h * row_len; - let mut proxy = vec![0.0; proxy_row_len]; - for (py, out_row) in proxy.chunks_exact_mut(row_len).enumerate() { - let y0 = py * step; - let y1 = (y0 + step).min(h); - let divisor = (y1 - y0) as f32; - for y in y0..y1 { - let in_row = &img[y * row_len..(y + 1) * row_len]; - for (out, &sample) in out_row.iter_mut().zip(in_row) { - *out += sample / divisor; - } - } - } - let proxy_protect = protect.map(|mask| { - let mut reduced = vec![0.0; proxy_h * w]; - for (py, out_row) in reduced.chunks_exact_mut(w).enumerate() { - let y0 = py * step; - let y1 = (y0 + step).min(h); - let divisor = (y1 - y0) as f32; - for y in y0..y1 { - let in_row = &mask[y * w..(y + 1) * w]; - for (out, &sample) in out_row.iter_mut().zip(in_row) { - *out += sample / divisor; - } - } - } - reduced - }); + let proxy = average_rows(img, row_len, h, step); + let proxy_protect = protect.map(|mask| average_rows(mask, w, h, step)); let seam_count = w - new_w; - let mut carver = Carver::new(w, proxy_h, ch, proxy, proxy_protect, true); + let mut carver = Carver::new(w, proxy_h, ch, &proxy, proxy_protect.as_deref()); let mut removed = Vec::with_capacity(seam_count); while carver.cw > new_w { ctl.check()?; @@ -373,31 +565,44 @@ fn carve_width_proxy_height(w: usize, h: usize, ch: usize, img: &[f32], protect: columns.sort_unstable(); removed_by_row.push(columns); } - let mut out = Vec::with_capacity(new_w * h * ch); - let mut columns = vec![0; seam_count]; - for y in 0..h { + // Each full-resolution row removes the columns interpolated between its two proxy rows'. + let rebuild = |columns: &mut Vec, (y, out): (usize, &mut [f32])| -> Result<(), Cancelled> { ctl.check()?; let proxy_y = (y / step).min(proxy_h - 1); let next_proxy_y = (proxy_y + 1).min(proxy_h - 1); let blend = (y % step) as f32 / step as f32; let lower = &removed_by_row[proxy_y]; let upper = &removed_by_row[next_proxy_y]; + columns.clear(); let mut min_x = 0; - for (i, x) in columns.iter_mut().enumerate() { + for i in 0..seam_count { let interpolated = lower[i] as f32 + (upper[i] as f32 - lower[i] as f32) * blend; let max_x = w - (seam_count - i); - *x = (interpolated.round() as usize).clamp(min_x, max_x); + let x = (interpolated.round() as usize).clamp(min_x, max_x); + columns.push(x); min_x = x.saturating_add(1); } - let mut next = 0; + // The columns rise strictly within the row: copy the runs between them. let row = &img[y * row_len..(y + 1) * row_len]; - for (x, pixel) in row.chunks_exact(ch).enumerate() { - if columns.get(next) == Some(&x) { - next += 1; - } else { - out.extend_from_slice(pixel); - } + let (mut from, mut at) = (0, 0); + for &x in columns.iter() { + let run = (x - from) * ch; + out[at..at + run].copy_from_slice(&row[from * ch..x * ch]); + (from, at) = (x + 1, at + run); } + out[at..].copy_from_slice(&row[from * ch..]); + Ok(()) + }; + let mut out = vec![0.0f32; new_w * h * ch]; + #[cfg(not(target_arch = "wasm32"))] + { + use rayon::prelude::*; + out.par_chunks_exact_mut(new_w * ch).enumerate().try_for_each_init(|| Vec::with_capacity(seam_count), rebuild)?; + } + #[cfg(target_arch = "wasm32")] + { + let mut columns = Vec::with_capacity(seam_count); + out.chunks_exact_mut(new_w * ch).enumerate().try_for_each(|r| rebuild(&mut columns, r))?; } ctl.progress(1.0); Ok(out) @@ -443,10 +648,10 @@ pub fn carve_with( /// Plain bilinear resize (the non-content-aware part of the Amount blend). pub fn resize_bilinear(w: usize, h: usize, ch: usize, img: &[f32], nw: usize, nh: usize) -> Vec { let mut out = vec![0.0f32; nw * nh * ch]; - if w == 0 || h == 0 { + if w == 0 || h == 0 || nw == 0 || nh == 0 { return out; } - for y in 0..nh { + let row = |(y, out): (usize, &mut [f32])| { let fy = ((y as f32 + 0.5) * h as f32 / nh as f32 - 0.5).clamp(0.0, (h - 1) as f32); let (y0, ty) = (fy.floor() as usize, fy.fract()); let y1 = (y0 + 1).min(h - 1); @@ -458,10 +663,17 @@ pub fn resize_bilinear(w: usize, h: usize, ch: usize, img: &[f32], nw: usize, nh let p = |xx: usize, yy: usize| img[(yy * w + xx) * ch + c]; let top = p(x0, y0) + (p(x1, y0) - p(x0, y0)) * tx; let bot = p(x0, y1) + (p(x1, y1) - p(x0, y1)) * tx; - out[(y * nw + x) * ch + c] = top + (bot - top) * ty; + out[x * ch + c] = top + (bot - top) * ty; } } + }; + #[cfg(not(target_arch = "wasm32"))] + { + use rayon::prelude::*; + out.par_chunks_mut(nw * ch).enumerate().for_each(row); } + #[cfg(target_arch = "wasm32")] + out.chunks_mut(nw * ch).enumerate().for_each(row); out } @@ -683,6 +895,62 @@ mod tests { } } + /// After every removal, the carver's incrementally updated seam search matches a full pass + /// over its current energy bit for bit (path costs and the seam traced from them), on images + /// where seams run through the edges, through flat areas full of ties and through protection. + /// Its energy matches a fresh map of the pixels left, and so do the pixels. + #[test] + fn incremental_dp_matches_full_dp() { + let mut ramp = vec![0.0f32; 120 * 90]; + for (i, v) in ramp.iter_mut().enumerate() { + let (x, y) = ((i % 120) as f32, (i / 120) as f32); + *v = ((x * 0.07).sin() * (y * 0.05).cos() * 0.5 + 0.5).clamp(0.0, 1.0); + } + // (w, h, channels, image, protection, seams to remove) + type Case = (usize, usize, usize, Vec, Option>, usize); + let cases: Vec = vec![ + (120, 90, 1, ramp, None, 40), + (97, 64, 3, noise(97 * 64 * 3, 2, 5), None, 90), + (80, 70, 4, noise(80 * 70 * 4, 1000, 6), Some(noise(80 * 70, 3, 7)), 60), + (64, 50, 3, bar(64, 50), None, 63), + (33, 1, 1, noise(33, 5, 8), None, 32), + (2, 40, 3, noise(2 * 40 * 3, 9, 9), None, 2), + (50, 40, 1, vec![0.5; 50 * 40], Some(noise(50 * 40, 2, 10)), 49), + ]; + let bits = |v: &[f32]| v.iter().map(|f| f.to_bits()).collect::>(); + for (case, (w, h, ch, img, prot, seams)) in cases.into_iter().enumerate() { + let mut c = Carver::new(w, h, ch, &img, prot.as_deref()); + for step in 0..=seams { + let rows = Rows { stride: c.w, cw: c.cw, off: &c.off }; + let mut fresh = Dp::default(); + fresh.full(rows, &c.e); + for y in 0..h { + assert_eq!(bits(&c.dp.cost[rows.of(y)]), bits(&fresh.cost[rows.of(y)]), "case {case} step {step} row {y}: costs"); + } + assert_eq!(c.dp.seam(rows), fresh.seam(rows), "case {case} step {step}: seam"); + // The pixels left, packed, and their energy (plus protection) from scratch. + let left: Vec = (0..h) + .flat_map(|y| c.idx[rows.of(y)].iter().flat_map(move |&x| (0..ch).map(move |k| (y * w + x as usize) * ch + k))) + .map(|i| img[i]) + .collect(); + let mut want = energy(c.cw, h, ch, &left); + if let Some(p) = &prot { + let kept = (0..h).flat_map(|y| c.idx[rows.of(y)].iter().map(move |&x| y * w + x as usize)); + for (e, i) in want.iter_mut().zip(kept) { + *e += p[i].clamp(0.0, 1.0) * PROTECT_ENERGY; + } + } + let have: Vec = (0..h).flat_map(|y| c.e[rows.of(y)].to_vec()).collect(); + assert_eq!(bits(&have), bits(&want), "case {case} step {step}: energy"); + if step == seams { + assert_eq!(bits(&c.into_pixels()), bits(&left), "case {case}: pixels"); + break; + } + c.remove_seam(); + } + } + } + #[test] fn cancelled_carve_stops() { let (w, h) = (40, 20); From d466da3d57153aec0e73f9a76e9aef765f5b4a49 Mon Sep 17 00:00:00 2001 From: Fabio Lissi Date: Tue, 13 Oct 2026 10:45:26 -0500 Subject: [PATCH 045/649] Camera Raw: Calibration panel, Auto, raw sidecars and live Camera Raw Defaults (FILE-215-11) Three pieces of G14 that needed no new data or dependencies. Calibration: Camera Raw's panel (Shadows tint, Red/Green/Blue Primary hue and saturation) as a develop stage in linear light. A pixel's hue turns by the weighted Hue of the primaries it is made of (triangular weights at 0, 120 and 240 degrees; +/-100 is +/-30 degrees, towards the next primary) and its saturation scales by their weighted Saturation; the luminance is kept, so neutrals are untouched. The shadow tint is magenta or green weighted by darkness, luminance kept, white untouched. The seven crs: keys load and save with the settings file, and filter.cameraRaw takes shadowTint, calibrationHue and calibrationSat. Auto: the Light panel's button (and "auto": true on the control channel) sets Exposure, Contrast, Highlights, Shadows, Whites and Blacks from the image's luminance histogram; the sliders show what it chose. The Apply auto tone preference opens a raw with it. Sidecars: a raw opened from a path reads IMG_0001.xmp beside it into the open-time dialog, naming in the status bar what the loader skipped (the absolute kelvin white balance has no counterpart), and Open writes the sidecar back when the settings aren't the defaults or one exists; never beside a DNG, off with the new rawDefaults.writeXmpSidecars preference. With "Open in Camera Raw" off, the sidecar still develops the file. Camera Raw Defaults: the six preferences the dialog hid as dead now act when a raw opens, with or without the dialog: colour space (a conversion from the develop's ProPhoto; Adobe RGB by default, as Photoshop's workflow), bit depth, resolution (300 ppi from 72), Sharpen For (folded into the Camera Raw step as 25/1.0, 35/1.2 or 40/1.0), Open as Smart Object and Apply auto tone; the dialog's reply lists what it applied, and opening still leaves the document unmodified. Tests: calibration maths and Auto (algo), the preset's RedHue now applied (io), calibration round trip, Auto and its preference, sidecar read / write / DNG / preference / no-dialog, and the defaults on open (ui-egui); the hidden-preference test lists the Camera Raw rows as live. Nine strings in every catalog. Scorecard FILE-215-11 missing -> partial with the evidence (lossy DNG from #5112 included); gaps G14 updated, with the CR3 assessment: the CRX codec has no public specification, only LGPL implementations, so a clean-room decoder is not possible. --- crates/algo/src/camera_raw.rs | 201 +++++++++++++++ crates/engine/src/lens_cmds.rs | 2 +- crates/engine/src/prefs.rs | 36 ++- crates/io/src/camera_raw_xmp.rs | 16 +- crates/ui-egui/src/camera_raw_ui.rs | 363 +++++++++++++++++++++++++++- crates/ui-egui/src/i18n/cs.tsv | 10 + crates/ui-egui/src/i18n/de.tsv | 10 + crates/ui-egui/src/i18n/el.tsv | 10 + crates/ui-egui/src/i18n/es.tsv | 10 + crates/ui-egui/src/i18n/fr.tsv | 10 + crates/ui-egui/src/i18n/hu.tsv | 10 + crates/ui-egui/src/i18n/id.tsv | 10 + crates/ui-egui/src/i18n/it.tsv | 10 + crates/ui-egui/src/i18n/ja.tsv | 10 + crates/ui-egui/src/i18n/ko.tsv | 10 + crates/ui-egui/src/i18n/nl.tsv | 10 + crates/ui-egui/src/i18n/pl.tsv | 10 + crates/ui-egui/src/i18n/pt-br.tsv | 10 + crates/ui-egui/src/i18n/ru.tsv | 10 + crates/ui-egui/src/i18n/sr.tsv | 10 + crates/ui-egui/src/i18n/tr.tsv | 10 + crates/ui-egui/src/i18n/uk.tsv | 10 + crates/ui-egui/src/i18n/vi.tsv | 10 + crates/ui-egui/src/i18n/zh-hans.tsv | 10 + crates/ui-egui/src/i18n/zh-hant.tsv | 10 + crates/ui-egui/src/jobs_ui.rs | 1 + crates/ui-egui/src/lib.rs | 3 + crates/ui-egui/src/prefs_ui.rs | 7 +- docs/control-protocol.md | 12 +- docs/gaps.md | 15 +- docs/scorecard.md | 10 +- scorecard/file_compat.toml | 4 +- 32 files changed, 837 insertions(+), 33 deletions(-) diff --git a/crates/algo/src/camera_raw.rs b/crates/algo/src/camera_raw.rs index f855b08bfe..faab3731ee 100644 --- a/crates/algo/src/camera_raw.rs +++ b/crates/algo/src/camera_raw.rs @@ -172,6 +172,13 @@ pub struct CameraRaw { /// The document's transfer curve: 0 for sRGB's, else the gamma of a power-law space (1.8 /// for ProPhoto). Set from the document's profile; Whites and Blacks act on light. pub encoding_gamma: f32, + // Calibration (Camera Raw's Calibration panel) + /// Shadows › Tint: −100 (green) … 100 (magenta), strongest in the darkest tones. + pub shadow_tint: f32, + /// Red, Green and Blue Primary › Hue: −100 … 100, the primary turned towards its neighbours. + pub calibration_hue: [f32; 3], + /// Red, Green and Blue Primary › Saturation: −100 (grey) … 100 (purer). + pub calibration_sat: [f32; 3], } impl Default for CameraRaw { @@ -228,6 +235,9 @@ impl Default for CameraRaw { seed: 0, pixel_scale: 1.0, encoding_gamma: 0.0, + shadow_tint: 0.0, + calibration_hue: [0.0; 3], + calibration_sat: [0.0; 3], } } } @@ -235,6 +245,90 @@ impl Default for CameraRaw { /// Hue band centres of the Color Mixer (degrees). pub const HSL_BANDS: [f32; 8] = [0.0, 30.0, 60.0, 120.0, 180.0, 240.0, 270.0, 300.0]; +/// How far a primary turns at Hue ±100 (degrees), as the Color Mixer's hue sliders do. +const CALIBRATION_TURN: f32 = 30.0; + +/// How much of each primary (red, green, blue) a hue is made of: triangular weights around +/// 0°, 120° and 240° that sum to one, so a colour between two primaries follows both. +pub fn calibration_weights(hue: f32) -> [f32; 3] { + let h = hue.rem_euclid(360.0); + let mut w = [0.0f32; 3]; + for (i, centre) in [0.0f32, 120.0, 240.0].iter().enumerate() { + let d = (h - centre).abs().min(360.0 - (h - centre).abs()); + w[i] = (1.0 - d / 120.0).max(0.0); + } + let sum: f32 = w.iter().sum(); + if sum > 1e-6 { w.map(|v| v / sum) } else { [1.0, 0.0, 0.0] } +} + +/// The Calibration panel's primaries on one linear-light pixel: its hue turns by the weighted +/// Hue of the primaries it is made of (±100 is ±30°, positive towards the next primary) and its +/// saturation scales by their weighted Saturation (−100 greys it); the luminance is kept, so +/// neutrals are untouched. +fn calibrate(c: [f32; 3], hue: [f32; 3], sat: [f32; 3]) -> [f32; 3] { + let [h, s, v] = rgb_to_hsv(c.map(|x| x.max(0.0))); + if s <= 1e-5 || v <= 1e-6 { + return c; + } + let w = calibration_weights(h); + let (mut dh, mut ds) = (0.0f32, 0.0f32); + for i in 0..3 { + dh += w[i] * hue[i].clamp(-100.0, 100.0); + ds += w[i] * sat[i].clamp(-100.0, 100.0); + } + let nh = h + dh / 100.0 * CALIBRATION_TURN; + let ns = (s * (1.0 + ds / 100.0)).clamp(0.0, 1.0); + let out = hsv_to_rgb(nh, ns, v); + let (l0, l1) = (luma(c), luma(out)); + if l1 > 1e-6 { out.map(|x| x * l0 / l1) } else { out } +} + +/// Shadows › Tint on one linear-light pixel: `tint` −1 (green) … 1 (magenta), weighted by how +/// dark the pixel is; the luminance is kept. +fn shadow_tint(c: [f32; 3], tint: f32) -> [f32; 3] { + let l = luma(c).max(0.0); + // Linear 0.18 is middle grey: full strength below it, fading out towards white. + let weight = (1.0 - (l / 0.18).sqrt().min(1.0)).powi(2) * 0.5 + (1.0 - l.min(1.0)).powi(4) * 0.5; + let k = tint * 0.12 * weight * (l + 0.02); + let o = [c[0] + k, c[1] - k, c[2] + k].map(|v| v.max(0.0)); + let l2 = luma(o); + if l2 > 1e-6 { o.map(|v| v * l / l2) } else { o } +} + +/// Camera Raw's Auto for the Light panel: Exposure, Contrast, Highlights, Shadows, Whites and +/// Blacks from the image's luminance histogram (`px` in the document's encoding). A well +/// exposed image gets near-zero settings; a dark one more exposure and lifted shadows; one +/// with a crushed or blown end gets Blacks or Whites back from the edge. The other panels are +/// left alone, as Camera Raw's Auto leaves them. +pub fn auto_tone(px: &[[f32; 4]], p: &mut CameraRaw) { + if px.is_empty() { + return; + } + let mut lum: Vec = px.iter().map(|q| luma([q[0], q[1], q[2]]).clamp(0.0, 1.0)).collect(); + lum.sort_by(|a, b| a.total_cmp(b)); + let at = |f: f32| lum[((lum.len() - 1) as f32 * f).round() as usize]; + let (black, shadow, median, light, white) = (at(0.001), at(0.1), at(0.5), at(0.9), at(0.999)); + // Exposure: the median towards middle grey (sRGB 0.46), damped so flat scenes aren't + // forced to it. + let median_lin = srgb_to_linear(median).max(1e-4); + p.exposure = (0.6 * (0.18f32 / median_lin).log2()).clamp(-2.0, 2.0); + // Blacks and Whites bring the ends to the edges without clipping more than Camera Raw does. + p.blacks = ((0.04 - black) * 400.0).clamp(-40.0, 40.0); + p.whites = ((0.96 - white) * 300.0).clamp(-40.0, 40.0); + // Shadows up when the darker tenth is crushed, highlights down when the brighter tenth is + // near white. + p.shadows = ((0.25 - shadow) * 200.0).clamp(0.0, 50.0); + p.highlights = ((light - 0.85) * -300.0).clamp(-50.0, 0.0); + // A little contrast for a flat histogram. + let spread = (light - shadow).max(0.0); + p.contrast = ((0.6 - spread) * 60.0).clamp(0.0, 25.0); + // Shown as Camera Raw shows them: Exposure to a hundredth of a stop, the others whole. + p.exposure = (p.exposure * 100.0).round() / 100.0; + for v in [&mut p.blacks, &mut p.whites, &mut p.shadows, &mut p.highlights, &mut p.contrast] { + *v = v.round(); + } +} + fn luma(c: [f32; 3]) -> f32 { 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2] } @@ -540,6 +634,10 @@ impl CameraRaw { fn grade_neutral(&self) -> bool { self.grade_shadows.neutral() && self.grade_midtones.neutral() && self.grade_highlights.neutral() && self.grade_global.neutral() } + /// The Calibration panel at rest. + fn calibration_neutral(&self) -> bool { + self.shadow_tint == 0.0 && self.calibration_hue.iter().chain(&self.calibration_sat).all(|v| *v == 0.0) + } fn curves_neutral(&self) -> bool { [self.curve_highlights, self.curve_lights, self.curve_darks, self.curve_shadows].iter().all(|v| *v == 0.0) && [&self.point_curve, &self.point_curve_red, &self.point_curve_green, &self.point_curve_blue].iter().all(|c| is_linear(c)) @@ -547,6 +645,7 @@ impl CameraRaw { /// True when every control is neutral (the filter is an identity). pub fn is_identity(&self) -> bool { self.wb_neutral() + && self.calibration_neutral() && self.tone_neutral() && self.dehaze == 0.0 && self.vibrance == 0.0 @@ -598,6 +697,24 @@ pub fn develop(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw, float: bo } }); } + // 1b. Calibration: the primaries turned and purer or greyer, and the shadows tinted, in + // linear light (the camera's primaries are what Camera Raw's panel calibrates). + if !p.calibration_neutral() { + let primaries = p.calibration_hue.iter().chain(&p.calibration_sat).any(|v| *v != 0.0); + let tint = p.shadow_tint.clamp(-100.0, 100.0) / 100.0; + par_rows(px, w, 1, |_, row| { + for q in row.iter_mut() { + let c = [srgb_to_linear(q[0]), srgb_to_linear(q[1]), srgb_to_linear(q[2])]; + let mut o = if primaries { calibrate(c, p.calibration_hue, p.calibration_sat) } else { c }; + if tint != 0.0 { + o = shadow_tint(o, tint); + } + for k in 0..3 { + q[k] = linear_to_srgb(o[k].max(0.0)); + } + } + }); + } // 2. Dehaze. if p.dehaze != 0.0 { dehaze(px, w, h, p.dehaze / 100.0); @@ -1150,6 +1267,90 @@ mod tests { assert!(v[0][0] < 0.35 && (v[(h / 2) * w + w / 2][0] - 0.5).abs() < 0.01, "{:?}", v[0]); } + #[test] + fn calibration_turns_primaries_keeps_neutrals_and_tints_shadows() { + let w = calibration_weights(0.0); + assert!((w[0] - 1.0).abs() < 1e-6, "pure red is all red primary: {w:?}"); + let w = calibration_weights(60.0); + assert!((w[0] - 0.5).abs() < 1e-6 && (w[1] - 0.5).abs() < 1e-6, "yellow is half red, half green: {w:?}"); + let w = calibration_weights(300.0); + assert!((w[2] - 0.5).abs() < 1e-6 && (w[0] - 0.5).abs() < 1e-6, "magenta wraps round: {w:?}"); + let (none, zero) = ([0.0f32; 3], [0.0f32; 3]); + let grey = calibrate([0.3, 0.3, 0.3], [100.0, -100.0, 50.0], [100.0, -100.0, 100.0]); + assert!(grey.iter().all(|v| (v - 0.3).abs() < 1e-5), "greys are untouched: {grey:?}"); + // Red turned towards green: it gains green, keeps its luminance. + let red = calibrate([0.5, 0.0, 0.0], [100.0, 0.0, 0.0], zero); + assert!(red[1] > 0.05 && (red[1] / red[0] - 0.5).abs() < 0.02 && red[2] < 1e-6, "red turns 30° towards green (orange): {red:?}"); + assert!((luma(red) - luma([0.5, 0.0, 0.0])).abs() < 1e-4, "luminance kept: {red:?}"); + // Blue at saturation −100 is grey; green at −50 is paler. + let blue = calibrate([0.0, 0.0, 0.8], none, [0.0, 0.0, -100.0]); + assert!((blue[0] - blue[1]).abs() < 1e-5 && (blue[1] - blue[2]).abs() < 1e-5, "blue at −100 saturation is grey: {blue:?}"); + let green = calibrate([0.2, 0.8, 0.2], none, [0.0, -50.0, 0.0]); + assert!(green[0] > 0.2 && green[1] < 0.8, "green at −50 is paler: {green:?}"); + // A primary's sliders leave the other primaries alone. + let unchanged = calibrate([0.0, 0.0, 0.8], [100.0, 100.0, 0.0], [100.0, 100.0, 0.0]); + assert!(unchanged.iter().zip([0.0, 0.0, 0.8]).all(|(a, b)| (a - b).abs() < 1e-5), "{unchanged:?}"); + // Shadows tint: magenta lifts red and blue over green in a dark pixel, keeps luminance, + // and leaves white alone. + let dark = shadow_tint([0.02, 0.02, 0.02], 1.0); + assert!(dark[0] > dark[1] && dark[2] > dark[1], "{dark:?}"); + assert!((luma(dark) - 0.02).abs() < 1e-4, "luminance kept: {dark:?}"); + let green = shadow_tint([0.02, 0.02, 0.02], -1.0); + assert!(green[1] > green[0], "{green:?}"); + let white = shadow_tint([1.0, 1.0, 1.0], 1.0); + assert!(white.iter().all(|v| (v - 1.0).abs() < 1e-3), "white is not tinted: {white:?}"); + // Through develop: neutral settings are an identity, a tint changes dark pixels only. + let mut p = CameraRaw::default(); + assert!(p.is_identity()); + p.shadow_tint = 100.0; + assert!(!p.is_identity()); + let mut px = vec![[0.1, 0.1, 0.1, 1.0], [0.95, 0.95, 0.95, 1.0]]; + develop(&mut px, 2, 1, &p, false); + assert!(px[0][0] > px[0][1], "dark grey turns magenta: {:?}", px[0]); + assert!((px[1][0] - px[1][1]).abs() < 0.01, "near-white stays neutral: {:?}", px[1]); + p = CameraRaw::default(); + p.calibration_hue[2] = 100.0; + let mut px = vec![[0.0, 0.0, 0.8, 1.0]]; + develop(&mut px, 1, 1, &p, false); + assert!(px[0][0] > 0.05, "blue turned towards red: {:?}", px[0]); + } + + #[test] + fn auto_tone_brightens_dark_and_darkens_bright_images() { + let mut p = CameraRaw::default(); + auto_tone(&[], &mut p); + assert_eq!(p, CameraRaw::default(), "no pixels: nothing changes"); + let dark: Vec<[f32; 4]> = (0..4096) + .map(|i| { + let v = 0.05 + (i % 64) as f32 / 64.0 * 0.15; + [v, v, v, 1.0] + }) + .collect(); + auto_tone(&dark, &mut p); + assert!(p.exposure > 0.5, "a dark image gets exposure: {}", p.exposure); + assert!(p.shadows > 0.0, "and lifted shadows: {}", p.shadows); + let mut p = CameraRaw::default(); + let bright: Vec<[f32; 4]> = (0..4096) + .map(|i| { + let v = 0.8 + (i % 64) as f32 / 64.0 * 0.19; + [v, v, v, 1.0] + }) + .collect(); + auto_tone(&bright, &mut p); + assert!(p.exposure < -0.5, "a bright image loses exposure: {}", p.exposure); + assert!(p.highlights < 0.0, "and its highlights come down: {}", p.highlights); + let mut p = CameraRaw::default(); + let good: Vec<[f32; 4]> = (0..4096) + .map(|i| { + let v = 0.04 + (i % 64) as f32 / 63.0 * 0.92; + [v, v, v, 1.0] + }) + .collect(); + auto_tone(&good, &mut p); + assert!(p.exposure.abs() < 0.3 && p.blacks.abs() < 10.0 && p.whites.abs() < 10.0, "a full-range image is left nearly alone: {p:?}"); + assert!(p.saturation == 0.0 && p.hsl_neutral(), "other panels untouched"); + } + #[test] fn float_documents_keep_overrange() { let mut a = vec![[2.0f32, 1.5, 0.5, 1.0]; 16]; diff --git a/crates/engine/src/lens_cmds.rs b/crates/engine/src/lens_cmds.rs index 379ca2402a..17742bd091 100644 --- a/crates/engine/src/lens_cmds.rs +++ b/crates/engine/src/lens_cmds.rs @@ -463,7 +463,7 @@ pub fn specs() -> Vec { label: "Camera Raw Filter…", menu: &["Filter"], shortcut: Some("Cmd+Shift+A"), - params: r##"{"temperature":-100..100=0,"tint":-100..100=0,"exposure":-5..5=0,"contrast":-100..100=0,"highlights":-100..100=0,"shadows":-100..100=0,"whites":-100..100=0,"blacks":-100..100=0,"texture":-100..100=0,"clarity":-100..100=0,"dehaze":-100..100=0,"vibrance":-100..100=0,"saturation":-100..100=0,"curveHighlights":-100..100=0,"curveLights":-100..100=0,"curveDarks":-100..100=0,"curveShadows":-100..100=0,"curveSplits":[25,50,75],"pointCurve":[[in,out]],"pointCurveRed":[[in,out]],"pointCurveGreen":[[in,out]],"pointCurveBlue":[[in,out]],"hslHue":[8],"hslSat":[8],"hslLum":[8],"gradeShadows":{"hue":deg,"sat":0..100,"lum":-100..100},"gradeMidtones":{},"gradeHighlights":{},"gradeGlobal":{},"gradeBlending":0..100=50,"gradeBalance":-100..100=0,"sharpenAmount":0..150=0,"sharpenRadius":0.5..3=1,"sharpenDetail":0..100=25,"sharpenMasking":0..100=0,"noiseLuminance":0..100=0,"noiseLuminanceDetail":0..100=50,"noiseColor":0..100=0,"noiseColorDetail":0..100=50,"grainAmount":0..100=0,"grainSize":0..100=25,"grainRoughness":0..100=50,"vignetteAmount":-100..100=0,"vignetteMidpoint":0..100=50,"vignetteRoundness":-100..100=0,"vignetteFeather":0..100=50,"vignetteHighlights":0..100=0,"vignetteStyle":"highlightPriority|colorPriority|paintOverlay","seed":u32=0}"##, + params: r##"{"temperature":-100..100=0,"tint":-100..100=0,"exposure":-5..5=0,"contrast":-100..100=0,"highlights":-100..100=0,"shadows":-100..100=0,"whites":-100..100=0,"blacks":-100..100=0,"texture":-100..100=0,"clarity":-100..100=0,"dehaze":-100..100=0,"vibrance":-100..100=0,"saturation":-100..100=0,"curveHighlights":-100..100=0,"curveLights":-100..100=0,"curveDarks":-100..100=0,"curveShadows":-100..100=0,"curveSplits":[25,50,75],"pointCurve":[[in,out]],"pointCurveRed":[[in,out]],"pointCurveGreen":[[in,out]],"pointCurveBlue":[[in,out]],"hslHue":[8],"hslSat":[8],"hslLum":[8],"gradeShadows":{"hue":deg,"sat":0..100,"lum":-100..100},"gradeMidtones":{},"gradeHighlights":{},"gradeGlobal":{},"gradeBlending":0..100=50,"gradeBalance":-100..100=0,"shadowTint":-100..100=0,"calibrationHue":[red,green,blue] -100..100,"calibrationSat":[red,green,blue] -100..100 (the Calibration panel: Shadows tint and the primaries' hue and saturation),"sharpenAmount":0..150=0,"sharpenRadius":0.5..3=1,"sharpenDetail":0..100=25,"sharpenMasking":0..100=0,"noiseLuminance":0..100=0,"noiseLuminanceDetail":0..100=50,"noiseColor":0..100=0,"noiseColorDetail":0..100=50,"grainAmount":0..100=0,"grainSize":0..100=25,"grainRoughness":0..100=50,"vignetteAmount":-100..100=0,"vignetteMidpoint":0..100=50,"vignetteRoundness":-100..100=0,"vignetteFeather":0..100=50,"vignetteHighlights":0..100=0,"vignetteStyle":"highlightPriority|colorPriority|paintOverlay","seed":u32=0}"##, enabled: raw_enabled, run: camera_raw_cmd, journal: true, diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index 378f71c18e..1d0a7c3696 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -914,6 +914,35 @@ pub struct RawDefaults { /// Photoshop does; off develops it with the defaults straight away. Automation opens never /// show the dialog. pub open_in_camera_raw: bool, + /// Keep a raw file's develop settings in a sidecar (`IMG_0001.xmp` beside `IMG_0001.CR2`), + /// as Camera Raw's "Save image settings in: Sidecar .xmp files"; the sidecar is read again + /// when the file is next opened. Off reads sidecars but never writes one. + pub write_xmp_sidecars: bool, +} + +impl RawColorSpace { + /// The built-in profile `edit.convertToProfile` knows this space as. + pub fn profile_id(self) -> &'static str { + match self { + RawColorSpace::Srgb => "srgb", + RawColorSpace::AdobeRgb => "adobe-rgb-compat", + RawColorSpace::ProPhoto => "prophoto-compat", + RawColorSpace::DisplayP3 => "display-p3", + } + } +} + +impl RawSharpen { + /// Camera Raw's output sharpening for this medium as the Detail panel's (amount, radius): + /// none, Screen (light, fine), Matte paper (stronger, wider: ink spreads), Glossy paper. + pub fn preset(self) -> Option<(f32, f32)> { + match self { + RawSharpen::None => None, + RawSharpen::Screen => Some((25.0, 1.0)), + RawSharpen::Matte => Some((35.0, 1.2)), + RawSharpen::Glossy => Some((40.0, 1.0)), + } + } } impl Default for RawDefaults { @@ -926,6 +955,7 @@ impl Default for RawDefaults { open_as_smart_object: false, apply_auto_tone: false, open_in_camera_raw: true, + write_xmp_sidecars: true, } } } @@ -1067,12 +1097,6 @@ pub const HIDDEN_UNTIL_IMPLEMENTED: &[&str] = &[ "type.recentFonts", "enhancedControls.scrubbySliderAcceleration", "enhancedControls.touchGestures", - "rawDefaults.colorSpace", - "rawDefaults.bitDepth", - "rawDefaults.resolution", - "rawDefaults.sharpenFor", - "rawDefaults.openAsSmartObject", - "rawDefaults.applyAutoTone", // Agent access is governed by the launch flags (`--control`, the automation roots), not // by these yet. "integrations.allowAgentControl", diff --git a/crates/io/src/camera_raw_xmp.rs b/crates/io/src/camera_raw_xmp.rs index 159e298a06..80ec9e7ef0 100644 --- a/crates/io/src/camera_raw_xmp.rs +++ b/crates/io/src/camera_raw_xmp.rs @@ -3,8 +3,9 @@ //! `x:xmpmeta/rdf:RDF/rdf:Description`, as attributes or as child elements. //! //! Loading applies only the settings the file holds, over the current ones, as Camera Raw's -//! Load Settings does; settings PhotoCraft has no control for (lens corrections, calibration, -//! geometry, defringe, …) are ignored and named in the report. Saving writes every supported +//! Load Settings does; settings PhotoCraft has no control for (lens corrections, geometry, +//! defringe, …) are ignored and named in the report. The same reader fills the dialog from a +//! raw file's sidecar (`IMG_0001.xmp` beside `IMG_0001.CR2`), and the writer keeps it. Saving writes every supported //! control, so loading the file in Photoshop reproduces the dialog. //! //! White balance: a Camera Raw Filter on a rendered image uses the relative @@ -100,6 +101,14 @@ const SCALARS: &[(&str, Field, f32, f32)] = &[ ("PostCropVignetteRoundness", |p| &mut p.vignette_roundness, -100.0, 100.0), ("PostCropVignetteFeather", |p| &mut p.vignette_feather, 0.0, 100.0), ("PostCropVignetteHighlightContrast", |p| &mut p.vignette_highlights, 0.0, 100.0), + // Calibration + ("ShadowTint", |p| &mut p.shadow_tint, -100.0, 100.0), + ("RedHue", |p| &mut p.calibration_hue[0], -100.0, 100.0), + ("RedSaturation", |p| &mut p.calibration_sat[0], -100.0, 100.0), + ("GreenHue", |p| &mut p.calibration_hue[1], -100.0, 100.0), + ("GreenSaturation", |p| &mut p.calibration_sat[1], -100.0, 100.0), + ("BlueHue", |p| &mut p.calibration_hue[2], -100.0, 100.0), + ("BlueSaturation", |p| &mut p.calibration_sat[2], -100.0, 100.0), ]; type Curve = fn(&mut CameraRaw) -> &mut Vec<[f32; 2]>; @@ -357,7 +366,8 @@ mod tests { assert_eq!(p.point_curve_red, vec![[0.0, 0.0], [128.0, 140.0], [255.0, 255.0]]); assert_eq!(p.dehaze, 12.0); // Lens vignetting, calibration and geometry have no counterpart. - assert_eq!(r.ignored, vec!["VignetteAmount".to_string(), "RedHue".to_string()]); + assert_eq!(r.ignored, vec!["VignetteAmount".to_string()], "the Calibration panel's keys load now"); + assert_eq!(p.calibration_hue[0], -5.0); } #[test] diff --git a/crates/ui-egui/src/camera_raw_ui.rs b/crates/ui-egui/src/camera_raw_ui.rs index 59ab86092d..dd898b1c02 100644 --- a/crates/ui-egui/src/camera_raw_ui.rs +++ b/crates/ui-egui/src/camera_raw_ui.rs @@ -231,7 +231,32 @@ fn open_raw(app: &mut PhotocraftApp, ctx: &egui::Context, raw: RawOpen) -> Resul let index = document_index(app, raw.document).ok_or("the raw document was closed")?; app.session.set_active(index); let (layer, surf, _) = crate::distort_ui::active_pixels(app)?; - open_pixels(app, ctx, layer, surf, CameraRaw::default(), Coverage::None, Target::OpenRaw)?; + // The file's sidecar (`IMG_0001.xmp` beside it) fills the dialog, as Camera Raw's does; the + // status bar names what it could not apply. + let mut params = CameraRaw::default(); + let mut from_sidecar = false; + if let Some((loaded, report, file)) = raw.path.as_deref().and_then(read_sidecar) { + params = loaded; + from_sidecar = true; + app.ui.status = if report.ignored.is_empty() { + crate::i18n::fmt(tl!("Settings from {name}"), &[("name", &file)]) + } else { + crate::i18n::fmt( + tl!("Settings from {name}; {count} not supported: {names}"), + &[("name", &file), ("count", &report.ignored.len().to_string()), ("names", &report.ignored.join(", "))], + ) + }; + app.ui.status_error = false; + } + open_pixels(app, ctx, layer, surf, params, Coverage::None, Target::OpenRaw)?; + // Camera Raw Defaults › Apply auto tone: a file without its own settings opens with Auto. + if !from_sidecar + && app.session.prefs().raw_defaults.apply_auto_tone + && let Some(d) = app.camera_raw.as_mut() + { + photocraft_algo::camera_raw::auto_tone(&d.proxy, &mut d.params); + d.dirty = true; + } let curve = match (&raw.bytes, &raw.path) { (Some(b), _) => Some(photocraft_io::raw::tone_curve(b)), #[cfg(not(target_arch = "wasm32"))] @@ -292,6 +317,7 @@ fn raw_stage(p: &CameraRaw) -> photocraft_io::raw::Tone { /// (tests, the web) it runs inline. fn commit_open_raw(app: &mut PhotocraftApp, params: &CameraRaw, raw: &RawOpen) -> Result { let index = document_index(app, raw.document).ok_or("the raw document was closed")?; + write_sidecar(app, raw, params); let tuning = photocraft_io::raw::RawTuning { temperature: params.temperature, tint: params.tint, @@ -398,10 +424,14 @@ fn finish_redevelop(app: &mut PhotocraftApp, params: &CameraRaw, raw: &RawOpen, /// The other settings as one Camera Raw step on document `index`, then the document is marked /// unmodified (developing is part of opening). The step runs like any filter (in the /// background in the desktop app); the document is marked unmodified when it lands. -fn finish_open_raw(app: &mut PhotocraftApp, index: usize, rest: CameraRaw, redeveloped: Option, raw: Option<&RawOpen>) -> Result { +fn finish_open_raw(app: &mut PhotocraftApp, index: usize, mut rest: CameraRaw, redeveloped: Option, raw: Option<&RawOpen>) -> Result { app.session.set_active(index); app.sync_views(); let mut result = json!({"document": index, "redeveloped": redeveloped.unwrap_or(false)}); + let defaults = apply_raw_defaults(app, index, &mut rest)?; + if !defaults.is_empty() { + result["defaults"] = json!(defaults); + } if !rest.is_identity() { let layer = app.session.active().and_then(|st| st.active_layer).ok_or("no layer to develop")?; let mut p = non_defaults(&rest); @@ -418,6 +448,151 @@ fn finish_open_raw(app: &mut PhotocraftApp, index: usize, rest: CameraRaw, redev Ok(result) } +/// The sidecar beside a raw file: `IMG_0001.xmp` for `IMG_0001.CR2`, as Camera Raw names it. +pub fn sidecar_path(path: &str) -> String { + match path.rsplit_once('.') { + Some((stem, ext)) if !ext.contains(['/', '\\']) => format!("{stem}.xmp"), + _ => format!("{path}.xmp"), + } +} + +/// A DNG carries its settings inside the file in Camera Raw; a sidecar is read for one too, +/// but never written beside it. +fn is_dng(path: &str) -> bool { + path.rsplit_once('.').is_some_and(|(_, ext)| ext.eq_ignore_ascii_case("dng")) +} + +/// The settings of the sidecar beside `path`, when there is one that parses: the settings, what +/// the loader skipped, and the sidecar's file name. A sidecar that doesn't parse is ignored (the +/// raw still opens) and reported in the log. +#[cfg(not(target_arch = "wasm32"))] +fn read_sidecar(path: &str) -> Option<(CameraRaw, photocraft_io::camera_raw_xmp::LoadReport, String)> { + let sidecar = sidecar_path(path); + let bytes = std::fs::read(&sidecar).ok()?; + if bytes.len() > photocraft_io::camera_raw_xmp::MAX_XMP_BYTES { + log::warn!("{sidecar}: sidecar larger than {} bytes, ignored", photocraft_io::camera_raw_xmp::MAX_XMP_BYTES); + return None; + } + let mut params = CameraRaw::default(); + match photocraft_io::camera_raw_xmp::load(&mut params, &bytes) { + Ok(report) => Some((params, report, crate::file_open::display_name(&sidecar))), + Err(e) => { + log::warn!("{sidecar}: sidecar ignored: {e}"); + None + } + } +} +#[cfg(target_arch = "wasm32")] +fn read_sidecar(_: &str) -> Option<(CameraRaw, photocraft_io::camera_raw_xmp::LoadReport, String)> { + None +} + +/// Keep the develop settings beside the raw file (Camera Raw Defaults › Write xmp sidecars): +/// written when the settings aren't the defaults or a sidecar already exists, so a file reopens +/// as it was developed. Not for DNGs, and never fatal: a folder that can't be written to is +/// reported in the status bar. +fn write_sidecar(app: &mut PhotocraftApp, raw: &RawOpen, params: &CameraRaw) { + if !app.session.prefs().raw_defaults.write_xmp_sidecars { + return; + } + let Some(path) = raw.path.as_deref().filter(|p| !is_dng(p)) else { return }; + let sidecar = sidecar_path(path); + #[cfg(not(target_arch = "wasm32"))] + let exists = std::path::Path::new(&sidecar).exists(); + #[cfg(target_arch = "wasm32")] + let exists = false; + if params.is_identity() && !exists { + return; + } + let bytes = photocraft_io::camera_raw_xmp::save(params).into_bytes(); + let Some(write) = app.services.write.as_mut() else { return }; + if let Err(e) = write(&sidecar, &bytes) { + app.ui.status = crate::i18n::fmt(tl!("Could not write {name}: {error}"), &[("name", &crate::file_open::display_name(&sidecar)), ("error", &e)]); + app.ui.status_error = true; + } +} + +/// Camera Raw Defaults (Preferences): the colour space, bit depth and resolution the developed +/// document opens in, output sharpening (folded into the Camera Raw step `rest`, as the +/// workflow's Sharpen For is), and Open as Smart Object. Returns what it applied. +fn apply_raw_defaults(app: &mut PhotocraftApp, index: usize, rest: &mut CameraRaw) -> Result, String> { + use photocraft_engine::prefs::{RawColorSpace, RawDepth}; + let d = app.session.prefs().raw_defaults.clone(); + app.session.set_active(index); + let mut applied = Vec::new(); + let profile = d.color_space.profile_id(); + // Raws develop into ProPhoto-compatible RGB (`photocraft_io::raw`); the other spaces are a + // conversion. + if profile != RawColorSpace::ProPhoto.profile_id() { + app.session.execute("edit.convertToProfile", json!({"profile": profile, "intent": "relative"})).map_err(|e| e.to_string())?; + applied.push("colorSpace"); + } + if d.bit_depth == RawDepth::Eight { + app.session.execute("image.mode.bits8", json!({})).map_err(|e| e.to_string())?; + applied.push("bitDepth"); + } + let dpi = app.session.active().map(|st| st.doc.resolution_dpi).unwrap_or(72.0); + if d.resolution.is_finite() && d.resolution > 0.0 && (f64::from(dpi) - d.resolution).abs() > 1e-6 { + app.session.execute("image.imageSize", json!({"resolution": d.resolution})).map_err(|e| e.to_string())?; + applied.push("resolution"); + } + if let Some((amount, radius)) = d.sharpen_for.preset() + && rest.sharpen_amount == 0.0 + { + rest.sharpen_amount = amount; + rest.sharpen_radius = radius; + applied.push("sharpenFor"); + } + if d.open_as_smart_object { + app.session.execute("layer.smartObjects.convertToSmartObject", json!({})).map_err(|e| e.to_string())?; + applied.push("openAsSmartObject"); + } + Ok(applied) +} + +/// A raw that opened without the dialog (Camera Raw Defaults › Open in Camera Raw off): its +/// sidecar's settings develop it as the dialog's Open would, and the Camera Raw Defaults apply. +/// `warnings` are the import's; only a developed raw qualifies. +pub fn opened_without_dialog(app: &mut PhotocraftApp, index: usize, name: &str, path: Option<&str>, warnings: &[String]) { + if !warnings.iter().any(|w| w.contains(photocraft_io::raw::DEVELOPED_NOTE)) { + return; + } + let Some(document) = app.session.documents().get(index).map(|st| st.doc.id) else { return }; + let raw = RawOpen { document, name: name.to_string(), path: path.map(str::to_string), bytes: None }; + let mut params = CameraRaw::default(); + if let Some((loaded, _, _)) = path.and_then(read_sidecar) { + params = loaded; + } else if app.session.prefs().raw_defaults.apply_auto_tone + && let Some(px) = app.session.active().and_then(|st| st.doc.layer(st.active_layer?)).and_then(|l| l.surface()).map(|s| sample_pixels(s, 512)) + { + photocraft_algo::camera_raw::auto_tone(&px, &mut params); + } + let r = if params.is_identity() { finish_open_raw(app, index, params, None, Some(&raw)) } else { commit_open_raw(app, ¶ms, &raw) }; + if let Err(e) = r { + app.ui.status = e; + app.ui.status_error = true; + } +} + +/// Every k-th pixel of a surface's content, k chosen so the longer side has about `max_side` +/// samples: enough for a histogram (Auto tone) without reading a whole raw. +fn sample_pixels(surf: &photocraft_raster::Surface, max_side: usize) -> Vec<[f32; 4]> { + let area = surf.content_bounds(); + let (w, h) = (area.x1.saturating_sub(area.x0).max(0) as usize, area.y1.saturating_sub(area.y0).max(0) as usize); + if w == 0 || h == 0 { + return Vec::new(); + } + let k = w.max(h).div_ceil(max_side.max(1)).max(1); + let mut out = Vec::with_capacity(w.div_ceil(k) * h.div_ceil(k)); + let mut row = vec![[0.0f32; 4]; w]; + for y in (0..h).step_by(k) { + let yy = area.y0.saturating_add(y as i32); + surf.read_rgba_into(Rect::new(area.x0, yy, area.x1, yy.saturating_add(1)), &mut row); + out.extend(row.iter().step_by(k).copied()); + } + out +} + fn mark_unmodified(app: &mut PhotocraftApp, index: usize) { let active = app.session.active_index(); app.session.set_active(index); @@ -676,8 +851,8 @@ pub fn menu(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str, params: &Val for (key, value) in fields { match key.as_str() { "set" | "scope" | "view" => {} - "before" | "commit" | "cancel" | "saveSettings" | "loadSettings" if value.is_boolean() => {} - "before" | "commit" | "cancel" | "saveSettings" | "loadSettings" => return Some(Err(format!("Camera Raw {key} must be a boolean"))), + "before" | "commit" | "cancel" | "saveSettings" | "loadSettings" | "auto" if value.is_boolean() => {} + "before" | "commit" | "cancel" | "saveSettings" | "loadSettings" | "auto" => return Some(Err(format!("Camera Raw {key} must be a boolean"))), _ => return Some(Err(format!("unknown Camera Raw ui property {key}"))), } } @@ -712,6 +887,10 @@ fn menu_update(app: &mut PhotocraftApp, ctx: &egui::Context, ui: &Value) -> Opti // occurs until every part of the request has passed validation. let d = app.camera_raw.as_ref()?; let mut next_params = d.params.clone(); + // Auto (the Light panel's button): the tone sliders from the image's histogram. + if ui.get("auto").and_then(Value::as_bool) == Some(true) { + photocraft_algo::camera_raw::auto_tone(&d.proxy, &mut next_params); + } if let Some(set) = ui.get("set") { if !set.is_object() { return Some(Err("bad Camera Raw settings: expected an object".into())); @@ -1073,9 +1252,16 @@ fn draw(app: &mut PhotocraftApp, ctx: &egui::Context, own_window: bool) { egui::ScrollArea::vertical().id_salt("camera-raw-props").show(&mut props, |ui| { ui.spacing_mut().item_spacing.y = 4.0; let p = &mut d.params; + let proxy = &d.proxy; let alt = &mut d.scope.alt_tone; let (ts, tn) = (temp_stops(), tint_stops()); section(ui, "Light", true, |ui| { + // Auto: Camera Raw's one-click tone from the histogram; the sliders show what it + // chose, so each can be adjusted afterwards. + if ui.button(tl!("Auto")).on_hover_text(tl!("Set the tone sliders from the image")).clicked() { + photocraft_algo::camera_raw::auto_tone(proxy, p); + dirty = true; + } tone_row(ui, &mut dirty, alt, ToneZone::Exposure, &mut p.exposure); row(ui, &mut dirty, "Contrast", &mut p.contrast, -100.0..=100.0, None); tone_row(ui, &mut dirty, alt, ToneZone::Highlights, &mut p.highlights); @@ -1170,6 +1356,19 @@ fn draw(app: &mut PhotocraftApp, ctx: &egui::Context, own_window: bool) { row(ui, &mut dirty, "Color", &mut p.noise_color, 0.0..=100.0, None); row(ui, &mut dirty, "Color Detail", &mut p.noise_color_detail, 0.0..=100.0, None); }); + // Camera Raw's Calibration panel: a tint for the shadows and each primary's hue and + // saturation (Process Version is implied: 2012 and later). + section(ui, "Calibration", false, |ui| { + widgets::section_label(ui, tl!("Shadows")); + row(ui, &mut dirty, "Tint", &mut p.shadow_tint, -100.0..=100.0, Some(&tn)); + for (i, name) in ["Red Primary", "Green Primary", "Blue Primary"].iter().enumerate() { + widgets::section_label(ui, crate::i18n::tr_ctx(crate::i18n::current(), "cameraRaw", name)); + ui.push_id(name, |ui| { + row(ui, &mut dirty, "Hue", &mut p.calibration_hue[i], -100.0..=100.0, None); + row(ui, &mut dirty, "Saturation", &mut p.calibration_sat[i], -100.0..=100.0, None); + }); + } + }); }); super::camera_raw_scope_ui::floating(ctx, d, scope, right); super::camera_raw_scope_ui::shortcuts(ctx, scope); @@ -1420,7 +1619,11 @@ mod tests { let (w, h) = (48, 32); let mut spec = DngSpec::cfa(w, h, mosaic(&scene(w, h), w, [0, 1, 1, 2], 0, 30000)); spec.as_shot_neutral = Some([0.5, 1.0, 0.7]); - (PhotocraftApp::new(photocraft_engine::Session::new(), services), spec.build()) + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), services); + // The pixel comparisons below read the developed ProPhoto values: no conversion on open + // (Camera Raw Defaults › Color space is Adobe RGB otherwise). + app.run("prefs.set", json!({"path": "rawDefaults.colorSpace", "value": "proPhoto"})).unwrap(); + (app, spec.build()) } fn mean_red(app: &PhotocraftApp) -> f32 { @@ -1547,7 +1750,8 @@ mod tests { let raw = app.pending_raw_open.take().unwrap(); open_raw(&mut app, &ctx, raw).unwrap(); let r = menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"commit": true}})).unwrap().unwrap(); - assert_eq!(r, json!({"document": 0, "redeveloped": false})); + assert_eq!((r["document"].as_u64(), r["redeveloped"].as_bool(), r.get("filter")), (Some(0), Some(false), None), "{r}"); + assert_eq!(r["defaults"], json!(["resolution"]), "Camera Raw Defaults: 300 ppi, from the develop's 72: {r}"); // Preference off: raws open straight away. app.run("prefs.set", json!({"path": "rawDefaults.openInCameraRaw", "value": false})).unwrap(); app.open_bytes("c.dng", &dng).unwrap(); @@ -1556,6 +1760,151 @@ mod tests { assert!(open_raw(&mut app, &ctx, RawOpen { document: photocraft_doc::DocId(u64::MAX), name: "x".into(), path: None, bytes: None }).is_err()); } + #[test] + fn calibration_changes_the_preview_and_round_trips_through_xmp() { + let (mut app, dng) = raw_app(); + let ctx = egui::Context::default(); + app.open_bytes("IMG_0005.dng", &dng).unwrap(); + let raw = app.pending_raw_open.take().unwrap(); + open_raw(&mut app, &ctx, raw).unwrap(); + let before = app.camera_raw.as_ref().unwrap().processed.clone(); + menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"set": {"shadowTint": 100, "calibrationHue": [100, 0, 0], "calibrationSat": [0, 0, -100]}}})) + .unwrap() + .unwrap(); + let d = app.camera_raw.as_mut().unwrap(); + d.render(&ctx); + assert!( + d.processed.iter().zip(&before).any(|(a, b)| (a[0] - b[0]).abs() > 0.01 || (a[1] - b[1]).abs() > 0.01), + "the Calibration panel changes the preview" + ); + let xmp = photocraft_io::camera_raw_xmp::save(&d.params); + assert!(xmp.contains("crs:ShadowTint=\"+100\"") && xmp.contains("crs:RedHue=\"+100\"") && xmp.contains("crs:BlueSaturation=\"-100\""), "{xmp}"); + let mut back = CameraRaw::default(); + photocraft_io::camera_raw_xmp::load(&mut back, xmp.as_bytes()).unwrap(); + assert_eq!((back.shadow_tint, back.calibration_hue, back.calibration_sat), (100.0, [100.0, 0.0, 0.0], [0.0, 0.0, -100.0])); + assert!(menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"auto": "yes"}})).unwrap().is_err(), "auto must be a boolean"); + } + + #[test] + fn auto_sets_the_light_sliders_from_the_image() { + let (mut app, dng) = raw_app(); + let ctx = egui::Context::default(); + app.open_bytes("IMG_0006.dng", &dng).unwrap(); + let raw = app.pending_raw_open.take().unwrap(); + open_raw(&mut app, &ctx, raw).unwrap(); + assert!(app.camera_raw.as_ref().unwrap().params.is_identity()); + menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"auto": true}})).unwrap().unwrap(); + let p = app.camera_raw.as_ref().unwrap().params.clone(); + assert!(!p.is_identity(), "Auto chose something: {p:?}"); + assert!(p.saturation == 0.0 && p.hsl_hue == [0.0; 8], "only the Light panel: {p:?}"); + // The preference does the same when a raw opens without a sidecar. + app.run("prefs.set", json!({"path": "rawDefaults.applyAutoTone", "value": true})).unwrap(); + app.open_bytes("IMG_0007.dng", &dng).unwrap(); + let raw = app.pending_raw_open.take().unwrap(); + open_raw(&mut app, &ctx, raw).unwrap(); + assert_eq!(app.camera_raw.as_ref().unwrap().params, p, "Apply auto tone opens the dialog with Auto's settings"); + } + + #[test] + fn a_sidecar_fills_the_dialog_and_open_writes_it_back() { + use std::sync::{Arc, Mutex}; + let (mut app, dng) = raw_app(); + let dir = std::env::temp_dir().join(format!("photocraft-sidecar-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).unwrap(); + let raw_path = dir.join("IMG_0008.cr2").to_string_lossy().into_owned(); + std::fs::write(&raw_path, &dng).unwrap(); + assert_eq!(sidecar_path(&raw_path), dir.join("IMG_0008.xmp").to_string_lossy()); + assert_eq!(sidecar_path("/a/b.c/noext"), "/a/b.c/noext.xmp"); + std::fs::write( + sidecar_path(&raw_path), + "", + ) + .unwrap(); + type Written = Arc)>>>; + let written: Written = Arc::default(); + let sink = written.clone(); + app.services.write = Some(Box::new(move |p: &str, b: &[u8]| { + sink.lock().unwrap().push((p.to_string(), b.to_vec())); + Ok(()) + })); + let ctx = egui::Context::default(); + app.open_bytes("IMG_0008.cr2", &dng).unwrap(); + let mut raw = app.pending_raw_open.take().unwrap(); + raw.path = Some(raw_path.clone()); + open_raw(&mut app, &ctx, raw).unwrap(); + let d = app.camera_raw.as_ref().unwrap(); + assert_eq!((d.params.exposure, d.params.shadow_tint), (1.5, 20.0), "the sidecar fills the dialog"); + assert!( + app.ui.status.contains("IMG_0008.xmp") && app.ui.status.contains("Temperature"), + "the absolute white balance is reported as not supported: {}", + app.ui.status + ); + menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"set": {"contrast": 15}}})).unwrap().unwrap(); + menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"commit": true}})).unwrap().unwrap(); + let w = written.lock().unwrap().clone(); + assert_eq!(w.len(), 1, "Open writes the sidecar once: {:?}", w.iter().map(|(p, _)| p).collect::>()); + assert_eq!(w[0].0, sidecar_path(&raw_path)); + let text = String::from_utf8(w[0].1.clone()).unwrap(); + assert!(text.contains("crs:Exposure2012=\"+1.50\"") && text.contains("crs:Contrast2012=\"+15\"") && text.contains("crs:ShadowTint=\"+20\""), "{text}"); + // A DNG keeps its settings inside: no sidecar beside it. And the preference turns writing off. + written.lock().unwrap().clear(); + let dng_path = dir.join("IMG_0009.dng").to_string_lossy().into_owned(); + std::fs::write(&dng_path, &dng).unwrap(); + app.open_bytes("IMG_0009.dng", &dng).unwrap(); + let mut raw = app.pending_raw_open.take().unwrap(); + raw.path = Some(dng_path); + open_raw(&mut app, &ctx, raw).unwrap(); + menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"set": {"contrast": 15}, "commit": true}})).unwrap().unwrap(); + assert!(written.lock().unwrap().is_empty(), "no sidecar for a DNG"); + app.run("prefs.set", json!({"path": "rawDefaults.writeXmpSidecars", "value": false})).unwrap(); + app.open_bytes("IMG_0008.cr2", &dng).unwrap(); + let mut raw = app.pending_raw_open.take().unwrap(); + raw.path = Some(raw_path.clone()); + open_raw(&mut app, &ctx, raw).unwrap(); + menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"set": {"contrast": 30}, "commit": true}})).unwrap().unwrap(); + assert!(written.lock().unwrap().is_empty(), "the preference stops the write"); + // Without the dialog, the sidecar still develops the file. + app.run("prefs.set", json!({"path": "rawDefaults.openInCameraRaw", "value": false})).unwrap(); + let before = app.session.documents().len(); + app.open_file(&raw_path, &dng).unwrap(); + assert!(app.pending_raw_open.is_none()); + assert_eq!(app.session.documents().len(), before + 1); + let st = app.session.active().unwrap(); + assert_eq!(st.saved_revision, st.revision, "opening with a sidecar leaves the document unmodified"); + assert!(mean_red(&app) > 0.0); + let _ = std::fs::remove_dir_all(&dir); + } + + #[test] + fn camera_raw_defaults_apply_when_a_raw_opens() { + let (mut app, dng) = raw_app(); + app.run("prefs.set", json!({"values": {"rawDefaults.openInCameraRaw": false, "rawDefaults.colorSpace": "srgb", "rawDefaults.bitDepth": "8", "rawDefaults.resolution": 240.0, "rawDefaults.sharpenFor": "screen", "rawDefaults.openAsSmartObject": true}})).unwrap(); + app.open_bytes("IMG_0010.dng", &dng).unwrap(); + assert!(app.pending_raw_open.is_none()); + let st = app.session.active().unwrap(); + assert_eq!(st.doc.depth, photocraft_color::SampleType::U8, "Bit depth 8"); + assert_eq!(st.doc.resolution_dpi, 240.0, "Resolution"); + let profile = st.doc.icc_profile.as_deref().and_then(|p| photocraft_cms::Profile::parse(p).ok()).map(|p| p.description).unwrap_or_default(); + assert!(profile.to_lowercase().contains("srgb"), "Color space: {profile}"); + let layer = st.doc.layer(st.active_layer.unwrap()).unwrap(); + assert!(matches!(layer.content, photocraft_doc::LayerContent::Smart(_)), "Open as Smart Object"); + assert_eq!(st.saved_revision, st.revision, "the defaults are part of opening: unmodified"); + // The dialog's Open applies them too, and reports what it applied. + app.run("prefs.set", json!({"values": {"rawDefaults.openInCameraRaw": true, "rawDefaults.openAsSmartObject": false, "rawDefaults.bitDepth": "16"}})) + .unwrap(); + let ctx = egui::Context::default(); + app.open_bytes("IMG_0011.dng", &dng).unwrap(); + let raw = app.pending_raw_open.take().unwrap(); + open_raw(&mut app, &ctx, raw).unwrap(); + let r = menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"commit": true}})).unwrap().unwrap(); + assert_eq!(r["defaults"], json!(["colorSpace", "resolution", "sharpenFor"]), "{r}"); + assert!(r.get("filter").is_some(), "Sharpen For is a Camera Raw step: {r}"); + let st = app.session.active().unwrap(); + assert_eq!(st.doc.depth, photocraft_color::SampleType::U16); + assert_eq!(st.saved_revision, st.revision); + } + #[test] fn save_and_load_settings_round_trip_through_xmp_files() { use crate::file_dialog::FileDialogAnswer; @@ -1564,7 +1913,7 @@ mod tests { let written: Written = Arc::default(); let w = written.clone(); let foreign = br#" - + "#; let answers = vec![ Some(FileDialogAnswer::SaveTo("/out/Look.xmp".into())), diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index cea55a1694..b1aa44a4c6 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -3734,3 +3734,13 @@ navigator Zoom Zvětšení @plural {n} action|{n} actions {n} akce|{n} akce|{n} akcí Auto Add/Delete Automaticky přidat/odstranit ICO is limited to 256 × 256 pixels ICO je omezen na 256 × 256 pixelů + Calibration Kalibrace + Red Primary Červená základní + Green Primary Zelená základní + Blue Primary Modrá základní + Write xmp sidecars Zapisovat přidružené soubory XMP + Set the tone sliders from the image Nastavit posuvníky tónů podle obrazu + Settings from {name} Nastavení z {name} + Settings from {name}; {count} not supported: {names} Nastavení z {name}; {count} nepodporováno: {names} + Could not write {name}: {error} Nelze zapsat {name}: {error} + Shadow Tint Odstín stínů diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index b23510e12e..e7c43129b8 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -2768,3 +2768,13 @@ curves Smooth Glätten @plural {n} action|{n} actions {n} Aktion|{n} Aktionen Auto Add/Delete Autom. hinzuf./löschen ICO is limited to 256 × 256 pixels ICO ist auf 256 × 256 Pixel begrenzt + Calibration Kalibrierung + Red Primary Rot-Primärfarbe + Green Primary Grün-Primärfarbe + Blue Primary Blau-Primärfarbe + Write xmp sidecars XMP-Filialdateien schreiben + Set the tone sliders from the image Tonwert-Regler aus dem Bild setzen + Settings from {name} Einstellungen aus {name} + Settings from {name}; {count} not supported: {names} Einstellungen aus {name}; {count} nicht unterstützt: {names} + Could not write {name}: {error} {name} konnte nicht geschrieben werden: {error} + Shadow Tint Schattentönung diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 1dd9ba3652..3eec523a21 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3823,3 +3823,13 @@ curves Smooth Εξομάλυνση @plural {n} action|{n} actions {n} ενέργεια|{n} ενέργειες Auto Add/Delete Αυτόματη προσθήκη/διαγραφή ICO is limited to 256 × 256 pixels Το ICO περιορίζεται σε 256 × 256 εικονοστοιχεία + Calibration Βαθμονόμηση + Red Primary Κόκκινο πρωτεύον + Green Primary Πράσινο πρωτεύον + Blue Primary Μπλε πρωτεύον + Write xmp sidecars Εγγραφή συνοδευτικών αρχείων XMP + Set the tone sliders from the image Ορισμός των ρυθμιστικών τόνων από την εικόνα + Settings from {name} Ρυθμίσεις από {name} + Settings from {name}; {count} not supported: {names} Ρυθμίσεις από {name}· {count} δεν υποστηρίζονται: {names} + Could not write {name}: {error} Αδυναμία εγγραφής του {name}: {error} + Shadow Tint Χροιά σκιών diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 5d1ff71146..64884faa46 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2809,3 +2809,13 @@ curves Smooth Suavizar @plural {n} action|{n} actions {n} acción|{n} acciones Auto Add/Delete Añadir/eliminar automáticamente ICO is limited to 256 × 256 pixels ICO está limitado a 256 × 256 píxeles + Calibration Calibración + Red Primary Primario rojo + Green Primary Primario verde + Blue Primary Primario azul + Write xmp sidecars Escribir archivos XMP auxiliares + Set the tone sliders from the image Ajustar los controles de tono a partir de la imagen + Settings from {name} Ajustes de {name} + Settings from {name}; {count} not supported: {names} Ajustes de {name}; {count} no compatibles: {names} + Could not write {name}: {error} No se pudo escribir {name}: {error} + Shadow Tint Tinte de sombras diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 6974616118..e0803628ab 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -3127,3 +3127,13 @@ curves Smooth Lisser @plural {n} action|{n} actions {n} action|{n} actions Auto Add/Delete Ajout/suppr. auto ICO is limited to 256 × 256 pixels Le format ICO est limité à 256 × 256 pixels + Calibration Étalonnage + Red Primary Primaire rouge + Green Primary Primaire verte + Blue Primary Primaire bleue + Write xmp sidecars Écrire les fichiers annexes XMP + Set the tone sliders from the image Régler les curseurs de tonalité d’après l’image + Settings from {name} Réglages de {name} + Settings from {name}; {count} not supported: {names} Réglages de {name} ; {count} non pris en charge : {names} + Could not write {name}: {error} Impossible d’écrire {name} : {error} + Shadow Tint Teinte des ombres diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 9aa29a7cb6..d7487f47ba 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -4047,3 +4047,13 @@ cameraRaw Yellow Sárga Color Indicates: A szín jelzése: Ink Characteristics Festék jellemzői Solidity: Fedőképesség: + Calibration Kalibrálás + Red Primary Vörös alapszín + Green Primary Zöld alapszín + Blue Primary Kék alapszín + Write xmp sidecars XMP kísérőfájlok írása + Set the tone sliders from the image Tónuscsúszkák beállítása a kép alapján + Settings from {name} Beállítások innen: {name} + Settings from {name}; {count} not supported: {names} Beállítások innen: {name}; {count} nem támogatott: {names} + Could not write {name}: {error} Nem sikerült írni: {name}: {error} + Shadow Tint Árnyék színezet diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 8182765c4a..e6f1dec68d 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -3114,3 +3114,13 @@ curves Smooth Haluskan @plural {n} action|{n} actions {n} tindakan Auto Add/Delete Tambah/Hapus Otomatis ICO is limited to 256 × 256 pixels ICO dibatasi hingga 256 × 256 piksel + Calibration Kalibrasi + Red Primary Primer merah + Green Primary Primer hijau + Blue Primary Primer biru + Write xmp sidecars Tulis berkas pendamping XMP + Set the tone sliders from the image Atur penggeser nada dari gambar + Settings from {name} Pengaturan dari {name} + Settings from {name}; {count} not supported: {names} Pengaturan dari {name}; {count} tidak didukung: {names} + Could not write {name}: {error} Tidak dapat menulis {name}: {error} + Shadow Tint Rona bayangan diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 08d8adcc14..fa86da7bfc 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -4090,3 +4090,13 @@ navigator Zoom Zoom @plural {n} action|{n} actions {n} azione|{n} azioni Auto Add/Delete Aggiungi/elimina automaticamente ICO is limited to 256 × 256 pixels ICO è limitato a 256 × 256 pixel + Calibration Calibrazione + Red Primary Primario rosso + Green Primary Primario verde + Blue Primary Primario blu + Write xmp sidecars Scrivi file sidecar XMP + Set the tone sliders from the image Imposta i cursori dei toni dall’immagine + Settings from {name} Impostazioni da {name} + Settings from {name}; {count} not supported: {names} Impostazioni da {name}; {count} non supportate: {names} + Could not write {name}: {error} Impossibile scrivere {name}: {error} + Shadow Tint Tinta ombre diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 8e878c2c21..920756580e 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3803,3 +3803,13 @@ curves Smooth スムーズ Reset All Locked Settings ロックされた設定をすべて初期化 Copy Texture to Other Tools テクスチャを他のツールにコピー ICO is limited to 256 × 256 pixels ICO は 256 × 256 ピクセルまでです + Calibration キャリブレーション + Red Primary レッド原色 + Green Primary グリーン原色 + Blue Primary ブルー原色 + Write xmp sidecars XMP サイドカーファイルを書き込む + Set the tone sliders from the image 画像からトーンスライダーを設定 + Settings from {name} {name} の設定 + Settings from {name}; {count} not supported: {names} {name} の設定; {count} 件は未対応: {names} + Could not write {name}: {error} {name} を書き込めません: {error} + Shadow Tint シャドウの色かぶり補正 diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index b7fe66cbb5..260eb2b9ea 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3299,3 +3299,13 @@ curves Smooth 매끄럽게 @plural {n} action|{n} actions 액션 {n}개 Auto Add/Delete 자동 추가/삭제 ICO is limited to 256 × 256 pixels ICO는 256 × 256픽셀로 제한됩니다 + Calibration 보정 + Red Primary 빨강 원색 + Green Primary 녹색 원색 + Blue Primary 파랑 원색 + Write xmp sidecars XMP 사이드카 파일 쓰기 + Set the tone sliders from the image 이미지에서 톤 슬라이더 설정 + Settings from {name} {name}의 설정 + Settings from {name}; {count} not supported: {names} {name}의 설정; {count}개 미지원: {names} + Could not write {name}: {error} {name}을(를) 쓸 수 없음: {error} + Shadow Tint 그림자 색조 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 9ffc6e89b8..776d3600d0 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -3885,3 +3885,13 @@ curves Smooth Vloeiend maken @plural {n} action|{n} actions {n} handeling|{n} handelingen Auto Add/Delete Automatisch toevoegen/verwijderen ICO is limited to 256 × 256 pixels ICO is beperkt tot 256 × 256 pixels + Calibration Kalibratie + Red Primary Primair rood + Green Primary Primair groen + Blue Primary Primair blauw + Write xmp sidecars XMP-sidecarbestanden schrijven + Set the tone sliders from the image Toonschuifregelaars instellen op basis van de afbeelding + Settings from {name} Instellingen uit {name} + Settings from {name}; {count} not supported: {names} Instellingen uit {name}; {count} niet ondersteund: {names} + Could not write {name}: {error} Kan {name} niet schrijven: {error} + Shadow Tint Schaduwtint diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 4601e90270..be7942739c 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3723,3 +3723,13 @@ curves Smooth Wygładź @plural {n} action|{n} actions {n} operacja|{n} operacje|{n} operacji Auto Add/Delete Automatyczne dodawanie/usuwanie ICO is limited to 256 × 256 pixels ICO jest ograniczony do 256 × 256 pikseli + Calibration Kalibracja + Red Primary Czerwień podstawowa + Green Primary Zieleń podstawowa + Blue Primary Niebieski podstawowy + Write xmp sidecars Zapisuj pliki poboczne XMP + Set the tone sliders from the image Ustaw suwaki tonów na podstawie obrazu + Settings from {name} Ustawienia z {name} + Settings from {name}; {count} not supported: {names} Ustawienia z {name}; nieobsługiwane: {count}: {names} + Could not write {name}: {error} Nie można zapisać {name}: {error} + Shadow Tint Tinta cieni diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 21ce217463..aa9610d556 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -3915,3 +3915,13 @@ layerLabel No Color Sem cor @plural {n} action|{n} actions {n} ação|{n} ações Auto Add/Delete Adicionar/excluir automaticamente ICO is limited to 256 × 256 pixels ICO é limitado a 256 × 256 pixels + Calibration Calibração + Red Primary Primária vermelha + Green Primary Primária verde + Blue Primary Primária azul + Write xmp sidecars Gravar arquivos auxiliares XMP + Set the tone sliders from the image Definir os controles de tom a partir da imagem + Settings from {name} Configurações de {name} + Settings from {name}; {count} not supported: {names} Configurações de {name}; {count} sem suporte: {names} + Could not write {name}: {error} Não foi possível gravar {name}: {error} + Shadow Tint Matiz das sombras diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index ca950c2e05..5d0e98f662 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -3071,3 +3071,13 @@ curves Smooth Сгладить @plural {n} action|{n} actions {n} операция|{n} операции|{n} операций Auto Add/Delete Автодобавление/удаление ICO is limited to 256 × 256 pixels ICO ограничен размером 256 × 256 пикселей + Calibration Калибровка + Red Primary Красный основной + Green Primary Зелёный основной + Blue Primary Синий основной + Write xmp sidecars Записывать сопутствующие файлы XMP + Set the tone sliders from the image Установить ползунки тона по изображению + Settings from {name} Настройки из {name} + Settings from {name}; {count} not supported: {names} Настройки из {name}; не поддерживается: {count}: {names} + Could not write {name}: {error} Не удалось записать {name}: {error} + Shadow Tint Оттенок теней diff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsv index 7a85f8d58f..60b17404b2 100644 --- a/crates/ui-egui/src/i18n/sr.tsv +++ b/crates/ui-egui/src/i18n/sr.tsv @@ -4201,3 +4201,13 @@ shape Appearance Izgled Color Indicates: Boja označava: Ink Characteristics Karakteristike mastila Solidity: Punoća: + Calibration Kalibracija + Red Primary Crvena primarna + Green Primary Zelena primarna + Blue Primary Plava primarna + Write xmp sidecars Upisuj prateće XMP datoteke + Set the tone sliders from the image Postavi klizače tona prema slici + Settings from {name} Podešavanja iz {name} + Settings from {name}; {count} not supported: {names} Podešavanja iz {name}; {count} nije podržano: {names} + Could not write {name}: {error} Nije moguće upisati {name}: {error} + Shadow Tint Nijansa senki diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 12383b694b..338170e890 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -3858,3 +3858,13 @@ cameraData Lens Lens Color Indicates: Rengin Gösterdiği: Ink Characteristics Mürekkep Özellikleri Solidity: Doluluk: + Calibration Kalibrasyon + Red Primary Kırmızı ana renk + Green Primary Yeşil ana renk + Blue Primary Mavi ana renk + Write xmp sidecars XMP yan dosyalarını yaz + Set the tone sliders from the image Ton kaydırıcılarını görüntüden ayarla + Settings from {name} {name} ayarları + Settings from {name}; {count} not supported: {names} {name} ayarları; {count} desteklenmiyor: {names} + Could not write {name}: {error} {name} yazılamadı: {error} + Shadow Tint Gölge tonu diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index a9bae9eb27..b1977e72a3 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3824,3 +3824,13 @@ curves Smooth Згладити @plural {n} action|{n} actions {n} операція|{n} операції|{n} операцій Auto Add/Delete Автододавання/видалення ICO is limited to 256 × 256 pixels ICO обмежено розміром 256 × 256 пікселів + Calibration Калібрування + Red Primary Червоний основний + Green Primary Зелений основний + Blue Primary Синій основний + Write xmp sidecars Записувати супутні файли XMP + Set the tone sliders from the image Встановити повзунки тону за зображенням + Settings from {name} Налаштування з {name} + Settings from {name}; {count} not supported: {names} Налаштування з {name}; не підтримується: {count}: {names} + Could not write {name}: {error} Не вдалося записати {name}: {error} + Shadow Tint Відтінок тіней diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index fc652eff83..c3391e59a1 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3611,3 +3611,13 @@ curves Smooth Làm mượt Choose a gradient file (.grd). Chọn tệp chuyển sắc (.grd). Auto Add/Delete Tự động thêm/xóa ICO is limited to 256 × 256 pixels ICO giới hạn ở 256 × 256 pixel + Calibration Hiệu chuẩn + Red Primary Màu đỏ cơ bản + Green Primary Màu lục cơ bản + Blue Primary Màu lam cơ bản + Write xmp sidecars Ghi tệp phụ XMP + Set the tone sliders from the image Đặt các thanh trượt tông từ ảnh + Settings from {name} Thiết lập từ {name} + Settings from {name}; {count} not supported: {names} Thiết lập từ {name}; {count} không được hỗ trợ: {names} + Could not write {name}: {error} Không thể ghi {name}: {error} + Shadow Tint Sắc độ bóng tối diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index fb6083985c..c16510782a 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2734,3 +2734,13 @@ curves Smooth 平滑 @plural {n} action|{n} actions {n} 个动作 Auto Add/Delete 自动添加/删除 ICO is limited to 256 × 256 pixels ICO 最大为 256 × 256 像素 + Calibration 校准 + Red Primary 红原色 + Green Primary 绿原色 + Blue Primary 蓝原色 + Write xmp sidecars 写入 XMP 附属文件 + Set the tone sliders from the image 根据图像设置色调滑块 + Settings from {name} 来自 {name} 的设置 + Settings from {name}; {count} not supported: {names} 来自 {name} 的设置;{count} 项不支持:{names} + Could not write {name}: {error} 无法写入 {name}:{error} + Shadow Tint 阴影色调 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 760e390812..a96a16c821 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2719,3 +2719,13 @@ curves Smooth 平滑 @plural {n} action|{n} actions {n} 個動作 Auto Add/Delete 自動增加/刪除 ICO is limited to 256 × 256 pixels ICO 最大為 256 × 256 像素 + Calibration 校準 + Red Primary 紅原色 + Green Primary 綠原色 + Blue Primary 藍原色 + Write xmp sidecars 寫入 XMP 附屬檔案 + Set the tone sliders from the image 根據影像設定色調滑桿 + Settings from {name} 來自 {name} 的設定 + Settings from {name}; {count} not supported: {names} 來自 {name} 的設定;{count} 項不支援:{names} + Could not write {name}: {error} 無法寫入 {name}:{error} + Shadow Tint 陰影色調 diff --git a/crates/ui-egui/src/jobs_ui.rs b/crates/ui-egui/src/jobs_ui.rs index 99479f4e32..babfcce497 100644 --- a/crates/ui-egui/src/jobs_ui.rs +++ b/crates/ui-egui/src/jobs_ui.rs @@ -549,6 +549,7 @@ fn finish_open(app: &mut PhotocraftApp, name: &str, path: Option<&str>, v: &Valu notices::io_warnings(app, &crate::i18n::fmt(tl!("Opened {name}"), &[("name", name)]), &crate::camera_raw_ui::without_develop_note(&warnings)); } else { notices::io_warnings(app, &crate::i18n::fmt(tl!("Opened {name}"), &[("name", name)]), &warnings); + crate::camera_raw_ui::opened_without_dialog(app, index, name, path, &warnings); } // Script events bound to "Open Document". photocraft_engine::automate_cmds::document_opened(&mut app.session); diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 6bffa8133f..a45a28ab30 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1229,6 +1229,9 @@ impl PhotocraftApp { notices::io_warnings(self, &crate::i18n::fmt(tl!("Opened {name}"), &[("name", name)]), &camera_raw_ui::without_develop_note(&warnings)); } else { notices::io_warnings(self, &crate::i18n::fmt(tl!("Opened {name}"), &[("name", name)]), &warnings); + if let Some(index) = self.session.active_index() { + camera_raw_ui::opened_without_dialog(self, index, name, None, &warnings); + } } // Script events bound to "Open Document". photocraft_engine::automate_cmds::document_opened(&mut self.session); diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs index cf0ff51969..8d5d15b783 100644 --- a/crates/ui-egui/src/prefs_ui.rs +++ b/crates/ui-egui/src/prefs_ui.rs @@ -2761,10 +2761,11 @@ mod tests { assert!(has_visible_fields(&values, "enhancedControls")); assert!(!prefs::is_hidden("enhancedControls.rotateViewWithTrackpad")); assert!(!prefs::is_hidden("enhancedControls.zoomWithTrackpadPinch")); - // Camera Raw Defaults shows only "Open in Camera Raw" so far. + // Camera Raw Defaults are all live: the dialog's Open applies them (camera_raw_ui). assert!(has_visible_fields(&values, "rawDefaults")); - assert!(!prefs::is_hidden("rawDefaults.openInCameraRaw")); - assert!(prefs::is_hidden("rawDefaults.applyAutoTone")); + for k in ["openInCameraRaw", "applyAutoTone", "colorSpace", "bitDepth", "resolution", "sharpenFor", "openAsSmartObject", "writeXmpSidecars"] { + assert!(!prefs::is_hidden(&format!("rawDefaults.{k}")), "{k}"); + } assert!(!prefs::is_hidden("general.autoShowHomeScreen")); assert!(!prefs::is_hidden("interface.uiScale")); assert!(!prefs::is_hidden("interface.uiFontSize")); diff --git a/docs/control-protocol.md b/docs/control-protocol.md index e571e94f8b..9e2a3b14b2 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -419,15 +419,23 @@ viewports, so the dialog is drawn over the main window and appears in the image. RGB/Grayscale layer. `params: {"smartFilter": {"layer": id, "index": i}}` opens it on an existing Camera Raw smart filter instead (as double-clicking the filter in the Layers panel does): the stored settings over the pixels below that filter, previewed through the filter mask; commit -then runs `layer.smartFilter.setParams` with every setting. `params.ui` accepts `set` (filter settings), `before`, `scope`, `view`, `commit` and +then runs `layer.smartFilter.setParams` with every setting. `params.ui` accepts `set` (filter settings), `before`, `scope`, `view`, `auto` (true: the Light +sliders from the image's histogram, the panel's Auto button), `saveSettings`, `loadSettings`, `commit` and `cancel`. All parts of one request are validated before any is applied; a rejected request leaves the settings, view state, preferences and document unchanged (and closes a dialog it -opened). Unknown `ui` or settings properties, non-boolean `before` / `commit` / `cancel`, and +opened). Unknown `ui` or settings properties, non-boolean `before` / `auto` / `commit` / `cancel`, and `commit` together with `cancel` are errors. Point curves (`pointCurve`, `pointCurveRed`, `pointCurveGreen`, `pointCurveBlue`) are empty or 2–16 finite points in 0–255 with inputs at least one level apart. Commit dispatches one `filter.cameraRaw` engine command; a failed commit keeps the dialog open for correction. Nothing else writes document history. +A raw file opened from a path reads its sidecar (`IMG_0001.xmp` beside `IMG_0001.CR2`, Camera +Raw's `crs:` settings) into the open-time dialog, and Open writes it back (Preferences › Camera +Raw Defaults › Write xmp sidecars; never beside a DNG). Open also applies the other Camera Raw +Defaults (colour space, bit depth, resolution, Sharpen For as a Camera Raw step, Open as Smart +Object, Apply auto tone), reported as `defaults` in the commit's reply; with "Open in Camera Raw" +off the sidecar and the defaults apply without the dialog. + **Opening a raw file.** An interactive open (File › Open, Open Recent, drag and drop, the command line) of a camera raw developed from its sensor data shows this dialog first, titled "Camera Raw (name)", with **Open** and **Cancel**, as Photoshop opens raws in Adobe Camera Raw. diff --git a/docs/gaps.md b/docs/gaps.md index f7929c276d..6174868ee2 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where PhotoCraft falls short of Photoshop -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (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-13 · **Change:** minor (G14: lossy DNG, raw sidecars, Camera Raw Defaults live, Calibration and Auto, CR3 assessed as not clean-room feasible; 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 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 @@ -116,9 +116,15 @@ what an agent can't finish alone. (AGENTS.md forbids JS in the app). ### G14. Camera Raw depth -- **Missing:** CR3 (detected, unsupported), compressed RAF, lossy DNG (FILE-215-11), .xmp - sidecars, masking and calibration in the Camera Raw dialog, per-camera colour for non-DNG - cameras, lens profiles. +- **Missing:** CR3 sensor data (the embedded preview opens; the CRX codec has no public + specification, only LGPL implementations, so a clean-room decoder is not possible), compressed + RAF, highlight recovery modes (FILE-215-11), masking in the Camera Raw dialog, per-camera + colour for non-DNG cameras, lens profiles. +- **Done 2026-10-13:** lossy DNG decodes (#5112); `.xmp` sidecars beside raw files fill the + open-time dialog and Open writes them back; the Camera Raw Defaults preferences (colour space, + bit depth, resolution, Sharpen For, Open as Smart Object, Apply auto tone, sidecars) all take + effect on open; the dialog has the Calibration panel (Shadows tint, primaries' hue and + saturation) and an Auto button, both in the `.xmp` settings and the `filter.cameraRaw` params. - **Evidence:** `crates/raw/src/lib.rs:228` (CR3), scorecard FILE-215-11/12, #50. - **Progress (2026-10-11):** on the embedded-JPEG rendering work in #2135, Camera Raw tuning retains the fitted look and applies user gains afterwards. Three D5100 NEFs @@ -255,6 +261,7 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| +| 2026-10-13 | minor | G14: lossy DNG (#5112), `.xmp` sidecars, Camera Raw Defaults wired, Calibration panel and Auto; CR3 sensor decode ruled out under the clean-room rule | | 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 | | 2026-10-12 | minor | G11: `.atn` import maps 112 events (Select and Mask, Spatter, Ripple, Crystallize, Pattern Fill, mask targeting, Step Backward, points, Bitmap) | diff --git a/docs/scorecard.md b/docs/scorecard.md index af13a3f265..0b7b98f40a 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -7,9 +7,9 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js | Area | Done | Partial | Missing | Key numbers | |---|---:|---:|---:|---| | [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 | +| [File compatibility](#file-compatibility) | 7 | 14 | 6 | 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 | | -| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 156 (target 0) | +| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 20 of 157 (target 0) | | [Type](#type) | 4 | 3 | 2 | | | [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) | | [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present | @@ -108,7 +108,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t | FILE-215-8 | Large and BigTIFF import with banded decode across all IFDs | done | [#215](https://github.com/storytold/photocraft/issues/215) | codecs tiff_ifd.rs (bounds-checked IFD chain + SubIFD walk, classic and BigTIFF, cycle-safe; tiff_info / decode_tiff_page), tiff.rs banded parallel strip/tile decode, planar 1 and 2, BigTIFF write (tiff_bigtiff or > 4 GiB); io import_tiff_page; 30 MP RGB8 Deflate 345 -> 32 ms; no page picker in the UI yet | | FILE-215-9 | SVG opens and places as shape layers or a vector Smart Object | done | [#215](https://github.com/storytold/photocraft/issues/215) | io svg.rs: paths, groups, text outlines as shape layers (gradients approximated; clip/mask/filter/pattern/image subtrees rasterised); smart_cmds.rs renders an SVG source at its placement scale | | FILE-215-10 | Multi-page PDF save, PDF presentation, layer comps to PDF, vector/text output, PDF import | missing | [#215](https://github.com/storytold/photocraft/issues/215) | Only print_cmds.rs:133 print_pdf (raster print page) | -| FILE-215-11 | RAW: lossy DNG, highlight modes, .xmp sidecars, RAW prefs wired, per-camera corpus | missing | [#215](https://github.com/storytold/photocraft/issues/215) | raw sensor.rs:210 lossy DNG unsupported; raw_defaults unread; no xmp | +| FILE-215-11 | RAW: lossy DNG, highlight modes, .xmp sidecars, RAW prefs wired, per-camera corpus | partial | [#215](https://github.com/storytold/photocraft/issues/215) | 2026-10-13: lossy DNG (34892) decodes stored 8-bit samples with padded edge tiles (raw sensor.rs lossy_jpeg, #5112); a raw's sidecar IMG.xmp fills the open-time dialog and Open writes it back (camera_raw_ui.rs read_sidecar/write_sidecar, pref rawDefaults.writeXmpSidecars); every Camera Raw Defaults preference is read (colour space, bit depth, resolution, Sharpen For, Open as Smart Object, Apply auto tone: apply_raw_defaults); Calibration panel (shadow tint, primaries hue/saturation) in the dialog, the filter and the crs: keys. Still missing: highlight recovery modes, the absolute (kelvin) white balance of raw sidecars, a per-camera corpus | | FILE-215-12 | Camera Raw dialog shows a histogram; settings persist as a PSD Smart Filter | partial | [#215](https://github.com/storytold/photocraft/issues/215) | Interactive RGB/Lab scopes. PSD WB/Light/Presence, curves, HSL, grading, sharpening/noise detail, grain and numeric vignette controls mapped with descriptor preservation. Active manual Optics and unverified vignette style keep the updated ACR 18.4 fixture opaque; PSD/.pcraft saves preserve it. HDR, remaining settings and Photoshop acceptance still open | | FILE-215-13 | Video layer frames persist in .pcraft; PSD video layers mapped | partial | [#215](https://github.com/storytold/photocraft/issues/215) | format convert.rs:89 + tests/roundtrip.rs:282 persist frames; no PSD video mapping | | FILE-215-14 | User swatch model with ACO/ASE import and export | done | [#215](https://github.com/storytold/photocraft/issues/215) | engine presets/swatches.rs (RGB/HSB/CMYK/Lab/Gray + verbatim colour books, persisted in prefs) + swatch_cmds.rs (swatches.*); psd aco.rs (v1/v2) and ase.rs (groups, spot/global) read+write; ui swatches_ui.rs, Color Picker Add to Swatches | @@ -176,9 +176,9 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t ## Workspace and UI -**Settings that do nothing: 26 of 156** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. +**Settings that do nothing: 20 of 157** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. -Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `file_handling.save_in_background`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`. +Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `file_handling.save_in_background`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `integrations.allow_agent_control`, `integrations.control_port`. | Id | Target | Status | Issue | Note | |---|---|---|---|---| diff --git a/scorecard/file_compat.toml b/scorecard/file_compat.toml index 40b242ea53..561ed49103 100644 --- a/scorecard/file_compat.toml +++ b/scorecard/file_compat.toml @@ -78,9 +78,9 @@ note = "Only print_cmds.rs:133 print_pdf (raster print page)" [[item]] id = "FILE-215-11" target = "RAW: lossy DNG, highlight modes, .xmp sidecars, RAW prefs wired, per-camera corpus" -status = "missing" +status = "partial" issue = 215 -note = "raw sensor.rs:210 lossy DNG unsupported; raw_defaults unread; no xmp" +note = "2026-10-13: lossy DNG (34892) decodes stored 8-bit samples with padded edge tiles (raw sensor.rs lossy_jpeg, #5112); a raw's sidecar IMG.xmp fills the open-time dialog and Open writes it back (camera_raw_ui.rs read_sidecar/write_sidecar, pref rawDefaults.writeXmpSidecars); every Camera Raw Defaults preference is read (colour space, bit depth, resolution, Sharpen For, Open as Smart Object, Apply auto tone: apply_raw_defaults); Calibration panel (shadow tint, primaries hue/saturation) in the dialog, the filter and the crs: keys. Still missing: highlight recovery modes, the absolute (kelvin) white balance of raw sidecars, a per-camera corpus" [[item]] id = "FILE-215-12" From b8b8483bf9b5af858bb44ead80dafebc31f42d7a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 13 Oct 2026 18:08:45 +0000 Subject: [PATCH 046/649] fix(algo): seam carving never panics on degenerate input; NaN never steers seams From an adversarial review of the Content-Aware Scale speed-up: - resize_bilinear with zero channels panicked (chunk size 0) since the previous commit; it, carve_with and carve_width_with now return early when there are no pixels or channels, or fewer values than the size says (sizes checked with checked_mul). carve with an empty width and a height change, and a protection map shorter than the image (now ignored), panicked before this series too. - With NaN in the energy map, which seam was chosen depended on the NaN payload, and that differed between builds. NaN samples now give the highest energy and NaN protection protects nothing, so costs are never NaN; outputs without NaN are unchanged (all pins match). Tests: degenerate_inputs_do_not_panic and nan_payloads_do_not_steer_seams (both failed before), proxy_rebuild_observes_cancellation (a cancel during the tall-image rebuild), and NaN/inf cases in incremental_dp_matches_full_dp. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LELc5BQzgV5dA7dxdMejkK --- crates/algo/src/seam.rs | 121 ++++++++++++++++++++++++++++++++++------ 1 file changed, 105 insertions(+), 16 deletions(-) diff --git a/crates/algo/src/seam.rs b/crates/algo/src/seam.rs index 8b5befda80..59e235bc05 100644 --- a/crates/algo/src/seam.rs +++ b/crates/algo/src/seam.rs @@ -9,13 +9,21 @@ //! //! A protect map (`0..=1`, e.g. an alpha channel or detected skin tones) adds a large energy so //! seams avoid protected pixels. Buffers are interleaved `w × h × ch` normalised floats of any -//! colour model and depth (alpha is carried like any other channel). Deterministic. +//! colour model and depth (alpha is carried like any other channel). Deterministic: a NaN sample +//! gives its pixels the highest energy and NaN protection protects nothing, so no NaN (whose +//! payload arithmetic does not keep consistently across builds) ever reaches the seam search. use photocraft_raster::{Cancelled, Interrupt}; /// Energy added per unit of protection: far above any gradient magnitude. const PROTECT_ENERGY: f32 = 1.0e4; +/// The energy protection `p` (`0..=1`) adds. NaN protects nothing. +#[inline] +fn protection(p: f32) -> f32 { + if p.is_nan() { 0.0 } else { p.clamp(0.0, 1.0) * PROTECT_ENERGY } +} + /// Keep full horizontal detail while reducing the height used to find vertical seams. At a /// 24 MP working size this cuts the dynamic-programming work by about four times without /// quantising the output pixels or changing the requested output dimensions. @@ -48,7 +56,7 @@ pub fn energy(w: usize, h: usize, ch: usize, img: &[f32]) -> Vec { /// [`energy`] of pixel `x` of row `y` of a `cw`-wide, `h`-tall image whose pixel `xx` of row `yy` /// is column `col(xx, yy)` of `img` (`w` pixels per row). Shared by the full map and the carver's -/// per-seam updates, so both give bit-identical values. +/// per-seam updates, so both give bit-identical values. NaN samples give the highest energy. #[allow(clippy::too_many_arguments)] #[inline] fn energy_at(img: &[f32], w: usize, cw: usize, h: usize, ch: usize, x: usize, y: usize, col: impl Fn(usize, usize) -> usize) -> f32 { @@ -62,7 +70,8 @@ fn energy_at(img: &[f32], w: usize, cw: usize, h: usize, ch: usize, x: usize, y: s += (img[right + c] - v).abs() + (v - img[left + c]).abs(); s += (img[down + c] - v).abs() + (v - img[up + c]).abs(); } - s * 0.5 + let e = s * 0.5; + if e.is_nan() { f32::INFINITY } else { e } } /// The lowest-energy vertical seam: one x per row. @@ -114,7 +123,8 @@ struct Dp { /// the pixel straight up, then up-left, then up-right. The cost doesn't depend on the tie-break /// and the direction doesn't depend on `e`, so the seam can be traced back from the costs alone. /// The full pass's edges, [`Dp::update`] and [`Dp::seam`] use it, and the full pass's interior -/// repeats it exactly, so every way of filling the map gives the same bits. +/// repeats it exactly, so every way of filling the map gives the same bits (costs are never NaN: +/// see [`energy_at`] and [`protection`]). #[inline] fn cell(up: &[f32], cw: usize, x: usize, e: f32) -> (f32, u8) { let (b, d) = if x == 0 { @@ -279,8 +289,8 @@ impl<'a> Carver<'a> { fn new(w: usize, h: usize, ch: usize, src: &'a [f32], prot: Option<&'a [f32]>) -> Self { let mut e = energy(w, h, ch, src); if let Some(p) = prot { - for (e, p) in e.iter_mut().zip(p) { - *e += p.clamp(0.0, 1.0) * PROTECT_ENERGY; + for (e, &p) in e.iter_mut().zip(p) { + *e += protection(p); } } let idx = (0..h).flat_map(|_| (0..w).map(|x| u32::try_from(x).unwrap_or(u32::MAX))).collect(); @@ -345,7 +355,7 @@ impl<'a> Carver<'a> { for x in lo..=hi { let mut v = energy_at(src, w, cw, h, ch, x, y, col); if let Some(p) = prot { - v += p[y * w + col(x, y)].clamp(0.0, 1.0) * PROTECT_ENERGY; + v += protection(p[y * w + col(x, y)]); } e[off[y] + x] = v; } @@ -458,6 +468,11 @@ fn average_rows(src: &[f32], row_len: usize, h: usize, step: usize) -> Vec out } +/// No pixels or channels to work with, or `img` holds fewer than `w × h × ch` values. +fn unusable(w: usize, h: usize, ch: usize, img: &[f32]) -> bool { + w == 0 || h == 0 || ch == 0 || w.checked_mul(h).and_then(|n| n.checked_mul(ch)).is_none_or(|n| img.len() < n) +} + /// Change the width of `img` to `new_w` by removing or duplicating vertical seams. pub fn carve_width(w: usize, h: usize, ch: usize, img: &[f32], protect: Option<&[f32]>, new_w: usize) -> Vec { // Never cancelled; the fallback is unreachable. @@ -467,10 +482,12 @@ pub fn carve_width(w: usize, h: usize, ch: usize, img: &[f32], protect: Option<& /// [`carve_width`] that checks `ctl` before every seam and reports progress per seam. pub fn carve_width_with(w: usize, h: usize, ch: usize, img: &[f32], protect: Option<&[f32]>, new_w: usize, ctl: &Interrupt) -> Result, Cancelled> { let new_w = new_w.max(1); - // No channels: nothing to carve (and no pixels to size the work by). - if new_w == w || w == 0 || h == 0 || ch == 0 { + // Nothing to carve: no pixels or channels, or fewer values than the size says. + if new_w == w || unusable(w, h, ch, img) { return Ok(img.to_vec()); } + // A protection map that doesn't cover the image protects nothing. + let protect = protect.filter(|p| p.len() >= w * h); let seams = new_w.abs_diff(w).max(1) as f32; if new_w < w { if h >= PROXY_SHRINK_MIN_HEIGHT && w - new_w >= PROXY_SHRINK_MIN_SEAMS { @@ -628,6 +645,10 @@ pub fn carve_with( ctl: &Interrupt, ) -> Result, Cancelled> { let (new_w, new_h) = (new_w.max(1), new_h.max(1)); + if unusable(w, h, ch, img) { + return Ok(img.to_vec()); + } + let protect = protect.filter(|p| p.len() >= w * h); // Split progress between the passes by their seam counts. let (sw, sh) = (new_w.abs_diff(w) as f32, new_h.abs_diff(h) as f32); let split = if sw + sh > 0.0 { sw / (sw + sh) } else { 1.0 }; @@ -647,8 +668,11 @@ pub fn carve_with( /// Plain bilinear resize (the non-content-aware part of the Amount blend). pub fn resize_bilinear(w: usize, h: usize, ch: usize, img: &[f32], nw: usize, nh: usize) -> Vec { - let mut out = vec![0.0f32; nw * nh * ch]; - if w == 0 || h == 0 || nw == 0 || nh == 0 { + let Some(len) = nw.checked_mul(nh).and_then(|n| n.checked_mul(ch)) else { + return Vec::new(); + }; + let mut out = vec![0.0f32; len]; + if len == 0 || unusable(w, h, ch, img) { return out; } let row = |(y, out): (usize, &mut [f32])| { @@ -702,7 +726,7 @@ mod tests { /// The straightforward implementation the per-seam carver replaced (full energy map, fresh /// seam search and a new buffer per seam), kept as the oracle for `carver_matches_reference`. mod reference { - use super::super::{PROTECT_ENERGY, resize_bilinear, transpose}; + use super::super::{protection, resize_bilinear, transpose}; pub(super) fn energy(w: usize, h: usize, ch: usize, img: &[f32]) -> Vec { let mut e = vec![0.0f32; w * h]; @@ -717,7 +741,8 @@ mod tests { s += (at(xr, y, c) - v).abs() + (v - at(xl, y, c)).abs(); s += (at(x, yd, c) - v).abs() + (v - at(x, yu, c)).abs(); } - e[y * w + x] = s * 0.5; + let v = s * 0.5; + e[y * w + x] = if v.is_nan() { f32::INFINITY } else { v }; } } e @@ -770,8 +795,8 @@ mod tests { } let protect_e = |e: &mut [f32], p: Option<&Vec>| { if let Some(p) = p { - for (e, p) in e.iter_mut().zip(p) { - *e += p.clamp(0.0, 1.0) * PROTECT_ENERGY; + for (e, &p) in e.iter_mut().zip(p) { + *e += protection(p); } } }; @@ -906,6 +931,12 @@ mod tests { let (x, y) = ((i % 120) as f32, (i / 120) as f32); *v = ((x * 0.07).sin() * (y * 0.05).cos() * 0.5 + 0.5).clamp(0.0, 1.0); } + // NaN and infinite samples and NaN protection: infinite energies, never NaN costs. + let mut odd = noise(40 * 30 * 3, 255, 11); + odd.iter_mut().step_by(13).for_each(|v| *v = f32::NAN); + odd.iter_mut().skip(5).step_by(17).for_each(|v| *v = f32::INFINITY); + let mut odd_prot = noise(40 * 30, 3, 12); + odd_prot.iter_mut().step_by(7).for_each(|v| *v = -f32::NAN); // (w, h, channels, image, protection, seams to remove) type Case = (usize, usize, usize, Vec, Option>, usize); let cases: Vec = vec![ @@ -916,6 +947,7 @@ mod tests { (33, 1, 1, noise(33, 5, 8), None, 32), (2, 40, 3, noise(2 * 40 * 3, 9, 9), None, 2), (50, 40, 1, vec![0.5; 50 * 40], Some(noise(50 * 40, 2, 10)), 49), + (40, 30, 3, odd, Some(odd_prot), 25), ]; let bits = |v: &[f32]| v.iter().map(|f| f.to_bits()).collect::>(); for (case, (w, h, ch, img, prot, seams)) in cases.into_iter().enumerate() { @@ -937,7 +969,7 @@ mod tests { if let Some(p) = &prot { let kept = (0..h).flat_map(|y| c.idx[rows.of(y)].iter().map(move |&x| y * w + x as usize)); for (e, i) in want.iter_mut().zip(kept) { - *e += p[i].clamp(0.0, 1.0) * PROTECT_ENERGY; + *e += protection(p[i]); } } let have: Vec = (0..h).flat_map(|y| c.e[rows.of(y)].to_vec()).collect(); @@ -951,6 +983,63 @@ mod tests { } } + /// Hostile but well-formed shapes return early instead of panicking: no channels, empty + /// sizes (also through the height pass), and images or protection maps shorter than their + /// size says (a short map protects nothing). + #[test] + fn degenerate_inputs_do_not_panic() { + assert!(carve(3, 3, 0, &[], None, 2, 2).is_empty()); + assert!(carve(3, 3, 0, &[], None, 5, 5).is_empty()); + assert!(transpose(3, 3, 0, &[]).is_empty()); + assert!(resize_bilinear(3, 3, 0, &[], 2, 2).is_empty()); + assert!(resize_bilinear(3, 3, 1, &[0.5; 9], 0, 2).is_empty()); + assert!(resize_bilinear(3, 3, 1, &[0.5; 9], 2, 0).is_empty()); + assert_eq!(resize_bilinear(3, 3, 1, &[0.5; 4], 2, 2), vec![0.0; 4]); + assert!(carve(0, 5, 3, &[], None, 3, 7).is_empty()); + assert!(carve(0, 5, 3, &[], None, 3, 2).is_empty()); + let img = noise(10 * 5, 7, 3); + assert_eq!(carve(10, 5, 1, &img, Some(&[0.0; 3]), 4, 5), carve(10, 5, 1, &img, None, 4, 5)); + assert_eq!(carve(10, 5, 1, &img, Some(&[0.0; 3]), 4, 3), carve(10, 5, 1, &img, None, 4, 3)); + assert_eq!(carve(10, 5, 3, &[0.5; 20], None, 4, 5), vec![0.5; 20]); + assert_eq!(carve_width(usize::MAX, 2, 4, &[0.5; 8], None, 1), vec![0.5; 8]); + } + + /// A cancel that arrives after the seam search, during the tall-image rebuild, still stops + /// the carve. + #[test] + fn proxy_rebuild_observes_cancellation() { + use std::sync::atomic::{AtomicUsize, Ordering}; + let (w, h, ch, new_w) = (128, PROXY_SHRINK_MIN_HEIGHT, 3, 64); + let img = noise(w * h * ch, 7, 5); + let calls = AtomicUsize::new(0); + // One check per seam passes; the first one after the search cancels. + let cancel = || calls.fetch_add(1, Ordering::Relaxed) >= w - new_w; + assert_eq!(carve_width_with(w, h, ch, &img, None, new_w, &Interrupt::cancel_only(&cancel)), Err(Cancelled)); + assert!(calls.load(Ordering::Relaxed) > w - new_w, "the rebuild checked for cancellation"); + } + + /// NaN samples and NaN protection steer seams the same whatever their sign and payload + /// (which arithmetic does not preserve consistently across builds): the same pixels are kept. + #[test] + fn nan_payloads_do_not_steer_seams() { + let (w, h, ch) = (24, 18, 3); + let (base, prot_base) = (noise(w * h * ch, 255, 21), noise(w * h, 3, 22)); + let carve_with_nans = |pixel: f32, prot: f32| { + let (mut img, mut p) = (base.clone(), prot_base.clone()); + img.iter_mut().step_by(37).for_each(|v| *v = pixel); + p.iter_mut().step_by(29).for_each(|v| *v = prot); + carve(w, h, ch, &img, Some(&p), 15, 11) + }; + let canonical = |v: Vec| v.into_iter().map(|f| if f.is_nan() { u32::MAX } else { f.to_bits() }).collect::>(); + let nans = [f32::NAN, -f32::NAN, f32::from_bits(0x7fc0_1234), f32::from_bits(0xffc0_0001)]; + let want = canonical(carve_with_nans(nans[0], nans[0])); + for &a in &nans { + for &b in &nans { + assert_eq!(canonical(carve_with_nans(a, b)), want, "pixel NaN {:#x}, protection NaN {:#x}", a.to_bits(), b.to_bits()); + } + } + } + #[test] fn cancelled_carve_stops() { let (w, h) = (40, 20); From bc947f667ad37fc8df9dc4e2d4d466e4f8fd264d Mon Sep 17 00:00:00 2001 From: Skyfuller1303 Date: Tue, 13 Oct 2026 20:10:38 +0200 Subject: [PATCH 047/649] refactor(ui): name the Move layer offset shown_layer_offset --- crates/ui-egui/src/canvas.rs | 2 +- crates/ui-egui/src/move_ui.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index db0efe31fa..15391e1a8f 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -4487,7 +4487,7 @@ pub(crate) fn layer_edges_rect(app: &PhotocraftApp, idx: usize) -> Option Vec { /// offset of the latest Move drag frame drawn ([`display_doc`]) when the layer moves with the drag, /// so its Layer Edges outline moves in lockstep with its pixels (#2413). `None` when it shows /// where it is. -pub(crate) fn shown_offset(app: &PhotocraftApp, doc: DocId, revision: u64, id: LayerId) -> Option<(i32, i32)> { +pub(crate) fn shown_layer_offset(app: &PhotocraftApp, doc: DocId, revision: u64, id: LayerId) -> Option<(i32, i32)> { let p = app.move_preview.as_ref().filter(|p| p.doc == doc && p.revision == revision && !p.floating && p.shown.is_some())?; if !p.moving.contains(&id) { return None; From 890442609e8b5d63b18f2ef3005f6997f6a49a72 Mon Sep 17 00:00:00 2001 From: Skyfuller1303 Date: Tue, 13 Oct 2026 20:11:02 +0200 Subject: [PATCH 048/649] refactor(ui): share the pattern library grid outside its popup --- crates/ui-egui/src/preset_panels.rs | 42 ++++++++++++++++++----------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/crates/ui-egui/src/preset_panels.rs b/crates/ui-egui/src/preset_panels.rs index 7e9e9b6727..cccf8ab029 100644 --- a/crates/ui-egui/src/preset_panels.rs +++ b/crates/ui-egui/src/preset_panels.rs @@ -261,22 +261,34 @@ pub(crate) fn pattern_picker(app: &PhotocraftApp, ui: &mut egui::Ui, selected: & resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, tl!("Patterns"))); let mut picked = None; egui::Popup::menu(&resp).show(|ui| { - ui.set_max_width(6.0 * (SWATCH + 4.0)); - ui.horizontal_wrapped(|ui| { - ui.spacing_mut().item_spacing = vec2(4.0, 4.0); - for p in pats { - let (r, cell) = ui.allocate_exact_size(vec2(SWATCH, SWATCH), Sense::click()); - ui.painter().image(pattern_texture(&ctx, p).id(), r, uv, Color32::WHITE); - let (w, c) = if p.id == selected { (2.0, t.accent) } else { (1.0, t.field_border) }; - ui.painter().rect_stroke(r, 0.0, Stroke::new(w, c), egui::StrokeKind::Outside); - let cell = cell.on_hover_text(p.display_name()); - cell.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, p.display_name())); - if cell.clicked() { - picked = Some(p.id.clone()); - ui.close(); - } + picked = pattern_grid(app, ui, selected); + }); + picked +} + +/// Library grid shared by the standalone picker and paint popups. Drawing it inline avoids +/// replacing an already-open paint popup with a second memory-backed popup. +pub(crate) fn pattern_grid(app: &PhotocraftApp, ui: &mut egui::Ui, selected: &str) -> Option { + const SWATCH: f32 = 40.0; + let t = Tokens::get(ui.ctx()); + let ctx = ui.ctx().clone(); + let uv = Rect::from_min_max(Pos2::ZERO, pos2(1.0, 1.0)); + let mut picked = None; + ui.set_max_width(6.0 * (SWATCH + 4.0)); + ui.horizontal_wrapped(|ui| { + ui.spacing_mut().item_spacing = vec2(4.0, 4.0); + for p in &app.session.patterns.items { + let (r, cell) = ui.allocate_exact_size(vec2(SWATCH, SWATCH), Sense::click()); + ui.painter().image(pattern_texture(&ctx, p).id(), r, uv, Color32::WHITE); + let (w, c) = if p.id == selected { (2.0, t.accent) } else { (1.0, t.field_border) }; + ui.painter().rect_stroke(r, 0.0, Stroke::new(w, c), egui::StrokeKind::Outside); + let cell = cell.on_hover_text(p.display_name()); + cell.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), p.display_name())); + if cell.clicked() { + picked = Some(p.id.clone()); + ui.close(); } - }); + } }); picked.filter(|id| id != selected) } From 0b067c7c68c82fe8c763119ab1b7a0af20513024 Mon Sep 17 00:00:00 2001 From: Skyfuller1303 Date: Tue, 13 Oct 2026 20:19:04 +0200 Subject: [PATCH 049/649] refactor(ui): let the gradient stop strip report actions to its caller --- crates/ui-egui/src/gradient_ui.rs | 114 ++++++++++++++---------------- 1 file changed, 54 insertions(+), 60 deletions(-) diff --git a/crates/ui-egui/src/gradient_ui.rs b/crates/ui-egui/src/gradient_ui.rs index be35f66028..b2c703bf4c 100644 --- a/crates/ui-egui/src/gradient_ui.rs +++ b/crates/ui-egui/src/gradient_ui.rs @@ -805,14 +805,50 @@ fn preset_stop_color(app: &mut PhotocraftApp, i: usize) { } fn stops_editor_for(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill) { - let key = strip_key(app, sink).with("selection"); - if ui.data(|d| d.get_temp::(key)).is_none() { - ui.data_mut(|d| d.insert_temp(key, Marker::Color(0))); + let key = strip_key(app, sink); + let selection_key = key.with("selection"); + if ui.data(|d| d.get_temp::(selection_key)).is_none() { + ui.data_mut(|d| d.insert_temp(selection_key, Marker::Color(0))); + } + let pending = match sink { + Sink::Layer(id) => app.gradient.panel.clone().filter(|(l, ..)| *l == id).map(|(_, _, p)| p), + Sink::Preset => app.gradient.preset_stop.clone(), + }; + let colors = (app.session.tools.foreground, app.session.tools.background); + match stop_strip(ui, key, &f, sink.midpoints(), pending.as_ref(), colors) { + Some(StopAction::Preview(p)) => match sink { + Sink::Layer(id) => app.gradient.panel = Some((id, cmds::STOP, sink.params(p))), + Sink::Preset => app.gradient.preset_stop = Some(p), + }, + Some(StopAction::Commit(p)) => { + match sink { + Sink::Layer(_) => app.gradient.panel = None, + Sink::Preset => app.gradient.preset_stop = None, + } + let selected = ui.data(|d| d.get_temp::(selection_key)); + let selection = selection_after_edit(&f, &p, selected); + if app.run(sink.cmd(), sink.params(p)).is_ok() + && let Some(marker) = selection + { + ui.data_mut(|d| d.insert_temp(selection_key, marker)); + } + } + Some(StopAction::Color(i)) => match sink { + Sink::Layer(id) => edit_stop_color(app, id, i), + Sink::Preset => preset_stop_color(app, i), + }, + None => {} } - stop_strip(app, ui, sink, f); properties_panel::stop_fields(app, ui, sink); } +/// A shared stop strip keeps previews local; its caller chooses the command or paint target. +pub(crate) enum StopAction { + Preview(Value), + Commit(Value), + Color(usize), +} + /// Keep selection on a stop after the engine sorts its new position. fn selection_after_edit(f: &Fill, p: &Value, previous: Option) -> Option { let Fill::Gradient { stops, opacity_stops, .. } = f else { return previous }; @@ -840,8 +876,8 @@ fn selection_after_edit(f: &Fill, p: &Value, previous: Option) -> Option Some(if opacity { Marker::Opacity(at) } else { Marker::Color(at) }) } -fn stop_strip(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill) { - let Fill::Gradient { stops, .. } = &f else { return }; +fn stop_strip(ui: &mut egui::Ui, key: egui::Id, f: &Fill, midpoints: bool, pending: Option<&Value>, colors: ([f32; 4], [f32; 4])) -> Option { + let Fill::Gradient { stops, .. } = f else { return None }; let t = Tokens::get(ui.ctx()); let w = ui.available_width().max(120.0); let (outer, resp) = ui.allocate_exact_size(vec2(w, 58.0), Sense::click_and_drag()); @@ -852,12 +888,8 @@ fn stop_strip(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill) { let x_of = |loc: f32| bar.left() + loc.clamp(0.0, 1.0) * bar.width(); let loc_of = |x: f32| ((x - bar.left()) / bar.width().max(1.0)).clamp(0.0, 1.0); // The ramp being shown (with a pending drag's edit applied). - let pending: Option = match sink { - Sink::Layer(id) => app.gradient.panel.clone().filter(|(l, ..)| *l == id).map(|(_, _, p)| p), - Sink::Preset => app.gradient.preset_stop.clone(), - }; - let (fg, bg) = (app.session.tools.foreground, app.session.tools.background); - let shown = pending.as_ref().and_then(|p| cmds::apply_stop(&f, p, fg, bg).ok()).unwrap_or_else(|| f.clone()); + let (fg, bg) = colors; + let shown = pending.and_then(|p| cmds::apply_stop(f, p, fg, bg).ok()).unwrap_or_else(|| f.clone()); let mut track_fill = shown.clone(); if let Fill::Gradient { reverse, .. } = &mut track_fill { // All markers address un-reversed positions; Reverse applies to the canvas output. @@ -875,7 +907,6 @@ fn stop_strip(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill) { sorted.sort_by(|a, b| a.0.total_cmp(&b.0)); let mut ops: Vec<(f32, f32)> = if os.is_empty() { vec![(0.0, 1.0), (1.0, 1.0)] } else { os.clone() }; ops.sort_by(|a, b| a.0.total_cmp(&b.0)); - let key = strip_key(app, sink); let selection_key = key.with("selection"); let selected: Option = ui.data(|d| d.get_temp(selection_key)); let dragging: Option = ui.data(|d| d.get_temp(key)); @@ -896,7 +927,7 @@ fn stop_strip(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill) { p.rect_filled(body, 1.0, color); p.rect_stroke(body, 1.0, Stroke::new(1.0, if sel { t.accent } else { t.text_dim }), StrokeKind::Outside); } - if sink.midpoints() { + if midpoints { for i in 0..sorted.len().saturating_sub(1) { let (a, b) = (sorted[i].0, sorted[i + 1].0); if b - a > 1e-3 { @@ -926,7 +957,7 @@ fn stop_strip(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill) { if let Some(i) = sorted.iter().position(|(l, _)| (x_of(*l) - pos.x).abs() <= 6.0 && pos.y >= bar.bottom() + 3.0) { return Some(Marker::Color(i)); } - if !sink.midpoints() { + if !midpoints { return None; } return (0..sorted.len().saturating_sub(1)) @@ -949,6 +980,7 @@ fn stop_strip(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill) { ui.data_mut(|d| d.insert_temp(selection_key, m)); } let dragging: Option = ui.data(|d| d.get_temp(key)); + let mut preview = None; if let (Some(m), Some(pos)) = (dragging, resp.interact_pointer_pos()) { let off = if pos.y > bar.bottom() + 28.0 || pos.y < bar.top() - 26.0 { 1.0 } else { 0.0 }; let loc = loc_of(pos.x); @@ -963,70 +995,32 @@ fn stop_strip(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill) { } }; if resp.dragged() { - match sink { - Sink::Layer(id) => app.gradient.panel = Some((id, cmds::STOP, sink.params(edit))), - Sink::Preset => app.gradient.preset_stop = Some(edit), - } + preview = Some(edit); } } if resp.drag_stopped() { ui.data_mut(|d| d.remove::(key)); - match sink { - Sink::Layer(_) => { - if let Some((_, cmd, p)) = app.gradient.panel.take() { - let selection = selection_after_edit(&f, &p, selected); - if app.run(cmd, p).is_ok() - && let Some(marker) = selection - { - ui.data_mut(|d| d.insert_temp(selection_key, marker)); - } - } - } - Sink::Preset => { - if let Some(p) = app.gradient.preset_stop.take() { - let selection = selection_after_edit(&f, &p, selected); - if app.run(sink.cmd(), p).is_ok() - && let Some(marker) = selection - { - ui.data_mut(|d| d.insert_temp(selection_key, marker)); - } - } - } - } - return; + return preview.or_else(|| pending.cloned()).map(StopAction::Commit); } if resp.double_clicked() && let Some(pos) = resp.interact_pointer_pos() && let Some(Marker::Color(i)) = hit(pos) { ui.data_mut(|d| d.insert_temp(selection_key, Marker::Color(i))); - match sink { - Sink::Layer(id) => edit_stop_color(app, id, i), - Sink::Preset => preset_stop_color(app, i), - } - return; + return Some(StopAction::Color(i)); } if resp.clicked() && let Some(pos) = resp.interact_pointer_pos() { if let Some(marker) = hit(pos) { ui.data_mut(|d| d.insert_temp(selection_key, marker)); - return; + return None; } let loc = loc_of(pos.x); - let opacity = pos.y < bar.center().y; - let p = if opacity { - sink.params(json!({"action": "add", "kind": "opacity", "location": loc})) - } else { - sink.params(json!({"action": "add", "location": loc})) - }; - let selection = selection_after_edit(&f, &p, selected); - if app.run(sink.cmd(), p).is_ok() - && let Some(marker) = selection - { - ui.data_mut(|d| d.insert_temp(selection_key, marker)); - } + let p = if pos.y < bar.center().y { json!({"action": "add", "kind": "opacity", "location": loc}) } else { json!({"action": "add", "location": loc}) }; + return Some(StopAction::Commit(p)); } + preview.map(StopAction::Preview) } #[cfg(test)] From d30683fb7f0240a935628423e1f586dd4a26bf8d Mon Sep 17 00:00:00 2001 From: Skyfuller1303 Date: Tue, 13 Oct 2026 20:19:04 +0200 Subject: [PATCH 050/649] refactor(ui): move the shape options bar and paint swatch into their own modules --- crates/ui-egui/src/lib.rs | 2 + crates/ui-egui/src/shape_options.rs | 158 ++++++++++++++ crates/ui-egui/src/shape_paint_ui.rs | 130 +++++++++++ crates/ui-egui/src/vector_paint_tests.rs | 2 + crates/ui-egui/src/vector_ui.rs | 263 +---------------------- 5 files changed, 298 insertions(+), 257 deletions(-) create mode 100644 crates/ui-egui/src/shape_options.rs create mode 100644 crates/ui-egui/src/shape_paint_ui.rs diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 2cd006087d..292c9dab81 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -177,6 +177,8 @@ pub mod select_mask_view; pub mod served_fonts; pub mod shape_dialog; pub(crate) mod shape_fill_ui; +mod shape_options; +mod shape_paint_ui; pub mod shape_stroke_ui; pub mod shortcut_dispatch; pub mod shortcuts; diff --git a/crates/ui-egui/src/shape_options.rs b/crates/ui-egui/src/shape_options.rs new file mode 100644 index 0000000000..a125e7cb06 --- /dev/null +++ b/crates/ui-egui/src/shape_options.rs @@ -0,0 +1,158 @@ +//! Shape toolbar edits share the engine commands used by the Properties panel. + +use photocraft_doc::LayerContent; +use serde_json::{Value, json}; + +use crate::PhotocraftApp; +use crate::shape_paint_ui::{PaintChange, swatch}; +use crate::state::Tool; +use crate::theme::Tokens; +use crate::vector_ui::enabled_stroke_width; + +fn solid(color: [f32; 4]) -> photocraft_doc::Fill { + photocraft_doc::Fill::Solid(photocraft_doc::Color::rgba(color[0], color[1], color[2], color[3])) +} + +/// The shape layer the options bar edits. +struct SelectedShape { + doc: photocraft_doc::DocId, + layer: photocraft_doc::LayerId, + fill: Option, + stroke: Option, + live: Option, +} + +fn selected_shape(session: &photocraft_engine::Session) -> Option { + let st = session.active()?; + let layer = st.active_layer?; + match &st.doc.layer(layer)?.content { + LayerContent::Shape(sh) => Some(SelectedShape { doc: st.doc.id, layer, fill: sh.fill.clone(), stroke: sh.stroke.clone(), live: sh.live.clone() }), + _ => None, + } +} + +pub(crate) fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) { + let t = Tokens::get(ui.ctx()); + let lbl = |ui: &mut egui::Ui, s: &str| { + ui.label(egui::RichText::new(s).color(t.text_dim).size(12.0)); + }; + let o = &mut app.ui.tool_options; + let target = selected_shape(&app.session); + // Fill and Stroke edit the selected shape layer too (#3347), and still set the next shape's. + let (fg, bg) = (app.session.tools.foreground, app.session.tools.background); + let (mut has_fill, fill, stroke) = match &target { + Some(s) => (s.fill.is_some(), s.fill.clone(), s.stroke.clone()), + None => (o.shape_fill, o.shape_fill.then(|| solid(fg)), (o.stroke_width > 0.0).then(|| o.shape_stroke.stroke(o.stroke_width, solid(bg)))), + }; + let mut width = stroke.as_ref().map_or(0.0, |s| s.width); + let style = stroke.as_ref().map_or_else(|| o.shape_stroke.clone(), crate::shape_stroke_ui::StrokeOptions::from); + let key = |k: &str| target.as_ref().map(|s| format!("shape-options-{:?}-{}-{k}", s.doc, s.layer.0)); + let mut edit: Option = None; + lbl(ui, tl!("Fill:")); + if crate::widgets::checkbox(ui, &mut has_fill, "").changed() { + o.shape_fill = has_fill; + edit = Some(json!({"fill": if has_fill { json!(fg) } else { Value::Null }})); + } + let fill_color = swatch(ui, fill.as_ref(), fg, tl!("Fill color")); + lbl(ui, tl!("Stroke:")); + let stroke_color = swatch(ui, stroke.as_ref().map(|s| &s.paint), bg, tl!("Stroke color")); + if crate::widgets::value_field(ui, &mut width, 0.0..=288.0, "px", 58.0).changed() { + o.stroke_width = width; + let mut p = json!({"width": width}); + if stroke.is_none() { + p["color"] = json!(bg); + } + edit = Some(if width <= 0.0 { json!({"stroke": null}) } else { json!({"stroke": p, "coalesce": key("stroke-w")}) }); + } + let preview = target.as_ref().filter(|s| s.stroke.is_some()).map(|s| (s.doc, s.layer)); + if let Some(change) = + crate::shape_stroke_ui::button(ui, "tool-stroke", &style, &mut app.ui.stroke_editor, true, tool != Tool::EllipseShape, preview, stroke.is_some()) + { + let mut p = change.options.params(); + if stroke.is_none() { + p["width"] = json!(3.0); + p["color"] = json!(bg); + } + edit = Some(json!({"stroke": p, "coalesce": change.coalesce})); + o.shape_stroke = change.options; + o.stroke_width = enabled_stroke_width(o.stroke_width); + } + match tool { + Tool::Rectangle => { + crate::widgets::vline(ui, 22.0); + lbl(ui, tl!("Radius:")); + let mut r = match target.as_ref().and_then(|s| s.live.as_ref()) { + Some(photocraft_doc::LiveShape::Rect { radii, .. }) => radii[0] as f32, + _ => o.corner_radius, + }; + if crate::widgets::value_field(ui, &mut r, 0.0..=10000.0, "px", 62.0).changed() { + o.corner_radius = r; + let rf = r as f64; + edit = Some(json!({"radii": [rf, rf, rf, rf], "coalesce": key("radius")})); + } + } + Tool::Polygon => { + crate::widgets::vline(ui, 22.0); + lbl(ui, tl!("Sides:")); + let mut s = o.polygon_sides as f32; + if crate::widgets::value_field(ui, &mut s, 3.0..=100.0, "", 48.0).changed() { + o.polygon_sides = s.round().clamp(3.0, 100.0) as u32; + } + } + Tool::Line => { + crate::widgets::vline(ui, 22.0); + lbl(ui, tl!("Weight:")); + crate::widgets::value_field(ui, &mut o.line_weight, 1.0..=1000.0, "px", 58.0); + } + Tool::CustomShape => { + crate::widgets::vline(ui, 22.0); + crate::preset_panels::shape_picker(app, ui); + } + _ if matches!(tool, Tool::PathSelection | Tool::DirectSelection) => { + if let Some(photocraft_doc::LiveShape::Rect { radii, .. }) = target.as_ref().and_then(|s| s.live.as_ref()) { + crate::widgets::vline(ui, 22.0); + lbl(ui, tl!("Radius:")); + let mut r = radii[0] as f32; + if crate::widgets::value_field(ui, &mut r, 0.0..=10000.0, "px", 62.0).changed() { + o.corner_radius = r; + let rf = r as f64; + edit = Some(json!({"radii": [rf, rf, rf, rf], "coalesce": key("radius")})); + } + } + } + _ => {} + } + for (is_stroke, change) in [(false, fill_color), (true, stroke_color)] { + let Some(change) = change else { continue }; + if let Err(e) = set_tool_paint(app, is_stroke, change) { + app.ui.status = e; + app.ui.status_error = true; + } + edit = Some(match (is_stroke, change) { + (false, PaintChange::None) => json!({"fill": null}), + (false, PaintChange::Color(color)) => json!({"fill": color, "coalesce": key("fill")}), + (true, PaintChange::None) => json!({"stroke": null}), + (true, PaintChange::Color(color)) => json!({"stroke": {"color": color, "width": enabled_stroke_width(width)}, "coalesce": key("stroke")}), + }); + } + if let (Some(mut p), Some(s)) = (edit, &target) { + p["layer"] = json!(s.layer.0); + if let Err(e) = app.run("shape.edit", p) { + app.ui.status = e; + app.ui.status_error = true; + } + } +} + +/// Tool-bar paint changes affect the next shape; Properties edits the selected shape instead. +pub(crate) fn set_tool_paint(app: &mut PhotocraftApp, stroke: bool, change: PaintChange) -> Result<(), String> { + if let PaintChange::Color(color) = change { + app.run("tools.setColors", if stroke { json!({"background": color}) } else { json!({"foreground": color}) })?; + } + if stroke { + app.ui.tool_options.stroke_width = if change == PaintChange::None { 0.0 } else { enabled_stroke_width(app.ui.tool_options.stroke_width) }; + } else { + app.ui.tool_options.shape_fill = change != PaintChange::None; + } + Ok(()) +} diff --git a/crates/ui-egui/src/shape_paint_ui.rs b/crates/ui-egui/src/shape_paint_ui.rs new file mode 100644 index 0000000000..28bb1c9058 --- /dev/null +++ b/crates/ui-egui/src/shape_paint_ui.rs @@ -0,0 +1,130 @@ +//! Shape fill and stroke swatches shared by the options bar and the Properties panel. + +use egui::{Color32, Sense, Stroke, vec2}; + +use crate::theme::Tokens; + +pub(crate) fn color_of(f: &photocraft_doc::Fill) -> Option<[f32; 4]> { + match f { + photocraft_doc::Fill::Solid(c) => { + let [r, g, b] = c.to_rgb(); + Some([r, g, b, c.alpha]) + } + _ => None, + } +} + +#[derive(Clone, Copy, Debug, PartialEq)] +pub(crate) enum PaintChange { + Color([f32; 4]), + None, +} + +fn rgba32(c: [f32; 4]) -> Color32 { + let b = |v: f32| (v.clamp(0.0, 1.0) * 255.0).round() as u8; + Color32::from_rgba_unmultiplied(b(c[0]), b(c[1]), b(c[2]), b(c[3])) +} + +fn picker_color(c: [f32; 4]) -> egui::ecolor::Hsva { + let linear = egui::ecolor::linear_from_gamma; + let display = c.map(|v| if v.is_finite() { v.clamp(0.0, 1.0) } else { 0.0 }); + egui::ecolor::Hsva::from_rgba_unmultiplied(linear(display[0]), linear(display[1]), linear(display[2]), display[3]) +} + +fn picker_rgba(hsva: egui::ecolor::Hsva) -> [f32; 4] { + let [r, g, b, a] = hsva.to_rgba_unmultiplied(); + let gamma = egui::ecolor::gamma_from_linear; + [gamma(r), gamma(g), gamma(b), a] +} + +/// The shared compact picker keeps the float RGB paint and its alpha. Color32 is only display +/// data: opening the picker must never quantize an existing high-depth colour or enable paint. +pub(crate) fn swatch(ui: &mut egui::Ui, fill: Option<&photocraft_doc::Fill>, fallback: [f32; 4], tip: &str) -> Option { + let t = Tokens::get(ui.ctx()); + let (r, resp) = ui.allocate_exact_size(vec2(30.0, 22.0), Sense::click()); + resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::ColorButton, ui.is_enabled(), tip)); + let current = fill.and_then(color_of); + crate::widgets::checker(ui.painter(), r.shrink(1.0), 4.0); + match (current, fill) { + (Some(c), _) => { + ui.painter().rect_filled(r.shrink(1.0), t.radius_sm, rgba32(c)); + } + (None, Some(photocraft_doc::Fill::Gradient { stops, .. })) if !stops.is_empty() => { + // Gradient fills preview as a left-to-right ramp through their stops. + let rgb = |c: &photocraft_doc::Color| { + let v = c.to_rgba8(); + Color32::from_rgba_unmultiplied(v[0], v[1], v[2], v[3]) + }; + let mut mesh = egui::Mesh::default(); + let mut ramp: Vec<(f32, Color32)> = stops.iter().map(|(p, c)| (p.clamp(0.0, 1.0), rgb(c))).collect(); + ramp.insert(0, (0.0, ramp[0].1)); + ramp.push((1.0, ramp[ramp.len() - 1].1)); + for (i, (p, c)) in ramp.iter().enumerate() { + let x = r.left() + r.width() * p; + mesh.colored_vertex(egui::pos2(x, r.top()), *c); + mesh.colored_vertex(egui::pos2(x, r.bottom()), *c); + if i > 0 { + let k = (i as u32) * 2; + mesh.add_triangle(k - 2, k - 1, k); + mesh.add_triangle(k - 1, k, k + 1); + } + } + ui.painter().add(mesh); + } + (None, Some(_)) => {} + (None, None) => { + ui.painter().rect_filled(r.shrink(1.0), t.radius_sm, t.field); + ui.painter().line_segment([r.shrink(3.0).left_bottom(), r.shrink(3.0).right_top()], Stroke::new(1.5, t.danger)); + } + }; + let border = if resp.has_focus() { + t.accent + } else if resp.hovered() { + t.text_dim + } else { + t.field_border + }; + ui.painter().rect_stroke(r, t.radius_sm, Stroke::new(1.0, border), egui::StrokeKind::Inside); + let resp = resp.on_hover_text(tip); + let screen_id = resp.id.with("screen-color"); + let original = current.unwrap_or(fallback); + let sampled = |rgb: [f32; 3]| PaintChange::Color([rgb[0], rgb[1], rgb[2], original[3]]); + let mut out = crate::screen_picker::take(ui.ctx(), screen_id).map(sampled); + let cache = resp.id.with("shape-paint-hsva"); + let mut hsva = ui + .data(|d| d.get_temp::<([f32; 4], egui::ecolor::Hsva)>(cache)) + .filter(|(previous, _)| *previous == original) + .map_or_else(|| picker_color(original), |(_, hsva)| hsva); + if let Some(PaintChange::Color(color)) = out { + hsva = picker_color(color); + } + crate::widgets::swatch_popup(&resp).show(|ui| { + ui.horizontal(|ui| { + if ui.selectable_label(fill.is_none(), tl!("No Color")).clicked() && fill.is_some() { + out = Some(PaintChange::None); + } + if ui.selectable_label(current.is_some(), tl!("Solid")).clicked() && current.is_none() { + out = Some(PaintChange::Color(original)); + } + }); + ui.separator(); + let before = picker_rgba(hsva); + if egui::color_picker::color_picker_hsva_2d(ui, &mut hsva, egui::color_picker::Alpha::OnlyBlend) { + let color = picker_rgba(hsva); + // egui's HSV gamma/linear round trip can move a float by an ulp without input. + if color.iter().zip(before).any(|(a, b)| (a - b).abs() > 0.000001) { + out = Some(PaintChange::Color(color)); + } + } + if let Some(rgb) = crate::screen_picker::button(ui, screen_id) { + out = Some(sampled(rgb)); + hsva = picker_color([rgb[0], rgb[1], rgb[2], original[3]]); + } + }); + let cached_color = match out { + Some(PaintChange::Color(color)) => color, + _ => original, + }; + ui.data_mut(|d| d.insert_temp(cache, (cached_color, hsva))); + out +} diff --git a/crates/ui-egui/src/vector_paint_tests.rs b/crates/ui-egui/src/vector_paint_tests.rs index c62277fb1e..c347a9dd01 100644 --- a/crates/ui-egui/src/vector_paint_tests.rs +++ b/crates/ui-egui/src/vector_paint_tests.rs @@ -1,5 +1,7 @@ //! Pointer, keyboard, colour precision and history regressions for shape appearance controls. use super::*; +use crate::shape_options::set_tool_paint; +use crate::shape_paint_ui::color_of; use egui::{Event, Key, Modifiers, PointerButton}; use egui_kittest::{Harness, kittest::Queryable}; use photocraft_doc::ShapeLayer; diff --git a/crates/ui-egui/src/vector_ui.rs b/crates/ui-egui/src/vector_ui.rs index e9d998b046..6621a6f5ae 100644 --- a/crates/ui-egui/src/vector_ui.rs +++ b/crates/ui-egui/src/vector_ui.rs @@ -11,6 +11,7 @@ use serde_json::{Value, json}; use crate::PhotocraftApp; use crate::canvas::ViewXform; +use crate::shape_paint_ui::{PaintChange, swatch}; use crate::state::{Tool, ToolOptions}; use crate::theme::Tokens; @@ -1117,129 +1118,15 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo let mut mode = "shape".to_string(); crate::widgets::dropdown(ui, "shape-mode", &mut mode, &[("shape".to_string(), tl!("Shape"))], 80.0); crate::widgets::vline(ui, 22.0); - // Fill and Stroke edit the selected shape layer too (#3347), and still set the next shape's. - let (fg, bg) = (app.session.tools.foreground, app.session.tools.background); - let (mut has_fill, fill, stroke) = match &target { - Some(s) => (s.fill.is_some(), s.fill.clone(), s.stroke.clone()), - None => (o.shape_fill, o.shape_fill.then(|| solid_paint(fg)), (o.stroke_width > 0.0).then(|| o.shape_stroke.stroke(o.stroke_width, solid_paint(bg)))), - }; - let mut width = stroke.as_ref().map_or(0.0, |s| s.width); - let style = stroke.as_ref().map_or_else(|| o.shape_stroke.clone(), crate::shape_stroke_ui::StrokeOptions::from); - let key = |k: &str| target.as_ref().map(|s| format!("shape-options-{:?}-{}-{k}", s.doc, s.layer.0)); - let mut edit: Option = None; - lbl(ui, tl!("Fill:")); - if crate::widgets::checkbox(ui, &mut has_fill, "").changed() { - o.shape_fill = has_fill; - edit = Some(json!({"fill": if has_fill { json!(fg) } else { Value::Null }})); - } - let fill_color = swatch(ui, fill.as_ref(), fg, tl!("Fill color")); - lbl(ui, tl!("Stroke:")); - let stroke_color = swatch(ui, stroke.as_ref().map(|s| &s.paint), bg, tl!("Stroke color")); - if crate::widgets::value_field(ui, &mut width, 0.0..=288.0, "px", 58.0).changed() { - o.stroke_width = width; - let mut p = json!({"width": width}); - if stroke.is_none() { - p["color"] = json!(bg); - } - edit = Some(if width <= 0.0 { json!({"stroke": null}) } else { json!({"stroke": p, "coalesce": key("stroke-w")}) }); - } - let preview = target.as_ref().filter(|s| s.stroke.is_some()).map(|s| (s.doc, s.layer)); - if let Some(change) = - crate::shape_stroke_ui::button(ui, "tool-stroke", &style, &mut app.ui.stroke_editor, true, tool != Tool::EllipseShape, preview, stroke.is_some()) - { - let mut p = change.options.params(); - if stroke.is_none() { - p["width"] = json!(3.0); - p["color"] = json!(bg); - } - edit = Some(json!({"stroke": p, "coalesce": change.coalesce})); - o.shape_stroke = change.options; - o.stroke_width = enabled_stroke_width(o.stroke_width); - } - match tool { - Tool::Rectangle => { - crate::widgets::vline(ui, 22.0); - lbl(ui, tl!("Radius:")); - let mut r = match target.as_ref().and_then(|s| s.live.as_ref()) { - Some(photocraft_doc::LiveShape::Rect { radii, .. }) => radii[0] as f32, - _ => o.corner_radius, - }; - if crate::widgets::value_field(ui, &mut r, 0.0..=10000.0, "px", 62.0).changed() { - o.corner_radius = r; - let rf = r as f64; - edit = Some(json!({"radii": [rf, rf, rf, rf], "coalesce": key("radius")})); - } - } - Tool::Polygon => { - crate::widgets::vline(ui, 22.0); - lbl(ui, tl!("Sides:")); - let mut s = o.polygon_sides as f32; - if crate::widgets::value_field(ui, &mut s, 3.0..=100.0, "", 48.0).changed() { - o.polygon_sides = s.round().clamp(3.0, 100.0) as u32; - } - } - Tool::Line => { - crate::widgets::vline(ui, 22.0); - lbl(ui, tl!("Weight:")); - crate::widgets::value_field(ui, &mut o.line_weight, 1.0..=1000.0, "px", 58.0); - } - Tool::CustomShape => { - crate::widgets::vline(ui, 22.0); - crate::preset_panels::shape_picker(app, ui); - } - _ if matches!(tool, Tool::PathSelection | Tool::DirectSelection) => { - if let Some(photocraft_doc::LiveShape::Rect { radii, .. }) = target.as_ref().and_then(|s| s.live.as_ref()) { - crate::widgets::vline(ui, 22.0); - lbl(ui, tl!("Radius:")); - let mut r = radii[0] as f32; - if crate::widgets::value_field(ui, &mut r, 0.0..=10000.0, "px", 62.0).changed() { - o.corner_radius = r; - let rf = r as f64; - edit = Some(json!({"radii": [rf, rf, rf, rf], "coalesce": key("radius")})); - } - } - } - _ => {} - } - for (is_stroke, change) in [(false, fill_color), (true, stroke_color)] { - let Some(change) = change else { continue }; - if let Err(e) = set_tool_paint(app, is_stroke, change) { - app.ui.status = e; - app.ui.status_error = true; - } - edit = Some(match (is_stroke, change) { - (false, PaintChange::None) => json!({"fill": null}), - (false, PaintChange::Color(color)) => json!({"fill": color, "coalesce": key("fill")}), - (true, PaintChange::None) => json!({"stroke": null}), - (true, PaintChange::Color(color)) => json!({"stroke": {"color": color, "width": enabled_stroke_width(width)}, "coalesce": key("stroke")}), - }); - } - if let (Some(mut p), Some(s)) = (edit, &target) { - p["layer"] = json!(s.layer.0); - if let Err(e) = app.run("shape.edit", p) { - app.ui.status = e; - app.ui.status_error = true; - } - } + crate::shape_options::options_bar(app, ui, tool); true } -/// The shape layer the options bar edits. -struct SelectedShape { - doc: photocraft_doc::DocId, - layer: photocraft_doc::LayerId, - fill: Option, - stroke: Option, - live: Option, -} - -fn selected_shape(session: &photocraft_engine::Session) -> Option { +/// Whether the active layer supplies the selected-shape options. +fn selected_shape(session: &photocraft_engine::Session) -> Option { let st = session.active()?; let layer = st.active_layer?; - match &st.doc.layer(layer)?.content { - LayerContent::Shape(sh) => Some(SelectedShape { doc: st.doc.id, layer, fill: sh.fill.clone(), stroke: sh.stroke.clone(), live: sh.live.clone() }), - _ => None, - } + matches!(st.doc.layer(layer)?.content, LayerContent::Shape(_)).then_some(layer) } // --------------------------------------------------------------------------------------------- @@ -1249,148 +1136,10 @@ fn solid_paint(c: [f32; 4]) -> photocraft_doc::Fill { photocraft_doc::Fill::Solid(photocraft_doc::Color::rgba(c[0], c[1], c[2], c[3])) } -fn color_of(f: &photocraft_doc::Fill) -> Option<[f32; 4]> { - match f { - photocraft_doc::Fill::Solid(c) => { - let [r, g, b] = c.to_rgb(); - Some([r, g, b, c.alpha]) - } - _ => None, - } -} - -#[derive(Clone, Copy, Debug, PartialEq)] -enum PaintChange { - Color([f32; 4]), - None, -} - -fn enabled_stroke_width(width: f32) -> f32 { +pub(crate) fn enabled_stroke_width(width: f32) -> f32 { if width.is_finite() && width > 0.0 { width } else { 3.0 } } -/// Tool-bar paint changes affect the next shape; Properties edits the selected shape instead. -fn set_tool_paint(app: &mut PhotocraftApp, stroke: bool, change: PaintChange) -> Result<(), String> { - if let PaintChange::Color(color) = change { - app.run("tools.setColors", if stroke { json!({"background": color}) } else { json!({"foreground": color}) })?; - } - if stroke { - app.ui.tool_options.stroke_width = if change == PaintChange::None { 0.0 } else { enabled_stroke_width(app.ui.tool_options.stroke_width) }; - } else { - app.ui.tool_options.shape_fill = change != PaintChange::None; - } - Ok(()) -} - -fn rgba32(c: [f32; 4]) -> Color32 { - let b = |v: f32| (v.clamp(0.0, 1.0) * 255.0).round() as u8; - Color32::from_rgba_unmultiplied(b(c[0]), b(c[1]), b(c[2]), b(c[3])) -} - -fn picker_color(c: [f32; 4]) -> egui::ecolor::Hsva { - let linear = egui::ecolor::linear_from_gamma; - let display = c.map(|v| if v.is_finite() { v.clamp(0.0, 1.0) } else { 0.0 }); - egui::ecolor::Hsva::from_rgba_unmultiplied(linear(display[0]), linear(display[1]), linear(display[2]), display[3]) -} - -fn picker_rgba(hsva: egui::ecolor::Hsva) -> [f32; 4] { - let [r, g, b, a] = hsva.to_rgba_unmultiplied(); - let gamma = egui::ecolor::gamma_from_linear; - [gamma(r), gamma(g), gamma(b), a] -} - -/// The shared compact picker keeps the float RGB paint and its alpha. Color32 is only display -/// data: opening the picker must never quantize an existing high-depth colour or enable paint. -fn swatch(ui: &mut egui::Ui, fill: Option<&photocraft_doc::Fill>, fallback: [f32; 4], tip: &str) -> Option { - let t = Tokens::get(ui.ctx()); - let (r, resp) = ui.allocate_exact_size(vec2(30.0, 22.0), Sense::click()); - resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::ColorButton, ui.is_enabled(), tip)); - let current = fill.and_then(color_of); - crate::widgets::checker(ui.painter(), r.shrink(1.0), 4.0); - match (current, fill) { - (Some(c), _) => { - ui.painter().rect_filled(r.shrink(1.0), t.radius_sm, rgba32(c)); - } - (None, Some(photocraft_doc::Fill::Gradient { stops, .. })) if !stops.is_empty() => { - // Gradient fills preview as a left-to-right ramp through their stops. - let rgb = |c: &photocraft_doc::Color| { - let v = c.to_rgba8(); - Color32::from_rgba_unmultiplied(v[0], v[1], v[2], v[3]) - }; - let mut mesh = egui::Mesh::default(); - let mut ramp: Vec<(f32, Color32)> = stops.iter().map(|(p, c)| (p.clamp(0.0, 1.0), rgb(c))).collect(); - ramp.insert(0, (0.0, ramp[0].1)); - ramp.push((1.0, ramp[ramp.len() - 1].1)); - for (i, (p, c)) in ramp.iter().enumerate() { - let x = r.left() + r.width() * p; - mesh.colored_vertex(egui::pos2(x, r.top()), *c); - mesh.colored_vertex(egui::pos2(x, r.bottom()), *c); - if i > 0 { - let k = (i as u32) * 2; - mesh.add_triangle(k - 2, k - 1, k); - mesh.add_triangle(k - 1, k, k + 1); - } - } - ui.painter().add(mesh); - } - (None, Some(_)) => {} - (None, None) => { - ui.painter().rect_filled(r.shrink(1.0), t.radius_sm, t.field); - ui.painter().line_segment([r.shrink(3.0).left_bottom(), r.shrink(3.0).right_top()], Stroke::new(1.5, t.danger)); - } - }; - let border = if resp.has_focus() { - t.accent - } else if resp.hovered() { - t.text_dim - } else { - t.field_border - }; - ui.painter().rect_stroke(r, t.radius_sm, Stroke::new(1.0, border), egui::StrokeKind::Inside); - let resp = resp.on_hover_text(tip); - let screen_id = resp.id.with("screen-color"); - let original = current.unwrap_or(fallback); - let sampled = |rgb: [f32; 3]| PaintChange::Color([rgb[0], rgb[1], rgb[2], original[3]]); - let mut out = crate::screen_picker::take(ui.ctx(), screen_id).map(sampled); - let cache = resp.id.with("shape-paint-hsva"); - let mut hsva = ui - .data(|d| d.get_temp::<([f32; 4], egui::ecolor::Hsva)>(cache)) - .filter(|(previous, _)| *previous == original) - .map_or_else(|| picker_color(original), |(_, hsva)| hsva); - if let Some(PaintChange::Color(color)) = out { - hsva = picker_color(color); - } - crate::widgets::swatch_popup(&resp).show(|ui| { - ui.horizontal(|ui| { - if ui.selectable_label(fill.is_none(), tl!("No Color")).clicked() && fill.is_some() { - out = Some(PaintChange::None); - } - if ui.selectable_label(current.is_some(), tl!("Solid")).clicked() && current.is_none() { - out = Some(PaintChange::Color(original)); - } - }); - ui.separator(); - let before = picker_rgba(hsva); - if egui::color_picker::color_picker_hsva_2d(ui, &mut hsva, egui::color_picker::Alpha::OnlyBlend) { - let color = picker_rgba(hsva); - // egui's HSV gamma/linear round trip can move a float by an ulp without input. - if color.iter().zip(before).any(|(a, b)| (a - b).abs() > 0.000001) { - out = Some(PaintChange::Color(color)); - } - } - if let Some(rgb) = crate::screen_picker::button(ui, screen_id) { - out = Some(sampled(rgb)); - hsva = picker_color([rgb[0], rgb[1], rgb[2], original[3]]); - } - }); - let cached_color = match out { - Some(PaintChange::Color(color)) => color, - _ => original, - }; - ui.data_mut(|d| d.insert_temp(cache, (cached_color, hsva))); - out -} - /// One corner of the live rectangle, preserving the other three radii. /// The engine takes the full [top-left, top-right, bottom-right, bottom-left] array. fn corner_radii_patch(radii: [f64; 4], corner: usize, radius: f32) -> Value { From d1a1569a6cda9e6984ad2a6ebab2d980c43df047 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 13 Oct 2026 18:20:06 +0000 Subject: [PATCH 051/649] bench(engine): bench_content_aware_scale times P28's command without the UI perf_scenarios needs the whole UI crate in release (about 25 min to build on 4 cores) to time edit.contentAwareScale. This example times the same command on the same synthetic 24 MP JPEG photo from the engine alone (about 6 min), undoing between runs. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LELc5BQzgV5dA7dxdMejkK --- .../examples/bench_content_aware_scale.rs | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 crates/engine/examples/bench_content_aware_scale.rs diff --git a/crates/engine/examples/bench_content_aware_scale.rs b/crates/engine/examples/bench_content_aware_scale.rs new file mode 100644 index 0000000000..dd137fefd5 --- /dev/null +++ b/crates/engine/examples/bench_content_aware_scale.rs @@ -0,0 +1,50 @@ +//! End-to-end timing of `edit.contentAwareScale` (perf scenario P28, #211) without the UI: a +//! synthetic 24 MP RGB photo opened from JPEG like `perf_scenarios`' (gradients, soft blobs, fine +//! noise and a high-contrast disc), scaled to 90 % width, undone between runs. +//! `cargo run --release -p photocraft-engine --example bench_content_aware_scale [reps] [width height]` +use std::time::Instant; + +use photocraft_engine::Session; +use serde_json::json; + +fn photo_jpeg(w: u32, h: u32) -> Result, String> { + let mut px = vec![0u8; w as usize * h as usize * 3]; + let (cx, cy, r) = (w as f32 * 0.55, h as f32 * 0.5, w.min(h) as f32 / 3.0); + for (y, row) in px.chunks_mut(w as usize * 3).enumerate() { + for x in 0..w as usize { + let (fx, fy) = (x as f32 / w as f32, y as f32 / h as f32); + let n = ((x.wrapping_mul(73_856_093) ^ y.wrapping_mul(19_349_663)) % 997) as f32 / 997.0 - 0.5; + let blob = (-(((fx - 0.4) * 3.0).powi(2) + ((fy - 0.55) * 4.0).powi(2))).exp(); + let inside = ((x as f32 - cx).powi(2) + (y as f32 - cy).powi(2)).sqrt() < r; + let (r0, g0, b0) = if inside { (0.85, 0.3 + 0.2 * (fx * 40.0).sin(), 0.15) } else { (0.35, 0.45, 0.55) }; + let rgb = [r0 + 0.1 * blob + n * 0.08, g0 + 0.1 * blob + n * 0.08, b0 + 0.2 * fy + n * 0.08]; + for (c, v) in rgb.into_iter().enumerate() { + row[x * 3 + c] = (v.clamp(0.0, 1.0) * 255.0 + 0.5) as u8; + } + } + } + let img = + photocraft_codecs::Image::from_raw(w, h, photocraft_codecs::ChannelLayout::Rgb, photocraft_codecs::SampleType::U8, px).map_err(|e| e.to_string())?; + photocraft_codecs::encode(&img, photocraft_codecs::Format::Jpeg, &Default::default()).map_err(|e| e.to_string()) +} + +fn main() -> Result<(), String> { + let args: Vec = std::env::args().collect(); + let num = |i: usize, d: u32| args.get(i).and_then(|v| v.parse::().ok()).unwrap_or(d); + let (reps, w, h) = (num(1, 3).clamp(1, 20) as usize, num(2, 6000).clamp(16, 20_000), num(3, 4000).clamp(16, 20_000)); + let jpeg = photo_jpeg(w, h)?; + let doc = photocraft_io::import("photo.jpg", &jpeg).map_err(|e| e.to_string())?.document; + let mut s = Session::new(); + s.open_document(doc, Some("photo.jpg".into())); + let mut times = Vec::with_capacity(reps); + for _ in 0..reps { + let t = Instant::now(); + s.execute("edit.contentAwareScale", json!({"scaleX": 90, "scaleY": 100})).map_err(|e| e.to_string())?; + times.push(t.elapsed().as_secs_f64() * 1000.0); + s.execute("edit.undo", json!({})).map_err(|e| e.to_string())?; + } + times.sort_by(f64::total_cmp); + let (p50, max) = (times[times.len() / 2], times[times.len() - 1]); + println!("edit.contentAwareScale {w}x{h} to 90 % width: p50 {p50:.1} ms, max {max:.1} ms ({reps} runs)"); + Ok(()) +} From 615f9d66589cae9dc1e28469aaf9b69623414eb2 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 13 Oct 2026 18:48:45 +0000 Subject: [PATCH 052/649] fix(algo): seam carving review follow-ups; infinite protection protects in the height pass From the second half of the adversarial review: - Correction to the previous commit: mapping energies that aren't numbers to +inf also changes output where the original computed NaN energies from NaN-free input (infinite samples at the border or next to each other, overflowing differences). The original's choice there went through NaN costs; keeping it would bring NaN back into the seam search, whose sign and payload aren't consistent across builds and wasm. So the contract is: bit-identical for every input whose energy stays a number (all finite images without overflow), deterministic everywhere else. infinite_samples_carve_deterministically pins it. - The height pass resampled the raw protection map, so an infinite value (or neighbours whose difference overflows) became NaN, which protects nothing: a row protected with +inf was carved away while 1.0 kept it. Where the plain resample gives NaN, the map clamped to 0..=1 is resampled instead (resample_protection); every other value is unchanged. infinite_protection_protects_in_both_passes failed before. - Values past w x h x ch are ignored through both passes. - Docs: row_costs is what recomputes pixels; the reduced-height search cuts the work 8-12 times at 24 MP, not about four; bench_seam's hash is FNV-style over 32-bit words. Carver::new reserves its index. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LELc5BQzgV5dA7dxdMejkK --- crates/algo/examples/bench_seam.rs | 4 +- crates/algo/src/seam.rs | 99 ++++++++++++++++++++++++------ 2 files changed, 83 insertions(+), 20 deletions(-) diff --git a/crates/algo/examples/bench_seam.rs b/crates/algo/examples/bench_seam.rs index e427a6b270..d25df5d8de 100644 --- a/crates/algo/examples/bench_seam.rs +++ b/crates/algo/examples/bench_seam.rs @@ -1,8 +1,8 @@ //! Timing of Content-Aware Scale's seam carving alone (no document plumbing), on a synthetic //! photo-like RGBA image: perf scenario P28's 24 MP width change (#211), the same image's height //! (the transposed pass) and two images short enough for the exact full-resolution seam search. -//! Prints an FNV-1a hash of each output's bits, so a speed-up can be checked to choose exactly the -//! same seams. +//! Prints an FNV-style hash of each output's bits (over 32-bit words), so a speed-up can be checked +//! to choose exactly the same seams. //! `cargo run --release -p photocraft-algo --example bench_seam [reps] [case filter]` use std::time::Instant; diff --git a/crates/algo/src/seam.rs b/crates/algo/src/seam.rs index 59e235bc05..b85fba5bab 100644 --- a/crates/algo/src/seam.rs +++ b/crates/algo/src/seam.rs @@ -9,9 +9,10 @@ //! //! A protect map (`0..=1`, e.g. an alpha channel or detected skin tones) adds a large energy so //! seams avoid protected pixels. Buffers are interleaved `w × h × ch` normalised floats of any -//! colour model and depth (alpha is carried like any other channel). Deterministic: a NaN sample -//! gives its pixels the highest energy and NaN protection protects nothing, so no NaN (whose -//! payload arithmetic does not keep consistently across builds) ever reaches the seam search. +//! colour model and depth (alpha is carried like any other channel). Deterministic on every +//! platform: an energy that isn't a number (from NaN samples, or infinite ones next to each other +//! or at the border) is the highest energy, and NaN protection protects nothing, so no NaN (whose +//! sign and payload arithmetic does not keep consistently across builds) reaches the seam search. use photocraft_raster::{Cancelled, Interrupt}; @@ -24,9 +25,10 @@ fn protection(p: f32) -> f32 { if p.is_nan() { 0.0 } else { p.clamp(0.0, 1.0) * PROTECT_ENERGY } } -/// Keep full horizontal detail while reducing the height used to find vertical seams. At a -/// 24 MP working size this cuts the dynamic-programming work by about four times without -/// quantising the output pixels or changing the requested output dimensions. +/// Keep full horizontal detail while reducing the height used to find vertical seams. On a +/// 6000×4000 image this cuts the dynamic-programming work eight times for a width change (4000 +/// rows to 500) and twelve times for a height change, without quantising the output pixels or +/// changing the requested output dimensions. const SEAM_SEARCH_MAX_HEIGHT: usize = 512; const PROXY_SHRINK_MIN_HEIGHT: usize = 2_048; const PROXY_SHRINK_MIN_SEAMS: usize = 64; @@ -56,7 +58,8 @@ pub fn energy(w: usize, h: usize, ch: usize, img: &[f32]) -> Vec { /// [`energy`] of pixel `x` of row `y` of a `cw`-wide, `h`-tall image whose pixel `xx` of row `yy` /// is column `col(xx, yy)` of `img` (`w` pixels per row). Shared by the full map and the carver's -/// per-seam updates, so both give bit-identical values. NaN samples give the highest energy. +/// per-seam updates, so both give bit-identical values. An energy that isn't a number is the +/// highest energy (`+inf`). #[allow(clippy::too_many_arguments)] #[inline] fn energy_at(img: &[f32], w: usize, cw: usize, h: usize, ch: usize, x: usize, y: usize, col: impl Fn(usize, usize) -> usize) -> f32 { @@ -122,9 +125,9 @@ struct Dp { /// its path cost and where that path came from (0 = up-left, 1 = up, 2 = up-right). Ties go to /// the pixel straight up, then up-left, then up-right. The cost doesn't depend on the tie-break /// and the direction doesn't depend on `e`, so the seam can be traced back from the costs alone. -/// The full pass's edges, [`Dp::update`] and [`Dp::seam`] use it, and the full pass's interior -/// repeats it exactly, so every way of filling the map gives the same bits (costs are never NaN: -/// see [`energy_at`] and [`protection`]). +/// [`row_costs`] uses it at the ends of a row and repeats its selection in between, and +/// [`Dp::seam`] traces seams with it, so every way of filling the map gives the same bits (costs +/// are never NaN: see [`energy_at`] and [`protection`]). #[inline] fn cell(up: &[f32], cw: usize, x: usize, e: f32) -> (f32, u8) { let (b, d) = if x == 0 { @@ -193,8 +196,8 @@ impl Dp { /// `seam[y-1..=y+1]` to the rightmost, which covers those pixels too. Every other pixel needs /// recomputing only if a parent's cost changed, so the work follows the changed costs down /// the map and narrows wherever they settle, instead of covering the whole map. Recomputed - /// pixels go through [`cell`], so the map matches a [`Dp::full`] pass over the same energy - /// bit for bit. + /// pixels go through [`row_costs`], like a [`Dp::full`] pass's, so the map matches one over + /// the same energy bit for bit. fn update(&mut self, rows: Rows, energy: &[f32], seam: &[usize]) { let (cw, h) = (rows.cw, rows.h()); if cw == 0 || h == 0 || seam.len() < h { @@ -293,7 +296,10 @@ impl<'a> Carver<'a> { *e += protection(p); } } - let idx = (0..h).flat_map(|_| (0..w).map(|x| u32::try_from(x).unwrap_or(u32::MAX))).collect(); + let mut idx = Vec::with_capacity(w * h); + for _ in 0..h { + idx.extend((0..w).map(|x| u32::try_from(x).unwrap_or(u32::MAX))); + } let off = vec![0; h]; let mut dp = Dp::default(); dp.full(Rows { stride: w, cw: w, off: &off }, &e); @@ -483,7 +489,12 @@ pub fn carve_width(w: usize, h: usize, ch: usize, img: &[f32], protect: Option<& pub fn carve_width_with(w: usize, h: usize, ch: usize, img: &[f32], protect: Option<&[f32]>, new_w: usize, ctl: &Interrupt) -> Result, Cancelled> { let new_w = new_w.max(1); // Nothing to carve: no pixels or channels, or fewer values than the size says. - if new_w == w || unusable(w, h, ch, img) { + if unusable(w, h, ch, img) { + return Ok(img.to_vec()); + } + // Values past the size are not part of the image. + let img = img.get(..w * h * ch).unwrap_or(img); + if new_w == w { return Ok(img.to_vec()); } // A protection map that doesn't cover the image protects nothing. @@ -648,6 +659,7 @@ pub fn carve_with( if unusable(w, h, ch, img) { return Ok(img.to_vec()); } + let img = img.get(..w * h * ch).unwrap_or(img); let protect = protect.filter(|p| p.len() >= w * h); // Split progress between the passes by their seam counts. let (sw, sh) = (new_w.abs_diff(w) as f32, new_h.abs_diff(h) as f32); @@ -658,14 +670,30 @@ pub fn carve_with( if new_h == h { return Ok(wide); } - // Protection follows the width change by plain resampling (it only steers seams). - let prot_t = protect.map(|p| transpose(new_w, h, 1, &resize_bilinear(w, h, 1, p, new_w, h))); + let prot_t = protect.map(|p| transpose(new_w, h, 1, &resample_protection(w, h, p, new_w))); let t = transpose(new_w, h, ch, &wide); let second = |f: f32| ctl.progress(split + f * (1.0 - split)); let tall = carve_width_with(h, new_w, ch, &t, prot_t.as_deref(), new_h, &Interrupt::new(&cancel, &second))?; Ok(transpose(new_h, new_w, ch, &tall)) } +/// The protection map `p` (`w × h`) for the height pass, after the width changed to `new_w`: +/// plainly resampled (it only steers seams). Where values out of `0..=1` resample to NaN +/// (infinities, or neighbours whose difference overflows), the map clamped to `0..=1` (NaN to 0) +/// resampled instead, so an infinite protection still protects. +fn resample_protection(w: usize, h: usize, p: &[f32], new_w: usize) -> Vec { + let mut out = resize_bilinear(w, h, 1, p, new_w, h); + if out.iter().any(|v| v.is_nan()) { + let clamped: Vec = p.iter().map(|&v| if v.is_nan() { 0.0 } else { v.clamp(0.0, 1.0) }).collect(); + for (v, c) in out.iter_mut().zip(resize_bilinear(w, h, 1, &clamped, new_w, h)) { + if v.is_nan() { + *v = c; + } + } + } + out +} + /// Plain bilinear resize (the non-content-aware part of the Amount blend). pub fn resize_bilinear(w: usize, h: usize, ch: usize, img: &[f32], nw: usize, nh: usize) -> Vec { let Some(len) = nw.checked_mul(nh).and_then(|n| n.checked_mul(ch)) else { @@ -726,7 +754,7 @@ mod tests { /// The straightforward implementation the per-seam carver replaced (full energy map, fresh /// seam search and a new buffer per seam), kept as the oracle for `carver_matches_reference`. mod reference { - use super::super::{protection, resize_bilinear, transpose}; + use super::super::{protection, resample_protection, transpose}; pub(super) fn energy(w: usize, h: usize, ch: usize, img: &[f32]) -> Vec { let mut e = vec![0.0f32; w * h]; @@ -879,7 +907,7 @@ mod tests { if new_h == h { return wide; } - let prot_t = protect.map(|p| transpose(new_w, h, 1, &resize_bilinear(w, h, 1, p, new_w, h))); + let prot_t = protect.map(|p| transpose(new_w, h, 1, &resample_protection(w, h, p, new_w))); let t = transpose(new_w, h, ch, &wide); let tall = carve_width(h, new_w, ch, &t, prot_t.as_deref(), new_h); transpose(new_h, new_w, ch, &tall) @@ -1002,6 +1030,41 @@ mod tests { assert_eq!(carve(10, 5, 1, &img, Some(&[0.0; 3]), 4, 3), carve(10, 5, 1, &img, None, 4, 3)); assert_eq!(carve(10, 5, 3, &[0.5; 20], None, 4, 5), vec![0.5; 20]); assert_eq!(carve_width(usize::MAX, 2, 4, &[0.5; 8], None, 1), vec![0.5; 8]); + // Values past the size are ignored, through both passes. + let long = noise(20, 7, 4); + assert_eq!(carve(5, 3, 1, &long, None, 3, 3), carve(5, 3, 1, &long[..15], None, 3, 3)); + assert_eq!(carve(5, 3, 1, &long, None, 5, 2), carve(5, 3, 1, &long[..15], None, 5, 2)); + } + + /// Infinite samples, and finite ones whose differences overflow, give energies that aren't + /// numbers; those are the highest energy (pinned deliberately: the code before NaN-free costs + /// fed NaN to the seam search and chose differently). + #[test] + fn infinite_samples_carve_deterministically() { + let inf = f32::INFINITY; + assert_eq!(carve(2, 1, 1, &[inf, 0.5], None, 1, 1), [0.5]); + assert_eq!(carve(2, 1, 1, &[f32::MAX, f32::MAX], None, 6, 1), [f32::MAX, inf, inf, inf, inf, f32::MAX]); + let mut img = noise(30 * 20 * 3, 255, 41); + img.iter_mut().step_by(11).for_each(|v| *v = inf); + img.iter_mut().skip(4).step_by(23).for_each(|v| *v = -inf); + let out = carve(30, 20, 3, &img, None, 21, 14); + assert_eq!(out.len(), 21 * 14 * 3); + assert_eq!(out, carve(30, 20, 3, &img, None, 21, 14)); + } + + /// Infinite protection protects like full protection in the height pass too, where the map + /// is resampled (and an infinity alone would resample to NaN). + #[test] + fn infinite_protection_protects_in_both_passes() { + let (w, h) = (6, 6); + let img: Vec = (0..w * h).map(|i| (i * 7 % 5) as f32 / 4.0).collect(); + let row = |v: f32| (0..w * h).map(|i| if i / w == 2 { v } else { 0.0 }).collect::>(); + let (full, inf) = (row(1.0), row(f32::INFINITY)); + for (nw, nh) in [(6, 3), (4, 3), (3, 6)] { + assert_eq!(carve(w, h, 1, &img, Some(&inf), nw, nh), carve(w, h, 1, &img, Some(&full), nw, nh), "{nw}x{nh}"); + } + let kept = carve(w, h, 1, &img, Some(&inf), 6, 3); + assert!(kept.chunks(6).any(|r| r == &img[12..18]), "the protected row survives"); } /// A cancel that arrives after the seam search, during the tall-image rebuild, still stops From b464a334ca36806110940f832a9916015efa45a2 Mon Sep 17 00:00:00 2001 From: abc2cb <271337822+abc2cb@users.noreply.github.com> Date: Tue, 13 Oct 2026 21:52:02 +0300 Subject: [PATCH 053/649] PSD: Distort smart filters and Invert open and save like Photoshop Smart filters PhotoCraft applied with Pinch, Polar Coordinates, Ripple, Spherize, Twirl, Wave, ZigZag or Invert were dropped when saving a PSD ("this filter has no PSD equivalent"), and the same filters in a Photoshop file opened as kept-verbatim entries that didn't render. They are now mapped both ways in `smart_map.rs`, with the keys, enum codes and key order Photoshop 27 writes (checked against a Photoshop-saved file holding one smart object per filter): - Pinch `Pnch` Amnt; Twirl `Twrl` Angl; Ripple `Rple` Amnt + RplS (Sml/Mdm/Lrg); Spherize `Sphr` Amnt + SphM (Nrml/HrzO/VrtO); Polar Coordinates `Plr ` Cnvr (RctP/PlrR); ZigZag `ZgZg` Amnt, NmbR, ZZTy (PndR/OtFr/ArnC); - Wave `Wave` Wvtp, NmbG, WLMn/WLMx, AmMn/AmMx, SclH/SclV, UndA, RndS. PhotoCraft's Wave has no Scale, so a Photoshop wave scaled off 100% stays verbatim rather than lose it; - Invert `Invr`: no `Fltr`, `hasoptions` true, like Photoshop. Shear stays unmapped for now: Photoshop stores its curve on its own grid. Tests: the Photoshop `Fltr` bytes read back as the PhotoCraft settings and are rewritten with the same keys, values and order; a scaled Wave round-trips unchanged; Invert's item; the new filters join modelled_filters_round_trip. The verbatim-filter tests now use Crystallize and Shear. Co-Authored-By: Claude Opus 5.5 --- crates/io/src/smart_map.rs | 209 +++++++++++++++++++++++++++++++++++-- docs/file-format-parity.md | 5 +- 2 files changed, 204 insertions(+), 10 deletions(-) diff --git a/crates/io/src/smart_map.rs b/crates/io/src/smart_map.rs index ab9349fbde..cb100ca559 100644 --- a/crates/io/src/smart_map.rs +++ b/crates/io/src/smart_map.rs @@ -144,7 +144,7 @@ const fn code(c: &[u8; 4]) -> i32 { i32::from_be_bytes(*c) } -const KNOWN: [Known; 14] = [ +const KNOWN: [Known; 22] = [ Known { class: "GsnB", filter_id: code(b"GsnB"), name: "Gaussian Blur...", command: "filter.blur.gaussianBlur" }, Known { class: "boxblur", filter_id: 840, name: "Box Blur...", command: "filter.blur.boxBlur" }, Known { class: "MtnB", filter_id: code(b"MtnB"), name: "Motion Blur...", command: "filter.blur.motionBlur" }, @@ -160,8 +160,40 @@ const KNOWN: [Known; 14] = [ Known { class: "Crvs", filter_id: code(b"Crvs"), name: "Curves...", command: "image.adjustments.curves" }, // Shadows/Highlights at its defaults stores no `Fltr` (`hasoptions` false). Known { class: "adaptCorrect", filter_id: 781, name: "Shado&ws/Highlights...", command: "image.adjustments.shadowsHighlights" }, + // Distort (Photoshop 27, `corpus`-style check: one smart object per filter saved from Photoshop + // and read back). Shear isn't mapped yet: its curve lives on Photoshop's own grid. + Known { class: "Pnch", filter_id: code(b"Pnch"), name: "Pinch...", command: "filter.distort.pinch" }, + Known { class: "Plr ", filter_id: code(b"Plr "), name: "Polar Coordinates...", command: "filter.distort.polarCoordinates" }, + Known { class: "Rple", filter_id: code(b"Rple"), name: "Ripple...", command: "filter.distort.ripple" }, + Known { class: "Sphr", filter_id: code(b"Sphr"), name: "Spherize...", command: "filter.distort.spherize" }, + Known { class: "Twrl", filter_id: code(b"Twrl"), name: "Twirl...", command: "filter.distort.twirl" }, + Known { class: "Wave", filter_id: code(b"Wave"), name: "Wave...", command: "filter.distort.wave" }, + Known { class: "ZgZg", filter_id: code(b"ZgZg"), name: "ZigZag...", command: "filter.distort.zigZag" }, + // Image › Adjustments › Invert on a smart object: no settings, so no `Fltr` (yet `hasoptions`). + Known { class: "Invr", filter_id: code(b"Invr"), name: "Invert", command: "image.adjustments.invert" }, ]; +/// Photoshop enum codes ↔ PhotoCraft parameter values, per filter setting. +const RIPPLE_SIZE: [(&[u8; 4], &str); 3] = [(b"Sml ", "small"), (b"Mdm ", "medium"), (b"Lrg ", "large")]; +const SPHERIZE_MODE: [(&[u8; 4], &str); 3] = [(b"Nrml", "normal"), (b"HrzO", "horizontalOnly"), (b"VrtO", "verticalOnly")]; +const POLAR_MODE: [(&[u8; 4], &str); 2] = [(b"RctP", "rectangularToPolar"), (b"PlrR", "polarToRectangular")]; +const ZIGZAG_STYLE: [(&[u8; 4], &str); 3] = [(b"PndR", "pondRipples"), (b"OtFr", "outFromCenter"), (b"ArnC", "aroundCenter")]; +const WAVE_TYPE: [(&[u8; 4], &str); 3] = [(b"WvSn", "sine"), (b"WvTr", "triangle"), (b"WvSq", "square")]; +const UNDEFINED_AREAS: [(&[u8; 4], &str); 2] = [(b"WrpA", "wrap"), (b"RptE", "repeat")]; + +/// The PhotoCraft value of the enum `key` in `f` (`None`: absent or a code we don't know). +fn enum_param(f: &Descriptor, key: &str, table: &[(&[u8; 4], &'static str)]) -> Option<&'static str> { + let code = enum_of(f, key)?; + table.iter().find(|(c, _)| c.as_slice() == code).map(|(_, v)| *v) +} + +/// The enum value Photoshop stores for PhotoCraft's `p[key]` (its `default` when unset). +fn enum_value(p: &J, key: &str, default: &str, type_id: &str, table: &[(&[u8; 4], &str)]) -> Result { + let v = p.get(key).and_then(J::as_str).unwrap_or(default); + let (code, _) = table.iter().find(|(_, name)| *name == v).ok_or_else(|| format!("{key} `{v}` has no PSD equivalent"))?; + Ok(Value::Enumerated { type_id: Id::new(type_id), value: Id::Code(**code) }) +} + fn known_by_command(command: &str) -> Option<&'static Known> { KNOWN.iter().find(|k| k.command == command) } @@ -263,8 +295,31 @@ fn curves_params(f: &Descriptor) -> Option { fn known_params(class: &str, f: Option<&Descriptor>) -> Option<(&'static str, J)> { let k = KNOWN.iter().find(|k| k.class == class)?; let params = match (class, f) { - ("adaptCorrect", None) => json!({}), + ("adaptCorrect" | "Invr", None) => json!({}), (_, None) => return None, + ("Pnch", Some(f)) => json!({"amount": int(f, "Amnt")?}), + ("Twrl", Some(f)) => json!({"angle": int(f, "Angl")?}), + ("Rple", Some(f)) => json!({"amount": int(f, "Amnt")?, "size": enum_param(f, "RplS", &RIPPLE_SIZE)?}), + ("Sphr", Some(f)) => json!({"amount": int(f, "Amnt")?, "mode": enum_param(f, "SphM", &SPHERIZE_MODE)?}), + ("Plr ", Some(f)) => json!({"mode": enum_param(f, "Cnvr", &POLAR_MODE)?}), + ("ZgZg", Some(f)) => json!({"amount": int(f, "Amnt")?, "ridges": int(f, "NmbR")?, "style": enum_param(f, "ZZTy", &ZIGZAG_STYLE)?}), + ("Wave", Some(f)) => { + // PhotoCraft's Wave has no Scale: a scaled wave stays verbatim rather than lose it. + if int(f, "SclH")? != 100 || int(f, "SclV")? != 100 { + return None; + } + json!({ + "type": enum_param(f, "Wvtp", &WAVE_TYPE)?, + "generators": int(f, "NmbG")?, + "wavelengthMin": int(f, "WLMn")?, + "wavelengthMax": int(f, "WLMx")?, + "amplitudeMin": int(f, "AmMn")?, + "amplitudeMax": int(f, "AmMx")?, + "undefinedAreas": enum_param(f, "UndA", &UNDEFINED_AREAS)?, + // `RndS` is a signed long; the seed is its bit pattern. + "seed": (int(f, "RndS")? as u32), + }) + } ("GsnB" | "boxblur" | "Mdn " | "HghP" | "Mxm " | "Mnm ", Some(f)) => json!({"radius": px(f, "Rds ")?}), ("MtnB", Some(f)) => json!({"angle": int(f, "Angl")?, "distance": px(f, "Dstn")?}), ("UnsM", Some(f)) => json!({"amount": px(f, "Amnt")?, "radius": px(f, "Rds ")?, "threshold": int(f, "Thsh")?}), @@ -455,6 +510,30 @@ fn fltr_for(k: &Known, p: &J) -> Result, String> { } return Ok(None); } + // Keys and order as Photoshop writes them. + "Pnch" => d.with("Amnt", pi(p, "amount", 50.0)), + "Twrl" => d.with("Angl", pi(p, "angle", 50.0)), + "Rple" => d.with("Amnt", pi(p, "amount", 100.0)).with("RplS", enum_value(p, "size", "medium", "RplS", &RIPPLE_SIZE)?), + "Sphr" => d.with("Amnt", pi(p, "amount", 100.0)).with("SphM", enum_value(p, "mode", "normal", "SphM", &SPHERIZE_MODE)?), + "Plr " => d.with("Cnvr", enum_value(p, "mode", "rectangularToPolar", "Cnvr", &POLAR_MODE)?), + "ZgZg" => d + .with("Amnt", pi(p, "amount", 10.0)) + .with("NmbR", pi(p, "ridges", 5.0)) + .with("ZZTy", enum_value(p, "style", "pondRipples", "ZZTy", &ZIGZAG_STYLE)?), + "Wave" => { + let seed = p.get("seed").and_then(J::as_u64).and_then(|s| u32::try_from(s).ok()).unwrap_or(0); + d.with("Wvtp", enum_value(p, "type", "sine", "Wvtp", &WAVE_TYPE)?) + .with("NmbG", pi(p, "generators", 5.0)) + .with("WLMn", pi(p, "wavelengthMin", 10.0)) + .with("WLMx", pi(p, "wavelengthMax", 120.0)) + .with("AmMn", pi(p, "amplitudeMin", 5.0)) + .with("AmMx", pi(p, "amplitudeMax", 35.0)) + .with("SclH", Value::Integer(100)) + .with("SclV", Value::Integer(100)) + .with("UndA", enum_value(p, "undefinedAreas", "wrap", "UndA", &UNDEFINED_AREAS)?) + .with("RndS", Value::Integer(seed as i32)) + } + "Invr" => return Ok(None), _ => return Err("not a recognized filter".into()), })) } @@ -486,7 +565,8 @@ pub fn item_for_filter(f: &SmartFilter) -> Result { .with("Nm ", Value::Text(UnicodeString::new_nul(k.name))) .with("blendOptions", blend_options(f)) .with("enab", Value::Boolean(f.visible)) - .with("hasoptions", Value::Boolean(fltr.is_some())) + // Photoshop marks Invert as having options although it stores none. + .with("hasoptions", Value::Boolean(fltr.is_some() || k.class == "Invr")) .with("FrgC", rgbc(0.0)) .with("BckC", rgbc(255.0)); if let Some(x) = fltr { @@ -878,6 +958,18 @@ mod tests { sf("image.adjustments.shadowsHighlights", json!({})), // A pencil-drawn curve: 256 output levels (`Mpng`). sf("image.adjustments.curves", json!({"pencil": true, "points": (0..256).rev().collect::>()})), + sf("filter.distort.pinch", json!({"amount": -28})), + sf("filter.distort.polarCoordinates", json!({"mode": "rectangularToPolar"})), + sf("filter.distort.ripple", json!({"amount": 250, "size": "small"})), + sf("filter.distort.spherize", json!({"amount": 60, "mode": "verticalOnly"})), + sf("filter.distort.twirl", json!({"angle": -355})), + sf( + "filter.distort.wave", + json!({"type": "square", "generators": 3, "wavelengthMin": 20, "wavelengthMax": 90, "amplitudeMin": 4, "amplitudeMax": 30, + "undefinedAreas": "repeat", "seed": 4_000_000_000u32}), + ), + sf("filter.distort.zigZag", json!({"amount": 30, "ridges": 7, "style": "aroundCenter"})), + sf("image.adjustments.invert", json!({})), ]; for mut f in filters { f.blend = BlendMode::Overlay; @@ -890,17 +982,117 @@ mod tests { } } + /// The `Fltr` descriptors Photoshop 27 wrote for these filters (one smart object each, saved as + /// PSD and read back), with the settings PhotoCraft reads from them. + const PHOTOSHOP_FLTR: [(&str, &str, &str); 6] = [ + ("filter.distort.pinch", r#"{"amount":-28}"#, "0000000600500069006e00630068000000000000506e63680000000100000000416d6e746c6f6e67ffffffe4"), + ("filter.distort.twirl", r#"{"angle":-355}"#, "000000060054007700690072006c0000000000005477726c0000000100000000416e676c6c6f6e67fffffe9d"), + ( + "filter.distort.ripple", + r#"{"amount":-273,"size":"large"}"#, + "000000070052006900700070006c006500000000000052706c650000000200000000416d6e746c6f6e67fffffeef0000000052706c53656e756d0000000052706c53000000004c726720", + ), + ( + "filter.distort.spherize", + r#"{"amount":-1,"mode":"horizontalOnly"}"#, + "00000009005300700068006500720069007a0065000000000000537068720000000200000000416d6e746c6f6e67ffffffff000000005370684d656e756d000000005370684d0000000048727a4f", + ), + ( + "filter.distort.polarCoordinates", + r#"{"mode":"polarToRectangular"}"#, + "000000120050006f006c0061007200200043006f006f007200640069006e0061007400650073000000000000506c72200000000100000000436e7672656e756d00000000436e767200000000506c7252", + ), + ( + "filter.distort.zigZag", + r#"{"amount":-42,"ridges":11,"style":"pondRipples"}"#, + "00000007005a00690067005a006100670000000000005a675a670000000300000000416d6e746c6f6e67ffffffd6000000004e6d62526c6f6e670000000b000000005a5a5479656e756d000000005a5a547900000000506e6452", + ), + ]; + + /// Photoshop's Wave with Scale 100% / 28%: PhotoCraft's Wave has no Scale. + const PHOTOSHOP_WAVE: &str = "000000050057006100760065000000000000576176650000000a0000000057767470656e756d00000000577674700000000057765472000000004e6d62476c6f6e670000014c00000000574c4d6e6c6f6e67000000d500000000574c4d786c6f6e67000000d600000000416d4d6e6c6f6e67000000f000000000416d4d786c6f6e67000000f10000000053636c486c6f6e67000000640000000053636c566c6f6e670000001c00000000556e6441656e756d00000000556e6441000000005772704100000000526e64536c6f6e670013624a"; + + fn photoshop_item(fltr: Descriptor) -> Descriptor { + let id = code(fltr.class_id.as_bytes().try_into().unwrap()); + Descriptor::new("filterFX") + .with("Nm ", Value::Text(UnicodeString::new_nul("from Photoshop"))) + .with("blendOptions", Value::Descriptor(Descriptor::new("blendOptions").with("Opct", unit(b"#Prc", 100.0)).with("Md ", enumv("BlnM", "normal")))) + .with("enab", Value::Boolean(true)) + .with("hasoptions", Value::Boolean(true)) + .with("Fltr", Value::Descriptor(fltr)) + .with("filterID", Value::Integer(id)) + } + + /// Distort smart filters from a Photoshop file open as their PhotoCraft filters, and the ones + /// PhotoCraft writes carry the same settings, keys and order as Photoshop's. + #[test] + fn photoshop_distort_filters_read_and_write_like_photoshop() { + for (command, params, hex) in PHOTOSHOP_FLTR { + let ps = Descriptor::from_bytes(&from_hex(hex).unwrap()).unwrap(); + let f = filter_from_item(&photoshop_item(ps.clone())); + let want: J = serde_json::from_str(params).unwrap(); + assert_eq!((f.command.as_str(), &f.params), (command, &want), "{command}"); + let ours = match item_for_filter(&f).unwrap().get("Fltr") { + Some(Value::Descriptor(d)) => d.clone(), + other => panic!("{command}: no Fltr ({other:?})"), + }; + assert_eq!((&ours.class_id, &ours.items), (&ps.class_id, &ps.items), "{command}: same keys, values and order"); + } + // A scaled wave can't be modelled, so it stays Photoshop's, unchanged. + let wave = Descriptor::from_bytes(&from_hex(PHOTOSHOP_WAVE).unwrap()).unwrap(); + let item = photoshop_item(wave); + let f = filter_from_item(&item); + assert_eq!(f.command, UNSUPPORTED_FILTER); + assert_eq!(item_for_filter(&f).unwrap().get("Fltr"), item.get("Fltr")); + // Unscaled, it opens as PhotoCraft's Wave (Triangle, the other settings as stored). + let mut unscaled = match item.get("Fltr") { + Some(Value::Descriptor(d)) => d.clone(), + _ => unreachable!(), + }; + set(&mut unscaled, "SclV", Value::Integer(100)); + let f = filter_from_item(&photoshop_item(unscaled.clone())); + assert_eq!( + (f.command.as_str(), &f.params), + ( + "filter.distort.wave", + &json!({"type": "triangle", "generators": 332, "wavelengthMin": 213, "wavelengthMax": 214, "amplitudeMin": 240, "amplitudeMax": 241, + "undefinedAreas": "wrap", "seed": 1270346}) + ) + ); + assert_eq!(item_for_filter(&f).unwrap().get("Fltr"), Some(&Value::Descriptor(unscaled))); + } + + /// Invert on a smart object: Photoshop stores no `Fltr`, but `hasoptions` and its filter id. + #[test] + fn invert_smart_filter_reads_and_writes_like_photoshop() { + let item = Descriptor::new("filterFX") + .with("Nm ", Value::Text(UnicodeString::new_nul("Invert"))) + .with("blendOptions", Value::Descriptor(Descriptor::new("blendOptions").with("Opct", unit(b"#Prc", 100.0)).with("Md ", enumv("BlnM", "normal")))) + .with("enab", Value::Boolean(true)) + .with("hasoptions", Value::Boolean(true)) + .with("FrgC", rgbc(255.0)) + .with("BckC", rgbc(0.0)) + .with("filterID", Value::Integer(code(b"Invr"))); + let f = filter_from_item(&item); + assert_eq!((f.command.as_str(), &f.params), ("image.adjustments.invert", &json!({}))); + let back = item_for_filter(&f).unwrap(); + assert_eq!(back.get("Fltr"), None); + assert_eq!(back.get("hasoptions"), Some(&Value::Boolean(true))); + assert_eq!(back.get("filterID"), Some(&Value::Integer(code(b"Invr")))); + assert_eq!(back.get("Nm "), Some(&Value::Text(UnicodeString::new_nul("Invert")))); + } + #[test] fn unknown_filters_keep_their_descriptor() { let item = Descriptor::new("filterFX") - .with("Nm ", Value::Text(UnicodeString::new_nul("Twirl..."))) + .with("Nm ", Value::Text(UnicodeString::new_nul("Crystallize..."))) .with("blendOptions", Value::Descriptor(Descriptor::new("blendOptions").with("Opct", unit(b"#Prc", 100.0)).with("Md ", enumv("BlnM", "normal")))) .with("enab", Value::Boolean(true)) - .with("Fltr", Value::Descriptor(Descriptor::new("Twrl").with("Angl", Value::Integer(50)))) - .with("filterID", Value::Integer(code(b"Twrl"))); + .with("Fltr", Value::Descriptor(Descriptor::new("Crst").with("ClSz", Value::Integer(10)))) + .with("filterID", Value::Integer(code(b"Crst"))); let f = filter_from_item(&item); assert_eq!(f.command, UNSUPPORTED_FILTER); - assert_eq!(f.params["name"], "Twirl..."); + assert_eq!(f.params["name"], "Crystallize..."); assert_eq!(item_for_filter(&f).unwrap(), item); // Hidden and re-blended: only those keys change. let mut g = f.clone(); @@ -917,7 +1109,8 @@ mod tests { fn unwritable_filters_are_reported_not_fatal() { let stack = FilterStack { filters: vec![ - sf("filter.distort.twirl", json!({"angle": 50})), + // Shear's curve isn't mapped to Photoshop's grid yet. + sf("filter.distort.shear", json!({"amount": 40})), sf("filter.blur.gaussianBlur", json!({"radius": 2.0})), sf(UNSUPPORTED_FILTER, json!({"psd": "zz"})), sf("image.adjustments.levels", json!({"cyan": {"gamma": 2.0}})), diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index cb2ca13acd..18a898b59d 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File-format parity -> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-13 · **Change:** minor (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-13 · **Change:** minor (PSD smart filters: Pinch, Polar Coordinates, Ripple, Spherize, Twirl, Wave and ZigZag, and Invert, read and written like Photoshop; 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 @@ -21,7 +21,7 @@ XL are missing (gap G10). Remaining: 300–500 h including PSD fidelity. | Format | Photoshop | PhotoCraft read | PhotoCraft write | Fidelity and tests | |---|---|---|---|---| -| PSD | R/W | yes | yes | 1/8/16/32-bit; Bitmap, Gray, Indexed, RGB, CMYK, Multichannel, Lab, Duotone; layers, groups, masks, vector masks, adjustment and fill layers, effects, text, shapes, smart objects (SoLd/lnk2; CS2 PlLd/lnkD read with their warp, kept as is or re-saved as SoLd once edited), smart filters (14 mapped, rest verbatim), slices, comps, Advanced Blending. Oracle floors: Photoshop-authored 145/258, io 146/170, psd-tools 236/309; round trip ≥ 169/170, 308/309, 258/256. Known failures: #1281, #2469 (#2374, text layers, closed 2026-10-10; #2465, CS2 `PlLd`-only smart objects, fixed 2026-10-12) | +| PSD | R/W | yes | yes | 1/8/16/32-bit; Bitmap, Gray, Indexed, RGB, CMYK, Multichannel, Lab, Duotone; layers, groups, masks, vector masks, adjustment and fill layers, effects, text, shapes, smart objects (SoLd/lnk2; CS2 PlLd/lnkD read with their warp, kept as is or re-saved as SoLd once edited), smart filters (22 mapped: blurs, Unsharp Mask, noise, Other, Mosaic, Emboss, Levels, Curves, Shadows/Highlights, Invert and the Distort filters but Shear; rest verbatim), slices, comps, Advanced Blending. Oracle floors: Photoshop-authored 145/258, io 146/170, psd-tools 236/309; round trip ≥ 169/170, 308/309, 258/256. Known failures: #1281, #2469 (#2374, text layers, closed 2026-10-10; #2465, CS2 `PlLd`-only smart objects, fixed 2026-10-12) | | PSB | R/W | yes | yes | Auto-switches above 2 GB (REL-212-2); 4–5 GB fixtures generated (FILE-216-2); > 4 GB fails on Windows (#375) | | Cloud PSD (.psdc) | R/W | no | no | Out of scope (Adobe cloud) | | TIFF | R/W | yes | yes | 8/16/32f, Gray/RGB/CMYK, BigTIFF, every IFD, banded parallel decode; layered TIFF both byte orders (FILE-215-7: extra alpha channels not written) | @@ -142,6 +142,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings. | Date | Change | Summary | |---|---|---| +| 2026-10-13 | minor | PSD smart filters: Pinch, Polar Coordinates, Ripple, Spherize, Twirl, Wave, ZigZag and Invert open as editable filters and are saved instead of dropped (checked against a Photoshop 27 file); a scaled Wave and Shear stay verbatim | | 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) | From e4dd35ce23550bd62b7103bea7e6d65c5d1b1bb1 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 13 Oct 2026 19:00:14 +0000 Subject: [PATCH 054/649] docs: Content-Aware Scale (P28) measured within its budget docs/content-aware-scale-performance.md records what changed, the exactness contract (bit-identical wherever the energy stays a number; NaN and infinities now deterministic), and interleaved before/after timings on a 4-core VM: the carve of P28's 24 MP photo 2013 -> 556 ms, the P28 row 3281 -> 1639 ms against its 3 s budget, smaller images 1.65-2.3x faster, peak memory unchanged or lower. gaps.md G2 and target-app-parity.md get the dated measurement; budgets.toml's P28 comment says the target is met. Its enforce flag and the committed baseline stay as they are until the reference machine reruns cargo xtask perf --update-baseline. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LELc5BQzgV5dA7dxdMejkK --- docs/content-aware-scale-performance.md | 138 ++++++++++++++++++++++++ docs/gaps.md | 14 ++- docs/target-app-parity.md | 12 ++- perf/budgets.toml | 2 +- 4 files changed, 162 insertions(+), 4 deletions(-) create mode 100644 docs/content-aware-scale-performance.md diff --git a/docs/content-aware-scale-performance.md b/docs/content-aware-scale-performance.md new file mode 100644 index 0000000000..5d15702a51 --- /dev/null +++ b/docs/content-aware-scale-performance.md @@ -0,0 +1,138 @@ +# Content-Aware Scale seam carving (2026-10-13) + +Perf scenario P28 ([#211](https://github.com/storytold/photocraft/issues/211)) scales a 24 MP +photo to 90 % width with Edit › Content-Aware Scale. Its budget is 3 s. + +- The committed baseline (2026-10-05) records 954 s. That predates the per-seam energy updates + and the reduced-height seam search already in `crates/algo/src/seam.rs`. +- Before this change, the row measured 3.3 s on the machine below. +- After it, the row measures 1.6 s and the carve itself is 3.6 times faster. The output is the + same. + +## What changed + +All changes are in `crates/algo/src/seam.rs`. The command, its parameters and its output are +unchanged. + +- **The seam search keeps its path-cost map across seams.** + - The search is the dynamic programme of Avidan and Shamir (2007). Before, it refilled the whole + map for every seam: for P28, 600 serial passes over about 3 M cells. + - After a removal, `Dp::update` recomputes row by row only two kinds of pixel: those next to the + seam, whose energies or parents changed, and those with a parent whose cost actually changed + (compared bit for bit). Nothing else can change, so the map stays identical to a full pass. + - On the bench images this recomputes 1.3 % of the map per seam on the reduced-height search, + and 6–10 % on the full-resolution one. 98–99 % of the recomputed pixels do change, so the work + is the removed seam's basin, not slack in the bounds. + - Directions are no longer stored. The seam is traced back from the costs with the same tie + rules (`cell`). Rows are computed by one shared, vectorised kernel (`row_costs`). +- **The carver moves no pixels.** + - It borrows the image, keeps each remaining pixel's source column (`u32`), and reads energy + neighbours and the result through it. + - A removal shifts whichever side of the seam is shorter, in three 4-byte per-pixel buffers + (index, energy, cost). Before, it shifted everything right of the seam in up to four buffers, + including the 16-byte RGBA pixels and, on the tracked paths, an 8-byte index. + - The image is no longer copied. +- **The full-resolution stages run in parallel over rows.** These are the tall-image proxy build, + its full-resolution rebuild (runs copied between removed columns), the height pass's transposes + (blocked) and the plain resample used by Amount. + +## Exactness + +**Inputs whose energy stays a number** (every finite image without overflow) produce output that +is bit-identical to the previous code. These tests pin it: + +- `output_bits_are_pinned`, for images under 2048 rows. +- `tall_proxy_output_bits_are_pinned`, for the reduced-height search. It was pinned from the + previous code before any change. +- `carver_matches_reference`, which runs 400 random cases against the original straightforward + implementation. +- `incremental_dp_matches_full_dp`, which after every removal checks the kept map, the seam, the + energy and the pixels against a recomputation from scratch. +- The hashes of the four `bench_seam` outputs. + +**An adversarial review** compared the previous and new code side by side over more than 37 000 +generated cases. Inputs included huge values, denormals, -0.0, out-of-range protection, enlarging +past 2× and proxy-size images. No difference appeared on any input whose energy stays a number. + +**NaN and infinities** are now deterministic on every platform: + +- An energy that isn't a number is the highest energy (`+inf`). Such energies come from NaN + samples, from infinite samples at the border or next to each other, and from overflowing + differences. +- NaN protection protects nothing. + +Before, these inputs fed NaN to the seam search. The chosen seam then depended on NaN payloads, +which arithmetic does not keep consistently across builds or on wasm. `nan_payloads_do_not_steer_seams` +and `infinite_samples_carve_deterministically` pin the new behaviour. + +**The height pass now keeps infinite protection.** It resamples the protection map; where that +gives NaN, the map clamped to 0..=1 is resampled instead. Before, a row protected with `+inf` +was carved away while one protected with `1.0` was kept. + +**Degenerate inputs now return early instead of panicking.** These are no channels, an empty +width with a height change, and images or protection maps shorter than their size. + +## Measurements + +**Machine and method:** + +- 4-vCPU cloud VM (Intel Xeon 2.1 GHz, Linux, no GPU), release builds. +- The VM's speed drifts by about 20 % over time, so before and after binaries ran interleaved in + the same window. Reported values are p50 with the [min–max] range. + +**The carver alone:** + +- Command: `cargo run --release -p photocraft-algo --example bench_seam`. +- Input: a synthetic photo-like RGBA image. +- Five interleaved rounds; the output hashes were identical in every run. + +| Case | Before | After | Speed-up | +|---|---|---|---| +| 24 MP to 90 % width (P28's carve, reduced-height search) | 2013 ms [1958–2149] | 556 ms [542–623] | 3.6× | +| 24 MP to 90 % height (transposed) | 2639 ms [2617–2809] | 993 ms [967–1017] | 2.7× | +| 5.4 MP to 90 % width (full-resolution search) | 1548 ms [1514–1648] | 677 ms [664–719] | 2.3× | +| 1.5 MP to 70 % width (full-resolution search) | 671 ms [658–766] | 406 ms [376–421] | 1.65× | + +**The P28 row:** + +- Command: `perf_scenarios --cpu --only "Content-Aware Scale"`. +- It also times reading the layer, the job and writing the result back. +- Five interleaved rounds, n = 1 per run: + +| P28 row | Before | After | +|---|---|---| +| Time | 3281 ms [3178–3364] | 1639 ms [1503–1728] | +| Peak RSS | 1368–1386 MB | 1305–1367 MB | + +`cargo run --release -p photocraft-engine --example bench_content_aware_scale` times the same +command without building the UI crate. After the change, one run split as follows: + +| Stage | Time | +|---|---| +| Reading the layer region | about 0.3 s | +| The carve | about 0.5 s | +| Writing the result back, with the undo step | about 0.2 s | + +**Memory inside the carver** is now 12 bytes per pixel. Before, it was the image copy (4 bytes per +channel), the energy and the stored directions, plus protection and an 8-byte index where used. + +- The only case that uses more is a one-channel shrink without protection: 9 → 12 bytes per pixel. + The review measured its peak 1.17× higher. +- Every other case uses less. + +## Limits and what is still open + +- **The scorecard and enforcement.** The scorecard keeps showing the 2026-10-05 baseline until + `cargo xtask perf --update-baseline` runs on the reference machine. `enforce` stays false for + P28 until then. +- **The rest of the P28 row** is now mostly plumbing outside the carver. `Surface::read_region` + converts the 24 MP layer pixel by pixel on one thread, and `write_region` also runs on one + thread. +- **Full-resolution searches.** Enlarging still runs them, since only shrinking tall images uses + the reduced-height search. The review measured a 24 MP 1 % enlarge going from 7.0 s to 1.8 s on a + loaded machine. What remains per seam is the removed seam's basin in the cost map (serial, row by + row) and the row shifts. +- **A worst case.** When every seam hugs the right edge of a one-sided smooth ramp, the old code + shifted nothing, but the new code's cost changes cover almost the whole map. The review measured + that case 1.3–1.5× slower than before. No other input it tried was slower. +- **wasm** builds run the same code on one thread. diff --git a/docs/gaps.md b/docs/gaps.md index 23b3751235..580a094f41 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where PhotoCraft falls short of Photoshop -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (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-13 · **Change:** minor (G2: Content-Aware Scale seam carving 1.65–3.6× faster with unchanged output, P28 row 3.3 → 1.6 s on a 4-core VM; 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 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 @@ -200,10 +200,19 @@ what an agent can't finish alone. default small blur and the 36 MP saturated-field gain are inconclusive. [Method and full ranges](tilt-shift-performance.md). Native GUI latency remains unmeasured; no scorecard budget or parity percentage is changed by this work. +- **Measured progress (2026-10-13):** Content-Aware Scale (P28) keeps its seam search across + seams and moves no pixels. On a 4-core cloud VM (CPU, interleaved runs), the carve of P28's + 24 MP photo to 90 % width takes 556 ms instead of 2013 ms (3.6×), and the whole P28 row takes + 1.64 s instead of 3.28 s, within its 3 s budget. Smaller images on the full-resolution search + are 1.65–2.3× faster. Output is bit-identical wherever the energy stays a number (pinned + hashes); NaN and infinities are now deterministic. The scorecard keeps the 2026-10-05 + baseline's 954 s, which predates the per-seam energy updates and the reduced-height search, + until the reference machine reruns it. Most of the row is now `read_region`/`write_region` + plumbing. [Method and ranges](content-aware-scale-performance.md). - **Missing:** 22 of 25 budgeted scenarios are over budget (baseline 2026-10-05, a heavily loaded machine): layer move with styles 321 ms p50 against 25 ms, opacity change 276 ms against 20 ms, paste 12 MP 1.2 s against 100 ms, layer move on 15000×10000 16-bit 2.7 s, - Content-Aware Scale 24 MP 954 s against 3 s, Select Subject 559 ms against 100 ms; the + Content-Aware Scale 24 MP 954 s against 3 s (older code; now met, see above), Select Subject 559 ms against 100 ms; the 150-layer nudge crashes the GPU compositor (P12); menus slow with thousands of layers (#2460); old machines lag (#2687). - **Estimate:** 200–350 h. Serial in places (compositor architecture). @@ -255,6 +264,7 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| +| 2026-10-13 | minor | G2: Content-Aware Scale (P28) measured: carve 2013 → 556 ms, row 3.28 → 1.64 s on a 4-core VM, output unchanged; baseline, budgets and estimate unchanged | | 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 | | 2026-10-12 | minor | G11: `.atn` import maps 112 events (Select and Mask, Spatter, Ripple, Crystallize, Pattern Fill, mask targeting, Step Backward, points, Bitmap) | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f6209c58db..e9a27beac9 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -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 (Content-Aware Scale measurements added; 2026-10-12: `.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 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); @@ -367,6 +367,15 @@ The transform also corrects f32 envelope errors past coordinate 4096, including distances at selected pixels. The parallel path needs an additional four bytes per pixel; see [measurements, correctness and limits](selection-distance-performance.md). +2026-10-13: Content-Aware Scale keeps its seam search's path costs across seams (recomputing +only the removed seam's basin) and no longer moves pixels. On a 4-core cloud VM (CPU, release, +interleaved runs) the carve of P28's 24 MP photo to 90 % width takes 2013 → 556 ms (3.6×), the +same image's height 2639 → 993 ms, and full-resolution searches 1.65–2.3× less time. The P28 +row with its document plumbing takes 3.28 → 1.64 s, within its 3 s budget. Output bits are +unchanged wherever the energy stays a number (pinned hashes, reference comparison, a 37 000-case +differential review); NaN and infinities are now deterministic. The committed baseline (954 s, +older code) is unchanged until the reference machine reruns it; see [method and limits](content-aware-scale-performance.md). + **Bottom line.** Two days after 0.2.0 we had merged ~96 PRs and closed ~48 issues, but **real Photoshop parity is still well below 50%**. The biggest gaps are AI, missing tools, professional workflow depth and the plug-in ecosystem. Most fixes since 0.2.0 have passed our tests but have @@ -563,6 +572,7 @@ See [method, raw measurements and reproduction](five-algorithm-performance.md). | Date | Change | Summary | |---|---|---| +| 2026-10-13 | minor | Added measured Content-Aware Scale gains (P28 under its budget on a 4-core VM, not yet in the baseline); percentages and budgets 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 | diff --git a/perf/budgets.toml b/perf/budgets.toml index a95c1c83dc..348be1d65f 100644 --- a/perf/budgets.toml +++ b/perf/budgets.toml @@ -342,7 +342,7 @@ issue = 211 bench = "perf_scenarios" row = "Content-Aware Scale 24 MP to 90 % width" budget_ms = 3000 -enforce = false # over budget in the 2026-10-05 baseline +enforce = false # 2026-10-13: met on a 4-core VM (CPU), row 3.3 s -> 1.6 s (docs/content-aware-scale-performance.md); enforce once the baseline is refreshed [[scenario]] id = "P29" From 99b23f70079ebfe42c021d9eddcef06a9753db5f Mon Sep 17 00:00:00 2001 From: abc2cb <271337822+abc2cb@users.noreply.github.com> Date: Tue, 13 Oct 2026 22:15:35 +0300 Subject: [PATCH 055/649] PSD smart filters test: compare Wave's settings, not Photoshop's descriptor name Co-Authored-By: Claude Opus 5.5 --- crates/io/src/smart_map.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/io/src/smart_map.rs b/crates/io/src/smart_map.rs index cb100ca559..6e0f0f8483 100644 --- a/crates/io/src/smart_map.rs +++ b/crates/io/src/smart_map.rs @@ -1059,7 +1059,10 @@ mod tests { "undefinedAreas": "wrap", "seed": 1270346}) ) ); - assert_eq!(item_for_filter(&f).unwrap().get("Fltr"), Some(&Value::Descriptor(unscaled))); + match item_for_filter(&f).unwrap().get("Fltr") { + Some(Value::Descriptor(ours)) => assert_eq!((&ours.class_id, &ours.items), (&unscaled.class_id, &unscaled.items)), + other => panic!("wave: no Fltr ({other:?})"), + } } /// Invert on a smart object: Photoshop stores no `Fltr`, but `hasoptions` and its filter id. From c75160659e4299d98114553065ac67ae764e6890 Mon Sep 17 00:00:00 2001 From: geduful Date: Wed, 14 Oct 2026 02:02:46 +0000 Subject: [PATCH 056/649] fix(gpu): catch validation errors in watched compositor work The scoped_work function skipped error scopes when watched is true (always the case in the app because the canvas sets up health monitoring). But error scopes are needed on native platforms to catch synchronous validation errors (e.g. invalid buffer in queue.write_buffer). The health callbacks only handle device loss and async errors. This fixes P12 (arrow-key nudge in a 150-layer document) which crashed with: wgpu error: Validation Error / Caused by: / In Queue::write_buffer / Buffer with pc_compose_uniforms label is invalid Now scoped_work always uses error scopes on native (non-WASM) to catch validation/internal/OOM errors, while WebGPU relies on health callbacks for async errors. --- crates/gpu/src/lib.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/gpu/src/lib.rs b/crates/gpu/src/lib.rs index 223d4ed983..c935ac7027 100644 --- a/crates/gpu/src/lib.rs +++ b/crates/gpu/src/lib.rs @@ -553,8 +553,8 @@ fn field_reaches(progs: &[fx::MapProgram]) -> HashMap { } /// Runs `f` inside GPU error scopes and returns the first error raised. -/// Native wgpu reports errors synchronously; where they only arrive asynchronously (WebGPU) none -/// is reported. +/// Native wgpu reports validation/internal/OOM errors synchronously; where they only arrive +/// asynchronously (WebGPU) none is reported. fn first_error(device: &wgpu::Device, f: impl FnOnce() -> T) -> (T, Option) { let validation = device.push_error_scope(wgpu::ErrorFilter::Validation); let internal = device.push_error_scope(wgpu::ErrorFilter::Internal); @@ -571,12 +571,13 @@ fn first_error(device: &wgpu::Device, f: impl FnOnce() -> T) -> (T, Option(device: &wgpu::Device, watched: bool, f: impl FnOnce() -> Result) -> Result { - // WebGPU errors arrive asynchronously; its callers still use the health callbacks. - if watched || cfg!(target_arch = "wasm32") { + // Always use error scopes on native to catch synchronous validation errors (e.g. invalid buffer + // in queue.write_buffer). On WebGPU, errors are async so scopes don't help; rely on health. + if cfg!(target_arch = "wasm32") { return f(); } let (result, error) = first_error(device, f); From c928895a082b7f2247836acdc084a49939874f6e Mon Sep 17 00:00:00 2001 From: abc2cb <271337822+abc2cb@users.noreply.github.com> Date: Wed, 14 Oct 2026 08:42:54 +0300 Subject: [PATCH 057/649] smart_map: rustfmt the ZigZag arm Co-Authored-By: Claude Opus 5.5 --- crates/io/src/smart_map.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/io/src/smart_map.rs b/crates/io/src/smart_map.rs index 6e0f0f8483..a82c2ca4c2 100644 --- a/crates/io/src/smart_map.rs +++ b/crates/io/src/smart_map.rs @@ -516,10 +516,9 @@ fn fltr_for(k: &Known, p: &J) -> Result, String> { "Rple" => d.with("Amnt", pi(p, "amount", 100.0)).with("RplS", enum_value(p, "size", "medium", "RplS", &RIPPLE_SIZE)?), "Sphr" => d.with("Amnt", pi(p, "amount", 100.0)).with("SphM", enum_value(p, "mode", "normal", "SphM", &SPHERIZE_MODE)?), "Plr " => d.with("Cnvr", enum_value(p, "mode", "rectangularToPolar", "Cnvr", &POLAR_MODE)?), - "ZgZg" => d - .with("Amnt", pi(p, "amount", 10.0)) - .with("NmbR", pi(p, "ridges", 5.0)) - .with("ZZTy", enum_value(p, "style", "pondRipples", "ZZTy", &ZIGZAG_STYLE)?), + "ZgZg" => { + d.with("Amnt", pi(p, "amount", 10.0)).with("NmbR", pi(p, "ridges", 5.0)).with("ZZTy", enum_value(p, "style", "pondRipples", "ZZTy", &ZIGZAG_STYLE)?) + } "Wave" => { let seed = p.get("seed").and_then(J::as_u64).and_then(|s| u32::try_from(s).ok()).unwrap_or(0); d.with("Wvtp", enum_value(p, "type", "sine", "Wvtp", &WAVE_TYPE)?) From b14d492378202d185654d6c6fd46f9493b25edc3 Mon Sep 17 00:00:00 2001 From: abc2cb <271337822+abc2cb@users.noreply.github.com> Date: Wed, 14 Oct 2026 10:01:46 +0300 Subject: [PATCH 058/649] smart_map test: panic! instead of unreachable! (clippy::unreachable) Co-Authored-By: Claude Opus 5.5 --- crates/io/src/smart_map.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/io/src/smart_map.rs b/crates/io/src/smart_map.rs index a82c2ca4c2..10165316e0 100644 --- a/crates/io/src/smart_map.rs +++ b/crates/io/src/smart_map.rs @@ -1046,7 +1046,7 @@ mod tests { // Unscaled, it opens as PhotoCraft's Wave (Triangle, the other settings as stored). let mut unscaled = match item.get("Fltr") { Some(Value::Descriptor(d)) => d.clone(), - _ => unreachable!(), + other => panic!("wave: no Fltr ({other:?})"), }; set(&mut unscaled, "SclV", Value::Integer(100)); let f = filter_from_item(&photoshop_item(unscaled.clone())); From ac3cac0b95092b282854edcdbafec93e23317129 Mon Sep 17 00:00:00 2001 From: ZhuanTou33212 <2534311904@qq.com> Date: Wed, 14 Oct 2026 16:45:20 +0800 Subject: [PATCH 059/649] Add opt-out startup release checks and manual update status --- Cargo.lock | 74 +++++++-- apps/photocraft/Cargo.toml | 2 + apps/photocraft/src/main.rs | 1 + apps/photocraft/src/services.rs | 1 + apps/photocraft/src/updates.rs | 126 +++++++++++++++ crates/engine/Cargo.toml | 2 + crates/engine/src/commands.rs | 1 + crates/engine/src/lib.rs | 3 + crates/engine/src/prefs.rs | 3 + crates/engine/src/updates_cmds.rs | 221 ++++++++++++++++++++++++++ crates/ui-egui/examples/snapshot.rs | 10 ++ crates/ui-egui/src/control.rs | 9 +- crates/ui-egui/src/i18n/cs.tsv | 13 ++ crates/ui-egui/src/i18n/de.tsv | 13 ++ crates/ui-egui/src/i18n/el.tsv | 13 ++ crates/ui-egui/src/i18n/es.tsv | 13 ++ crates/ui-egui/src/i18n/fr.tsv | 13 ++ crates/ui-egui/src/i18n/hu.tsv | 12 ++ crates/ui-egui/src/i18n/id.tsv | 13 ++ crates/ui-egui/src/i18n/it.tsv | 13 ++ crates/ui-egui/src/i18n/ja.tsv | 13 ++ crates/ui-egui/src/i18n/ko.tsv | 13 ++ crates/ui-egui/src/i18n/nl.tsv | 13 ++ crates/ui-egui/src/i18n/pl.tsv | 13 ++ crates/ui-egui/src/i18n/pt-br.tsv | 13 ++ crates/ui-egui/src/i18n/ru.tsv | 13 ++ crates/ui-egui/src/i18n/tr.tsv | 12 ++ crates/ui-egui/src/i18n/uk.tsv | 13 ++ crates/ui-egui/src/i18n/vi.tsv | 12 ++ crates/ui-egui/src/i18n/zh-hans.tsv | 13 ++ crates/ui-egui/src/i18n/zh-hant.tsv | 13 ++ crates/ui-egui/src/lib.rs | 10 +- crates/ui-egui/src/links.rs | 15 +- crates/ui-egui/src/menus.rs | 11 +- crates/ui-egui/src/prefs_ui.rs | 1 + crates/ui-egui/src/state.rs | 4 + crates/ui-egui/src/updates_ui.rs | 233 ++++++++++++++++++++++++++++ docs/control-protocol.md | 13 ++ docs/gaps.md | 10 +- docs/releasing.md | 16 ++ docs/scorecard.md | 8 +- docs/target-app-parity.md | 5 +- scorecard/distribution.toml | 6 +- 43 files changed, 1000 insertions(+), 29 deletions(-) create mode 100644 apps/photocraft/src/updates.rs create mode 100644 crates/engine/src/updates_cmds.rs create mode 100644 crates/ui-egui/src/updates_ui.rs diff --git a/Cargo.lock b/Cargo.lock index e7bfc1112c..449364a318 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -849,7 +849,7 @@ dependencies = [ "maybe-owned", "rustix 1.1.5", "rustix-linux-procfs", - "windows-sys 0.60.2", + "windows-sys 0.61.2", "winx", ] @@ -1891,7 +1891,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -3028,7 +3028,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -3690,7 +3690,7 @@ dependencies = [ "objc2-foundation 0.3.2", "png 0.18.1", "thiserror 2.0.21", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -4436,7 +4436,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -4646,6 +4646,7 @@ dependencies = [ "rfd", "ron", "serde_json", + "ureq", "winit", "winresource", "winsafe", @@ -4805,6 +4806,7 @@ dependencies = [ "photocraft-vector", "rayon", "roxmltree", + "semver", "serde", "serde_json", "tempfile", @@ -5457,7 +5459,7 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -5976,7 +5978,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -5996,7 +5998,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634" dependencies = [ "aws-lc-rs", + "log", "once_cell", + "ring", "rustls-pki-types", "rustls-webpki", "subtle", @@ -6043,7 +6047,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -6681,7 +6685,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -6908,10 +6912,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom 0.4.3", "once_cell", "rustix 1.1.5", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -7311,7 +7315,7 @@ checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" dependencies = [ "memoffset", "tempfile", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -7392,6 +7396,35 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +[[package]] +name = "ureq" +version = "3.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a7ac20be9b7726e0bbdbf974c059676d9acb1cd414961f570a4e8231cacd7fc" +dependencies = [ + "base64 0.23.1", + "log", + "percent-encoding", + "rustls", + "rustls-pki-types", + "rustls-platform-verifier", + "ureq-proto", + "utf8-zero", + "webpki-roots", +] + +[[package]] +name = "ureq-proto" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f86fd172ccca569e458f61b6bdd6220965a9ef36e672a6852953b51a0e1583be" +dependencies = [ + "base64 0.23.1", + "http", + "httparse", + "log", +] + [[package]] name = "url" version = "2.5.8" @@ -7431,6 +7464,12 @@ dependencies = [ "xmlwriter", ] +[[package]] +name = "utf8-zero" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8c0a043c9540bae7c578c88f91dda8bd82e59ae27c21baca69c8b191aaf5a6e" + [[package]] name = "utf8_iter" version = "1.0.4" @@ -7870,6 +7909,15 @@ dependencies = [ "rustls-pki-types", ] +[[package]] +name = "webpki-roots" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "weezl" version = "0.1.12" @@ -8071,7 +8119,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] diff --git a/apps/photocraft/Cargo.toml b/apps/photocraft/Cargo.toml index e5af663471..a10071cfba 100644 --- a/apps/photocraft/Cargo.toml +++ b/apps/photocraft/Cargo.toml @@ -40,6 +40,8 @@ arboard = { version = "3.6", features = ["wayland-data-control"] } open = "5" # Reads the saved window layout (eframe persistence) to drop values that would abort startup. ron = "0.12" +# Background release checks; HTTPS with Rust TLS, no async runtime. +ureq = { version = "3.4", default-features = false, features = ["rustls", "platform-verifier"] } [target.'cfg(target_os = "macos")'.dependencies] # Safe CoreGraphics bindings, compatible with the existing macOS 11 deployment target. diff --git a/apps/photocraft/src/main.rs b/apps/photocraft/src/main.rs index 1739568159..bff18f630d 100644 --- a/apps/photocraft/src/main.rs +++ b/apps/photocraft/src/main.rs @@ -50,6 +50,7 @@ mod services; #[cfg(any(target_os = "macos", target_os = "linux", test))] mod tablet; mod ui_state; +mod updates; mod window_frame; use photocraft_engine::Session; diff --git a/apps/photocraft/src/services.rs b/apps/photocraft/src/services.rs index d4a3869f31..1a98eca5f3 100644 --- a/apps/photocraft/src/services.rs +++ b/apps/photocraft/src/services.rs @@ -461,6 +461,7 @@ pub fn native(automation: Option) -> inbox: None, open_url: Some(Box::new(|url: &str| open::that(url).map_err(|e| e.to_string()))), beep: Some(platform_beep), + check_updates: Some(crate::updates::service()), clipboard_set_image: Some({ let clip = clip.clone(); Box::new(move |w: u32, h: u32, px: &[u8]| { diff --git a/apps/photocraft/src/updates.rs b/apps/photocraft/src/updates.rs new file mode 100644 index 0000000000..bbe4a9f3dc --- /dev/null +++ b/apps/photocraft/src/updates.rs @@ -0,0 +1,126 @@ +//! Native HTTPS transport for release checks. Only public release metadata is requested. + +use photocraft_engine::updates_cmds::{CheckFn, CheckResult, parse_release}; +use std::time::Duration; + +const LATEST: &str = "https://api.github.com/repos/storytold/photocraft/releases/latest"; +const MAX_RESPONSE: u64 = 1024 * 1024; + +pub fn service() -> CheckFn { + Box::new(|| { + let (tx, rx) = std::sync::mpsc::channel(); + std::thread::Builder::new() + .name("update check".into()) + .spawn(move || { + let result = fetch(LATEST, Duration::from_secs(15)); + if let Err(e) = &result { + log::warn!("Update check: {e}"); + } + let _ = tx.send(result); + }) + .map_err(|e| format!("Could not start update check: {e}"))?; + Ok(rx) + }) +} + +fn fetch(url: &str, timeout: Duration) -> CheckResult { + // Respect the OS trust store (including managed-network certificates), while still + // validating the certificate chain and server name. + let agent = ureq::Agent::config_builder() + .tls_config(ureq::tls::TlsConfig::builder().root_certs(ureq::tls::RootCerts::PlatformVerifier).build()) + .timeout_global(Some(timeout)) + .max_redirects(0) + .build() + .new_agent(); + let mut response = match agent + .get(url) + .header("User-Agent", "PhotoCraft-update-check") + .header("Accept", "application/vnd.github+json") + .header("X-GitHub-Api-Version", "2026-03-10") + .call() + { + Ok(response) => response, + // The repository may not have published a stable release yet. + Err(ureq::Error::StatusCode(404)) => return Ok(None), + Err(ureq::Error::StatusCode(403 | 429)) => return Err("GitHub is limiting update checks. Please try again later.".into()), + Err(e) => return Err(format!("Could not contact the release server: {e}")), + }; + if response.status() != 200 { + return Err(format!("Unexpected release server status: {}", response.status())); + } + let bytes = response.body_mut().with_config().limit(MAX_RESPONSE).read_to_vec().map_err(|e| format!("Could not read release response: {e}"))?; + parse_release(&bytes, photocraft_engine::build_info::VERSION) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::io::{Read, Write}; + use std::net::TcpListener; + + fn server(status: &str, body: &str, extra: &str) -> (String, std::thread::JoinHandle) { + let listener = TcpListener::bind("127.0.0.1:0").unwrap(); + let url = format!("http://{}/latest", listener.local_addr().unwrap()); + let response = format!("HTTP/1.1 {status}\r\nContent-Length: {}\r\n{extra}Connection: close\r\n\r\n{body}", body.len()); + let worker = std::thread::spawn(move || { + let (mut stream, _) = listener.accept().unwrap(); + stream.set_read_timeout(Some(Duration::from_secs(5))).unwrap(); + let mut request = Vec::new(); + let mut chunk = [0; 1024]; + while !request.windows(4).any(|w| w == b"\r\n\r\n") { + let n = stream.read(&mut chunk).unwrap(); + if n == 0 { + break; + } + request.extend_from_slice(&chunk[..n]); + } + let _ = stream.write_all(response.as_bytes()); + String::from_utf8(request).unwrap() + }); + (url, worker) + } + + #[test] + fn fetches_release_metadata_with_generic_headers() { + let (url, worker) = server("200 OK", r#"{"tag_name":"v99.0.0","draft":false,"prerelease":false}"#, ""); + let result = fetch(&url, Duration::from_secs(5)).unwrap().unwrap(); + assert_eq!(result.version, "99.0.0"); + let request = worker.join().unwrap().to_ascii_lowercase(); + assert!(request.contains("user-agent: photocraft-update-check\r\n")); + assert!(request.contains("accept: application/vnd.github+json")); + assert!(!request.contains("authorization:") && !request.contains("cookie:")); + } + + #[test] + fn handles_missing_release_rate_limits_and_bad_responses() { + for (status, body, extra, expected_none) in [ + ("404 Not Found", "", "", true), + ("403 Forbidden", "", "", false), + ("429 Too Many Requests", "", "", false), + ("500 Internal Server Error", "", "", false), + ("200 OK", "invalid JSON", "", false), + ("302 Found", "", "Location: https://untrusted.example/\r\n", false), + ] { + let (url, worker) = server(status, body, extra); + let result = fetch(&url, Duration::from_secs(5)); + if expected_none { + assert_eq!(result, Ok(None)); + } else { + assert!(result.is_err(), "{status}"); + } + worker.join().unwrap(); + } + } + + #[test] + fn caps_response_size_and_times_out() { + let (url, worker) = server("200 OK", &" ".repeat(MAX_RESPONSE as usize + 1), ""); + assert!(fetch(&url, Duration::from_secs(5)).is_err()); + worker.join().unwrap(); + let listener = TcpListener::bind("127.0.0.1:0").unwrap(); + let url = format!("http://{}/latest", listener.local_addr().unwrap()); + let start = std::time::Instant::now(); + assert!(fetch(&url, Duration::from_millis(100)).is_err()); + assert!(start.elapsed() < Duration::from_secs(2)); + } +} diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml index 741d927a3f..7a6e30c580 100644 --- a/crates/engine/Cargo.toml +++ b/crates/engine/Cargo.toml @@ -39,6 +39,8 @@ craft-print = { workspace = true } # Photoshop `.kys` shortcut sets (`edit.keyboardShortcuts` `importKys`); already in the tree # through photocraft-ui-egui and usvg. roxmltree = "0.20" +# Release tags use the same semantic versions as Cargo. +semver = "1" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tempfile = "3" diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs index a954eca7e2..a9ff0ea45a 100644 --- a/crates/engine/src/commands.rs +++ b/crates/engine/src/commands.rs @@ -1306,6 +1306,7 @@ fn build() -> Vec { v.extend(crate::layer_multi_cmds::specs()); v.extend(crate::layer_copy_cmds::specs()); v.extend(crate::prefs::specs()); + v.extend(crate::updates_cmds::specs()); v.extend(crate::edit_menu_cmds::specs()); v.extend(crate::fill_key_cmds::specs()); v.extend(crate::sample_cmds::specs()); diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index ff3cde6e4c..d231474a30 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -117,6 +117,7 @@ pub mod type_extra_cmds; pub mod type_mask_cmds; pub mod type_spell_cmds; pub mod type_styles_cmds; +pub mod updates_cmds; mod variables_cmds; pub use variables_cmds::{export_data_sets_with, import_data_sets_text}; pub mod vector_cmds; @@ -417,6 +418,8 @@ pub struct Session { color_restrict: Option, /// Edit › Preferences, keyboard shortcuts, menu and toolbar customisation (see `prefs`). pub prefs: prefs::PrefsStore, + /// Release checks use an injected platform transport; no network I/O in the engine. + pub updates: updates_cmds::Updates, /// Edit menu state: Fade source, custom shape library (see `edit_menu_cmds`). pub edit_state: edit_menu_cmds::EditState, /// The pattern library (Window › Patterns; see `pattern.*`). diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index b163d40d88..9119276dee 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -221,6 +221,8 @@ pub struct General { pub zoom_resizes_windows: bool, pub use_legacy_free_transform: bool, pub auto_show_home_screen: bool, + /// Desktop: check published stable releases once in the background at launch. + pub automatically_check_updates: bool, } impl Default for General { @@ -237,6 +239,7 @@ impl Default for General { zoom_resizes_windows: false, use_legacy_free_transform: false, auto_show_home_screen: true, + automatically_check_updates: true, } } } diff --git a/crates/engine/src/updates_cmds.rs b/crates/engine/src/updates_cmds.rs new file mode 100644 index 0000000000..76dbd91b6c --- /dev/null +++ b/crates/engine/src/updates_cmds.rs @@ -0,0 +1,221 @@ +//! Release-check state and commands. The desktop injects a non-blocking transport; the engine +//! owns the result so CLI, MCP and the GUI query the same state without network dependencies. + +use std::sync::mpsc::{Receiver, TryRecvError}; + +use semver::Version; +use serde::{Deserialize, Serialize}; +use serde_json::{Value, json}; + +use crate::commands::{CommandSpec, always}; +use crate::{EngineError, Result, Session}; + +pub const RELEASES: &str = "https://github.com/storytold/photocraft/releases"; +pub type CheckResult = std::result::Result, String>; +/// Starts background work and returns immediately. No document or personal data is sent. +pub type CheckFn = Box std::result::Result, String> + Send>; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Release { + pub version: String, + pub url: String, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +#[serde(tag = "status", rename_all = "camelCase")] +pub enum Status { + #[default] + Idle, + Checking, + UpToDate, + Available { + release: Release, + }, + Failed { + message: String, + }, +} + +#[derive(Default)] +pub struct Updates { + pub check: Option, + pub status: Status, + pending: Option>, +} + +impl Updates { + /// Consume a completed check; a disconnected worker becomes an actionable error. + pub fn poll(&mut self) -> bool { + let Some(rx) = &self.pending else { return false }; + let result = match rx.try_recv() { + Ok(r) => r, + Err(TryRecvError::Empty) => return false, + Err(TryRecvError::Disconnected) => Err("The update check stopped before returning a result".into()), + }; + self.pending = None; + self.status = match result { + Ok(Some(release)) => Status::Available { release }, + Ok(None) => Status::UpToDate, + Err(message) => Status::Failed { message }, + }; + true + } +} + +/// Interpret GitHub's latest-release response. Never trust a remote URL: construct the release +/// page from a validated tag in our own repository. Build metadata doesn't affect precedence. +pub fn parse_release(bytes: &[u8], current: &str) -> CheckResult { + #[derive(Deserialize)] + struct GithubRelease { + tag_name: String, + draft: bool, + prerelease: bool, + } + let release: GithubRelease = serde_json::from_slice(bytes).map_err(|e| format!("Invalid release response: {e}"))?; + if release.draft || release.prerelease { + return Ok(None); + } + let tag = &release.tag_name; + if tag.len() > 128 || !tag.bytes().all(|b| b.is_ascii_alphanumeric() || matches!(b, b'.' | b'-' | b'+')) { + return Err("Invalid release tag".into()); + } + let version = Version::parse(tag.strip_prefix('v').unwrap_or(tag)).map_err(|e| format!("Invalid release version: {e}"))?; + let current = Version::parse(current).map_err(|e| format!("Invalid installed version: {e}"))?; + if !version.pre.is_empty() || !version.cmp_precedence(¤t).is_gt() { + return Ok(None); + } + Ok(Some(Release { version: version.to_string(), url: format!("{RELEASES}/tag/{tag}") })) +} + +fn empty_params(p: &Value) -> Result<()> { + if p.as_object().is_some_and(|p| p.is_empty()) { Ok(()) } else { Err(EngineError::Other("update commands take an empty object".into())) } +} + +fn enabled(s: &Session) -> std::result::Result<(), String> { + s.updates.check.as_ref().map(|_| ()).ok_or_else(|| "Update checks are unavailable in this frontend".into()) +} + +fn check(s: &mut Session, p: &Value) -> Result { + empty_params(p)?; + // Repeated automation requests must not spawn an unbounded number of network workers. + if s.updates.pending.is_none() { + let start = s.updates.check.as_mut().ok_or_else(|| EngineError::Other("Update checks are unavailable in this frontend".into()))?; + match start() { + Ok(rx) => { + s.updates.pending = Some(rx); + s.updates.status = Status::Checking; + } + Err(message) => { + s.updates.status = Status::Failed { message: message.clone() }; + return Err(EngineError::Other(message)); + } + } + } + Ok(json!(s.updates.status)) +} + +pub fn specs() -> Vec { + vec![ + CommandSpec { + id: "help.checkForUpdates", + label: "Check for Updates…", + menu: &["Help"], + shortcut: None, + params: "{}", + enabled, + run: check, + journal: false, + }, + CommandSpec { + id: "updates.status", + label: "Update Check Status", + menu: &[], + shortcut: None, + params: "{}", + enabled: always, + run: |s, p| { + empty_params(p)?; + s.updates.poll(); + Ok(json!({"supported": s.updates.check.is_some(), "currentVersion": crate::build_info::VERSION, "result": s.updates.status})) + }, + journal: false, + }, + ] +} + +#[cfg(test)] +mod tests { + use super::*; + + fn response(tag: &str) -> Vec { + serde_json::to_vec(&json!({"tag_name": tag, "draft": false, "prerelease": false, "html_url": "https://untrusted.example"})).unwrap() + } + + #[test] + fn semantic_versions_and_trusted_links() { + let release = parse_release(&response("v0.10.0"), "0.9.0").unwrap().unwrap(); + assert_eq!(release.version, "0.10.0"); + assert_eq!(release.url, format!("{RELEASES}/tag/v0.10.0")); + for tag in ["v0.9.0", "v0.8.9", "v0.9.0+build.2", "v1.0.0-rc.1"] { + assert_eq!(parse_release(&response(tag), "0.9.0").unwrap(), None, "{tag}"); + } + assert!(parse_release(&response("0.9.0"), "0.9.0-rc.1").unwrap().is_some()); + } + + #[test] + fn unpublished_and_hostile_responses() { + for flag in ["draft", "prerelease"] { + let mut v: Value = serde_json::from_slice(&response("v1.0.0")).unwrap(); + v[flag] = json!(true); + assert_eq!(parse_release(&serde_json::to_vec(&v).unwrap(), "0.7.0").unwrap(), None); + } + for tag in ["", "latest", "v1.0.0/../evil", "v1.0.0?next=evil", "v1.0.0\n", "版本1.0.0", "999999999999999999999.0.0"] { + assert!(parse_release(&response(tag), "0.7.0").is_err(), "{tag}"); + } + for bytes in [b"not JSON".as_slice(), b"{}", b"null", b"{\"tag_name\":42}"] { + assert!(parse_release(bytes, "0.7.0").is_err()); + } + } + + #[test] + fn commands_are_nonblocking_deduplicated_and_queryable_without_a_document() { + let mut s = Session::new(); + let (tx, rx) = std::sync::mpsc::channel(); + let mut rx = Some(rx); + s.updates.check = Some(Box::new(move || Ok(rx.take().expect("only one worker")))); + for _ in 0..3 { + assert_eq!(s.execute("help.checkForUpdates", json!({})).unwrap()["status"], "checking"); + } + tx.send(Ok(Some(Release { version: "1.0.0".into(), url: format!("{RELEASES}/tag/v1.0.0") }))).unwrap(); + let status = s.execute("updates.status", json!({})).unwrap(); + assert_eq!(status["result"]["status"], "available"); + assert_eq!(status["result"]["release"]["version"], "1.0.0"); + assert!(s.journal.is_empty()); + } + + #[test] + fn graceful_failures_and_preference_compatibility() { + let mut s = Session::new(); + assert!(s.execute("help.checkForUpdates", json!({})).is_err()); + for p in [Value::Null, json!([]), json!({"url": "evil"}), json!("bad")] { + assert!(s.execute("updates.status", p.clone()).is_err()); + assert!(check(&mut s, &p).is_err()); + } + s.updates.check = Some(Box::new(|| Err("Could not start worker".into()))); + assert!(s.execute("help.checkForUpdates", json!({})).is_err()); + assert!(matches!(s.updates.status, Status::Failed { .. })); + s.updates.check = Some(Box::new(|| { + let (_tx, rx) = std::sync::mpsc::channel(); + Ok(rx) + })); + s.execute("help.checkForUpdates", json!({})).unwrap(); + assert_eq!(s.execute("updates.status", json!({})).unwrap()["result"]["status"], "failed"); + s.load_prefs_json("{}").unwrap(); + assert!(s.prefs().general.automatically_check_updates); + s.execute("prefs.set", json!({"path": "general.automaticallyCheckUpdates", "value": false})).unwrap(); + let saved = s.prefs_to_json(); + let mut restored = Session::new(); + restored.load_prefs_json(&saved).unwrap(); + assert!(!restored.prefs().general.automatically_check_updates); + } +} diff --git a/crates/ui-egui/examples/snapshot.rs b/crates/ui-egui/examples/snapshot.rs index 31e4c60301..7561a40879 100644 --- a/crates/ui-egui/examples/snapshot.rs +++ b/crates/ui-egui/examples/snapshot.rs @@ -10,6 +10,7 @@ //! //! `--safe-gpu` draws the canvas on the CPU path, like the app's `--safe-gpu` launch. //! `--wayland-notice` previews the native file drag-and-drop guidance shown in Wayland sessions. +//! `--update-notice` previews a newer release without contacting the network. //! `--custom-titlebar` draws the Windows/Linux title bar (caption buttons in the top bar). //! //! `--monitor 1366x768 --window-top 31` simulates the display the window is on (in points) and @@ -37,6 +38,7 @@ fn main() { .unwrap_or((1440.0, 900.0)); let scale: f32 = arg(&args, "--scale").and_then(|s| s.parse().ok()).unwrap_or(2.0); let wayland_notice = args.iter().any(|a| a == "--wayland-notice"); + let update_notice = args.iter().any(|a| a == "--update-notice"); let script: Vec<(String, Value)> = arg(&args, "--script").map(|s| serde_json::from_str::>(&s).expect("--script must be [[method, params], …]")).unwrap_or_default(); @@ -73,6 +75,14 @@ fn main() { services.is_wayland = wayland_notice; services.xwayland_command = wayland_notice.then(|| "WAYLAND_DISPLAY= photocraft".into()); let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), services); + if update_notice { + app.session.updates.status = photocraft_engine::updates_cmds::Status::Available { + release: photocraft_engine::updates_cmds::Release { + version: "99.0.0".into(), + url: "https://github.com/storytold/photocraft/releases/tag/v99.0.0".into(), + }, + }; + } app.background_jobs = background_jobs; app.custom_titlebar = custom_titlebar; // `--safe-gpu`: the CPU canvas, as the desktop app's `--safe-gpu` launch. diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index 209691b875..b0a2b35d54 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -131,7 +131,8 @@ pub enum Outcome { /// field's value is validated before the first one is applied, so a typo, an unknown field, a /// bad value or a bad nested key can't reply with success while nothing — or only half of it — /// changed (#412). -pub const UI_SET_FIELDS: [&str; 35] = [ +pub const UI_SET_FIELDS: [&str; 36] = [ + "updatesOpen", "tool", "panels", "dock", @@ -539,6 +540,7 @@ fn dispatch(app: &mut PhotocraftApp, ctx: &egui::Context, req: &ControlRequest) } let panels = merged_object(&app.ui.panels, p.get("panels"), "panels")?; let mask_target = bool_field(p, "maskTarget")?; + let updates_open = bool_field(p, "updatesOpen")?; let vector_mask_target = bool_field(p, "vectorMaskTarget")?; let selection_mode = uint_field(p, "selectionMode")?; let dock_tabs = merged_object(&app.ui.dock_tabs, p.get("dockTabs"), "dockTabs")?; @@ -693,6 +695,9 @@ fn dispatch(app: &mut PhotocraftApp, ctx: &egui::Context, req: &ControlRequest) app.ui.vector_mask_target &= !m; app.sync_mask_targets(); } + if let Some(open) = updates_open { + app.ui.updates_open = open; + } if let Some(m) = vector_mask_target { app.ui.vector_mask_target = m; app.ui.mask_target &= !m; @@ -1310,6 +1315,8 @@ pub fn inspect(app: &PhotocraftApp, ctx: &egui::Context) -> Value { "status": app.ui.status, "statusError": app.ui.status_error, "notices": app.ui.notices, + "updatesOpen": app.ui.updates_open, + "updates": {"supported": app.session.updates.check.is_some(), "currentVersion": photocraft_engine::build_info::VERSION, "result": app.session.updates.status}, "gpuFallbackNotice": app.ui.gpu_fallback_notice, "kysOffer": app.ui.kys_offer, "frame": app.frame, diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 01a8b9e4d9..4deff4d7e2 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -3752,3 +3752,16 @@ navigator Zoom Zvětšení Sent to {printer} Odesláno do {printer} set in Print Settings… nastavuje se v nastavení tisku… ICO is limited to 256 × 256 pixels ICO je omezen na 256 × 256 pixelů +# PhotoCraft release checks. + Check for Updates… Zkontrolovat aktualizace… + PhotoCraft Updates Aktualizace PhotoCraft + Checking for updates… Kontrola aktualizací… + Open the release page to choose an installer for your system. Otevřete stránku vydání a vyberte instalační program pro svůj systém. + Open Download Page Otevřít stránku ke stažení + PhotoCraft is up to date. PhotoCraft je aktuální. + Could not check for updates. Aktualizace se nepodařilo zkontrolovat. + Updates have not been checked yet. Aktualizace ještě nebyly zkontrolovány. + Check Again Zkontrolovat znovu + Automatically Check for Updates Automaticky kontrolovat aktualizace + Installed version: {version} Nainstalovaná verze: {version} + PhotoCraft {version} is available. PhotoCraft {version} je k dispozici. diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 489647ed21..c7b51b6dd2 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -3142,3 +3142,16 @@ curves Smooth Glätten Sent to {printer} An {printer} gesendet set in Print Settings… in den Druckeinstellungen festlegen… ICO is limited to 256 × 256 pixels ICO ist auf 256 × 256 Pixel begrenzt +# PhotoCraft release checks. + Check for Updates… Nach Updates suchen… + PhotoCraft Updates PhotoCraft-Updates + Checking for updates… Suche nach Updates… + Open the release page to choose an installer for your system. Öffnen Sie die Versionsseite und wählen Sie ein Installationspaket für Ihr System. + Open Download Page Downloadseite öffnen + PhotoCraft is up to date. PhotoCraft ist auf dem neuesten Stand. + Could not check for updates. Updates konnten nicht geprüft werden. + Updates have not been checked yet. Es wurde noch nicht nach Updates gesucht. + Check Again Erneut prüfen + Automatically Check for Updates Automatisch nach Updates suchen + Installed version: {version} Installierte Version: {version} + PhotoCraft {version} is available. PhotoCraft {version} ist verfügbar. diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 410da1a188..02183d1907 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3842,3 +3842,16 @@ curves Smooth Εξομάλυνση Sent to {printer} Στάλθηκε στον {printer} set in Print Settings… ορίζεται στις ρυθμίσεις εκτύπωσης… ICO is limited to 256 × 256 pixels Το ICO περιορίζεται σε 256 × 256 εικονοστοιχεία +# PhotoCraft release checks. + Check for Updates… Έλεγχος ενημερώσεων… + PhotoCraft Updates Ενημερώσεις PhotoCraft + Checking for updates… Έλεγχος για ενημερώσεις… + Open the release page to choose an installer for your system. Ανοίξτε τη σελίδα της έκδοσης για να επιλέξετε πρόγραμμα εγκατάστασης για το σύστημά σας. + Open Download Page Άνοιγμα σελίδας λήψης + PhotoCraft is up to date. Το PhotoCraft είναι ενημερωμένο. + Could not check for updates. Δεν ήταν δυνατός ο έλεγχος ενημερώσεων. + Updates have not been checked yet. Δεν έχει γίνει ακόμη έλεγχος ενημερώσεων. + Check Again Νέος έλεγχος + Automatically Check for Updates Αυτόματος έλεγχος ενημερώσεων + Installed version: {version} Εγκατεστημένη έκδοση: {version} + PhotoCraft {version} is available. Το PhotoCraft {version} είναι διαθέσιμο. diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index b5db4e9925..41f9a83f06 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2829,3 +2829,16 @@ curves Smooth Suavizar Sent to {printer} Enviado a {printer} set in Print Settings… se establece en Ajustes de impresión… ICO is limited to 256 × 256 pixels ICO está limitado a 256 × 256 píxeles +# PhotoCraft release checks. + Check for Updates… Buscar actualizaciones… + PhotoCraft Updates Actualizaciones de PhotoCraft + Checking for updates… Buscando actualizaciones… + Open the release page to choose an installer for your system. Abra la página de la versión para elegir un instalador para su sistema. + Open Download Page Abrir página de descarga + PhotoCraft is up to date. PhotoCraft está actualizado. + Could not check for updates. No se pudieron buscar actualizaciones. + Updates have not been checked yet. Aún no se han buscado actualizaciones. + Check Again Comprobar de nuevo + Automatically Check for Updates Buscar actualizaciones automáticamente + Installed version: {version} Versión instalada: {version} + PhotoCraft {version} is available. PhotoCraft {version} está disponible. diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index ab0cca6f40..e30e814502 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -3146,3 +3146,16 @@ curves Smooth Lisser Sent to {printer} Envoyé à {printer} set in Print Settings… défini dans les paramètres d’impression… ICO is limited to 256 × 256 pixels Le format ICO est limité à 256 × 256 pixels +# PhotoCraft release checks. + Check for Updates… Rechercher des mises à jour… + PhotoCraft Updates Mises à jour de PhotoCraft + Checking for updates… Recherche de mises à jour… + Open the release page to choose an installer for your system. Ouvrez la page de la version pour choisir un programme d’installation pour votre système. + Open Download Page Ouvrir la page de téléchargement + PhotoCraft is up to date. PhotoCraft est à jour. + Could not check for updates. Impossible de rechercher des mises à jour. + Updates have not been checked yet. Les mises à jour n’ont pas encore été vérifiées. + Check Again Vérifier à nouveau + Automatically Check for Updates Rechercher automatiquement des mises à jour + Installed version: {version} Version installée : {version} + PhotoCraft {version} is available. PhotoCraft {version} est disponible. diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 9a7283a5a1..86d3d9e8a8 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -4065,3 +4065,15 @@ cameraRaw Yellow Sárga Ink Characteristics Festék jellemzői Solidity: Fedőképesség: Redrawing Újrarajzolás + Check for Updates… Frissítések keresése… + PhotoCraft Updates PhotoCraft-frissítések + Checking for updates… Frissítések keresése… + Open the release page to choose an installer for your system. Nyissa meg a kiadás oldalát, és válassza ki a rendszerének megfelelő telepítőt. + Open Download Page Letöltési oldal megnyitása + PhotoCraft is up to date. A PhotoCraft naprakész. + Could not check for updates. Nem sikerült ellenőrizni a frissítéseket. + Updates have not been checked yet. A frissítések még nem lettek ellenőrizve. + Check Again Újraellenőrzés + Automatically Check for Updates Frissítések automatikus keresése + Installed version: {version} Telepített verzió: {version} + PhotoCraft {version} is available. Elérhető a PhotoCraft {version}. diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 6924c45609..1c3e1f3506 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -3133,3 +3133,16 @@ curves Smooth Haluskan Sent to {printer} Dikirim ke {printer} set in Print Settings… diatur di Pengaturan Cetak… ICO is limited to 256 × 256 pixels ICO dibatasi hingga 256 × 256 piksel +# PhotoCraft release checks. + Check for Updates… Periksa Pembaruan… + PhotoCraft Updates Pembaruan PhotoCraft + Checking for updates… Memeriksa pembaruan… + Open the release page to choose an installer for your system. Buka halaman rilis untuk memilih penginstal bagi sistem Anda. + Open Download Page Buka Halaman Unduhan + PhotoCraft is up to date. PhotoCraft sudah versi terbaru. + Could not check for updates. Tidak dapat memeriksa pembaruan. + Updates have not been checked yet. Pembaruan belum diperiksa. + Check Again Periksa Lagi + Automatically Check for Updates Periksa Pembaruan Secara Otomatis + Installed version: {version} Versi terpasang: {version} + PhotoCraft {version} is available. PhotoCraft {version} tersedia. diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 2d42c550cc..2989d6ec3e 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -4107,3 +4107,16 @@ navigator Zoom Zoom Sent to {printer} Inviato a {printer} set in Print Settings… impostato nelle impostazioni di stampa… ICO is limited to 256 × 256 pixels ICO è limitato a 256 × 256 pixel +# PhotoCraft release checks. + Check for Updates… Cerca aggiornamenti… + PhotoCraft Updates Aggiornamenti di PhotoCraft + Checking for updates… Ricerca aggiornamenti… + Open the release page to choose an installer for your system. Apri la pagina della versione per scegliere un programma di installazione per il tuo sistema. + Open Download Page Apri pagina di download + PhotoCraft is up to date. PhotoCraft è aggiornato. + Could not check for updates. Impossibile cercare aggiornamenti. + Updates have not been checked yet. Gli aggiornamenti non sono ancora stati verificati. + Check Again Controlla di nuovo + Automatically Check for Updates Cerca automaticamente aggiornamenti + Installed version: {version} Versione installata: {version} + PhotoCraft {version} is available. PhotoCraft {version} è disponibile. diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index e05f27d718..8faf69267c 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3821,3 +3821,16 @@ curves Smooth スムーズ Reset All Locked Settings ロックされた設定をすべて初期化 Copy Texture to Other Tools テクスチャを他のツールにコピー ICO is limited to 256 × 256 pixels ICO は 256 × 256 ピクセルまでです +# PhotoCraft release checks. + Check for Updates… アップデートを確認… + PhotoCraft Updates PhotoCraft のアップデート + Checking for updates… アップデートを確認中… + Open the release page to choose an installer for your system. リリースページでお使いのシステム用のインストーラーを選択してください。 + Open Download Page ダウンロードページを開く + PhotoCraft is up to date. PhotoCraft は最新です。 + Could not check for updates. アップデートを確認できませんでした。 + Updates have not been checked yet. まだアップデートを確認していません。 + Check Again 再確認 + Automatically Check for Updates アップデートを自動的に確認 + Installed version: {version} インストール済みのバージョン: {version} + PhotoCraft {version} is available. PhotoCraft {version} が利用可能です。 diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 7de9f61f10..89cf6970f8 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3319,3 +3319,16 @@ curves Smooth 매끄럽게 Sent to {printer} {printer}(으)로 전송됨 set in Print Settings… 인쇄 설정에서 지정… ICO is limited to 256 × 256 pixels ICO는 256 × 256픽셀로 제한됩니다 +# PhotoCraft release checks. + Check for Updates… 업데이트 확인… + PhotoCraft Updates PhotoCraft 업데이트 + Checking for updates… 업데이트 확인 중… + Open the release page to choose an installer for your system. 릴리스 페이지에서 시스템에 맞는 설치 프로그램을 선택하세요. + Open Download Page 다운로드 페이지 열기 + PhotoCraft is up to date. PhotoCraft가 최신 버전입니다. + Could not check for updates. 업데이트를 확인할 수 없습니다. + Updates have not been checked yet. 아직 업데이트를 확인하지 않았습니다. + Check Again 다시 확인 + Automatically Check for Updates 자동으로 업데이트 확인 + Installed version: {version} 설치된 버전: {version} + PhotoCraft {version} is available. PhotoCraft {version}을 사용할 수 있습니다. diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 4ed7d8a744..04665cedde 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -3904,3 +3904,16 @@ curves Smooth Vloeiend maken Sent to {printer} Verzonden naar {printer} set in Print Settings… instellen in de afdrukinstellingen… ICO is limited to 256 × 256 pixels ICO is beperkt tot 256 × 256 pixels +# PhotoCraft release checks. + Check for Updates… Controleren op updates… + PhotoCraft Updates PhotoCraft-updates + Checking for updates… Controleren op updates… + Open the release page to choose an installer for your system. Open de releasepagina om een installatieprogramma voor uw systeem te kiezen. + Open Download Page Downloadpagina openen + PhotoCraft is up to date. PhotoCraft is bijgewerkt. + Could not check for updates. Kan niet controleren op updates. + Updates have not been checked yet. Er is nog niet op updates gecontroleerd. + Check Again Opnieuw controleren + Automatically Check for Updates Automatisch op updates controleren + Installed version: {version} Geïnstalleerde versie: {version} + PhotoCraft {version} is available. PhotoCraft {version} is beschikbaar. diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index a27cb4af8d..3a984e5bdf 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3742,3 +3742,16 @@ curves Smooth Wygładź Sent to {printer} Wysłano do {printer} set in Print Settings… ustawiane w ustawieniach druku… ICO is limited to 256 × 256 pixels ICO jest ograniczony do 256 × 256 pikseli +# PhotoCraft release checks. + Check for Updates… Sprawdź aktualizacje… + PhotoCraft Updates Aktualizacje PhotoCraft + Checking for updates… Sprawdzanie aktualizacji… + Open the release page to choose an installer for your system. Otwórz stronę wydania, aby wybrać instalator dla swojego systemu. + Open Download Page Otwórz stronę pobierania + PhotoCraft is up to date. PhotoCraft jest aktualny. + Could not check for updates. Nie udało się sprawdzić aktualizacji. + Updates have not been checked yet. Aktualizacje nie zostały jeszcze sprawdzone. + Check Again Sprawdź ponownie + Automatically Check for Updates Automatycznie sprawdzaj aktualizacje + Installed version: {version} Zainstalowana wersja: {version} + PhotoCraft {version} is available. PhotoCraft {version} jest dostępny. diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 0a64497704..0254fe128f 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -3934,3 +3934,16 @@ layerLabel No Color Sem cor Sent to {printer} Enviado para {printer} set in Print Settings… definido nas configurações de impressão… ICO is limited to 256 × 256 pixels ICO é limitado a 256 × 256 pixels +# PhotoCraft release checks. + Check for Updates… Verificar atualizações… + PhotoCraft Updates Atualizações do PhotoCraft + Checking for updates… Verificando atualizações… + Open the release page to choose an installer for your system. Abra a página da versão para escolher um instalador para o seu sistema. + Open Download Page Abrir página de download + PhotoCraft is up to date. O PhotoCraft está atualizado. + Could not check for updates. Não foi possível verificar atualizações. + Updates have not been checked yet. As atualizações ainda não foram verificadas. + Check Again Verificar novamente + Automatically Check for Updates Verificar atualizações automaticamente + Installed version: {version} Versão instalada: {version} + PhotoCraft {version} is available. PhotoCraft {version} está disponível. diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 2dbbf4003c..da56499d37 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -3110,3 +3110,16 @@ curves Smooth Сгладить Gray Value (Median) Уровень серого (медиана) Integrated Density Интегральная плотность Length Длина +# PhotoCraft release checks. + Check for Updates… Проверить обновления… + PhotoCraft Updates Обновления PhotoCraft + Checking for updates… Проверка обновлений… + Open the release page to choose an installer for your system. Откройте страницу выпуска и выберите установщик для своей системы. + Open Download Page Открыть страницу загрузки + PhotoCraft is up to date. Установлена последняя версия PhotoCraft. + Could not check for updates. Не удалось проверить обновления. + Updates have not been checked yet. Обновления ещё не проверялись. + Check Again Проверить снова + Automatically Check for Updates Автоматически проверять обновления + Installed version: {version} Установленная версия: {version} + PhotoCraft {version} is available. Доступна версия PhotoCraft {version}. diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 01c37a18b2..09765d0643 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -3876,3 +3876,15 @@ cameraData Lens Lens Ink Characteristics Mürekkep Özellikleri Solidity: Doluluk: Redrawing Yeniden çiziliyor + Check for Updates… Güncellemeleri Denetle… + PhotoCraft Updates PhotoCraft Güncellemeleri + Checking for updates… Güncellemeler denetleniyor… + Open the release page to choose an installer for your system. Sisteminize uygun yükleyiciyi seçmek için sürüm sayfasını açın. + Open Download Page İndirme Sayfasını Aç + PhotoCraft is up to date. PhotoCraft güncel. + Could not check for updates. Güncellemeler denetlenemedi. + Updates have not been checked yet. Güncellemeler henüz denetlenmedi. + Check Again Yeniden Denetle + Automatically Check for Updates Güncellemeleri Otomatik Denetle + Installed version: {version} Yüklü sürüm: {version} + PhotoCraft {version} is available. PhotoCraft {version} kullanılabilir. diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 79ebc8df36..04a8cd9ab2 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3843,3 +3843,16 @@ curves Smooth Згладити Sent to {printer} Надіслано на {printer} set in Print Settings… задається в параметрах друку… ICO is limited to 256 × 256 pixels ICO обмежено розміром 256 × 256 пікселів +# PhotoCraft release checks. + Check for Updates… Перевірити оновлення… + PhotoCraft Updates Оновлення PhotoCraft + Checking for updates… Перевірка оновлень… + Open the release page to choose an installer for your system. Відкрийте сторінку випуску й виберіть інсталятор для своєї системи. + Open Download Page Відкрити сторінку завантаження + PhotoCraft is up to date. PhotoCraft оновлено до останньої версії. + Could not check for updates. Не вдалося перевірити оновлення. + Updates have not been checked yet. Оновлення ще не перевірялися. + Check Again Перевірити знову + Automatically Check for Updates Автоматично перевіряти оновлення + Installed version: {version} Встановлена версія: {version} + PhotoCraft {version} is available. Доступна версія PhotoCraft {version}. diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 1fea5e6b38..f10f8c0aa0 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3631,3 +3631,15 @@ curves Smooth Làm mượt Sent to {printer} Đã gửi tới {printer} set in Print Settings… đặt trong thiết lập in… ICO is limited to 256 × 256 pixels ICO giới hạn ở 256 × 256 pixel + Check for Updates… Kiểm tra bản cập nhật… + PhotoCraft Updates Bản cập nhật PhotoCraft + Checking for updates… Đang kiểm tra bản cập nhật… + Open the release page to choose an installer for your system. Mở trang phát hành để chọn bộ cài đặt cho hệ thống của bạn. + Open Download Page Mở trang tải xuống + PhotoCraft is up to date. PhotoCraft đã được cập nhật. + Could not check for updates. Không thể kiểm tra bản cập nhật. + Updates have not been checked yet. Chưa kiểm tra bản cập nhật. + Check Again Kiểm tra lại + Automatically Check for Updates Tự động kiểm tra bản cập nhật + Installed version: {version} Phiên bản đã cài: {version} + PhotoCraft {version} is available. PhotoCraft {version} đã có sẵn. diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 375b61c40b..820d448b78 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2754,3 +2754,16 @@ curves Smooth 平滑 Sent to {printer} 已发送到 {printer} set in Print Settings… 在打印设置中设置… ICO is limited to 256 × 256 pixels ICO 最大为 256 × 256 像素 +# PhotoCraft release checks. + Check for Updates… 检查更新… + PhotoCraft Updates PhotoCraft 更新 + Checking for updates… 正在检查更新… + Open the release page to choose an installer for your system. 打开发布页,选择适合您系统的安装包。 + Open Download Page 打开下载页面 + PhotoCraft is up to date. PhotoCraft 已是最新版本。 + Could not check for updates. 无法检查更新。 + Updates have not been checked yet. 尚未检查更新。 + Check Again 重新检查 + Automatically Check for Updates 自动检查更新 + Installed version: {version} 已安装版本:{version} + PhotoCraft {version} is available. PhotoCraft {version} 已发布。 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index de931038db..766dcda2bb 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2739,3 +2739,16 @@ curves Smooth 平滑 Sent to {printer} 已傳送至 {printer} set in Print Settings… 在列印設定中設定… ICO is limited to 256 × 256 pixels ICO 最大為 256 × 256 像素 +# PhotoCraft release checks. + Check for Updates… 檢查更新… + PhotoCraft Updates PhotoCraft 更新 + Checking for updates… 正在檢查更新… + Open the release page to choose an installer for your system. 開啟發佈頁,選擇適合您系統的安裝程式。 + Open Download Page 開啟下載頁面 + PhotoCraft is up to date. PhotoCraft 已是最新版本。 + Could not check for updates. 無法檢查更新。 + Updates have not been checked yet. 尚未檢查更新。 + Check Again 重新檢查 + Automatically Check for Updates 自動檢查更新 + Installed version: {version} 已安裝版本:{version} + PhotoCraft {version} is available. PhotoCraft {version} 已發佈。 diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 38118955c3..765bfb49a0 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -219,6 +219,7 @@ mod type_font_preview; pub mod type_panels_ui; pub mod type_tool; mod type_transform; +pub mod updates_ui; mod variables_ui; pub mod vector_ui; pub mod view_cmds; @@ -430,6 +431,8 @@ pub struct Services { /// Preferences ▸ General ▸ Beep When Done: the platform's default beep, played when a /// background job finishes successfully. `None` in the web build (and in tests). pub beep: Option, + /// Starts a background check for published releases (desktop only). + pub check_updates: Option, /// Files delivered asynchronously (web drag-and-drop): drained every frame. pub inbox: Option, /// OS clipboard images: copies go out, screenshots and images from other apps come in. @@ -735,6 +738,7 @@ pub struct PhotocraftApp { pub stroke_trace: stroke_trace::StrokeTrace, /// Preferences, autosave and snapping runtime state (see `prefs_ui`, `snap_ui`). pub(crate) prefs_rt: prefs_ui::Runtime, + pub(crate) updates_rt: updates_ui::Runtime, /// Close, Revert or Exit parked behind the unsaved-changes prompt (see `discard_ui`). pub(crate) discard: Option, /// The Open or Save dialog in progress, and the action waiting on it (see `file_dialog`). @@ -764,7 +768,8 @@ pub struct PhotocraftApp { } impl PhotocraftApp { - pub fn new(session: Session, services: Services) -> Self { + pub fn new(mut session: Session, mut services: Services) -> Self { + session.updates.check = services.check_updates.take(); let mut app = Self { session, ui: UiState::default(), @@ -880,6 +885,7 @@ impl PhotocraftApp { perf: Default::default(), stroke_trace: stroke_trace::StrokeTrace::from_env(), prefs_rt: Default::default(), + updates_rt: Default::default(), discard: None, file_dialog: None, tiff_options: None, @@ -1715,6 +1721,7 @@ impl eframe::App for PhotocraftApp { self.collect_screenshots(ctx); self.issue_screenshots(ctx); prefs_ui::tick(self, ctx); + updates_ui::tick(self, ctx); monitor_status::poll_frame(self, ctx, frame); // Control requests and persisted preferences can change the language in this frame. i18n::sync_context(ctx, &self.session.prefs().interface.language); @@ -1875,6 +1882,7 @@ impl eframe::App for PhotocraftApp { wide_angle_ui::show(self, &ctx); canvas::extra_windows(self, &ctx); notices::show(self, &ctx); + updates_ui::show(self, &ctx); gpu_status::show_fallback(self, &ctx); kys_import::show_offer(self, &ctx); if chrome && self.ui.panels.menu_bar && self.custom_titlebar && !self.ui.dialogs.is_empty() { diff --git a/crates/ui-egui/src/links.rs b/crates/ui-egui/src/links.rs index e01a19d93d..2042d996e0 100644 --- a/crates/ui-egui/src/links.rs +++ b/crates/ui-egui/src/links.rs @@ -102,7 +102,20 @@ mod tests { fn help_menu_lists_links_then_separator_then_system_info_and_about() { let app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); let help: Vec = crate::menus::menu_items(&app).into_iter().filter(|i| i.path == ["Help"]).map(|i| i.id).collect(); - assert_eq!(help, ["help.discord", "help.website", "help.artcraftWebsite", "help.github", "help.reportIssue", "---", "help.systemInfo", "help.about"]); + assert_eq!( + help, + [ + "help.discord", + "help.website", + "help.artcraftWebsite", + "help.github", + "help.reportIssue", + "help.checkForUpdates", + "---", + "help.systemInfo", + "help.about" + ] + ); for (id, _) in COMMANDS { assert!(crate::menus::is_live(id) && crate::menus::is_enabled(&app, id), "{id}"); } diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 403994ac10..9caafa53b4 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -167,6 +167,9 @@ pub(crate) fn invoke_unguarded(app: &mut PhotocraftApp, ctx: &egui::Context, id: app.ui.tool = tool; return Ok(json!({"tool": tool})); } + if id == "help.checkForUpdates" { + return crate::updates_ui::check(app, ctx, params); + } if id == "ui.symmetryTransform" { return crate::symmetry_ui::begin(app).map(|_| Value::Null); } @@ -1075,7 +1078,13 @@ pub fn menu_items(app: &PhotocraftApp) -> Vec { items.insert(after + 1 + k, it); } } - // Help: the link items, a separator, then System Info and About. + // Keep the update command with the links, ahead of System Info and About. + if let Some(at) = items.iter().position(|i| i.id == "help.checkForUpdates") { + let update = items.remove(at); + let before = items.iter().position(|i| i.id == "help.systemInfo" || i.id == "help.about").unwrap_or(items.len()); + items.insert(before, update); + } + // Help: the link items and update check, a separator, then System Info and About. if let Some(at) = items.iter().position(|i| i.id == "help.systemInfo" || i.id == "help.about") { items.insert( at, diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs index db908ae23f..6a6bc22e88 100644 --- a/crates/ui-egui/src/prefs_ui.rs +++ b/crates/ui-egui/src/prefs_ui.rs @@ -1026,6 +1026,7 @@ fn humanize(key: &str) -> String { "appearanceMode" => return "Appearance Mode".into(), "darkTheme" => return "Dark Theme".into(), "lightTheme" => return "Light Theme".into(), + "automaticallyCheckUpdates" => return "Automatically Check for Updates".into(), _ => {} } // These controls appear only for WebP, so reuse the existing translated labels. diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 42997fe62c..19bf966e8c 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -1248,6 +1248,9 @@ pub struct UiState { /// Non-blocking notices (import/export warnings, files that couldn't open), newest last. #[serde(default)] pub notices: Vec, + /// Non-modal release-check window; readable and controllable through `ui.inspect`/`ui.set`. + #[serde(default)] + pub updates_open: bool, /// Pending GPU fallback warning, visible to automation. #[serde(default)] pub gpu_fallback_notice: Option, @@ -1342,6 +1345,7 @@ impl Default for UiState { status: String::new(), status_error: false, notices: Vec::new(), + updates_open: false, gpu_fallback_notice: None, kys_offer: None, slow_refresh_noticed: Vec::new(), diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs new file mode 100644 index 0000000000..bbbbc7bba9 --- /dev/null +++ b/crates/ui-egui/src/updates_ui.rs @@ -0,0 +1,233 @@ +//! One background check at startup and a non-modal window for release information. + +use photocraft_engine::updates_cmds::Status; +use serde_json::Value; + +use crate::PhotocraftApp; + +#[derive(Default)] +pub(crate) struct Runtime { + startup_checked: bool, + notified_version: Option, +} + +pub(crate) fn check(app: &mut PhotocraftApp, _ctx: &egui::Context, params: Value) -> Result { + let result = app.run("help.checkForUpdates", params)?; + app.ui.updates_open = true; + app.updates_rt.startup_checked = true; + Ok(result) +} + +pub(crate) fn tick(app: &mut PhotocraftApp, ctx: &egui::Context) { + // `updates.status` also polls (automation may consume the result before this frame). + app.session.updates.poll(); + if let Status::Available { release } = &app.session.updates.status + && app.updates_rt.notified_version.as_ref() != Some(&release.version) + { + app.updates_rt.notified_version = Some(release.version.clone()); + app.ui.updates_open = true; + } + if app.session.updates.check.is_none() { + return; + } + if !app.updates_rt.startup_checked { + app.updates_rt.startup_checked = true; + if app.session.prefs().general.automatically_check_updates && matches!(app.session.updates.status, Status::Idle) { + let _ = app.run("help.checkForUpdates", serde_json::json!({})); + } + } + if matches!(app.session.updates.status, Status::Checking) { + ctx.request_repaint_after(std::time::Duration::from_millis(100)); + } +} + +pub(crate) fn show(app: &mut PhotocraftApp, ctx: &egui::Context) { + if !app.ui.updates_open { + return; + } + let mut open = true; + let status = app.session.updates.status.clone(); + let mut retry = false; + let mut download = None; + egui::Window::new(tl!("PhotoCraft Updates")) + .id(egui::Id::new("photocraft_updates")) + .open(&mut open) + .collapsible(false) + .resizable(false) + .default_width(380.0) + .show(ctx, |ui| { + let t = crate::theme::Tokens::get(ctx); + ui.label(crate::i18n::fmt(crate::i18n::t("Installed version: {version}"), &[("version", photocraft_engine::build_info::VERSION)])); + ui.add_space(8.0); + match &status { + Status::Checking => { + ui.horizontal(|ui| { + ui.spinner(); + ui.label(tl!("Checking for updates…")); + }); + } + Status::Available { release } => { + ui.label(crate::i18n::fmt(crate::i18n::t("PhotoCraft {version} is available."), &[("version", &release.version)])); + ui.label(tl!("Open the release page to choose an installer for your system.")); + if crate::widgets::primary_button(ui, tl!("Open Download Page"), 160.0).clicked() { + download = Some(release.url.clone()); + } + } + Status::UpToDate => { + ui.label(tl!("PhotoCraft is up to date.")); + } + Status::Failed { message } => { + ui.colored_label(t.warning, tl!("Could not check for updates.")); + ui.label(message); + } + Status::Idle => { + ui.label(tl!("Updates have not been checked yet.")); + } + } + if !matches!(status, Status::Checking) && ui.button(tl!("Check Again")).clicked() { + retry = true; + } + }); + app.ui.updates_open = open; + if let Some(url) = download { + crate::links::open(app, ctx, &url); + } + if retry { + let _ = check(app, ctx, serde_json::json!({})); + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{Services, menus}; + use photocraft_engine::{Session, updates_cmds::Release}; + use std::sync::{Arc, Mutex, mpsc}; + + type Sender = Arc>>>; + + fn app() -> (PhotocraftApp, Arc>, Sender) { + let calls = Arc::new(Mutex::new(0)); + let count = calls.clone(); + let sender = Arc::new(Mutex::new(None)); + let tx = sender.clone(); + let app = PhotocraftApp::new( + Session::new(), + Services { + check_updates: Some(Box::new(move || { + *count.lock().unwrap() += 1; + let (sender, receiver) = mpsc::channel(); + *tx.lock().unwrap() = Some(sender); + Ok(receiver) + })), + ..Default::default() + }, + ); + (app, calls, sender) + } + + fn at(app: &mut PhotocraftApp, ctx: &egui::Context, time: f64) { + let mut output = ctx.run_ui(egui::RawInput { time: Some(time), ..Default::default() }, |ui| tick(app, ui.ctx())); + output.textures_delta.clear(); + } + + #[test] + fn automatic_check_runs_once_per_launch_even_after_days_or_preference_changes() { + let (mut app, calls, sender) = app(); + let ctx = egui::Context::default(); + at(&mut app, &ctx, 0.0); + at(&mut app, &ctx, 1.0); + at(&mut app, &ctx, 2.0); + assert_eq!(*calls.lock().unwrap(), 1); + sender.lock().unwrap().as_ref().unwrap().send(Ok(None)).unwrap(); + at(&mut app, &ctx, 3.0); + assert!(!app.ui.updates_open, "automatic up-to-date checks stay quiet"); + at(&mut app, &ctx, 86400.0); + app.session.edit_prefs(|p| p.general.automatically_check_updates = false); + at(&mut app, &ctx, 86401.0); + app.session.edit_prefs(|p| p.general.automatically_check_updates = true); + at(&mut app, &ctx, 172800.0); + assert_eq!(*calls.lock().unwrap(), 1, "no periodic checks or preference-triggered rechecks"); + let (mut restarted, restarted_calls, _) = self::app(); + at(&mut restarted, &ctx, 0.0); + assert_eq!(*restarted_calls.lock().unwrap(), 1, "the next launch checks again"); + } + + #[test] + fn startup_opt_out_and_failed_checks_do_not_retry_automatically() { + let (mut disabled, calls, _) = app(); + let ctx = egui::Context::default(); + disabled.session.edit_prefs(|p| p.general.automatically_check_updates = false); + at(&mut disabled, &ctx, 0.0); + disabled.session.edit_prefs(|p| p.general.automatically_check_updates = true); + at(&mut disabled, &ctx, 86400.0); + assert_eq!(*calls.lock().unwrap(), 0, "opt-out is evaluated at startup"); + + let (mut failed, calls, sender) = app(); + at(&mut failed, &ctx, 0.0); + sender.lock().unwrap().as_ref().unwrap().send(Err("offline".into())).unwrap(); + at(&mut failed, &ctx, 1.0); + at(&mut failed, &ctx, 172800.0); + assert_eq!(*calls.lock().unwrap(), 1); + assert!(!failed.ui.updates_open, "an automatic failure stays quiet"); + } + + #[test] + fn manual_check_works_when_automatic_checks_are_off_and_opens_status() { + let (mut app, calls, sender) = app(); + let ctx = egui::Context::default(); + app.session.edit_prefs(|p| p.general.automatically_check_updates = false); + assert!(menus::is_enabled(&app, "help.checkForUpdates")); + menus::invoke(&mut app, &ctx, "help.checkForUpdates", serde_json::json!({})).unwrap(); + assert!(app.ui.updates_open); + assert_eq!(*calls.lock().unwrap(), 1); + sender.lock().unwrap().as_ref().unwrap().send(Err("offline".into())).unwrap(); + at(&mut app, &ctx, 1.0); + assert!(matches!(app.session.updates.status, Status::Failed { .. })); + let mut web = PhotocraftApp::new(Session::new(), Services::default()); + assert!(!menus::is_enabled(&web, "help.checkForUpdates")); + at(&mut web, &ctx, 2.0); + assert_eq!(web.session.updates.status, Status::Idle); + } + + #[test] + fn available_release_notifies_once_even_when_automation_polls_first() { + let (mut app, _, sender) = app(); + let ctx = egui::Context::default(); + at(&mut app, &ctx, 0.0); + sender + .lock() + .unwrap() + .as_ref() + .unwrap() + .send(Ok(Some(Release { version: "99.0.0".into(), url: "https://github.com/storytold/photocraft/releases/tag/v99.0.0".into() }))) + .unwrap(); + app.run("updates.status", serde_json::json!({})).unwrap(); + at(&mut app, &ctx, 1.0); + assert!(app.ui.updates_open); + app.ui.updates_open = false; + at(&mut app, &ctx, 2.0); + assert!(!app.ui.updates_open); + } + + #[test] + fn update_window_is_drivable_and_bad_state_changes_are_atomic() { + let (mut app, _, _) = app(); + let ctx = egui::Context::default(); + let call = |app: &mut PhotocraftApp, method: &str, params: Value| { + let (req, _) = crate::control::ControlRequest::new(method, params); + match crate::control::handle(app, &ctx, &req) { + crate::control::Outcome::Done(value) => value, + _ => panic!("expected an immediate reply"), + } + }; + assert_eq!(call(&mut app, "ui.set", serde_json::json!({"updatesOpen": true}))["ok"], true); + let inspected = call(&mut app, "ui.inspect", serde_json::json!({})); + assert_eq!(inspected["result"]["updatesOpen"], true); + assert_eq!(inspected["result"]["updates"]["supported"], true); + assert_eq!(call(&mut app, "ui.set", serde_json::json!({"updatesOpen": false, "maskTarget": "bad"}))["ok"], false); + assert!(app.ui.updates_open); + assert_eq!(call(&mut app, "ui.set", serde_json::json!({"updatesOpen": false}))["ok"], true); + assert!(!app.ui.updates_open); + } +} diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 771fec92e9..0b8054756e 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -267,6 +267,19 @@ toolbox colour as `backgroundColor: [r,g,b]` (0..1), so reusing it does not foll changes. Up to 256 presets are kept. Invalid saved entries are skipped independently; other presets and preferences still load. Automatic Recent configurations are separate follow-up work. +## Update checks + +On desktop, `engine.execute` with `help.checkForUpdates` and `{}` starts a background +check; `updates.status` returns `{supported, currentVersion, result}`. The result's `status` +is `idle`, `checking`, `upToDate`, `available` (with `release: {version, url}`), or `failed` +(with `message`). No document is required and neither command adds history or journal entries. +Headless and web sessions without a release transport report `supported: false`. + +Set `general.automaticallyCheckUpdates` with `prefs.set` to enable or disable the next +desktop startup's single check (enabled by default). Manual checks still work when automatic checks are off. +`ui.inspect` includes `updates` and `updatesOpen`; `ui.set {"updatesOpen": false}` closes +the non-modal update window. + ## Snapping With View › Snap on, tool gestures snap to the View › Snap To targets (guides and grid while they diff --git a/docs/gaps.md b/docs/gaps.md index c952bac81b..2461639fe1 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where PhotoCraft falls short of Photoshop -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (in-app startup/manual release checks implemented under G17; 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 @@ -252,8 +252,11 @@ what an agent can't finish alone. ## Platform gaps ### G17. Platforms and distribution -- **Missing:** Windows code signing (material not obtained), in-app update check (DIST-220-1, - #2650, #2375), in-app bug report (DIST-220-3), Flathub (#173), +- **Implemented (2026-10-14):** in-app update check (DIST-220-1, #2650, #2375): native + one background check at launch, persisted opt-out, Help manual check and official + release-page link. Installer download/installation remains a user action. +- **Missing:** Windows code signing (material not obtained), + in-app bug report (DIST-220-3), Flathub (#173), starting without a GPU adapter (#2519, #2412), Windows 7 (#2310, out of scope), Intel Macs with OpenCore (#1859). - **Estimate:** 30–60 h. **Human:** signing certificates. @@ -262,6 +265,7 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| +| 2026-10-14 | minor | Implemented stable release checks once per launch, opt-out and manual status/download link (DIST-220-1); estimates unchanged | | 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 | diff --git a/docs/releasing.md b/docs/releasing.md index 6d35b6379e..cb7f809dff 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -9,6 +9,22 @@ This is PhotoCraft's implementation of the shared [release playbook](release-playbook.md). User-facing names say **PhotoCraft**. Files, binaries and ids stay lowercase (`photocraft---.`, `ai.storyteller.photocraft`). +## In-app update checks + +The native desktop app checks the public GitHub latest-release endpoint in a background +thread once at launch, with no periodic checks or automatic retries. Preferences › General › Automatically +Check for Updates disables the startup check; Help › Check for Updates runs one manually. +Checks use a 15-second timeout and a 1 MiB response limit, need no GitHub token, and send +no document or personal data. Network failures are quiet during automatic checks and visible +in the manual check window. Concurrent requests share one check. +HTTPS validates certificates and host names against the operating system's trust store. + +Tags must be semantic versions (`v0.8.0` or `0.8.0`); only published stable versions newer +than the installed workspace version trigger a notice. The notice opens the official release +page to choose an installer; installation remains a user action. Drafts and prereleases do +not trigger it. Web/headless frontends have no update transport. No release-workflow changes +are required: publishing a newer stable GitHub Release makes it discoverable. + ## Cutting a release 1. **Bump the version** on `main`. The only place it lives is `[workspace.package] version` diff --git a/docs/scorecard.md b/docs/scorecard.md index 56a16654bd..42a6a82f3e 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -9,11 +9,11 @@ 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) | 29 | 13 | 1 | | -| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 157 (target 0) | +| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 158 (target 0) | | [Type](#type) | 4 | 3 | 2 | | | [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) | | [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present | -| [Distribution](#distribution) | 5 | 4 | 2 | | +| [Distribution](#distribution) | 6 | 4 | 1 | | | [Open bugs](#open-bugs) | 29 | 2 | 1 | | ## Performance @@ -176,7 +176,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t ## Workspace and UI -**Settings that do nothing: 26 of 157** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. +**Settings that do nothing: 26 of 158** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `file_handling.save_in_background`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`. @@ -262,7 +262,7 @@ Never-crash attribute on 28 of 28 crate roots. | DIST-4 | Flatpak single-file bundles, x86_64 and aarch64 | done | | release.yml:204-216 (#163) | | DIST-5 | Web build (wasm32, trunk) | done | | release.yml:312 | | DIST-6 | FreeBSD 14 x86_64 tar.gz (/usr/local tree) built in a FreeBSD VM | partial | | release.yml:242-283 (freebsd job) + packaging/freebsd/package.sh; layout checked with --dry-run, not yet produced by a release run | -| DIST-220-1 | Help > Check for Updates plus an opt-out periodic release-feed check on all desktops | missing | [#220](https://github.com/storytold/photocraft/issues/220) | No update check in crates | +| DIST-220-1 | Help > Check for Updates plus an opt-out startup release-feed check on all desktops | done | [#220](https://github.com/storytold/photocraft/issues/220) | 2026-10-12: updates_cmds + native HTTPS service; one check per launch, persisted opt-out, non-modal manual status/download page; version, timeout, malformed response and startup tests | | DIST-220-2 | Windows ARM64 (aarch64-pc-windows-msvc) in the release matrix, signed like x64 | done | [#220](https://github.com/storytold/photocraft/issues/220) | release.yml has { arch: arm64, target: aarch64-pc-windows-msvc } in the Windows matrix, and .github/workflows/windows-arm64.yml packages that MSI, installs it on a Windows 11 ARM64 runner, checks the installed binaries are ARM64 and runs the CLI natively before uninstalling. Signing takes the same path as x64: the secrets are optional and a missing one produces an unsigned artifact and a warning (see DIST-2) | | DIST-220-3 | In-app bug report with reviewable diagnostics that opens a prefilled issue | missing | [#220](https://github.com/storytold/photocraft/issues/220) | No bug report dialog in crates | | DIST-220-4 | Translation coverage per language reported by xtask; RTL layout for Arabic and Hebrew | partial | [#220](https://github.com/storytold/photocraft/issues/220) | `cargo xtask i18n-coverage` reports per-language coverage (#427); RTL languages mirror the shell (`direction.rs`), not yet panel interiors or dialogs | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index c11ad8aff8..12853a1ba2 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,6 +1,6 @@ # PhotoCraft vs Adobe Photoshop: target-app parity -> **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 +> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-14 · **Change:** minor (native startup/manual release checks; `.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); @@ -82,7 +82,7 @@ Weights reflect what a working Photoshop user depends on (photographers, retouch | Stability | 10% | 45% | 150–250 | Never-crash lints on 28/28 crates, `panic_hunt` in the gate, atomic saves; but field reports of freezes (#2518 Type tool 60 s on macOS), GPU panics (#2020, #1215), no-GPU start failures (#2519, #2412) | [gaps.md](gaps.md) | | Hardware | 5% | 50% | 80–150 | GPU compositor (wgpu), pen pressure on all desktops but tilt/rotation not on Windows, Wayland pen broken (#2622), no HDR/EDR output, monitor profile auto-detected on macOS only | [hardware-parity.md](hardware-parity.md) | | Localization | 5% | 55% | 80–140 | 7 of the 12 key languages at 100% of measured UI keys; Hindi and Arabic absent, Vietnamese catalog added 2026-10-12 (#2636, coverage not re-measured); no RTL UI; engine messages English | [localization-parity.md](localization-parity.md) | -| Platforms | 5% | 80% | 30–60 | macOS (notarized), Windows (unsigned), Linux (AppImage/deb/rpm/Flatpak), web, FreeBSD partial; Windows ARM64 is packaged and install-checked by `.github/workflows/windows-arm64.yml` (DIST-220-2); no in-app updates | [scorecard.md](scorecard.md#distribution) | +| Platforms | 5% | 80% | 30–60 | macOS (notarized), Windows (unsigned), Linux (AppImage/deb/rpm/Flatpak), web, FreeBSD partial; Windows ARM64 is packaged and install-checked by `.github/workflows/windows-arm64.yml` (DIST-220-2); native release checks with opt-out (2026-10-14); no automatic installer | [scorecard.md](scorecard.md#distribution) | | Ecosystem (plug-ins, scripting, presets, libraries) | 5% | 15% | 250–450 | No .8BF hosting (#2647), no UXP/ExtendScript; .atn load/save (2026-10-12, 112 events, the rest kept verbatim), .abr/.grd/.pat/.aco/.ase/.cube supported | [gaps.md](gaps.md) | | AI features | 5% | 10% | 300–600 | No ML runtime at all (scorecard AUTO-219-7); classical substitutes only. Needs an owner decision and openly licensed models (#41) | [gaps.md](gaps.md) | | **Weighted** | 100% | **~46%** | **2,340–4,100** | | | @@ -565,6 +565,7 @@ See [method, raw measurements and reproduction](five-algorithm-performance.md). | Date | Change | Summary | |---|---|---| +| 2026-10-14 | minor | Implemented native background/manual stable release checks with opt-out and download-page link (DIST-220-1); headline estimates unchanged | | 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 | diff --git a/scorecard/distribution.toml b/scorecard/distribution.toml index 1a65920852..95a06c3736 100644 --- a/scorecard/distribution.toml +++ b/scorecard/distribution.toml @@ -42,10 +42,10 @@ note = "release.yml:242-283 (freebsd job) + packaging/freebsd/package.sh; layout [[item]] id = "DIST-220-1" -target = "Help > Check for Updates plus an opt-out periodic release-feed check on all desktops" -status = "missing" +target = "Help > Check for Updates plus an opt-out startup release-feed check on all desktops" +status = "done" issue = 220 -note = "No update check in crates" +note = "2026-10-12: updates_cmds + native HTTPS service; one check per launch, persisted opt-out, non-modal manual status/download page; version, timeout, malformed response and startup tests" [[item]] id = "DIST-220-2" From c2b56ef5c23e050e203ee212d521a5c43595239f Mon Sep 17 00:00:00 2001 From: geduful Date: Wed, 14 Oct 2026 10:10:52 +0000 Subject: [PATCH 060/649] fix(gpu): record a caught compositor error on the device's health flag An error scope swallows the error DeviceHealth's uncaptured-error handler would have recorded, and scoped_work returns before submit_batch can poll the device: a watched compositor never learned of the failure and kept handing it work every frame. device_loss::destroyed_device_returns_an_error_not_a_panic caught this. scoped_work now takes the health flag and hands a caught error to the new DeviceHealth::caught, which polls first so a lost device is recorded as a Fault::Lost rather than as an error. Only a watched caller records: the recovery tests render again after a transient validation error with no health flag set, and must keep doing so. Also drops scoped_work's watched argument, which this change had left unused. --- crates/gpu/src/health.rs | 34 +++++++++++++++++++++++++++++----- crates/gpu/src/lib.rs | 30 +++++++++++++++++++++--------- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/crates/gpu/src/health.rs b/crates/gpu/src/health.rs index cb1a116c4b..a7238e0b1d 100644 --- a/crates/gpu/src/health.rs +++ b/crates/gpu/src/health.rs @@ -96,11 +96,27 @@ impl DeviceHealth { self.0.errors.fetch_add(1, Ordering::Relaxed); let text = e.to_string(); log::error!("uncaptured wgpu error: {text}"); - // Errors about invalid or lost objects follow a device loss whose callback may not have - // run yet (it fires on the next poll). - let lower = text.to_ascii_lowercase(); - let fault = if lower.contains("lost") || lower.contains("destroyed") { Fault::Lost(first_line(&text)) } else { Fault::Error(first_line(&text)) }; - self.mark(fault); + self.mark(fault_of(&text)); + } + + /// Record an error an error scope caught. + /// + /// [`DeviceHealth::watch`]'s uncaptured-error handler never sees a scoped error, so without + /// this a watched device would keep being handed to a GPU that has already failed. Polls + /// first: a lost device is a [`Fault::Lost`], and its callback may not have run yet (it fires + /// on a poll, and `Device::poll` panics on a lost device). + pub fn caught(&self, device: &wgpu::Device, error: &wgpu::Error) { + if !self.is_ok() { + return; + } + #[cfg(not(target_arch = "wasm32"))] + self.wait(device, None); + #[cfg(target_arch = "wasm32")] + let _ = device; + if !self.is_ok() { + return; + } + self.mark(fault_of(&error.to_string())); } /// Mark the device unusable. The first fault is kept; a later device loss upgrades an error. @@ -163,6 +179,14 @@ impl DeviceHealth { } } +/// The fault a wgpu error message stands for. Errors about invalid or lost objects follow a +/// device loss whose callback may not have run yet (it fires on the next poll), so they count as +/// a loss rather than as an error. +fn fault_of(text: &str) -> Fault { + let lower = text.to_ascii_lowercase(); + if lower.contains("lost") || lower.contains("destroyed") { Fault::Lost(first_line(text)) } else { Fault::Error(first_line(text)) } +} + fn first_line(s: &str) -> String { let line = s.lines().map(str::trim).find(|l| !l.is_empty()).unwrap_or(""); let mut out: String = line.chars().take(200).collect(); diff --git a/crates/gpu/src/lib.rs b/crates/gpu/src/lib.rs index c935ac7027..7fabc4aaf7 100644 --- a/crates/gpu/src/lib.rs +++ b/crates/gpu/src/lib.rs @@ -571,18 +571,30 @@ fn first_error(device: &wgpu::Device, f: impl FnOnce() -> T) -> (T, Option(device: &wgpu::Device, watched: bool, f: impl FnOnce() -> Result) -> Result { - // Always use error scopes on native to catch synchronous validation errors (e.g. invalid buffer - // in queue.write_buffer). On WebGPU, errors are async so scopes don't help; rely on health. +/// Runs `f` inside the error scopes of [`first_error`], turning a reported error into +/// [`Unsupported`] instead of letting it escape to wgpu's panic handler. +/// +/// Every native caller needs this, watched or not: a validation error (writing into a destroyed +/// or too-small buffer, say) is raised synchronously and never reaches the health callbacks, so a +/// watched compositor still panicked on it. WebGPU reports its errors asynchronously, long after +/// the scope has popped, so wasm relies on the health callbacks alone. +/// +/// A scope also swallows the error that [`DeviceHealth`]'s uncaptured-error handler would have +/// recorded, so a reported error is handed back to `health`: a watched device must stop being +/// used and let the caller fall back to the CPU compositor. +fn scoped_work(device: &wgpu::Device, health: Option, f: impl FnOnce() -> Result) -> Result { + // WebGPU errors arrive asynchronously; its callers still use the health callbacks. if cfg!(target_arch = "wasm32") { return f(); } let (result, error) = first_error(device, f); match error { - Some(error) => Err(Unsupported(format!("GPU work failed: {error}"))), + Some(error) => { + if let Some(health) = health.as_ref() { + health.caught(device, &error); + } + Err(Unsupported(format!("GPU work failed: {error}"))) + } None => result, } } @@ -919,7 +931,7 @@ impl Compositor { region: Rect, mut sink: impl FnMut(&mut wgpu::CommandEncoder, ChunkOut<'_>), ) -> Result { - let result = scoped_work(device, self.health.is_some(), || { + let result = scoped_work(device, self.health.clone(), || { let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: Some("pc_compose") }); let stats = self.encode_inner(device, queue, &mut encoder, doc, region, &mut sink, true)?; queue.submit([encoder.finish()]); @@ -941,7 +953,7 @@ impl Compositor { region: Rect, sink: &mut dyn FnMut(&mut wgpu::CommandEncoder, ChunkOut<'_>), ) -> Result { - let result = scoped_work(device, self.health.is_some(), || self.encode_inner(device, queue, encoder, doc, region, sink, false)); + let result = scoped_work(device, self.health.clone(), || self.encode_inner(device, queue, encoder, doc, region, sink, false)); if result.is_err() { self.discard_failed_work(); } From a16b352f59c1193140c27455ad282c9d9683407e Mon Sep 17 00:00:00 2001 From: Reynold Hu <88558425+reynold-hu@users.noreply.github.com> Date: Wed, 14 Oct 2026 23:18:49 +0800 Subject: [PATCH 061/649] engine: Generate Image Assets needs the Generator preference enabled --- crates/engine/src/web_cmds.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/web_cmds.rs b/crates/engine/src/web_cmds.rs index 595ad21956..ac96f0a10c 100644 --- a/crates/engine/src/web_cmds.rs +++ b/crates/engine/src/web_cmds.rs @@ -1445,7 +1445,7 @@ fn image_assets(s: &mut Session, p: &Value) -> Result { /// After a save: regenerate the document's image assets when Generate › Image Assets is on. pub fn on_saved(s: &Session, index: usize) -> Option { let d = s.documents().get(index)?; - if !s.file_menu.image_assets.contains(&d.doc.id) || cfg!(target_arch = "wasm32") { + if !s.file_menu.image_assets.contains(&d.doc.id) || !s.prefs().plug_ins.generator_enabled || cfg!(target_arch = "wasm32") { return None; } let dir = assets_dir(d.path.as_deref()?); @@ -1462,6 +1462,16 @@ pub fn specs() -> Vec { fn has_doc(s: &Session) -> std::result::Result<(), String> { s.active().map(|_| ()).ok_or_else(|| "no document open".into()) } + + /// Generate ▸ Image Assets needs Preferences ▸ Plug-ins ▸ Generator enabled, as in + /// Photoshop (where "Enable Generator" is unchecked until turned on). + fn generator_enabled(s: &Session) -> std::result::Result<(), String> { + has_doc(s)?; + if !s.prefs().plug_ins.generator_enabled { + return Err("Enable Generator in Preferences ▸ Plug-ins".into()); + } + Ok(()) + } vec![ spec!( "file.export.saveForWebLegacy", @@ -1496,7 +1506,7 @@ pub fn specs() -> Vec { &["File", "Generate"], None, r##"{"on":bool? (default: toggle),"dir":folder? (default -assets next to the file)} → {enabled, files, errors}; layers named like "foo.png", "200% foo@2x.png", "48x48 icons/a.png8", "photo.jpg80%" are exported, now and after each save"##, - has_doc, + generator_enabled, image_assets ), ] From be01d7ee0e15be39e803d57d9e7a5ef74117a074 Mon Sep 17 00:00:00 2001 From: Reynold Hu <88558425+reynold-hu@users.noreply.github.com> Date: Wed, 14 Oct 2026 23:18:49 +0800 Subject: [PATCH 062/649] engine: test that Image Assets needs the Generator preference --- crates/engine/src/web_cmds/tests.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/engine/src/web_cmds/tests.rs b/crates/engine/src/web_cmds/tests.rs index c3ffe6edce..4db1912bb3 100644 --- a/crates/engine/src/web_cmds/tests.rs +++ b/crates/engine/src/web_cmds/tests.rs @@ -511,10 +511,35 @@ fn generator_naming_grammar() { assert!(parse_defaults("defaults are nice", 72.0).is_none()); } +#[test] +fn image_assets_needs_the_generator_preference() { + let dir = tmp("generator_pref"); + let mut s = session(8); + let id = s.active().unwrap().active_layer.unwrap(); + s.execute("layer.renameLayer", json!({"layer": id.0, "name": "logo.png"})).unwrap(); + assert!(!s.prefs().plug_ins.generator_enabled, "off by default, as in Photoshop"); + assert!(!s.is_enabled("file.generate.imageAssets"), "unavailable until it is enabled"); + assert!(s.execute("file.generate.imageAssets", json!({"dir": dir})).is_err()); + + s.execute("prefs.set", json!({"path": "plugIns.generatorEnabled", "value": true})).unwrap(); + assert!(s.is_enabled("file.generate.imageAssets")); + assert_eq!(s.execute("file.generate.imageAssets", json!({"dir": dir})).unwrap()["enabled"], true); + s.active_mut().unwrap().path = Some(format!("{dir}/doc.psd")); + assert!(crate::automate_cmds::document_saved(&mut s, 0).is_some(), "assets are written on save"); + + // Turning it off again takes the menu item away and stops the export, even for a document + // left switched on. + s.execute("prefs.set", json!({"path": "plugIns.generatorEnabled", "value": false})).unwrap(); + assert!(!s.is_enabled("file.generate.imageAssets")); + assert!(crate::automate_cmds::document_saved(&mut s, 0).is_none(), "no assets while Generator is off"); +} + #[test] fn image_assets_are_generated_now_and_on_save() { let dir = tmp("assets"); let mut s = session(8); + // Preferences ▸ Plug-ins ▸ Generator enabled: the feature is opt-in. + s.execute("prefs.set", json!({"path": "plugIns.generatorEnabled", "value": true})).unwrap(); let id = s.active().unwrap().active_layer.unwrap(); s.execute("layer.renameLayer", json!({"layer": id.0, "name": "logo.png, 50% small/logo.gif, logo.jpg80%"})).unwrap(); let r = s.execute("file.generate.imageAssets", json!({"dir": dir})).unwrap(); From f415b7522235ff9f0f091dd8a8bbeeebf0d61a05 Mon Sep 17 00:00:00 2001 From: Reynold Hu <88558425+reynold-hu@users.noreply.github.com> Date: Wed, 14 Oct 2026 23:18:49 +0800 Subject: [PATCH 063/649] ui: the Image Assets menu item needs Generator enabled --- crates/ui-egui/src/file_ui.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/ui-egui/src/file_ui.rs b/crates/ui-egui/src/file_ui.rs index c3b8abc4d7..0ff3e3927f 100644 --- a/crates/ui-egui/src/file_ui.rs +++ b/crates/ui-egui/src/file_ui.rs @@ -1420,6 +1420,10 @@ mod tests { assert_eq!(checked(&app, "view.lockSlices"), Some(false)); crate::menus::invoke(&mut app, &ctx, "view.lockSlices", json!({})).unwrap(); assert_eq!(checked(&app, "view.lockSlices"), Some(true)); + // Generator is opt-in (Preferences ▸ Plug-ins), as in Photoshop: the menu item is + // unavailable until it is enabled. + assert!(crate::menus::invoke(&mut app, &ctx, "file.generate.imageAssets", json!({})).is_err()); + app.run("prefs.set", json!({"path": "plugIns.generatorEnabled", "value": true})).unwrap(); crate::menus::invoke(&mut app, &ctx, "file.generate.imageAssets", json!({})).unwrap(); assert_eq!(checked(&app, "file.generate.imageAssets"), Some(true)); // Form dialogs open for the rest. From e4474298e1f7f5da035174f23218bb03a9dcd2d6 Mon Sep 17 00:00:00 2001 From: Reynold Hu <88558425+reynold-hu@users.noreply.github.com> Date: Wed, 14 Oct 2026 23:18:50 +0800 Subject: [PATCH 064/649] engine: show Generator enabled in Preferences, it is wired --- crates/engine/src/prefs.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index b163d40d88..138542a038 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -1066,7 +1066,6 @@ pub const HIDDEN_UNTIL_IMPLEMENTED: &[&str] = &[ "unitsAndRulers.gutter", "plugIns.showExtensionPanels", "plugIns.allowScriptsToConnect", - "plugIns.generatorEnabled", "type.textEngine", "type.recentFonts", "enhancedControls.scrubbySliderAcceleration", From 731bb2aa986f298bca7414900e6996e76ce55709 Mon Sep 17 00:00:00 2001 From: Reynold Hu <88558425+reynold-hu@users.noreply.github.com> Date: Wed, 14 Oct 2026 23:18:50 +0800 Subject: [PATCH 065/649] docs: scorecard regenerated --- docs/scorecard.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/scorecard.md b/docs/scorecard.md index 56a16654bd..f5d26ff8dd 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -9,7 +9,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) | 29 | 13 | 1 | | -| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 157 (target 0) | +| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 25 of 157 (target 0) | | [Type](#type) | 4 | 3 | 2 | | | [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) | | [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present | @@ -176,9 +176,9 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t ## Workspace and UI -**Settings that do nothing: 26 of 157** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. +**Settings that do nothing: 25 of 157** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. -Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `file_handling.save_in_background`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`. +Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `file_handling.save_in_background`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`. | Id | Target | Status | Issue | Note | |---|---|---|---|---| From 0351f635d795d25e541008854b1be09697eadc72 Mon Sep 17 00:00:00 2001 From: Finn Newick Date: Wed, 14 Oct 2026 21:08:33 +0100 Subject: [PATCH 066/649] perf(doc): share the XMP packet, Duotone PSD data and unsupported adjustment bytes between snapshots Every edit clones the document and history keeps one per state. Metadata.xmp (String), Duotone.psd_raw (Vec) and Adjustment::Unsupported.raw (Vec) were owned, so each copy duplicated them, uncounted; their siblings (EXIF, PSD resources and blocks, a layer's psd_raw) were already Arc. They are now Arc and Arc<[u8]>. Reads are unchanged (Arc derefs to str); the boundaries to the codecs, the .pcraft manifest and the PSD model convert once per file operation. The architecture's snapshot principle now states the rule for every large payload, and a test checks that a history state shares all three. Fixes #4535. Co-Authored-By: Claude Opus 5.5 --- crates/doc/src/adjust.rs | 5 ++-- crates/doc/src/lib.rs | 5 +++- crates/doc/src/mode.rs | 3 +- crates/engine/src/file_cmds.rs | 2 +- crates/engine/src/file_cmds/tests.rs | 4 +-- crates/engine/src/tests.rs | 34 +++++++++++++++++++++++ crates/format/src/convert.rs | 4 +-- crates/format/tests/common/mod.rs | 2 +- crates/io/src/adjust_map.rs | 8 +++--- crates/io/src/flat.rs | 4 +-- crates/io/src/psd_export.rs | 2 +- crates/io/src/psd_import.rs | 8 ++++-- crates/io/src/tiff_layers.rs | 2 +- crates/io/tests/adjust_blend_roundtrip.rs | 2 +- crates/io/tests/adjust_warnings.rs | 4 +-- crates/io/tests/color.rs | 2 +- crates/io/tests/common/mod.rs | 2 +- crates/io/tests/psd_structure.rs | 4 +-- crates/io/tests/xmp_export.rs | 2 +- docs/architecture.md | 5 ++-- 20 files changed, 72 insertions(+), 32 deletions(-) diff --git a/crates/doc/src/adjust.rs b/crates/doc/src/adjust.rs index 855cd1f399..e197236a4a 100644 --- a/crates/doc/src/adjust.rs +++ b/crates/doc/src/adjust.rs @@ -281,10 +281,11 @@ pub enum Adjustment { relative: bool, adjustments: [[f32; 4]; 9], }, - /// A PSD adjustment we can't evaluate yet; preserved raw for round-trip. + /// A PSD adjustment we can't evaluate yet; preserved raw for round-trip, shared between + /// document snapshots (#4535). Unsupported { psd_key: String, - raw: Vec, + raw: std::sync::Arc<[u8]>, }, } diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rs index c4f7f523d1..88a0925378 100644 --- a/crates/doc/src/lib.rs +++ b/crates/doc/src/lib.rs @@ -841,7 +841,10 @@ pub type PsdGlobalBlock = ([u8; 4], [u8; 4], Arc>); #[derive(Clone, Debug, Default, PartialEq)] pub struct Metadata { - pub xmp: Option, + /// The XMP packet as stored, kept as text so properties PhotoCraft doesn't model survive. + /// Shared like the other payloads here: cloning a document or a history state never copies + /// it (#4535). + pub xmp: Option>, pub exif: Option>>, /// Free-form image text (PNG tEXt/zTXt/iTXt, TIFF ASCII tags), including duplicate keys. pub text: Vec<(String, String)>, diff --git a/crates/doc/src/mode.rs b/crates/doc/src/mode.rs index 96e129cbee..263cb83df4 100644 --- a/crates/doc/src/mode.rs +++ b/crates/doc/src/mode.rs @@ -57,8 +57,9 @@ impl DuotoneInk { pub struct Duotone { pub inks: Vec, /// The PSD colour-mode data this came from, written back unchanged while the inks are unedited. + /// Shared between document snapshots (#4535). #[serde(default)] - pub psd_raw: Option>, + pub psd_raw: Option>, } impl DuotoneInk { diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index 43828b76b1..4bdf30e28b 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -850,7 +850,7 @@ fn file_info(s: &mut Session, p: &Value) -> Result { let xmp = s.active().ok_or(EngineError::NoDocument)?.doc.metadata.xmp.clone(); let new = write_file_info(xmp.as_deref(), p); s.edit("File Info", |doc, _| { - doc.metadata.xmp = Some(new); + doc.metadata.xmp = Some(new.into()); Ok(()) })?; } diff --git a/crates/engine/src/file_cmds/tests.rs b/crates/engine/src/file_cmds/tests.rs index 3cc72c30c4..3a3a5b9d95 100644 --- a/crates/engine/src/file_cmds/tests.rs +++ b/crates/engine/src/file_cmds/tests.rs @@ -505,7 +505,7 @@ fn file_info_translations_survive_undo_and_psd_round_trip() { for depth in [8, 16, 32] { let mut s = session(8, 8, depth); s.edit("Set metadata", |doc, _| { - doc.metadata.xmp = Some(MULTILINGUAL_XMP.to_string()); + doc.metadata.xmp = Some(MULTILINGUAL_XMP.into()); Ok(()) }) .unwrap(); @@ -515,7 +515,7 @@ fn file_info_translations_survive_undo_and_psd_round_trip() { assert!(s.undo()); assert_eq!(doc(&s).metadata.xmp.as_deref(), Some(MULTILINGUAL_XMP)); assert!(s.redo()); - assert_eq!(doc(&s).metadata.xmp.as_deref(), Some(edited.as_str())); + assert_eq!(doc(&s).metadata.xmp.as_deref(), Some(&*edited)); let (bytes, _) = encode(doc(&s), "x.psd", None).unwrap(); let back = photocraft_io::import("x.psd", &bytes).unwrap().document; assert_translations_kept(back.metadata.xmp.as_deref().unwrap()); diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 04063d3073..f9ef4ee396 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -1580,3 +1580,37 @@ fn merge_down_on_a_group_merges_the_group() { s.execute("edit.undo", json!({})).unwrap(); assert!(s.active().unwrap().doc.layer(photocraft_doc::LayerId(group)).is_some()); } + +/// #4535: every edit snapshots the document into history. The large payloads it carries (the +/// XMP packet, Duotone's PSD data, an unsupported adjustment's bytes) are shared between the +/// snapshot and the document, not copied per state. +#[test] +fn history_states_share_large_document_payloads() { + use photocraft_doc::{Adjustment, Duotone, DuotoneInk, Layer, LayerContent}; + let mut s = Session::new(); + s.execute("file.new", json!({"width": 16, "height": 16})).unwrap(); + let raw_id = { + let st = s.active_mut().unwrap(); + let doc = std::sync::Arc::make_mut(&mut st.doc); + doc.metadata.xmp = Some("x".repeat(1 << 20).into()); + doc.duotone = Some(Duotone { inks: vec![DuotoneInk::new("Black", [0.0; 3])], psd_raw: Some(vec![7u8; 1 << 16].into()) }); + let layer = Layer::new("kept", LayerContent::Adjustment(Adjustment::Unsupported { psd_key: "abcd".into(), raw: vec![9u8; 1 << 16].into() })); + let id = layer.id; + doc.layers.push(layer); + id + }; + s.execute("layer.new.layer", json!({})).unwrap(); + let st = s.active().unwrap(); + let before = st.history.state(st.history.past_len() - 1).unwrap(); + let (now, then) = (&st.doc, &before); + assert!(!std::sync::Arc::ptr_eq(now, then), "the edit made a new document"); + let xmp = |d: &Document| d.metadata.xmp.clone().unwrap(); + assert!(std::sync::Arc::ptr_eq(&xmp(now), &xmp(then)), "the XMP packet is shared"); + let duotone = |d: &Document| d.duotone.as_ref().and_then(|d| d.psd_raw.clone()).unwrap(); + assert!(std::sync::Arc::ptr_eq(&duotone(now), &duotone(then)), "the Duotone data is shared"); + let raw = |d: &Document| match &d.layer(raw_id).unwrap().content { + LayerContent::Adjustment(Adjustment::Unsupported { raw, .. }) => raw.clone(), + other => panic!("{other:?}"), + }; + assert!(std::sync::Arc::ptr_eq(&raw(now), &raw(then)), "the adjustment's bytes are shared"); +} diff --git a/crates/format/src/convert.rs b/crates/format/src/convert.rs index 51d6183baa..878e6445be 100644 --- a/crates/format/src/convert.rs +++ b/crates/format/src/convert.rs @@ -233,7 +233,7 @@ pub(crate) fn doc_m(d: &Document, sink: &mut dyn Sink) -> DocM { ruler_origin: d.ruler_origin, selection: d.selection.as_ref().map(|s| surface_m(s, sink)), metadata: MetadataM { - xmp: d.metadata.xmp.clone(), + xmp: d.metadata.xmp.as_deref().map(str::to_owned), exif: opt_blob(&d.metadata.exif, sink), text: d.metadata.text.clone(), psd_resources: d.metadata.psd_resources.iter().map(|(id, n, b)| (*id, n.clone(), sink.blob(b))).collect(), @@ -575,7 +575,7 @@ impl Loader<'_> { } let quick_mask = m.quick_mask.as_ref().map(|c| self.channel(c)).transpose()?; let mut md = Metadata { - xmp: m.metadata.xmp.clone(), + xmp: m.metadata.xmp.as_deref().map(std::sync::Arc::from), exif: self.opt_blob(&m.metadata.exif)?, text: m.metadata.text.clone(), psd_resources: Vec::new(), diff --git a/crates/format/tests/common/mod.rs b/crates/format/tests/common/mod.rs index 8d5641d9cd..9f2662e6af 100644 --- a/crates/format/tests/common/mod.rs +++ b/crates/format/tests/common/mod.rs @@ -226,7 +226,7 @@ pub fn rich_doc(mode: ColorMode, depth: SampleType) -> Document { d.color_table = Some(photocraft_doc::ColorTable { colors: vec![[0, 0, 0], [255, 128, 0]], transparent: Some(1) }); d.duotone = Some(photocraft_doc::Duotone { inks: vec![photocraft_doc::DuotoneInk::new("Black", [0.0; 3]), photocraft_doc::DuotoneInk::new("PANTONE 151 C", [1.0, 0.5, 0.0])], - psd_raw: Some(vec![1, 2, 3]), + psd_raw: Some(vec![1, 2, 3].into()), }); d.guides = Guides { horizontal: vec![10.0, 20.5], vertical: vec![100.25], colors: vec![GuideColor { vertical: true, position: 100.25, rgb: [0x33, 0x66, 0xff] }] }; diff --git a/crates/io/src/adjust_map.rs b/crates/io/src/adjust_map.rs index d4bc312690..2ada62a5f6 100644 --- a/crates/io/src/adjust_map.rs +++ b/crates/io/src/adjust_map.rs @@ -29,7 +29,7 @@ fn bef32(d: &[u8], at: usize) -> Option { } fn unsupported(key: &[u8; 4], data: &[u8]) -> Adjustment { - Adjustment::Unsupported { psd_key: String::from_utf8_lossy(key).into_owned(), raw: data.to_vec() } + Adjustment::Unsupported { psd_key: String::from_utf8_lossy(key).into_owned(), raw: data.into() } } fn levels_rec(d: &[u8], at: usize) -> Option { @@ -787,7 +787,7 @@ pub fn write(adj: &Adjustment) -> Vec<([u8; 4], Vec)> { Adjustment::Unsupported { psd_key, raw } => { let k = psd_key.as_bytes(); if k.len() == 4 { - return vec![([k[0], k[1], k[2], k[3]], raw.clone())]; + return vec![([k[0], k[1], k[2], k[3]], raw.to_vec())]; } } } @@ -990,7 +990,7 @@ mod tests { let inkl = Adjustment::Levels { master: lc(0, 255), per_channel: [lc(0, 255), lc(5, 250), lc(0, 255)], space: ToneSpace::Cmyk, black: lc(30, 255) }; let b = write(&inkl); assert_eq!(parse(&b[0].0, &b[0].1, None, Channels::Cmyk), inkl); - rt(Adjustment::Unsupported { psd_key: "selc".into(), raw: vec![1, 2, 3] }); + rt(Adjustment::Unsupported { psd_key: "selc".into(), raw: vec![1, 2, 3].into() }); rt(Adjustment::GradientMap { stops: vec![(0.0, [0.0, 0.0, 0.0]), (0.5, [1.0, 0.0, 0.0]), (1.0, [1.0, 1.0, 1.0])], reverse: true, dither: false }); rt(Adjustment::GradientMap { stops: vec![(0.0, [0.0, 0.0, 0.0]), (1.0, [1.0, 1.0, 1.0])], reverse: false, dither: true }); rt(Adjustment::SelectiveColor { relative: true, adjustments: std::array::from_fn(|r| [r as f32 * 10.0 - 40.0, 5.0, -100.0, 100.0]) }); @@ -1304,7 +1304,7 @@ mod tests { assert_eq!(*t, photocraft_cms::lutfile::LutFile::identity(2).data); } // Every kind except a malformed Unsupported key has an encoding. - assert!(write(&Adjustment::Unsupported { psd_key: "abc".into(), raw: vec![] }).is_empty()); + assert!(write(&Adjustment::Unsupported { psd_key: "abc".into(), raw: Vec::new().into() }).is_empty()); } #[test] diff --git a/crates/io/src/flat.rs b/crates/io/src/flat.rs index 54fe96090d..ee2e2487fb 100644 --- a/crates/io/src/flat.rs +++ b/crates/io/src/flat.rs @@ -234,7 +234,7 @@ pub(crate) fn image_to_document(name: &str, img: &Image) -> Result, cmyk_target }; let meta = codecs::Metadata { exif: doc.metadata.exif.as_ref().map(|e| e.to_vec()), - xmp: doc.metadata.xmp.clone(), + xmp: doc.metadata.xmp.as_deref().map(str::to_owned), text: doc.metadata.text.clone(), dpi: Some((doc.resolution_dpi, doc.resolution_dpi)), ..Default::default() diff --git a/crates/io/src/psd_export.rs b/crates/io/src/psd_export.rs index 47861dbcc3..5427460a45 100644 --- a/crates/io/src/psd_export.rs +++ b/crates/io/src/psd_export.rs @@ -1451,7 +1451,7 @@ pub(crate) fn estimate_psd_size(doc: &Document) -> Option { structural_bytes = structural_bytes .checked_add(u64::try_from(doc.icc_profile.as_ref().map_or(0, |profile| profile.len())).ok()?)? - .checked_add(u64::try_from(doc.metadata.xmp.as_ref().map_or(0, String::len)).ok()?)? + .checked_add(u64::try_from(doc.metadata.xmp.as_deref().map_or(0, str::len)).ok()?)? .checked_add(u64::try_from(doc.metadata.exif.as_ref().map_or(0, |data| data.len())).ok()?)?; for (_, name, data) in &doc.metadata.psd_resources { structural_bytes = structural_bytes.checked_add(u64::try_from(name.len()).ok()?)?.checked_add(u64::try_from(data.len()).ok()?)?; diff --git a/crates/io/src/psd_import.rs b/crates/io/src/psd_import.rs index 94c4ea9932..d91784396b 100644 --- a/crates/io/src/psd_import.rs +++ b/crates/io/src/psd_import.rs @@ -761,7 +761,7 @@ pub fn psd_to_document_with(file: &PsdFile, ctl: &photocraft_raster::Interrupt) } } ids::ICC_PROFILE => doc.icc_profile = Some(Arc::new(r.data.clone())), - ids::XMP => doc.metadata.xmp = Some(String::from_utf8_lossy(&r.data).into_owned()), + ids::XMP => doc.metadata.xmp = Some(String::from_utf8_lossy(&r.data).into()), ids::EXIF => doc.metadata.exif = Some(Arc::new(r.data.clone())), 1032 => parse_guides(&r.data, &mut doc), ids::GLOBAL_ANGLE | ids::GLOBAL_ALTITUDE => { @@ -959,8 +959,10 @@ pub fn psd_to_document_with(file: &PsdFile, ctl: &photocraft_raster::Interrupt) doc.color_table = Some(photocraft_doc::ColorTable { colors, transparent: None }); } else if h.color_mode == PsdMode::Duotone && !file.color_mode_data.is_empty() { // The duotone ink block is undocumented: keep it raw; the image shows as its gray plate. - doc.duotone = - Some(photocraft_doc::Duotone { inks: vec![photocraft_doc::DuotoneInk::new("Black", [0.0; 3])], psd_raw: Some(file.color_mode_data.clone()) }); + doc.duotone = Some(photocraft_doc::Duotone { + inks: vec![photocraft_doc::DuotoneInk::new("Black", [0.0; 3])], + psd_raw: Some(file.color_mode_data.as_slice().into()), + }); cx.warn("duotone inks are not interpreted (shown as grayscale)"); } else if !file.color_mode_data.is_empty() { cx.warn("color mode data is not preserved"); diff --git a/crates/io/src/tiff_layers.rs b/crates/io/src/tiff_layers.rs index 8a5810e922..3afc0b59db 100644 --- a/crates/io/src/tiff_layers.rs +++ b/crates/io/src/tiff_layers.rs @@ -240,7 +240,7 @@ pub(crate) fn export_layered(doc: &Document, opts: &ExportOptions, ctl: &photocr // importer reads it back from there unchanged. A second copy in `meta.exif` (the codec's // Exif directory) would be read back in its place, rebuilt without the thumbnail and IFD0 // orientation (#1545). - xmp: doc.metadata.xmp.clone().filter(|_| opts.xmp == crate::XmpEmbed::All), + xmp: doc.metadata.xmp.as_deref().map(str::to_owned).filter(|_| opts.xmp == crate::XmpEmbed::All), text: if opts.xmp == crate::XmpEmbed::All { doc.metadata.text.clone() } else { Vec::new() }, dpi: Some((doc.resolution_dpi, doc.resolution_dpi)), photoshop_resources: Some(resources), diff --git a/crates/io/tests/adjust_blend_roundtrip.rs b/crates/io/tests/adjust_blend_roundtrip.rs index 4e8b727af2..fee2c01f82 100644 --- a/crates/io/tests/adjust_blend_roundtrip.rs +++ b/crates/io/tests/adjust_blend_roundtrip.rs @@ -101,7 +101,7 @@ fn adjustments() -> Vec<(Adjustment, bool)> { (Adjustment::SelectiveColor { relative: true, adjustments: std::array::from_fn(|r| [r as f32 * 10.0 - 40.0, 5.0, -30.0, 20.0]) }, true), (Adjustment::SelectiveColor { relative: false, adjustments: std::array::from_fn(|r| [0.0, r as f32 * 5.0, 0.0, -10.0]) }, true), // A block this version cannot read (a truncated Selective Color) is kept verbatim. - (Adjustment::Unsupported { psd_key: "selc".into(), raw: vec![0, 1, 0, 0] }, true), + (Adjustment::Unsupported { psd_key: "selc".into(), raw: vec![0, 1, 0, 0].into() }, true), ]; // Compile-time guard: a new Adjustment kind must be added to the list above. for (a, _) in &all { diff --git a/crates/io/tests/adjust_warnings.rs b/crates/io/tests/adjust_warnings.rs index 9b91f40bcf..617911f18e 100644 --- a/crates/io/tests/adjust_warnings.rs +++ b/crates/io/tests/adjust_warnings.rs @@ -17,7 +17,7 @@ fn reopen(adj: Adjustment, path: &str, opts: &ExportOptions) -> (Document, Vec Document { black: Vec::new(), pencil: false, }, - Adjustment::Unsupported { psd_key: "selc".into(), raw: vec![0, 1, 0, 0] }, + Adjustment::Unsupported { psd_key: "selc".into(), raw: vec![0, 1, 0, 0].into() }, ]; // Colour adjustments (Photoshop offers them for colour documents only: they would tint // a grayscale composite). diff --git a/crates/io/tests/psd_structure.rs b/crates/io/tests/psd_structure.rs index 5627dca3f4..643e6ad546 100644 --- a/crates/io/tests/psd_structure.rs +++ b/crates/io/tests/psd_structure.rs @@ -361,9 +361,7 @@ fn adjustment_and_fill_layers_from_psd() { use photocraft_doc::{Adjustment, Fill}; assert!(matches!(d.layers[n - 4].content, LayerContent::Adjustment(Adjustment::Invert))); assert!(matches!(d.layers[n - 3].content, LayerContent::Adjustment(Adjustment::Posterize { levels: 4 }))); - assert!( - matches!(&d.layers[n - 2].content, LayerContent::Adjustment(Adjustment::Unsupported { psd_key, raw }) if psd_key == "selc" && raw == &vec![1, 2, 3]) - ); + assert!(matches!(&d.layers[n - 2].content, LayerContent::Adjustment(Adjustment::Unsupported { psd_key, raw }) if psd_key == "selc" && **raw == [1, 2, 3])); assert!(matches!(&d.layers[n - 1].content, LayerContent::Fill(Fill::Solid(c)) if c.c[0] == 1.0)); } diff --git a/crates/io/tests/xmp_export.rs b/crates/io/tests/xmp_export.rs index 8d22017ff6..08af0006c7 100644 --- a/crates/io/tests/xmp_export.rs +++ b/crates/io/tests/xmp_export.rs @@ -17,7 +17,7 @@ fn doc_with_xmp() -> Document { let mut s = Surface::new(d.pixel_format()); s.fill_rect(photocraft_geom::Rect::new(0, 0, 8, 6), &[0.5, 0.4, 0.3, 1.0]); d.layers.push(Layer::new("flat", LayerContent::Raster(s))); - d.metadata.xmp = Some(XMP.to_string()); + d.metadata.xmp = Some(XMP.into()); d } diff --git a/docs/architecture.md b/docs/architecture.md index 67eebe9cce..975a0b6e84 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -1,6 +1,6 @@ # PhotoCraft architecture -> **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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (large payloads in the document model are `Arc`-shared, #4535; earlier: 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) @@ -53,7 +53,7 @@ This plan sets out: 2. **Everything is a command.** Each user-visible action has a stable `CommandId` (such as `filter.blur.gaussianBlur`) with typed, serializable parameters. The menu, command palette, shortcuts, recorded actions/macros, CLI, MCP and plugins all dispatch the same commands. 3. **Data describes the UI; toolkits draw it.** Tools produce *overlay primitives* (lines, handles, marching-ants paths) as data. Filter and adjustment dialogs are generated from *parameter schemas*. A new toolkit implements one renderer for each, not about 150 bespoke dialogs. 4. **One algorithm, one parameter struct.** Every algorithm has a CPU reference implementation (Rust + rayon, deterministic). Some also get a GPU implementation (WGSL). Both read the same `#[repr(C)]` `bytemuck::Pod` parameter struct. We never keep hand-synced copies of an algorithm in several languages. -5. **Immutable snapshots, copy-on-write tiles.** Pixel data is stored in `Arc`-shared 256² tiles. Taking a document snapshot is O(layers), which makes undo, background jobs, autosave and UI reads cheap and lock-free. +5. **Immutable snapshots, copy-on-write tiles.** Pixel data is stored in `Arc`-shared 256² tiles. Taking a document snapshot is O(layers), which makes undo, background jobs, autosave and UI reads cheap and lock-free. Every other large payload in `photocraft-doc` is `Arc`-shared too (the XMP packet, EXIF, raw PSD resources and blocks, a layer's or Duotone's raw PSD data, an unsupported adjustment's bytes), so a snapshot never copies one; a new field that can hold a large payload follows the same rule (#4535). 6. **Determinism.** The same input gives the same output across CPU and GPU (within tolerance), across thread counts, and between preview and export. Noise is hashed from document coordinates. 7. **Pure Rust by default.** C/C++ dependencies are allowed only behind Cargo features, in I/O-edge crates (for example an optional LibRaw). 8. **Clean-room.** We study other editors' *behaviour* only, and we must **not copy proprietary source** (Rust, WGSL, C++ or JS), even where it ships as readable source. Specs come from public format docs (Adobe PSD spec, ISO/ICC), academic papers (PatchMatch, Poisson blending, ARAP) and observed behaviour. Never paste code from another product. @@ -588,6 +588,7 @@ Each phase ends with a demoable build and green CI on all targets. Phases 8–10 | Date | Change | Summary | |---|---|---| +| 2026-10-14 | minor | Principle 5: every large payload in the document model is `Arc`-shared, so snapshots never copy one (#4535) | | 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 | From d709fd81a1a05a62b602f96ef2f6c68f35b32b67 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 14 Oct 2026 20:33:52 +0000 Subject: [PATCH 067/649] =?UTF-8?q?Warp:=20Photoshop's=20Cylinder=20warp?= =?UTF-8?q?=20as=20a=204=20=C3=97=201=20patch=20mesh=20(#4112)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Transform Warp's Cylinder (`warpCylinder`) stores seven `warpValues` instead of a bend. WarpStyle gains Cylinder (parsed, named, not one of the fifteen bend presets and not listed in the Warp menus yet), and Warp::cylinder builds its mesh: four patches across (back, front left, front right, back) and one down, in the warp's value space like a custom mesh, so map, to_mesh and is_identity treat it as one. Warp keeps the values for writing them back (serde: omitted when empty). The model and its table of shape factors were measured against Photoshop 2026's renders by the reporter of #4112 (not from Adobe's code). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EuC9R3K5QeMBrDkixa1jnt --- crates/geom/src/warp.rs | 226 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 216 insertions(+), 10 deletions(-) diff --git a/crates/geom/src/warp.rs b/crates/geom/src/warp.rs index 9c8f138747..cd4979d775 100644 --- a/crates/geom/src/warp.rs +++ b/crates/geom/src/warp.rs @@ -9,6 +9,9 @@ //! - **Custom meshes** ([`BezierMesh`]): a grid of bicubic Bezier patches. The default is one //! patch (a 4×4 control grid); split warps add patch rows/columns by exact de Casteljau //! subdivision, so splitting never changes the shape. +//! - **Cylinder** ([`WarpStyle::Cylinder`], Transform Warp only): seven `warpValues` that +//! Photoshop turns into a 4 × 1 patch mesh wrapping the contents round a cylinder; see +//! [`cylinder_mesh`]. //! //! Pure geometry: resampling lives in `photocraft-algo::warp`. @@ -38,6 +41,10 @@ pub enum WarpStyle { Inflate, Squeeze, Twist, + /// Edit › Transform › Warp's Cylinder (`warpCylinder`): not one of the fifteen bend presets + /// (Warp Text doesn't have it), it takes seven values instead of a bend; see + /// [`Warp::cylinder`]. + Cylinder, } impl WarpStyle { @@ -60,7 +67,8 @@ impl WarpStyle { WarpStyle::Twist, ]; - /// Every style (none, custom, presets). + /// The styles the Warp menus list: none, custom and the presets. [`WarpStyle::Cylinder`] is + /// read from PSDs and taken by commands, but has no editor yet. pub fn all() -> impl Iterator { [WarpStyle::None, WarpStyle::Custom].into_iter().chain(Self::PRESETS) } @@ -85,6 +93,7 @@ impl WarpStyle { WarpStyle::Inflate => "warpInflate", WarpStyle::Squeeze => "warpSqueeze", WarpStyle::Twist => "warpTwist", + WarpStyle::Cylinder => "warpCylinder", } } @@ -109,6 +118,7 @@ impl WarpStyle { "Fisheye" => "fisheye", "Inflate" => "inflate", "Squeeze" => "squeeze", + "Cylinder" => "cylinder", _ => "twist", } } @@ -133,17 +143,19 @@ impl WarpStyle { WarpStyle::Inflate => "Inflate", WarpStyle::Squeeze => "Squeeze", WarpStyle::Twist => "Twist", + WarpStyle::Cylinder => "Cylinder", } } /// Parses a short id, a PSD name or a label (case-insensitive, spaces ignored). pub fn parse(s: &str) -> Option { let k: String = s.chars().filter(|c| !c.is_whitespace()).collect::().to_ascii_lowercase(); - Self::all().find(|w| w.id().to_ascii_lowercase() == k || w.psd_name().to_ascii_lowercase() == k) + Self::all().chain([WarpStyle::Cylinder]).find(|w| w.id().to_ascii_lowercase() == k || w.psd_name().to_ascii_lowercase() == k) } + /// One of the fifteen bend presets ([`Self::PRESETS`]). pub fn is_preset(self) -> bool { - !matches!(self, WarpStyle::None | WarpStyle::Custom) + Self::PRESETS.contains(&self) } } @@ -357,7 +369,7 @@ fn preset_grid(style: WarpStyle, b: f64, hd: f64, vd: f64, vertical: bool, aspec g[2][2][1] -= a; } } - WarpStyle::None | WarpStyle::Custom => {} + WarpStyle::None | WarpStyle::Custom | WarpStyle::Cylinder => {} } // Vertical distortion: the top and bottom rows scale about their end points' midpoint (by // 1 ∓ vd) and the middle rows follow by the blend of those two moves. @@ -412,6 +424,101 @@ fn split_cubic(p: [[f64; 2]; 4], t: f64) -> [[f64; 2]; 7] { [p[0], a, d, f, e, c, p[3]] } +/// Photoshop's Cylinder warp as a Bezier mesh in the `warp` descriptor's value space (the space +/// of its `bounds`), from the seven `warpValues` `v` of a horizontal cylinder with no +/// perspective. Like a custom warp's mesh, its control-point box is what the placement quad +/// frames. `None` unless there are seven finite values with the right silhouette right of the +/// left one. +/// +/// The model was measured against Photoshop 2026's renders of a UV grid (issue #4112: within +/// 0.3 px vertically and 1.2 px horizontally at the 99th percentile), not taken from Adobe's code: +/// - `v[0]`, `v[2]`: the left and right silhouettes. Half axis `a = (v[2] − v[0]) / 2`. +/// - `v[3]`, `v[1]`: the top and bottom edges at the silhouettes (the centre lines of the upper +/// and lower ellipses); `v[4]`, `v[5]`: those ellipses' depth in units of `a`. +/// - `v[6]` (0..1): how far the contents wrap round. The outer `uL` of the contents on each side +/// is on the back of the cylinder and collapses onto the silhouette: 1/6 at 0, 0.006 at 1. +/// +/// Four patches across (`us = [0, uL, 0.5, 1 − uL, 1]`: back, front left, front right, back) and +/// one down; control rows are linear between the top and bottom edge. +pub fn cylinder_mesh(v: &[f64]) -> Option { + let v: [f64; 7] = v.try_into().ok()?; + if !v.iter().all(|x| x.is_finite()) || v[2] <= v[0] { + return None; + } + let a = (v[2] - v[0]) / 2.0; + let cx = (v[0] + v[2]) / 2.0; + let [ul, kx, ky, my] = cylinder_shape(v[6]); + let s = [-1.0, -1.0, -1.0, -1.0, -1.0, -kx, 0.0, kx, 1.0, 1.0, 1.0, 1.0, 1.0]; + let e = [0.0, 0.0, 0.0, 0.0, ky, my, 1.0, my, ky, 0.0, 0.0, 0.0, 0.0]; + let mut points = Vec::with_capacity(13 * 4); + for r in 0..4 { + let t = f64::from(r) / 3.0; + for (sk, ek) in s.iter().zip(e) { + let (top, bottom) = (v[3] + v[4] * a * ek, v[1] + v[5] * a * ek); + points.push([cx + a * sk, top + (bottom - top) * t]); + } + } + let mesh = BezierMesh { us: vec![0.0, ul, 0.5, 1.0 - ul, 1.0], vs: vec![0.0, 1.0], points }; + mesh.is_valid().then_some(mesh) +} + +/// `[uL, kx, ky, my]` for a cylinder's wrap `g` (`warpValues[6]`, clamped to 0..1): the share of +/// the contents on the back on each side, then the front patches' inner x control point (in +/// units of the half axis) and their ellipse factors. Linear between the measured rows. +fn cylinder_shape(g: f64) -> [f64; 4] { + let n = CYLINDER_SHAPE.len() - 1; + let x = if g.is_finite() { g.clamp(0.0, 1.0) * n as f64 } else { 0.0 }; + let i = (x.floor() as usize).min(n - 1); + let (a, b, t) = (CYLINDER_SHAPE[i], CYLINDER_SHAPE[i + 1], x - i as f64); + std::array::from_fn(|k| a[k] + (b[k] - a[k]) * t) +} + +/// [`cylinder_shape`]'s rows for `g` = 0, 0.025 … 1, measured from Photoshop's renders (#4112): +/// no closed form was found. +const CYLINDER_SHAPE: [[f64; 4]; 41] = [ + [0.166169, 0.655404, 0.382374, 1.003104], + [0.157304, 0.650228, 0.388326, 1.002685], + [0.148438, 0.645374, 0.394211, 1.007918], + [0.140060, 0.639652, 0.401415, 1.006938], + [0.131885, 0.634064, 0.408465, 1.006069], + [0.123875, 0.628845, 0.414586, 1.005743], + [0.116162, 0.623565, 0.421033, 1.005233], + [0.108674, 0.618563, 0.426905, 1.004990], + [0.101198, 0.614439, 0.431943, 1.010787], + [0.094322, 0.609611, 0.437749, 1.010560], + [0.087757, 0.604929, 0.443406, 1.010361], + [0.081514, 0.600390, 0.448907, 1.010190], + [0.075599, 0.596012, 0.454288, 1.010019], + [0.069994, 0.591836, 0.459420, 1.009888], + [0.064709, 0.587844, 0.464361, 1.009768], + [0.059740, 0.584026, 0.469109, 1.009669], + [0.055072, 0.580427, 0.473609, 1.009588], + [0.050712, 0.576990, 0.477904, 1.009528], + [0.046635, 0.573760, 0.481968, 1.009477], + [0.042824, 0.570758, 0.485764, 1.009440], + [0.039295, 0.567910, 0.489377, 1.009411], + [0.036023, 0.565229, 0.492800, 1.009382], + [0.032681, 0.563478, 0.495519, 1.015285], + [0.029877, 0.561152, 0.498513, 1.015270], + [0.027282, 0.559012, 0.501313, 1.015245], + [0.024894, 0.557004, 0.503913, 1.015241], + [0.022693, 0.555163, 0.506331, 1.015225], + [0.020668, 0.553463, 0.508575, 1.015213], + [0.018816, 0.551877, 0.510651, 1.015217], + [0.017106, 0.550434, 0.512556, 1.015214], + [0.015542, 0.549100, 0.514319, 1.015213], + [0.014115, 0.547868, 0.515936, 1.015223], + [0.012806, 0.546743, 0.517432, 1.015223], + [0.011600, 0.545730, 0.518775, 1.015228], + [0.010506, 0.544788, 0.520034, 1.015230], + [0.009510, 0.543920, 0.521179, 1.015238], + [0.008600, 0.543134, 0.522224, 1.015244], + [0.007763, 0.542420, 0.523173, 1.015251], + [0.007006, 0.541757, 0.524065, 1.015252], + [0.006315, 0.541164, 0.524867, 1.015252], + [0.005686, 0.540608, 0.525602, 1.015261], +]; + /// Inverse of the Bernstein interpolation matrix at t = 0, 1/3, 2/3, 1 (rows: control point, /// columns: sample). Exact rational values. const BERN_INV: [[f64; 4]; 4] = [[1.0, 0.0, 0.0, 0.0], [-5.0 / 6.0, 3.0, -1.5, 1.0 / 3.0], [1.0 / 3.0, -1.5, 3.0, -5.0 / 6.0], [0.0, 0.0, 0.0, 1.0]]; @@ -917,15 +1024,18 @@ pub struct Warp { pub vertical: bool, /// The source box `[x0, y0, x1, y1]` the warp is defined over. pub bounds: [f64; 4], - /// Control mesh for [`WarpStyle::Custom`] (output coordinates). + /// Control mesh for [`WarpStyle::Custom`] and [`WarpStyle::Cylinder`] (output coordinates). #[serde(default)] pub mesh: Option, + /// A cylinder's seven `warpValues` (see [`Warp::cylinder`]); empty for other styles. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub values: Vec, } impl Warp { /// No warp over `bounds`. pub fn none(bounds: [f64; 4]) -> Warp { - Warp { style: WarpStyle::None, bend: 0.0, h_distort: 0.0, v_distort: 0.0, vertical: false, bounds, mesh: None } + Warp { style: WarpStyle::None, bend: 0.0, h_distort: 0.0, v_distort: 0.0, vertical: false, bounds, mesh: None, values: Vec::new() } } /// A preset style. @@ -938,6 +1048,13 @@ impl Warp { Warp { style: WarpStyle::Custom, mesh: Some(mesh), ..Warp::none(bounds) } } + /// A horizontal Cylinder warp over `bounds` from its seven `warpValues` (see + /// [`cylinder_mesh`]). `None` when they don't describe one. + pub fn cylinder(values: &[f64], bounds: [f64; 4]) -> Option { + let mesh = cylinder_mesh(values)?; + Some(Warp { style: WarpStyle::Cylinder, mesh: Some(mesh), values: values.to_vec(), ..Warp::none(bounds) }) + } + fn style_warp(&self) -> Option { StyleWarp::new(self.style, self.bend, self.h_distort, self.v_distort, self.vertical, self.bounds) } @@ -946,7 +1063,7 @@ impl Warp { pub fn is_identity(&self) -> bool { match self.style { WarpStyle::None => true, - WarpStyle::Custom => match &self.mesh { + WarpStyle::Custom | WarpStyle::Cylinder => match &self.mesh { None => true, Some(m) => { let id = BezierMesh::fit(&|s, t| self.box_point(s, t), m.us.clone(), m.vs.clone()); @@ -966,7 +1083,7 @@ impl Warp { pub fn map(&self, x: f64, y: f64) -> (f64, f64) { match self.style { WarpStyle::None => (x, y), - WarpStyle::Custom => match &self.mesh { + WarpStyle::Custom | WarpStyle::Cylinder => match &self.mesh { Some(m) => { let b = self.bounds; let (w, h) = (b[2] - b[0], b[3] - b[1]); @@ -986,9 +1103,9 @@ impl Warp { } /// The warp as a control mesh (a preset is its own Bezier patch split into `cols × rows`; - /// custom warps return their own mesh). + /// custom and cylinder warps return their own mesh). pub fn to_mesh(&self, cols: usize, rows: usize) -> BezierMesh { - if let (WarpStyle::Custom, Some(m)) = (self.style, &self.mesh) { + if let (WarpStyle::Custom | WarpStyle::Cylinder, Some(m)) = (self.style, &self.mesh) { return m.clone(); } let (cols, rows) = (cols.clamp(1, 64), rows.clamp(1, 64)); @@ -1364,4 +1481,93 @@ mod tests { let ob = Warp::none(B).output_bounds(); assert!((ob[0] - 10.0).abs() < 1e-9 && (ob[3] - 70.0).abs() < 1e-9); } + + /// A cylinder over a 1000 × 1000 source like #4112's: silhouettes at x 100 and 900, edges at + /// y 200 (top) and 800 (bottom), ellipses 0.3 deep, half wrapped round. + const CYL: [f64; 7] = [100.0, 800.0, 900.0, 200.0, 0.3, 0.3, 0.5]; + + #[test] + fn cylinder_style_is_read_and_named_but_not_a_bend_preset() { + for s in ["cylinder", "warpCylinder", "Cylinder"] { + assert_eq!(WarpStyle::parse(s), Some(WarpStyle::Cylinder), "{s}"); + } + assert_eq!(WarpStyle::Cylinder.psd_name(), "warpCylinder"); + assert_eq!(WarpStyle::Cylinder.id(), "cylinder"); + assert!(!WarpStyle::Cylinder.is_preset()); + assert!(StyleWarp::new(WarpStyle::Cylinder, 50.0, 0.0, 0.0, false, B).is_none()); + // The Warp menus list what they can edit. + assert!(WarpStyle::all().all(|s| s != WarpStyle::Cylinder)); + assert_eq!(WarpStyle::all().filter(|s| s.is_preset()).count(), 15); + } + + #[test] + fn cylinder_values_that_describe_no_cylinder_are_refused() { + assert!(cylinder_mesh(&CYL[..6]).is_none(), "six values"); + assert!(cylinder_mesh(&[CYL.as_slice(), &[0.0]].concat()).is_none(), "eight values"); + for i in 0..7 { + for bad in [f64::NAN, f64::INFINITY] { + let mut v = CYL; + v[i] = bad; + assert!(cylinder_mesh(&v).is_none(), "value {i} = {bad}"); + } + } + let mut v = CYL; + v[2] = v[0]; + assert!(Warp::cylinder(&v, [0.0, 0.0, 1000.0, 1000.0]).is_none(), "no width"); + v[2] = 50.0; + assert!(Warp::cylinder(&v, [0.0, 0.0, 1000.0, 1000.0]).is_none(), "right silhouette left of the left one"); + } + + #[test] + fn cylinder_wraps_the_contents_between_its_silhouettes() { + let w = Warp::cylinder(&CYL, [0.0, 0.0, 1000.0, 1000.0]).unwrap(); + assert_eq!(w.style, WarpStyle::Cylinder); + assert_eq!(w.values, CYL); + assert!(!w.is_identity()); + let m = w.mesh.as_ref().unwrap(); + assert_eq!((m.nx(), m.ny()), (13, 4)); + let [ul, ..] = cylinder_shape(0.5); + assert!((m.us[1] - ul).abs() < 1e-12 && (m.us[3] - (1.0 - ul)).abs() < 1e-12); + // The middle of the contents is at the front: centred, on the ellipses' near side. + assert!(close(w.map(500.0, 0.0), (500.0, 200.0 + 0.3 * 400.0), 1e-9)); + assert!(close(w.map(500.0, 1000.0), (500.0, 800.0 + 0.3 * 400.0), 1e-9)); + // What wraps round the back lies on the silhouettes, at the edges' ends. + for x in [0.0, ul * 500.0, ul * 1000.0] { + assert!(close(w.map(x, 0.0), (100.0, 200.0), 1e-9), "{x}"); + assert!(close(w.map(1000.0 - x, 1000.0), (900.0, 800.0), 1e-9), "{x}"); + } + // Across the front x only grows, and the two halves mirror each other. + let mut last = f64::MIN; + for i in 0..=200 { + let x = 1000.0 * (ul + (1.0 - 2.0 * ul) * f64::from(i) / 200.0); + let (px, py) = w.map(x, 400.0); + assert!(px >= last - 1e-9, "x {x}"); + last = px; + let (qx, qy) = w.map(1000.0 - x, 400.0); + assert!(close((px - 500.0, py), (500.0 - qx, qy), 1e-9), "x {x}"); + } + // Every point stays inside the control-point box the placement frames. + let cb = m.control_bounds(); + let ob = w.output_bounds(); + assert!(ob[0] >= cb[0] - 1e-9 && ob[1] >= cb[1] - 1e-9 && ob[2] <= cb[2] + 1e-9 && ob[3] <= cb[3] + 1e-9); + assert!((cb[0] - 100.0).abs() < 1e-9 && (cb[2] - 900.0).abs() < 1e-9); + // The box's bottom is the lower ellipse's deepest control point (`my` > 1). + assert!((cb[3] - (800.0 + 0.3 * 400.0 * cylinder_shape(0.5)[3])).abs() < 1e-9); + assert_eq!(w.to_mesh(4, 4), *m, "a cylinder is its own mesh"); + } + + #[test] + fn cylinder_shape_follows_the_measured_rows() { + assert_eq!(cylinder_shape(0.0), CYLINDER_SHAPE[0]); + assert_eq!(cylinder_shape(1.0), CYLINDER_SHAPE[40]); + assert_eq!(cylinder_shape(-3.0), CYLINDER_SHAPE[0]); + assert_eq!(cylinder_shape(7.0), CYLINDER_SHAPE[40]); + assert_eq!(cylinder_shape(f64::NAN), CYLINDER_SHAPE[0]); + let mid = cylinder_shape(0.0125); + for k in 0..4 { + assert!((mid[k] - (CYLINDER_SHAPE[0][k] + CYLINDER_SHAPE[1][k]) / 2.0).abs() < 1e-12); + } + // The more it wraps, the less of the contents is on the back. + assert!(CYLINDER_SHAPE.windows(2).all(|r| r[1][0] < r[0][0])); + } } From a4531d3122d0fef445f335000db651aa413d2a9d Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 14 Oct 2026 20:48:54 +0000 Subject: [PATCH 068/649] PSD: read and write Photoshop's Cylinder warp on placed layers (#4112) A `warpCylinder` placed layer was read as having no warp: it showed Photoshop's cached pixels on open, but Replace Contents, Relink and Edit Contents drew the contents flat, and a regenerated SoLd wrote warpNone. - Import reads the seven `warpValues` (a list of doubles or unit floats) of a horizontal cylinder without perspective into Warp::cylinder. Vertical cylinders and ones with perspective, never measured, stay unreadable as before, as do broken values. - Like a custom warp's (#3677), the cylinder's control-point box is what the placement quad frames, for affine corners and, new for this style, projective ones (`nonAffineTransform`): perspective_frame and corners_perspective_in. Custom warps keep the source rect there. - Export writes `warpCylinder` with its values back and frames the same box, so a moved or replaced layer reopens where it was. An unchanged layer is still written verbatim. Tests: synthetic SoLd parsing (both value encodings, the refused variants), the quad framing the control box (affine and projective), SoLd and PlLd round trips, and a PSD export/import whose re-render hides the contents wrapped round the back (fails before the change). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EuC9R3K5QeMBrDkixa1jnt --- crates/io/src/blocks.rs | 175 ++++++++++++++++++++++++++++--- crates/io/src/smart_map.rs | 62 +++++++++-- crates/io/tests/cylinder_warp.rs | 123 ++++++++++++++++++++++ 3 files changed, 342 insertions(+), 18 deletions(-) create mode 100644 crates/io/tests/cylinder_warp.rs diff --git a/crates/io/src/blocks.rs b/crates/io/src/blocks.rs index 87fda102fe..a54e07fee7 100644 --- a/crates/io/src/blocks.rs +++ b/crates/io/src/blocks.rs @@ -526,7 +526,8 @@ pub(crate) fn with_pattern_placement(mut d: Descriptor, angle: f32, link: bool, } /// The warp of a placed layer (`SoLd`/`SoLE` `warp` descriptor): style, bend, distortions, -/// axis, bounds and, for `warpCustom`, the 4 × 4 `customEnvelopeWarp` mesh. Read-only: the raw +/// axis, bounds and, for `warpCustom`, the 4 × 4 `customEnvelopeWarp` mesh, for `warpCylinder` +/// its seven `warpValues`. Read-only: the raw /// block is what gets written back. `None` when absent or `warpNone` with no mesh. A `PlLd` /// record keeps its warp elsewhere: see [`parse_plld_warp`]. pub fn parse_placed_warp(key: &[u8; 4], data: &[u8]) -> Option { @@ -539,7 +540,8 @@ pub fn parse_placed_warp(key: &[u8; 4], data: &[u8]) -> Option Option> { use photocraft_geom::warp::{BezierMesh, Warp, WarpStyle}; let style = enum_of(w, "warpStyle").and_then(|v| WarpStyle::parse(&String::from_utf8_lossy(v)))?; @@ -553,6 +555,17 @@ fn warp_of(w: &Descriptor) -> Option> { warp.h_distort = num(w.get("warpPerspective")).unwrap_or(0.0); warp.v_distort = num(w.get("warpPerspectiveOther")).unwrap_or(0.0); warp.vertical = enum_of(w, "warpRotate") == Some(b"Vrtc"); + if style == WarpStyle::Cylinder { + if warp.vertical || warp.h_distort != 0.0 || warp.v_distort != 0.0 { + return None; + } + let values: Vec = match w.get("warpValues")? { + Value::List(l) => l.iter().map(|v| num(Some(v))).collect::>()?, + Value::UnitFloats { values, .. } => values.clone(), + _ => return None, + }; + return Some(Some(Warp::cylinder(&values, bounds)?)); + } if style == WarpStyle::Custom { let env = get_desc(w, "customEnvelopeWarp")?; let Some(Value::ObjectArray(arr)) = env.get("meshPoints") else { return None }; @@ -593,12 +606,17 @@ pub(crate) fn parse_prefix_versioned(data: &[u8]) -> Option { } /// The source-space box Photoshop maps onto a placed layer's `Trnf` quad: the bounding box of a -/// single-patch custom warp's 16 control points, which may spill past the source, else the source -/// rect `0..w × 0..h`. Mapping the source rect instead counts the overhang twice and stretches the -/// placement. A degenerate or non-finite box falls back to the source rect. +/// single-patch custom warp's 16 control points or of a cylinder's mesh (#4112), which may spill +/// past the source, else the source rect `0..w × 0..h`. Mapping the source rect instead counts the +/// overhang twice and stretches the placement. A degenerate or non-finite box falls back to the +/// source rect. pub(crate) fn placed_frame(warp: Option<&photocraft_geom::warp::Warp>, w: f64, h: f64) -> [f64; 4] { + use photocraft_geom::warp::WarpStyle; let rect = [0.0, 0.0, w, h]; - let Some(m) = warp.filter(|wp| wp.style == photocraft_geom::warp::WarpStyle::Custom).and_then(|wp| wp.mesh.as_ref()).filter(|m| m.points.len() == 16) + let Some(m) = warp + .and_then(|wp| wp.mesh.as_ref().map(|m| (wp.style, m))) + .filter(|(style, m)| (*style == WarpStyle::Custom && m.points.len() == 16) || *style == WarpStyle::Cylinder) + .map(|(_, m)| m) else { return rect; }; @@ -608,6 +626,16 @@ pub(crate) fn placed_frame(warp: Option<&photocraft_geom::warp::Warp>, w: f64, h if ok { b } else { rect } } +/// The source-space box a projective (Distort / Perspective) placement maps onto its corners: a +/// cylinder's control-point box, as for an affine placement (#4112), else the source rect. A +/// custom warp keeps the source rect here: there is no Photoshop reference for that combination. +pub(crate) fn perspective_frame(warp: Option<&photocraft_geom::warp::Warp>, w: f64, h: f64) -> [f64; 4] { + match warp { + Some(wp) if wp.style == photocraft_geom::warp::WarpStyle::Cylinder => placed_frame(warp, w, h), + _ => [0.0, 0.0, w, h], + } +} + /// Smart object identifier and transform from `SoLd`/`SoLE` (best effort). A `PlLd` block /// stores no source size, so its transform needs the embedded file: see [`parse_plld`]. pub fn parse_smart(key: &[u8; 4], data: &[u8]) -> (String, Affine) { @@ -647,15 +675,15 @@ pub fn corners_affine(p: &[f64; 8], frame: [f64; 4]) -> Option { /// for a source of `size` warped by `warp`: the inverse of [`crate::smart_map::plld_bytes`]'s /// quad. As for `SoLd`'s `Trnf` (#3677), affine corners frame a single-patch custom warp's /// control-point box (which may spill past the source), else the source rect; projective corners -/// frame the source rect, as `parse_smart_perspective` reads them. `PlLd` stores no source size: +/// frame [`perspective_frame`], as `parse_smart_perspective` reads them. `PlLd` stores no source size: /// without the source file (`None`) the layer is taken as placed at 100 %, the edge lengths being /// its size (a custom warp's box needs no size); position and rotation stay right, only Replace /// Contents and re-renders depend on the scale. Import and export (which keeps an unedited record /// verbatim) both place a `PlLd` layer with this. pub fn plld_transform(p: &[f64; 8], size: Option<(f64, f64)>, warp: Option<&photocraft_geom::warp::Warp>) -> (Affine, Option<[f64; 9]>) { let (w, h) = size.unwrap_or_else(|| ((p[2] - p[0]).hypot(p[3] - p[1]), (p[6] - p[0]).hypot(p[7] - p[1]))); - let perspective = corners_perspective([[p[0], p[1]], [p[2], p[3]], [p[4], p[5]], [p[6], p[7]]], (w, h)); - let frame = if perspective.is_some() { [0.0, 0.0, w, h] } else { placed_frame(warp, w, h) }; + let perspective = corners_perspective_in([[p[0], p[1]], [p[2], p[3]], [p[4], p[5]], [p[6], p[7]]], perspective_frame(warp, w, h)); + let frame = if perspective.is_some() { perspective_frame(warp, w, h) } else { placed_frame(warp, w, h) }; (corners_affine(p, frame).unwrap_or(Affine::IDENTITY), perspective) } @@ -730,18 +758,26 @@ pub fn parse_smart_perspective(key: &[u8; 4], data: &[u8]) -> Option<[f64; 9]> { (p.len() == 8 && p.iter().all(|v| v.is_finite())).then(|| [[p[0], p[1]], [p[2], p[3]], [p[4], p[5]], [p[6], p[7]]]) }; let q = quad("nonAffineTransform").or_else(|| quad("Trnf"))?; - corners_perspective(q, (w, h)) + let warp = get_desc(&d, "warp").and_then(warp_of).flatten(); + corners_perspective_in(q, perspective_frame(warp.as_ref(), w, h)) } /// The projective placement of a `w` × `h` source onto corners `q` that aren't a parallelogram; /// `None` for affine corners (see [`corners_affine`]) or an empty size. pub fn corners_perspective(q: [[f64; 2]; 4], (w, h): (f64, f64)) -> Option<[f64; 9]> { + corners_perspective_in(q, [0.0, 0.0, w, h]) +} + +/// [`corners_perspective`] for the source-space box `frame` (left, top, right, bottom; see +/// [`perspective_frame`]). +pub(crate) fn corners_perspective_in(q: [[f64; 2]; 4], frame: [f64; 4]) -> Option<[f64; 9]> { // A parallelogram (top-left + bottom-right = top-right + bottom-left) is affine. let tol = 1e-6 * (1.0 + q.iter().flatten().fold(0.0f64, |m, v| m.max(v.abs()))); - if (0..2).all(|i| (q[0][i] + q[2][i] - q[1][i] - q[3][i]).abs() <= tol) || w <= 0.0 || h <= 0.0 { + let ok = frame.iter().all(|v| v.is_finite()) && frame[2] > frame[0] && frame[3] > frame[1]; + if (0..2).all(|i| (q[0][i] + q[2][i] - q[1][i] - q[3][i]).abs() <= tol) || !ok { return None; } - photocraft_algo::transform::Homography::rect_to_quad([0.0, 0.0, w, h], q).map(|m| m.0) + photocraft_algo::transform::Homography::rect_to_quad(frame, q).map(|m| m.0) } /// `masterFXSwitch` from an `lfx2` block (defaults to `true`). @@ -1239,6 +1275,121 @@ mod more_tests { assert_eq!(placed_frame(None, 50.0, 25.0), [0.0, 0.0, 50.0, 25.0]); } + /// A `SoLd` placed on `quad` (`Trnf` and `nonAffineTransform`) for a 1000 × 1000 source, + /// warped by `warp`. + fn sold_placed(quad: [f64; 8], warp: Descriptor) -> Vec { + let list = Value::List(quad.iter().map(|v| Value::Double(*v)).collect()); + let d = Descriptor::new("null") + .with("Trnf", list.clone()) + .with("nonAffineTransform", list) + .with("Sz ", Value::Descriptor(Descriptor::new("Pnt ").with("Wdth", Value::Double(1000.0)).with("Hght", Value::Double(1000.0)))) + .with("warp", Value::Descriptor(warp)); + let mut data = b"soLD".to_vec(); + data.extend_from_slice(&4u32.to_be_bytes()); + data.extend(VersionedDescriptor::new(d).to_bytes()); + data + } + + /// A `warpCylinder` descriptor as #4112 describes it: horizontal, no perspective, seven + /// `warpValues` in the space of `bounds`. + fn cylinder_desc(values: Value) -> Descriptor { + let e = |t: &str, v: &str| Value::Enumerated { type_id: Id::new(t), value: Id::new(v) }; + let bounds = Descriptor::new("classFloatRect") + .with("Top ", Value::Double(0.0)) + .with("Left", Value::Double(0.0)) + .with("Btom", Value::Double(1000.0)) + .with("Rght", Value::Double(1000.0)); + Descriptor::new("warp") + .with("warpStyle", e("warpStyle", "warpCylinder")) + .with("warpValue", Value::Double(0.0)) + .with("warpValues", values) + .with("warpPerspective", Value::Double(0.0)) + .with("warpPerspectiveOther", Value::Double(0.0)) + .with("warpRotate", e("Ornt", "Hrzn")) + .with("bounds", Value::Descriptor(bounds)) + } + + const CYL: [f64; 7] = [100.0, 800.0, 900.0, 200.0, 0.3, 0.3, 0.5]; + + fn doubles(v: &[f64]) -> Value { + Value::List(v.iter().map(|x| Value::Double(*x)).collect()) + } + + /// #4112: a `warpCylinder` placed layer comes in as the cylinder its seven values describe, + /// instead of no warp (which re-rendered the contents flat). + #[test] + fn placed_cylinder_warp_is_read() { + use photocraft_geom::warp::{Warp, WarpStyle}; + let quad = [0.0, 0.0, 800.0, 0.0, 800.0, 800.0, 0.0, 800.0]; + let want = Warp::cylinder(&CYL, [0.0, 0.0, 1000.0, 1000.0]).unwrap(); + let w = parse_placed_warp(b"SoLd", &sold_placed(quad, cylinder_desc(doubles(&CYL)))).expect("a cylinder"); + assert_eq!(w, want); + assert_eq!(w.style, WarpStyle::Cylinder); + // Values written as one unit-float list read the same. + let floats = Value::UnitFloats { unit: *b"#Pxl", values: CYL.to_vec() }; + assert_eq!(parse_placed_warp(b"SoLE", &sold_placed(quad, cylinder_desc(floats))), Some(want)); + } + + /// Cylinders nobody has measured (vertical, with perspective) and broken values stay + /// unreadable, as every cylinder was before: the layer keeps the pixels Photoshop stored. + #[test] + fn placed_cylinder_warps_that_cant_be_read() { + let quad = [0.0, 0.0, 800.0, 0.0, 800.0, 800.0, 0.0, 800.0]; + let read = |d: Descriptor| parse_placed_warp(b"SoLd", &sold_placed(quad, d)); + let e = |t: &str, v: &str| Value::Enumerated { type_id: Id::new(t), value: Id::new(v) }; + let with = |key: &str, v: Value| { + let mut d = cylinder_desc(doubles(&CYL)); + d.items.iter_mut().filter(|(k, _)| k.is(key)).for_each(|(_, old)| *old = v.clone()); + d + }; + assert!(read(with("warpRotate", e("Ornt", "Vrtc"))).is_none(), "vertical"); + assert!(read(with("warpPerspective", Value::Double(20.0))).is_none(), "perspective"); + assert!(read(with("warpPerspectiveOther", Value::Double(-5.0))).is_none(), "the other perspective"); + assert!(read(cylinder_desc(doubles(&CYL[..6]))).is_none(), "six values"); + assert!(read(cylinder_desc(Value::List(vec![Value::Text(UnicodeString::new_nul("x")); 7]))).is_none(), "not numbers"); + assert!(read(cylinder_desc(Value::Double(1.0))).is_none(), "one number"); + let mut flipped = CYL; + flipped.swap(0, 2); + assert!(read(cylinder_desc(doubles(&flipped))).is_none(), "silhouettes swapped"); + let mut no_values = cylinder_desc(doubles(&CYL)); + no_values.items.retain(|(k, _)| !k.is("warpValues")); + assert!(read(no_values).is_none(), "no warpValues"); + } + + /// Like a custom warp's (#3677), a cylinder's control-point box is what the placement quad + /// frames, for affine corners and for projective ones (`nonAffineTransform`). + #[test] + fn placed_cylinder_quad_frames_its_control_box() { + use photocraft_geom::warp::Warp; + let cb = Warp::cylinder(&CYL, [0.0, 0.0, 1000.0, 1000.0]).unwrap().mesh.unwrap().control_bounds(); + // Affine: the box lands on the quad. + let quad = [10.0, 20.0, 410.0, 20.0, 410.0, 520.0, 10.0, 520.0]; + let (_, a) = parse_smart(b"SoLd", &sold_placed(quad, cylinder_desc(doubles(&CYL)))); + let [m0, m1, m2, m3, m4, m5] = a.m; + let map = |x: f64, y: f64| (m0 * x + m2 * y + m4, m1 * x + m3 * y + m5); + for ((x, y), (qx, qy)) in + [(cb[0], cb[1]), (cb[2], cb[1]), (cb[2], cb[3]), (cb[0], cb[3])].into_iter().zip(quad.as_chunks::<2>().0.iter().map(|p| (p[0], p[1]))) + { + let (px, py) = map(x, y); + assert!((px - qx).abs() < 1e-9 && (py - qy).abs() < 1e-9, "{x},{y} → {px},{py}, not {qx},{qy}"); + } + assert!(parse_smart_perspective(b"SoLd", &sold_placed(quad, cylinder_desc(doubles(&CYL)))).is_none(), "affine"); + // Projective: the same box lands on the four corners. + let quad = [10.0, 20.0, 410.0, 60.0, 400.0, 480.0, 30.0, 520.0]; + let h = photocraft_algo::transform::Homography(parse_smart_perspective(b"SoLd", &sold_placed(quad, cylinder_desc(doubles(&CYL)))).expect("projective")); + for ((x, y), (qx, qy)) in + [(cb[0], cb[1]), (cb[2], cb[1]), (cb[2], cb[3]), (cb[0], cb[3])].into_iter().zip(quad.as_chunks::<2>().0.iter().map(|p| (p[0], p[1]))) + { + let (px, py) = h.apply(x, y); + assert!((px - qx).abs() < 1e-6 && (py - qy).abs() < 1e-6, "{x},{y} → {px},{py}, not {qx},{qy}"); + } + // Without a warp a projective quad still frames the source rect. + let none = Descriptor::new("warp").with("warpStyle", Value::Enumerated { type_id: Id::new("warpStyle"), value: Id::new("warpNone") }); + let h = photocraft_algo::transform::Homography(parse_smart_perspective(b"SoLd", &sold_placed(quad, none)).expect("projective")); + let (px, py) = h.apply(1000.0, 1000.0); + assert!((px - 400.0).abs() < 1e-6 && (py - 480.0).abs() < 1e-6); + } + #[test] fn effects_switch() { let mut lfx = vec![0, 0, 0, 0]; diff --git a/crates/io/src/smart_map.rs b/crates/io/src/smart_map.rs index 6eeda61a13..4f46a7bbd5 100644 --- a/crates/io/src/smart_map.rs +++ b/crates/io/src/smart_map.rs @@ -692,7 +692,8 @@ pub struct PlacedSpec<'a> { /// Where the frame corners land (top-left, top-right, bottom-right, bottom-left), as x, y pairs. /// The frame is [`crate::blocks::placed_frame`] for an affine placement (the inverse of -/// `parse_smart`), the source rect for a projective one (as `parse_smart_perspective` reads it). +/// `parse_smart`), [`crate::blocks::perspective_frame`] for a projective one (as +/// `parse_smart_perspective` reads it). fn quad_points(s: &PlacedSpec<'_>) -> [f64; 8] { let (w, h) = s.size; let [a, b, c, d, e, f] = s.transform.m; @@ -700,7 +701,7 @@ fn quad_points(s: &PlacedSpec<'_>) -> [f64; 8] { Some(p) => photocraft_algo::transform::Homography(*p).apply(x, y), None => (a * x + c * y + e, b * x + d * y + f), }; - let [x0, y0, x1, y1] = if s.perspective.is_some() { [0.0, 0.0, w, h] } else { crate::blocks::placed_frame(s.warp, w, h) }; + let [x0, y0, x1, y1] = if s.perspective.is_some() { crate::blocks::perspective_frame(s.warp, w, h) } else { crate::blocks::placed_frame(s.warp, w, h) }; let mut out = [0.0; 8]; for (i, (x, y)) in [(x0, y0), (x1, y0), (x1, y1), (x0, y1)].into_iter().enumerate() { (out[2 * i], out[2 * i + 1]) = map(x, y); @@ -726,7 +727,7 @@ fn enumv(t: &str, v: &str) -> Value { } /// The `warp` descriptor (also the `PlLd` warp). Multi-patch meshes have no 1 × 1 envelope and -/// are written as no warp, with a message. +/// are written as no warp, with a message. A cylinder is written as its seven `warpValues`. fn warp_desc(w: Option<&Warp>, size: (f64, f64), warnings: &mut Vec) -> Value { let none = Warp::none([0.0, 0.0, size.0, size.1]); let mut w = w.unwrap_or(&none).clone(); @@ -745,9 +746,11 @@ fn warp_desc(w: Option<&Warp>, size: (f64, f64), warnings: &mut Vec) -> .with("Left", Value::Double(x0)) .with("Btom", Value::Double(y1)) .with("Rght", Value::Double(x1)); - let mut d = Descriptor::new("warp") - .with("warpStyle", enumv("warpStyle", w.style.psd_name())) - .with("warpValue", Value::Double(w.bend)) + let mut d = Descriptor::new("warp").with("warpStyle", enumv("warpStyle", w.style.psd_name())).with("warpValue", Value::Double(w.bend)); + if w.style == WarpStyle::Cylinder { + d = d.with("warpValues", Value::List(w.values.iter().copied().map(Value::Double).collect())); + } + let mut d = d .with("warpPerspective", Value::Double(w.h_distort)) .with("warpPerspectiveOther", Value::Double(w.v_distort)) .with("warpRotate", enumv("Ornt", if w.vertical { "Vrtc" } else { "Hrzn" })) @@ -1424,6 +1427,53 @@ mod tests { assert!(!quad_moved(&p.descriptor, &spec)); } + /// #4112: a regenerated `SoLd` (after Replace Contents, a move…) writes a cylinder back as + /// `warpCylinder` and its seven values, not as no warp, and frames its control-point box with + /// the quad, affine or projective, so import places it where it was. + #[test] + fn cylinder_warp_round_trips_through_sold() { + let v = [100.0, 800.0, 900.0, 200.0, 0.3, 0.3, 0.5]; + let warp = Warp::cylinder(&v, [0.0, 0.0, 1000.0, 1000.0]).unwrap(); + let transform = Affine { m: [0.5, 0.0, 0.0, 0.5, 40.0, 30.0] }; + let mut spec = + PlacedSpec { idnt: "i", placed: "p", transform, perspective: None, size: (1000.0, 1000.0), dpi: 72.0, warp: Some(&warp), filter_fx: None }; + let mut warnings = Vec::new(); + let sold = sold_bytes(None, &spec, &mut warnings); + assert!(warnings.is_empty(), "{warnings:?}"); + let p = parse_sold(&sold).expect("parses"); + let Some(Value::Descriptor(w)) = p.descriptor.get("warp") else { panic!("no warp") }; + assert_eq!(crate::blocks::enum_of(w, "warpStyle"), Some(b"warpCylinder".as_slice())); + let Some(Value::List(values)) = w.get("warpValues") else { panic!("no warpValues") }; + assert_eq!(values.iter().filter_map(|x| num(Some(x))).collect::>(), v); + assert!(w.get("customEnvelopeWarp").is_none()); + assert_eq!(crate::blocks::parse_placed_warp(b"SoLd", &sold), Some(warp.clone())); + for (a, b) in p.transform.m.iter().zip(transform.m) { + assert!((a - b).abs() < 1e-9, "{:?}", p.transform); + } + // The quad is the image of the control-point box, not of the source rect. + let cb = warp.mesh.as_ref().unwrap().control_bounds(); + let Some(Value::List(q)) = p.descriptor.get("Trnf") else { panic!("no Trnf") }; + let q: Vec = q.iter().filter_map(|x| num(Some(x))).collect(); + let want = [cb[0], cb[1], cb[2], cb[1], cb[2], cb[3], cb[0], cb[3]].map(|c| 0.5 * c); + for (i, (a, b)) in q.iter().zip(want).enumerate() { + let shift = if i % 2 == 0 { 40.0 } else { 30.0 }; + assert!((a - (b + shift)).abs() < 1e-9, "corner {i}: {q:?}"); + } + assert!(!quad_moved(&p.descriptor, &spec)); + // A projective placement comes back as the same map. + let h = photocraft_algo::transform::Homography::rect_to_quad(cb, [[10.0, 20.0], [410.0, 60.0], [400.0, 480.0], [30.0, 520.0]]).unwrap(); + spec.perspective = Some(h.0); + let sold = sold_bytes(None, &spec, &mut warnings); + let back = crate::blocks::parse_smart_perspective(b"SoLd", &sold).expect("projective"); + let n = |m: [f64; 9]| m.map(|x| x / m[8]); + for (a, b) in n(back).iter().zip(n(h.0)) { + assert!((a - b).abs() < 1e-9 * (1.0 + b.abs()), "{back:?} vs {:?}", h.0); + } + let plld = plld_bytes(&spec, &mut warnings); + assert_eq!(crate::blocks::parse_plld_warp(&plld), crate::blocks::PlldWarp::Warp(warp)); + assert!(warnings.is_empty(), "{warnings:?}"); + } + #[test] fn hex_and_uuid() { assert_eq!(from_hex(&to_hex(&[0, 1, 0xab, 0xff])), Some(vec![0, 1, 0xab, 0xff])); diff --git a/crates/io/tests/cylinder_warp.rs b/crates/io/tests/cylinder_warp.rs new file mode 100644 index 0000000000..be75e31505 --- /dev/null +++ b/crates/io/tests/cylinder_warp.rs @@ -0,0 +1,123 @@ +//! Smart objects warped with Photoshop's Cylinder (#4112) through PSD persistence and a re-render +//! from their contents, as Replace Contents, Relink and Edit Contents do. + +use std::sync::Arc; + +use photocraft_color::{ColorMode, SampleType}; +use photocraft_doc::{Document, Layer, LayerContent, SmartObject, SmartSource}; +use photocraft_geom::warp::{Warp, WarpStyle}; +use photocraft_geom::{Affine, Rect, Size}; +use photocraft_io::{ExportOptions, export, import, smart_map}; +use photocraft_psd::PsdFile; +use photocraft_raster::Surface; + +/// Silhouettes at x 10 and 90, edges at y 20 and 80, ellipses 0.3 deep, wrapped as little as +/// Photoshop allows (a sixth of the contents on the back on each side). +const VALUES: [f64; 7] = [10.0, 80.0, 90.0, 20.0, 0.3, 0.3, 0.0]; + +/// A 100 × 100 source: a red band at the left and a blue band at the right (both on the back of +/// the cylinder), green in between. +fn contents() -> Surface { + let mut s = Surface::new(photocraft_color::PixelFormat::new(ColorMode::Rgb, SampleType::U8, true)); + s.fill_rect(Rect::new(0, 0, 100, 100), &[0.0, 1.0, 0.0, 1.0]); + s.fill_rect(Rect::new(0, 0, 5, 100), &[1.0, 0.0, 0.0, 1.0]); + s.fill_rect(Rect::new(95, 0, 100, 100), &[0.0, 0.0, 1.0, 1.0]); + s +} + +fn document(transform: Affine, perspective: Option<[f64; 9]>) -> (Document, Warp) { + let pixels = contents(); + let mut source = Document::new("label", Size::new(100, 100), ColorMode::Rgb, SampleType::U8); + source.layers.push(Layer::new("art", LayerContent::Raster(pixels.clone()))); + let bytes = photocraft_format::save_to_bytes(&source, &Default::default()).unwrap(); + let warp = Warp::cylinder(&VALUES, [0.0, 0.0, 100.0, 100.0]).unwrap(); + let mut sm = SmartObject::new(SmartSource::Embedded { file_name: "label.pcraft".into(), bytes: Arc::new(bytes) }, transform, None); + sm.warp = Some(warp.clone()); + sm.perspective = perspective; + sm.cache = Some(render(&sm)); + let mut doc = Document::new("jar", Size::new(160, 160), ColorMode::Rgb, SampleType::U8); + doc.layers.push(Layer::new("label", LayerContent::Smart(sm))); + (doc, warp) +} + +/// The smart object drawn from its contents, as the engine re-renders it. +fn render(sm: &SmartObject) -> Surface { + let src = contents(); + match &sm.perspective { + Some(p) => { + photocraft_algo::warp::place_source_projective(&src, Rect::new(0, 0, 100, 100), &photocraft_algo::transform::Homography(*p), sm.warp.as_ref()) + } + None => photocraft_algo::warp::place_source(&src, Rect::new(0, 0, 100, 100), &sm.transform, sm.warp.as_ref()), + } + .unwrap() +} + +fn smart(doc: &Document) -> &SmartObject { + let LayerContent::Smart(sm) = &doc.layers[0].content else { panic!("not a smart object") }; + sm +} + +fn round_trip(doc: &Document) -> (PsdFile, Document) { + let out = export(doc, "psd", &ExportOptions::default()).unwrap(); + assert!(!out.warnings.iter().any(|w| w.contains("warp") || w.contains("written as pixels")), "{:?}", out.warnings); + (PsdFile::from_bytes(&out.bytes).unwrap(), import("psd", &out.bytes).unwrap().document) +} + +/// Opaque pixels of the render that are mostly `channel` (0 red, 1 green, 2 blue). +fn count(s: &Surface, channel: usize) -> usize { + let r = s.content_bounds(); + s.read_region(r).chunks_exact(4).filter(|p| p[3] > 0.5 && p[channel] > 0.5 && (0..3).all(|c| c == channel || p[c] < 0.5)).count() +} + +/// Before #4112 a cylinder was read as no warp: re-rendering the contents drew them flat, the +/// red and blue bands that wrap round the back included. Now the PSD keeps the cylinder and the +/// re-render hides the back and centres the front between the silhouettes. +#[test] +fn a_cylinder_survives_psd_and_wraps_the_contents_again() { + let transform = Affine { m: [1.0, 0.0, 0.0, 1.0, 30.0, 20.0] }; + let (doc, warp) = document(transform, None); + let (file, back) = round_trip(&doc); + let layer = file.layers().iter().find(|l| l.name() == "label").unwrap(); + let sold = smart_map::parse_sold(&layer.block(b"SoLd").unwrap().data).unwrap(); + let Some(photocraft_psd::descriptor::Value::Descriptor(w)) = sold.descriptor.get("warp") else { panic!("no warp") }; + assert!(matches!(w.get("warpStyle"), Some(photocraft_psd::descriptor::Value::Enumerated { value, .. }) if value.as_bytes() == b"warpCylinder")); + let sm = smart(&back); + assert_eq!(sm.warp.as_ref().map(|w| w.style), Some(WarpStyle::Cylinder)); + assert_eq!(sm.warp.as_ref(), Some(&warp)); + for (a, b) in sm.transform.m.iter().zip(transform.m) { + assert!((a - b).abs() < 1e-9, "{:?}", sm.transform); + } + let out = render(sm); + assert_eq!((count(&out, 0), count(&out, 2)), (0, 0), "the bands on the back are hidden"); + assert!(count(&out, 1) > 3000, "the front is drawn"); + // Between the silhouettes (x 10 and 90, shifted by 30) and no further. + let b = out.content_bounds(); + assert!(b.x0 >= 39 && b.x1 <= 121, "{b:?}"); + // The middle of the contents is at the front, centred. + let mid = out.pixel(80, 60); + assert!(mid[1] > 0.9 && mid[3] > 0.9, "{mid:?}"); + // Saved again unchanged, the block is written as it was read. + let (again, _) = round_trip(&back); + let layer2 = again.layers().iter().find(|l| l.name() == "label").unwrap(); + assert_eq!(layer2.block(b"SoLd").unwrap().data, layer.block(b"SoLd").unwrap().data); +} + +/// Mockups usually place the label in perspective (`nonAffineTransform`): that placement and +/// the cylinder both come back. +#[test] +fn a_cylinder_in_perspective_survives_psd() { + let cb = Warp::cylinder(&VALUES, [0.0, 0.0, 100.0, 100.0]).unwrap().mesh.unwrap().control_bounds(); + let h = photocraft_algo::transform::Homography::rect_to_quad(cb, [[20.0, 20.0], [140.0, 30.0], [135.0, 150.0], [25.0, 140.0]]).unwrap(); + let (doc, warp) = document(Affine::IDENTITY, Some(h.0)); + let (_, back) = round_trip(&doc); + let sm = smart(&back); + assert_eq!(sm.warp.as_ref(), Some(&warp)); + let p = sm.perspective.expect("still projective"); + let n = |m: [f64; 9]| m.map(|v| v / m[8]); + for (a, b) in n(p).iter().zip(n(h.0)) { + assert!((a - b).abs() < 1e-9 * (1.0 + b.abs()), "{p:?} vs {:?}", h.0); + } + let out = render(sm); + assert_eq!((count(&out, 0), count(&out, 2)), (0, 0)); + assert!(count(&out, 1) > 3000); +} From 0981fd79d32e6147d86f7b3c25378782894704b5 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 14 Oct 2026 20:59:02 +0000 Subject: [PATCH 069/649] Warp commands take a cylinder; docs for #4112 - `edit.transform.warp` / `layer.smartObjects.warp`: `style: "cylinder"` with its seven `values` (document px; depths in half axes), or a full `warp` object whose mesh is rebuilt from its values. Anything that isn't a horizontal cylinder without distortion is refused, never a silent no-op; on type it is refused like a custom mesh. - On a smart object the cylinder is stored in source space: still a cylinder (so it goes to PSD as one) when the placement only scales and moves, its mesh as a custom warp otherwise. - docs: file-format-parity (PSD row, history) and gaps G1. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EuC9R3K5QeMBrDkixa1jnt --- crates/engine/src/warp_cmds.rs | 135 ++++++++++++++++++++++++++++++++- crates/io/src/blocks.rs | 15 ++-- crates/io/src/smart_map.rs | 2 +- docs/file-format-parity.md | 5 +- docs/gaps.md | 7 +- 5 files changed, 148 insertions(+), 16 deletions(-) diff --git a/crates/engine/src/warp_cmds.rs b/crates/engine/src/warp_cmds.rs index 5142b0a940..87811f7346 100644 --- a/crates/engine/src/warp_cmds.rs +++ b/crates/engine/src/warp_cmds.rs @@ -71,10 +71,14 @@ pub fn smart_warp_doc_space(layer: &Layer) -> Option { } /// Parses the warp params: a full `"warp"` object, or `"style"` (+ `"bend"`, `"hDistort"`, -/// `"vDistort"`, `"vertical"`), `"mesh"` and `"grid"` over `rect`. +/// `"vDistort"`, `"vertical"`; `"values"` for a cylinder), `"mesh"` and `"grid"` over `rect`. pub fn warp_from_params(cmd: &str, p: &Value, rect: [f64; 4]) -> Result { if let Some(w) = p.get("warp") { - let w: Warp = serde_json::from_value(w.clone()).map_err(|e| bad(cmd, format!("bad `warp`: {e}")))?; + let mut w: Warp = serde_json::from_value(w.clone()).map_err(|e| bad(cmd, format!("bad `warp`: {e}")))?; + // A cylinder is its values: the mesh is rebuilt from them, whatever was passed. + if w.style == WarpStyle::Cylinder { + w = Warp::cylinder(&w.values, w.bounds).ok_or_else(|| bad(cmd, CYLINDER_VALUES))?; + } if w.mesh.as_ref().is_some_and(|m| !m.is_valid()) { return Err(bad(cmd, "malformed warp mesh")); } @@ -90,6 +94,13 @@ pub fn warp_from_params(cmd: &str, p: &Value, rect: [f64; 4]) -> Result { w.h_distort = num("hDistort", 0.0); w.v_distort = num("vDistort", 0.0); w.vertical = p.get("vertical").and_then(Value::as_bool).unwrap_or(false); + if style == WarpStyle::Cylinder { + if w.vertical || w.h_distort != 0.0 || w.v_distort != 0.0 { + return Err(bad(cmd, "a cylinder is horizontal, with no hDistort or vDistort")); + } + let values: Option> = p.get("values").and_then(Value::as_array).and_then(|a| a.iter().map(Value::as_f64).collect()); + return values.and_then(|v| Warp::cylinder(&v, rect)).ok_or_else(|| bad(cmd, CYLINDER_VALUES)); + } if style == WarpStyle::Custom { let mesh = match p.get("mesh") { Some(m) => { @@ -110,6 +121,30 @@ pub fn warp_from_params(cmd: &str, p: &Value, rect: [f64; 4]) -> Result { Ok(w) } +const CYLINDER_VALUES: &str = + "a cylinder needs `values`: seven numbers [left, bottom, right, top, top depth, bottom depth, wrap 0..1], the right silhouette right of the left one"; + +/// A document-space cylinder `w` stored on a smart object, whose placement's inverse is `inv` and +/// whose warp box `w.bounds` lands on `sb` in source space. A placement that only scales and +/// moves keeps it a cylinder (written to PSD as one): the silhouettes and edges map, and the +/// ellipses' depth, in units of the half axis, follows the change of aspect. Otherwise (rotated, +/// skewed, flipped, in perspective) it becomes its mesh, a custom warp. +fn cylinder_in_source(w: &Warp, inv: &Homography, sb: [f64; 4]) -> Option { + let m = inv.0; + let axis_aligned = m[8] != 0.0 && m[1] == 0.0 && m[3] == 0.0 && m[6] == 0.0 && m[7] == 0.0; + let (sx, sy) = (m[0] / m[8], m[4] / m[8]); + if axis_aligned && sx > 0.0 && sy > 0.0 && w.values.len() == 7 { + let v = &w.values; + let (x, y) = (|v: f64| sx * v + m[2] / m[8], |v: f64| sy * v + m[5] / m[8]); + let k = sy / sx; + if let Some(c) = Warp::cylinder(&[x(v[0]), y(v[1]), x(v[2]), y(v[3]), v[4] * k, v[5] * k, v[6]], sb) { + return Some(c); + } + } + let mesh = w.to_mesh(1, 1).map_points(|p| hom_apply(inv, p)); + Some(Warp::custom(mesh, sb)) +} + /// A Background is turned into a normal layer by the caller first /// ([`crate::extra_cmds::background_to_layer`]). fn warp_layer(doc_sel: Option<&Surface>, group: Locks, l: &mut Layer, w: &Warp, rect: Rect, interp: Interp, frames: Option<&Frames>) -> Result<()> { @@ -146,6 +181,7 @@ fn warp_layer(doc_sel: Option<&Surface>, group: Locks, l: &mut Layer, w: &Warp, None => Some(Warp::custom(mesh, sb)), } } + WarpStyle::Cylinder => cylinder_in_source(w, &inv, sb), _ => Some(Warp { bounds: sb, mesh: None, ..w.clone() }), }; sm.warp = src_warp.filter(|w| !w.is_identity()); @@ -302,6 +338,7 @@ fn type_warp(cmd: &str, w: &Warp) -> Result Ok(None), WarpStyle::Custom if w.is_identity() => Ok(None), WarpStyle::Custom => Err(bad(cmd, "type can only take a warp style (arc, flag, …); a custom mesh needs rasterized type")), + WarpStyle::Cylinder => Err(bad(cmd, "type can only take a warp style (arc, flag, …); a cylinder needs rasterized type")), s => Ok(Some(photocraft_doc::text::TextWarp { style: s.psd_name().into(), value: clamp(w.bend), @@ -546,7 +583,7 @@ fn grid(s: &mut Session, p: &Value) -> Result { } pub fn specs() -> Vec { - const P: &str = r##"{"layer":id?,"rect":[x0,y0,x1,y1]? (warp box; default = layer content ∩ selection),"style":"custom|none|arc|arcLower|arcUpper|arch|bulge|shellLower|shellUpper|flag|wave|fish|rise|fisheye|inflate|squeeze|twist","bend":%=50,"hDistort":%,"vDistort":%,"vertical":bool,"mesh":{"us":[0,…,1],"vs":[0,…,1],"points":[[x,y]…]} ((3c+1)×(3r+1) control points, row-major, document px; on a smart object `us`/`vs` span the source contents, so points equal to the placement are an identity warp even when it is skewed),"grid":[cols,rows]?,"warp":{full warp object}?,"interpolation":"bicubic|bilinear|nearest"} — on a type layer a style (or none) sets its Warp Text and the type stays editable"##; + const P: &str = r##"{"layer":id?,"rect":[x0,y0,x1,y1]? (warp box; default = layer content ∩ selection),"style":"custom|none|arc|arcLower|arcUpper|arch|bulge|shellLower|shellUpper|flag|wave|fish|rise|fisheye|inflate|squeeze|twist|cylinder","bend":%=50,"hDistort":%,"vDistort":%,"vertical":bool,"values":[left,bottom,right,top,topDepth,bottomDepth,wrap]? (cylinder: silhouettes and edges in document px, the ellipses' depths in half-axis units, wrap 0..1; horizontal only),"mesh":{"us":[0,…,1],"vs":[0,…,1],"points":[[x,y]…]} ((3c+1)×(3r+1) control points, row-major, document px; on a smart object `us`/`vs` span the source contents, so points equal to the placement are an identity warp even when it is skewed),"grid":[cols,rows]?,"warp":{full warp object}?,"interpolation":"bicubic|bilinear|nearest"} — on a type layer a style (or none) sets its Warp Text and the type stays editable"##; const S: &str = r##"{"warp":{…}? (the warp being edited; returned split),"rect":[x0,y0,x1,y1]?,"at":[x,y]? (document point; default = middle of the patch)} — without `warp`, edits the active smart object's warp. A 1×1 custom mesh is divided at the thirds first (the guides drawn on the default grid), so splitWarpCrosswise on an identity custom warp returns a 4×4 mesh (knots at 0, 1/3, 1/2, 2/3 and 1), not a 2×2. A preset is fitted as one patch and split without that step."##; const G: &str = r##"{"warp":{…}? (the warp being edited; returned with the new mesh),"rect":[x0,y0,x1,y1]?,"size":n|"default"|"3"|"4"|"5" (square patches, 1..=64; 1 and "default" are the single-patch grid)} — without `warp`/`style`/`mesh`, edits the active smart object's warp. The surface is kept and the new lines are real splits at i/n."##; vec![ @@ -668,6 +705,98 @@ mod tests { assert!(s.execute("edit.transform.warp", json!({"warp": Warp::custom(mesh, [0.0, 0.0, 10.0, 10.0])})).is_err()); } + /// The seven values of a cylinder over the session's painted box (x 10..60, y 10..40). + const CYL: [f64; 7] = [10.0, 40.0, 60.0, 10.0, 0.3, 0.3, 0.5]; + + /// `style: "cylinder"` takes its seven values (#4112); anything that isn't a horizontal + /// cylinder is refused, never a silent no-op, and the layer is left alone. + #[test] + fn cylinder_style_needs_its_values() { + let mut s = session(8); + let before = active_surface(&s); + for p in [ + json!({"style": "cylinder"}), + json!({"style": "cylinder", "values": [10, 40, 60, 10, 0.3, 0.3]}), + json!({"style": "cylinder", "values": [60, 40, 10, 10, 0.3, 0.3, 0.5]}), + json!({"style": "cylinder", "values": [10, 40, 60, 10, 0.3, 0.3, "x"]}), + json!({"style": "cylinder", "values": "seven"}), + json!({"style": "cylinder", "values": CYL, "vertical": true}), + json!({"style": "cylinder", "values": CYL, "hDistort": 10}), + json!({"warp": {"style": "cylinder", "bounds": [10.0, 10.0, 60.0, 40.0]}}), + ] { + let e = s.execute("edit.transform.warp", p.clone()).unwrap_err().to_string(); + assert!(e.contains("cylinder"), "{p}: {e}"); + } + assert_eq!(active_surface(&s), before); + // On type it is refused like a custom mesh: Warp Text has no cylinder. + s.execute("type.create", json!({"x": 10, "y": 50, "text": "Hi"})).unwrap(); + assert!(s.execute("edit.transform.warp", json!({"style": "cylinder", "values": CYL})).is_err()); + } + + #[test] + fn cylinder_warps_pixels_at_every_depth() { + for depth in [8u64, 16, 32] { + let mut s = session(depth); + let r = s.execute("edit.transform.warp", json!({"style": "cylinder", "values": CYL})).unwrap(); + assert_eq!(r["changed"], true, "{depth}"); + let after = active_surface(&s); + let b = after.content_bounds(); + // Between the silhouettes, the edges bowed down by the ellipses. + assert!(b.x0 >= 9 && b.x1 <= 61 && b.y0 >= 9 && b.y1 > 40, "{depth}: {b:?}"); + // The same cylinder as a full warp object (its mesh rebuilt from the values) agrees. + let mut t = session(depth); + let w = Warp::cylinder(&CYL, [10.0, 10.0, 60.0, 40.0]).unwrap(); + let mut garbled = w.clone(); + garbled.mesh = None; + t.execute("edit.transform.warp", json!({"warp": garbled})).unwrap(); + assert_eq!(active_surface(&t), after, "{depth}"); + } + } + + /// On a smart object the cylinder is stored in source space: still a cylinder (so it goes to + /// PSD as one) when the placement only scales and moves, its mesh when it rotates. + #[test] + fn smart_object_cylinder_is_stored_in_source_space() { + let stored = |s: &Session| { + let st = s.active().unwrap(); + let LayerContent::Smart(sm) = &st.doc.layer(st.active_layer.unwrap()).unwrap().content else { panic!("smart") }; + sm.warp.clone().unwrap() + }; + let mut s = session(8); + s.execute("layer.smartObjects.convertToSmartObject", json!({})).unwrap(); + s.execute("layer.smartObjects.warp", json!({"style": "cylinder", "values": CYL, "rect": [10, 10, 60, 40]})).unwrap(); + let w = stored(&s); + assert_eq!(w.style, WarpStyle::Cylinder); + let LayerContent::Smart(sm) = &s.active().unwrap().doc.layers[1].content else { panic!("smart") }; + let inv = crate::smart_cmds::placement(sm).inverse().unwrap(); + let src = |x: f64, y: f64| inv.apply(x, y); + let ((l, t), (r, bt)) = (src(10.0, 10.0), src(60.0, 40.0)); + for (a, b) in w.values.iter().zip([l, bt, r, t, 0.3, 0.3, 0.5]) { + assert!((a - b).abs() < 1e-9, "{:?}", w.values); + } + // Twice as wide: the silhouettes double, the ellipses' depth (in half axes) halves. + let mut s = session(8); + s.execute("layer.smartObjects.convertToSmartObject", json!({})).unwrap(); + s.execute("edit.transform", json!({"scaleX": 200, "scaleY": 100})).unwrap(); + let wide = [-15.0, 40.0, 85.0, 10.0, 0.3, 0.3, 0.5]; + s.execute("layer.smartObjects.warp", json!({"style": "cylinder", "values": wide, "rect": [-15, 10, 85, 40]})).unwrap(); + let w = stored(&s); + assert_eq!(w.style, WarpStyle::Cylinder); + assert!((w.values[4] - 0.6).abs() < 1e-9 && (w.values[5] - 0.6).abs() < 1e-9, "{:?}", w.values); + // The silhouettes land on the source's own edges (its contents span the scaled box). + let LayerContent::Smart(sm) = &s.active().unwrap().doc.layers[1].content else { panic!("smart") }; + let inv = crate::smart_cmds::placement(sm).inverse().unwrap(); + assert!((w.values[0] - inv.apply(-15.0, 10.0).0).abs() < 1e-9 && (w.values[2] - inv.apply(85.0, 10.0).0).abs() < 1e-9, "{:?}", w.values); + // Rotated: a custom mesh with the same shape. + let mut s = session(8); + s.execute("layer.smartObjects.convertToSmartObject", json!({})).unwrap(); + s.execute("edit.transform", json!({"rotate": 30})).unwrap(); + s.execute("layer.smartObjects.warp", json!({"style": "cylinder", "values": CYL, "rect": [10, 10, 60, 40]})).unwrap(); + let w = stored(&s); + assert_eq!(w.style, WarpStyle::Custom); + assert_eq!(w.mesh.as_ref().map(|m| (m.nx(), m.ny())), Some((13, 4))); + } + #[test] fn identity_and_bend_zero_are_no_ops_at_every_depth() { for depth in [8u64, 16, 32] { diff --git a/crates/io/src/blocks.rs b/crates/io/src/blocks.rs index a54e07fee7..087f2121d2 100644 --- a/crates/io/src/blocks.rs +++ b/crates/io/src/blocks.rs @@ -527,9 +527,8 @@ pub(crate) fn with_pattern_placement(mut d: Descriptor, angle: f32, link: bool, /// The warp of a placed layer (`SoLd`/`SoLE` `warp` descriptor): style, bend, distortions, /// axis, bounds and, for `warpCustom`, the 4 × 4 `customEnvelopeWarp` mesh, for `warpCylinder` -/// its seven `warpValues`. Read-only: the raw -/// block is what gets written back. `None` when absent or `warpNone` with no mesh. A `PlLd` -/// record keeps its warp elsewhere: see [`parse_plld_warp`]. +/// its seven `warpValues`. Read-only: the raw block is what gets written back. `None` when absent +/// or `warpNone` with no mesh. A `PlLd` record keeps its warp elsewhere: see [`parse_plld_warp`]. pub fn parse_placed_warp(key: &[u8; 4], data: &[u8]) -> Option { if key != b"SoLd" && key != b"SoLE" { return None; @@ -675,11 +674,11 @@ pub fn corners_affine(p: &[f64; 8], frame: [f64; 4]) -> Option { /// for a source of `size` warped by `warp`: the inverse of [`crate::smart_map::plld_bytes`]'s /// quad. As for `SoLd`'s `Trnf` (#3677), affine corners frame a single-patch custom warp's /// control-point box (which may spill past the source), else the source rect; projective corners -/// frame [`perspective_frame`], as `parse_smart_perspective` reads them. `PlLd` stores no source size: -/// without the source file (`None`) the layer is taken as placed at 100 %, the edge lengths being -/// its size (a custom warp's box needs no size); position and rotation stay right, only Replace -/// Contents and re-renders depend on the scale. Import and export (which keeps an unedited record -/// verbatim) both place a `PlLd` layer with this. +/// frame [`perspective_frame`], as `parse_smart_perspective` reads them. `PlLd` stores no source +/// size: without the source file (`None`) the layer is taken as placed at 100 %, the edge lengths +/// being its size (a custom warp's box needs no size); position and rotation stay right, only +/// Replace Contents and re-renders depend on the scale. Import and export (which keeps an unedited +/// record verbatim) both place a `PlLd` layer with this. pub fn plld_transform(p: &[f64; 8], size: Option<(f64, f64)>, warp: Option<&photocraft_geom::warp::Warp>) -> (Affine, Option<[f64; 9]>) { let (w, h) = size.unwrap_or_else(|| ((p[2] - p[0]).hypot(p[3] - p[1]), (p[6] - p[0]).hypot(p[7] - p[1]))); let perspective = corners_perspective_in([[p[0], p[1]], [p[2], p[3]], [p[4], p[5]], [p[6], p[7]]], perspective_frame(warp, w, h)); diff --git a/crates/io/src/smart_map.rs b/crates/io/src/smart_map.rs index 4f46a7bbd5..4e7f955208 100644 --- a/crates/io/src/smart_map.rs +++ b/crates/io/src/smart_map.rs @@ -750,7 +750,7 @@ fn warp_desc(w: Option<&Warp>, size: (f64, f64), warnings: &mut Vec) -> if w.style == WarpStyle::Cylinder { d = d.with("warpValues", Value::List(w.values.iter().copied().map(Value::Double).collect())); } - let mut d = d + d = d .with("warpPerspective", Value::Double(w.h_distort)) .with("warpPerspectiveOther", Value::Double(w.v_distort)) .with("warpRotate", enumv("Ornt", if w.vertical { "Vrtc" } else { "Hrzn" })) diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 2651f4c4d1..3349852b38 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File-format parity -> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-13 · **Change:** minor (CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-14 · **Change:** minor (smart objects keep Photoshop's Cylinder warp through re-renders and saves, #4112; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; 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 @@ -21,7 +21,7 @@ XL are missing (gap G10). Remaining: 300–500 h including PSD fidelity. | Format | Photoshop | PhotoCraft read | PhotoCraft write | Fidelity and tests | |---|---|---|---|---| -| PSD | R/W | yes | yes | 1/8/16/32-bit; Bitmap, Gray, Indexed, RGB, CMYK, Multichannel, Lab, Duotone; layers, groups, masks, vector masks, adjustment and fill layers, effects, text, shapes, smart objects (SoLd/lnk2; CS2 PlLd/lnkD read with their warp, kept as is or re-saved as SoLd once edited), smart filters (14 mapped plus Filter Gallery with Chrome, rest verbatim), slices, comps, Advanced Blending. Oracle floors: Photoshop-authored 185/258, io 148/170, psd-tools 249/309; round trip ≥ 169/170, 308/309, 258/256. Known failures: #1281, #2469 (#2374, text layers, closed 2026-10-10; #2465, CS2 `PlLd`-only smart objects, fixed 2026-10-12) | +| PSD | R/W | yes | yes | 1/8/16/32-bit; Bitmap, Gray, Indexed, RGB, CMYK, Multichannel, Lab, Duotone; layers, groups, masks, vector masks, adjustment and fill layers, effects, text, shapes, smart objects (SoLd/lnk2 with their warp: the bend presets, a custom mesh and, since #4112, Cylinder; CS2 PlLd/lnkD read with their warp, kept as is or re-saved as SoLd once edited), smart filters (14 mapped plus Filter Gallery with Chrome, rest verbatim), slices, comps, Advanced Blending. Oracle floors: Photoshop-authored 185/258, io 148/170, psd-tools 249/309; round trip ≥ 169/170, 308/309, 258/256. Known failures: #1281, #2469 (#2374, text layers, closed 2026-10-10; #2465, CS2 `PlLd`-only smart objects, fixed 2026-10-12) | | PSB | R/W | yes | yes | Auto-switches above 2 GB (REL-212-2); 4–5 GB fixtures generated (FILE-216-2); > 4 GB fails on Windows (#375) | | Cloud PSD (.psdc) | R/W | no | no | Out of scope (Adobe cloud) | | TIFF | R/W | yes | yes | 8/16/32f, Gray/RGB/CMYK, BigTIFF, every IFD, banded parallel decode; layered TIFF both byte orders (FILE-215-7: extra alpha channels not written) | @@ -142,6 +142,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings. | Date | Change | Summary | |---|---|---| +| 2026-10-14 | minor | PSD smart objects warped with Transform Warp's Cylinder (`warpCylinder`, seven `warpValues`) are read and written: Replace Contents, Relink and Edit Contents re-render them wrapped instead of flat, and a regenerated `SoLd` no longer drops the warp (#4112). Vertical cylinders and ones with perspective are still unread | | 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 | | 2026-10-13 | minor | CMYK Hue/Saturation (not Colorize) and Color Balance work on C, M and Y as inverted RGB with black kept, on the inks for display, export and destructive edits; cmyk8/16 hue-saturation 100% → 0.4–0.7% bad pixels, color-balance 74% → 25% | | 2026-10-13 | minor | CMYK Posterize works on the stored values (1 − ink), as Photoshop does: psd-tools posterize_cmyk passes (13.8 % → 0 of pixels off on the ink path); psd-tools floor → 242 of 309 | diff --git a/docs/gaps.md b/docs/gaps.md index 52b467b2dd..52edd1cd7f 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where PhotoCraft falls short of Photoshop -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (G1: smart objects keep Photoshop's Cylinder warp, #4112; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 @@ -48,7 +48,9 @@ what an agent can't finish alone. re-saved unmodified would not reopen (#2374, closed 2026-10-10), Photoshop 26.6 cannot reopen our files (#1281), "PSD not opening in Photoshop" (#2469), a CS2-era smart object unavailable (#2465, fixed 2026-10-12), PSB smart object blank (#1764), perspective placed layers flattened (#579, fixed by #426), PSB > 4 GB fails on Windows (#375). - No test opens our exports in a third-party editor (FILE-216-4). + No test opens our exports in a third-party editor (FILE-216-4). Mockups whose smart object + uses Transform Warp's Cylinder re-rendered flat after Replace Contents (#4112, fixed 2026-10-14; + vertical cylinders and ones with perspective are still unread). - **Impact:** PSD is the format professionals exchange. Beta requires it to be reliable. - **Estimate:** 150–250 h. **Human:** opening exports in Photoshop on the owner's Mac (or a scripted check there) is the only real oracle. @@ -263,6 +265,7 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| +| 2026-10-14 | minor | G1: PSD smart objects keep Transform Warp's Cylinder through Replace Contents, Relink, Edit Contents and re-saves (#4112) | | 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 | | 2026-10-13 | minor | G1: CMYK Hue/Saturation and Color Balance work on C, M and Y as inverted RGB with black kept, as Photoshop does; cmyk hue-saturation 100% → 0.4–0.7% bad pixels, color-balance 74% → 25%; floor unchanged | | 2026-10-13 | minor | G1: CMYK Posterize works on the stored values (1 − ink); psd-tools posterize_cmyk passes; psd-tools floor → 242 of 309 | From 2fc221e66ba3c79adb67c721b5db2aed1fa449c0 Mon Sep 17 00:00:00 2001 From: bazmarth Date: Wed, 14 Oct 2026 22:27:37 +0000 Subject: [PATCH 070/649] Color: a picked colour recolours the selected type and shapes, as in Photoshop The Color panel, the Swatches panel and the Color Picker set the foreground; like Photoshop, the new colour now also goes to what is selected, depending on the tool in hand (new apply_color.rs, which the three already call through): - characters selected while editing type: those characters (as before); - a Type tool, not editing: every selected type layer (type.setStyle); - a shape tool, a Pen or a path selection tool: every selected shape layer's fill (shape.edit); - any other tool (Move, brushes...): only the foreground. One pick is one history step for all the layers it recolours; a drag in the Color panel's field or sliders is one step too (coalesce). Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/apply_color.rs | 94 ++++++++++++++++ crates/ui-egui/src/apply_color_tests.rs | 144 ++++++++++++++++++++++++ crates/ui-egui/src/color_picker_ui.rs | 2 +- crates/ui-egui/src/lib.rs | 1 + crates/ui-egui/src/panels.rs | 6 +- crates/ui-egui/src/state.rs | 4 + crates/ui-egui/src/swatches_ui.rs | 5 +- docs/ui-parity.md | 4 +- 8 files changed, 253 insertions(+), 7 deletions(-) create mode 100644 crates/ui-egui/src/apply_color.rs create mode 100644 crates/ui-egui/src/apply_color_tests.rs diff --git a/crates/ui-egui/src/apply_color.rs b/crates/ui-egui/src/apply_color.rs new file mode 100644 index 0000000000..ce51b23fe1 --- /dev/null +++ b/crates/ui-egui/src/apply_color.rs @@ -0,0 +1,94 @@ +//! A new foreground colour recolours the selected objects, as in Photoshop: the Color panel, the +//! Swatches panel and the Color Picker set the foreground, and depending on the tool in hand it +//! also goes to what is selected: +//! +//! * characters selected while editing type: those characters (`type_tool::foreground_changed`); +//! * a Type tool, not editing: the colour of every selected type layer (`type.setStyle`); +//! * a shape tool, a Pen or a path selection tool: the fill of every selected shape layer +//! (`shape.edit` with `fill`); +//! * any other tool (Move, the brushes…): nothing, only the foreground changes. +//! +//! One pick is one history step for all the layers it recolours; a drag in the Color panel's field +//! or sliders is one step too. + +use egui::Context; +use photocraft_doc::LayerContent; +use serde_json::json; + +use crate::PhotocraftApp; +use crate::state::Tool; + +fn hex(c: [f32; 4]) -> String { + let b = |v: f32| (v.clamp(0.0, 1.0) * 255.0).round() as u8; + format!("#{:02x}{:02x}{:02x}", b(c[0]), b(c[1]), b(c[2])) +} + +/// Does a new foreground recolour selected shape layers with `tool`? +fn recolours_shapes(tool: Tool) -> bool { + crate::vector_ui::is_shape_tool(tool) + || matches!( + tool, + Tool::PathSelection + | Tool::DirectSelection + | Tool::Pen + | Tool::FreeformPen + | Tool::CurvaturePen + | Tool::AddAnchorPoint + | Tool::DeleteAnchorPoint + | Tool::ConvertPoint + ) +} + +/// Is the pointer still held from an earlier frame (a drag in the Color panel), so this pick +/// joins the previous one's history step? +pub fn continuing(ctx: &Context) -> bool { + ctx.input(|i| i.pointer.any_down() && !i.pointer.any_pressed()) +} + +/// The foreground colour just changed through the Color panel, the Swatches panel or the Color +/// Picker: recolour what is selected, as the tool in hand says (see the module docs). +/// `continuing` (a drag still in progress) joins the previous pick's history step. +pub fn foreground_changed(app: &mut PhotocraftApp, continuing: bool) { + // Editing type: the selected characters, in the editing session's step; nothing else. + if app.ui.text_edit.is_some() { + crate::type_tool::foreground_changed(app); + return; + } + let tool = app.ui.tool; + let type_tool = tool.is_type() && !tool.is_type_mask(); + if !type_tool && !recolours_shapes(tool) { + return; + } + let Some(st) = app.session.active() else { return }; + let (texts, shapes): (Vec, Vec) = { + let selected: Vec<_> = st.selected_layers().into_iter().filter_map(|id| st.doc.layer(id)).collect(); + let pick = |want: fn(&LayerContent) -> bool| selected.iter().filter(|l| want(&l.content)).map(|l| l.id.0).collect::>(); + (pick(|c| matches!(c, LayerContent::Text(_))), pick(|c| matches!(c, LayerContent::Shape(_)))) + }; + let targets = if type_tool { &texts } else { &shapes }; + if targets.is_empty() { + return; + } + let key = match app.ui.apply_color_key.clone().filter(|_| continuing) { + Some(k) => k, + None => { + let k = format!("apply-color-{}", app.ui.alloc_id()); + app.ui.apply_color_key = Some(k.clone()); + k + } + }; + let color = hex(app.session.tools.foreground); + let result = if type_tool { + app.run("type.setStyle", json!({"layers": texts, "color": color, "coalesce": key})).map(|_| ()) + } else { + shapes.iter().try_for_each(|id| app.run("shape.edit", json!({"layer": id, "fill": color, "coalesce": key})).map(|_| ())) + }; + if let Err(e) = result { + app.ui.status = e; + app.ui.status_error = true; + } +} + +#[cfg(test)] +#[path = "apply_color_tests.rs"] +mod tests; diff --git a/crates/ui-egui/src/apply_color_tests.rs b/crates/ui-egui/src/apply_color_tests.rs new file mode 100644 index 0000000000..0a0accb6b2 --- /dev/null +++ b/crates/ui-egui/src/apply_color_tests.rs @@ -0,0 +1,144 @@ +//! A new foreground colour recolours the selected type or shape layers, as the tool in hand says. + +use photocraft_doc::{Fill, LayerContent, LayerId}; +use serde_json::json; + +use crate::PhotocraftApp; +use crate::state::Tool; + +const RED: [f32; 4] = [1.0, 0.0, 0.0, 1.0]; + +/// Two type layers and two shape layers (black, the default colours), all selected. +fn app(tool: Tool) -> (PhotocraftApp, Vec, Vec) { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 300, "height": 200})).unwrap(); + app.sync_views(); + app.run("tools.setColors", json!({"foreground": "#000000"})).unwrap(); + let mut texts = Vec::new(); + for y in [40, 90] { + texts.push(LayerId(app.run("type.create", json!({"x": 20, "y": y, "text": "Hello", "size": 20})).unwrap()["layer"].as_u64().unwrap())); + } + let mut shapes = Vec::new(); + for x in [150, 220] { + app.run("shape.create", json!({"kind": "rect", "rect": [x, 20, 50, 50], "fill": "#000000"})).unwrap(); + shapes.push(app.session.active().unwrap().active_layer.unwrap()); + } + for id in texts.iter().chain(&shapes) { + app.run("layer.select", json!({"layer": id.0, "mode": "add"})).unwrap(); + } + app.ui.tool = tool; + (app, texts, shapes) +} + +fn text_rgb(app: &PhotocraftApp, id: LayerId) -> [f32; 3] { + match &app.session.active().unwrap().doc.layer(id).unwrap().content { + LayerContent::Text(t) => { + let c = t.char_runs().into_iter().next().map_or(t.color, |r| r.style.color); + [c.c[0], c.c[1], c.c[2]] + } + _ => panic!("type layer"), + } +} + +fn fill_rgb(app: &PhotocraftApp, id: LayerId) -> Option<[f32; 3]> { + match &app.session.active().unwrap().doc.layer(id).unwrap().content { + LayerContent::Shape(sh) => match &sh.fill { + Some(Fill::Solid(c)) => Some([c.c[0], c.c[1], c.c[2]]), + _ => None, + }, + _ => panic!("shape layer"), + } +} + +fn red(c: [f32; 3]) -> bool { + (c[0] - 1.0).abs() < 1e-3 && c[1].abs() < 1e-3 && c[2].abs() < 1e-3 +} + +fn steps(app: &PhotocraftApp) -> usize { + app.session.active().unwrap().history.entries().len() +} + +fn pick(app: &mut PhotocraftApp, c: [f32; 4], continuing: bool) { + app.session.tools.foreground = c; + super::foreground_changed(app, continuing); +} + +#[test] +fn a_type_tool_recolours_every_selected_type_layer_in_one_step() { + for tool in [Tool::Type, Tool::VerticalType] { + let (mut app, texts, shapes) = app(tool); + let n = steps(&app); + pick(&mut app, RED, false); + assert!(texts.iter().all(|id| red(text_rgb(&app, *id))), "{tool:?}"); + assert!(shapes.iter().all(|id| !red(fill_rgb(&app, *id).unwrap())), "{tool:?}: shapes keep their fill"); + assert_eq!(steps(&app), n + 1, "one history step"); + assert!(app.session.undo()); + assert!(texts.iter().all(|id| !red(text_rgb(&app, *id)))); + } +} + +#[test] +fn shape_and_path_tools_recolour_every_selected_shape_fill_in_one_step() { + for tool in [Tool::Rectangle, Tool::Polygon, Tool::PathSelection, Tool::DirectSelection, Tool::Pen, Tool::CurvaturePen] { + let (mut app, texts, shapes) = app(tool); + let n = steps(&app); + pick(&mut app, RED, false); + assert!(shapes.iter().all(|id| fill_rgb(&app, *id).is_some_and(red)), "{tool:?}"); + assert!(texts.iter().all(|id| !red(text_rgb(&app, *id))), "{tool:?}: type keeps its colour"); + assert_eq!(steps(&app), n + 1, "{tool:?}: one history step for both layers"); + } +} + +#[test] +fn other_tools_only_change_the_foreground() { + for tool in [Tool::Move, Tool::Brush, Tool::RectMarquee, Tool::Eyedropper, Tool::HorizontalTypeMask] { + let (mut app, texts, shapes) = app(tool); + let n = steps(&app); + pick(&mut app, RED, false); + assert_eq!(app.session.tools.foreground, RED); + assert!(texts.iter().all(|id| !red(text_rgb(&app, *id))) && shapes.iter().all(|id| !red(fill_rgb(&app, *id).unwrap())), "{tool:?}"); + assert_eq!(steps(&app), n, "{tool:?}: nothing recorded"); + } +} + +#[test] +fn a_color_panel_drag_is_one_history_step_and_a_new_pick_another() { + let (mut app, _, shapes) = app(Tool::Rectangle); + let n = steps(&app); + pick(&mut app, [0.2, 0.0, 0.0, 1.0], false); + pick(&mut app, [0.6, 0.0, 0.0, 1.0], true); + pick(&mut app, RED, true); + assert!(fill_rgb(&app, shapes[0]).is_some_and(red)); + assert_eq!(steps(&app), n + 1, "the drag is one step"); + pick(&mut app, [0.0, 0.0, 1.0, 1.0], false); + assert_eq!(steps(&app), n + 2, "a new pick is another"); +} + +#[test] +fn a_swatch_and_the_color_picker_go_through_it() { + let (mut app, _, shapes) = app(Tool::Rectangle); + let same = |app: &PhotocraftApp, id: LayerId| { + let f = app.session.tools.foreground; + fill_rgb(app, id).is_some_and(|c| (0..3).all(|i| (c[i] - f[i]).abs() < 1e-3)) + }; + // A swatch from the default library (the first one that isn't black). + let names = app.run("swatches.list", json!({})).unwrap(); + let name = names["groups"] + .as_array() + .into_iter() + .flatten() + .flat_map(|g| g["swatches"].as_array().cloned().unwrap_or_default()) + .find(|w| w["hex"].as_str().is_some_and(|h| h != "#000000")) + .and_then(|w| w["name"].as_str().map(str::to_string)) + .expect("a default swatch"); + crate::swatches_ui::use_swatch(&mut app, &name, false); + assert_ne!(app.session.tools.foreground, [0.0, 0.0, 0.0, 1.0]); + assert!(shapes.iter().all(|id| same(&app, *id)), "the swatch recoloured the shapes"); + // The Color Picker's OK for the foreground. + let mut f = serde_json::Map::new(); + f.insert("__colorPicker".into(), json!("foreground")); + f.insert("color".into(), json!("#0000ff")); + crate::color_picker_ui::confirm(&mut app, &f).unwrap(); + assert_eq!(app.session.tools.foreground, [0.0, 0.0, 1.0, 1.0]); + assert!(shapes.iter().all(|id| same(&app, *id)), "the picker recoloured the shapes"); +} diff --git a/crates/ui-egui/src/color_picker_ui.rs b/crates/ui-egui/src/color_picker_ui.rs index 09a3ce8d4c..f275fcf4d9 100644 --- a/crates/ui-egui/src/color_picker_ui.rs +++ b/crates/ui-egui/src/color_picker_ui.rs @@ -824,7 +824,7 @@ pub fn confirm(app: &mut PhotocraftApp, f: &Map) -> Result, /// A live rectangle's corner radius widget being dragged (TOOL-214-12). #[serde(skip)] pub corner_radius: Option, @@ -1344,6 +1347,7 @@ impl Default for UiState { pen: None, stroke_editor: None, direct_selection: Default::default(), + apply_color_key: None, corner_radius: None, selected_path: None, panels: Panels::default(), diff --git a/crates/ui-egui/src/swatches_ui.rs b/crates/ui-egui/src/swatches_ui.rs index a18ddee640..6013ec779d 100644 --- a/crates/ui-egui/src/swatches_ui.rs +++ b/crates/ui-egui/src/swatches_ui.rs @@ -51,8 +51,9 @@ fn colors(app: &PhotocraftApp, ctx: &egui::Context) -> Arc>> { pub fn use_swatch(app: &mut PhotocraftApp, name: &str, background: bool) { let target = if background { "background" } else { "foreground" }; if run(app, "swatches.use", json!({"swatch": name, "target": target})).is_some() && !background { - // Clicking a swatch while characters are selected recolours them (#364). - crate::type_tool::foreground_changed(app); + // Clicking a swatch recolours the selected characters (#364), or the selected type or + // shape layers with a Type, shape or Pen tool, as in Photoshop. + crate::apply_color::foreground_changed(app, false); } } diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 7fbe8932cc..e22aee3483 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI parity: tools, handles, modifiers and feel -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (a picked colour recolours the selected type and shapes; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; 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, @@ -207,6 +207,7 @@ Paragraph; the rest open as in-app floating windows. | Drag panels to reorder and regroup | partial | #2272, #2305 | | Docked resize pushes the neighbour | partial | #2573 | | Color panel wheel and RGB/HSB/CMYK/Lab sliders | missing | UI-217-17, #2569 | +| A colour picked in the Color or Swatches panel or the Color Picker recolours the selection: selected characters while editing; every selected type layer with a Type tool; every selected shape's fill with a shape, Pen or path selection tool; only the foreground with other tools; one history step (a Color panel drag too) | done: `apply_color.rs`, `apply_color_tests.rs` | | | Window size and dock width remembered | done | UI-217-2 | | Command palette with recents | done | UI-217-7 | | Menu bar from the keyboard: Alt / F10 focus the bar, ← → ↓ ↩ drive it, Alt+letter opens a menu, underlined mnemonics run items | done | `menu_keys.rs`, #4988; macOS uses the native bar | @@ -253,3 +254,4 @@ Paragraph; the rest open as in-app floating windows. | 2026-10-11 | minor | Pen ⇧ 45° done: ⇧-click puts the next anchor on the nearest 45° ray, ⇧-drag turns its handles in 45° steps (TOOL-214-10 done, #3751) | | 2026-10-14 | minor | Last selected tool restored across launches; temporary overrides excluded, explicit Eraser choices retained, and final selection flushed on normal exit | | 2026-10-13 | minor | Free Transform with a selection: the box is the selection's rectangle, and the marching ants follow it while it is transformed (#5297) | +| 2026-10-14 | minor | A colour picked in the Color or Swatches panel or the Color Picker recolours the selected type layers (Type tool) or shape fills (shape, Pen and path selection tools) | From c8e871292620387acbafa71a822c4f8281258edc Mon Sep 17 00:00:00 2001 From: abc2cb <271337822+abc2cb@users.noreply.github.com> Date: Wed, 14 Oct 2026 22:34:47 +0000 Subject: [PATCH 071/649] Name layerFilter in the ui_set tool description main's UI_SET_FIELDS gained layerFilter (#5268) but the ui_set description did not, so ui_set_description_names_every_accepted_field fails on ubuntu. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01F8jU8SSgnSWm5L17agT9ZT (cherry picked from commit 1d1cb4e4620a4c239d5c17e3d23a68fc4ba50982) --- crates/automation/src/server.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/automation/src/server.rs b/crates/automation/src/server.rs index c5a0c3b180..be0764e6d9 100644 --- a/crates/automation/src/server.rs +++ b/crates/automation/src/server.rs @@ -325,7 +325,9 @@ pub struct UiSetParams { /// dashes, dashOffset and opacity; null disables the stroke). Shape stroke fields use /// `shape.edit` names and units; colour comes from `tools.setColors`. camTransformOnDrop (bool, /// the Content-Aware Move tool's Transform On Drop). tileGrid (bool, a developer overlay of the - /// active layer's storage tiles). Other fields are an error. + /// active layer's storage tiles). layerFilter (an object patching by (kind, name, mode), kinds + /// (a list of pixel, adjustment, type, shape, smart), name and mode, the Layers panel's filter). + /// Other fields are an error. pub fields: Value, } From d86069c0393d105ce61f6a95c4b2751511c1c72a Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Wed, 14 Oct 2026 19:13:01 -0400 Subject: [PATCH 072/649] Preferences: old settings files take Shift-to-switch-tools on (#5647) #3528 made Preferences > Tools > Use Shift Key for Tool Switch on by default, as in Photoshop, but every settings file written before stores the old default (off), so upgraded installs kept cycling a tool group on each press of its letter. Files before version 2 now load with the new default; saves write version 2, so a later explicit "off" is kept. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/prefs.rs | 16 +++++++++++++++- crates/engine/src/prefs/tests.rs | 23 +++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index d6b40178d3..e30e999013 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -1531,6 +1531,10 @@ impl PrefsStore { } } +/// The preferences file format written by [`Session::prefs_value`]. 2: Use Shift Key for Tool +/// Switch stored as chosen (before, a stored `false` was the old default; see `load_prefs_json`). +pub const PREFS_VERSION: u64 = 2; + impl Session { /// The current preferences. pub fn prefs(&self) -> &Preferences { @@ -1571,7 +1575,7 @@ impl Session { let mut v = self.prefs().to_json(); if let Value::Object(m) = &mut v { m.insert("colorSettings".into(), serde_json::to_value(&self.color.settings).unwrap_or(Value::Null)); - m.insert("version".into(), json!(1)); + m.insert("version".into(), json!(PREFS_VERSION)); m.insert("presets".into(), self.presets.to_json(self)); } v @@ -1581,6 +1585,16 @@ impl Session { /// defaults and unknown keys are ignored, so files from older and newer versions load. pub fn load_prefs_json(&mut self, s: &str) -> std::result::Result<(), String> { let mut v: Value = serde_json::from_str(s).map_err(|e| format!("preferences: {e}"))?; + // Files before version 2 hold Use Shift Key for Tool Switch off because that was the + // default when they were written: every key is saved, chosen or not. Like Photoshop it is + // on by default now (#3528), so those files take the new default (#5647: a tool letter + // pressed again kept cycling its group). A choice made since is saved as version 2. + if v.get("version").and_then(Value::as_u64).unwrap_or(0) < 2 + && let Some(tools) = v.get_mut("tools").and_then(Value::as_object_mut) + && tools.get("useShiftKeyForToolSwitch") == Some(&json!(false)) + { + tools.remove("useShiftKeyForToolSwitch"); + } // Saved preferences before appearance modes had one concrete theme. Preserve its // appearance instead of silently switching established users to Auto. if let Some(interface) = v.get_mut("interface").and_then(Value::as_object_mut) diff --git a/crates/engine/src/prefs/tests.rs b/crates/engine/src/prefs/tests.rs index bf2fe52efd..d4259b0bde 100644 --- a/crates/engine/src/prefs/tests.rs +++ b/crates/engine/src/prefs/tests.rs @@ -827,3 +827,26 @@ fn shift_key_tool_switch_is_on_by_default_and_a_stored_false_is_kept() { let stored: Tools = serde_json::from_value(json!({"useShiftKeyForToolSwitch": false})).unwrap(); assert!(!stored.use_shift_key_for_tool_switch); } + +/// #5647: a settings file from before version 2 stored the switch off only because that was the +/// old default, so it loads with the new default (on); one saved since keeps an explicit off. +#[test] +fn old_settings_files_take_the_shift_key_tool_switch_default() { + for old in + [json!({"tools": {"useShiftKeyForToolSwitch": false}}), json!({"version": 1, "tools": {"useShiftKeyForToolSwitch": false, "showTooltips": false}})] + { + let mut s = Session::new(); + s.load_prefs_json(&old.to_string()).unwrap(); + assert!(s.prefs().tools.use_shift_key_for_tool_switch, "{old}"); + } + let mut s = Session::new(); + s.load_prefs_json(&json!({"version": 1, "tools": {"showTooltips": false}}).to_string()).unwrap(); + assert!(!s.prefs().tools.show_tooltips, "other tool settings are kept"); + // Chosen off and saved now: kept on the next start. + s.edit_prefs(|p| p.tools.use_shift_key_for_tool_switch = false); + let saved = s.prefs_to_json(); + assert_eq!(serde_json::from_str::(&saved).unwrap()["version"], json!(PREFS_VERSION)); + let mut restored = Session::new(); + restored.load_prefs_json(&saved).unwrap(); + assert!(!restored.prefs().tools.use_shift_key_for_tool_switch); +} From 62ab7f38685f4c63959a1155babed9e01c378fef Mon Sep 17 00:00:00 2001 From: bazmarth Date: Thu, 15 Oct 2026 00:26:11 +0000 Subject: [PATCH 073/649] Color: the Move tool recolours the selected type and shapes too Layers picked with the Move tool (a click, Shift-click or its marquee) now take a colour picked in the Color or Swatches panel or the Color Picker: every selected type layer's colour and every selected shape's fill, in one history step. The brushes, the pixel selection tools and the other tools still change only the foreground. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/apply_color.rs | 35 ++++++++++++--------- crates/ui-egui/src/apply_color_tests.rs | 42 ++++++++++++++++++++++++- docs/ui-parity.md | 4 +-- 3 files changed, 64 insertions(+), 17 deletions(-) diff --git a/crates/ui-egui/src/apply_color.rs b/crates/ui-egui/src/apply_color.rs index ce51b23fe1..ed40823a04 100644 --- a/crates/ui-egui/src/apply_color.rs +++ b/crates/ui-egui/src/apply_color.rs @@ -1,12 +1,14 @@ -//! A new foreground colour recolours the selected objects, as in Photoshop: the Color panel, the -//! Swatches panel and the Color Picker set the foreground, and depending on the tool in hand it -//! also goes to what is selected: +//! A new foreground colour recolours the selected objects: the Color panel, the Swatches panel and +//! the Color Picker set the foreground, and depending on the tool in hand it also goes to what is +//! selected: //! //! * characters selected while editing type: those characters (`type_tool::foreground_changed`); //! * a Type tool, not editing: the colour of every selected type layer (`type.setStyle`); //! * a shape tool, a Pen or a path selection tool: the fill of every selected shape layer //! (`shape.edit` with `fill`); -//! * any other tool (Move, the brushes…): nothing, only the foreground changes. +//! * the Move tool (layers picked by a click, ⇧-click or its marquee): both, every selected type +//! layer and shape; +//! * any other tool (the brushes, the pixel selection tools…): nothing, only the foreground. //! //! One pick is one history step for all the layers it recolours; a drag in the Color panel's field //! or sliders is one step too. @@ -55,18 +57,22 @@ pub fn foreground_changed(app: &mut PhotocraftApp, continuing: bool) { return; } let tool = app.ui.tool; - let type_tool = tool.is_type() && !tool.is_type_mask(); - if !type_tool && !recolours_shapes(tool) { - return; - } + // What the tool in hand recolours: type layers, shape layers, or both (the Move tool). + let (do_texts, do_shapes) = match tool { + Tool::Move => (true, true), + t if t.is_type() && !t.is_type_mask() => (true, false), + t if recolours_shapes(t) => (false, true), + _ => return, + }; let Some(st) = app.session.active() else { return }; let (texts, shapes): (Vec, Vec) = { let selected: Vec<_> = st.selected_layers().into_iter().filter_map(|id| st.doc.layer(id)).collect(); let pick = |want: fn(&LayerContent) -> bool| selected.iter().filter(|l| want(&l.content)).map(|l| l.id.0).collect::>(); (pick(|c| matches!(c, LayerContent::Text(_))), pick(|c| matches!(c, LayerContent::Shape(_)))) }; - let targets = if type_tool { &texts } else { &shapes }; - if targets.is_empty() { + let texts = if do_texts { texts } else { Vec::new() }; + let shapes = if do_shapes { shapes } else { Vec::new() }; + if texts.is_empty() && shapes.is_empty() { return; } let key = match app.ui.apply_color_key.clone().filter(|_| continuing) { @@ -78,11 +84,12 @@ pub fn foreground_changed(app: &mut PhotocraftApp, continuing: bool) { } }; let color = hex(app.session.tools.foreground); - let result = if type_tool { - app.run("type.setStyle", json!({"layers": texts, "color": color, "coalesce": key})).map(|_| ()) - } else { + let result = (|| { + if !texts.is_empty() { + app.run("type.setStyle", json!({"layers": texts, "color": color, "coalesce": key}))?; + } shapes.iter().try_for_each(|id| app.run("shape.edit", json!({"layer": id, "fill": color, "coalesce": key})).map(|_| ())) - }; + })(); if let Err(e) = result { app.ui.status = e; app.ui.status_error = true; diff --git a/crates/ui-egui/src/apply_color_tests.rs b/crates/ui-egui/src/apply_color_tests.rs index 0a0accb6b2..a007eb9845 100644 --- a/crates/ui-egui/src/apply_color_tests.rs +++ b/crates/ui-egui/src/apply_color_tests.rs @@ -91,7 +91,7 @@ fn shape_and_path_tools_recolour_every_selected_shape_fill_in_one_step() { #[test] fn other_tools_only_change_the_foreground() { - for tool in [Tool::Move, Tool::Brush, Tool::RectMarquee, Tool::Eyedropper, Tool::HorizontalTypeMask] { + for tool in [Tool::Brush, Tool::RectMarquee, Tool::Eyedropper, Tool::HorizontalTypeMask] { let (mut app, texts, shapes) = app(tool); let n = steps(&app); pick(&mut app, RED, false); @@ -142,3 +142,43 @@ fn a_swatch_and_the_color_picker_go_through_it() { assert_eq!(app.session.tools.foreground, [0.0, 0.0, 1.0, 1.0]); assert!(shapes.iter().all(|id| same(&app, *id)), "the picker recoloured the shapes"); } + +#[test] +fn the_move_tool_recolours_the_selected_type_and_shapes_together_in_one_step() { + // Layers picked with the Move tool (a click, ⇧-click or its marquee) take the colour, type and + // shapes alike. + let (mut app, texts, shapes) = app(Tool::Move); + let n = steps(&app); + pick(&mut app, RED, false); + assert!(texts.iter().all(|id| red(text_rgb(&app, *id))), "the type is red"); + assert!(shapes.iter().all(|id| fill_rgb(&app, *id).is_some_and(red)), "the shapes are red"); + assert_eq!(steps(&app), n + 1, "one history step for all four layers"); + assert!(app.session.undo()); + assert!(texts.iter().all(|id| !red(text_rgb(&app, *id))) && shapes.iter().all(|id| !red(fill_rgb(&app, *id).unwrap()))); + // Only the selected ones: with one shape selected, the rest keep their colour. + app.run("layer.select", json!({"layer": shapes[0].0})).unwrap(); + pick(&mut app, RED, false); + assert!(fill_rgb(&app, shapes[0]).is_some_and(red)); + assert!(!red(fill_rgb(&app, shapes[1]).unwrap()) && texts.iter().all(|id| !red(text_rgb(&app, *id)))); +} + +#[test] +fn a_move_tool_marquee_selection_takes_the_colour() { + // The video case: shapes box-selected with the Move tool's marquee, then a swatch. + let (mut app, _, shapes) = app(Tool::Move); + app.run("layer.select", json!({"layer": shapes[0].0})).unwrap(); + // The marquee from an empty spot across both shapes. + for (kind, x, y) in [("down", 140.0, 10.0), ("move", 200.0, 50.0), ("move", 290.0, 90.0), ("up", 290.0, 90.0)] { + let ev = match kind { + "down" => crate::canvas::ToolEvent::Down { x, y, pressure: 1.0 }, + "move" => crate::canvas::ToolEvent::Move { x, y, pressure: 1.0 }, + _ => crate::canvas::ToolEvent::Up { x, y }, + }; + crate::canvas::tool_event(&mut app, ev, egui::Modifiers::NONE); + } + let mut sel = app.session.active().unwrap().selected_layers(); + sel.sort_by_key(|l| l.0); + assert_eq!(sel, shapes, "the marquee selected both shapes"); + pick(&mut app, RED, false); + assert!(shapes.iter().all(|id| fill_rgb(&app, *id).is_some_and(red))); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index e22aee3483..adb6c2da4c 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -207,7 +207,7 @@ Paragraph; the rest open as in-app floating windows. | Drag panels to reorder and regroup | partial | #2272, #2305 | | Docked resize pushes the neighbour | partial | #2573 | | Color panel wheel and RGB/HSB/CMYK/Lab sliders | missing | UI-217-17, #2569 | -| A colour picked in the Color or Swatches panel or the Color Picker recolours the selection: selected characters while editing; every selected type layer with a Type tool; every selected shape's fill with a shape, Pen or path selection tool; only the foreground with other tools; one history step (a Color panel drag too) | done: `apply_color.rs`, `apply_color_tests.rs` | | +| A colour picked in the Color or Swatches panel or the Color Picker recolours the selection: selected characters while editing; every selected type layer with a Type tool; every selected shape's fill with a shape, Pen or path selection tool; both with the Move tool (layers picked by click, ⇧-click or its marquee); only the foreground with other tools; one history step (a Color panel drag too) | done: `apply_color.rs`, `apply_color_tests.rs` | | | Window size and dock width remembered | done | UI-217-2 | | Command palette with recents | done | UI-217-7 | | Menu bar from the keyboard: Alt / F10 focus the bar, ← → ↓ ↩ drive it, Alt+letter opens a menu, underlined mnemonics run items | done | `menu_keys.rs`, #4988; macOS uses the native bar | @@ -254,4 +254,4 @@ Paragraph; the rest open as in-app floating windows. | 2026-10-11 | minor | Pen ⇧ 45° done: ⇧-click puts the next anchor on the nearest 45° ray, ⇧-drag turns its handles in 45° steps (TOOL-214-10 done, #3751) | | 2026-10-14 | minor | Last selected tool restored across launches; temporary overrides excluded, explicit Eraser choices retained, and final selection flushed on normal exit | | 2026-10-13 | minor | Free Transform with a selection: the box is the selection's rectangle, and the marching ants follow it while it is transformed (#5297) | -| 2026-10-14 | minor | A colour picked in the Color or Swatches panel or the Color Picker recolours the selected type layers (Type tool) or shape fills (shape, Pen and path selection tools) | +| 2026-10-14 | minor | A colour picked in the Color or Swatches panel or the Color Picker recolours the selected type layers (Type tool), shape fills (shape, Pen and path selection tools), or both (Move tool) | From 96e11ebd63b2a7f43398b710d922f3a58c93452c Mon Sep 17 00:00:00 2001 From: ZhuanTou33212 <2534311904@qq.com> Date: Thu, 15 Oct 2026 09:03:32 +0800 Subject: [PATCH 074/649] Translate release checks for the new Serbian catalog --- crates/ui-egui/src/i18n/sr.tsv | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsv index b91b67b3eb..2eeac87f96 100644 --- a/crates/ui-egui/src/i18n/sr.tsv +++ b/crates/ui-egui/src/i18n/sr.tsv @@ -4248,3 +4248,17 @@ shape Appearance Izgled # View › Guides › right-click a guide Edit Selected Guides Uredi izabrane vodilje Clear Selected Guides Ukloni izabrane vodilje + +# PhotoCraft release checks. + Check for Updates… Proveri ažuriranja… + PhotoCraft Updates Ažuriranja za PhotoCraft + Checking for updates… Provera ažuriranja… + Open the release page to choose an installer for your system. Otvorite stranicu izdanja da biste izabrali instalacioni program za svoj sistem. + Open Download Page Otvori stranicu za preuzimanje + PhotoCraft is up to date. PhotoCraft je ažuran. + Could not check for updates. Nije moguće proveriti ažuriranja. + Updates have not been checked yet. Ažuriranja još nisu proverena. + Check Again Proveri ponovo + Automatically Check for Updates Automatski proveravaj ažuriranja + Installed version: {version} Instalirana verzija: {version} + PhotoCraft {version} is available. Dostupan je PhotoCraft {version}. From 6ee3c9391acb56627a45e95a4e799166422f237e Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 00:31:16 -0700 Subject: [PATCH 075/649] feat(text): find where a closed path leaves room for a line of type Co-Authored-By: Claude Opus 5.5 --- crates/text/src/area.rs | 368 ++++++++++++++++++++++++++++++++++++++++ crates/text/src/lib.rs | 1 + 2 files changed, 369 insertions(+) create mode 100644 crates/text/src/area.rs diff --git a/crates/text/src/area.rs b/crates/text/src/area.rs new file mode 100644 index 0000000000..85a83868fb --- /dev/null +++ b/crates/text/src/area.rs @@ -0,0 +1,368 @@ +//! Area type: text that wraps inside a closed path, like Photoshop's area type. +//! +//! The path is flattened once into edges. For a line's band (ascent to descent), +//! [`AreaShape::spans`] gives the intervals that are inside the shape for the whole band, left +//! to right. A shape with dents or holes gives several spans on a row, and the layout fills +//! them in order at the same baseline, as Photoshop does. + +use std::ops::Range; + +use photocraft_doc::vector::{FillRule, Path, PathOp}; +use photocraft_geom::Point; + +/// Pieces each curved segment is cut into (about 0.1 px off a 300 px bubble's curve). +const CURVE_PIECES: usize = 16; +/// Largest number of edges an area keeps, so a hostile path can't make every line scan millions. +pub const MAX_AREA_EDGES: usize = 65_536; +/// Most rows sampled inside one band; past that, evenly spread vertex rows stand in. +const MAX_BAND_SAMPLES: usize = 256; +/// Most baselines `next_row` tries before giving up. +const MAX_ROW_STEPS: usize = 1024; + +#[derive(Clone, Copy, Debug)] +struct Edge { + x0: f32, + y0: f32, + x1: f32, + y1: f32, +} + +#[derive(Clone, Debug)] +struct Component { + op: PathOp, + edges: Range, +} + +/// A closed path ready for line fitting, in area space (text space, or `(y, -x)` for vertical +/// type so its rows are columns). +#[derive(Clone, Debug)] +pub struct AreaShape { + edges: Vec, + comps: Vec, + rule: FillRule, + /// Extent of the edges: `[x0, y0, x1, y1]`. + pub bounds: [f32; 4], +} + +fn cubic(s: &[Point; 4], t: f64) -> (f64, f64) { + let u = 1.0 - t; + let (a, b, c, d) = (u * u * u, 3.0 * u * u * t, 3.0 * u * t * t, t * t * t); + (a * s[0].x + b * s[1].x + c * s[2].x + d * s[3].x, a * s[0].y + b * s[1].y + c * s[2].y + d * s[3].y) +} + +fn same(a: Point, b: Point) -> bool { + (a.x - b.x).abs() < 1e-9 && (a.y - b.y).abs() < 1e-9 +} + +/// f64 → f32, rejecting values that are not finite as f32. +fn small(v: f64) -> Option { + let f = v as f32; + f.is_finite().then_some(f) +} + +impl AreaShape { + /// `None` when the path encloses nothing: no closed subpath, no height or width, an + /// inverted (unbounded) path, coordinates that aren't finite, or more than + /// [`MAX_AREA_EDGES`] edges. + pub fn new(path: &Path, vertical: bool) -> Option { + if path.inverted { + return None; + } + let map = |x: f64, y: f64| -> Option<(f32, f32)> { if vertical { Some((small(y)?, small(-x)?)) } else { Some((small(x)?, small(y)?)) } }; + let mut edges: Vec = Vec::new(); + let mut comps: Vec = Vec::new(); + for range in path.components() { + let op = path.effective_op(range.start); + let start = edges.len(); + for sub in path.subpaths.get(range).unwrap_or(&[]) { + if !sub.closed { + continue; + } + let mut pts: Vec<(f32, f32)> = Vec::new(); + for seg in sub.segments() { + if pts.is_empty() { + pts.push(map(seg[0].x, seg[0].y)?); + } + if same(seg[1], seg[0]) && same(seg[2], seg[3]) { + pts.push(map(seg[3].x, seg[3].y)?); + } else { + for j in 1..=CURVE_PIECES { + let (x, y) = cubic(&seg, j as f64 / CURVE_PIECES as f64); + pts.push(map(x, y)?); + } + } + if edges.len().saturating_add(pts.len()) > MAX_AREA_EDGES { + return None; + } + } + // Closing edge back to the first point. + if let Some(&first) = pts.first() { + pts.push(first); + } + for w in pts.windows(2) { + if let [(x0, y0), (x1, y1)] = *w { + edges.push(Edge { x0, y0, x1, y1 }); + } + } + if edges.len() > MAX_AREA_EDGES { + return None; + } + } + comps.push(Component { op, edges: start..edges.len() }); + } + let mut b = [f32::INFINITY, f32::INFINITY, f32::NEG_INFINITY, f32::NEG_INFINITY]; + for e in &edges { + b = [b[0].min(e.x0).min(e.x1), b[1].min(e.y0).min(e.y1), b[2].max(e.x0).max(e.x1), b[3].max(e.y0).max(e.y1)]; + } + if edges.is_empty() || !(b[2] - b[0] >= 1.0 && b[3] - b[1] >= 1.0) { + return None; + } + Some(AreaShape { edges, comps, rule: path.fill_rule, bounds: b }) + } + + fn filled(&self, winding: i32) -> bool { + match self.rule { + FillRule::NonZero => winding != 0, + FillRule::EvenOdd => winding & 1 != 0, + } + } + + /// Inside intervals of one component on row `y` (half-open in y, so a vertex is counted once). + fn component_intervals(&self, c: &Component, y: f32) -> Vec<(f32, f32)> { + let mut xs: Vec<(f32, i32)> = Vec::new(); + for e in self.edges.get(c.edges.clone()).unwrap_or(&[]) { + let (lo, hi, dir) = if e.y0 < e.y1 { (e.y0, e.y1, 1) } else { (e.y1, e.y0, -1) }; + if lo <= y && y < hi { + let t = (y - e.y0) / (e.y1 - e.y0); + xs.push((e.x0 + t * (e.x1 - e.x0), dir)); + } + } + xs.sort_by(|a, b| a.0.total_cmp(&b.0)); + let mut out = Vec::new(); + let (mut winding, mut start) = (0i32, 0.0f32); + for (x, dir) in xs { + let was = self.filled(winding); + winding = winding.saturating_add(dir); + let now = self.filled(winding); + if !was && now { + start = x; + } else if was && !now && x > start { + out.push((start, x)); + } + } + out + } + + /// Inside intervals of the whole path on row `y`, components folded in with their ops. + fn intervals_at(&self, y: f32) -> Vec<(f32, f32)> { + let mut acc: Vec<(f32, f32)> = Vec::new(); + for c in &self.comps { + let v = self.component_intervals(c, y); + acc = match c.op { + PathOp::Combine | PathOp::Join => boolean(&acc, &v, |a, b| a || b), + PathOp::Subtract => boolean(&acc, &v, |a, b| a && !b), + PathOp::Intersect => boolean(&acc, &v, |a, b| a && b), + PathOp::Exclude => boolean(&acc, &v, |a, b| a != b), + }; + } + acc + } + + /// Intervals inside the shape on every row of `[y0, y1]`, left to right, each at least + /// `min_width` wide. Edges are straight, so checking the band's ends and every vertex row + /// between them is exact. + pub fn spans(&self, y0: f32, y1: f32, min_width: f32) -> Vec<(f32, f32)> { + if !(y0.is_finite() && y1.is_finite()) || y1 < y0 { + return Vec::new(); + } + let mut ys: Vec = self.edges.iter().flat_map(|e| [e.y0, e.y1]).filter(|&y| y > y0 && y < y1).collect(); + ys.sort_by(f32::total_cmp); + ys.dedup(); + if ys.len() > MAX_BAND_SAMPLES { + let step = ys.len() / MAX_BAND_SAMPLES + 1; + ys = ys.into_iter().step_by(step).collect(); + } + ys.push(y0); + ys.push(y1); + let mut acc: Option> = None; + for y in ys { + let v = self.intervals_at(y); + acc = Some(match acc { + None => v, + Some(a) => boolean(&a, &v, |p, q| p && q), + }); + } + acc.unwrap_or_default().into_iter().filter(|(l, r)| r - l >= min_width).collect() + } + + /// The first baseline at or below `from` whose band `[b - ascent, b + descent]` has spans + /// at least `min_width` wide, with those spans. `None` once the band leaves the shape. + pub fn next_row(&self, from: f32, ascent: f32, descent: f32, min_width: f32) -> Option<(f32, Vec<(f32, f32)>)> { + if !(from.is_finite() && ascent.is_finite() && descent.is_finite()) { + return None; + } + let step = ((self.bounds[3] - self.bounds[1]) / 512.0).max(0.5); + let mut b = from; + for _ in 0..MAX_ROW_STEPS { + if b + descent > self.bounds[3] { + return None; + } + let s = self.spans(b - ascent, b + descent, min_width); + if !s.is_empty() { + return Some((b, s)); + } + b += step; + } + None + } + + /// Is `(x, y)` (area space) inside the shape? + pub fn contains(&self, x: f32, y: f32) -> bool { + self.intervals_at(y).iter().any(|&(l, r)| l <= x && x < r) + } +} + +/// Boolean combination of two sorted, disjoint interval lists. +fn boolean(a: &[(f32, f32)], b: &[(f32, f32)], f: impl Fn(bool, bool) -> bool) -> Vec<(f32, f32)> { + let mut xs: Vec = a.iter().chain(b).flat_map(|&(l, r)| [l, r]).collect(); + xs.sort_by(f32::total_cmp); + xs.dedup(); + let inside = |set: &[(f32, f32)], x: f32| set.iter().any(|&(l, r)| l <= x && x < r); + let mut out: Vec<(f32, f32)> = Vec::new(); + for w in xs.windows(2) { + let &[l, r] = w else { continue }; + let mid = (l + r) * 0.5; + if f(inside(a, mid), inside(b, mid)) { + match out.last_mut() { + Some(last) if last.1 == l => last.1 = r, + _ => out.push((l, r)), + } + } + } + out +} + +#[cfg(test)] +mod tests { + use super::*; + use photocraft_doc::vector::{FillRule, Knot, Path, PathOp, Subpath}; + + fn poly(pts: &[(f64, f64)]) -> Path { + Path::new(vec![Subpath::polygon(pts)]) + } + + fn close(a: (f32, f32), b: (f32, f32)) -> bool { + (a.0 - b.0).abs() < 0.01 && (a.1 - b.1).abs() < 0.01 + } + + #[test] + fn rectangle_band_is_its_width() { + let a = AreaShape::new(&poly(&[(0.0, 0.0), (100.0, 0.0), (100.0, 50.0), (0.0, 50.0)]), false).unwrap(); + assert_eq!(a.bounds, [0.0, 0.0, 100.0, 50.0]); + let s = a.spans(10.0, 20.0, 1.0); + assert_eq!(s.len(), 1); + assert!(close(s[0], (0.0, 100.0)), "{s:?}"); + // A band leaving the shape has no span. + assert!(a.spans(40.0, 60.0, 1.0).is_empty()); + } + + #[test] + fn triangle_band_is_its_narrowest_row() { + // Apex at the top: the width at y is y. + let a = AreaShape::new(&poly(&[(50.0, 0.0), (100.0, 100.0), (0.0, 100.0)]), false).unwrap(); + let s = a.spans(40.0, 60.0, 1.0); + assert_eq!(s.len(), 1); + assert!(close(s[0], (30.0, 70.0)), "{s:?}"); + // Narrower than min_width: dropped. + assert!(a.spans(5.0, 10.0, 20.0).is_empty()); + } + + #[test] + fn hole_splits_the_row() { + let outer = Subpath::polygon(&[(0.0, 0.0), (100.0, 0.0), (100.0, 100.0), (0.0, 100.0)]); + let hole = Subpath::polygon(&[(40.0, 40.0), (60.0, 40.0), (60.0, 60.0), (40.0, 60.0)]).with_op(PathOp::Subtract); + let a = AreaShape::new(&Path::new(vec![outer.clone(), hole]), false).unwrap(); + let s = a.spans(45.0, 55.0, 1.0); + assert_eq!(s.len(), 2, "{s:?}"); + assert!(close(s[0], (0.0, 40.0)) && close(s[1], (60.0, 100.0)), "{s:?}"); + // The same hole as a joined subpath under even-odd (a custom shape's counter). + let joined = Subpath::polygon(&[(40.0, 40.0), (60.0, 40.0), (60.0, 60.0), (40.0, 60.0)]).with_op(PathOp::Join); + let mut p = Path::new(vec![outer, joined]); + p.fill_rule = FillRule::EvenOdd; + assert_eq!(AreaShape::new(&p, false).unwrap().spans(45.0, 55.0, 1.0).len(), 2); + } + + #[test] + fn intersect_and_exclude_follow_photoshop_ops() { + let a = Subpath::polygon(&[(0.0, 0.0), (60.0, 0.0), (60.0, 10.0), (0.0, 10.0)]); + let b = |op| Subpath::polygon(&[(40.0, 0.0), (100.0, 0.0), (100.0, 10.0), (40.0, 10.0)]).with_op(op); + let i = AreaShape::new(&Path::new(vec![a.clone(), b(PathOp::Intersect)]), false).unwrap().spans(2.0, 8.0, 1.0); + assert!(i.len() == 1 && close(i[0], (40.0, 60.0)), "{i:?}"); + let x = AreaShape::new(&Path::new(vec![a, b(PathOp::Exclude)]), false).unwrap().spans(2.0, 8.0, 1.0); + assert!(x.len() == 2 && close(x[0], (0.0, 40.0)) && close(x[1], (60.0, 100.0)), "{x:?}"); + } + + #[test] + fn curves_are_flattened() { + // A circle of radius 50 centred on (50, 50) from four kappa curves. + let k = 0.552_284_75 * 50.0; + let c = |x: f64, y: f64, ix: f64, iy: f64, ox: f64, oy: f64| Knot::smooth( + photocraft_geom::Point::new(x, y), + photocraft_geom::Point::new(ix, iy), + photocraft_geom::Point::new(ox, oy), + ); + let circle = Subpath { + closed: true, + knots: vec![ + c(50.0, 0.0, 50.0 - k, 0.0, 50.0 + k, 0.0), + c(100.0, 50.0, 100.0, 50.0 - k, 100.0, 50.0 + k), + c(50.0, 100.0, 50.0 + k, 100.0, 50.0 - k, 100.0), + c(0.0, 50.0, 0.0, 50.0 + k, 0.0, 50.0 - k), + ], + op: PathOp::Combine, + }; + let a = AreaShape::new(&Path::new(vec![circle]), false).unwrap(); + let s = a.spans(49.0, 51.0, 1.0); + assert!(s.len() == 1 && s[0].0 < 1.0 && s[0].1 > 99.0, "{s:?}"); + assert!(a.contains(50.0, 50.0) && !a.contains(3.0, 3.0)); + } + + #[test] + fn next_row_skips_the_narrow_top() { + let a = AreaShape::new(&poly(&[(50.0, 0.0), (100.0, 100.0), (0.0, 100.0)]), false).unwrap(); + // Ascent 8: the band's top (b - 8) needs width ≥ 30, so b ≥ 38. + let (b, s) = a.next_row(8.0, 8.0, 2.0, 30.0).unwrap(); + assert!((b - 38.0).abs() <= 0.51, "{b}"); + assert!(s[0].1 - s[0].0 >= 30.0); + // Past the bottom: no row. + assert!(a.next_row(99.0, 8.0, 2.0, 1.0).is_none()); + } + + #[test] + fn vertical_maps_columns_right_to_left() { + // Text space 100 wide, 50 tall; area space is (y, -x): x in 0..50, y in -100..0. + let a = AreaShape::new(&poly(&[(0.0, 0.0), (100.0, 0.0), (100.0, 50.0), (0.0, 50.0)]), true).unwrap(); + assert_eq!(a.bounds, [0.0, -100.0, 50.0, 0.0]); + let s = a.spans(-60.0, -40.0, 1.0); + assert!(s.len() == 1 && close(s[0], (0.0, 50.0)), "{s:?}"); + } + + #[test] + fn degenerate_and_hostile_paths_give_no_area() { + assert!(AreaShape::new(&Path::default(), false).is_none()); + assert!(AreaShape::new(&Path::new(vec![Subpath::polyline(&[(0.0, 0.0), (10.0, 10.0), (0.0, 10.0)])]), false).is_none(), "open only"); + assert!(AreaShape::new(&poly(&[(0.0, 0.0), (10.0, 0.0), (20.0, 0.0)]), false).is_none(), "no height"); + assert!(AreaShape::new(&poly(&[(0.0, 0.0), (f64::NAN, 0.0), (5.0, 5.0)]), false).is_none()); + assert!(AreaShape::new(&poly(&[(0.0, 0.0), (1e300, 0.0), (5.0, 5.0)]), false).is_none(), "beyond f32"); + let mut inv = poly(&[(0.0, 0.0), (10.0, 0.0), (10.0, 10.0)]); + inv.inverted = true; + assert!(AreaShape::new(&inv, false).is_none(), "an inverted path is unbounded"); + let many: Vec<(f64, f64)> = (0..MAX_AREA_EDGES + 10).map(|i| ((i as f64).cos() * 50.0, (i as f64).sin() * 50.0)).collect(); + assert!(AreaShape::new(&poly(&many), false).is_none()); + // Bad bands never panic. + let a = AreaShape::new(&poly(&[(0.0, 0.0), (10.0, 0.0), (10.0, 10.0)]), false).unwrap(); + assert!(a.spans(f32::NAN, 5.0, 1.0).is_empty()); + assert!(a.spans(5.0, 1.0, 1.0).is_empty()); + assert!(a.next_row(f32::INFINITY, 1.0, 1.0, 1.0).is_none()); + } +} diff --git a/crates/text/src/lib.rs b/crates/text/src/lib.rs index ad5e90ae35..e1a313e4aa 100644 --- a/crates/text/src/lib.rs +++ b/crates/text/src/lib.rs @@ -16,6 +16,7 @@ #![forbid(unsafe_code)] #![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] +pub mod area; pub mod cjk; pub mod craft_fonts; pub mod engine_data; From c531be4d0fd5237dfe4ca0f69bf4463ddefdeb4d Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 00:37:14 -0700 Subject: [PATCH 076/649] fix(text): make area spans exact and bound their cost spans sampled rows, so an edge sweeping across x between rows (slanted holes, bowties, component crossings) was missed. It now takes the inside intervals at the middle row and subtracts what every edge sweeps in the band. Edges are indexed by y per component and boolean is a linear merge, so a query no longer scans every edge. next_row clamps a far-above start, and coordinates beyond 1e7 are rejected. Co-Authored-By: Claude Opus 5.5 --- crates/text/src/area.rs | 157 +++++++++++++++++++++++++++++++--------- 1 file changed, 122 insertions(+), 35 deletions(-) diff --git a/crates/text/src/area.rs b/crates/text/src/area.rs index 85a83868fb..27efeb2401 100644 --- a/crates/text/src/area.rs +++ b/crates/text/src/area.rs @@ -14,8 +14,8 @@ use photocraft_geom::Point; const CURVE_PIECES: usize = 16; /// Largest number of edges an area keeps, so a hostile path can't make every line scan millions. pub const MAX_AREA_EDGES: usize = 65_536; -/// Most rows sampled inside one band; past that, evenly spread vertex rows stand in. -const MAX_BAND_SAMPLES: usize = 256; +/// Largest coordinate magnitude an area accepts, so f32 math on it can't overflow. +const MAX_COORD: f64 = 1e7; /// Most baselines `next_row` tries before giving up. const MAX_ROW_STEPS: usize = 1024; @@ -25,12 +25,18 @@ struct Edge { y0: f32, x1: f32, y1: f32, + /// Lower and upper y of the edge. + lo: f32, + hi: f32, } #[derive(Clone, Debug)] struct Component { op: PathOp, + /// Range into `AreaShape::edges`, sorted by `lo`. edges: Range, + /// Tallest edge in the range, so a query only looks at edges whose `lo` is within it. + max_h: f32, } /// A closed path ready for line fitting, in area space (text space, or `(y, -x)` for vertical @@ -54,10 +60,10 @@ fn same(a: Point, b: Point) -> bool { (a.x - b.x).abs() < 1e-9 && (a.y - b.y).abs() < 1e-9 } -/// f64 → f32, rejecting values that are not finite as f32. +/// f64 → f32, rejecting values that are not finite or are beyond [`MAX_COORD`]. fn small(v: f64) -> Option { let f = v as f32; - f.is_finite().then_some(f) + (v.abs() <= MAX_COORD && f.is_finite()).then_some(f) } impl AreaShape { @@ -101,14 +107,18 @@ impl AreaShape { } for w in pts.windows(2) { if let [(x0, y0), (x1, y1)] = *w { - edges.push(Edge { x0, y0, x1, y1 }); + edges.push(Edge { x0, y0, x1, y1, lo: y0.min(y1), hi: y0.max(y1) }); } } if edges.len() > MAX_AREA_EDGES { return None; } } - comps.push(Component { op, edges: start..edges.len() }); + if let Some(mine) = edges.get_mut(start..) { + mine.sort_by(|a, b| a.lo.total_cmp(&b.lo)); + } + let max_h = edges.get(start..).unwrap_or(&[]).iter().map(|e| e.hi - e.lo).fold(0.0f32, f32::max); + comps.push(Component { op, edges: start..edges.len(), max_h }); } let mut b = [f32::INFINITY, f32::INFINITY, f32::NEG_INFINITY, f32::NEG_INFINITY]; for e in &edges { @@ -127,12 +137,20 @@ impl AreaShape { } } + /// Edges of `c` that may overlap `[ya, yb]` (a superset), found by binary search. + fn candidates(&self, c: &Component, ya: f32, yb: f32) -> &[Edge] { + let all = self.edges.get(c.edges.clone()).unwrap_or(&[]); + let from = all.partition_point(|e| e.lo < ya - c.max_h); + let to = all.partition_point(|e| e.lo <= yb); + all.get(from..to.max(from)).unwrap_or(&[]) + } + /// Inside intervals of one component on row `y` (half-open in y, so a vertex is counted once). fn component_intervals(&self, c: &Component, y: f32) -> Vec<(f32, f32)> { let mut xs: Vec<(f32, i32)> = Vec::new(); - for e in self.edges.get(c.edges.clone()).unwrap_or(&[]) { - let (lo, hi, dir) = if e.y0 < e.y1 { (e.y0, e.y1, 1) } else { (e.y1, e.y0, -1) }; - if lo <= y && y < hi { + for e in self.candidates(c, y, y) { + if e.lo <= y && y < e.hi { + let dir = if e.y0 < e.y1 { 1 } else { -1 }; let t = (y - e.y0) / (e.y1 - e.y0); xs.push((e.x0 + t * (e.x1 - e.x0), dir)); } @@ -168,31 +186,48 @@ impl AreaShape { acc } + /// The x-ranges swept by edges while inside `[y0, y1]`, sorted and merged. + fn swept(&self, y0: f32, y1: f32) -> Vec<(f32, f32)> { + let mut v: Vec<(f32, f32)> = Vec::new(); + for c in &self.comps { + for e in self.candidates(c, y0, y1) { + if e.hi < y0 || e.lo > y1 { + continue; + } + if e.lo == e.hi { + // A horizontal edge only matters strictly inside the band. + if e.lo > y0 && e.lo < y1 { + v.push((e.x0.min(e.x1), e.x0.max(e.x1))); + } + continue; + } + let at = |y: f32| e.x0 + (y - e.y0) / (e.y1 - e.y0) * (e.x1 - e.x0); + let (xa, xb) = (at(e.lo.max(y0)), at(e.hi.min(y1))); + v.push((xa.min(xb), xa.max(xb))); + } + } + v.sort_by(|a, b| a.0.total_cmp(&b.0)); + let mut out: Vec<(f32, f32)> = Vec::new(); + for (l, r) in v { + match out.last_mut() { + Some(last) if l <= last.1 => last.1 = last.1.max(r), + _ => out.push((l, r)), + } + } + out + } + /// Intervals inside the shape on every row of `[y0, y1]`, left to right, each at least - /// `min_width` wide. Edges are straight, so checking the band's ends and every vertex row - /// between them is exact. + /// `min_width` wide. A point is inside for the whole band exactly when it is inside on one + /// row and no edge crosses its vertical segment, so: the inside intervals at the middle row, + /// minus everything the edges sweep across within the band. pub fn spans(&self, y0: f32, y1: f32, min_width: f32) -> Vec<(f32, f32)> { if !(y0.is_finite() && y1.is_finite()) || y1 < y0 { return Vec::new(); } - let mut ys: Vec = self.edges.iter().flat_map(|e| [e.y0, e.y1]).filter(|&y| y > y0 && y < y1).collect(); - ys.sort_by(f32::total_cmp); - ys.dedup(); - if ys.len() > MAX_BAND_SAMPLES { - let step = ys.len() / MAX_BAND_SAMPLES + 1; - ys = ys.into_iter().step_by(step).collect(); - } - ys.push(y0); - ys.push(y1); - let mut acc: Option> = None; - for y in ys { - let v = self.intervals_at(y); - acc = Some(match acc { - None => v, - Some(a) => boolean(&a, &v, |p, q| p && q), - }); - } - acc.unwrap_or_default().into_iter().filter(|(l, r)| r - l >= min_width).collect() + let base = self.intervals_at(y0 + (y1 - y0) * 0.5); + let blocked = self.swept(y0, y1); + boolean(&base, &blocked, |a, b| a && !b).into_iter().filter(|(l, r)| r - l >= min_width).collect() } /// The first baseline at or below `from` whose band `[b - ascent, b + descent]` has spans @@ -201,6 +236,7 @@ impl AreaShape { if !(from.is_finite() && ascent.is_finite() && descent.is_finite()) { return None; } + let from = from.max(self.bounds[1] + ascent); let step = ((self.bounds[3] - self.bounds[1]) / 512.0).max(0.5); let mut b = from; for _ in 0..MAX_ROW_STEPS { @@ -222,17 +258,46 @@ impl AreaShape { } } -/// Boolean combination of two sorted, disjoint interval lists. +/// Boolean combination of two sorted, disjoint interval lists, in one linear merge. fn boolean(a: &[(f32, f32)], b: &[(f32, f32)], f: impl Fn(bool, bool) -> bool) -> Vec<(f32, f32)> { - let mut xs: Vec = a.iter().chain(b).flat_map(|&(l, r)| [l, r]).collect(); - xs.sort_by(f32::total_cmp); - xs.dedup(); - let inside = |set: &[(f32, f32)], x: f32| set.iter().any(|&(l, r)| l <= x && x < r); + let ends = |v: &[(f32, f32)]| -> Vec { v.iter().flat_map(|&(l, r)| [l, r]).collect() }; + let (ea, eb) = (ends(a), ends(b)); + let mut xs: Vec = Vec::with_capacity(ea.len() + eb.len()); + let (mut i, mut j) = (0, 0); + while i < ea.len() || j < eb.len() { + let next = match (ea.get(i), eb.get(j)) { + (Some(&p), Some(&q)) if q < p => { + j += 1; + q + } + (Some(&p), _) => { + i += 1; + p + } + (None, Some(&q)) => { + j += 1; + q + } + (None, None) => break, + }; + if xs.last() != Some(&next) { + xs.push(next); + } + } + let (mut ia, mut ib) = (0usize, 0usize); let mut out: Vec<(f32, f32)> = Vec::new(); for w in xs.windows(2) { let &[l, r] = w else { continue }; let mid = (l + r) * 0.5; - if f(inside(a, mid), inside(b, mid)) { + while a.get(ia).is_some_and(|s| s.1 <= mid) { + ia += 1; + } + while b.get(ib).is_some_and(|s| s.1 <= mid) { + ib += 1; + } + let in_a = a.get(ia).is_some_and(|s| s.0 <= mid); + let in_b = b.get(ib).is_some_and(|s| s.0 <= mid); + if f(in_a, in_b) { match out.last_mut() { Some(last) if last.1 == l => last.1 = r, _ => out.push((l, r)), @@ -338,6 +403,27 @@ mod tests { assert!(a.next_row(99.0, 8.0, 2.0, 1.0).is_none()); } + #[test] + fn next_row_from_far_above_still_finds_rows() { + let a = AreaShape::new(&poly(&[(0.0, 0.0), (100.0, 0.0), (100.0, 50.0), (0.0, 50.0)]), false).unwrap(); + let (b, s) = a.next_row(-1000.0, 8.0, 2.0, 10.0).unwrap(); + assert!((b - 8.0).abs() < 0.6 && close(s[0], (0.0, 100.0)), "{b} {s:?}"); + } + + #[test] + fn slanted_hole_is_never_spanned() { + let outer = Subpath::polygon(&[(0.0, 0.0), (100.0, 0.0), (100.0, 100.0), (0.0, 100.0)]); + let strip = || Subpath::polygon(&[(5.0, 0.0), (8.0, 0.0), (98.0, 100.0), (95.0, 100.0)]); + let sub = Path::new(vec![outer.clone(), strip().with_op(PathOp::Subtract)]); + let mut eo = Path::new(vec![outer, strip().with_op(PathOp::Join)]); + eo.fill_rule = FillRule::EvenOdd; + for p in [sub, eo] { + let s = AreaShape::new(&p, false).unwrap().spans(40.0, 60.0, 1.0); + assert!(!s.is_empty()); + assert!(s.iter().all(|&(l, r)| r <= 50.0 || l >= 53.0), "{s:?}"); + } + } + #[test] fn vertical_maps_columns_right_to_left() { // Text space 100 wide, 50 tall; area space is (y, -x): x in 0..50, y in -100..0. @@ -359,6 +445,7 @@ mod tests { assert!(AreaShape::new(&inv, false).is_none(), "an inverted path is unbounded"); let many: Vec<(f64, f64)> = (0..MAX_AREA_EDGES + 10).map(|i| ((i as f64).cos() * 50.0, (i as f64).sin() * 50.0)).collect(); assert!(AreaShape::new(&poly(&many), false).is_none()); + assert!(AreaShape::new(&poly(&[(0.0, 0.0), (1e8, 0.0), (5.0, 5.0)]), false).is_none(), "beyond 1e7"); // Bad bands never panic. let a = AreaShape::new(&poly(&[(0.0, 0.0), (10.0, 0.0), (10.0, 10.0)]), false).unwrap(); assert!(a.spans(f32::NAN, 5.0, 1.0).is_empty()); From 6b44a482fa0f9f1d16d913ee0a8bdf0681075c25 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 00:40:09 -0700 Subject: [PATCH 077/649] fix(text): keep area edge lookups safe from rounding The binary-search cut-off y - max_h rounds in f32 and could land above the lo of an edge that really crosses the row, dropping it and flipping the winding for the whole row. Add slack; the exact lo <= y < hi test still filters extras. Also document that inner edges block width conservatively. Co-Authored-By: Claude Opus 5.5 --- crates/text/src/area.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/text/src/area.rs b/crates/text/src/area.rs index 27efeb2401..0106e3878d 100644 --- a/crates/text/src/area.rs +++ b/crates/text/src/area.rs @@ -140,7 +140,9 @@ impl AreaShape { /// Edges of `c` that may overlap `[ya, yb]` (a superset), found by binary search. fn candidates(&self, c: &Component, ya: f32, yb: f32) -> &[Edge] { let all = self.edges.get(c.edges.clone()).unwrap_or(&[]); - let from = all.partition_point(|e| e.lo < ya - c.max_h); + // Slack covers f32 rounding of `max_h` and of the subtraction; extras are filtered exactly later. + let slack = (ya.abs() + c.max_h) * 1e-6 + 1e-3; + let from = all.partition_point(|e| e.lo < ya - c.max_h - slack); let to = all.partition_point(|e| e.lo <= yb); all.get(from..to.max(from)).unwrap_or(&[]) } @@ -220,7 +222,9 @@ impl AreaShape { /// Intervals inside the shape on every row of `[y0, y1]`, left to right, each at least /// `min_width` wide. A point is inside for the whole band exactly when it is inside on one /// row and no edge crosses its vertical segment, so: the inside intervals at the middle row, - /// minus everything the edges sweep across within the band. + /// minus everything the edges sweep across within the band. Edges that lie inside the filled + /// area (inner edges of overlapping Combine/Join components, or Subtract edges outside the + /// shape) also block width. That is conservative and never puts text over a cutout. pub fn spans(&self, y0: f32, y1: f32, min_width: f32) -> Vec<(f32, f32)> { if !(y0.is_finite() && y1.is_finite()) || y1 < y0 { return Vec::new(); @@ -410,6 +414,16 @@ mod tests { assert!((b - 8.0).abs() < 0.6 && close(s[0], (0.0, 100.0)), "{b} {s:?}"); } + #[test] + fn tall_edge_survives_rounding_at_its_end() { + // The tallest edge's height and `y - height` both round; the lookup must still find it. + let a = AreaShape::new(&poly(&[(0.0, -1898.2166), (10.0, 212.32651), (0.0, 212.32651)]), false).unwrap(); + let y = 212.32649_f32; + assert!(a.contains(5.0, y)); + let s = a.spans(y, y, 1.0); + assert!(s.len() == 1 && s[0].0 < 0.01 && s[0].1 > 9.9, "{s:?}"); + } + #[test] fn slanted_hole_is_never_spanned() { let outer = Subpath::polygon(&[(0.0, 0.0), (100.0, 0.0), (100.0, 100.0), (0.0, 100.0)]); From 810ddb92325d4ea0d77518dffd21e950257009ef Mon Sep 17 00:00:00 2001 From: Muhammad Saad Date: Thu, 15 Oct 2026 11:48:34 +0400 Subject: [PATCH 078/649] Raw: charge the retained tile intermediates together (#4959) read_plane decodes every segment through par::map and keeps the whole Vec of decoded tiles until it scatters them into the destination, so the working set is the sum of the tiles rather than the largest one. Each tile is charged against Limits on its own just before it decodes (#2925), and max_alloc is a per-buffer limit by contract, so a file that declares many segments which are each admissible can still retain far more than any one of them allows. Charge the sum before any segment decodes: retained_segment_bytes adds up the decoded size of every segment from its declared geometry, refusing a segment whose own size overflows rather than wrapping, and stops as soon as the running total passes max_alloc. A segment's geometry is declared independently of the image, which is what lets the total run away. For a well-formed file the segments tile the image, so their sum is about its own size and limits.check has already bounded it; what this refuses is a file whose declared tiles are far larger than the image they belong to. Test: tiles that each sit far inside the budget are refused once their sum passes it, more samples a pixel cost proportionally more, an overflowing geometry is refused rather than wrapping, and an ordinary 6000 x 4000 frame in 512-pixel tiles still passes the default limits. --- crates/raw/src/sensor.rs | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/crates/raw/src/sensor.rs b/crates/raw/src/sensor.rs index f2cffdb808..2e619b4d37 100644 --- a/crates/raw/src/sensor.rs +++ b/crates/raw/src/sensor.rs @@ -255,6 +255,7 @@ pub(crate) fn read_plane(t: &Tiff, ifd: &Ifd, limits: &Limits, layout: JpegLayou } limits.check(width as u64, height as u64, samples as u64 * 2)?; let segments = segments(t, ifd, width, height)?; + retained_segment_bytes(&segments, samples, limits)?; let le = t.le; let tiled = t.tag_uint(ifd, tag::TILE_WIDTH).is_some(); let decoded: Vec>> = par::map(segments.len(), |i| { @@ -334,6 +335,29 @@ pub(crate) fn read_plane(t: &Tiff, ifd: &Ifd, limits: &Limits, layout: JpegLayou Ok(Plane { width, height, samples, bits, data }) } +/// Bytes of decoded samples the segments hold at once. +/// +/// Each segment is charged against `limits` on its own just before it decodes, but every decoded +/// tile is retained until the scatter at the end of [`read_plane`], so the peak is their sum and +/// not the largest of them. A segment's geometry is declared independently of the image, so a +/// file can carry many segments that are each admissible and together are not (#4959). For a +/// well-formed file the segments tile the image, so their sum is about its own size, which +/// `limits.check` has already bounded. +fn retained_segment_bytes(segments: &[Segment], samples: usize, limits: &Limits) -> Result { + let mut total: u64 = 0; + for s in segments { + let bytes = (s.w as u64) + .checked_mul(s.h as u64) + .and_then(|px| px.checked_mul(samples as u64 * 2)) + .ok_or_else(|| RawError::LimitExceeded("a raw segment is too large to decode".into()))?; + total = total.saturating_add(bytes); + if total > limits.max_alloc { + return Err(RawError::LimitExceeded(format!("{total} bytes of decoded segments exceed {}", limits.max_alloc))); + } + } + Ok(total) +} + pub(crate) fn segments(t: &Tiff, ifd: &Ifd, width: usize, height: usize) -> Result> { let mut out = Vec::new(); if let (Some(tw), Some(th)) = (t.tag_uint(ifd, tag::TILE_WIDTH), t.tag_uint(ifd, tag::TILE_LENGTH)) { @@ -480,6 +504,29 @@ fn unpack(src: &[u8], w: usize, rows: usize, samples: usize, bits: u32, le: bool mod tests { use super::*; + /// #4959: a decoded segment is retained until the scatter, so the segments are charged + /// together. Each of these is far inside the budget on its own; their sum is not. + #[test] + fn segments_are_charged_together_rather_than_one_at_a_time() { + let limits = Limits { max_alloc: 8 << 20, ..Limits::default() }; + // 1024 x 512 samples, two bytes each: one mebibyte a tile. + let tile = |i: usize| Segment { x: 0, y: i * 512, w: 1024, h: 512, offset: 0, len: 0 }; + let eight: Vec = (0..8).map(tile).collect(); + assert_eq!(retained_segment_bytes(&eight, 1, &limits).unwrap(), 8 << 20, "the budget is spent exactly"); + + let nine: Vec = (0..9).map(tile).collect(); + assert!(matches!(retained_segment_bytes(&nine, 1, &limits), Err(RawError::LimitExceeded(_))), "one tile over"); + assert!(retained_segment_bytes(&eight, 3, &limits).is_err(), "more samples a pixel cost proportionally more"); + + // A segment whose own geometry overflows is refused rather than wrapping to a small sum. + let huge = [Segment { x: 0, y: 0, w: usize::MAX, h: usize::MAX, offset: 0, len: 0 }]; + assert!(matches!(retained_segment_bytes(&huge, 1, &limits), Err(RawError::LimitExceeded(_)))); + + // A normal tiled frame is unaffected: 6000 x 4000 in 512-pixel tiles, padding included. + let normal: Vec = (0..12 * 8).map(|i| Segment { x: (i % 12) * 512, y: (i / 12) * 512, w: 512, h: 512, offset: 0, len: 0 }).collect(); + assert!(retained_segment_bytes(&normal, 1, &Limits::default()).is_ok()); + } + #[test] fn bayer_patterns() { for p in ["RGGB", "BGGR", "GRBG", "GBRG"] { From 4fda152dbd3884b6d7562775c32da4ac7d31e370 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 01:07:26 -0700 Subject: [PATCH 079/649] feat(text): lay out area type inside a closed path Adds TextShape::Area { path } and lays it out: each paragraph is broken a line at a time with parley's BreakLines, because a line's width depends on where it lands in the shape (the row's spans at that baseline), which break_all_lines can't express. Rows are planned with the first style's metrics and re-planned once with the real ones when a line is taller, so mixed sizes can leave a little extra gap. Lines align within their own span (parley aligns per line to the width it was broken at; no manual alignment needed). Text past the shape is hidden, as in a text box, and hides later paragraphs too. A span too narrow for the word that would start it (the narrow top of an ellipse) is left empty and the word moves on, so lines stay inside the shape; a word wider than the whole shape overflows its span, as in a box. BreakLines doesn't report trailing whitespace, so this is checked after each pass and the paragraph re-broken (at most 64 skips). PSD has no area type writer yet: an area layer saves as paragraph text over the path's bounds, so Photoshop opens it wrapping in a rectangle. Other matches (PSD import, transform box, point/box conversions) get the arm matching their neighbours. Co-Authored-By: Claude Opus 5.5 --- crates/doc/src/text.rs | 7 +- crates/engine/src/type_extra_cmds.rs | 3 +- crates/text/src/layout.rs | 240 ++++++++++++++++++++++++--- crates/text/src/psd.rs | 25 ++- crates/text/src/tests.rs | 123 ++++++++++++++ crates/ui-egui/src/type_transform.rs | 9 +- 6 files changed, 374 insertions(+), 33 deletions(-) diff --git a/crates/doc/src/text.rs b/crates/doc/src/text.rs index 6f7836fa46..070ab11328 100644 --- a/crates/doc/src/text.rs +++ b/crates/doc/src/text.rs @@ -209,7 +209,8 @@ pub struct ParagraphRun { } /// Point text grows from its anchor (text-space origin = first baseline at the anchor); -/// paragraph (box) text wraps inside a rectangle; path text runs along a curve. +/// paragraph (box) text wraps inside a rectangle; path text runs along a curve; area text +/// wraps inside a closed path. #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub enum TextShape { #[default] @@ -221,6 +222,10 @@ pub enum TextShape { /// curve. `start` is the arc-length offset (px) of the text origin along the path; `flip` /// puts the text on the other side of the path. Path { path: super::vector::Subpath, start: f32, flip: bool }, + /// Area type: paragraph text that wraps inside the closed subpaths of `path` (text-space + /// pixels, before the layer transform), combined with their path operations and fill rule. + /// Text that doesn't fit is hidden, as in a text box. + Area { path: super::vector::Path }, } #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] diff --git a/crates/engine/src/type_extra_cmds.rs b/crates/engine/src/type_extra_cmds.rs index efa2d791cc..569af27c96 100644 --- a/crates/engine/src/type_extra_cmds.rs +++ b/crates/engine/src/type_extra_cmds.rs @@ -44,7 +44,7 @@ fn has_point_text(s: &Session) -> std::result::Result<(), String> { match active_text(s)?.shape { TextShape::Point => Ok(()), TextShape::Box { .. } => Err("the type layer is already paragraph text".into()), - TextShape::Path { .. } => Err("detach the type layer from its path first".into()), + TextShape::Path { .. } | TextShape::Area { .. } => Err("release the type layer from its path first".into()), } } @@ -53,6 +53,7 @@ fn has_box_text(s: &Session) -> std::result::Result<(), String> { TextShape::Box { .. } => Ok(()), TextShape::Point => Err("the type layer is already point text".into()), TextShape::Path { .. } => Err("the type layer is path text".into()), + TextShape::Area { .. } => Err("the type layer is area type; release it from its path first".into()), } } diff --git a/crates/text/src/layout.rs b/crates/text/src/layout.rs index e2bd223b3b..0a09cbc08d 100644 --- a/crates/text/src/layout.rs +++ b/crates/text/src/layout.rs @@ -22,7 +22,7 @@ use parley::{ PositionedLayoutItem, StyleProperty, }; use photocraft_doc::TextLayer; -use photocraft_doc::text::{Caps, CharStyle, Kerning, Orientation, TextAlign, TextDirection, TextShape}; +use photocraft_doc::text::{Caps, CharStyle, Kerning, Orientation, ParagraphStyle, TextAlign, TextDirection, TextShape}; use skrifa::raw::types::Tag; use crate::fonts::FontDb; @@ -502,9 +502,18 @@ impl Layouter { let text = &t.text; let (box_rect, is_box) = match t.shape { TextShape::Box { x, y, width, height } => ((x, y, width, height), true), - // Path text is laid out as one point-text line, then bent onto the path. - TextShape::Point | TextShape::Path { .. } => ((0.0, 0.0, 0.0, 0.0), false), + // Path text is laid out as one point-text line, then bent onto the path. Area text + // places its own lines (`area` below). + TextShape::Point | TextShape::Path { .. } | TextShape::Area { .. } => ((0.0, 0.0, 0.0, 0.0), false), }; + // Area type: the shape its lines wrap inside. A path that encloses nothing (only from a + // hostile file; `type.fillPath` refuses one) lays out as point text. + let area = match &t.shape { + TextShape::Area { path } => crate::area::AreaShape::new(path, vertical), + _ => None, + }; + // Box and area text wrap, align within their lines and hide what doesn't fit. + let wraps = is_box || area.is_some(); let mut prev_baseline: Option = None; let mut pending_space = 0.0f32; let mut stop = false; @@ -640,35 +649,66 @@ impl Layouter { // Box extent along the lines: width, or height for vertical type (columns). let (line_origin, line_len) = if vertical { (box_rect.1, box_rect.3) } else { (box_rect.0, box_rect.2) }; let avail = if is_box { Some((line_len - indent_start - indent_end).max(1.0)) } else { None }; - let break_lines = |layout: &mut Layout| { + // Area type: plan rows with the first style's metrics, and the first row no higher + // than one leading (plus paragraph spacing) below the previous paragraph's last line. + let area_style = out.styles[style_at(prange.start)].clone(); + let guess = AreaMetrics { + ascent: if vertical { first_px * 0.5 } else { first_px * 0.8 }, + descent: if vertical { first_px * 0.5 } else { first_px * 0.2 }, + leading: area_style.leading_pt.map_or(ps.auto_leading * first_px, |l| l * k), + }; + let space_before = if prev_baseline.is_some() { ps.space_before_pt * k } else { 0.0 }; + let area_from = |m: AreaMetrics| match (&area, prev_baseline) { + (Some(_), Some(b)) => b + m.leading + pending_space + space_before, + (Some(a), None) => a.bounds[1] + m.ascent, + (None, _) => 0.0, + }; + let break_lines = |layout: &mut Layout| -> (Vec, bool) { if first_indent != 0.0 { layout.set_text_indent(first_indent, IndentOptions::default()); } - layout.break_all_lines(avail); + let Some(a) = &area else { + layout.break_all_lines(avail); + return (Vec::new(), false); + }; + let mut r = break_area(layout, a, area_from(guess), guess, (indent_start, indent_end), first_px); + // Re-plan once with the real metrics if a line is taller than the guess. + let real = area_metrics(layout, &out.styles, &ps, k, &area_style, vertical); + if real.ascent > guess.ascent + 0.5 || real.descent > guess.descent + 0.5 || real.leading > guess.leading + 0.5 { + let m = AreaMetrics { + ascent: real.ascent.max(guess.ascent), + descent: real.descent.max(guess.descent), + leading: real.leading.max(guess.leading), + }; + r = break_area(layout, a, area_from(m), m, (indent_start, indent_end), first_px); + } + r }; // Paragraph text: a tab is never wider than a space plus one tab interval, so breaking // lines at that width keeps the expanded tabs inside the box, but can wrap early. // Break again with the tab widths that layout gives until they agree; if they don't // settle, keep the safe layout. - let wide = if is_box { tab_px } else { 0.0 }; + let wide = if wraps { tab_px } else { 0.0 }; let mut layout = build(&mut self.lcx, &mut fonts.fcx, &vec![wide; tabs.len()]); - break_lines(&mut layout); - if is_box && !tabs.is_empty() { + let (mut area_slots, mut area_full) = break_lines(&mut layout); + if wraps && !tabs.is_empty() { let first = tab_widths(&layout, &tabs, &out.styles, indent_start, first_indent, tab_px); let mut want: Vec = first.iter().map(|t| t.width).collect(); for _ in 0..4 { let spacing: Vec = first.iter().zip(&want).map(|(t, w)| w / t.scale - (t.advance - tab_px)).collect(); let mut next = build(&mut self.lcx, &mut fonts.fcx, &spacing); - break_lines(&mut next); + let (next_slots, next_full) = break_lines(&mut next); let got: Vec = tab_widths(&next, &tabs, &out.styles, indent_start, first_indent, tab_px).iter().map(|t| t.width).collect(); if got.iter().zip(&want).all(|(a, b)| (a - b).abs() < 0.01) { layout = next; + area_slots = next_slots; + area_full = next_full; break; } want = got; } } - let alignment = if is_box { + let alignment = if wraps { match ps.align { TextAlign::Left => Alignment::Left, TextAlign::Center => Alignment::Center, @@ -678,7 +718,7 @@ impl Layouter { } else { Alignment::Left }; - layout.align(alignment, AlignmentOptions { align_when_overflowing: !is_box }); + layout.align(alignment, AlignmentOptions { align_when_overflowing: !wraps }); // Stack lines. if prev_baseline.is_some() { @@ -686,6 +726,12 @@ impl Layouter { } let nlines = layout.len(); for (li, line) in layout.lines().enumerate() { + // Area type: the slot the breaker gave this line. + let slot = area_slots.get(li).copied(); + if area.is_some() && slot.is_none() { + stop = true; + break; + } let m = *line.metrics(); // Largest leading among the glyph runs of the line. let mut leading = 0.0f32; @@ -716,14 +762,15 @@ impl Layouter { } else { (first_px * 0.8, first_px * 0.2) }; - let baseline = match prev_baseline { + let baseline = match (slot, prev_baseline) { + (Some(s), _) => s.baseline, // The first column's right edge touches the box's right edge. - None if is_box && vertical => -(box_rect.0 + box_rect.2) + col_half, + (None, None) if is_box && vertical => -(box_rect.0 + box_rect.2) + col_half, // Photoshop's "first baseline: ascent": the top of the tallest ascender // (height of 'd') touches the box top, not the font's hhea ascent. - None if is_box => box_rect.1 + first_ascent(&line).unwrap_or(ascent), - None => 0.0, - Some(b) => b + leading + pending_space, + (None, None) if is_box => box_rect.1 + first_ascent(&line).unwrap_or(ascent), + (None, None) => 0.0, + (None, Some(b)) => b + leading + pending_space, }; pending_space = 0.0; // Photoshop keeps a horizontal line whose baseline is inside the box and lets @@ -847,7 +894,7 @@ impl Layouter { cursors.push((run.index(), g2s, 0, base)); } // Parley aligned box lines without the kerning. - let kern_align = if is_box { + let kern_align = if wraps { match ps.align { TextAlign::Center => line_kern / 2.0, TextAlign::Right => line_kern, @@ -856,9 +903,13 @@ impl Layouter { } else { 0.0 }; - let dx = if is_box { - let base = line_origin + indent_start - kern_align; - let slack = avail.unwrap_or(0.0) - adv - line_kern; + // Box and area lines start at their box or span edge; the line's own width + // (`line_avail`) takes the justify-last-line slack. + let line_avail = slot.map(|s| s.width).or(avail); + let dx = if wraps { + let origin = slot.map_or(line_origin, |s| s.x); + let base = origin + indent_start - kern_align; + let slack = line_avail.unwrap_or(0.0) - adv - line_kern; base + if last_line { match ps.align { TextAlign::JustifyCenter => slack * 0.5 - m.offset, @@ -876,7 +927,7 @@ impl Layouter { }; target - m.offset }; - let justify_all = is_box && last_line && ps.align == TextAlign::JustifyAll; + let justify_all = wraps && last_line && ps.align == TextAlign::JustifyAll; let line_index = out.lines.len(); let lr = line.text_range(); let g0 = out.glyphs.len(); @@ -996,7 +1047,7 @@ impl Layouter { extra -= squeeze_punctuation(text, &mut out.clusters[c0..], &mut out.glyphs[g0..]); } if justify_all { - let slack = avail.unwrap_or(0.0) - (adv + extra); + let slack = line_avail.unwrap_or(0.0) - (adv + extra); let n = out.clusters.len() - c0; if n > 1 && slack > 0.0 { let step = slack / (n - 1) as f32; @@ -1037,6 +1088,10 @@ impl Layouter { paragraph: pi, }); } + if area_full { + // The shape is full: later paragraphs are hidden too. + stop = true; + } pending_space += ps.space_after_pt * k; } out @@ -1048,6 +1103,147 @@ fn next_tab_stop(pos: f32, interval: f32) -> f32 { if interval > 0.0 && pos.is_finite() { ((pos + 1e-3) / interval).floor() * interval + interval } else { pos } } +/// Where one line of area type goes: its baseline, the left edge of its span, and the width +/// it may fill (the span less the paragraph's indents). +#[derive(Clone, Copy, Debug, PartialEq)] +struct Slot { + baseline: f32, + x: f32, + width: f32, +} + +/// Line metrics an area paragraph is planned with. +#[derive(Clone, Copy, Debug)] +struct AreaMetrics { + ascent: f32, + descent: f32, + leading: f32, +} + +/// Most spans one area paragraph skips because the word that would start there doesn't fit (each +/// skip breaks the paragraph again). +const MAX_AREA_SKIPS: usize = 64; + +/// Breaks one paragraph of area type a line at a time, each line as wide as the next span the +/// shape leaves (rows from `from` down, spans left to right). Returns each line's slot and +/// whether text was left over because the shape ran out (hidden, like box overflow). +/// +/// A span too narrow for the word that would start it (the narrow top of an ellipse) is left +/// empty and the word goes to the next span, as long as the word fits across the shape's full +/// width somewhere; a word wider than the whole shape overflows its span, as in a text box. +fn break_area( + layout: &mut Layout, + area: &crate::area::AreaShape, + from: f32, + m: AreaMetrics, + indents: (f32, f32), + min_width: f32, +) -> (Vec, bool) { + let widest = area.bounds[2] - area.bounds[0] - indents.0 - indents.1; + // Spans left empty, by baseline and left edge (exact: every pass computes them the same way). + let mut skip: Vec<(f32, f32)> = Vec::new(); + loop { + let (slots, overflow) = break_area_pass(layout, area, from, m, indents, min_width, &skip); + // Skipping only makes progress when rows move down. + if m.leading < 1.0 || skip.len() >= MAX_AREA_SKIPS { + return (slots, overflow); + } + let narrow = layout.lines().zip(&slots).find_map(|(line, s)| { + let lm = line.metrics(); + let content = lm.advance - lm.trailing_whitespace; + (content > s.width + 0.5 && content <= widest).then_some((s.baseline, s.x)) + }); + match narrow { + Some(span) => skip.push(span), + None => return (slots, overflow), + } + } +} + +/// One pass of [`break_area`], leaving the spans in `skip` empty. +fn break_area_pass( + layout: &mut Layout, + area: &crate::area::AreaShape, + from: f32, + m: AreaMetrics, + indents: (f32, f32), + min_width: f32, + skip: &[(f32, f32)], +) -> (Vec, bool) { + let mut slots = Vec::new(); + let mut br = layout.break_lines(); + // Per-line widths below are never wider than this, as parley requires. + br.state_mut().set_layout_max_advance(f32::INFINITY); + let mut baseline = from; + // The current row's spans, rightmost first so `pop` takes them left to right. + let mut row: Vec<(f32, f32)> = Vec::new(); + let mut overflow = false; + while !br.is_done() { + if row.is_empty() { + match area.next_row(baseline, m.ascent, m.descent, min_width) { + Some((b, mut spans)) => { + baseline = b; + spans.reverse(); + row = spans; + } + None => { + overflow = true; + break; + } + } + } + let Some((x0, x1)) = row.pop() else { break }; + if !skip.contains(&(baseline, x0)) { + let width = (x1 - x0 - indents.0 - indents.1).max(1.0); + br.state_mut().set_line_max_advance(width); + if br.break_next().is_none() { + break; + } + // Parley aligns each line within the width it was broken at. + br.set_prior_line_width(width); + slots.push(Slot { baseline, x: x0, width }); + } + if row.is_empty() { + baseline += m.leading; + } + } + br.finish(); + (slots, overflow) +} + +/// Largest ascent, descent and leading over the lines of a broken paragraph, computed the same +/// way the line loop below does, so an area paragraph can be re-planned with its real metrics. +fn area_metrics(layout: &Layout, styles: &[CharStyle], ps: &ParagraphStyle, k: f32, fallback: &CharStyle, vertical: bool) -> AreaMetrics { + let first_px = fallback.size_pt * k; + let mut out = AreaMetrics { ascent: 0.0, descent: 0.0, leading: 0.0 }; + for line in layout.lines() { + let m = *line.metrics(); + let mut leading = 0.0f32; + let mut half = 0.0f32; + for item in line.items() { + if let PositionedLayoutItem::GlyphRun(gr) = item { + let px = gr.run().font_size(); + half = half.max(px * 0.5); + let lp = styles.get(gr.style().brush.0 as usize).and_then(|st| st.leading_pt); + leading = leading.max(lp.map_or(ps.auto_leading * px, |l| l * k)); + } + } + if leading == 0.0 { + leading = fallback.leading_pt.map_or(ps.auto_leading * first_px, |l| l * k); + } + let (a, d) = if vertical { + let h = if half > 0.0 { half } else { first_px * 0.5 }; + (h, h) + } else if m.ascent > 0.0 || m.descent > 0.0 { + (m.ascent, m.descent) + } else { + (first_px * 0.8, first_px * 0.2) + }; + out = AreaMetrics { ascent: out.ascent.max(a), descent: out.descent.max(d), leading: out.leading.max(leading) }; + } + out +} + /// A tab as line breaking saw it: its shaped advance (before horizontal scale), the horizontal /// scale, and the width that takes it to its tab stop on its line. struct TabWidth { diff --git a/crates/text/src/psd.rs b/crates/text/src/psd.rs index 0092fcf92e..4c8c966ac4 100644 --- a/crates/text/src/psd.rs +++ b/crates/text/src/psd.rs @@ -248,7 +248,7 @@ pub fn apply_txt2_frame(layer: &mut TextLayer, tysh: &[u8], txt2: &E) { let p = arr_f(frame.get("0")); if p.len() == 2 && p.iter().all(|v| v.is_finite()) { Affine::translate(p[0], p[1]) } else { Affine::IDENTITY } } - TextShape::Box { .. } => Affine::IDENTITY, + TextShape::Box { .. } | TextShape::Area { .. } => Affine::IDENTITY, }; let to_text = matrix.mul(&at); if to_text == Affine::IDENTITY || to_text.determinant().abs() <= 1e-9 { @@ -261,7 +261,7 @@ pub fn apply_txt2_frame(layer: &mut TextLayer, tysh: &[u8], txt2: &E) { // again would move it twice. let origin = match layer.shape { TextShape::Point | TextShape::Path { .. } => Point::new(0.0, 0.0), - TextShape::Box { .. } => { + TextShape::Box { .. } | TextShape::Area { .. } => { let b = engine_data(&t.text) .map(|e| { arr_f( @@ -1188,10 +1188,16 @@ pub fn build_engine_data(layer: &TextLayer, template: Option, dpi: f32) -> E if dict.get("UseFractionalGlyphWidths").is_none() { dict.set("UseFractionalGlyphWidths", E::Bool(true)); } - let (shape_type, box_bounds) = match layer.shape { + let (shape_type, box_bounds) = match &layer.shape { // PSD path type is not written yet: the layer saves as point text. TextShape::Point | TextShape::Path { .. } => (0, None), - TextShape::Box { x, y, width, height } => (1, Some([x, y, x + width, y + height])), + TextShape::Box { x, y, width, height } => (1, Some([*x, *y, x + width, y + height])), + // PSD area type is not written yet: the layer saves as paragraph text over the path's + // bounds, so Photoshop opens it with the same text wrapping in a rectangle. + TextShape::Area { path } => match path.control_bounds() { + Some((x0, y0, x1, y1)) => (1, Some([x0 as f32, y0 as f32, x1 as f32, y1 as f32])), + None => (0, None), + }, }; let mut photoshop = E::Dict(vec![("ShapeType".into(), E::Int(shape_type))]); match box_bounds { @@ -1303,9 +1309,14 @@ pub fn build_tysh(layer: &TextLayer, dpi: f32, ink: Option<[f32; 4]>) -> Vec }, ), ); - let [l, t, r, b] = match (&layer.shape, ink) { - (&TextShape::Box { x, y, width, height }, _) => [x, y, x + width, y + height], - (_, Some(i)) => i, + let area = match &layer.shape { + TextShape::Area { path } => path.control_bounds().map(|(x0, y0, x1, y1)| [x0 as f32, y0 as f32, x1 as f32, y1 as f32]), + _ => None, + }; + let [l, t, r, b] = match (&layer.shape, area, ink) { + (&TextShape::Box { x, y, width, height }, _, _) => [x, y, x + width, y + height], + (_, Some(a), _) => a, + (_, _, Some(i)) => i, _ => [0.0; 4], }; let rect = |cls: &str| { diff --git a/crates/text/src/tests.rs b/crates/text/src/tests.rs index 13de665ccd..03f37f7f0a 100644 --- a/crates/text/src/tests.rs +++ b/crates/text/src/tests.rs @@ -2008,3 +2008,126 @@ fn hyphenless_postscript_names_split_trailing_styles() { assert_eq!((r.family.as_str(), r.weight, r.italic), (family, weight, italic), "{ps}"); } } + +/// Closed polygon in text space. +fn area_poly(pts: &[(f64, f64)]) -> photocraft_doc::vector::Path { + photocraft_doc::vector::Path::new(vec![photocraft_doc::vector::Subpath::polygon(pts)]) +} + +/// An ellipse from four kappa curves inside `[x, y, w, h]`. +fn area_ellipse(x: f64, y: f64, w: f64, h: f64) -> photocraft_doc::vector::Path { + use photocraft_doc::vector::{Knot, Subpath}; + use photocraft_geom::Point; + let (rx, ry, cx, cy) = (w / 2.0, h / 2.0, x + w / 2.0, y + h / 2.0); + let (kx, ky) = (0.552_284_75 * rx, 0.552_284_75 * ry); + let p = Point::new; + let knots = vec![ + Knot::smooth(p(cx, y), p(cx - kx, y), p(cx + kx, y)), + Knot::smooth(p(x + w, cy), p(x + w, cy - ky), p(x + w, cy + ky)), + Knot::smooth(p(cx, y + h), p(cx + kx, y + h), p(cx - kx, y + h)), + Knot::smooth(p(x, cy), p(x, cy + ky), p(x, cy - ky)), + ]; + photocraft_doc::vector::Path::new(vec![Subpath { closed: true, knots, op: Default::default() }]) +} + +const BUBBLE_TEXT: &str = "Well, that went better than expected. Now where did the cat hide the keys this time?"; + +/// Every laid-out line sits inside a span of the shape across its band. +fn assert_lines_inside(l: &crate::TextLayout, path: &photocraft_doc::vector::Path) { + let a = crate::area::AreaShape::new(path, false).unwrap(); + for line in &l.lines { + let spans = a.spans(line.baseline - line.ascent, line.baseline + line.descent, 0.0); + assert!(spans.iter().any(|&(s0, s1)| line.x0 >= s0 - 0.5 && line.x1 <= s1 + 0.5), "{line:?} not inside {spans:?}"); + } +} + +#[test] +fn area_text_stays_inside_an_ellipse() { + let mut e = TextEngine::new(); + let mut t = point(BUBBLE_TEXT, 18.0); + let path = area_ellipse(0.0, 0.0, 260.0, 160.0); + t.shape = TextShape::Area { path: path.clone() }; + let l = e.layout(&t, 72.0); + assert!(l.lines.len() >= 4, "{}", l.lines.len()); + assert_lines_inside(&l, &path); + // The top of an ellipse is too narrow for a line at its very edge: the first line starts lower. + assert!(l.lines[0].baseline - l.lines[0].ascent > 1.0, "{:?}", l.lines[0]); + // Lines go down the shape in text order. + for w in l.lines.windows(2) { + assert!(w[1].baseline >= w[0].baseline && w[1].range.start >= w[0].range.end, "{w:?}"); + } + // Middle lines are wider than the first (the ellipse is widest in the middle). + let width = |i: usize| l.lines[i].x1 - l.lines[i].x0; + assert!(width(l.lines.len() / 2) > width(0), "{l:?}"); +} + +#[test] +fn area_overflow_is_hidden() { + let mut e = TextEngine::new(); + let mut t = point(&BUBBLE_TEXT.repeat(10), 14.0); + let path = area_ellipse(0.0, 0.0, 200.0, 80.0); + t.shape = TextShape::Area { path: path.clone() }; + let l = e.layout(&t, 72.0); + assert!(!l.lines.is_empty()); + assert!(l.lines.last().unwrap().range.end < t.text.len(), "the rest is hidden"); + assert_lines_inside(&l, &path); +} + +#[test] +fn area_lines_center_in_their_span() { + let mut e = TextEngine::new(); + let mut t = point(BUBBLE_TEXT, 12.0); + t.paragraphs = vec![ParagraphRun { len: t.text.len(), style: ParagraphStyle { align: TextAlign::Center, ..Default::default() } }]; + // A diamond: every row's span is centred on x = 100. + t.shape = TextShape::Area { path: area_poly(&[(100.0, 0.0), (200.0, 100.0), (100.0, 200.0), (0.0, 100.0)]) }; + let l = e.layout(&t, 72.0); + assert!(l.lines.len() >= 3); + for line in &l.lines { + assert!(((line.x0 + line.x1) / 2.0 - 100.0).abs() < 1.5, "{line:?}"); + } +} + +#[test] +fn area_rows_split_around_a_hole() { + use photocraft_doc::vector::{PathOp, Subpath}; + let mut e = TextEngine::new(); + let mut t = point(&BUBBLE_TEXT.repeat(6), 12.0); + let path = photocraft_doc::vector::Path::new(vec![ + Subpath::polygon(&[(0.0, 0.0), (300.0, 0.0), (300.0, 300.0), (0.0, 300.0)]), + Subpath::polygon(&[(120.0, 100.0), (180.0, 100.0), (180.0, 200.0), (120.0, 200.0)]).with_op(PathOp::Subtract), + ]); + t.shape = TextShape::Area { path: path.clone() }; + let l = e.layout(&t, 72.0); + assert_lines_inside(&l, &path); + // Some baseline carries two lines: one left of the hole, one right of it, left first. + let w = l.lines.windows(2).find(|w| (w[0].baseline - w[1].baseline).abs() < 1e-3).expect("a row split around the hole"); + let (left, right) = (&w[0], &w[1]); + assert!(left.x1 <= 120.5 && right.x0 >= 179.5, "{left:?} {right:?}"); +} + +#[test] +fn vertical_area_text_stays_inside() { + use photocraft_doc::text::Orientation; + let mut e = TextEngine::new(); + let mut t = point(BUBBLE_TEXT, 12.0); + t.orientation = Orientation::Vertical; + t.shape = TextShape::Area { path: area_poly(&[(0.0, 0.0), (120.0, 0.0), (120.0, 200.0), (0.0, 200.0)]) }; + let l = e.layout(&t, 72.0); + assert!(l.lines.len() >= 2, "several columns"); + for g in &l.glyphs { + assert!(g.x > -1.0 && g.x < 121.0 && g.y > -1.0 && g.y < 201.0, "{g:?}"); + } +} + +#[test] +fn area_without_room_lays_out_nothing_and_a_bad_path_lays_out_as_point_text() { + let mut e = TextEngine::new(); + let mut t = point("Hello", 40.0); + // 10 px tall: no 40 pt line fits. + t.shape = TextShape::Area { path: area_poly(&[(0.0, 0.0), (300.0, 0.0), (300.0, 10.0), (0.0, 10.0)]) }; + assert!(e.layout(&t, 72.0).lines.is_empty()); + // An open path encloses nothing (only reachable from a hostile file): point text, no panic. + t.shape = TextShape::Area { path: photocraft_doc::vector::Path::new(vec![photocraft_doc::vector::Subpath::polyline(&[(0.0, 0.0), (9.0, 9.0)])]) }; + let point_layout = e.layout(&point("Hello", 40.0), 72.0); + assert_eq!(e.layout(&t, 72.0).lines.len(), point_layout.lines.len()); +} diff --git a/crates/ui-egui/src/type_transform.rs b/crates/ui-egui/src/type_transform.rs index 0c1b4837ed..890e4b9687 100644 --- a/crates/ui-egui/src/type_transform.rs +++ b/crates/ui-egui/src/type_transform.rs @@ -92,8 +92,13 @@ pub(crate) fn frame(app: &mut PhotocraftApp) -> Option { if !aff.m.iter().all(|v| v.is_finite()) || aff.inverse().is_none() { return None; } - let rect = match shape { - TextShape::Box { x, y, width, height } => [x, y, x + width, y + height].map(f64::from), + let area = match &shape { + TextShape::Area { path } => path.control_bounds(), + _ => None, + }; + let rect = match (shape, area) { + (TextShape::Box { x, y, width, height }, _) => [x, y, x + width, y + height].map(f64::from), + (_, Some((x0, y0, x1, y1))) => [x0, y0, x1, y1], _ => { let mut r = layout.bounds().unwrap_or([0.0, -size * layout.px_per_pt, 1.0, 0.0]).map(f64::from); // Empty lines still have a caret and can be moved/scaled, without inventing glyphs. From 14b90ddd8832fbc08c1912e1ebbc13ae2c089715 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 01:21:10 -0700 Subject: [PATCH 080/649] style(text): format area.rs Co-Authored-By: Claude Opus 5.5 --- crates/text/src/area.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/text/src/area.rs b/crates/text/src/area.rs index 0106e3878d..aab563e623 100644 --- a/crates/text/src/area.rs +++ b/crates/text/src/area.rs @@ -375,11 +375,9 @@ mod tests { fn curves_are_flattened() { // A circle of radius 50 centred on (50, 50) from four kappa curves. let k = 0.552_284_75 * 50.0; - let c = |x: f64, y: f64, ix: f64, iy: f64, ox: f64, oy: f64| Knot::smooth( - photocraft_geom::Point::new(x, y), - photocraft_geom::Point::new(ix, iy), - photocraft_geom::Point::new(ox, oy), - ); + let c = |x: f64, y: f64, ix: f64, iy: f64, ox: f64, oy: f64| { + Knot::smooth(photocraft_geom::Point::new(x, y), photocraft_geom::Point::new(ix, iy), photocraft_geom::Point::new(ox, oy)) + }; let circle = Subpath { closed: true, knots: vec![ From 0c6734a465db79726d53a9cd42ac0b6e5cd62da4 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 01:21:10 -0700 Subject: [PATCH 081/649] fix(text): skip a narrow area span only when a later span holds the word The skip test compared a too-wide line with the shape's bounding-box width. In a shape made of separate parts (two side-by-side bubbles, a U, rows split by holes) a word narrower than the box but wider than every real span was skipped span after span until it fell off the bottom, and it and everything after it was hidden. A line now moves only to the first later span (from the shape's real rows) that holds it; otherwise it overflows its span, as box text does. Rows don't depend on the text, so they are found once per plan and shared by every pass, and a skip jumps straight to the span that fits. Rows are planned with the paragraph's real metrics, measured on the unwrapped paragraph (the max over its wrapped lines), so the second "re-plan" pass is gone; output matches the old re-plan, minus its 0.8 em floor. A per-paragraph budget (32 passes, shared by the tab loop) bounds the worst case. Co-Authored-By: Claude Opus 5.5 --- crates/text/src/layout.rs | 222 ++++++++++++++++++++++++-------------- crates/text/src/tests.rs | 33 ++++++ 2 files changed, 176 insertions(+), 79 deletions(-) diff --git a/crates/text/src/layout.rs b/crates/text/src/layout.rs index 0a09cbc08d..58db511fb0 100644 --- a/crates/text/src/layout.rs +++ b/crates/text/src/layout.rs @@ -649,20 +649,16 @@ impl Layouter { // Box extent along the lines: width, or height for vertical type (columns). let (line_origin, line_len) = if vertical { (box_rect.1, box_rect.3) } else { (box_rect.0, box_rect.2) }; let avail = if is_box { Some((line_len - indent_start - indent_end).max(1.0)) } else { None }; - // Area type: plan rows with the first style's metrics, and the first row no higher - // than one leading (plus paragraph spacing) below the previous paragraph's last line. - let area_style = out.styles[style_at(prange.start)].clone(); - let guess = AreaMetrics { - ascent: if vertical { first_px * 0.5 } else { first_px * 0.8 }, - descent: if vertical { first_px * 0.5 } else { first_px * 0.2 }, - leading: area_style.leading_pt.map_or(ps.auto_leading * first_px, |l| l * k), - }; + // Area type: the first row goes no higher than one leading (plus paragraph spacing) + // below the previous paragraph's last line. let space_before = if prev_baseline.is_some() { ps.space_before_pt * k } else { 0.0 }; let area_from = |m: AreaMetrics| match (&area, prev_baseline) { (Some(_), Some(b)) => b + m.leading + pending_space + space_before, (Some(a), None) => a.bounds[1] + m.ascent, (None, _) => 0.0, }; + // Line-breaking passes left for this paragraph's area type (see `break_area`). + let area_budget = std::cell::Cell::new(MAX_AREA_PASSES); let break_lines = |layout: &mut Layout| -> (Vec, bool) { if first_indent != 0.0 { layout.set_text_indent(first_indent, IndentOptions::default()); @@ -671,18 +667,12 @@ impl Layouter { layout.break_all_lines(avail); return (Vec::new(), false); }; - let mut r = break_area(layout, a, area_from(guess), guess, (indent_start, indent_end), first_px); - // Re-plan once with the real metrics if a line is taller than the guess. - let real = area_metrics(layout, &out.styles, &ps, k, &area_style, vertical); - if real.ascent > guess.ascent + 0.5 || real.descent > guess.descent + 0.5 || real.leading > guess.leading + 0.5 { - let m = AreaMetrics { - ascent: real.ascent.max(guess.ascent), - descent: real.descent.max(guess.descent), - leading: real.leading.max(guess.leading), - }; - r = break_area(layout, a, area_from(m), m, (indent_start, indent_end), first_px); - } - r + // Plan every row with the paragraph's real line metrics (its tallest font and + // largest leading, measured on the unwrapped paragraph), so no wrapped line comes + // out taller than the row it was planned in and no second plan is needed. + layout.break_all_lines(None); + let m = area_metrics(layout, &out.styles, &ps, k, first_style, vertical); + break_area(layout, a, area_from(m), m, (indent_start, indent_end), first_px, &area_budget) }; // Paragraph text: a tab is never wider than a space plus one tab interval, so breaking // lines at that width keeps the expanded tabs inside the box, but can wrap early. @@ -1104,12 +1094,14 @@ fn next_tab_stop(pos: f32, interval: f32) -> f32 { } /// Where one line of area type goes: its baseline, the left edge of its span, and the width -/// it may fill (the span less the paragraph's indents). +/// it may fill (the span less the paragraph's indents), plus the row and span it came from. #[derive(Clone, Copy, Debug, PartialEq)] struct Slot { baseline: f32, x: f32, width: f32, + row: usize, + span: usize, } /// Line metrics an area paragraph is planned with. @@ -1120,17 +1112,79 @@ struct AreaMetrics { leading: f32, } -/// Most spans one area paragraph skips because the word that would start there doesn't fit (each -/// skip breaks the paragraph again). -const MAX_AREA_SKIPS: usize = 64; +/// Most line-breaking passes area type makes for one paragraph, over all its plans (each span +/// left empty for a word that doesn't fit costs a pass). Past it, words overflow their spans. +const MAX_AREA_PASSES: usize = 32; +/// Most rows one area paragraph is planned on. +const MAX_AREA_ROWS: usize = 4096; + +#[cfg(test)] +thread_local! { + /// Area line-breaking passes made on this thread, for tests. + pub(crate) static AREA_PASSES: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// The rows an area paragraph's lines go on: baselines from `next` down, one leading apart, +/// each with its spans left to right. They don't depend on the text, so they are found once +/// (lazily) and shared by every pass. +struct AreaRows<'a> { + area: &'a crate::area::AreaShape, + m: AreaMetrics, + min_width: f32, + /// Where the search for the next row starts. + next: f32, + rows: Vec<(f32, Vec<(f32, f32)>)>, + done: bool, +} + +impl AreaRows<'_> { + /// Row `i`: its baseline and spans; `None` past the shape. + fn get(&mut self, i: usize) -> Option<&(f32, Vec<(f32, f32)>)> { + while self.rows.len() <= i && !self.done { + match self.area.next_row(self.next, self.m.ascent, self.m.descent, self.min_width) { + Some((b, spans)) if self.rows.len() < MAX_AREA_ROWS => { + self.next = b + self.m.leading; + self.rows.push((b, spans)); + } + _ => self.done = true, + } + } + self.rows.get(i) + } + + /// The first span, from span `span` of row `row` on, that leaves at least `width` once + /// `inset` (the paragraph's indents) is taken off: its row and span. + fn first_fit(&mut self, row: usize, span: usize, width: f32, inset: f32) -> Option<(usize, usize)> { + let (mut r, mut first) = (row, span); + while let Some((_, spans)) = self.get(r) { + if let Some(j) = spans.iter().skip(first).position(|&(x0, x1)| x1 - x0 - inset + 0.5 >= width) { + return Some((r, first + j)); + } + r += 1; + first = 0; + } + None + } +} + +/// A line wider than the span it fell in, that a later span can hold: the line's index in the +/// paragraph, where its text starts, and its width. +#[derive(Clone, Copy, Debug)] +struct Need { + line: usize, + start: usize, + width: f32, +} /// Breaks one paragraph of area type a line at a time, each line as wide as the next span the /// shape leaves (rows from `from` down, spans left to right). Returns each line's slot and /// whether text was left over because the shape ran out (hidden, like box overflow). /// /// A span too narrow for the word that would start it (the narrow top of an ellipse) is left -/// empty and the word goes to the next span, as long as the word fits across the shape's full -/// width somewhere; a word wider than the whole shape overflows its span, as in a text box. +/// empty and the word goes to the first later span that holds it, as Photoshop does. A word no +/// later span holds overflows its span, as in a text box. Parley doesn't report a line's +/// trailing whitespace while breaking, so overflowing lines are found after a pass and the +/// paragraph broken again; `budget` (shared by the paragraph's calls) bounds the passes. fn break_area( layout: &mut Layout, area: &crate::area::AreaShape, @@ -1138,81 +1192,91 @@ fn break_area( m: AreaMetrics, indents: (f32, f32), min_width: f32, + budget: &std::cell::Cell, ) -> (Vec, bool) { - let widest = area.bounds[2] - area.bounds[0] - indents.0 - indents.1; - // Spans left empty, by baseline and left edge (exact: every pass computes them the same way). - let mut skip: Vec<(f32, f32)> = Vec::new(); + let inset = indents.0 + indents.1; + let mut rows = AreaRows { area, m, min_width, next: from, rows: Vec::new(), done: false }; + let mut needs: Vec = Vec::new(); loop { - let (slots, overflow) = break_area_pass(layout, area, from, m, indents, min_width, &skip); - // Skipping only makes progress when rows move down. - if m.leading < 1.0 || skip.len() >= MAX_AREA_SKIPS { + let (slots, overflow) = break_area_pass(layout, &mut rows, inset, &needs); + budget.set(budget.get().saturating_sub(1)); + if budget.get() == 0 { return (slots, overflow); } - let narrow = layout.lines().zip(&slots).find_map(|(line, s)| { - let lm = line.metrics(); - let content = lm.advance - lm.trailing_whitespace; - (content > s.width + 0.5 && content <= widest).then_some((s.baseline, s.x)) - }); - match narrow { - Some(span) => skip.push(span), + // Each line's text start and width without its trailing whitespace. + let lines: Vec<(usize, f32)> = layout + .lines() + .map(|l| { + let lm = l.metrics(); + (l.text_range().start, lm.advance - lm.trailing_whitespace) + }) + .collect(); + // A line that now starts elsewhere (an earlier line changed) no longer needs its span. + let kept = needs.len(); + needs.retain(|n| lines.get(n.line).is_some_and(|l| l.0 == n.start)); + if needs.len() != kept { + continue; + } + let mut new = None; + for (li, (&(start, width), s)) in lines.iter().zip(&slots).enumerate() { + if width > s.width + 0.5 && !needs.iter().any(|n| n.line == li) && rows.first_fit(s.row, s.span + 1, width, inset).is_some() { + new = Some(Need { line: li, start, width }); + break; + } + } + match new { + Some(n) => needs.push(n), None => return (slots, overflow), } } } -/// One pass of [`break_area`], leaving the spans in `skip` empty. -fn break_area_pass( - layout: &mut Layout, - area: &crate::area::AreaShape, - from: f32, - m: AreaMetrics, - indents: (f32, f32), - min_width: f32, - skip: &[(f32, f32)], -) -> (Vec, bool) { - let mut slots = Vec::new(); +/// One pass of [`break_area`]: each line in the next span, skipping spans too narrow for a +/// line in `needs` when a later span holds it. +fn break_area_pass(layout: &mut Layout, rows: &mut AreaRows<'_>, inset: f32, needs: &[Need]) -> (Vec, bool) { + #[cfg(test)] + AREA_PASSES.with(|c| c.set(c.get() + 1)); + let mut slots: Vec = Vec::new(); let mut br = layout.break_lines(); // Per-line widths below are never wider than this, as parley requires. br.state_mut().set_layout_max_advance(f32::INFINITY); - let mut baseline = from; - // The current row's spans, rightmost first so `pop` takes them left to right. - let mut row: Vec<(f32, f32)> = Vec::new(); + let (mut row, mut span) = (0, 0); let mut overflow = false; while !br.is_done() { - if row.is_empty() { - match area.next_row(baseline, m.ascent, m.descent, min_width) { - Some((b, mut spans)) => { - baseline = b; - spans.reverse(); - row = spans; - } - None => { - overflow = true; - break; - } - } + let Some((baseline, spans)) = rows.get(row) else { + overflow = true; + break; + }; + let baseline = *baseline; + let Some(&(x0, x1)) = spans.get(span) else { + row += 1; + span = 0; + continue; + }; + let width = (x1 - x0 - inset).max(1.0); + // A line known to be too wide here moves on to the first span that holds it. + if let Some(w) = needs.iter().find(|n| n.line == slots.len()).map(|n| n.width) + && w > width + 0.5 + && let Some((r, j)) = rows.first_fit(row, span + 1, w, inset) + { + (row, span) = (r, j); + continue; } - let Some((x0, x1)) = row.pop() else { break }; - if !skip.contains(&(baseline, x0)) { - let width = (x1 - x0 - indents.0 - indents.1).max(1.0); - br.state_mut().set_line_max_advance(width); - if br.break_next().is_none() { - break; - } - // Parley aligns each line within the width it was broken at. - br.set_prior_line_width(width); - slots.push(Slot { baseline, x: x0, width }); - } - if row.is_empty() { - baseline += m.leading; + br.state_mut().set_line_max_advance(width); + if br.break_next().is_none() { + break; } + // Parley aligns each line within the width it was broken at. + br.set_prior_line_width(width); + slots.push(Slot { baseline, x: x0, width, row, span }); + span += 1; } br.finish(); (slots, overflow) } /// Largest ascent, descent and leading over the lines of a broken paragraph, computed the same -/// way the line loop below does, so an area paragraph can be re-planned with its real metrics. +/// way the line loop does, so an area paragraph's rows can be planned with its real metrics. fn area_metrics(layout: &Layout, styles: &[CharStyle], ps: &ParagraphStyle, k: f32, fallback: &CharStyle, vertical: bool) -> AreaMetrics { let first_px = fallback.size_pt * k; let mut out = AreaMetrics { ascent: 0.0, descent: 0.0, leading: 0.0 }; diff --git a/crates/text/src/tests.rs b/crates/text/src/tests.rs index 03f37f7f0a..79ccfbac64 100644 --- a/crates/text/src/tests.rs +++ b/crates/text/src/tests.rs @@ -2131,3 +2131,36 @@ fn area_without_room_lays_out_nothing_and_a_bad_path_lays_out_as_point_text() { let point_layout = e.layout(&point("Hello", 40.0), 72.0); assert_eq!(e.layout(&t, 72.0).lines.len(), point_layout.lines.len()); } + +#[test] +fn area_word_wider_than_every_span_overflows_instead_of_hiding_the_text() { + use photocraft_doc::vector::Subpath; + let mut e = TextEngine::new(); + // Two 40 px columns 120 px apart: their bounding box is 200 px wide, but no span is wider + // than 40 px, so no row can ever hold the long word. + let mut t = point("Wonderfulness is a long word", 12.0); + let path = photocraft_doc::vector::Path::new(vec![ + Subpath::polygon(&[(0.0, 0.0), (40.0, 0.0), (40.0, 200.0), (0.0, 200.0)]), + Subpath::polygon(&[(160.0, 0.0), (200.0, 0.0), (200.0, 200.0), (160.0, 200.0)]), + ]); + t.shape = TextShape::Area { path }; + let l = e.layout(&t, 72.0); + let first = l.lines.first().expect("the text is shown"); + // The word overflows its 40 px span, as in a text box, on the first row. + assert!(first.x1 - first.x0 > 40.0 && first.x1 - first.x0 < 200.0, "{first:?}"); + assert!(first.x0 >= -0.5, "{first:?}"); + // Nothing is hidden. + assert_eq!(l.lines.last().map(|line| line.range.end), Some(t.text.len()), "{:?}", l.lines); +} + +#[test] +fn single_size_area_paragraph_breaks_in_one_pass() { + let mut e = TextEngine::new(); + let mut t = point(BUBBLE_TEXT, 12.0); + t.shape = TextShape::Area { path: area_poly(&[(0.0, 0.0), (300.0, 0.0), (300.0, 300.0), (0.0, 300.0)]) }; + crate::layout::AREA_PASSES.with(|c| c.set(0)); + let l = e.layout(&t, 72.0); + assert!(l.lines.len() >= 2); + // Rows are planned with the paragraph's real metrics: no re-plan and no skipped spans. + assert_eq!(crate::layout::AREA_PASSES.with(|c| c.get()), 1); +} From 0d38aec094e424b0b3bb348087bab54cceb88757 Mon Sep 17 00:00:00 2001 From: Khawar Zamman Wani Date: Thu, 15 Oct 2026 14:04:39 +0530 Subject: [PATCH 082/649] Color panel: Photoshop's panel-menu modes, the same in every theme (#6000) The theme no longer decides the Color panel's layout: Photoshop's themes used to get the stretched spectrum field, the others a short field with HSB sliders. The panel menu now picks it, as in Photoshop: Hue Cube (default), Brightness Cube, Color Wheel, and Grayscale, RGB, HSB, CMYK, Lab and Web Color sliders over a colour ramp, plus Copy Color as HTML / Hex Code, the ramp choices (RGB and CMYK Spectrum, Grayscale Ramp, Current Colors) and Make Ramp Web Safe. - Slider rows: label, gradient track with a triangle thumb, field and unit; the out-of-gamut and web-colour alerts sit under the chips. Web sliders snap to web steps and take hex. Typed HSB, CMYK and Lab values are kept while they still give the colour. - Ramp: fills the group, white and black boxes at its end; Shift-click cycles the ramps, Alt-click picks the other colour, right-click opens its menu. - Color Wheel: HSB sliders over a hue ring and a rotating saturation/brightness triangle, with an add-to-swatches button. - The choice is saved in UI state; `ui.set colorPanel` merges and takes `mode`, `ramp` and `webSafeRamp`. - Menu strings in all 20 complete catalogs; UI-217-17 done in the scorecard, ui-parity, gaps and control-protocol docs. Closes #6000. Closes #2569. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HJVuULF2tg9pN2x4VJoED1 --- crates/ui-egui/src/color_panel_tests.rs | 328 +++++++++ crates/ui-egui/src/color_panel_ui.rs | 732 ++++++++++++++++++++ crates/ui-egui/src/color_picker_ui.rs | 4 +- crates/ui-egui/src/color_tab_theme_tests.rs | 59 +- crates/ui-egui/src/control.rs | 4 +- crates/ui-egui/src/dock.rs | 8 +- crates/ui-egui/src/dock_tests.rs | 6 +- crates/ui-egui/src/i18n/cs.tsv | 18 + crates/ui-egui/src/i18n/de.tsv | 18 + crates/ui-egui/src/i18n/el.tsv | 17 + crates/ui-egui/src/i18n/es.tsv | 17 + crates/ui-egui/src/i18n/fr.tsv | 17 + crates/ui-egui/src/i18n/hu.tsv | 17 + crates/ui-egui/src/i18n/id.tsv | 17 + crates/ui-egui/src/i18n/it.tsv | 17 + crates/ui-egui/src/i18n/ja.tsv | 17 + crates/ui-egui/src/i18n/ko.tsv | 18 + crates/ui-egui/src/i18n/nl.tsv | 17 + crates/ui-egui/src/i18n/pl.tsv | 17 + crates/ui-egui/src/i18n/pt-br.tsv | 17 + crates/ui-egui/src/i18n/ru.tsv | 17 + crates/ui-egui/src/i18n/sr.tsv | 17 + crates/ui-egui/src/i18n/tr.tsv | 17 + crates/ui-egui/src/i18n/uk.tsv | 17 + crates/ui-egui/src/i18n/vi.tsv | 18 + crates/ui-egui/src/i18n/zh-hans.tsv | 18 + crates/ui-egui/src/i18n/zh-hant.tsv | 18 + crates/ui-egui/src/lib.rs | 3 + crates/ui-egui/src/panels.rs | 211 +++--- crates/ui-egui/src/state.rs | 94 ++- docs/control-protocol.md | 2 +- docs/gaps.md | 9 +- docs/scorecard.md | 4 +- docs/ui-parity.md | 5 +- scorecard/ui.toml | 4 +- 35 files changed, 1647 insertions(+), 172 deletions(-) create mode 100644 crates/ui-egui/src/color_panel_tests.rs create mode 100644 crates/ui-egui/src/color_panel_ui.rs diff --git a/crates/ui-egui/src/color_panel_tests.rs b/crates/ui-egui/src/color_panel_tests.rs new file mode 100644 index 0000000000..65239d6a19 --- /dev/null +++ b/crates/ui-egui/src/color_panel_tests.rs @@ -0,0 +1,328 @@ +//! The Color panel's modes, ramp and panel menu (#6000, #2569): every mode draws and edits the +//! colour in every theme, and the choice is the panel menu's, never the theme's. + +use egui::{Modifiers, Pos2, Rect, pos2, vec2}; +use egui_kittest::Harness; +use egui_kittest::kittest::Queryable; +use serde_json::json; + +use crate::PhotocraftApp; +use crate::color_panel_ui::{Model, hex_code, html_color, ramp_color}; +use crate::dock::Group; +use crate::state::{ColorPanelMode, ColorRamp}; +use crate::theme::{ThemeKind, Tokens}; + +/// The Color tab of `kind` in `mode`, alone in a 300 x 400 pt panel that offers it 360 pt. +fn color_tab(kind: ThemeKind, mode: ColorPanelMode, fg: [f32; 4]) -> Harness<'static, PhotocraftApp> { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.session.tools.foreground = fg; + app.ui.color_panel.mode = mode; + let tab = Group::Color.tabs(Tokens::for_kind(kind).pro).iter().position(|name| *name == "Color").unwrap(); + let mut h = Harness::builder().with_size(vec2(300.0, 400.0)).with_step_dt(1.0 / 60.0).build_ui_state( + move |ui, app: &mut PhotocraftApp| { + if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { + ui.data_mut(|d| d.insert_temp(crate::panels::color_field_fill_id(), 360.0_f32)); + crate::panels::dock_body(app, ui, Group::Color, tab); + } + }, + app, + ); + PhotocraftApp::setup_context(&h.ctx, kind); + h.run_steps(3); + h +} + +/// Click at `p` with `modifiers` held. +fn press(h: &mut Harness<'_, PhotocraftApp>, p: Pos2, modifiers: Modifiers) { + h.hover_at(p); + h.event(egui::Event::ModifiersChanged(modifiers)); + h.run_steps(1); + for pressed in [true, false] { + h.event(egui::Event::PointerButton { pos: p, button: egui::PointerButton::Primary, pressed, modifiers }); + h.run_steps(1); + } + h.event(egui::Event::ModifiersChanged(Modifiers::NONE)); + h.run_steps(2); +} + +fn bytes(c: [f32; 4]) -> [u8; 3] { + [c[0], c[1], c[2]].map(|v| (v.clamp(0.0, 1.0) * 255.0).round() as u8) +} + +fn type_into(h: &mut Harness<'_, PhotocraftApp>, role: egui::accesskit::Role, nth: usize, text: &str) { + h.query_all_by_role(role).nth(nth).unwrap().click(); + h.run_steps(1); + h.key_press_modifiers(Modifiers::COMMAND, egui::Key::A); + h.run_steps(1); + for ch in text.chars() { + h.event(egui::Event::Text(ch.to_string())); + h.run_steps(1); + } + h.key_press(egui::Key::Tab); + h.run_steps(2); +} + +#[test] +fn every_model_round_trips_its_colours() { + let colours = [[0.2, 0.6, 0.8], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [1.0, 1.0, 1.0], [0.5, 0.25, 0.75]]; + for model in [Model::Rgb, Model::Hsb, Model::Web, Model::Lab, Model::Cmyk] { + for c in colours { + // Pure red, for one, can't print: CMYK gives the nearest printable colour back. + if model == Model::Cmyk && crate::color_picker_ui::out_of_gamut(c).is_some() { + continue; + } + let back = model.to_rgb(model.values_of(c)); + let worst = (0..3).map(|i| (back[i] - c[i]).abs()).fold(0.0, f32::max); + // Whole-number fields: RGB is exact, HSB within a step, CMYK and Lab within a few. + let tolerance = match model { + Model::Rgb | Model::Web => 0.6 / 255.0, + Model::Hsb => 2.5 / 255.0, + _ => 0.03, + }; + assert!(worst <= tolerance, "{model:?} {c:?} -> {back:?}"); + } + } + for g in [0.0, 0.25, 0.5, 1.0] { + let back = Model::Gray.to_rgb(Model::Gray.values_of([g; 3])); + assert!((back[0] - g).abs() < 0.01, "gray {g} -> {back:?}"); + } + // Hostile values give a valid colour. + for model in [Model::Gray, Model::Rgb, Model::Hsb, Model::Cmyk, Model::Lab, Model::Web] { + for v in [[f32::NAN; 4], [f32::INFINITY; 4], [-1e9; 4], [1e9; 4]] { + assert!(model.to_rgb(v).iter().all(|x| (0.0..=1.0).contains(x)), "{model:?} {v:?}"); + } + assert_eq!( + model.channels().len(), + match model { + Model::Gray => 1, + Model::Cmyk => 4, + _ => 3, + } + ); + } +} + +#[test] +fn ramps_match_photoshop() { + let (fg, bg) = ([0.2, 0.4, 0.6], [1.0, 1.0, 0.0]); + let near = |a: [f32; 3], b: [f32; 3]| (0..3).all(|i| (a[i] - b[i]).abs() < 0.02); + // RGB Spectrum: hue across, white at the top, the full colour in the middle, black at the bottom. + assert!(near(ramp_color(ColorRamp::RgbSpectrum, false, fg, bg, 0.0, 0.0), [1.0; 3])); + assert!(near(ramp_color(ColorRamp::RgbSpectrum, false, fg, bg, 0.0, 0.5), [1.0, 0.0, 0.0])); + assert!(near(ramp_color(ColorRamp::RgbSpectrum, false, fg, bg, 1.0 / 3.0, 0.5), [0.0, 1.0, 0.0])); + assert!(near(ramp_color(ColorRamp::RgbSpectrum, false, fg, bg, 0.5, 1.0), [0.0; 3])); + assert!(near(ramp_color(ColorRamp::GrayscaleRamp, false, fg, bg, 0.0, 0.3), [1.0; 3])); + assert!(near(ramp_color(ColorRamp::GrayscaleRamp, false, fg, bg, 1.0, 0.3), [0.0; 3])); + assert!(near(ramp_color(ColorRamp::CurrentColors, false, fg, bg, 0.0, 0.9), fg)); + assert!(near(ramp_color(ColorRamp::CurrentColors, false, fg, bg, 1.0, 0.1), bg)); + // CMYK Spectrum stays printable. + let c = ramp_color(ColorRamp::CmykSpectrum, false, fg, bg, 0.6, 0.5); + assert!(crate::color_picker_ui::out_of_gamut(c).is_none(), "{c:?}"); + // Make Ramp Web Safe: every colour is a web colour. + for ramp in ColorRamp::ALL { + for (x, y) in [(0.13, 0.37), (0.71, 0.66), (0.5, 0.5)] { + let c = ramp_color(ramp, true, fg, bg, x, y); + assert!(crate::color_picker_ui::not_web_safe(c).is_none(), "{ramp:?} {c:?}"); + } + let c = ramp_color(ramp, false, fg, bg, f32::NAN, f32::INFINITY); + assert!(c.iter().all(|v| (0.0..=1.0).contains(v)), "{ramp:?} {c:?}"); + } + // Shift-click cycles the ramps in menu order and wraps. + let mut r = ColorRamp::RgbSpectrum; + let mut seen = vec![r]; + for _ in 0..3 { + r = r.next(); + seen.push(r); + } + assert_eq!(seen, ColorRamp::ALL); + assert_eq!(r.next(), ColorRamp::RgbSpectrum); +} + +#[test] +fn copy_color_formats() { + assert_eq!(html_color([0.2, 0.6, 0.8]), "color=\"#3399cc\""); + assert_eq!(hex_code([0.2, 0.6, 0.8]), "3399cc"); +} + +/// Every mode draws in every theme, and a click in it sets the colour. +#[test] +fn every_mode_works_in_every_theme() { + for kind in ThemeKind::ALL { + for mode in ColorPanelMode::ALL { + let mut h = color_tab(kind, mode, [1.0, 0.0, 0.0, 1.0]); + match mode { + ColorPanelMode::HueCube | ColorPanelMode::BrightnessCube => { + assert!(h.query_by_label("#").is_some(), "{kind:?} {mode:?}: the readout"); + } + ColorPanelMode::ColorWheel => { + for label in ["H", "S", "B", "Add to Swatches"] { + assert!(h.query_by_label(label).is_some(), "{kind:?} {mode:?}: {label}"); + } + } + _ => { + for (label, ..) in Model::of(mode).channels() { + assert!(h.query_by_label(label).is_some(), "{kind:?} {mode:?}: the {label} slider"); + } + // The black box at the end of the ramp sets black. + let black = h.get_by_label("Black").rect().center(); + press(&mut h, black, Modifiers::NONE); + assert_eq!(bytes(h.state().session.tools.foreground), [0, 0, 0], "{kind:?} {mode:?}"); + } + } + assert!(h.query_by_label("Hue").is_none() && h.query_by_label("Saturation").is_none(), "{kind:?} {mode:?}: no old sliders"); + } + } +} + +#[test] +fn rgb_slider_track_sets_its_channel() { + let mut h = color_tab(ThemeKind::AdwaitaDark, ColorPanelMode::RgbSliders, [0.0, 0.0, 0.0, 1.0]); + let g = h.get_by_label("G").rect(); + press(&mut h, pos2(g.right() - 2.0, g.center().y), Modifiers::NONE); + assert_eq!(bytes(h.state().session.tools.foreground), [0, 255, 0]); + // The field takes a typed value too (the spin buttons are R, G, B). + type_into(&mut h, egui::accesskit::Role::SpinButton, 2, "128"); + assert_eq!(bytes(h.state().session.tools.foreground), [0, 255, 128]); +} + +/// Black has no hue or saturation of its own: typed H and S must stick while B is still 0. +#[test] +fn hsb_sliders_take_values_on_black() { + let mut h = color_tab(ThemeKind::Studio, ColorPanelMode::HsbSliders, [0.0, 0.0, 0.0, 1.0]); + for (field, typed) in [(0, "120"), (1, "100"), (2, "100")] { + type_into(&mut h, egui::accesskit::Role::SpinButton, field, typed); + } + assert_eq!(bytes(h.state().session.tools.foreground), [0, 255, 0]); +} + +#[test] +fn cmyk_sliders_keep_typed_values() { + let mut h = color_tab(ThemeKind::Pro, ColorPanelMode::CmykSliders, [1.0, 1.0, 1.0, 1.0]); + type_into(&mut h, egui::accesskit::Role::SpinButton, 0, "40"); + type_into(&mut h, egui::accesskit::Role::SpinButton, 3, "20"); + let shown: Vec = h.query_all_by_role(egui::accesskit::Role::SpinButton).filter_map(|n| n.value()).collect(); + assert_eq!(shown.first().map(String::as_str), Some("40"), "C stays as typed: {shown:?}"); + assert_eq!(shown.get(3).map(String::as_str), Some("20"), "K stays as typed: {shown:?}"); +} + +#[test] +fn web_sliders_snap_and_take_hex() { + let mut h = color_tab(ThemeKind::Classic, ColorPanelMode::WebColorSliders, [0.0, 0.0, 0.0, 1.0]); + let r = h.get_by_label("R").rect(); + // 45% along the track snaps to 0x66 (102), the nearest web step. + let x = r.left() + 4.0 + (r.width() - 8.0) * 0.45; + press(&mut h, pos2(x, r.center().y), Modifiers::NONE); + assert_eq!(bytes(h.state().session.tools.foreground), [0x66, 0, 0]); + // Not a web colour: the cube alert snaps it. + type_into(&mut h, egui::accesskit::Role::TextInput, 1, "C8"); + assert_eq!(bytes(h.state().session.tools.foreground), [0x66, 0xC8, 0]); + let alert = h.get_by_label("Not a web colour: click for the nearest web colour").rect().center(); + press(&mut h, alert, Modifiers::NONE); + assert_eq!(bytes(h.state().session.tools.foreground), [0x66, 0xCC, 0]); +} + +#[test] +fn ramp_picks_and_shift_click_cycles_and_alt_picks_the_other_colour() { + let mut h = color_tab(ThemeKind::BreezeDark, ColorPanelMode::RgbSliders, [0.0, 0.0, 0.0, 1.0]); + let ramp: Rect = h.get_by_label("Color Ramp").rect(); + // The RGB Spectrum's top is white. + press(&mut h, pos2(ramp.left() + 3.0, ramp.top() + 1.0), Modifiers::NONE); + assert!(bytes(h.state().session.tools.foreground).iter().all(|v| *v > 240), "{:?}", h.state().session.tools.foreground); + // Alt picks the background (the panel edits the foreground). + press(&mut h, pos2(ramp.left() + 3.0, ramp.bottom() - 1.0), Modifiers::ALT); + assert!(bytes(h.state().session.tools.background).iter().all(|v| *v < 16), "{:?}", h.state().session.tools.background); + assert!(bytes(h.state().session.tools.foreground).iter().all(|v| *v > 240), "Alt leaves the foreground"); + // Shift-click cycles the ramp and picks nothing. + let fg = h.state().session.tools.foreground; + for expected in [ColorRamp::CmykSpectrum, ColorRamp::GrayscaleRamp, ColorRamp::CurrentColors, ColorRamp::RgbSpectrum] { + press(&mut h, ramp.center(), Modifiers::SHIFT); + assert_eq!(h.state().ui.color_panel.ramp, expected); + } + assert_eq!(h.state().session.tools.foreground, fg); + // Grayscale Ramp: its left end is white. + h.state_mut().ui.color_panel.ramp = ColorRamp::GrayscaleRamp; + h.state_mut().session.tools.foreground = [0.0, 0.0, 0.0, 1.0]; + h.run_steps(2); + press(&mut h, pos2(ramp.left() + 1.0, ramp.center().y), Modifiers::NONE); + assert!(bytes(h.state().session.tools.foreground).iter().all(|v| *v > 245)); +} + +#[test] +fn color_wheel_ring_sets_hue_and_triangle_sets_saturation_and_brightness() { + let mut h = color_tab(ThemeKind::Pro, ColorPanelMode::ColorWheel, [0.0, 0.0, 1.0, 1.0]); + let area = h.get_by_label("Color Wheel").rect(); + let (center, inner, outer) = crate::color_panel_ui::wheel_geometry(area); + let mid = (inner + outer) / 2.0; + // Up on the ring: hue 90° (yellow-green). Blue is fully saturated and bright, so it keeps both. + press(&mut h, pos2(center.x, center.y - mid), Modifiers::NONE); + let [r, g, bl] = bytes(h.state().session.tools.foreground); + assert!(r > 100 && g > 240 && bl < 10, "hue 90: {r} {g} {bl}"); + // The triangle's centre: some saturation, some brightness, same hue. + press(&mut h, center, Modifiers::NONE); + let after = bytes(h.state().session.tools.foreground); + let hsv = crate::color_picker_ui::rgb_to_hsv(after.map(|v| f32::from(v) / 255.0)); + assert!((hsv[0] - 90.0).abs() < 4.0 && hsv[1] < 0.9 && hsv[2] < 0.95, "{after:?} {hsv:?}"); +} + +/// Picking a mode from the panel menu changes the panel; the theme never does. +#[test] +fn panel_menu_picks_the_mode_and_ramp() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.session.tools.foreground = [0.2, 0.6, 0.8, 1.0]; + let mut h = Harness::builder().with_size(vec2(260.0, 700.0)).build_ui_state( + |ui, app: &mut PhotocraftApp| { + if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { + crate::color_panel_ui::panel_menu(app, ui); + } + }, + app, + ); + PhotocraftApp::setup_context(&h.ctx, ThemeKind::AdwaitaDark); + h.run_steps(2); + assert!(h.query_by_label("✔ Hue Cube").is_some(), "Hue Cube is the default"); + for mode in ColorPanelMode::ALL.into_iter().skip(1).chain([ColorPanelMode::HueCube, ColorPanelMode::WebColorSliders]) { + h.get_by_label(&format!(" {}", mode.label())).click(); + h.run_steps(2); + assert_eq!(h.state().ui.color_panel.mode, mode); + assert!(h.query_by_label(&format!("✔ {}", mode.label())).is_some()); + } + h.get_by_label(" Current Colors").click(); + h.run_steps(2); + assert_eq!(h.state().ui.color_panel.ramp, ColorRamp::CurrentColors); + h.get_by_label(" Make Ramp Web Safe").click(); + h.run_steps(2); + assert!(h.state().ui.color_panel.web_safe_ramp); + h.get_by_label("Copy Color's Hex Code").click(); + h.run_steps(1); + let copied: Vec<_> = + h.output().platform_output.commands.iter().filter_map(|c| if let egui::OutputCommand::CopyText(s) = c { Some(s.clone()) } else { None }).collect(); + assert_eq!(copied, ["3399cc"]); + // Switching theme keeps the mode. + let ctx = h.ctx.clone(); + h.state_mut().set_theme(&ctx, ThemeKind::Pro); + h.run_steps(2); + assert_eq!(h.state().ui.color_panel.mode, ColorPanelMode::WebColorSliders); +} + +/// `ui.set colorPanel` merges, so setting the mode keeps the edited chip; bad values change nothing. +#[test] +fn control_sets_the_mode_ramp_and_web_safe_ramp() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + let ctx = egui::Context::default(); + let call = |app: &mut PhotocraftApp, params: serde_json::Value| { + let (req, _rx) = crate::control::ControlRequest::new("ui.set", params); + match crate::control::handle(app, &ctx, &req) { + crate::control::Outcome::Done(v) => v["ok"] == true, + _ => panic!("expected an immediate reply"), + } + }; + assert!(call(&mut app, json!({"colorPanel": {"background": true}}))); + assert!(call(&mut app, json!({"colorPanel": {"mode": "labSliders", "ramp": "grayscaleRamp", "webSafeRamp": true}}))); + let cp = app.ui.color_panel; + assert!(cp.background, "the chip is kept"); + assert_eq!((cp.mode, cp.ramp, cp.web_safe_ramp), (ColorPanelMode::LabSliders, ColorRamp::GrayscaleRamp, true)); + for bad in [json!({"colorPanel": {"mode": "hueWheel"}}), json!({"colorPanel": {"ramp": 3}}), json!({"colorPanel": {"webSafeRamp": "yes"}})] { + assert!(!call(&mut app, bad.clone()), "{bad}"); + assert_eq!(app.ui.color_panel, cp, "{bad}: nothing changes"); + } +} diff --git a/crates/ui-egui/src/color_panel_ui.rs b/crates/ui-egui/src/color_panel_ui.rs new file mode 100644 index 0000000000..8f1acf67f4 --- /dev/null +++ b/crates/ui-egui/src/color_panel_ui.rs @@ -0,0 +1,732 @@ +//! Photoshop's Color panel modes, picked from its panel menu and the same in every theme (#6000, +//! #2569): Hue Cube and Brightness Cube (drawn by [`crate::panels::color_field`]), Color Wheel (HSB +//! sliders over a hue ring around a saturation/brightness triangle), and the Grayscale, RGB, HSB, +//! CMYK, Lab and Web Color sliders over a colour ramp. The panel menu also has Copy Color as HTML, +//! Copy Color's Hex Code, the ramp choices (RGB Spectrum, CMYK Spectrum, Grayscale Ramp, Current +//! Colors) and Make Ramp Web Safe. Shift-click on the ramp cycles the ramps, Alt-click picks the +//! colour the panel isn't editing, and a right-click opens the ramp menu. + +use std::f32::consts::TAU; +use std::sync::Arc; + +use egui::{Color32, Mesh, Pos2, Rect, Sense, Stroke, StrokeKind, pos2, vec2}; +use serde_json::json; + +use crate::PhotocraftApp; +use crate::color_picker_ui::{hex, hsv_to_rgb, not_web_safe, out_of_gamut, rgb_to_hsv}; +use crate::panels::{color_field_fill_id, field_chips, field_hsva, srgb_hsva}; +use crate::state::{ColorPanelMode, ColorRamp}; +use crate::theme::Tokens; +use crate::widgets; +use photocraft_color::convert; + +/// Width of the chips column, as the cube field's. +const CHIPS_W: f32 = 38.0; +/// Height of one slider row. +const ROW_H: f32 = 22.0; +/// Width of a slider row's value field. +const FIELD_W: f32 = 44.0; +/// Width of the unit after a field ("°", "%"). +const UNIT_W: f32 = 14.0; +/// Width of the white and black boxes at the right end of the ramp. +const BOXES_W: f32 = 16.0; + +/// The Color tab: whatever the panel menu picked. +pub(crate) fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) { + match app.ui.color_panel.mode { + ColorPanelMode::HueCube | ColorPanelMode::BrightnessCube => crate::panels::color_field(app, ui), + ColorPanelMode::ColorWheel => wheel(app, ui), + mode => sliders(app, ui, mode), + } +} + +/// The colour model a slider mode edits. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub(crate) enum Model { + Gray, + Rgb, + Hsb, + Cmyk, + Lab, + Web, +} + +impl Model { + pub(crate) fn of(mode: ColorPanelMode) -> Model { + match mode { + ColorPanelMode::GrayscaleSlider => Model::Gray, + ColorPanelMode::HsbSliders | ColorPanelMode::ColorWheel => Model::Hsb, + ColorPanelMode::CmykSliders => Model::Cmyk, + ColorPanelMode::LabSliders => Model::Lab, + ColorPanelMode::WebColorSliders => Model::Web, + ColorPanelMode::RgbSliders | ColorPanelMode::HueCube | ColorPanelMode::BrightnessCube => Model::Rgb, + } + } + + /// Each slider: label, range and unit, in Photoshop's order. + pub(crate) fn channels(self) -> &'static [(&'static str, f32, f32, &'static str)] { + match self { + Model::Gray => &[("K", 0.0, 100.0, "%")], + Model::Rgb | Model::Web => &[("R", 0.0, 255.0, ""), ("G", 0.0, 255.0, ""), ("B", 0.0, 255.0, "")], + Model::Hsb => &[("H", 0.0, 360.0, "°"), ("S", 0.0, 100.0, "%"), ("B", 0.0, 100.0, "%")], + Model::Cmyk => &[("C", 0.0, 100.0, "%"), ("M", 0.0, 100.0, "%"), ("Y", 0.0, 100.0, "%"), ("K", 0.0, 100.0, "%")], + Model::Lab => &[("L", 0.0, 100.0, ""), ("a", -128.0, 127.0, ""), ("b", -128.0, 127.0, "")], + } + } + + /// The sRGB colour of slider values `v` (in the units the fields show). + pub(crate) fn to_rgb(self, v: [f32; 4]) -> [f32; 3] { + let [a, b, c, d] = v.map(|x| if x.is_finite() { x } else { 0.0 }); + let rgb = match self { + Model::Gray => [1.0 - a / 100.0; 3], + Model::Rgb | Model::Web => [a / 255.0, b / 255.0, c / 255.0], + Model::Hsb => hsv_to_rgb(a, b / 100.0, c / 100.0), + Model::Cmyk => convert::cmyk_to_rgb([a / 100.0, b / 100.0, c / 100.0, d / 100.0]), + Model::Lab => convert::lab_to_srgb([a, b, c]), + }; + rgb.map(|x| if x.is_finite() { x.clamp(0.0, 1.0) } else { 0.0 }) + } + + /// Slider values of `rgb`, rounded to whole numbers as Photoshop's fields show them. + pub(crate) fn values_of(self, rgb: [f32; 3]) -> [f32; 4] { + let v = match self { + Model::Gray => [(1.0 - convert::rgb_to_gray(rgb)) * 100.0, 0.0, 0.0, 0.0], + Model::Rgb | Model::Web => [rgb[0] * 255.0, rgb[1] * 255.0, rgb[2] * 255.0, 0.0], + Model::Hsb => { + let [h, s, b] = rgb_to_hsv(rgb); + [h, s * 100.0, b * 100.0, 0.0] + } + Model::Cmyk => convert::rgb_to_cmyk(rgb).map(|x| x * 100.0), + Model::Lab => { + let [l, a, b] = convert::srgb_to_lab(rgb); + [l, a, b, 0.0] + } + }; + v.map(|x| if x.is_finite() { x.round() } else { 0.0 }) + } +} + +/// The colour the panel edits. +fn active(app: &PhotocraftApp) -> [f32; 3] { + let c = if app.ui.color_panel.background { app.session.tools.background } else { app.session.tools.foreground }; + [c[0], c[1], c[2]].map(|x| x.clamp(0.0, 1.0)) +} + +/// Set the foreground (and recolour selected type) or the background colour. +pub(crate) fn set_color(app: &mut PhotocraftApp, background: bool, rgb: [f32; 3]) { + let c = [rgb[0], rgb[1], rgb[2], 1.0]; + if background { + app.session.tools.background = c; + } else { + app.session.tools.foreground = c; + crate::type_tool::foreground_changed(app); + } +} + +/// The key of the slider values last shown for `model`, kept while they still give the colour: +/// a grey has no hue, and CMYK or Lab values don't survive an sRGB round trip (#3228). +fn values_key(model: Model, background: bool) -> egui::Id { + egui::Id::new(("color-panel-values", model, background)) +} + +/// The key of the Hue Cube's remembered hue and saturation (see [`field_hsva`]). +fn field_key(background: bool) -> egui::Id { + egui::Id::new(("color-field-hue", background)) +} + +/// Slider values for the colour the panel edits: the ones last shown while they still give it. +fn current_values(ui: &egui::Ui, model: Model, background: bool, rgb: [f32; 3]) -> [f32; 4] { + let stored: Option<[f32; 4]> = ui.data(|d| d.get_temp(values_key(model, background))); + if let Some(v) = stored.filter(|v| hex(model.to_rgb(*v)) == hex(rgb)) { + return v; + } + if model == Model::Hsb { + // Share the cube's hue and saturation, so a grey keeps its hue across modes. + let c = [rgb[0], rgb[1], rgb[2], 1.0]; + let hsva = srgb_hsva(c); + let remembered: (f32, f32) = ui.data(|d| d.get_temp(field_key(background))).unwrap_or((hsva.h, hsva.s)); + let h = field_hsva(hsva, remembered); + return [h.h * 360.0, h.s * 100.0, h.v * 100.0, 0.0].map(f32::round); + } + model.values_of(rgb) +} + +/// Apply edited slider values: the colour, and the values (and the cube's hue) remembered. +fn apply_values(app: &mut PhotocraftApp, ui: &egui::Ui, model: Model, v: [f32; 4]) { + let background = app.ui.color_panel.background; + let rgb = model.to_rgb(v); + set_color(app, background, rgb); + ui.data_mut(|d| d.insert_temp(values_key(model, background), v)); + if model == Model::Hsb && v[2] > 0.5 { + ui.data_mut(|d| d.insert_temp(field_key(background), (v[0] / 360.0, v[1] / 100.0))); + } +} + +/// Track colours of slider `i` at `steps` + 1 points, the other sliders at `v`. +fn track_stops(model: Model, v: [f32; 4], i: usize, steps: usize) -> Vec { + let Some(&(_, lo, hi, _)) = model.channels().get(i) else { return Vec::new() }; + (0..=steps) + .map(|k| { + let mut w = v; + if let Some(slot) = w.get_mut(i) { + *slot = lo + (hi - lo) * k as f32 / steps as f32; + } + // HSB's hue track is the full spectrum, whatever the saturation and brightness. + if model == Model::Hsb && i == 0 { + w = [w[0], 100.0, 100.0, 0.0]; + } + rgb32(model.to_rgb(w)) + }) + .collect() +} + +pub(crate) fn rgb32(c: [f32; 3]) -> Color32 { + let q = |v: f32| (v.clamp(0.0, 1.0) * 255.0).round() as u8; + Color32::from_rgb(q(c[0]), q(c[1]), q(c[2])) +} + +/// The slider rows of `model`. Returns the edited values, if any. +fn slider_rows(ui: &mut egui::Ui, model: Model, v: [f32; 4], background: bool, dynamic: bool) -> Option<[f32; 4]> { + let t = Tokens::get(ui.ctx()); + // Dynamic Color Sliders off: the tracks keep the colours they had when a drag began. + let stops_key = egui::Id::new(("color-panel-stops", model, background)); + let dragging = ui.input(|i| i.pointer.any_down()); + let stops_from = if dynamic || !dragging { v } else { ui.data(|d| d.get_temp::<[f32; 4]>(stops_key)).unwrap_or(v) }; + if !dragging { + ui.data_mut(|d| d.insert_temp(stops_key, v)); + } + let mut out = None; + let mut values = v; + for (i, &(label, lo, hi, unit)) in model.channels().iter().enumerate() { + let Some(¤t) = values.get(i) else { continue }; + let mut x = current; + let mut changed = false; + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing.x = 4.0; + ui.set_height(ROW_H); + let (lr, _) = ui.allocate_exact_size(vec2(12.0, ROW_H), Sense::hover()); + ui.painter().text(lr.left_center(), egui::Align2::LEFT_CENTER, label, egui::FontId::proportional(12.0), t.text_dim); + let track_w = (ui.available_width() - FIELD_W - UNIT_W - 8.0).max(24.0); + let (tr, resp) = ui.allocate_exact_size(vec2(track_w, ROW_H), Sense::click_and_drag()); + let stops = track_stops(model, stops_from, i, 24); + changed |= track(ui, tr, &resp, &mut x, lo, hi, &stops, model == Model::Web); + resp.widget_info(|| egui::WidgetInfo::slider(ui.is_enabled(), f64::from(x), label)); + if model == Model::Web { + changed |= hex_pair(ui, ui.id().with(("web-field", i, background)), &mut x); + } else if widgets::value_field(ui, &mut x, lo..=hi, "", FIELD_W).changed() { + changed = true; + } + let (ur, _) = ui.allocate_exact_size(vec2(UNIT_W, ROW_H), Sense::hover()); + ui.painter().text(ur.left_center(), egui::Align2::LEFT_CENTER, unit, egui::FontId::proportional(12.0), t.text_faint); + }); + if changed && let Some(slot) = values.get_mut(i) { + *slot = x.clamp(lo, hi).round(); + out = Some(values); + } + } + out +} + +/// A slider track with Photoshop's triangle thumb under it. Returns true when dragged or clicked +/// to a new value; Web Color tracks snap to the web steps (00, 33, 66, 99, CC, FF). +#[allow(clippy::too_many_arguments)] +fn track(ui: &egui::Ui, r: Rect, resp: &egui::Response, value: &mut f32, lo: f32, hi: f32, stops: &[Color32], web: bool) -> bool { + let t = Tokens::get(ui.ctx()); + let bar = Rect::from_min_max(pos2(r.left() + 4.0, r.center().y - 6.0), pos2(r.right() - 4.0, r.center().y + 1.0)); + let mut mesh = Mesh::default(); + let n = stops.len().saturating_sub(1).max(1); + for (k, c) in stops.iter().enumerate() { + let x = bar.left() + bar.width() * k as f32 / n as f32; + mesh.colored_vertex(pos2(x, bar.top()), *c); + mesh.colored_vertex(pos2(x, bar.bottom()), *c); + } + for k in 0..stops.len().saturating_sub(1) as u32 { + let a = k * 2; + mesh.add_triangle(a, a + 1, a + 3); + mesh.add_triangle(a, a + 3, a + 2); + } + ui.painter().add(mesh); + ui.painter().rect_stroke(bar, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Outside); + if web { + // Ticks at the web steps. + for k in 0..=5 { + let x = bar.left() + bar.width() * k as f32 / 5.0; + ui.painter().line_segment([pos2(x, bar.bottom() + 1.0), pos2(x, bar.bottom() + 3.0)], Stroke::new(1.0, t.text_faint)); + } + } + let mut changed = false; + if (resp.dragged() || resp.clicked()) + && let Some(p) = resp.interact_pointer_pos() + && bar.width() > 0.0 + && hi > lo + { + let f = ((p.x - bar.left()) / bar.width()).clamp(0.0, 1.0); + let mut v = lo + (hi - lo) * f; + if web { + v = (v / 51.0).round() * 51.0; + } + let v = v.round().clamp(lo, hi); + if v != *value { + *value = v; + changed = true; + } + } + let f = if hi > lo { ((*value - lo) / (hi - lo)).clamp(0.0, 1.0) } else { 0.0 }; + let x = bar.left() + bar.width() * f; + let y = bar.bottom() + 1.0; + let thumb = vec![pos2(x, y), pos2(x + 5.0, y + 7.0), pos2(x - 5.0, y + 7.0)]; + ui.painter().add(egui::Shape::convex_polygon(thumb, t.text, Stroke::new(1.0, t.field_border))); + changed +} + +/// A Web Color slider's field: the channel as two hex digits. Valid input sets `value` (0..255) +/// and returns true; while focused it shows what is typed, and an invalid entry snaps back. +fn hex_pair(ui: &mut egui::Ui, id: egui::Id, value: &mut f32) -> bool { + let t = Tokens::get(ui.ctx()); + let (rect, _) = ui.allocate_exact_size(vec2(FIELD_W, ROW_H), Sense::hover()); + widgets::surface(ui, rect, t.field, false); + if !t.bevel { + ui.painter().rect_stroke(rect, t.radius_sm, Stroke::new(1.0, t.field_border), StrokeKind::Inside); + } + let byte = value.clamp(0.0, 255.0).round() as u8; + let typing = if ui.memory(|m| m.has_focus(id)) { ui.data(|d| d.get_temp::(id)) } else { None }; + let mut text = typing.unwrap_or_else(|| format!("{byte:02X}")); + let inner = rect.shrink2(vec2(5.0, 2.0)); + let mut child = ui.new_child(egui::UiBuilder::new().max_rect(inner).layout(egui::Layout::left_to_right(egui::Align::Center))); + let resp = child + .add(egui::TextEdit::singleline(&mut text).id(id).char_limit(2).desired_width(inner.width()).frame(egui::Frame::NONE).font(crate::theme::mono(12.0))); + if resp.has_focus() { + ui.data_mut(|d| d.insert_temp(id, text.clone())); + } else { + ui.data_mut(|d| d.remove::(id)); + } + if resp.changed() + && text.len() == 2 + && let Ok(b) = u8::from_str_radix(&text, 16) + { + *value = f32::from(b); + return true; + } + false +} + +/// The slider modes: chips (with the out-of-gamut and web-colour alerts under them) beside the +/// sliders, over the colour ramp. +fn sliders(app: &mut PhotocraftApp, ui: &mut egui::Ui, mode: ColorPanelMode) { + let model = Model::of(mode); + let background = app.ui.color_panel.background; + let rgb = active(app); + let v = current_values(ui, model, background, rgb); + let dynamic = app.session.prefs().interface.dynamic_color_sliders; + let rows_h = model.channels().len() as f32 * (ROW_H + ui.spacing().item_spacing.y); + let top_h = rows_h.max(CHIPS_W + 40.0); + let mut edited = None; + ui.horizontal_top(|ui| { + ui.spacing_mut().item_spacing.x = 8.0; + let (col, _) = ui.allocate_exact_size(vec2(CHIPS_W, top_h), Sense::hover()); + field_chips(app, ui, col); + alerts(app, ui, col, rgb, model == Model::Web); + ui.vertical(|ui| { + edited = slider_rows(ui, model, v, background, dynamic); + }); + }); + if let Some(v) = edited { + apply_values(app, ui, model, v); + } + ui.add_space(6.0); + let fill = ui.data(|d| d.get_temp::(color_field_fill_id())); + let gaps = 2.0 * ui.spacing().item_spacing.y + 6.0; + let ramp_h = fill.filter(|f| f.is_finite()).map_or(36.0, |f| (f - top_h - gaps).clamp(28.0, 2000.0)); + ramp(app, ui, ramp_h); +} + +/// Photoshop's alerts under the chips: ⚠ when the colour can't print (click: the nearest CMYK +/// colour) and, for Web Color sliders, the cube when it isn't a web colour (click: the nearest). +fn alerts(app: &mut PhotocraftApp, ui: &mut egui::Ui, col: Rect, rgb: [f32; 3], web: bool) { + let t = Tokens::get(ui.ctx()); + let background = app.ui.color_panel.background; + let mut y = col.top() + CHIPS_W + 2.0; + let warnings = [ + (out_of_gamut(rgb), "Out of gamut for printing: click for the nearest printable colour", false), + (if web { not_web_safe(rgb) } else { None }, "Not a web colour: click for the nearest web colour", true), + ]; + for (slot, (near, tip, cube)) in warnings.into_iter().enumerate() { + let Some(near) = near else { continue }; + let icon = Rect::from_min_size(pos2(col.left() + 1.0, y), vec2(14.0, 13.0)); + let chip = Rect::from_min_size(pos2(col.left() + 18.0, y), vec2(13.0, 13.0)); + if cube { + crate::color_picker_ui::web_cube(ui.painter(), icon.shrink(0.5), t.text_dim); + } else { + crate::color_picker_ui::warning_triangle(ui.painter(), icon, t.text_dim, t.card); + } + ui.painter().rect_filled(chip, 0.0, rgb32(near)); + ui.painter().rect_stroke(chip, 0.0, Stroke::new(1.0, t.text_dim), StrokeKind::Outside); + let resp = ui.interact(icon.union(chip), ui.id().with(("color-panel-alert", slot)), Sense::click()); + resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), tip)); + if resp.on_hover_text(tl!(tip)).clicked() { + set_color(app, background, near); + } + y += 18.0; + } +} + +/// The ramp's colour at (x, y) in 0..1 (y down). RGB Spectrum: hue across, white at the top +/// through the full colour to black at the bottom; CMYK Spectrum: the same in the CMYK gamut; +/// Grayscale Ramp: white to black; Current Colors: the foreground to the background. +pub(crate) fn ramp_color(ramp: ColorRamp, web_safe: bool, fg: [f32; 3], bg: [f32; 3], x: f32, y: f32) -> [f32; 3] { + let (x, y) = (x.clamp(0.0, 1.0), y.clamp(0.0, 1.0)); + let spectrum = || { + let (s, v) = if y < 0.5 { (y * 2.0, 1.0) } else { (1.0, 1.0 - (y - 0.5) * 2.0) }; + hsv_to_rgb(x.min(0.9999) * 360.0, s, v) + }; + let c = match ramp { + ColorRamp::RgbSpectrum => spectrum(), + ColorRamp::CmykSpectrum => convert::cmyk_to_rgb(convert::rgb_to_cmyk(spectrum())), + ColorRamp::GrayscaleRamp => [1.0 - x; 3], + ColorRamp::CurrentColors => [0, 1, 2].map(|i| fg[i] + (bg[i] - fg[i]) * x), + }; + let c = c.map(|v| if v.is_finite() { v.clamp(0.0, 1.0) } else { 0.0 }); + if web_safe { c.map(|v| (v * 5.0).round() / 5.0) } else { c } +} + +/// Cells across and down the ramp's mesh. +const RAMP_NX: usize = 48; +const RAMP_NY: usize = 8; + +/// The ramp's colours, cached until the ramp, its inputs or the CMYK space change: the CMYK +/// Spectrum takes a CMYK round trip per vertex, too slow to redo every frame. +fn ramp_colors(ui: &egui::Ui, ramp: ColorRamp, web_safe: bool, fg: [f32; 3], bg: [f32; 3]) -> Arc> { + use std::hash::{Hash, Hasher}; + let mut h = std::collections::hash_map::DefaultHasher::new(); + (ramp as u8, web_safe).hash(&mut h); + if ramp == ColorRamp::CurrentColors { + (hex(fg), hex(bg)).hash(&mut h); + } + if ramp == ColorRamp::CmykSpectrum { + convert::active_cmyk_space().map(|s| Arc::as_ptr(&s) as usize).hash(&mut h); + } + let sig = h.finish(); + let key = egui::Id::new("color-panel-ramp-cache"); + if let Some((s, colors)) = ui.data(|d| d.get_temp::<(u64, Arc>)>(key)) + && s == sig + { + return colors; + } + // Web-safe ramps are flat cells (sampled at their centres), the others shaded vertices. + let (nx, ny, half) = if web_safe { (RAMP_NX, RAMP_NY, 0.5) } else { (RAMP_NX + 1, RAMP_NY + 1, 0.0) }; + let mut colors = Vec::with_capacity(nx * ny); + for j in 0..ny { + for i in 0..nx { + let (x, y) = ((i as f32 + half) / RAMP_NX as f32, (j as f32 + half) / RAMP_NY as f32); + colors.push(rgb32(ramp_color(ramp, web_safe, fg, bg, x, y))); + } + } + let colors = Arc::new(colors); + ui.data_mut(|d| d.insert_temp(key, (sig, colors.clone()))); + colors +} + +/// The ramp mesh over `r` from [`ramp_colors`]. +fn ramp_mesh(r: Rect, colors: &[Color32], web_safe: bool) -> Mesh { + let mut m = Mesh::default(); + let at = |i: usize, j: usize| pos2(r.left() + r.width() * i as f32 / RAMP_NX as f32, r.top() + r.height() * j as f32 / RAMP_NY as f32); + if web_safe { + for j in 0..RAMP_NY { + for i in 0..RAMP_NX { + let Some(&c) = colors.get(j * RAMP_NX + i) else { continue }; + let a = m.vertices.len() as u32; + for p in [at(i, j), at(i + 1, j), at(i + 1, j + 1), at(i, j + 1)] { + m.colored_vertex(p, c); + } + m.add_triangle(a, a + 1, a + 2); + m.add_triangle(a, a + 2, a + 3); + } + } + return m; + } + for j in 0..=RAMP_NY { + for i in 0..=RAMP_NX { + m.colored_vertex(at(i, j), colors.get(j * (RAMP_NX + 1) + i).copied().unwrap_or(Color32::BLACK)); + } + } + let row = (RAMP_NX + 1) as u32; + for j in 0..RAMP_NY as u32 { + for i in 0..RAMP_NX as u32 { + let a = j * row + i; + m.add_triangle(a, a + 1, a + row + 1); + m.add_triangle(a, a + row + 1, a + row); + } + } + m +} + +/// The colour ramp with the white and black boxes at its right end. A click or drag picks; with +/// Alt it picks the colour the panel isn't editing; Shift-click cycles the ramps; a right-click +/// opens the ramp menu. +fn ramp(app: &mut PhotocraftApp, ui: &mut egui::Ui, height: f32) { + let t = Tokens::get(ui.ctx()); + let w = ui.available_width(); + let (all, _) = ui.allocate_exact_size(vec2(w, height), Sense::hover()); + let bar = Rect::from_min_max(all.min, pos2(all.right() - BOXES_W - 2.0, all.bottom())); + let boxes = Rect::from_min_max(pos2(all.right() - BOXES_W, all.top()), all.max); + let cp = app.ui.color_panel; + let fg = rgb3(app.session.tools.foreground); + let bg = rgb3(app.session.tools.background); + let colors = ramp_colors(ui, cp.ramp, cp.web_safe_ramp, fg, bg); + ui.painter().add(ramp_mesh(bar, &colors, cp.web_safe_ramp)); + ui.painter().rect_stroke(bar, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Outside); + let (white, black) = + (Rect::from_min_max(boxes.min, pos2(boxes.right(), boxes.center().y)), Rect::from_min_max(pos2(boxes.left(), boxes.center().y), boxes.max)); + ui.painter().rect_filled(white, 0.0, Color32::WHITE); + ui.painter().rect_filled(black, 0.0, Color32::BLACK); + ui.painter().rect_stroke(boxes, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Outside); + let resp = ui.interact(bar, ui.id().with("color-panel-ramp"), Sense::click_and_drag()); + resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Other, ui.is_enabled(), "Color Ramp")); + let mods = ui.input(|i| i.modifiers); + let target = cp.background != mods.alt; + if resp.clicked() && mods.shift { + app.ui.color_panel.ramp = cp.ramp.next(); + } else if (resp.dragged() || resp.clicked()) + && !mods.shift + && let Some(p) = resp.interact_pointer_pos() + && bar.width() > 0.0 + && bar.height() > 0.0 + { + let c = ramp_color(cp.ramp, cp.web_safe_ramp, fg, bg, (p.x - bar.left()) / bar.width(), (p.y - bar.top()) / bar.height()); + set_color(app, target, c); + } + resp.context_menu(|ui| { + widgets::style_spectrum_popup_menu(ui); + ramp_menu(app, ui); + }); + for (r, c, name) in [(white, [1.0; 3], "White"), (black, [0.0; 3], "Black")] { + let b = ui.interact(r, ui.id().with(("color-panel-box", name)), Sense::click()); + b.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), name)); + if b.clicked() { + set_color(app, target, c); + } + } +} + +fn rgb3(c: [f32; 4]) -> [f32; 3] { + [c[0], c[1], c[2]].map(|v| v.clamp(0.0, 1.0)) +} + +/// The Color Wheel: HSB sliders over a hue ring (red at the right, running counter-clockwise +/// through yellow and green) around a triangle whose tip is the hue, with white and black at its +/// other corners; the add-to-swatches button sits under it. +fn wheel(app: &mut PhotocraftApp, ui: &mut egui::Ui) { + let t = Tokens::get(ui.ctx()); + let background = app.ui.color_panel.background; + let rgb = active(app); + let v = current_values(ui, Model::Hsb, background, rgb); + let dynamic = app.session.prefs().interface.dynamic_color_sliders; + let rows_h = 3.0 * (ROW_H + ui.spacing().item_spacing.y); + let top_h = rows_h.max(CHIPS_W); + let mut edited = None; + ui.horizontal_top(|ui| { + ui.spacing_mut().item_spacing.x = 8.0; + let (col, _) = ui.allocate_exact_size(vec2(CHIPS_W, top_h), Sense::hover()); + field_chips(app, ui, col); + ui.vertical(|ui| { + edited = slider_rows(ui, Model::Hsb, v, background, dynamic); + }); + }); + let mut v = edited.unwrap_or(v); + let mut changed = edited.is_some(); + ui.add_space(6.0); + let fill = ui.data(|d| d.get_temp::(color_field_fill_id())); + let gaps = 2.0 * ui.spacing().item_spacing.y + 6.0; + let w = ui.available_width(); + let side = fill.filter(|f| f.is_finite()).map_or(w.min(220.0), |f| (f - top_h - gaps).min(w)).max(80.0); + let (area, resp) = ui.allocate_exact_size(vec2(w, side), Sense::click_and_drag()); + resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Other, ui.is_enabled(), "Color Wheel")); + let (center, inner, outer) = wheel_geometry(area); + let ring_w = outer - inner; + let (h, s, b) = (v[0] / 360.0, v[1] / 100.0, v[2] / 100.0); + ui.painter().add(ring_mesh(center, inner, outer)); + let tri = triangle(center, inner - 1.0, h); + ui.painter().add(triangle_mesh(tri, h)); + // Which part a drag began on: the ring sets the hue, the triangle saturation and brightness. + // The ring or the triangle, from where the press began (kept for frames without a press + // origin), so a drag that leaves the ring keeps turning the hue. + let drag_key = ui.id().with("color-wheel-drag"); + if (resp.dragged() || resp.clicked()) + && let Some(p) = resp.interact_pointer_pos() + { + // A click is where it landed; a drag goes by where its press began. + let origin = if resp.clicked() { Some(p) } else { ui.input(|i| i.pointer.press_origin()) }; + let on_ring = match origin { + Some(origin) => { + let on_ring = origin.distance(center) >= inner - 2.0; + ui.data_mut(|d| d.insert_temp(drag_key, on_ring)); + on_ring + } + None => ui.data(|d| d.get_temp::(drag_key)).unwrap_or(false), + }; + if on_ring { + let a = (center.y - p.y).atan2(p.x - center.x).rem_euclid(TAU); + v[0] = (a / TAU * 360.0).round().rem_euclid(360.0); + } else if let Some((s2, b2)) = triangle_sv(tri, p) { + v[1] = (s2 * 100.0).round(); + v[2] = (b2 * 100.0).round(); + } + changed = true; + } + // Knobs: on the ring at the hue, in the triangle at the saturation and brightness. + let a = h * TAU; + let ring_knob = center + vec2(a.cos(), -a.sin()) * (inner + ring_w / 2.0); + let tri_knob = triangle_point(tri, s, b); + for k in [ring_knob, tri_knob] { + ui.painter().circle_stroke(k, 5.0, Stroke::new(1.5, Color32::WHITE)); + ui.painter().circle_stroke(k, 6.5, Stroke::new(1.0, Color32::from_black_alpha(160))); + } + // Photoshop's add-to-swatches button under the wheel. + let add = Rect::from_min_size(pos2(area.right() - 16.0, area.bottom() - 16.0), vec2(14.0, 14.0)); + ui.painter().rect_stroke(add, 1.0, Stroke::new(1.0, t.text_dim), StrokeKind::Inside); + ui.painter().line_segment([pos2(add.center().x, add.top() + 3.5), pos2(add.center().x, add.bottom() - 3.5)], Stroke::new(1.0, t.text_dim)); + ui.painter().line_segment([pos2(add.left() + 3.5, add.center().y), pos2(add.right() - 3.5, add.center().y)], Stroke::new(1.0, t.text_dim)); + let add_resp = ui.interact(add, ui.id().with("color-wheel-add"), Sense::click()); + add_resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), "Add to Swatches")); + if add_resp.on_hover_text(tl!("Create new swatch")).clicked() + && let Err(e) = app.run("swatches.add", json!({"color": hex(rgb)})) + { + app.ui.status = e; + app.ui.status_error = true; + } + if changed { + apply_values(app, ui, Model::Hsb, v); + } +} + +/// The wheel in `area`: its centre and the hue ring's inner and outer radii. +pub(crate) fn wheel_geometry(area: Rect) -> (Pos2, f32, f32) { + let outer = (area.width().min(area.height()) / 2.0 - 2.0).max(1.0); + let ring_w = (outer * 0.09).clamp(6.0, 22.0).min(outer * 0.5); + (area.center(), outer - ring_w, outer) +} + +/// The wheel's hue ring between radii `inner` and `outer`. +fn ring_mesh(center: Pos2, inner: f32, outer: f32) -> Mesh { + let mut m = Mesh::default(); + let steps = 96u32; + for k in 0..=steps { + let f = k as f32 / steps as f32; + let a = f * TAU; + let c = rgb32(hsv_to_rgb(f * 360.0, 1.0, 1.0)); + let dir = vec2(a.cos(), -a.sin()); + m.colored_vertex(center + dir * inner, c); + m.colored_vertex(center + dir * outer, c); + } + for k in 0..steps { + let a = k * 2; + m.add_triangle(a, a + 1, a + 3); + m.add_triangle(a, a + 3, a + 2); + } + m +} + +/// The triangle's corners for hue `h` (0..1): the pure hue at the hue's angle, white 120° on and +/// black 240° on, inside radius `r`. +fn triangle(center: Pos2, r: f32, h: f32) -> [Pos2; 3] { + let at = |turns: f32| { + let a = (h + turns) * TAU; + center + vec2(a.cos(), -a.sin()) * r + }; + [at(0.0), at(1.0 / 3.0), at(2.0 / 3.0)] +} + +/// The point of saturation `s` and brightness `b` in the triangle: black + b·(white − black) + +/// b·s·(hue − white). +fn triangle_point([hue, white, black]: [Pos2; 3], s: f32, b: f32) -> Pos2 { + black + (white - black) * b + (hue - white) * (b * s) +} + +/// Saturation and brightness at `p`, clamped into the triangle; `None` for a degenerate one. +fn triangle_sv([hue, white, black]: [Pos2; 3], p: Pos2) -> Option<(f32, f32)> { + let (a, c, d) = (white - black, hue - white, p - black); + let det = a.x * c.y - a.y * c.x; + if det.abs() < 1e-6 { + return None; + } + let b = ((d.x * c.y - d.y * c.x) / det).clamp(0.0, 1.0); + let bs = ((a.x * d.y - a.y * d.x) / det).clamp(0.0, b); + Some((if b > 0.0 { bs / b } else { 0.0 }, b)) +} + +/// The triangle shaded through saturation and brightness at hue `h`. +fn triangle_mesh(tri: [Pos2; 3], h: f32) -> Mesh { + let n = 16usize; + let mut m = Mesh::default(); + for j in 0..=n { + for i in 0..=n { + let (s, b) = (i as f32 / n as f32, j as f32 / n as f32); + m.colored_vertex(triangle_point(tri, s, b), rgb32(hsv_to_rgb(h * 360.0, s, b))); + } + } + let row = (n + 1) as u32; + for j in 0..n as u32 { + for i in 0..n as u32 { + let a = j * row + i; + m.add_triangle(a, a + 1, a + row + 1); + m.add_triangle(a, a + row + 1, a + row); + } + } + m +} + +/// `color="#rrggbb"`, what Copy Color as HTML puts on the clipboard. +pub(crate) fn html_color(rgb: [f32; 3]) -> String { + format!("color=\"{}\"", hex(rgb)) +} + +/// `rrggbb`, what Copy Color's Hex Code puts on the clipboard. +pub(crate) fn hex_code(rgb: [f32; 3]) -> String { + hex(rgb).trim_start_matches('#').to_string() +} + +/// A panel menu row with Photoshop's check mark column. +fn check_item(ui: &mut egui::Ui, on: bool, label: &str) -> bool { + ui.button(format!("{}{}", if on { "✔ " } else { " " }, tl!(label))).clicked() +} + +/// The ramp choices and Make Ramp Web Safe (the panel menu's last section and the ramp's +/// right-click menu). +fn ramp_menu(app: &mut PhotocraftApp, ui: &mut egui::Ui) { + for r in ColorRamp::ALL { + if check_item(ui, app.ui.color_panel.ramp == r, r.label()) { + app.ui.color_panel.ramp = r; + ui.close(); + } + } + ui.separator(); + if check_item(ui, app.ui.color_panel.web_safe_ramp, "Make Ramp Web Safe") { + app.ui.color_panel.web_safe_ramp = !app.ui.color_panel.web_safe_ramp; + ui.close(); + } +} + +/// The Color panel's panel menu, Photoshop's: the modes, the copy commands, the ramps. +pub(crate) fn panel_menu(app: &mut PhotocraftApp, ui: &mut egui::Ui) { + for (i, mode) in ColorPanelMode::ALL.into_iter().enumerate() { + if i == 3 { + ui.separator(); + } + if check_item(ui, app.ui.color_panel.mode == mode, mode.label()) { + app.ui.color_panel.mode = mode; + ui.close(); + } + } + ui.separator(); + let rgb = active(app); + if ui.button(tl!("Copy Color as HTML")).clicked() { + ui.ctx().copy_text(html_color(rgb)); + ui.close(); + } + if ui.button(tl!("Copy Color's Hex Code")).clicked() { + ui.ctx().copy_text(hex_code(rgb)); + ui.close(); + } + ui.separator(); + ramp_menu(app, ui); +} diff --git a/crates/ui-egui/src/color_picker_ui.rs b/crates/ui-egui/src/color_picker_ui.rs index 09a3ce8d4c..f2177da237 100644 --- a/crates/ui-egui/src/color_picker_ui.rs +++ b/crates/ui-egui/src/color_picker_ui.rs @@ -596,7 +596,7 @@ fn swatches(ui: &mut egui::Ui, f: &mut Map) { } /// ⚠: a filled triangle with an exclamation mark cut out of it. -fn warning_triangle(p: &egui::Painter, r: Rect, ink: Color32, cut: Color32) { +pub(crate) fn warning_triangle(p: &egui::Painter, r: Rect, ink: Color32, cut: Color32) { let tri = vec![pos2(r.center().x, r.top()), pos2(r.right(), r.bottom()), pos2(r.left(), r.bottom())]; p.add(egui::Shape::convex_polygon(tri, ink, Stroke::NONE)); let x = r.center().x; @@ -605,7 +605,7 @@ fn warning_triangle(p: &egui::Painter, r: Rect, ink: Color32, cut: Color32) { } /// A cube seen corner-on: a hexagon with three edges meeting in the middle. -fn web_cube(p: &egui::Painter, r: Rect, ink: Color32) { +pub(crate) fn web_cube(p: &egui::Painter, r: Rect, ink: Color32) { let (c, rad) = (r.center(), r.width() / 2.0); let corner = |k: f32| { let a = std::f32::consts::FRAC_PI_3 * k - std::f32::consts::FRAC_PI_2; diff --git a/crates/ui-egui/src/color_tab_theme_tests.rs b/crates/ui-egui/src/color_tab_theme_tests.rs index b3566277e2..7996284d94 100644 --- a/crates/ui-egui/src/color_tab_theme_tests.rs +++ b/crates/ui-egui/src/color_tab_theme_tests.rs @@ -1,5 +1,5 @@ -//! The Color panel tab draws Photoshop's spectrum field in every theme (#4367): the light themes -//! used to show HSB sliders only. Those themes keep the sliders, under the field. +//! The Color panel tab is Photoshop's spectrum field in every theme (#4367, #6000): the light +//! themes used to show HSB sliders only, then a short field with the sliders under it. use egui::{Rect, pos2}; use egui_kittest::kittest::Queryable; @@ -12,8 +12,9 @@ fn left_top() -> egui::Id { egui::Id::new("color-tab-test-origin") } -/// The Color tab of `kind`, alone in a 300 pt wide panel, starting from a red foreground. -fn color_tab(kind: ThemeKind) -> egui_kittest::Harness<'static, PhotocraftApp> { +/// The Color tab of `kind`, alone in a 300 pt wide panel, starting from a red foreground. `fill` +/// is the group body height the dock offers, if any. +fn color_tab(kind: ThemeKind, fill: Option) -> egui_kittest::Harness<'static, PhotocraftApp> { let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); app.session.tools.foreground = [1.0, 0.0, 0.0, 1.0]; let tab = Group::Color.tabs(Tokens::for_kind(kind).pro).iter().position(|name| *name == "Color").unwrap(); @@ -22,6 +23,9 @@ fn color_tab(kind: ThemeKind) -> egui_kittest::Harness<'static, PhotocraftApp> { if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { let origin = ui.cursor().min; ui.data_mut(|d| d.insert_temp(left_top(), Rect::from_min_size(origin, egui::Vec2::ZERO))); + if let Some(fill) = fill { + ui.data_mut(|d| d.insert_temp(crate::panels::color_field_fill_id(), fill)); + } crate::panels::dock_body(app, ui, Group::Color, tab); } }, @@ -32,24 +36,41 @@ fn color_tab(kind: ThemeKind) -> egui_kittest::Harness<'static, PhotocraftApp> { h } +/// Drag on the saturation/brightness field at `y` below its top, on its left edge (no saturation). +fn pick_at(h: &mut egui_kittest::Harness<'static, PhotocraftApp>, y: f32) -> [f32; 4] { + let origin = h.ctx.data(|d| d.get_temp::(left_top())).unwrap().min; + // After the 38 pt chips and the 8 pt gap. + let p = pos2(origin.x + 38.0 + 8.0 + 1.0, origin.y + y); + h.hover_at(p); + h.run_steps(1); + h.drag_at(p); + h.run_steps(1); + h.drop_at(p); + h.run_steps(2); + h.state().session.tools.foreground +} + #[test] -fn every_theme_shows_the_spectrum_field() { +fn every_theme_shows_the_same_spectrum_field() { for kind in ThemeKind::ALL { - let mut h = color_tab(kind); - let origin = h.ctx.data(|d| d.get_temp::(left_top())).unwrap().min; - // Left edge of the saturation/brightness field (after the 38 pt chips and the 8 pt gap), - // halfway down its 120 pt: no saturation, half brightness. - let p = pos2(origin.x + 38.0 + 8.0 + 1.0, origin.y + 60.0); - h.hover_at(p); - h.run_steps(1); - h.drag_at(p); - h.run_steps(1); - h.drop_at(p); - h.run_steps(2); - let [r, g, b, _] = h.state().session.tools.foreground; + let mut h = color_tab(kind, None); + // Halfway down its 120 pt: no saturation, half brightness. + let [r, g, b, _] = pick_at(&mut h, 60.0); assert!((r - g).abs() < 0.02 && (g - b).abs() < 0.02 && (0.3..0.7).contains(&r), "{kind:?}: the field picks a mid grey, got {r} {g} {b}"); - if !Tokens::for_kind(kind).pro { - assert!(h.query_by_label("Saturation").is_some(), "{kind:?}: the sliders stay under the field"); + // No theme swaps the field for sliders or adds them under it (#6000). + for slider in ["Hue", "Saturation", "Brightness"] { + assert!(h.query_by_label(slider).is_none(), "{kind:?}: no {slider} slider"); } } } + +/// Every theme stretches the field over the dock group, as Photoshop's themes always did (#6000). +#[test] +fn every_theme_stretches_the_field_over_the_group() { + for kind in ThemeKind::ALL { + let mut h = color_tab(kind, Some(380.0)); + // Far below a 120 pt field: only a stretched one picks here, and a dark grey. + let [r, g, b, _] = pick_at(&mut h, 300.0); + assert!((r - g).abs() < 0.02 && (g - b).abs() < 0.02 && r < 0.25, "{kind:?}: the stretched field picks a dark grey, got {r} {g} {b}"); + } +} diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index ff786be197..f1d8deb8f3 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -228,7 +228,7 @@ fn merged_object(current: &T, serde_json::from_value(cur).map(Some).map_err(|e| format!("{field}: {e}")) } -/// A `ui.set` object field applied by whole-value replacement (e.g. `dock`, `colorPanel`): +/// A `ui.set` object field applied by whole-value replacement (e.g. `dock`): /// unknown nested keys are rejected like [`merged_object`] does, but the value replaces the /// state instead of merging into it. fn whole_object(current: &T, v: Option<&Value>, field: &str) -> std::result::Result, String> { @@ -556,7 +556,7 @@ fn dispatch(app: &mut PhotocraftApp, ctx: &egui::Context, req: &ControlRequest) let dock_tabs = merged_object(&app.ui.dock_tabs, p.get("dockTabs"), "dockTabs")?; let dock = whole_object(&app.ui.dock, p.get("dock"), "dock")?; // Which chip the Color panel edits. - let color_panel = whole_object(&app.ui.color_panel, p.get("colorPanel"), "colorPanel")?; + let color_panel = merged_object(&app.ui.color_panel, p.get("colorPanel"), "colorPanel")?; let dock_width = num_field(p, "dockWidth")?; let zoom = num_field(p, "zoom")?; let rotation = num_field(p, "rotation")?; diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs index deaea4e783..716d66fee3 100644 --- a/crates/ui-egui/src/dock.rs +++ b/crates/ui-egui/src/dock.rs @@ -521,8 +521,8 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui, shown: &[Group], mut bod ui.set_min_height(inner); body(app, ui, g, tab); } else { - // The pro Color field stretches to the group's height instead of a fixed 120 pt. - if t.pro && g == Group::Color && tab == 0 { + // The Color field stretches to the group's height instead of a fixed 120 pt. + if g == Group::Color && g.tabs(t.pro).get(tab) == Some(&"Color") { ui.data_mut(|d| d.insert_temp(crate::panels::color_field_fill_id(), inner)); } // No scroll fade: it darkens real colours, swatches and previews at the edge @@ -608,6 +608,10 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui, shown: &[Group], mut bod crate::layer_row_ui::panel_menu(app, ui); ui.separator(); } + if tabs.get(sel) == Some(&"Color") { + crate::color_panel_ui::panel_menu(app, ui); + ui.separator(); + } if tabs.get(sel) == Some(&"Swatches") { crate::swatches_ui::panel_menu(app, ui); ui.separator(); diff --git a/crates/ui-egui/src/dock_tests.rs b/crates/ui-egui/src/dock_tests.rs index f0a64562c4..ba5a95390f 100644 --- a/crates/ui-egui/src/dock_tests.rs +++ b/crates/ui-egui/src/dock_tests.rs @@ -689,8 +689,10 @@ fn theme_switch_keeps_the_selected_color_group_panel() { h.state_mut().set_theme(&ctx, theme); h.run_steps(4); assert_eq!(Group::Color.tabs(is_pro(theme)).get(h.state().ui.dock_tabs.color), Some(name), "{theme:?}"); - if *name == "Color" && !is_pro(theme) { - assert!(h.query_by_label("Hue").is_some(), "{theme:?}: Color picker missing"); + if *name == "Color" { + // The spectrum field's hex readout, the same in every theme (#6000). + assert!(h.query_by_label("#").is_some(), "{theme:?}: Color field missing"); + assert!(h.query_by_label("Hue").is_none(), "{theme:?}: no HSB sliders"); } h.state_mut().set_theme(&ctx, ThemeKind::Pro); h.run_steps(4); diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 6c8f21418a..0f7f44aede 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -3797,3 +3797,21 @@ navigator Zoom Zvětšení There are too many sets: delete one first. Sad je příliš mnoho: nejprve jednu smažte. set name název sady {set} (modified) {set} (změněno) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Krychle odstínu + Brightness Cube Krychle jasu + Color Wheel Barevné kolo + Grayscale Slider Jezdec stupňů šedi + RGB Sliders Jezdce RGB + HSB Sliders Jezdce HSB + CMYK Sliders Jezdce CMYK + Lab Sliders Jezdce Lab + Web Color Sliders Jezdce webových barev + Copy Color as HTML Kopírovat barvu jako HTML + Copy Color's Hex Code Kopírovat šestnáctkový kód barvy + RGB Spectrum Spektrum RGB + CMYK Spectrum Spektrum CMYK + Grayscale Ramp Přechod stupňů šedi + Current Colors Aktuální barvy + Make Ramp Web Safe Omezit pruh na webové barvy diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 2bb1c57f19..b7a9e63e81 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -3191,3 +3191,21 @@ curves Smooth Glätten There are too many sets: delete one first. Zu viele Sätze: Löschen Sie zuerst einen. set name Name des Satzes {set} (modified) {set} (geändert) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Farbtonwürfel + Brightness Cube Helligkeitswürfel + Color Wheel Farbkreis + Grayscale Slider Graustufen-Regler + RGB Sliders RGB-Regler + HSB Sliders HSB-Regler + CMYK Sliders CMYK-Regler + Lab Sliders Lab-Regler + Web Color Sliders Webfarben-Regler + Copy Color as HTML Farbe als HTML kopieren + Copy Color's Hex Code Hex-Code der Farbe kopieren + RGB Spectrum RGB-Spektrum + CMYK Spectrum CMYK-Spektrum + Grayscale Ramp Graustufenbalken + Current Colors Aktuelle Farben + Make Ramp Web Safe Farbbalken auf Webfarben beschränken diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 48d23d13b9..1d642bead6 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3889,3 +3889,20 @@ curves Smooth Εξομάλυνση There are too many sets: delete one first. Υπάρχουν πάρα πολλά σύνολα: διαγράψτε πρώτα ένα. set name όνομα συνόλου {set} (modified) {set} (τροποποιημένο) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Κύβος απόχρωσης + Brightness Cube Κύβος φωτεινότητας + Color Wheel Χρωματικός τροχός + RGB Sliders Ρυθμιστικά RGB + HSB Sliders Ρυθμιστικά HSB + CMYK Sliders Ρυθμιστικά CMYK + Lab Sliders Ρυθμιστικά Lab + Web Color Sliders Ρυθμιστικά χρωμάτων ιστού + Copy Color as HTML Αντιγραφή χρώματος ως HTML + Copy Color's Hex Code Αντιγραφή δεκαεξαδικού κωδικού χρώματος + RGB Spectrum Φάσμα RGB + CMYK Spectrum Φάσμα CMYK + Grayscale Ramp Διαβάθμιση του γκρι + Current Colors Τρέχοντα χρώματα + Make Ramp Web Safe Μόνο χρώματα ιστού στη διαβάθμιση diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index a7338795aa..76149debb5 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -4151,3 +4151,20 @@ navigator Zoom Zoom There are too many sets: delete one first. Hay demasiados conjuntos: elimine uno primero. set name nombre del conjunto {set} (modified) {set} (modificado) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Cubo de tono + Brightness Cube Cubo de brillo + Color Wheel Rueda de color + RGB Sliders Reguladores RGB + HSB Sliders Reguladores HSB + CMYK Sliders Reguladores CMYK + Lab Sliders Reguladores Lab + Web Color Sliders Reguladores de colores web + Copy Color as HTML Copiar color como HTML + Copy Color's Hex Code Copiar código hexadecimal del color + RGB Spectrum Espectro RGB + CMYK Spectrum Espectro CMYK + Grayscale Ramp Rampa de escala de grises + Current Colors Colores actuales + Make Ramp Web Safe Hacer rampa segura para web diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index ba1de7b706..cda25aa9dd 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -3194,3 +3194,20 @@ curves Smooth Lisser set name nom du jeu {set} (modified) {set} (modifié) Random Aléatoire + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Cube de teinte + Brightness Cube Cube de luminosité + Color Wheel Roue chromatique + RGB Sliders Curseurs RVB + HSB Sliders Curseurs TSL + CMYK Sliders Curseurs CMJN + Lab Sliders Curseurs Lab + Web Color Sliders Curseurs de couleurs Web + Copy Color as HTML Copier la couleur en HTML + Copy Color's Hex Code Copier le code hexadécimal de la couleur + RGB Spectrum Spectre RVB + CMYK Spectrum Spectre CMJN + Grayscale Ramp Barre de niveaux de gris + Current Colors Couleurs actuelles + Make Ramp Web Safe Limiter la barre aux couleurs Web diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index e26f3ec3b8..fe020bface 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -4108,3 +4108,20 @@ cameraRaw Yellow Sárga There are too many sets: delete one first. Túl sok készlet van: előbb töröljön egyet. set name készlet neve {set} (modified) {set} (módosítva) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Színárnyalat-kocka + Brightness Cube Fényerő-kocka + Color Wheel Színkör + RGB Sliders RGB-csúszkák + HSB Sliders HSB-csúszkák + CMYK Sliders CMYK-csúszkák + Lab Sliders Lab-csúszkák + Web Color Sliders Webes színek csúszkái + Copy Color as HTML Szín másolása HTML-ként + Copy Color's Hex Code Szín hexadecimális kódjának másolása + RGB Spectrum RGB-spektrum + CMYK Spectrum CMYK-spektrum + Grayscale Ramp Szürkeárnyalatos sáv + Current Colors Aktuális színek + Make Ramp Web Safe Sáv korlátozása webes színekre diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index d13db9f0cf..a7a6d2d4d2 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -3181,3 +3181,20 @@ curves Smooth Haluskan set name nama set {set} (modified) {set} (diubah) Random Acak + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Kubus Hue + Brightness Cube Kubus Kecerahan + Color Wheel Roda Warna + RGB Sliders Slider RGB + HSB Sliders Slider HSB + CMYK Sliders Slider CMYK + Lab Sliders Slider Lab + Web Color Sliders Slider Warna Web + Copy Color as HTML Salin Warna sebagai HTML + Copy Color's Hex Code Salin Kode Hex Warna + RGB Spectrum Spektrum RGB + CMYK Spectrum Spektrum CMYK + Grayscale Ramp Gradasi Grayscale + Current Colors Warna Saat Ini + Make Ramp Web Safe Jadikan Gradasi Aman untuk Web diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 1779c1259e..29cce09b38 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -4310,3 +4310,20 @@ shape Appearance Aspetto There are too many sets: delete one first. Ci sono troppi set: eliminane prima uno. set name nome del set {set} (modified) {set} (modificato) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Cubo tonalità + Brightness Cube Cubo luminosità + Color Wheel Ruota dei colori + RGB Sliders Cursori RGB + HSB Sliders Cursori HSB + CMYK Sliders Cursori CMYK + Lab Sliders Cursori Lab + Web Color Sliders Cursori colori web + Copy Color as HTML Copia colore come HTML + Copy Color's Hex Code Copia codice esadecimale del colore + RGB Spectrum Spettro RGB + CMYK Spectrum Spettro CMYK + Grayscale Ramp Barra scala di grigio + Current Colors Colori correnti + Make Ramp Web Safe Limita la barra ai colori web diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index dd0cca727f..15c4e77226 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3865,3 +3865,20 @@ curves Smooth スムーズ There are too many sets: delete one first. セットが多すぎます。先に 1 つ削除してください。 set name セット名 {set} (modified) {set}(変更あり) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube 色相キューブ + Brightness Cube 明るさキューブ + Color Wheel カラーホイール + RGB Sliders RGB スライダー + HSB Sliders HSB スライダー + CMYK Sliders CMYK スライダー + Lab Sliders Lab スライダー + Web Color Sliders Web カラースライダー + Copy Color as HTML カラーを HTML としてコピー + Copy Color's Hex Code カラーの 16 進コードをコピー + RGB Spectrum RGB スペクトル + CMYK Spectrum CMYK スペクトル + Grayscale Ramp グレースケールランプ + Current Colors 現在のカラー + Make Ramp Web Safe ランプを Web セーフにする diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index f5c243d1e5..ee1b899c05 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3367,3 +3367,21 @@ curves Smooth 매끄럽게 There are too many sets: delete one first. 세트가 너무 많습니다. 먼저 하나를 삭제하세요. set name 세트 이름 {set} (modified) {set}(수정됨) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube 색조 큐브 + Brightness Cube 밝기 큐브 + Color Wheel 색상환 + Grayscale Slider 회색 음영 슬라이더 + RGB Sliders RGB 슬라이더 + HSB Sliders HSB 슬라이더 + CMYK Sliders CMYK 슬라이더 + Lab Sliders Lab 슬라이더 + Web Color Sliders 웹 색상 슬라이더 + Copy Color as HTML 색상을 HTML로 복사 + Copy Color's Hex Code 색상의 16진수 코드 복사 + RGB Spectrum RGB 스펙트럼 + CMYK Spectrum CMYK 스펙트럼 + Grayscale Ramp 회색 음영 램프 + Current Colors 현재 색상 + Make Ramp Web Safe 램프를 웹 안전 색상으로 만들기 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index aea44757ca..f5cd05acae 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -3949,3 +3949,20 @@ curves Smooth Vloeiend maken There are too many sets: delete one first. Er zijn te veel sets: verwijder er eerst een. set name naam van de set {set} (modified) {set} (gewijzigd) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Kleurtoonkubus + Brightness Cube Helderheidskubus + Color Wheel Kleurenwiel + RGB Sliders RGB-schuifregelaars + HSB Sliders HSB-schuifregelaars + CMYK Sliders CMYK-schuifregelaars + Lab Sliders Lab-schuifregelaars + Web Color Sliders Webkleurschuifregelaars + Copy Color as HTML Kleur kopiëren als HTML + Copy Color's Hex Code Hexadecimale code van kleur kopiëren + RGB Spectrum RGB-spectrum + CMYK Spectrum CMYK-spectrum + Grayscale Ramp Grijswaardenbalk + Current Colors Huidige kleuren + Make Ramp Web Safe Balk beperken tot webkleuren diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 17feb459aa..41cf02b84c 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3787,3 +3787,20 @@ curves Smooth Wygładź There are too many sets: delete one first. Zestawów jest za dużo: najpierw usuń jeden. set name nazwa zestawu {set} (modified) {set} (zmieniony) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Sześcian odcienia + Brightness Cube Sześcian jasności + Color Wheel Koło kolorów + RGB Sliders Suwaki RGB + HSB Sliders Suwaki HSB + CMYK Sliders Suwaki CMYK + Lab Sliders Suwaki Lab + Web Color Sliders Suwaki kolorów internetowych + Copy Color as HTML Kopiuj kolor jako HTML + Copy Color's Hex Code Kopiuj kod szesnastkowy koloru + RGB Spectrum Widmo RGB + CMYK Spectrum Widmo CMYK + Grayscale Ramp Pasek skali szarości + Current Colors Bieżące kolory + Make Ramp Web Safe Ogranicz pasek do kolorów internetowych diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 0e9559c80e..7195891d9e 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -3979,3 +3979,20 @@ layerLabel No Color Sem cor There are too many sets: delete one first. Há conjuntos demais: exclua um primeiro. set name nome do conjunto {set} (modified) {set} (modificado) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Cubo de matiz + Brightness Cube Cubo de brilho + Color Wheel Roda de cores + RGB Sliders Controles deslizantes RGB + HSB Sliders Controles deslizantes HSB + CMYK Sliders Controles deslizantes CMYK + Lab Sliders Controles deslizantes Lab + Web Color Sliders Controles deslizantes de cores da Web + Copy Color as HTML Copiar cor como HTML + Copy Color's Hex Code Copiar código hexadecimal da cor + RGB Spectrum Espectro RGB + CMYK Spectrum Espectro CMYK + Grayscale Ramp Rampa de tons de cinza + Current Colors Cores atuais + Make Ramp Web Safe Tornar rampa segura para a Web diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 78e10a10c4..77ada5a05f 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -3159,3 +3159,20 @@ curves Smooth Сгладить set name имя набора {set} (modified) {set} (изменён) Random Случайно + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Куб цветового тона + Brightness Cube Куб яркости + Color Wheel Цветовой круг + RGB Sliders Ползунки RGB + HSB Sliders Ползунки HSB + CMYK Sliders Ползунки CMYK + Lab Sliders Ползунки Lab + Web Color Sliders Ползунки web-цветов + Copy Color as HTML Копировать цвет как HTML + Copy Color's Hex Code Копировать шестнадцатеричный код цвета + RGB Spectrum Спектр RGB + CMYK Spectrum Спектр CMYK + Grayscale Ramp Шкала градаций серого + Current Colors Текущие цвета + Make Ramp Web Safe Сделать шкалу безопасной для web diff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsv index f4a8552fb0..69ec405a52 100644 --- a/crates/ui-egui/src/i18n/sr.tsv +++ b/crates/ui-egui/src/i18n/sr.tsv @@ -4262,3 +4262,20 @@ shape Appearance Izgled There are too many sets: delete one first. Previše skupova: prvo obrišite jedan. set name ime skupa {set} (modified) {set} (izmenjen) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Kocka nijanse + Brightness Cube Kocka osvetljenosti + Color Wheel Točak boja + RGB Sliders RGB klizači + HSB Sliders HSB klizači + CMYK Sliders CMYK klizači + Lab Sliders Lab klizači + Web Color Sliders Klizači veb boja + Copy Color as HTML Kopiraj boju kao HTML + Copy Color's Hex Code Kopiraj heksadecimalni kod boje + RGB Spectrum RGB spektar + CMYK Spectrum CMYK spektar + Grayscale Ramp Skala nijansi sive + Current Colors Trenutne boje + Make Ramp Web Safe Učini skalu bezbednom za veb diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index b11f51a807..58f6bf6b4e 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -3919,3 +3919,20 @@ cameraData Lens Lens There are too many sets: delete one first. Çok fazla küme var: önce birini silin. set name küme adı {set} (modified) {set} (değiştirildi) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Renk Tonu Küpü + Brightness Cube Parlaklık Küpü + Color Wheel Renk Çarkı + RGB Sliders RGB Kaydırıcıları + HSB Sliders HSB Kaydırıcıları + CMYK Sliders CMYK Kaydırıcıları + Lab Sliders Lab Kaydırıcıları + Web Color Sliders Web Rengi Kaydırıcıları + Copy Color as HTML Rengi HTML Olarak Kopyala + Copy Color's Hex Code Rengin Onaltılık Kodunu Kopyala + RGB Spectrum RGB Spektrumu + CMYK Spectrum CMYK Spektrumu + Grayscale Ramp Gri Tonlama Şeridi + Current Colors Geçerli Renkler + Make Ramp Web Safe Şeridi Web Renkleriyle Sınırla diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index e563354fdf..1712f05980 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3888,3 +3888,20 @@ curves Smooth Згладити There are too many sets: delete one first. Забагато наборів: спершу видаліть один. set name назва набору {set} (modified) {set} (змінено) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Куб тону + Brightness Cube Куб яскравості + Color Wheel Колірне коло + RGB Sliders Повзунки RGB + HSB Sliders Повзунки HSB + CMYK Sliders Повзунки CMYK + Lab Sliders Повзунки Lab + Web Color Sliders Повзунки вебкольорів + Copy Color as HTML Копіювати колір як HTML + Copy Color's Hex Code Копіювати шістнадцятковий код кольору + RGB Spectrum Спектр RGB + CMYK Spectrum Спектр CMYK + Grayscale Ramp Шкала градацій сірого + Current Colors Поточні кольори + Make Ramp Web Safe Зробити шкалу безпечною для вебу diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 6907be96aa..b6afa96ac2 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3675,3 +3675,21 @@ curves Smooth Làm mượt There are too many sets: delete one first. Có quá nhiều bộ: hãy xóa một bộ trước. set name tên bộ {set} (modified) {set} (đã sửa đổi) + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube Khối sắc màu + Brightness Cube Khối độ sáng + Color Wheel Bánh xe màu + Grayscale Slider Thanh trượt thang xám + RGB Sliders Thanh trượt RGB + HSB Sliders Thanh trượt HSB + CMYK Sliders Thanh trượt CMYK + Lab Sliders Thanh trượt Lab + Web Color Sliders Thanh trượt màu web + Copy Color as HTML Sao chép màu dạng HTML + Copy Color's Hex Code Sao chép mã hex của màu + RGB Spectrum Phổ RGB + CMYK Spectrum Phổ CMYK + Grayscale Ramp Dải thang xám + Current Colors Màu hiện tại + Make Ramp Web Safe Giới hạn dải màu ở màu web diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 3962f46d65..e18b1aba46 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2805,3 +2805,21 @@ curves Smooth 平滑 set name 组名称 {set} (modified) {set}(已修改) Random 随机 + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube 色相立方体 + Brightness Cube 亮度立方体 + Color Wheel 色轮 + Grayscale Slider 灰度滑块 + RGB Sliders RGB 滑块 + HSB Sliders HSB 滑块 + CMYK Sliders CMYK 滑块 + Lab Sliders Lab 滑块 + Web Color Sliders Web 颜色滑块 + Copy Color as HTML 将颜色复制为 HTML + Copy Color's Hex Code 复制颜色的十六进制代码 + RGB Spectrum RGB 色谱 + CMYK Spectrum CMYK 色谱 + Grayscale Ramp 灰度色带 + Current Colors 当前颜色 + Make Ramp Web Safe 使色带成为 Web 安全色 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 005c992e23..4606b86c93 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2790,3 +2790,21 @@ curves Smooth 平滑 set name 組合名稱 {set} (modified) {set}(已修改) Random 隨機 + +# Color panel menu: modes, copy commands and colour ramps (#6000) + Hue Cube 色相立方體 + Brightness Cube 亮度立方體 + Color Wheel 色輪 + Grayscale Slider 灰階滑桿 + RGB Sliders RGB 滑桿 + HSB Sliders HSB 滑桿 + CMYK Sliders CMYK 滑桿 + Lab Sliders Lab 滑桿 + Web Color Sliders 網頁色彩滑桿 + Copy Color as HTML 將色彩複製為 HTML + Copy Color's Hex Code 複製色彩的十六進位碼 + RGB Spectrum RGB 色譜 + CMYK Spectrum CMYK 色譜 + Grayscale Ramp 灰階色帶 + Current Colors 目前色彩 + Make Ramp Web Safe 讓色帶成為網頁安全色 diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 5d95f2d662..09ea82a0d8 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -54,6 +54,7 @@ pub mod channels_panel; pub mod chrome_ui; pub mod cjk_fonts; pub mod clip_line_ui; +pub mod color_panel_ui; pub mod color_picker_ui; pub mod color_range_ui; pub mod comps_ui; @@ -2653,6 +2654,8 @@ mod move_auto_select_tests; #[cfg(test)] mod new_group_button_tests; +#[cfg(test)] +mod color_panel_tests; #[cfg(test)] mod color_tab_theme_tests; diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 522c74dc15..65b50b7fd8 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -1758,10 +1758,10 @@ pub(crate) fn dock_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, group: crate match (group, tab) { (Group::Color, 2) => crate::preset_panels::gradients_panel(app, ui), (Group::Color, 3) => crate::preset_panels::patterns_panel(app, ui), - (Group::Color, 0) if pro => color_field(app, ui), - (Group::Color, _) if pro => crate::swatches_ui::panel(app, ui), - (Group::Color, 0) => crate::swatches_ui::panel(app, ui), - (Group::Color, _) => color_picker(app, ui), + // The Color tab is the same in every theme, in the mode picked from its panel menu + // (#6000); only the tab order differs between themes. + (Group::Color, tab) if group.tabs(pro).get(tab) == Some(&"Color") => crate::color_panel_ui::panel(app, ui), + (Group::Color, _) => crate::swatches_ui::panel(app, ui), (Group::Properties, 0) => properties_body(app, ui), (Group::Properties, _) => adjustments_grid(app, ui), (Group::Character, tab) => crate::type_tool::character_panel(app, ui, tab == 1), @@ -2114,44 +2114,6 @@ fn empty(ui: &mut egui::Ui, s: &str) { ui.add_space(6.0); } -/// The Color tab of the themes other than Photoshop's: the same spectrum field (chips, saturation -/// and brightness field, hue strip and readout) with HSB sliders under it (#4367). -fn color_picker(app: &mut PhotocraftApp, ui: &mut egui::Ui) { - color_field(app, ui); - ui.add_space(8.0); - hsb_sliders(app, ui); -} - -/// Hue, Saturation and Brightness sliders for the foreground colour. -fn hsb_sliders(app: &mut PhotocraftApp, ui: &mut egui::Ui) { - let fg = app.session.tools.foreground; - // Keep the last edited HSB while it still gives the foreground: black and greys have no hue or - // saturation of their own, so recomputing them from RGB would reset what was just typed to 0. - let key = egui::Id::new("color-picker-hsva"); - let stored: Option = ui.data(|d| d.get_temp(key)); - let hsva0 = stored.filter(|h| srgb_bytes(hsva_srgb(*h)) == srgb_bytes(fg)).unwrap_or_else(|| srgb_hsva(fg)); - let mut h = hsva0.h * 360.0; - let mut s = hsva0.s * 100.0; - let mut v = hsva0.v * 100.0; - let hue = widgets::hue_stops(); - // Preferences ▸ Interface ▸ Dynamic Color Sliders: off, the tracks are the plain ones. - let dynamic = app.session.prefs().interface.dynamic_color_sliders; - let mut changed = widgets::slider_row(ui, tl!("Hue"), &mut h, 0.0..=360.0, "°", dynamic.then_some(&hue)).changed(); - let sat_stops = - [egui::ecolor::Hsva::new(hsva0.h, 0.0, hsva0.v.max(0.2), 1.0), egui::ecolor::Hsva::new(hsva0.h, 1.0, hsva0.v.max(0.2), 1.0)].map(hsva_color32); - changed |= widgets::slider_row(ui, tl!("Saturation"), &mut s, 0.0..=100.0, "%", dynamic.then_some(&sat_stops)).changed(); - let val_stops = [Color32::BLACK, hsva_color32(egui::ecolor::Hsva::new(hsva0.h, hsva0.s, 1.0, 1.0))]; - changed |= widgets::slider_row(ui, tl!("Brightness"), &mut v, 0.0..=100.0, "%", dynamic.then_some(&val_stops)).changed(); - let hsva = egui::ecolor::Hsva::new(h / 360.0, s / 100.0, v / 100.0, 1.0); - // Only an edit counts: the h/s/v round trip isn't exact, so comparing values would rewrite - // the foreground (and recolour selected type) every frame. - if changed { - app.session.tools.foreground = hsva_srgb(hsva); - ui.data_mut(|d| d.insert_temp(key, hsva)); - crate::type_tool::foreground_changed(app); - } -} - // ----------------------------------------------------------------------------- layers /// The simple themes' single lock button. On the Background it converts the layer to a normal @@ -3574,7 +3536,7 @@ fn adjustments_grid(app: &mut PhotocraftApp, ui: &mut egui::Ui) { /// The Color panel's foreground and background chips. A click picks the colour the field edits, /// framed; a double-click opens the Color Picker on it. -fn field_chips(app: &mut PhotocraftApp, ui: &mut egui::Ui, chips: Rect) { +pub(crate) fn field_chips(app: &mut PhotocraftApp, ui: &mut egui::Ui, chips: Rect) { let t = Tokens::get(ui.ctx()); let bgr = Rect::from_min_size(chips.min + vec2(13.0, 13.0), vec2(22.0, 22.0)); let fgr = Rect::from_min_size(chips.min + vec2(3.0, 3.0), vec2(22.0, 22.0)); @@ -3618,7 +3580,7 @@ fn color_field_height(avail: Option, width: f32) -> f32 { /// neither hue nor saturation — so a drag that bottoms out into black would otherwise round-trip /// through RGB as `s = 0` and drop the knob from the bottom-right corner to the bottom-left one /// (#3228). -fn field_hsva(mut hsva: egui::ecolor::Hsva, remembered: (f32, f32)) -> egui::ecolor::Hsva { +pub(crate) fn field_hsva(mut hsva: egui::ecolor::Hsva, remembered: (f32, f32)) -> egui::ecolor::Hsva { if hsva.v < 0.01 { hsva.h = remembered.0; hsva.s = remembered.1; @@ -3630,8 +3592,9 @@ fn field_hsva(mut hsva: egui::ecolor::Hsva, remembered: (f32, f32)) -> egui::eco hsva } -/// Photoshop Color panel: saturation/brightness field + hue strip, drawn as shaded meshes. -fn color_field(app: &mut PhotocraftApp, ui: &mut egui::Ui) { +/// Photoshop's Color panel Hue Cube (saturation/brightness field + hue strip) or Brightness Cube +/// (hue/saturation field + brightness strip), drawn as shaded meshes, over a hex/RGB readout. +pub(crate) fn color_field(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let t = Tokens::get(ui.ctx()); let bg_active = app.ui.color_panel.background; let key = egui::Id::new(("color-field-hue", bg_active)); @@ -3641,70 +3604,60 @@ fn color_field(app: &mut PhotocraftApp, ui: &mut egui::Ui) { hsva = field_hsva(hsva, remembered); let w = ui.available_width(); let strip_w = 14.0; - // Photoshop's Color panel field fills the panel: take the height the dock offers, less the - // hex/RGB readout (which folds onto a second line in a narrow dock). Without a dock, 120 pt. - // Only Photoshop's themes stretch it over the group: the other themes put sliders under it. - let fill = if t.pro { ui.data(|d| d.get_temp::(color_field_fill_id())) } else { None }; + // Photoshop's Color panel field fills the panel in every theme (#6000): take the height the + // dock offers, less the hex/RGB readout (which folds onto a second line in a narrow dock) and + // the theme's spacing between the rows. Without a dock, 120 pt. + let gaps = 2.0 * ui.spacing().item_spacing.y; + let fill = ui.data(|d| d.get_temp::(color_field_fill_id())).map(|a| a - gaps); let h = color_field_height(fill, w); ui.horizontal(|ui| { ui.spacing_mut().item_spacing.x = 8.0; let (chips, _) = ui.allocate_exact_size(vec2(38.0, h), Sense::hover()); field_chips(app, ui, chips); - // SV field. + // Hue Cube: saturation across and brightness up, hue on the strip. Brightness Cube (the + // Color Picker's B mode): hue across and saturation up, brightness on the strip. + let brightness = app.ui.color_panel.mode == crate::state::ColorPanelMode::BrightnessCube; let field_w = w - 38.0 - strip_w - 16.0; let (field, fresp) = ui.allocate_exact_size(vec2(field_w, h), Sense::click_and_drag()); - let mut mesh = egui::Mesh::default(); - let n = 16; - for j in 0..=n { - for i in 0..=n { - let (sx, vy) = (i as f32 / n as f32, j as f32 / n as f32); - let c = hsva_color32(egui::ecolor::Hsva::new(hsva.h, sx, 1.0 - vy, 1.0)); - mesh.colored_vertex(pos2(field.left() + sx * field.width(), field.top() + vy * field.height()), c); - } - } - for j in 0..n { - for i in 0..n { - let a = (j * (n + 1) + i) as u32; - let b = a + 1; - let c = a + (n + 1) as u32; - let d = c + 1; - mesh.add_triangle(a, b, d); - mesh.add_triangle(a, d, c); - } - } - ui.painter().add(mesh); + let at = |x: f32, y: f32| { + if brightness { egui::ecolor::Hsva::new(x.min(0.9999), 1.0 - y, hsva.v, 1.0) } else { egui::ecolor::Hsva::new(hsva.h, x, 1.0 - y, 1.0) } + }; + ui.painter().add(color_grid(field, 16, |x, y| hsva_color32(at(x, y)))); ui.painter().rect_stroke(field, 0.0, Stroke::new(1.0, t.separator), StrokeKind::Outside); if (fresp.dragged() || fresp.clicked()) && let Some(p) = fresp.interact_pointer_pos() { - hsva.s = ((p.x - field.left()) / field.width()).clamp(0.0, 1.0); - hsva.v = 1.0 - ((p.y - field.top()) / field.height()).clamp(0.0, 1.0); + let x = ((p.x - field.left()) / field.width()).clamp(0.0, 1.0); + let y = ((p.y - field.top()) / field.height()).clamp(0.0, 1.0); + if brightness { + hsva.h = x.min(0.9999); + hsva.s = 1.0 - y; + } else { + hsva.s = x; + hsva.v = 1.0 - y; + } } - let knob = pos2(field.left() + hsva.s * field.width(), field.top() + (1.0 - hsva.v) * field.height()); + let (kx, ky) = if brightness { (hsva.h, 1.0 - hsva.s) } else { (hsva.s, 1.0 - hsva.v) }; + let knob = pos2(field.left() + kx * field.width(), field.top() + ky * field.height()); ui.painter().circle_stroke(knob, 5.0, Stroke::new(1.5, Color32::WHITE)); ui.painter().circle_stroke(knob, 6.5, Stroke::new(1.0, Color32::from_black_alpha(160))); - // Hue strip. + // The strip: hue (red at both ends, as Photoshop's) or brightness (the colour down to black). let (strip, sresp) = ui.allocate_exact_size(vec2(strip_w, h), Sense::click_and_drag()); - let mut m2 = egui::Mesh::default(); - let steps = 24; - for k in 0..=steps { - let f = k as f32 / steps as f32; - let c = hsva_color32(egui::ecolor::Hsva::new(1.0 - f, 1.0, 1.0, 1.0)); - m2.colored_vertex(pos2(strip.left(), strip.top() + f * strip.height()), c); - m2.colored_vertex(pos2(strip.right(), strip.top() + f * strip.height()), c); - } - for k in 0..steps { - let a = (k * 2) as u32; - m2.add_triangle(a, a + 1, a + 3); - m2.add_triangle(a, a + 3, a + 2); - } - ui.painter().add(m2); + let strip_at = |f: f32| { + if brightness { egui::ecolor::Hsva::new(hsva.h, hsva.s, 1.0 - f, 1.0) } else { egui::ecolor::Hsva::new(1.0 - f, 1.0, 1.0, 1.0) } + }; + ui.painter().add(color_grid(strip, 24, |_, y| hsva_color32(strip_at(y)))); if (sresp.dragged() || sresp.clicked()) && let Some(p) = sresp.interact_pointer_pos() { - hsva.h = 1.0 - ((p.y - strip.top()) / strip.height()).clamp(0.0, 0.9999); + let f = ((p.y - strip.top()) / strip.height()).clamp(0.0, 1.0); + if brightness { + hsva.v = 1.0 - f; + } else { + hsva.h = 1.0 - f.min(0.9999); + } } - let y = strip.top() + (1.0 - hsva.h) * strip.height(); + let y = strip.top() + (1.0 - if brightness { hsva.v } else { hsva.h }) * strip.height(); let tri = vec![pos2(strip.right() + 1.0, y), pos2(strip.right() + 6.0, y - 4.0), pos2(strip.right() + 6.0, y + 4.0)]; ui.painter().add(egui::Shape::convex_polygon(tri, t.text, Stroke::NONE)); if fresp.dragged() || fresp.clicked() || sresp.dragged() || sresp.clicked() { @@ -3737,9 +3690,31 @@ fn color_field(app: &mut PhotocraftApp, ui: &mut egui::Ui) { }); } +/// A smooth-shaded `n` x `n` grid over `rect`, coloured by `color(x, y)` with x and y in 0..1 +/// (y down). +pub(crate) fn color_grid(rect: Rect, n: usize, color: impl Fn(f32, f32) -> Color32) -> egui::Mesh { + let n = n.max(1); + let mut mesh = egui::Mesh::default(); + for j in 0..=n { + for i in 0..=n { + let (x, y) = (i as f32 / n as f32, j as f32 / n as f32); + mesh.colored_vertex(pos2(rect.left() + x * rect.width(), rect.top() + y * rect.height()), color(x, y)); + } + } + let row = (n + 1) as u32; + for j in 0..n as u32 { + for i in 0..n as u32 { + let a = j * row + i; + mesh.add_triangle(a, a + 1, a + row + 1); + mesh.add_triangle(a, a + row + 1, a + row); + } + } + mesh +} + /// Tool colours are sRGB-encoded floats; egui's Hsva works on sRGB bytes via these helpers /// (its `from_rgba_unmultiplied` expects *linear* RGB, which gave wrong readouts). -fn srgb_bytes(c: [f32; 4]) -> [u8; 3] { +pub(crate) fn srgb_bytes(c: [f32; 4]) -> [u8; 3] { let q = |v: f32| (v.clamp(0.0, 1.0) * 255.0 + 0.5) as u8; [q(c[0]), q(c[1]), q(c[2])] } @@ -3747,18 +3722,18 @@ fn srgb_bytes(c: [f32; 4]) -> [u8; 3] { /// The Color panel's HSB, as Photoshop's and the Color Picker's: on the sRGB-encoded values, /// so a 50% grey has Brightness 50%. egui's `Hsva` conversions work in linear light, which put /// that grey at 22% and drew the field's middle as 188 (#3323); `Hsva` only holds the numbers. -fn srgb_hsva(c: [f32; 4]) -> egui::ecolor::Hsva { +pub(crate) fn srgb_hsva(c: [f32; 4]) -> egui::ecolor::Hsva { let [h, s, v] = crate::color_picker_ui::rgb_to_hsv([c[0], c[1], c[2]].map(|v| v.clamp(0.0, 1.0))); egui::ecolor::Hsva::new(h / 360.0, s, v, 1.0) } -fn hsva_srgb(h: egui::ecolor::Hsva) -> [f32; 4] { +pub(crate) fn hsva_srgb(h: egui::ecolor::Hsva) -> [f32; 4] { let [r, g, b] = crate::color_picker_ui::hsv_to_rgb(h.h * 360.0, h.s.clamp(0.0, 1.0), h.v.clamp(0.0, 1.0)); [r, g, b, 1.0] } /// The colour to draw for Color panel HSB `h` (see [`srgb_hsva`]). -fn hsva_color32(h: egui::ecolor::Hsva) -> Color32 { +pub(crate) fn hsva_color32(h: egui::ecolor::Hsva) -> Color32 { let [r, g, b] = srgb_bytes(hsva_srgb(h)); Color32::from_rgb(r, g, b) } @@ -3766,7 +3741,7 @@ fn hsva_color32(h: egui::ecolor::Hsva) -> Color32 { /// The Color panel's editable colour readout: a hex field and R, G, B fields, all drawn like the /// dock's [`widgets::value_field`] so they sit in the theme. Editing any of them sets `color` /// (sRGB-encoded floats) and returns `true`. -fn color_readout(ui: &mut egui::Ui, id: egui::Id, color: &mut [f32; 4]) -> bool { +pub(crate) fn color_readout(ui: &mut egui::Ui, id: egui::Id, color: &mut [f32; 4]) -> bool { let t = Tokens::get(ui.ctx()); let mut changed = false; // Wrapped so the fields fold onto a second line in a narrow dock instead of being clipped. @@ -4283,7 +4258,7 @@ mod color_tests { let mut h = egui_kittest::Harness::builder().with_size(vec2(300.0, 300.0)).build_ui_state( |ui, app: &mut PhotocraftApp| { if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { - color_picker(app, ui); + color_field(app, ui); } }, app, @@ -4408,7 +4383,7 @@ mod color_tests { let mut h = egui_kittest::Harness::builder().with_size(vec2(300.0, 300.0)).build_ui_state( |ui, app: &mut PhotocraftApp| { if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { - color_picker(app, ui); + color_field(app, ui); } }, app, @@ -4461,36 +4436,6 @@ mod color_tests { assert_eq!(srgb_bytes(h.state().session.tools.foreground), [0x00, 0x33, 0x00]); } - #[test] - fn hue_and_saturation_fields_take_values_on_black() { - use egui_kittest::kittest::Queryable; - let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); - app.session.tools.foreground = [0.0, 0.0, 0.0, 1.0]; - let mut h = egui_kittest::Harness::builder().with_size(vec2(300.0, 300.0)).build_ui_state( - |ui, app: &mut PhotocraftApp| { - if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { - hsb_sliders(app, ui); - } - }, - app, - ); - PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::Studio); - h.run_steps(2); - // Hue, Saturation, Brightness, typed one key per frame. Black has no hue or saturation of its - // own, so the first two used to reset to 0 and this ended on white. - for (field, typed) in [(0, "120"), (1, "100"), (2, "100")] { - h.query_all_by_role(egui::accesskit::Role::SpinButton).nth(field).unwrap().click(); - h.run_steps(1); - for ch in typed.chars() { - h.event(egui::Event::Text(ch.to_string())); - h.run_steps(1); - } - h.key_press(egui::Key::Tab); - h.run_steps(2); - } - assert_eq!(srgb_bytes(h.state().session.tools.foreground), [0, 255, 0]); - } - /// The Color field fills the dock group, never shrinks below 120 pt, and ignores a bad height. #[test] fn color_field_height_fills_the_group() { @@ -5037,11 +4982,11 @@ mod swatch_type_tests { use super::*; use egui_kittest::Harness; - /// The HSB sliders only act on an edit. Their h/s/v round trip isn't exact for every colour - /// (#D8452E isn't), and comparing values used to rewrite the foreground every frame, which - /// would recolour selected type the moment it was selected. + /// The Color field only acts on an edit. Its h/s/v round trip isn't exact for every colour + /// (#D8452E isn't), and writing it back every frame would recolour selected type the moment it + /// was selected. #[test] - fn idle_hsb_sliders_leave_the_foreground_and_selected_type_alone() { + fn idle_color_field_leaves_the_foreground_and_selected_type_alone() { let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); app.run("file.new", json!({"width": 400, "height": 200})).unwrap(); let id = app.run("type.create", json!({"text": "Hello world", "size": 40, "x": 20, "y": 100, "color": "#ffffff"})).unwrap()["layer"].as_u64().unwrap(); @@ -5059,7 +5004,7 @@ mod swatch_type_tests { resize: None, preedit: None, }); - let mut h = Harness::builder().with_size(vec2(300.0, 300.0)).build_ui_state(|ui, app: &mut PhotocraftApp| color_picker(app, ui), app); + let mut h = Harness::builder().with_size(vec2(300.0, 300.0)).build_ui_state(|ui, app: &mut PhotocraftApp| color_field(app, ui), app); h.run_steps(4); assert_eq!(h.state().session.tools.foreground, fg); let st = h.state().session.active().unwrap(); diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 5cbda434e7..5bb0877155 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -1050,10 +1050,100 @@ pub struct DockTabs { /// Color panel state. #[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)] -#[serde(default)] +#[serde(rename_all = "camelCase", default)] pub struct ColorPanelState { /// The panel edits the background colour (its chip was clicked), not the foreground. pub background: bool, + /// What the panel shows, picked from its panel menu as in Photoshop (#6000). + pub mode: ColorPanelMode, + /// The colour ramp under the sliders. + pub ramp: ColorRamp, + /// Make Ramp Web Safe: the ramp shows (and picks) web colours only. + pub web_safe_ramp: bool, +} + +/// The Color panel's display, Photoshop's panel menu choices in its order. Hue Cube is +/// Photoshop's default; the theme never changes it (#6000). +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum ColorPanelMode { + #[default] + HueCube, + BrightnessCube, + ColorWheel, + GrayscaleSlider, + RgbSliders, + HsbSliders, + CmykSliders, + LabSliders, + WebColorSliders, +} + +impl ColorPanelMode { + /// Every mode, in Photoshop's panel menu order. + pub const ALL: [ColorPanelMode; 9] = [ + ColorPanelMode::HueCube, + ColorPanelMode::BrightnessCube, + ColorPanelMode::ColorWheel, + ColorPanelMode::GrayscaleSlider, + ColorPanelMode::RgbSliders, + ColorPanelMode::HsbSliders, + ColorPanelMode::CmykSliders, + ColorPanelMode::LabSliders, + ColorPanelMode::WebColorSliders, + ]; + + /// The panel menu item. + pub fn label(self) -> &'static str { + match self { + ColorPanelMode::HueCube => "Hue Cube", + ColorPanelMode::BrightnessCube => "Brightness Cube", + ColorPanelMode::ColorWheel => "Color Wheel", + ColorPanelMode::GrayscaleSlider => "Grayscale Slider", + ColorPanelMode::RgbSliders => "RGB Sliders", + ColorPanelMode::HsbSliders => "HSB Sliders", + ColorPanelMode::CmykSliders => "CMYK Sliders", + ColorPanelMode::LabSliders => "Lab Sliders", + ColorPanelMode::WebColorSliders => "Web Color Sliders", + } + } + + /// The slider modes, which show the colour ramp under their sliders. + pub fn is_sliders(self) -> bool { + !matches!(self, ColorPanelMode::HueCube | ColorPanelMode::BrightnessCube | ColorPanelMode::ColorWheel) + } +} + +/// The Color panel's colour ramp, from its panel menu (or Shift-click on the ramp to cycle). +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum ColorRamp { + #[default] + RgbSpectrum, + CmykSpectrum, + GrayscaleRamp, + CurrentColors, +} + +impl ColorRamp { + /// Every ramp, in Photoshop's panel menu order (also the Shift-click cycle). + pub const ALL: [ColorRamp; 4] = [ColorRamp::RgbSpectrum, ColorRamp::CmykSpectrum, ColorRamp::GrayscaleRamp, ColorRamp::CurrentColors]; + + /// The panel menu item. + pub fn label(self) -> &'static str { + match self { + ColorRamp::RgbSpectrum => "RGB Spectrum", + ColorRamp::CmykSpectrum => "CMYK Spectrum", + ColorRamp::GrayscaleRamp => "Grayscale Ramp", + ColorRamp::CurrentColors => "Current Colors", + } + } + + /// The next ramp in the Shift-click cycle. + pub fn next(self) -> ColorRamp { + let i = ColorRamp::ALL.iter().position(|r| *r == self).unwrap_or(0); + ColorRamp::ALL.get(i + 1).copied().unwrap_or(ColorRamp::RgbSpectrum) + } } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -1232,7 +1322,7 @@ pub struct UiState { /// One-frame focus/raise request from an explicit panel reveal. #[serde(skip)] pub docking_reveal: Option, - /// Which chip the Color panel edits. + /// Which chip the Color panel edits, and how it shows the colour. #[serde(default)] pub color_panel: ColorPanelState, /// Brush Settings: selected section (0 = Brush Tip Shape) and tab (0 settings, 1 Brushes). diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 8536507104..04802ccd9d 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -47,7 +47,7 @@ The transport is `apps/photocraft/src/control_server.rs`, and the handlers are i - `engine.execute {command, params}`: run any engine or UI command by id. Engine commands run directly with their default params and never open a dialog. Use `ui.menu.invoke` for menu-click behaviour, which opens a command's dialog when no params are given. `params` must be a JSON object (omit it or pass `null` for none); an array, string, number or boolean is an error naming the command, in every transport (control channel, `serve`, MCP and the CLI) - `engine.commands`: list commands with enablement; the `result` is a JSON array of command objects (see [Command list replies](#command-list-replies)) - `ui.inspect`: full UI state (tool, panels, views, dialogs, windows, window size). The menu tree is not included; use `ui.menu.list`. `brushPicker` is `null` while closed and `{pos: [x, y], size: [w, h]?, list: {collapsed, filter, renaming, showName, showStroke, showTip, scale}}` while the Brush Preset picker is open (coordinates in screen points; `size` is the picker's content size once its corner grip was dragged, `null` before that, and the drag remembers both dimensions; the three `show*` flags pick the parts of each preset's card — at least one is always on; `scale` is the footer slider, 0.15–2 with 1 the standard, multiplying the cards' width and height — the heights stop at half size and the name and tip-size text hold their 1.0 size — and dropping the tips' size numbers at 0.40 and below; the parts and the scale are remembered across restarts, while the search, collapsed groups and a rename in progress are not). `view` holds the View/Window/Type preferences: `screen_mode`, `extras`, `show` and `snap_to` flags, `flip_horizontal`, `arrange` (Window › Arrange layout), pixel aspect, font preview size, language options. `perf.timings.gpuInfo` holds the graphics adapter, backend, driver, the backend chosen at launch and why, the canvas renderer (`gpu`/`cpu`) and, after a device loss, `lost` (`help.systemInfo` returns the same as `info`) -- `ui.set {tool?, panels?, dockTabs?, dock?, dockWidth?, colorPanel?, maskTarget?, vectorMaskTarget?, selectionMode?, zoom?, center?, rotation?, fit?, theme?, brushSize?, brushSection?, brushTab?, brushesView?, brushPicker?, brushPickerName?, brushPickerStroke?, brushPickerTip?, brushPickerScale?, gradientBlendMode?, gradientClassic?, shapeStroke?}`: change UI state; any other field is an error, checked before anything changes (`zoom` is the canvas zoom where 1 = 100%, one document pixel per physical display pixel, so a scaled display doesn't magnify the image; `theme` is `pro`, `proMedium`, `studio`, `studioLight` or `classic`; `selectionMode` is the selection tools' options-bar mode, 0 New, 1 Add, 2 Subtract, 3 Intersect; `brushSection` indexes the Brush Settings sections, `brushTab` 0 = Brush Settings, 1 = Brushes; `brushesView` is `list` or `grid` for the Brushes panel; `brushPickerName`, `brushPickerStroke` and `brushPickerTip` are the Brush Preset picker's card parts (booleans, at least one on), and `brushPickerScale` its footer card-scale slider (0.15 to 2, 1 the standard); `brushPicker` is `[x, y]` in screen points to open the Brush Preset picker there (as a right-click with a painting tool does) or `null` to close it, and picking a preset in it is `tools.setBrush {"preset": name}`; `dock` is `{order: ["layers", …], heights: {"properties": 180}, collapsed: ["color"], tabOrder: {"layers": ["Paths", "Layers", "Channels"]}}`, the right-dock groups top to bottom, their heights in points, the groups collapsed to their tab strip and each group's tab order left to right by panel name (a group left out keeps its default order, unknown names are ignored and tabs not listed follow in their default order; `dockTabs` keeps indexing tabs in their default order); `dockWidth` sets the right dock width in points, clamped to 250..520; `colorPanel` is `{background}`, whether the Color panel edits the background colour; `maskTarget` targets the active layer's mask, which, like Photoshop, swaps in the foreground/background pair kept for masks (white/black until one is picked) and swaps the pixels' pair back when the pixels are targeted again) +- `ui.set {tool?, panels?, dockTabs?, dock?, dockWidth?, colorPanel?, maskTarget?, vectorMaskTarget?, selectionMode?, zoom?, center?, rotation?, fit?, theme?, brushSize?, brushSection?, brushTab?, brushesView?, brushPicker?, brushPickerName?, brushPickerStroke?, brushPickerTip?, brushPickerScale?, gradientBlendMode?, gradientClassic?, shapeStroke?}`: change UI state; any other field is an error, checked before anything changes (`zoom` is the canvas zoom where 1 = 100%, one document pixel per physical display pixel, so a scaled display doesn't magnify the image; `theme` is `pro`, `proMedium`, `studio`, `studioLight` or `classic`; `selectionMode` is the selection tools' options-bar mode, 0 New, 1 Add, 2 Subtract, 3 Intersect; `brushSection` indexes the Brush Settings sections, `brushTab` 0 = Brush Settings, 1 = Brushes; `brushesView` is `list` or `grid` for the Brushes panel; `brushPickerName`, `brushPickerStroke` and `brushPickerTip` are the Brush Preset picker's card parts (booleans, at least one on), and `brushPickerScale` its footer card-scale slider (0.15 to 2, 1 the standard); `brushPicker` is `[x, y]` in screen points to open the Brush Preset picker there (as a right-click with a painting tool does) or `null` to close it, and picking a preset in it is `tools.setBrush {"preset": name}`; `dock` is `{order: ["layers", …], heights: {"properties": 180}, collapsed: ["color"], tabOrder: {"layers": ["Paths", "Layers", "Channels"]}}`, the right-dock groups top to bottom, their heights in points, the groups collapsed to their tab strip and each group's tab order left to right by panel name (a group left out keeps its default order, unknown names are ignored and tabs not listed follow in their default order; `dockTabs` keeps indexing tabs in their default order); `dockWidth` sets the right dock width in points, clamped to 250..520; `colorPanel` is `{background?, mode?, ramp?, webSafeRamp?}`, merged into the Color panel's state: `background` is whether it edits the background colour, `mode` its panel-menu display (`hueCube`, `brightnessCube`, `colorWheel`, `grayscaleSlider`, `rgbSliders`, `hsbSliders`, `cmykSliders`, `labSliders` or `webColorSliders`), `ramp` the colour ramp under the sliders (`rgbSpectrum`, `cmykSpectrum`, `grayscaleRamp` or `currentColors`) and `webSafeRamp` Make Ramp Web Safe; `maskTarget` targets the active layer's mask, which, like Photoshop, swaps in the foreground/background pair kept for masks (white/black until one is picked) and swaps the pixels' pair back when the pixels are targeted again) - `typeTransform` is `null` outside a temporary Ctrl/Cmd Type-tool drag. During a drag it reports its source document/revision, original affine, oriented `frame` (layer, local bounds, document-space corners and pivot), and captured `gesture`. Drive it with `ui.pointer` and `command: true` at `down`; `move`/`up` may release the modifier. The document/history remain unchanged during preview, and `up` applies one `type.edit` within `textEdit`'s session. Pressing Escape during the drag cancels only the preview. This pointer state is never restored from saved UI state. - `ui.menu.invoke {id, params?, wait?}` / `ui.menu.list`: activate a menu item by id; list the menu tree. A menu item that starts a background job (a filter without a dialog, such as Blur More) replies with the job's result once it has been applied; with `"wait": false` the reply is `{job, pending: true}` at once. Window ends with the open documents as `window.document.` (tab order, the active one checked, #2991); invoking one brings that document to the front and replies `{document: index}` - `ui.set` also accepts `gradientBlendMode` (a layer blend mode name, such as `Difference`) and `gradientClassic` (boolean) for the Gradient tool options bar. diff --git a/docs/gaps.md b/docs/gaps.md index faf0884c89..9b3f567eae 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where PhotoCraft falls short of Photoshop -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-15 · **Change:** minor (G9: Color panel modes, ramp and copy commands, the same in every theme, UI-217-17, #6000; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 @@ -197,9 +197,11 @@ what an agent can't finish alone. ### G9. Panels, preferences and workspace - **Progress (2026-10-12):** toolbar tool shortcuts can be reassigned, removed and reset (#4086), with saved bindings, matching toolbar hints and regression coverage (`ui-egui/src/tool_shortcuts.rs`). +- **Progress (2026-10-15):** the Color panel has Photoshop's panel-menu modes (Hue Cube, Brightness + Cube, Color Wheel, Grayscale/RGB/HSB/CMYK/Lab/Web Color sliders), its colour ramp and copy + commands, the same in every theme (UI-217-17, #2569, #6000; `ui-egui/src/color_panel_ui.rs`). - **Missing:** 27 of 156 preferences do nothing (scorecard prefs audit); panel groups can't - float or tear off into OS windows (UI-217-5, #1828, #1213, #2305); Color panel lacks wheel and - slider modes (UI-217-17, #2569); more themes (UI-217-11, #2661); layer clipboard + float or tear off into OS windows (UI-217-5, #1828, #1213, #2305); more themes (UI-217-11, #2661); layer clipboard (UI-217-23, #2670); tool-specific context menus beyond brushes, selections and Pen ([context-menu-parity.md](context-menu-parity.md)); Libraries, Comments, Contextual Task Bar panels. @@ -270,6 +272,7 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| +| 2026-10-15 | minor | G9: Color panel modes, ramp and copy commands from its panel menu, the same in every theme (UI-217-17 done, #6000) | | 2026-10-14 | minor | G1: a PSD smart object's filter mask shows when the file opens (Photoshop stores the filtered pixels unmasked); export stores them that way too; Photoshop-oracle floor 185 → 188 of 258 | | 2026-10-13 | minor | G14: D90 image area measured (4288 × 2848 at (10, 10)); gap remains open | | 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 | diff --git a/docs/scorecard.md b/docs/scorecard.md index 1e0576ba02..62ff17f281 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -9,7 +9,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 | 14 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | | [Tools](#tools) | 33 | 11 | 0 | | -| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 166 (target 0) | +| [Workspace and UI](#workspace-and-ui) | 14 | 6 | 3 | settings that do nothing: 26 of 166 (target 0) | | [Type](#type) | 4 | 3 | 2 | | | [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) | | [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 29 of 29 crates; panic_hunt present | @@ -199,7 +199,7 @@ Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_w | UI-217-14 | Layers panel: wheel steps blend modes, drop on New/Trash duplicates/deletes, checker behind art | done | [#217](https://github.com/storytold/photocraft/issues/217) | panels.rs: the wheel steps the blend-mode dropdown (widgets::dropdown_wheel_hovered, #1747); rows dropped on New Layer/Group/Delete duplicate/group/delete them (footer_drop, #736), effect rows dropped on Delete delete that effect or the whole style (fx_trash_drop, #3102); pixel thumbnails draw widgets::checker behind the art; Shift+Plus/Minus step the layer's or the painting tool's blend mode (blend_keys.rs, #3102) | | UI-217-15 | Curves: smoothing / pencil mode, black/grey/white eyedroppers, tooltips | done | [#217](https://github.com/storytold/photocraft/issues/217) | Curves editor (adjust_editors.rs, dialog and Properties): Edit points / Draw (pencil) buttons and Smooth, all with tooltips; pencil curves are 256-level maps (Adjustment::Curves pencil, params pencil/smooth, PSD curv map form and smart-filter Mpng; #3088). Set Black/Neutral Gray/White Point eyedroppers in the Image > Adjustments > Curves dialog (adjust_dialog.rs, #873) and in a Curves adjustment layer's Properties panel (layer_picker.rs: a click on the image is one layer.setAdjustment with the eyedropper param, sampling below the layer; Esc or another tool disarms; #3110) | | UI-217-16 | Hue/Saturation: Saturation and Lightness sliders get hue-following colour tracks | done | [#217](https://github.com/storytold/photocraft/issues/217) | saturation_track/lightness_track (adjust_editors.rs): grey -> the hue and black -> the hue -> white, recolouring as the Hue slider moves; saturation_and_lightness_tracks_follow_the_hue | -| UI-217-17 | Color panel: wheel plus RGB/HSB/CMYK/Lab/Gray/Web slider modes; resizes with its group | missing | [#217](https://github.com/storytold/photocraft/issues/217) | panels.rs:1837 single field + hex/RGB readout | +| UI-217-17 | Color panel: wheel plus RGB/HSB/CMYK/Lab/Gray/Web slider modes; resizes with its group | done | [#217](https://github.com/storytold/photocraft/issues/217) | color_panel_ui.rs: Hue/Brightness Cube, Color Wheel, Grayscale/RGB/HSB/CMYK/Lab/Web sliders, ramp; the same in every theme (#6000); color_panel_tests.rs | | UI-217-18 | Alt+wheel zooms in gentle ~5 % steps; zoom controls uncramped | missing | [#217](https://github.com/storytold/photocraft/issues/217) | canvas.rs:1107-1125 no Alt handling | | UI-217-19 | Shortcut hints rendered per platform; Reveal label per OS | done | [#217](https://github.com/storytold/photocraft/issues/217) | hints and tooltips go through shortcuts::pretty (6266b7a9, #262; pretty_uses_the_platform_notation); menus::reveal_label names Reveal in Finder per OS (Show in Explorer / Show in Folder) in the Smart Objects menu and the tab menu; reveal_label_names_the_platform_file_manager + smart_objects_reveal_item_names_the_platform_file_manager | | UI-217-20 | 'Show rulers in new documents' preference; guides stored as f64 | done | [#217](https://github.com/storytold/photocraft/issues/217) | View › Rulers is remembered in unitsAndRulers.showRulers and applied at launch and on change (#2918; rulers_open_as_last_set_after_a_restart); doc Guides are Vec through New Guide, .pcraft and PSD 1032 (guides_keep_sub_pixel_positions_through_pcraft_and_psd) | diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 6edff953df..2a2541e47b 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI parity: tools, handles, modifiers and feel -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-15 · **Change:** minor (Color panel modes from its panel menu, the same in every theme, UI-217-17, #6000; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; 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, @@ -208,7 +208,7 @@ Paragraph; the rest open as in-app floating windows. | Panel groups float and tear off into OS windows | missing | UI-217-5, #1828, #1213 | | Drag panels to reorder and regroup | partial | #2272, #2305 | | Docked resize pushes the neighbour | partial | #2573 | -| Color panel wheel and RGB/HSB/CMYK/Lab sliders | missing | UI-217-17, #2569 | +| Color panel modes from its panel menu (Hue Cube, Brightness Cube, Color Wheel, Grayscale/RGB/HSB/CMYK/Lab/Web Color sliders), colour ramp (RGB/CMYK Spectrum, Grayscale Ramp, Current Colors, Make Ramp Web Safe; Shift-click cycles, Alt-click picks the other colour), Copy Color as HTML / Hex Code; the same in every theme | done | `color_panel_ui.rs`, `color_panel_tests.rs`; UI-217-17, #2569, #6000 | | Window size and dock width remembered | done | UI-217-2 | | Command palette with recents | done | UI-217-7 | | Menu bar from the keyboard: Alt / F10 focus the bar, ← → ↓ ↩ drive it, Alt+letter opens a menu, underlined mnemonics run items | done | `menu_keys.rs`, #4988; macOS uses the native bar | @@ -256,3 +256,4 @@ Paragraph; the rest open as in-app floating windows. | 2026-10-14 | minor | Last selected tool restored across launches; temporary overrides excluded, explicit Eraser choices retained, and final selection flushed on normal exit | | 2026-10-13 | minor | Free Transform with a selection: the box is the selection's rectangle, and the marching ants follow it while it is transformed (#5297) | | 2026-10-14 | minor | Move › Show Transform Controls frames every selected layer and outlines the selected shapes | +| 2026-10-15 | minor | Color panel: Photoshop's panel-menu modes, colour ramp and copy commands; the theme no longer picks the panel's layout (UI-217-17 done, #2569, #6000) | diff --git a/scorecard/ui.toml b/scorecard/ui.toml index 4ac0ce6386..94bdebe648 100644 --- a/scorecard/ui.toml +++ b/scorecard/ui.toml @@ -120,9 +120,9 @@ note = "saturation_track/lightness_track (adjust_editors.rs): grey -> the hue an [[item]] id = "UI-217-17" target = "Color panel: wheel plus RGB/HSB/CMYK/Lab/Gray/Web slider modes; resizes with its group" -status = "missing" +status = "done" issue = 217 -note = "panels.rs:1837 single field + hex/RGB readout" +note = "color_panel_ui.rs: Hue/Brightness Cube, Color Wheel, Grayscale/RGB/HSB/CMYK/Lab/Web sliders, ramp; the same in every theme (#6000); color_panel_tests.rs" [[item]] id = "UI-217-18" From 2160d5d735b528a818a3fff146e86a4a39c334f3 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 01:35:30 -0700 Subject: [PATCH 083/649] feat(engine): add type.fillPath to wrap type inside a closed path Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/commands.rs | 1 + crates/engine/src/lib.rs | 1 + crates/engine/src/type_area_cmds.rs | 97 ++++++++++++++++++ crates/engine/src/type_area_cmds/tests.rs | 115 ++++++++++++++++++++++ crates/engine/src/type_extra_cmds.rs | 2 +- 5 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 crates/engine/src/type_area_cmds.rs create mode 100644 crates/engine/src/type_area_cmds/tests.rs diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs index 7ddad80737..9f5b359cde 100644 --- a/crates/engine/src/commands.rs +++ b/crates/engine/src/commands.rs @@ -1356,6 +1356,7 @@ fn build() -> Vec { v.extend(crate::file_cmds::specs()); v.extend(crate::exr_cmds::specs()); v.extend(crate::type_extra_cmds::specs()); + v.extend(crate::type_area_cmds::specs()); v.extend(crate::type_styles_cmds::specs()); v.extend(crate::type_spell_cmds::specs()); v.extend(crate::type_caret_cmds::specs()); diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index d2aecf37db..40316fd9fd 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -115,6 +115,7 @@ pub mod symmetry_cmds; mod timeline_cmds; pub mod transform_cmds; mod trap_cmds; +pub mod type_area_cmds; pub mod type_caret_cmds; pub mod type_cmds; pub mod type_extra_cmds; diff --git a/crates/engine/src/type_area_cmds.rs b/crates/engine/src/type_area_cmds.rs new file mode 100644 index 0000000000..09b22b0fca --- /dev/null +++ b/crates/engine/src/type_area_cmds.rs @@ -0,0 +1,97 @@ +//! Area type (#218): type that wraps inside a closed path, like Photoshop's Type tool clicked +//! inside a closed path or shape. `type.detachFromPath` (type_extra_cmds.rs) releases it. + +use photocraft_doc::text::TextShape; +use photocraft_doc::vector::{Knot, Path}; +use photocraft_doc::{Document, LayerContent, LayerId}; +use photocraft_geom::Point; +use serde_json::{Value, json}; + +use crate::commands::{CommandSpec, layer_param}; +use crate::type_extra_cmds::with_text; +use crate::{EngineError, Result, Session}; + +const CMD: &str = "type.fillPath"; + +/// Largest total anchor count of a path area type can fill (as for type on a path). +const MAX_AREA_KNOTS: usize = 100_000; + +fn bad(m: &str) -> EngineError { + EngineError::BadParams { cmd: CMD.into(), msg: m.into() } +} + +fn has_text(s: &Session) -> std::result::Result<(), String> { + let d = s.active().ok_or("no document open")?; + match d.active_layer.and_then(|id| d.doc.layer(id)).map(|l| &l.content) { + Some(LayerContent::Text(_)) => Ok(()), + _ => Err("the active layer is not a type layer".into()), + } +} + +/// The path area type fills, in document space: the work path (default) or a shape layer's +/// path (`"shape":id`). Every closed subpath counts, with its path operation. +fn area_source(doc: &Document, p: &Value) -> Result { + let path = match p.get("shape") { + None | Some(Value::Null) => doc.work_path.as_ref().ok_or_else(|| bad("the document has no work path; draw a closed path or pass \"shape\":layerId"))?, + Some(v) => { + let id = v.as_u64().ok_or_else(|| bad("\"shape\" must be a layer id"))?; + match doc.layer(LayerId(id)).map(|l| &l.content) { + Some(LayerContent::Shape(sh)) => &sh.path, + Some(_) => return Err(bad("\"shape\" is not a shape layer")), + None => return Err(EngineError::NoLayer(LayerId(id))), + } + } + }; + let knots = path.subpaths.iter().fold(0usize, |n, s| n.saturating_add(s.knots.len())); + if knots > MAX_AREA_KNOTS { + return Err(bad("the path has too many anchor points")); + } + if path.inverted { + return Err(bad("an inverted path has no inside to fill")); + } + Ok(path.clone()) +} + +fn fill_path(s: &mut Session, p: &Value) -> Result { + let id = layer_param(s, p)?; + let doc = &s.active().ok_or(EngineError::NoDocument)?.doc; + if doc.effective_locks(id).all { + return Err(EngineError::Other("the type layer is locked".into())); + } + let source = area_source(doc, p)?; + let n = source.subpaths.len(); + with_text(s, p, "Area Type", |t, _| { + // The path is in document space; the layer keeps it in text space so the type lands + // inside the path where it is drawn. + let inv = t.transform.inverse().ok_or_else(|| EngineError::Other("the type layer's transform cannot be inverted".into()))?; + let map = |q: Point| inv.apply(q); + let mut path = source.clone(); + for k in path.subpaths.iter_mut().flat_map(|s| s.knots.iter_mut()) { + *k = Knot { anchor: map(k.anchor), in_ctrl: map(k.in_ctrl), out_ctrl: map(k.out_ctrl), smooth: k.smooth }; + } + let vertical = t.orientation == photocraft_doc::text::Orientation::Vertical; + if photocraft_text::area::AreaShape::new(&path, vertical).is_none() { + return Err(bad("the path encloses no area; draw a closed path")); + } + t.shape = TextShape::Area { path }; + Ok(()) + })?; + Ok(json!({"layer": id.0, "subpaths": n})) +} + +pub fn specs() -> Vec { + vec![CommandSpec { + id: CMD, + label: "Area Type", + menu: &[], + shortcut: None, + params: r##"{"layer":id? (default active Type layer),"shape":layerId? (a shape layer; default the work path)} → the text wraps inside the path's closed subpaths, holes included"##, + enabled: has_text, + journal: true, + run: fill_path, + }] +} + +#[cfg(test)] +#[path = "type_area_cmds/tests.rs"] +mod tests; diff --git a/crates/engine/src/type_area_cmds/tests.rs b/crates/engine/src/type_area_cmds/tests.rs new file mode 100644 index 0000000000..083b01ffce --- /dev/null +++ b/crates/engine/src/type_area_cmds/tests.rs @@ -0,0 +1,115 @@ +use super::*; +use photocraft_doc::text::TextShape; +use photocraft_doc::vector::{Path, PathOp, Subpath}; +use photocraft_doc::{LayerContent, LayerId, TextLayer}; +use serde_json::json; + +fn session(depth: u32) -> Session { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 400, "height": 300, "depth": depth, "background": "white"})).unwrap(); + s +} + +fn text_layer(s: &mut Session, text: &str) -> LayerId { + let r = s.execute("type.create", json!({"x": 100, "y": 100, "text": text, "size": 14, "color": "#000000"})).unwrap(); + LayerId(r["layer"].as_u64().unwrap()) +} + +fn text(s: &Session, id: LayerId) -> &TextLayer { + match &s.active().unwrap().doc.layer(id).unwrap().content { + LayerContent::Text(t) => t, + c => panic!("not text: {}", c.kind_name()), + } +} + +fn set_work_path(s: &mut Session, p: Path) { + s.edit("path", |doc, _| { + doc.work_path = Some(p); + Ok(()) + }) + .unwrap(); +} + +const WORDS: &str = "Well, that went better than expected. Now where did the cat hide the keys?"; + +#[test] +fn fill_path_wraps_text_inside_the_work_path_in_one_step() { + for depth in [8, 16, 32] { + let mut s = session(depth); + let id = text_layer(&mut s, WORDS); + set_work_path(&mut s, Path::new(vec![Subpath::polygon(&[(50.0, 50.0), (250.0, 50.0), (250.0, 200.0), (50.0, 200.0)])])); + let steps = s.active().unwrap().history.entries().len(); + let r = s.execute("type.fillPath", json!({})).unwrap(); + assert_eq!(r["layer"], json!(id.0)); + assert_eq!(s.active().unwrap().history.entries().len(), steps + 1, "one history step"); + assert!(matches!(text(&s, id).shape, TextShape::Area { .. })); + // The ink stays inside the path, in document space. + let ink = s.active().unwrap().doc.layer(id).unwrap().surface().unwrap().content_bounds(); + assert!(ink.x0 >= 49 && ink.x1 <= 251 && ink.y0 >= 49 && ink.y1 <= 201, "depth {depth}: {ink:?}"); + assert!(ink.height() > 30, "several lines"); + assert!(s.undo()); + assert_eq!(text(&s, id).shape, TextShape::Point); + assert!(s.redo()); + assert!(matches!(text(&s, id).shape, TextShape::Area { .. })); + } +} + +#[test] +fn fill_path_uses_a_shape_layer_with_its_hole() { + let mut s = session(8); + let shape = s.execute("shape.create", json!({"kind": "rect", "rect": [20, 20, 300, 200], "fill": "#cccccc"})).unwrap()["layer"].as_u64().unwrap(); + s.execute("shape.create", json!({"kind": "rect", "rect": [140, 80, 60, 80], "addTo": shape, "op": "subtract"})).unwrap(); + let id = text_layer(&mut s, &WORDS.repeat(3)); + s.execute("type.fillPath", json!({"layer": id.0, "shape": shape})).unwrap(); + let TextShape::Area { path } = &text(&s, id).shape else { panic!("area") }; + assert_eq!(path.subpaths.len(), 2); + assert_eq!(path.subpaths[1].op, PathOp::Subtract); +} + +#[test] +fn fill_path_maps_the_path_into_text_space() { + let mut s = session(8); + let id = text_layer(&mut s, WORDS); // transform: translate(100, 100) + set_work_path(&mut s, Path::new(vec![Subpath::polygon(&[(100.0, 100.0), (300.0, 100.0), (300.0, 250.0), (100.0, 250.0)])])); + s.execute("type.fillPath", json!({})).unwrap(); + let TextShape::Area { path } = &text(&s, id).shape else { panic!("area") }; + let a = path.subpaths[0].knots[0].anchor; + assert!((a.x, a.y) == (0.0, 0.0), "{a:?}"); +} + +#[test] +fn fill_path_rejects_bad_paths_without_history() { + let mut s = session(8); + assert!(!s.is_enabled("type.fillPath"), "no type layer"); + let id = text_layer(&mut s, WORDS); + assert!(s.is_enabled("type.fillPath")); + let history = |s: &Session| s.active().unwrap().history.entries().len(); + // No work path. + assert!(s.execute("type.fillPath", json!({})).is_err()); + for bad in [ + Path::new(vec![Subpath::polyline(&[(0.0, 0.0), (90.0, 90.0), (0.0, 90.0)])]), // open only + Path::new(vec![Subpath::polygon(&[(0.0, 0.0), (90.0, 0.0), (180.0, 0.0)])]), // no area + Path::new(vec![Subpath::polygon(&[(0.0, 0.0), (f64::NAN, 0.0), (9.0, 9.0)])]), + { + let mut p = Path::new(vec![Subpath::polygon(&[(0.0, 0.0), (90.0, 0.0), (90.0, 90.0)])]); + p.inverted = true; + p + }, + Path::new(vec![Subpath::polygon(&(0..100_001).map(|i| ((i as f64).cos() * 90.0, (i as f64).sin() * 90.0)).collect::>())]), + ] { + set_work_path(&mut s, bad); + let h = history(&s); + assert!(s.execute("type.fillPath", json!({})).is_err()); + assert_eq!(history(&s), h, "no history step on error"); + assert_eq!(text(&s, id).shape, TextShape::Point); + } + for p in [json!({"shape": "x"}), json!({"shape": u64::MAX}), json!({"layer": u64::MAX})] { + assert!(s.execute("type.fillPath", p).is_err()); + } + // A shape param that is not a shape layer. + assert!(s.execute("type.fillPath", json!({"shape": id.0})).is_err()); + // Locked layer. + set_work_path(&mut s, Path::new(vec![Subpath::polygon(&[(0.0, 0.0), (200.0, 0.0), (200.0, 200.0)])])); + s.execute("layer.setProps", json!({"layer": id.0, "locked": true})).unwrap(); + assert!(s.execute("type.fillPath", json!({})).is_err()); +} diff --git a/crates/engine/src/type_extra_cmds.rs b/crates/engine/src/type_extra_cmds.rs index 569af27c96..907b991c4a 100644 --- a/crates/engine/src/type_extra_cmds.rs +++ b/crates/engine/src/type_extra_cmds.rs @@ -70,7 +70,7 @@ fn has_defaults(s: &Session) -> std::result::Result<(), String> { // ---------- helpers ---------- /// Edits a type layer as one history step and re-renders it. -fn with_text(s: &mut Session, p: &Value, label: &str, f: impl FnOnce(&mut TextLayer, &Document) -> Result) -> Result { +pub(crate) fn with_text(s: &mut Session, p: &Value, label: &str, f: impl FnOnce(&mut TextLayer, &Document) -> Result) -> Result { let id = layer_param(s, p)?; check_text_unlocked(&s.active().ok_or(EngineError::NoDocument)?.doc, id)?; s.edit(label, |doc, _| { From 19261c5f12ca236d44ea968f04d7d7076b3b9d97 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 01:47:51 -0700 Subject: [PATCH 084/649] feat(type): release area type to box text; warn when PSD can't keep it Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/type_area_cmds/tests.rs | 34 +++++++++++++++++++++++ crates/engine/src/type_extra_cmds.rs | 21 +++++++++----- crates/io/src/psd_export.rs | 4 +++ 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/crates/engine/src/type_area_cmds/tests.rs b/crates/engine/src/type_area_cmds/tests.rs index 083b01ffce..e8e72953bd 100644 --- a/crates/engine/src/type_area_cmds/tests.rs +++ b/crates/engine/src/type_area_cmds/tests.rs @@ -113,3 +113,37 @@ fn fill_path_rejects_bad_paths_without_history() { s.execute("layer.setProps", json!({"layer": id.0, "locked": true})).unwrap(); assert!(s.execute("type.fillPath", json!({})).is_err()); } + +#[test] +fn release_turns_area_type_into_box_text_over_the_path() { + let mut s = session(8); + let id = text_layer(&mut s, WORDS); + set_work_path(&mut s, Path::new(vec![Subpath::polygon(&[(100.0, 100.0), (300.0, 100.0), (300.0, 250.0)])])); + s.execute("type.fillPath", json!({})).unwrap(); + assert!(s.is_enabled("type.detachFromPath")); + assert!(!s.is_enabled("type.convertToPointText") && !s.is_enabled("type.convertToParagraphText")); + s.execute("type.detachFromPath", json!({})).unwrap(); + assert_eq!(text(&s, id).shape, TextShape::Box { x: 0.0, y: 0.0, width: 200.0, height: 150.0 }); + assert!(s.undo()); + assert!(matches!(text(&s, id).shape, TextShape::Area { .. })); +} + +#[test] +fn area_type_saves_to_psd_as_paragraph_text_with_a_warning() { + let mut s = session(8); + let id = text_layer(&mut s, WORDS); + set_work_path(&mut s, Path::new(vec![Subpath::polygon(&[(100.0, 100.0), (300.0, 100.0), (300.0, 250.0), (100.0, 250.0)])])); + s.execute("type.fillPath", json!({})).unwrap(); + let doc = s.active().unwrap().doc.clone(); + let r = photocraft_io::export(&doc, "x.psd", &photocraft_io::ExportOptions::default()).unwrap(); + assert!(r.warnings.iter().any(|w| w.contains("area type")), "{:?}", r.warnings); + let back = photocraft_io::import("x.psd", &r.bytes).unwrap().document; + let t = back.walk().into_iter().find_map(|(_, _, l)| match &l.content { + LayerContent::Text(t) => Some(t.clone()), + _ => None, + }); + let t = t.expect("still a type layer"); + assert_eq!(t.text, WORDS); + assert!(matches!(t.shape, TextShape::Box { width, height, .. } if (width - 200.0).abs() < 0.5 && (height - 150.0).abs() < 0.5), "{:?}", t.shape); + let _ = id; +} diff --git a/crates/engine/src/type_extra_cmds.rs b/crates/engine/src/type_extra_cmds.rs index 907b991c4a..533958c64d 100644 --- a/crates/engine/src/type_extra_cmds.rs +++ b/crates/engine/src/type_extra_cmds.rs @@ -393,7 +393,7 @@ fn attach_to_path(s: &mut Session, p: &Value) -> Result { fn is_path_text(s: &Session) -> std::result::Result<(), String> { match active_text(s)?.shape { - TextShape::Path { .. } => Ok(()), + TextShape::Path { .. } | TextShape::Area { .. } => Ok(()), _ => Err("the type layer is not on a path".into()), } } @@ -401,13 +401,20 @@ fn is_path_text(s: &Session) -> std::result::Result<(), String> { fn detach_from_path(s: &mut Session, p: &Value) -> Result { let id = layer_param(s, p)?; with_text(s, p, "Release Type from Path", |t, _| { - if !matches!(t.shape, TextShape::Path { .. }) { - return Err(EngineError::Other("the type layer is not on a path".into())); + match &t.shape { + TextShape::Path { .. } => { + // Point text starts where the type started on the path. + let origin = photocraft_text::warp::Warp::on_path(&t.shape).map_or((0.0, 0.0), |w| w.apply(0.0, 0.0)); + t.shape = TextShape::Point; + t.transform = then_translate(&t.transform, origin.0, origin.1); + } + // Area type keeps wrapping, in a text box over the path's bounds. + TextShape::Area { path } => { + let (x0, y0, x1, y1) = path.control_bounds().ok_or_else(|| EngineError::Other("the area type's path is empty".into()))?; + t.shape = TextShape::Box { x: x0 as f32, y: y0 as f32, width: ((x1 - x0) as f32).max(1.0), height: ((y1 - y0) as f32).max(1.0) }; + } + _ => return Err(EngineError::Other("the type layer is not on a path".into())), } - // Point text starts where the type started on the path. - let origin = photocraft_text::warp::Warp::on_path(&t.shape).map_or((0.0, 0.0), |w| w.apply(0.0, 0.0)); - t.shape = TextShape::Point; - t.transform = then_translate(&t.transform, origin.0, origin.1); Ok(()) })?; Ok(json!({"layer": id.0})) diff --git a/crates/io/src/psd_export.rs b/crates/io/src/psd_export.rs index 8ba30d83c4..7265c0ccb9 100644 --- a/crates/io/src/psd_export.rs +++ b/crates/io/src/psd_export.rs @@ -625,6 +625,10 @@ impl Ex { crate::vector_map::shape_blocks(sh, &mut raw, w, h, self.dpi); } LayerContent::Text(t) => { + if matches!(t.shape, photocraft_doc::text::TextShape::Area { .. }) { + self.warnings + .push(format!("layer \"{}\": area type is saved as paragraph text over its path's bounds (PSD area type is not written yet)", l.name)); + } // Text layers without PSD data (created here) get a generated TySh. let generated = t.psd_raw.is_none().then(|| std::sync::Arc::new(photocraft_text::psd::build_tysh(t, self.dpi, None))); let src = t.psd_raw.as_ref().or(generated.as_ref()); From d2856e6ecb3e40d9cb7f20a98147ea4545dd3965 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 01:51:37 -0700 Subject: [PATCH 085/649] test(format): area type round-trips through .pcraft Co-Authored-By: Claude Opus 5.5 --- crates/format/tests/roundtrip.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crates/format/tests/roundtrip.rs b/crates/format/tests/roundtrip.rs index f78e93947e..a3b09cc3cd 100644 --- a/crates/format/tests/roundtrip.rs +++ b/crates/format/tests/roundtrip.rs @@ -562,6 +562,32 @@ fn path_text_shape_roundtrips() { assert_eq!(shape, Some(TextShape::Path { path, start: 12.5, flip: true })); } +/// Area type (#218): the whole path, ops and fill rule included, survives .pcraft. +#[test] +fn area_text_shape_roundtrips() { + use photocraft_doc::text::TextShape; + use photocraft_doc::vector::{FillRule, Path, PathOp, Subpath}; + let mut doc = rich_doc(ColorMode::Rgb, SampleType::U8); + let mut path = Path::new(vec![ + Subpath::polygon(&[(0.0, 0.0), (200.0, 0.0), (200.0, 120.0), (0.0, 120.0)]), + Subpath::polygon(&[(80.0, 40.0), (120.0, 40.0), (120.0, 80.0)]).with_op(PathOp::Subtract), + ]); + path.fill_rule = FillRule::EvenOdd; + let ids: Vec = doc.walk().into_iter().filter(|(_, _, l)| matches!(l.content, LayerContent::Text(_))).map(|(_, _, l)| l.id).collect(); + assert!(!ids.is_empty()); + for id in ids { + if let Some(LayerContent::Text(t)) = doc.layer_mut(id).map(|l| &mut l.content) { + t.shape = TextShape::Area { path: path.clone() }; + } + } + let back = load_from_bytes(&save_to_bytes(&doc, &SaveOptions::default()).unwrap()).unwrap(); + let shape = back.walk().into_iter().find_map(|(_, _, l)| match &l.content { + LayerContent::Text(t) => Some(t.shape.clone()), + _ => None, + }); + assert_eq!(shape, Some(TextShape::Area { path })); +} + #[test] fn channel_restrictions_and_bevel_elements_roundtrip() { use photocraft_doc::{Bevel, BevelContour, BevelTexture, Contour, Effect}; From 94c48b63b700caca7032193bac5f998e7e8012b7 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 02:32:06 -0700 Subject: [PATCH 086/649] feat(ui): Type tool click inside or on a path starts area or path type Photoshop's Type tool turns a click inside a closed path into area type and a click on a path outline into type on the path from that point; a drag still makes a text box and the Type Mask tools ignore paths. The path is the active shape layer's, else the work path. Create and fill share the edit session's coalesce key, so the click is one undo step. The pointer shows the area-type or path-type cursor over a path, and an open area-type edit draws the shape's outline. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/canvas.rs | 12 ++++ crates/ui-egui/src/tool_cursor.rs | 37 ++++++++++++ crates/ui-egui/src/tool_cursor/tests.rs | 10 ++++ crates/ui-egui/src/type_tool.rs | 70 ++++++++++++++++++++++ crates/ui-egui/src/type_tool_tests.rs | 78 ++++++++++++++++++++++++- 5 files changed, 206 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 391ad464fd..e64665d10e 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -3897,6 +3897,14 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: if !resizing && !alt && !app.ui.shell.sticky_alt { draw_clone_preview(app, &painter, &xf, xf.to_doc(p), output); } + // The Type tool over a path shows Photoshop's area-type or type-on-a-path pointer (#218). + // Not while a type edit is open: a click then commits rather than starting new type. + let type_path = if matches!(tool, Tool::Type | Tool::VerticalType) && app.ui.text_edit.is_none() { + let [x, y] = xf.to_doc(p); + crate::type_tool::path_target(app, x, y) + } else { + None + }; let icon = match tool { // Resizing the brush: the circle stays where the drag began (`brush_resize`). t if resizing && crate::brush_resize::applies(t) => egui::CursorIcon::None, @@ -4022,6 +4030,10 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: Tool::Hand => crate::tool_cursor::hand(ui.ctx(), false), Tool::RotateView => crate::rotate_view::cursor(response.dragged()), Tool::Zoom => crate::tool_cursor::zoom(ui.ctx(), zoom_out(alt)), + Tool::Type | Tool::VerticalType if type_path.is_some() => match type_path { + Some(crate::type_tool::PathClick::Area { .. }) => crate::tool_cursor::area_type(&painter, p), + _ => crate::tool_cursor::path_type(&painter, p), + }, Tool::Type | Tool::VerticalType | Tool::HorizontalTypeMask | Tool::VerticalTypeMask => egui::CursorIcon::Text, Tool::MagneticLasso => crate::magnetic_lasso_ui::cursor(app, &painter, p, xf.zoom), Tool::RedEye => { diff --git a/crates/ui-egui/src/tool_cursor.rs b/crates/ui-egui/src/tool_cursor.rs index 8b67b96d60..f53d5b7558 100644 --- a/crates/ui-egui/src/tool_cursor.rs +++ b/crates/ui-egui/src/tool_cursor.rs @@ -92,6 +92,43 @@ fn close_ring() -> Vec { (0..16).map(|i| (i as f32 / 16.0 * std::f32::consts::TAU, vec2(9.0, 9.0))).map(|(a, c)| c + vec2(a.cos(), a.sin()) * 3.5).collect() } +/// Closed outline of an I-beam, centred on the hotspot. +fn i_beam() -> Vec { + [(-3.0, -8.0), (3.0, -8.0), (3.0, -7.0), (0.5, -7.0), (0.5, 7.0), (3.0, 7.0), (3.0, 8.0), (-3.0, 8.0), (-3.0, 7.0), (-0.5, 7.0), (-0.5, -7.0), (-3.0, -7.0)] + .into_iter() + .map(|(x, y)| vec2(x, y)) + .collect() +} + +/// A dot (a tiny closed square) at `c`. +fn dot(c: Vec2) -> Vec { + vec![c + vec2(-0.75, -0.75), c + vec2(0.75, -0.75), c + vec2(0.75, 0.75), c + vec2(-0.75, 0.75)] +} + +/// Photoshop's area-type pointer (#218): the I-beam inside a dotted ellipse. +pub(crate) fn area_type_rings() -> Vec> { + let mut rings = vec![i_beam()]; + rings.extend((0..12).map(|i| i as f32 / 12.0 * std::f32::consts::TAU).map(|a| dot(vec2(a.cos() * 8.0, a.sin() * 10.5)))); + rings +} + +/// Photoshop's type-on-a-path pointer (#218): the I-beam crossed by a dotted wave. +pub(crate) fn path_type_rings() -> Vec> { + let mut rings = vec![i_beam()]; + rings.extend((0..9).map(|i| -10.0 + i as f32 * 2.5).map(|x| dot(vec2(x, 4.0 + (x * 0.4).sin() * 2.0)))); + rings +} + +/// The Type tool over the inside of a closed path: a click starts area type there. +pub(crate) fn area_type(painter: &Painter, at: Pos2) -> CursorIcon { + outline(painter, at, area_type_rings(), false) +} + +/// The Type tool over a path's outline: a click starts type on the path there. +pub(crate) fn path_type(painter: &Painter, at: Pos2) -> CursorIcon { + outline(painter, at, path_type_rings(), false) +} + /// Can this pass show an OS cursor bitmap? eframe's immediate viewports and its web integration /// don't upload cursor images; every desktop root viewport does (winit custom cursors). Wayland at /// any scale but 1 doesn't either: winit sizes the bitmap there with a `wp_viewport` destination diff --git a/crates/ui-egui/src/tool_cursor/tests.rs b/crates/ui-egui/src/tool_cursor/tests.rs index d68be241f5..b15774147e 100644 --- a/crates/ui-egui/src/tool_cursor/tests.rs +++ b/crates/ui-egui/src/tool_cursor/tests.rs @@ -515,3 +515,13 @@ fn resize_follows_the_view() { assert_eq!(got, want, "view turned {rotation}°, flip {flip}"); } } + +#[test] +fn type_path_cursors_are_small_and_centred() { + for rings in [super::area_type_rings(), super::path_type_rings()] { + assert!(rings.len() > 3); + for v in rings.iter().flatten() { + assert!(v.x.abs() <= 12.0 && v.y.abs() <= 12.0, "{v:?}"); + } + } +} diff --git a/crates/ui-egui/src/type_tool.rs b/crates/ui-egui/src/type_tool.rs index d73bb2e2c4..684738e907 100644 --- a/crates/ui-egui/src/type_tool.rs +++ b/crates/ui-egui/src/type_tool.rs @@ -296,6 +296,53 @@ pub fn pointer_move(app: &mut PhotocraftApp, x: f64, y: f64) { } } +/// What a Type tool click on a path does, like Photoshop: inside a closed path, area type; +/// on a path's outline, type on the path from that point. +#[derive(Clone, Debug, PartialEq)] +pub(crate) enum PathClick { + Area { shape: Option }, + OnPath { shape: Option, subpath: usize, start: f64 }, +} + +/// Arc length (px) along `sub` from its first anchor to segment `seg` at curve parameter `t`. +fn arc_length_to(sub: &photocraft_doc::Subpath, seg: usize, t: f64) -> f64 { + const PIECES: usize = 32; + let eval = photocraft_vector::edit::eval; + let length = |s: &[Point; 4], upto: f64| { + (1..=PIECES) + .fold((0.0, eval(s, 0.0)), |(len, prev), j| { + let q = eval(s, upto * j as f64 / PIECES as f64); + (len + (q.x - prev.x).hypot(q.y - prev.y), q) + }) + .0 + }; + let segs = sub.segments(); + let whole: f64 = segs.iter().take(seg).map(|s| length(s, 1.0)).sum(); + whole + segs.get(seg).map_or(0.0, |s| length(s, t.clamp(0.0, 1.0))) +} + +/// The path a Type tool click at document `(x, y)` would use: the active shape layer's path, +/// else the work path (the path Photoshop shows), within 4 screen px of its outline or inside it. +pub(crate) fn path_target(app: &PhotocraftApp, x: f64, y: f64) -> Option { + use photocraft_vector::edit::{Hit, hit}; + let (shape, path) = match crate::vector_ui::active_shape_path(app) { + Some((id, p)) => (Some(id), p), + None => (None, app.session.active()?.doc.work_path.clone()?), + }; + let tol = 4.0 / app.point_zoom().max(0.01) as f64; + let on_path = |sp: usize, k: usize, t: f64| { + let sub = path.subpaths.get(sp)?; + Some(PathClick::OnPath { shape, subpath: sp, start: arc_length_to(sub, k, t) }) + }; + match hit(&path, Point::new(x, y), tol, &[]) { + Some(Hit::Segment([sp, k], t)) => return on_path(sp, k, t), + Some(Hit::Anchor([sp, k])) => return on_path(sp, k, 0.0), + _ => {} + } + let area = photocraft_text::area::AreaShape::new(&path, false)?; + area.contains(x as f32, y as f32).then_some(PathClick::Area { shape }) +} + /// Pointer up. `rect` is the dragged box (document px) when no edit session consumed the press. pub fn pointer_up(app: &mut PhotocraftApp, start: [f64; 2], end: [f64; 2]) { if let Some(e) = app.ui.text_edit.as_mut() { @@ -307,6 +354,9 @@ pub fn pointer_up(app: &mut PhotocraftApp, start: [f64; 2], end: [f64; 2]) { let min = 4.0 / app.point_zoom().max(0.01) as f64; let o = app.ui.tool_options.clone(); let mask = app.ui.tool.is_type_mask(); + // A click (not a drag) with the Type tool on a path: area type inside a closed path, type + // on the path on its outline. The Type Mask tools ignore paths. + let target = if !mask && !(w >= min && h >= min) { path_target(app, start[0], start[1]) } else { None }; // Preferences ▸ Type: "Fill new type layers with placeholder text" (on by default). The Type // Mask tools start empty, as Photoshop's do. let text = if !mask && app.session.prefs().type_.fill_new_type_layers_with_placeholder { PLACEHOLDER } else { "" }; @@ -330,6 +380,15 @@ pub fn pointer_up(app: &mut PhotocraftApp, start: [f64; 2], end: [f64; 2]) { if let Ok(v) = app.run("type.create", p) && let Some(id) = v.get("layer").and_then(serde_json::Value::as_u64) { + match &target { + Some(PathClick::Area { shape }) => { + let _ = app.run("type.fillPath", json!({"layer": id, "shape": shape, "coalesce": key})); + } + Some(PathClick::OnPath { shape, subpath, start }) => { + let _ = app.run("type.attachToPath", json!({"layer": id, "shape": shape, "subpath": subpath, "start": start, "coalesce": key})); + } + None => {} + } if o.type_aa != "sharp" { let _ = app.run("type.edit", json!({"layer": id, "antialias": o.type_aa, "coalesce": key})); } @@ -1043,6 +1102,17 @@ pub fn draw_overlay(app: &mut PhotocraftApp, painter: &egui::Painter, xf: &ViewX } } } + // Area type: the outline of the shape it wraps inside. + Some(photocraft_doc::text::TextShape::Area { path }) => { + if !has_transform { + for poly in photocraft_vector::flatten::flatten_path(&path, 0.5) { + let pts: Vec = poly.pts.iter().map(|&(x, y)| scr_t(x as f32, y as f32)).collect(); + if pts.len() >= 2 { + painter.add(egui::Shape::closed_line(pts, frame)); + } + } + } + } _ => { for ln in &l.lines { // Horizontal: just under the baseline; vertical: the column's centre line. diff --git a/crates/ui-egui/src/type_tool_tests.rs b/crates/ui-egui/src/type_tool_tests.rs index f56829c6d1..98a1002780 100644 --- a/crates/ui-egui/src/type_tool_tests.rs +++ b/crates/ui-egui/src/type_tool_tests.rs @@ -10,7 +10,7 @@ use photocraft_doc::{LayerContent, LayerId, TextLayer}; use photocraft_geom::{Affine, Point}; use serde_json::json; -use super::{layout, text_layer}; +use super::{PathClick, layout, path_target, text_layer}; use crate::PhotocraftApp; use crate::canvas::ViewXform; @@ -2062,3 +2062,79 @@ fn type_mask_shift_adds_and_alt_subtracts_without_a_layer_row() { assert!(at(&app, stem.0, stem.1) < 0.01, "⌥ subtracts the glyphs"); assert!(at(&app, 1050, 150) > 0.99, "and keeps the rest"); } + +fn ellipse_layer(app: &mut PhotocraftApp) -> u64 { + app.run("shape.create", json!({"kind": "ellipse", "rect": [200, 200, 400, 300], "fill": "#dddddd"})).unwrap()["layer"].as_u64().unwrap() +} + +fn click_at(app: &mut PhotocraftApp, x: f64, y: f64) { + use crate::canvas::{ToolEvent, tool_event}; + tool_event(app, ToolEvent::Down { x, y, pressure: 1.0 }, Modifiers::NONE); + tool_event(app, ToolEvent::Up { x, y }, Modifiers::NONE); +} + +#[test] +fn clicking_inside_a_shape_starts_area_type_in_one_step() { + use photocraft_doc::text::TextShape; + let mut app = new_app(); + let shape = ellipse_layer(&mut app); + assert!(matches!(path_target(&app, 400.0, 350.0), Some(PathClick::Area { shape: Some(s) }) if s == shape)); + let before = app.session.active().unwrap().history.entries().len(); + click_at(&mut app, 400.0, 350.0); + let id = LayerId(app.ui.text_edit.as_ref().expect("editing").layer); + let st = app.session.active().unwrap(); + assert!(matches!(text_layer(&st.doc, id).unwrap().shape, TextShape::Area { .. })); + assert_eq!(st.history.entries().len(), before + 1, "create + fill is one step"); + super::commit(&mut app); + app.run("edit.undo", json!({})).unwrap(); + assert!(app.session.active().unwrap().doc.layer(id).is_none()); +} + +#[test] +fn clicking_on_a_path_outline_starts_type_on_the_path_where_clicked() { + use photocraft_doc::text::TextShape; + let mut app = new_app(); + ellipse_layer(&mut app); + // The ellipse's bottom point (400, 500); its perimeter is about 1105 px. + let Some(PathClick::OnPath { start, .. }) = path_target(&app, 400.0, 500.0) else { panic!("on the outline") }; + assert!((0.0..1110.0).contains(&start), "{start}"); + // A point a quarter of the way further round is about 276 px further along (mod the perimeter). + let Some(PathClick::OnPath { start: right, .. }) = path_target(&app, 600.0, 350.0) else { panic!("on the outline") }; + let d = (right - start).rem_euclid(1105.0); + assert!((d - 276.0).abs() < 15.0 || (d - 829.0).abs() < 15.0, "{start} → {right}"); + click_at(&mut app, 400.0, 500.0); + let id = LayerId(app.ui.text_edit.as_ref().unwrap().layer); + assert!( + matches!(text_layer(&app.session.active().unwrap().doc, id).unwrap().shape, TextShape::Path { start: s, .. } if (f64::from(s) - start).abs() < 0.01) + ); +} + +#[test] +fn click_outside_paths_still_makes_point_text() { + use photocraft_doc::text::TextShape; + let mut app = new_app(); + ellipse_layer(&mut app); + assert!(path_target(&app, 1200.0, 700.0).is_none()); + click_at(&mut app, 1200.0, 700.0); + let id = LayerId(app.ui.text_edit.as_ref().unwrap().layer); + assert_eq!(text_layer(&app.session.active().unwrap().doc, id).unwrap().shape, TextShape::Point); + // A drag inside the shape still makes a text box, as in Photoshop. + let mut app = new_app(); + ellipse_layer(&mut app); + use crate::canvas::{ToolEvent, tool_event}; + tool_event(&mut app, ToolEvent::Down { x: 300.0, y: 300.0, pressure: 1.0 }, Modifiers::NONE); + tool_event(&mut app, ToolEvent::Move { x: 450.0, y: 400.0, pressure: 1.0 }, Modifiers::NONE); + tool_event(&mut app, ToolEvent::Up { x: 450.0, y: 400.0 }, Modifiers::NONE); + let id = LayerId(app.ui.text_edit.as_ref().unwrap().layer); + assert!(matches!(text_layer(&app.session.active().unwrap().doc, id).unwrap().shape, TextShape::Box { .. })); +} + +#[test] +fn type_mask_tools_ignore_paths() { + let mut app = new_app(); + ellipse_layer(&mut app); + app.ui.tool = crate::state::Tool::HorizontalTypeMask; + click_at(&mut app, 400.0, 350.0); + let id = LayerId(app.ui.text_edit.as_ref().unwrap().layer); + assert_eq!(text_layer(&app.session.active().unwrap().doc, id).unwrap().shape, photocraft_doc::text::TextShape::Point); +} From 5a8a8f8167648310ac3664a8fd9f91ba958af560 Mon Sep 17 00:00:00 2001 From: Khawar Zamman Wani Date: Thu, 15 Oct 2026 15:06:55 +0530 Subject: [PATCH 087/649] CI: re-run (flaky compose test) Co-Authored-By: Claude Opus 5.5 From 566a501bb8f917bf2a45716a90e8dedbe498e456 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 02:49:21 -0700 Subject: [PATCH 088/649] fix(ui): keep the Type tool's path pointer in step with what a click does Over existing type that sits on a path, the pointer showed the area or path-type cursor while the press edited the type layer, because the hover never asked the hit test pointer_down uses. The hover now goes through hover_path_target, which shares hit_layer with the press and keeps Photoshop's plain I-beam there (a shifted press still starts new type on the path). hit_layer and layout borrow the document instead of cloning it, since the hover calls them; the type hit only runs once a path is under the pointer. A one-anchor subpath is no longer an on-path target (type.attachToPath rejects it, so the cursor promised type it could not place), and paths over 4096 anchors are skipped so the per-frame segment hit stays cheap; pointer and click use the same rule. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/canvas.rs | 6 ++- crates/ui-egui/src/type_tool.rs | 61 ++++++++++++++++++--------- crates/ui-egui/src/type_tool_tests.rs | 54 ++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 21 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index e64665d10e..62240d3d98 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -3898,10 +3898,12 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: draw_clone_preview(app, &painter, &xf, xf.to_doc(p), output); } // The Type tool over a path shows Photoshop's area-type or type-on-a-path pointer (#218). - // Not while a type edit is open: a click then commits rather than starting new type. + // Not while a type edit is open (a click then commits rather than starting new type), + // nor over type a click would edit. let type_path = if matches!(tool, Tool::Type | Tool::VerticalType) && app.ui.text_edit.is_none() { let [x, y] = xf.to_doc(p); - crate::type_tool::path_target(app, x, y) + let shift = crate::workspace_ui::sticky_mods(app, ui.input(|i| i.modifiers)).shift; + crate::type_tool::hover_path_target(app, x, y, shift) } else { None }; diff --git a/crates/ui-egui/src/type_tool.rs b/crates/ui-egui/src/type_tool.rs index 684738e907..30d03d6aa5 100644 --- a/crates/ui-egui/src/type_tool.rs +++ b/crates/ui-egui/src/type_tool.rs @@ -32,17 +32,18 @@ fn byte_of(text: &str, ci: usize) -> usize { /// Layout of a type layer (cached per document revision) and its text → document transform. pub fn layout(app: &mut PhotocraftApp, id: LayerId) -> Option<(Arc, Affine, String)> { + let dragged = crate::type_transform::current_transform(app, id); + // Borrows the document in place (no clone): the canvas hover hit-tests type every frame. let st = app.session.active()?; - let (doc, rev) = (st.doc.clone(), st.revision); - let t = text_layer(&doc, id)?; - let transform = crate::type_transform::current_transform(app, id).unwrap_or(t.transform); - let key = (doc.id.0, rev, id.0); + let t = text_layer(&st.doc, id)?; + let transform = dragged.unwrap_or(t.transform); + let key = (st.doc.id.0, st.revision, id.0); if let Some((k, l)) = &app.type_layout && *k == key { return Some((l.clone(), transform, t.text.clone())); } - let l = Arc::new(photocraft_text::shared().lock().ok()?.layout(t, doc.resolution_dpi)); + let l = Arc::new(photocraft_text::shared().lock().ok()?.layout(t, st.doc.resolution_dpi)); app.type_layout = Some((key, l.clone())); Some((l, transform, t.text.clone())) } @@ -53,23 +54,25 @@ fn to_text(aff: &Affine, x: f64, y: f64) -> (f32, f32) { } /// Topmost shown type layer (it and every group around it visible, #4320) whose laid-out text -/// contains the document point. +/// contains the document point. The press and the canvas hover (`hover_path_target`) share it, so +/// the pointer never promises a path click that the press would turn into editing this layer. fn hit_layer(app: &mut PhotocraftApp, x: f64, y: f64) -> Option { - let doc = app.session.active()?.doc.clone(); let slop = 6.0 / app.point_zoom().max(0.01); // A Type Mask session's text is a hidden layer; it is still the text being edited. let editing = app.ui.text_edit.as_ref().filter(|ed| ed.mask).map(|ed| LayerId(ed.layer)); - let mut ids: Vec = doc - .walk() - .into_iter() - .filter(|(path, _, l)| matches!(l.content, LayerContent::Text(_)) && (editing == Some(l.id) || doc.shown_at(path))) - .map(|(_, _, l)| l.id) - .collect(); + let mut ids: Vec = { + let doc = &app.session.active()?.doc; + doc.walk() + .into_iter() + .filter(|(path, _, l)| matches!(l.content, LayerContent::Text(_)) && (editing == Some(l.id) || doc.shown_at(path))) + .map(|(_, _, l)| l.id) + .collect() + }; ids.reverse(); // walk() is bottom-up; hit the topmost first ids.into_iter().find(|id| { // The pixels shown count too: a PSD's type keeps Photoshop's rendering until edited, // which can sit off our layout when fonts are substituted (#123). - let shown = text_layer(&doc, *id).and_then(|t| t.cache.as_ref()).map(|c| c.content_bounds()).is_some_and(|r| { + let shown = app.session.active().and_then(|st| text_layer(&st.doc, *id)).and_then(|t| t.cache.as_ref()).map(|c| c.content_bounds()).is_some_and(|r| { let s = f64::from(slop); !r.is_empty() && x >= f64::from(r.x0) - s && x <= f64::from(r.x1) + s && y >= f64::from(r.y0) - s && y <= f64::from(r.y1) + s }); @@ -329,20 +332,40 @@ pub(crate) fn path_target(app: &PhotocraftApp, x: f64, y: f64) -> Option (Some(id), p), None => (None, app.session.active()?.doc.work_path.clone()?), }; + // The canvas hover runs this every frame and `hit` samples every segment, so a path with more + // anchors than this is not a click target (the click and the pointer agree: plain point + // text). 4096 anchors is far beyond hand-drawn paths and shapes yet keeps a frame cheap. + const MAX_TARGET_KNOTS: usize = 4096; + if path.subpaths.iter().map(|s| s.knots.len()).fold(0usize, usize::saturating_add) > MAX_TARGET_KNOTS { + return None; + } let tol = 4.0 / app.point_zoom().max(0.01) as f64; let on_path = |sp: usize, k: usize, t: f64| { - let sub = path.subpaths.get(sp)?; + // Type on a path needs a segment to run along (`type.attachToPath` rejects one anchor). + let sub = path.subpaths.get(sp).filter(|s| s.knots.len() >= 2)?; Some(PathClick::OnPath { shape, subpath: sp, start: arc_length_to(sub, k, t) }) }; - match hit(&path, Point::new(x, y), tol, &[]) { - Some(Hit::Segment([sp, k], t)) => return on_path(sp, k, t), - Some(Hit::Anchor([sp, k])) => return on_path(sp, k, 0.0), - _ => {} + let outline = match hit(&path, Point::new(x, y), tol, &[]) { + Some(Hit::Segment([sp, k], t)) => on_path(sp, k, t), + Some(Hit::Anchor([sp, k])) => on_path(sp, k, 0.0), + _ => None, + }; + if outline.is_some() { + return outline; } let area = photocraft_text::area::AreaShape::new(&path, false)?; area.contains(x as f32, y as f32).then_some(PathClick::Area { shape }) } +/// What the Type tool's pointer over document `(x, y)` shows (#218): the path click a press there +/// would make, unless the press edits the type layer under it instead (`pointer_down`: an +/// unshifted press on shown type), where Photoshop keeps the plain I-beam. The type hit is only +/// tested over a path, so a hover elsewhere lays out nothing. +pub(crate) fn hover_path_target(app: &mut PhotocraftApp, x: f64, y: f64, shift: bool) -> Option { + let target = path_target(app, x, y)?; + (shift || hit_layer(app, x, y).is_none()).then_some(target) +} + /// Pointer up. `rect` is the dragged box (document px) when no edit session consumed the press. pub fn pointer_up(app: &mut PhotocraftApp, start: [f64; 2], end: [f64; 2]) { if let Some(e) = app.ui.text_edit.as_mut() { diff --git a/crates/ui-egui/src/type_tool_tests.rs b/crates/ui-egui/src/type_tool_tests.rs index 98a1002780..99c3a48640 100644 --- a/crates/ui-egui/src/type_tool_tests.rs +++ b/crates/ui-egui/src/type_tool_tests.rs @@ -2102,8 +2102,10 @@ fn clicking_on_a_path_outline_starts_type_on_the_path_where_clicked() { let Some(PathClick::OnPath { start: right, .. }) = path_target(&app, 600.0, 350.0) else { panic!("on the outline") }; let d = (right - start).rem_euclid(1105.0); assert!((d - 276.0).abs() < 15.0 || (d - 829.0).abs() < 15.0, "{start} → {right}"); + let before = app.session.active().unwrap().history.entries().len(); click_at(&mut app, 400.0, 500.0); let id = LayerId(app.ui.text_edit.as_ref().unwrap().layer); + assert_eq!(app.session.active().unwrap().history.entries().len(), before + 1, "create + attach is one step"); assert!( matches!(text_layer(&app.session.active().unwrap().doc, id).unwrap().shape, TextShape::Path { start: s, .. } if (f64::from(s) - start).abs() < 0.01) ); @@ -2138,3 +2140,55 @@ fn type_mask_tools_ignore_paths() { let id = LayerId(app.ui.text_edit.as_ref().unwrap().layer); assert_eq!(text_layer(&app.session.active().unwrap().doc, id).unwrap().shape, photocraft_doc::text::TextShape::Point); } + +#[test] +fn a_one_anchor_work_path_is_not_a_path_target() { + // `type.attachToPath` needs a segment, so the pointer must not promise type on this path. + let mut app = new_app(); + std::sync::Arc::make_mut(&mut app.session.active_mut().unwrap().doc).work_path = + Some(photocraft_doc::Path::new(vec![photocraft_doc::Subpath::polyline(&[(500.0, 400.0)])])); + assert!(path_target(&app, 500.0, 400.0).is_none()); + click_at(&mut app, 500.0, 400.0); + let id = LayerId(app.ui.text_edit.as_ref().unwrap().layer); + assert_eq!(text_layer(&app.session.active().unwrap().doc, id).unwrap().shape, photocraft_doc::text::TextShape::Point); +} + +#[test] +fn over_existing_type_on_a_shape_the_pointer_is_the_plain_i_beam_and_a_click_edits_it() { + let mut app = new_app(); + let text = app.run("type.create", json!({"text": "Hello", "x": 330, "y": 370, "size": 36})).unwrap()["layer"].as_u64().unwrap(); + let shape = ellipse_layer(&mut app); // the shape layer is active, so its path is the target + let layers = app.session.active().unwrap().doc.walk().len(); + let mut h = harness(1.0, app); + let on_text = glyph(&mut h, LayerId(text), 1, 0.5); + let [dx, dy] = xf(h.state()).to_doc(on_text); + assert!(matches!(path_target(h.state(), dx, dy), Some(PathClick::Area { shape: Some(s) }) if s == shape), "the text sits inside the shape"); + h.hover_at(on_text); + h.run_steps(2); + assert_eq!(h.output().platform_output.cursor_icon, egui::CursorIcon::Text, "a click here edits the type, so the plain I-beam"); + // Inside the shape but away from the type: the area-type pointer (drawn, not the OS I-beam). + let inside = xf(h.state()).to_screen(400.0, 250.0); + h.hover_at(inside); + h.run_steps(2); + assert_ne!(h.output().platform_output.cursor_icon, egui::CursorIcon::Text, "area-type pointer inside the shape"); + click(&mut h, on_text); + let app = h.state(); + assert_eq!(app.ui.text_edit.as_ref().expect("editing").layer, text, "the click edits the existing layer"); + assert_eq!(app.session.active().unwrap().doc.walk().len(), layers, "no new layer"); + assert_eq!(text_layer(&app.session.active().unwrap().doc, LayerId(text)).unwrap().shape, photocraft_doc::text::TextShape::Point); +} + +#[test] +fn paths_with_too_many_anchors_are_not_hover_targets() { + // The hover hit-tests every segment each frame, so huge paths are skipped (click and pointer alike). + let ring = |n: usize| -> Vec<(f64, f64)> { + (0..n).map(|i| i as f64 / n as f64 * std::f64::consts::TAU).map(|a| (500.0 + 200.0 * a.cos(), 400.0 + 200.0 * a.sin())).collect() + }; + let mut app = new_app(); + std::sync::Arc::make_mut(&mut app.session.active_mut().unwrap().doc).work_path = + Some(photocraft_doc::Path::new(vec![photocraft_doc::Subpath::polygon(&ring(4000))])); + assert!(matches!(path_target(&app, 500.0, 400.0), Some(PathClick::Area { shape: None }))); + std::sync::Arc::make_mut(&mut app.session.active_mut().unwrap().doc).work_path = + Some(photocraft_doc::Path::new(vec![photocraft_doc::Subpath::polygon(&ring(5000))])); + assert!(path_target(&app, 500.0, 400.0).is_none()); +} From c71e3f94ad851384c1d1a427f9306ede2ced1557 Mon Sep 17 00:00:00 2001 From: adrdsouza <102761952+adrdsouza@users.noreply.github.com> Date: Thu, 15 Oct 2026 16:27:30 +0530 Subject: [PATCH 089/649] fix(psd): refine legacy point anchors after font resolution --- crates/io/src/affinity.rs | 2 +- crates/io/src/lib.rs | 3 +- crates/io/src/text_import.rs | 15 +++-- crates/text/src/psd.rs | 39 ++++++++++- crates/text/src/tests.rs | 123 ++++++++++++++++++++++++++--------- docs/file-format-parity.md | 3 +- 6 files changed, 144 insertions(+), 41 deletions(-) diff --git a/crates/io/src/affinity.rs b/crates/io/src/affinity.rs index efba868be0..9c4fd72b99 100644 --- a/crates/io/src/affinity.rs +++ b/crates/io/src/affinity.rs @@ -43,7 +43,7 @@ pub(crate) fn import(name: &str, bytes: &[u8]) -> Result // Type layers draw from their model, within the import's raster bound: the sizes and // frames come from an untrusted file. let mut document = b.doc; - crate::text_import::prepare(&mut document); + crate::text_import::prepare(&mut document, None); // Save never writes back over the Affinity file. Ok(ImportResult { document, warnings, source_read_only: true, preview_only: false }) } diff --git a/crates/io/src/lib.rs b/crates/io/src/lib.rs index a620ddcf33..5dee7d88b7 100644 --- a/crates/io/src/lib.rs +++ b/crates/io/src/lib.rs @@ -283,7 +283,8 @@ fn import_stages(name: &str, bytes: &[u8], ctl: &photocraft_raster::Interrupt, m ctl.progress(0.05); let (mut document, warnings) = psd_import::psd_to_document_decoded(&file, ctl, merged).ok_or(IoError::Cancelled)?; document.name = name.to_string(); - text_import::prepare(&mut document); + let txt2 = file.global_blocks.iter().find(|b| &b.key == b"Txt2").and_then(|b| photocraft_text::psd::parse_txt2(&b.data)); + text_import::prepare(&mut document, txt2.as_ref()); return Ok(ImportResult { document, warnings, source_read_only: false, preview_only: false }); } if affinity::is_affinity(bytes) || affinity::has_extension(name) { diff --git a/crates/io/src/text_import.rs b/crates/io/src/text_import.rs index 9272f0b5b7..0522f39e90 100644 --- a/crates/io/src/text_import.rs +++ b/crates/io/src/text_import.rs @@ -28,8 +28,14 @@ fn render_bounded(eng: &mut photocraft_text::TextEngine, t: &mut TextLayer, dpi: /// - a type layer without pixels (ag-psd, GIMP and other writers leave the image data out and /// let Photoshop re-render on open) is rendered from its model, instead of staying empty /// until it is edited. -pub(crate) fn prepare(doc: &mut Document) { - fn visit(layers: &mut [Layer], eng: &mut photocraft_text::TextEngine, dpi: f32, format: photocraft_color::PixelFormat) { +pub(crate) fn prepare(doc: &mut Document, txt2: Option<&photocraft_text::engine_data::Value>) { + fn visit( + layers: &mut [Layer], + eng: &mut photocraft_text::TextEngine, + dpi: f32, + format: photocraft_color::PixelFormat, + txt2: Option<&photocraft_text::engine_data::Value>, + ) { for l in layers { match &mut l.content { LayerContent::Text(t) => { @@ -56,11 +62,12 @@ pub(crate) fn prepare(doc: &mut Document) { if changed { t.sync_summary(); } + photocraft_text::psd::refine_legacy_point_origin(t, dpi, eng, txt2); if t.cache.is_none() { render_bounded(eng, t, dpi, format); } } - LayerContent::Group(g) => visit(&mut g.children, eng, dpi, format), + LayerContent::Group(g) => visit(&mut g.children, eng, dpi, format, txt2), _ => {} } } @@ -68,5 +75,5 @@ pub(crate) fn prepare(doc: &mut Document) { let dpi = doc.resolution_dpi; let format = doc.pixel_format(); let mut eng = photocraft_text::shared().lock().unwrap_or_else(|e| e.into_inner()); - visit(&mut doc.layers, &mut eng, dpi, format); + visit(&mut doc.layers, &mut eng, dpi, format, txt2); } diff --git a/crates/text/src/psd.rs b/crates/text/src/psd.rs index 0092fcf92e..1c9867eba9 100644 --- a/crates/text/src/psd.rs +++ b/crates/text/src/psd.rs @@ -376,12 +376,43 @@ pub fn text_layer_from_tysh(data: &[u8], dpi: f32) -> Option { // writing the TySh all agree on the visible position (#1469). if let Some([x, y]) = legacy_point_origin(&t) { let [a, b, c, d, e, f] = layer.transform.m; - layer.transform.m = [a, b, c, d, a * x + c * y + e, b * x + d * y + f]; + let corrected = [a, b, c, d, a * x + c * y + e, b * x + d * y + f]; + if corrected.iter().all(|v| v.is_finite()) { + layer.transform.m = corrected; + } } layer.sync_summary(); Some(layer) } +/// Refines a legacy point-text estimate after imported fonts and styles have been resolved. +/// Uses the rendering engine's font context; an accepted `Txt2` frame stays authoritative. +pub fn refine_legacy_point_origin(layer: &mut TextLayer, dpi: f32, engine: &mut crate::TextEngine, txt2: Option<&E>) { + let Some(raw) = layer.psd_raw.clone() else { return }; + let Some(t) = parse_tysh(&raw) else { return }; + let Some([x, y]) = legacy_point_origin(&t) else { return }; + if !matches!(layer.shape, TextShape::Point) { + return; + } + let guessed = t.transform.mul(&Affine::translate(x, y)); + if layer.transform != guessed { + return; + } + let Some(bounds) = engine.layout(layer, dpi).bounds() else { return }; + if !bounds.iter().all(|v| v.is_finite()) { + return; + } + let corrected = t.transform.mul(&Affine::translate(x - f64::from(bounds[0]), y - f64::from(bounds[1]))); + if corrected.m.iter().all(|v| v.is_finite()) { + layer.transform = corrected; + // A valid frame can coincide with the initial estimate; numeric equality cannot tell + // whether it was used. Reapply it after the fallback so it always wins. + if let Some(txt2) = txt2 { + apply_txt2_frame(layer, &raw, txt2); + } + } +} + /// The local origin to fold into a legacy point-text transform, if present. /// /// Photoshop normally keeps point text close to its PointBase. The affected legacy files instead @@ -412,7 +443,11 @@ fn legacy_point_origin(t: &TySh) -> Option<[f64; 2]> { // A local bounding-box origin in the thousands and a transform origin beyond a normal canvas // are the signature of this old writer. Requiring that the bounding-box origin is closer to // the document prevents applying the correction again after export/import. - (bounds[0].abs().max(bounds[1].abs()) > 1024.0 && origin_distance > 4096.0 && shifted_distance < origin_distance).then_some([bounds[0], bounds[1]]) + if !(bounds[0].abs().max(bounds[1].abs()) > 1024.0 && origin_distance > 4096.0 && shifted_distance < origin_distance) { + return None; + } + + Some([bounds[0], bounds[1]]) } fn descriptor_rect(text: &Descriptor, key: &str) -> Option<[f64; 4]> { diff --git a/crates/text/src/tests.rs b/crates/text/src/tests.rs index 13de665ccd..9eaedb6f8a 100644 --- a/crates/text/src/tests.rs +++ b/crates/text/src/tests.rs @@ -1222,47 +1222,106 @@ fn psd_round_trips_antialias_opentype_and_warp() { } /// #1469: Some older PSD writers combine a zero PointBase with an enormous local ink origin. -/// The TySh transform cancels that origin, so importing it as a zero-based layout puts text far -/// off-canvas. Fold the descriptor origin into the imported transform and preserve it on a TySh -/// round trip so every editing and export path uses the same position. +/// Recover the saved ink origin relative to style-aware layout bounds, so point alignment anchors +/// stay fixed for left, centered and right text through import and a TySh round trip. #[test] fn legacy_tysh_point_origin_imports_and_round_trips_on_canvas() { use photocraft_psd::descriptor::{Descriptor, Id, Value as D}; - let source = styled("Name", CharStyle { font_family: "Inter".into(), size_pt: 120.0, ..Default::default() }); - let mut tysh = crate::psd::parse_tysh(&crate::psd::build_tysh(&source, 72.0, None)).unwrap(); - tysh.transform = Affine { m: [4.1667, 0.0, 0.0, 4.1667, -32375.0, -32887.5] }; - let ink = [8050.0, 8160.0, 8220.0, 8300.0]; - let rect = |class| { - D::Descriptor( - Descriptor::new(class) - .with("Left", D::UnitFloat { unit: *b"#Pnt", value: ink[0] }) - .with("Top ", D::UnitFloat { unit: *b"#Pnt", value: ink[1] }) - .with("Rght", D::UnitFloat { unit: *b"#Pnt", value: ink[2] }) - .with("Btom", D::UnitFloat { unit: *b"#Pnt", value: ink[3] }), - ) - }; - tysh.text.items.retain(|(key, _)| !key.is("bounds") && !key.is("boundingBox")); - tysh.text.items.push((Id::new("bounds"), rect("bounds"))); - tysh.text.items.push((Id::new("boundingBox"), rect("boundingBox"))); - let data = crate::psd::write_tysh(&tysh); + let original = Affine { m: [4.1667, 0.0, 0.0, 4.1667, -32375.0, -32887.5] }; + let saved_ink_origin = [8050.0, 8160.0]; + for align in [TextAlign::Left, TextAlign::Center, TextAlign::Right] { + let mut source = styled("Name", CharStyle { font_family: "Inter".into(), size_pt: 120.0, ..Default::default() }); + source.paragraphs = vec![ParagraphRun { len: source.text.len(), style: ParagraphStyle { align, ..Default::default() } }]; + let native = TextEngine::new().layout(&source, 72.0).bounds().unwrap(); + let saved_ink = [ + saved_ink_origin[0], + saved_ink_origin[1], + saved_ink_origin[0] + f64::from(native[2] - native[0]), + saved_ink_origin[1] + f64::from(native[3] - native[1]), + ]; + let rect = |class| { + D::Descriptor( + Descriptor::new(class) + .with("Left", D::UnitFloat { unit: *b"#Pnt", value: saved_ink[0] }) + .with("Top ", D::UnitFloat { unit: *b"#Pnt", value: saved_ink[1] }) + .with("Rght", D::UnitFloat { unit: *b"#Pnt", value: saved_ink[2] }) + .with("Btom", D::UnitFloat { unit: *b"#Pnt", value: saved_ink[3] }), + ) + }; + let mut tysh = crate::psd::parse_tysh(&crate::psd::build_tysh(&source, 72.0, None)).unwrap(); + tysh.transform = original; + tysh.text.items.retain(|(key, _)| !key.is("bounds") && !key.is("boundingBox")); + tysh.text.items.push((Id::new("bounds"), rect("bounds"))); + tysh.text.items.push((Id::new("boundingBox"), rect("boundingBox"))); + let data = crate::psd::write_tysh(&tysh); - let imported = crate::psd::text_layer_from_tysh(&data, 72.0).unwrap(); - let expected = [4.1667, 0.0, 0.0, 4.1667, 1166.935, 1112.772]; - for (got, want) in imported.transform.m.iter().zip(expected) { - assert!((got - want).abs() < 0.001, "{:?}", imported.transform.m); - } - let (_, rendered) = TextEngine::new().render(&imported, 72.0, PixelFormat::RGBA8); - let placed = rendered.surface.content_bounds(); - assert!(!placed.is_empty(), "the normalized layer renders"); - assert!((1000..3000).contains(&placed.x0) && (500..2000).contains(&placed.y0), "{placed:?}"); + let mut imported = crate::psd::text_layer_from_tysh(&data, 72.0).unwrap(); + imported.psd_raw = Some(std::sync::Arc::new(data.clone())); + let mut engine = TextEngine::new(); + crate::psd::refine_legacy_point_origin(&mut imported, 72.0, &mut engine, None); + assert_eq!(imported.paragraph_runs()[0].style.align, align); + let expected_anchor = original.apply(photocraft_geom::Point::new(saved_ink_origin[0], saved_ink_origin[1])); + let recovered_ink = imported.transform.apply(photocraft_geom::Point::new(f64::from(native[0]), f64::from(native[1]))); + assert!((recovered_ink.x - expected_anchor.x).abs() < 0.001, "{align:?}: {recovered_ink:?} vs {expected_anchor:?}"); + assert!((recovered_ink.y - expected_anchor.y).abs() < 0.001, "{align:?}: {recovered_ink:?} vs {expected_anchor:?}"); - let round_trip = crate::psd::text_layer_from_tysh(&crate::psd::build_tysh(&imported, 72.0, Some(ink.map(|v| v as f32))), 72.0).unwrap(); - for (got, want) in round_trip.transform.m.iter().zip(expected) { - assert!((got - want).abs() < 0.001, "{:?}", round_trip.transform.m); + let (_, rendered) = engine.render(&imported, 72.0, PixelFormat::RGBA8); + let placed = rendered.surface.content_bounds(); + assert!(!placed.is_empty(), "{align:?}: no rendered pixels"); + let mut expected = source.clone(); + expected.transform = original.mul(&Affine::translate(saved_ink_origin[0] - f64::from(native[0]), saved_ink_origin[1] - f64::from(native[1]))); + let (_, expected_pixels) = engine.render(&expected, 72.0, PixelFormat::RGBA8); + assert_eq!(placed, expected_pixels.surface.content_bounds(), "{align:?}: raster placement"); + + let round_trip_data = crate::psd::build_tysh(&imported, 72.0, Some(native)); + let round_trip = crate::psd::text_layer_from_tysh(&round_trip_data, 72.0).unwrap(); + let round_trip_ink = TextEngine::new().layout(&round_trip, 72.0).bounds().unwrap(); + let round_trip_origin = round_trip.transform.apply(photocraft_geom::Point::new(f64::from(round_trip_ink[0]), f64::from(round_trip_ink[1]))); + assert!((round_trip_origin.x - expected_anchor.x).abs() < 1.0, "{align:?}: {round_trip_origin:?}"); + assert!((round_trip_origin.y - expected_anchor.y).abs() < 1.0, "{align:?}: {round_trip_origin:?}"); + + // A valid frame may equal the old ink-corner estimate. It must still win over refinement. + let framed = with_text_index(&data, 0); + let txt2 = crate::psd::parse_txt2(&txt2_with_frame("Name", Some(saved_ink_origin), [1.0, 0.0, 0.0, 1.0, 0.0, 0.0])).unwrap(); + let mut with_frame = crate::psd::text_layer_from_tysh(&framed, 72.0).unwrap(); + with_frame.psd_raw = Some(std::sync::Arc::new(framed.clone())); + crate::psd::apply_txt2_frame(&mut with_frame, &framed, &txt2); + let authoritative = with_frame.transform; + crate::psd::refine_legacy_point_origin(&mut with_frame, 72.0, &mut engine, Some(&txt2)); + assert_eq!(with_frame.transform, authoritative, "{align:?}: exact frame wins"); } } +#[test] +fn legacy_origin_uses_the_rendering_engines_registered_face() { + let mut engine = TextEngine::new(); + let mut style = CharStyle { font_family: "JetBrains Mono".into(), font_style: "Regular".into(), size_pt: 100.0, ..Default::default() }; + // This exact-face alias exists only in this engine, like a user-registered font. + engine.fonts.select_named_face(&mut style); + assert!(style.font_family.starts_with(".PhotoCraft-face-")); + let source = with_para(styled("Name", style), ParagraphStyle { align: TextAlign::Right, ..Default::default() }); + let native = engine.layout(&source, 72.0).bounds().unwrap(); + let mut t = crate::psd::parse_tysh(&crate::psd::build_tysh(&source, 72.0, None)).unwrap(); + t.transform = Affine::translate(-8000.0, -8000.0); + let saved = [8100.0, 8200.0, 8100.0 + f64::from(native[2] - native[0]), 8200.0 + f64::from(native[3] - native[1])]; + let raw = with_bounds(&crate::psd::write_tysh(&t), saved); + let mut t = crate::psd::parse_tysh(&raw).unwrap(); + let bounds = t.text.get("bounds").unwrap().clone(); + t.text.items.retain(|(k, _)| !k.is("boundingBox")); + t.text.items.push((photocraft_psd::descriptor::Id::new("boundingBox"), bounds)); + let raw = crate::psd::write_tysh(&t); + let mut imported = crate::psd::text_layer_from_tysh(&raw, 72.0).unwrap(); + // Import preparation has resolved the face before refining placement. + imported.runs = source.runs.clone(); + imported.sync_summary(); + imported.psd_raw = Some(std::sync::Arc::new(raw)); + crate::psd::refine_legacy_point_origin(&mut imported, 72.0, &mut engine, None); + let bounds = engine.layout(&imported, 72.0).bounds().unwrap(); + let placed = imported.transform.apply(photocraft_geom::Point::new(f64::from(bounds[0]), f64::from(bounds[1]))); + assert!((placed.x - 100.0).abs() < 0.001 && (placed.y - 200.0).abs() < 0.001, "{placed:?}"); +} + /// Regression: a PSD whose text engine data has no `EngineDict` (or isn't a dictionary) /// panicked with `expect("EngineDict")` when the layer was written back (PSD export). #[test] diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index ba74623709..28cf1e337a 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File-format parity -> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-13 · **Change:** minor (earlier: PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-15 · **Change:** minor (earlier: PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; 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 @@ -142,6 +142,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings. | Date | Change | Summary | |---|---|---| +| 2026-10-15 | minor | Legacy PSD point-text placement is refined after font resolution using the rendering engine; centered/right alignment keeps its layout offset, while valid `Txt2` frames remain authoritative. Synthetic alignment, font-context and round-trip regressions cover this fallback. | | 2026-10-14 | minor | PSD smart filter masks: Photoshop stores a smart object's filtered pixels without its filter mask and mixes the unfiltered ones (`FEid`) back in; import now mixes them and export writes them that way, so sf-filter-mask-hard, -gradient and sf-stack-blend-and-mask pass; Photoshop-oracle floor 185 → 188 of 258 | | 2026-10-13 | minor | Lossy DNG (compression 34892) decodes: 8-bit baseline JPEG tiles and strips, CFA and LinearRaw, partial edge tiles; the stored values take the normal levels and LinearizationTable (FILE-215-11, lossy DNG part) | | 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 | From 9380a8ddb290fa509849b4b9543ade7bfbf236b9 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 08:06:22 -0700 Subject: [PATCH 090/649] docs: record area type (TYPE-218-10) in the scorecard and gaps Area type is partial: PSD saves it as paragraph text over the path's bounds, and mixed type sizes in one area paragraph space at the largest line. Also notes the 4096-anchor click limit and overflow of words wider than every span. TYPE-218-1 now credits the Type tool click on an outline. Co-Authored-By: Claude Opus 5.5 --- docs/gaps.md | 8 +++++--- docs/scorecard.md | 5 +++-- scorecard/type.toml | 9 ++++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/gaps.md b/docs/gaps.md index faf0884c89..ebfbb39ea5 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where PhotoCraft falls short of Photoshop -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-15 · **Change:** minor (G8: area type (TYPE-218-10); G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 @@ -82,10 +82,11 @@ what an agent can't finish alone. fallback fonts and golden tests (TYPE-218-3), OpenType Numerals and Stylistic Sets submenus (TYPE-218-5; the Character panel buttons landed 2026-10-11, #3752), live Warp Text preview (TYPE-218-7, #2689), "rasterize and continue" for distort/perspective on type - (TYPE-218-9), text free transform (#2630). Done since the re-measure: manual and optical kerning + (TYPE-218-9), text free transform (#2630), area type in PSD (TYPE-218-10). Done since the re-measure: manual and optical kerning with PSD round trip (TYPE-218-6, #206), variable-font axes (TYPE-218-4, #2985). - **Evidence:** scorecard Type: 3 done, 2 partial, 4 missing. 2026-10-11: 2/3/4/5 clicks select - word, line, paragraph and all text, with tests (TYPE-218-8, #3493). The Type tool froze the app for + word, line, paragraph and all text, with tests (TYPE-218-8, #3493). 2026-10-15: area type, type + inside a closed path or shape, with holes (TYPE-218-10). The Type tool froze the app for 60 s on one macOS machine (#2518). - **Estimate:** 120–200 h. @@ -270,6 +271,7 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| +| 2026-10-15 | minor | G8: area type: Type tool click inside a closed path or shape wraps text inside it (TYPE-218-10); Type tool click on a path's outline (TYPE-218-1) | | 2026-10-14 | minor | G1: a PSD smart object's filter mask shows when the file opens (Photoshop stores the filtered pixels unmasked); export stores them that way too; Photoshop-oracle floor 185 → 188 of 258 | | 2026-10-13 | minor | G14: D90 image area measured (4288 × 2848 at (10, 10)); gap remains open | | 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 | diff --git a/docs/scorecard.md b/docs/scorecard.md index 1e0576ba02..44593bca06 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -10,7 +10,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js | [File compatibility](#file-compatibility) | 7 | 14 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | | [Tools](#tools) | 33 | 11 | 0 | | | [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 166 (target 0) | -| [Type](#type) | 4 | 3 | 2 | | +| [Type](#type) | 4 | 4 | 2 | | | [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) | | [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 29 of 29 crates; panic_hunt present | | [Distribution](#distribution) | 5 | 4 | 2 | | @@ -211,7 +211,7 @@ Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_w | Id | Target | Status | Issue | Note | |---|---|---|---|---| -| TYPE-218-1 | Type on a path: path shape, glyphs along the curve, caret follows, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip. Missing: clicking a path with the Type tool, the caret and selection following the curve, and PSD path text (it saves as point text) | +| TYPE-218-1 | Type on a path: path shape, glyphs along the curve, caret follows, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip. Type tool click on a path's outline starts type there (type_tool.rs path_target, #218 area-type PR). Missing: the caret and selection following the curve, and PSD path text (it saves as point text) | | TYPE-218-2 | Paragraph direction (Auto/LTR/RTL) in the panel and options bar; visual RTL caret | missing | [#218](https://github.com/storytold/photocraft/issues/218) | Engine has TextDirection (text.rs:155); no UI | | TYPE-218-3 | Thai/Khmer/Indic fallback fonts; golden shaping tests for complex scripts and RTL | partial | [#218](https://github.com/storytold/photocraft/issues/218) | Fallback fonts are covered for Thai, Khmer, Lao, Myanmar (THAI_FAMILIES, KHMER_FAMILIES, LAO_FAMILIES, MYANMAR_FAMILIES in fonts.rs; #1909, #3259), the nine Indic scripts (INDIC_FAMILIES: Nirmala UI, Kohinoor and Sangam MN, Noto Sans) and Arabic and Hebrew. Still missing: per-script golden shaping tests against reference output (only smoke tests that an installed font shapes without .notdef, plus a bidi test) | | TYPE-218-4 | Variable font axis sliders from the font's axes; opsz follows the point size | done | [#218](https://github.com/storytold/photocraft/issues/218) | One slider per axis of the style's font in the Character section (Properties and Window > Character), setting type.setStyle variations; opsz follows the type size unless set (layout.rs variation_list); a style or weight resets the wght axis (#2985). PSD does not round-trip axis values yet | @@ -220,6 +220,7 @@ Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_w | TYPE-218-7 | Warp Text dialog previews live and opens with the layer's current warp | missing | [#218](https://github.com/storytold/photocraft/issues/218) | view_cmds.rs:834 always seeds arc, bend 50 | | TYPE-218-8 | Text editing: select all, double/triple/quadruple-click selection, paste, with tests | done | [#218](https://github.com/storytold/photocraft/issues/218) | Like Photoshop, 2 clicks select the word, 3 the laid-out line (a column in vertical type), 4 the paragraph up to the hard return, 5 all text, and the next quick click starts over (#3493; type_tool.rs next_click_count, click_selection, multi_click). Tested through real canvas clicks in point, paragraph and vertical type, with paste replacing the selection and Cmd+A selecting all (type_tool_tests.rs multi_click_selects_word_line_paragraph_and_all_in_point_text, multi_click_separates_wrapped_lines_from_paragraphs, click_counts_cycle_and_restart, click_selection_without_layout_and_on_hostile_input, multi_click_without_a_session_does_nothing) | | TYPE-218-9 | Distort/Perspective/Warp on live type as in Photoshop (was: offer 'Rasterize and continue?'; Photoshop doesn't prompt) | done | [#218](https://github.com/storytold/photocraft/issues/218) | Photoshop 2026 prompts for none of these: Edit › Transform › Warp on live type stays enabled with no rasterize prompt and offers only the warp styles (the mesh can't be dragged), so the type stays editable; Distort, Perspective and the split warps are greyed. PhotoCraft does the same: Warp on type commits the layer's Warp Text in one step (transform_tool.rs enter_type_warp, warp_cmds.rs warp_type_layer, #3004; warp_on_type_takes_a_style_and_keeps_the_type_editable), Distort/Perspective greyed (enable_rules.rs, #2701) | +| TYPE-218-10 | Area type: Type tool click inside a closed path or shape wraps text inside it, holes and dents included, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; a Type tool click only targets paths with at most 4096 anchors (a bigger path gets point text on click, though type.fillPath still works on it); a word too wide for every span in the shape overflows its span the way box text does | ## Automation diff --git a/scorecard/type.toml b/scorecard/type.toml index ee8a876a41..1a9e2ee164 100644 --- a/scorecard/type.toml +++ b/scorecard/type.toml @@ -9,7 +9,7 @@ id = "TYPE-218-1" target = "Type on a path: path shape, glyphs along the curve, caret follows, PSD round trip" status = "partial" issue = 218 -note = "TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip. Missing: clicking a path with the Type tool, the caret and selection following the curve, and PSD path text (it saves as point text)" +note = "TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip. Type tool click on a path's outline starts type there (type_tool.rs path_target, #218 area-type PR). Missing: the caret and selection following the curve, and PSD path text (it saves as point text)" [[item]] id = "TYPE-218-2" @@ -66,3 +66,10 @@ target = "Distort/Perspective/Warp on live type as in Photoshop (was: offer 'Ras status = "done" issue = 218 note = "Photoshop 2026 prompts for none of these: Edit › Transform › Warp on live type stays enabled with no rasterize prompt and offers only the warp styles (the mesh can't be dragged), so the type stays editable; Distort, Perspective and the split warps are greyed. PhotoCraft does the same: Warp on type commits the layer's Warp Text in one step (transform_tool.rs enter_type_warp, warp_cmds.rs warp_type_layer, #3004; warp_on_type_takes_a_style_and_keeps_the_type_editable), Distort/Perspective greyed (enable_rules.rs, #2701)" + +[[item]] +id = "TYPE-218-10" +target = "Area type: Type tool click inside a closed path or shape wraps text inside it, holes and dents included, PSD round trip" +status = "partial" +issue = 218 +note = "TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; a Type tool click only targets paths with at most 4096 anchors (a bigger path gets point text on click, though type.fillPath still works on it); a word too wide for every span in the shape overflows its span the way box text does" From de3e05a36a55499fa4a50f31f51bc1457bfbf8c0 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 08:20:11 -0700 Subject: [PATCH 091/649] fix(text): let combined shapes' inner edges stop cutting area rows A speech bubble (an ellipse combined with a tail) split every row that crossed the tail: spans() blocked the x-range swept by every edge in the band, including the tail's edges hidden inside the ellipse's fill. Each component now gives the x-ranges inside it for the whole band (middle-row inside minus its own swept edges) and those inside it on some row (middle-row inside plus its swept edges). The components fold with their ops: Combine/Join unite the whole ranges, Subtract removes everything the cut ever covers, Intersect keeps what both hold throughout, and Exclude keeps what one holds throughout and the other never touches. Fill rules still apply within a component, so holes stay holes and text never sits over a cutout. Co-Authored-By: Claude Opus 5.5 --- crates/text/src/area.rs | 112 +++++++++++++++++++++++++++++++--------- 1 file changed, 87 insertions(+), 25 deletions(-) diff --git a/crates/text/src/area.rs b/crates/text/src/area.rs index aab563e623..7bde357322 100644 --- a/crates/text/src/area.rs +++ b/crates/text/src/area.rs @@ -188,25 +188,23 @@ impl AreaShape { acc } - /// The x-ranges swept by edges while inside `[y0, y1]`, sorted and merged. - fn swept(&self, y0: f32, y1: f32) -> Vec<(f32, f32)> { + /// The x-ranges swept by the edges of `c` while inside `[y0, y1]`, sorted and merged. + fn swept(&self, c: &Component, y0: f32, y1: f32) -> Vec<(f32, f32)> { let mut v: Vec<(f32, f32)> = Vec::new(); - for c in &self.comps { - for e in self.candidates(c, y0, y1) { - if e.hi < y0 || e.lo > y1 { - continue; - } - if e.lo == e.hi { - // A horizontal edge only matters strictly inside the band. - if e.lo > y0 && e.lo < y1 { - v.push((e.x0.min(e.x1), e.x0.max(e.x1))); - } - continue; - } - let at = |y: f32| e.x0 + (y - e.y0) / (e.y1 - e.y0) * (e.x1 - e.x0); - let (xa, xb) = (at(e.lo.max(y0)), at(e.hi.min(y1))); - v.push((xa.min(xb), xa.max(xb))); + for e in self.candidates(c, y0, y1) { + if e.hi < y0 || e.lo > y1 { + continue; } + if e.lo == e.hi { + // A horizontal edge only matters strictly inside the band. + if e.lo > y0 && e.lo < y1 { + v.push((e.x0.min(e.x1), e.x0.max(e.x1))); + } + continue; + } + let at = |y: f32| e.x0 + (y - e.y0) / (e.y1 - e.y0) * (e.x1 - e.x0); + let (xa, xb) = (at(e.lo.max(y0)), at(e.hi.min(y1))); + v.push((xa.min(xb), xa.max(xb))); } v.sort_by(|a, b| a.0.total_cmp(&b.0)); let mut out: Vec<(f32, f32)> = Vec::new(); @@ -220,18 +218,38 @@ impl AreaShape { } /// Intervals inside the shape on every row of `[y0, y1]`, left to right, each at least - /// `min_width` wide. A point is inside for the whole band exactly when it is inside on one - /// row and no edge crosses its vertical segment, so: the inside intervals at the middle row, - /// minus everything the edges sweep across within the band. Edges that lie inside the filled - /// area (inner edges of overlapping Combine/Join components, or Subtract edges outside the - /// shape) also block width. That is conservative and never puts text over a cutout. + /// `min_width` wide. + /// + /// Within one component a point is inside for the whole band exactly when it is inside on + /// the middle row and none of that component's edges crosses its vertical segment + /// (`whole`); it is inside on some row when either holds (`ever`). The components then fold + /// together with their ops, so an edge hidden inside another component's fill (the inner + /// edges of a speech bubble's tail) never cuts the row, and text never sits over a cutout: + /// Subtract takes away everything the cut ever covers. pub fn spans(&self, y0: f32, y1: f32, min_width: f32) -> Vec<(f32, f32)> { if !(y0.is_finite() && y1.is_finite()) || y1 < y0 { return Vec::new(); } - let base = self.intervals_at(y0 + (y1 - y0) * 0.5); - let blocked = self.swept(y0, y1); - boolean(&base, &blocked, |a, b| a && !b).into_iter().filter(|(l, r)| r - l >= min_width).collect() + let mid = y0 + (y1 - y0) * 0.5; + let mut whole: Vec<(f32, f32)> = Vec::new(); + let mut ever: Vec<(f32, f32)> = Vec::new(); + for c in &self.comps { + let inside = self.component_intervals(c, mid); + let edges = self.swept(c, y0, y1); + let w = boolean(&inside, &edges, |a, b| a && !b); + let e = boolean(&inside, &edges, |a, b| a || b); + (whole, ever) = match c.op { + PathOp::Combine | PathOp::Join => (boolean(&whole, &w, |a, b| a || b), boolean(&ever, &e, |a, b| a || b)), + PathOp::Subtract => (boolean(&whole, &e, |a, b| a && !b), boolean(&ever, &w, |a, b| a && !b)), + PathOp::Intersect => (boolean(&whole, &w, |a, b| a && b), boolean(&ever, &e, |a, b| a && b)), + PathOp::Exclude => { + let both = boolean(&whole, &w, |a, b| a && b); + let x = boolean(&boolean(&whole, &e, |a, b| a && !b), &boolean(&w, &ever, |a, b| a && !b), |a, b| a || b); + (x, boolean(&boolean(&ever, &e, |a, b| a || b), &both, |a, b| a && !b)) + } + }; + } + whole.into_iter().filter(|(l, r)| r - l >= min_width).collect() } /// The first baseline at or below `from` whose band `[b - ascent, b + descent]` has spans @@ -394,6 +412,50 @@ mod tests { assert!(a.contains(50.0, 50.0) && !a.contains(3.0, 3.0)); } + /// A 260×160 ellipse at the origin from four kappa curves. + fn ellipse() -> Subpath { + let (cx, cy, rx, ry) = (130.0, 80.0, 130.0, 80.0); + let (kx, ky) = (0.552_284_75 * rx, 0.552_284_75 * ry); + let p = photocraft_geom::Point::new; + let c = |x: f64, y: f64, ix: f64, iy: f64, ox: f64, oy: f64| Knot::smooth(p(x, y), p(ix, iy), p(ox, oy)); + Subpath { + closed: true, + knots: vec![ + c(cx, cy - ry, cx - kx, cy - ry, cx + kx, cy - ry), + c(cx + rx, cy, cx + rx, cy - ky, cx + rx, cy + ky), + c(cx, cy + ry, cx + kx, cy + ry, cx - kx, cy + ry), + c(cx - rx, cy, cx - rx, cy + ky, cx - rx, cy - ky), + ], + op: PathOp::Combine, + } + } + + /// The speech bubble: the ellipse combined with a tail whose wide end sits inside it. + fn bubble() -> AreaShape { + let tail = Subpath::polygon(&[(120.0, 64.0), (180.0, 64.0), (230.0, 210.0)]).with_op(PathOp::Combine); + AreaShape::new(&Path::new(vec![ellipse(), tail]), false).unwrap() + } + + #[test] + fn combined_overlap_hides_inner_edges() { + let a = bubble(); + // Rows through the overlap: the tail's edges inside the ellipse must not cut the row. + for y0 in [56.0f32, 70.0, 90.0, 110.0, 120.0] { + let s = a.spans(y0, y0 + 18.0, 1.0); + assert_eq!(s.len(), 1, "band {y0}: {s:?}"); + // The ellipse's own edge bounds the row on both sides. + let dy = (y0 - 80.0).abs().max((y0 + 18.0 - 80.0).abs()); + let half = 130.0 * (1.0 - (dy / 80.0).powi(2)).sqrt(); + assert!((s[0].0 - (130.0 - half)).abs() < 0.5 && (s[0].1 - (130.0 + half)).abs() < 0.5, "band {y0}: {s:?}"); + } + // Lower down the tail pokes out on the right: still one span, out to the tail's edge. + let s = a.spans(130.0, 148.0, 1.0); + assert!(s.len() == 1 && s[0].1 > 202.0, "{s:?}"); + // Below the ellipse only the tail is left. + let s = a.spans(165.0, 183.0, 1.0); + assert!(s.len() == 1 && s[0].0 > 190.0 && s[0].1 < 220.0, "{s:?}"); + } + #[test] fn next_row_skips_the_narrow_top() { let a = AreaShape::new(&poly(&[(50.0, 0.0), (100.0, 100.0), (0.0, 100.0)]), false).unwrap(); From f17f1dc4c637448741d5eefba257742ed9eeefd8 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 08:21:08 -0700 Subject: [PATCH 092/649] fix(text): leave out area components that enclose nothing, and cap them A component made only of open subpaths has no edges. Folded in with Intersect it emptied every row, so an open path left in a shape layer's path stopped all area text. Such components are now skipped, as they add no fill. Every row folds in each component, so the count is also capped (4096) to keep a path of thousands of tiny shapes from making each line cost thousands of interval merges; past the cap the path gives no area, like the existing edge cap. Co-Authored-By: Claude Opus 5.5 --- crates/text/src/area.rs | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/crates/text/src/area.rs b/crates/text/src/area.rs index 7bde357322..806b3df22b 100644 --- a/crates/text/src/area.rs +++ b/crates/text/src/area.rs @@ -14,6 +14,9 @@ use photocraft_geom::Point; const CURVE_PIECES: usize = 16; /// Largest number of edges an area keeps, so a hostile path can't make every line scan millions. pub const MAX_AREA_EDGES: usize = 65_536; +/// Most shape components an area keeps: every row folds each one in, so a path of thousands of +/// tiny shapes can't make each line cost thousands of interval merges. +pub const MAX_AREA_COMPONENTS: usize = 4096; /// Largest coordinate magnitude an area accepts, so f32 math on it can't overflow. const MAX_COORD: f64 = 1e7; /// Most baselines `next_row` tries before giving up. @@ -69,7 +72,9 @@ fn small(v: f64) -> Option { impl AreaShape { /// `None` when the path encloses nothing: no closed subpath, no height or width, an /// inverted (unbounded) path, coordinates that aren't finite, or more than - /// [`MAX_AREA_EDGES`] edges. + /// [`MAX_AREA_EDGES`] edges or [`MAX_AREA_COMPONENTS`] components. A component with no + /// closed subpath encloses nothing and is left out, so an open path drawn with Intersect + /// doesn't empty the shape. pub fn new(path: &Path, vertical: bool) -> Option { if path.inverted { return None; @@ -114,6 +119,12 @@ impl AreaShape { return None; } } + if edges.len() == start { + continue; + } + if comps.len() >= MAX_AREA_COMPONENTS { + return None; + } if let Some(mine) = edges.get_mut(start..) { mine.sort_by(|a, b| a.lo.total_cmp(&b.lo)); } @@ -456,6 +467,28 @@ mod tests { assert!(s.len() == 1 && s[0].0 > 190.0 && s[0].1 < 220.0, "{s:?}"); } + #[test] + fn component_without_edges_is_left_out() { + let rect = Subpath::polygon(&[(0.0, 0.0), (100.0, 0.0), (100.0, 50.0), (0.0, 50.0)]); + let open = Subpath::polyline(&[(10.0, 10.0), (90.0, 40.0)]).with_op(PathOp::Intersect); + let a = AreaShape::new(&Path::new(vec![rect, open]), false).unwrap(); + let s = a.spans(10.0, 20.0, 1.0); + assert!(s.len() == 1 && close(s[0], (0.0, 100.0)), "{s:?}"); + } + + #[test] + fn too_many_components_give_no_area() { + let square = |i: usize| { + let x = (i % 100) as f64 * 3.0; + let y = (i / 100) as f64 * 3.0; + Subpath::polygon(&[(x, y), (x + 2.0, y), (x + 2.0, y + 2.0), (x, y + 2.0)]) + }; + let at_cap: Vec = (0..MAX_AREA_COMPONENTS).map(square).collect(); + assert!(AreaShape::new(&Path::new(at_cap), false).is_some()); + let over: Vec = (0..=MAX_AREA_COMPONENTS).map(square).collect(); + assert!(AreaShape::new(&Path::new(over), false).is_none()); + } + #[test] fn next_row_skips_the_narrow_top() { let a = AreaShape::new(&poly(&[(50.0, 0.0), (100.0, 100.0), (0.0, 100.0)]), false).unwrap(); From 250c15c503ce01fa7d4c81803ef8367a69f36520 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 08:28:57 -0700 Subject: [PATCH 093/649] fix(ui): no Type tool path target while the target path is hidden With View > Show > Target Path (or Extras) off the canvas draws no path, yet a Type tool click still turned into area or path type on it. The target now uses the same check the canvas uses to draw the path, so a click on a hidden path makes plain point text and the pointer agrees. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/type_tool.rs | 4 ++++ crates/ui-egui/src/type_tool_tests.rs | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/crates/ui-egui/src/type_tool.rs b/crates/ui-egui/src/type_tool.rs index 30d03d6aa5..a2ebf1a913 100644 --- a/crates/ui-egui/src/type_tool.rs +++ b/crates/ui-egui/src/type_tool.rs @@ -326,8 +326,12 @@ fn arc_length_to(sub: &photocraft_doc::Subpath, seg: usize, t: f64) -> f64 { /// The path a Type tool click at document `(x, y)` would use: the active shape layer's path, /// else the work path (the path Photoshop shows), within 4 screen px of its outline or inside it. +/// None while View › Show › Target Path (or Extras) hides the path, as the canvas then draws none. pub(crate) fn path_target(app: &PhotocraftApp, x: f64, y: f64) -> Option { use photocraft_vector::edit::{Hit, hit}; + if !app.ui.view.shows(app.ui.view.show.target_path) { + return None; + } let (shape, path) = match crate::vector_ui::active_shape_path(app) { Some((id, p)) => (Some(id), p), None => (None, app.session.active()?.doc.work_path.clone()?), diff --git a/crates/ui-egui/src/type_tool_tests.rs b/crates/ui-egui/src/type_tool_tests.rs index 99c3a48640..278f71152c 100644 --- a/crates/ui-egui/src/type_tool_tests.rs +++ b/crates/ui-egui/src/type_tool_tests.rs @@ -2192,3 +2192,17 @@ fn paths_with_too_many_anchors_are_not_hover_targets() { Some(photocraft_doc::Path::new(vec![photocraft_doc::Subpath::polygon(&ring(5000))])); assert!(path_target(&app, 500.0, 400.0).is_none()); } + +#[test] +fn hidden_target_path_is_not_a_click_target() { + // View › Show › Target Path off hides the path, so a click there makes plain point text. + let mut app = new_app(); + std::sync::Arc::make_mut(&mut app.session.active_mut().unwrap().doc).work_path = + Some(photocraft_doc::Path::new(vec![photocraft_doc::Subpath::polygon(&[(300.0, 300.0), (700.0, 300.0), (700.0, 500.0), (300.0, 500.0)])])); + assert!(matches!(path_target(&app, 500.0, 400.0), Some(PathClick::Area { shape: None }))); + app.ui.view.show.target_path = false; + assert!(path_target(&app, 500.0, 400.0).is_none(), "Target Path off"); + app.ui.view.show.target_path = true; + app.ui.view.extras = false; + assert!(path_target(&app, 500.0, 400.0).is_none(), "Extras off"); +} From d3da314b5f029403b8738816317c6b7797c8addb Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 08:32:16 -0700 Subject: [PATCH 094/649] perf(ui): skip the type layout in hit_layer when the pixels already hit The Type tool hover calls hit_layer every frame over a path, and it laid out each candidate layer even when the layer's shown pixels already answered the hit. It now returns as soon as the pixels hit; the result is unchanged because the pixel hit was or'ed in anyway. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/type_tool.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/type_tool.rs b/crates/ui-egui/src/type_tool.rs index a2ebf1a913..f790625531 100644 --- a/crates/ui-egui/src/type_tool.rs +++ b/crates/ui-egui/src/type_tool.rs @@ -76,9 +76,13 @@ fn hit_layer(app: &mut PhotocraftApp, x: f64, y: f64) -> Option { let s = f64::from(slop); !r.is_empty() && x >= f64::from(r.x0) - s && x <= f64::from(r.x1) + s && y >= f64::from(r.y0) - s && y <= f64::from(r.y1) + s }); - let Some((l, aff, _)) = layout(app, *id) else { return shown }; + // The hover calls this every frame: skip the layout when the pixels already answer. + if shown { + return true; + } + let Some((l, aff, _)) = layout(app, *id) else { return false }; let (tx, ty) = to_text(&aff, x, y); - shown || photocraft_text::text_point_inside(&l, tx, ty, slop) + photocraft_text::text_point_inside(&l, tx, ty, slop) }) } From 7040fdc233ce6e50d951450fcbd703e4a689a578 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 08:45:38 -0700 Subject: [PATCH 095/649] fix(type): use an area path's bounds only when they are finite PSD export, Release Type from Path and the type transform box all took the area path's control_bounds() as given. A path from a file can hold NaN, infinite or huge coordinates, and f64::min skips a NaN, so those bounds could be NaN, infinite, or finite while the path itself is not; they then became a NaN BoxBounds in the PSD or a NaN text box. photocraft_text::area::path_bounds returns the bounds only when every point is finite and within the area module's 1e7 coordinate limit (the paths AreaShape accepts). PSD export then saves point text, release returns an error, and the transform box falls back to the layout bounds. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/type_area_cmds/tests.rs | 19 +++++++++++++++++ crates/engine/src/type_extra_cmds.rs | 3 ++- crates/text/src/area.rs | 23 +++++++++++++++++++++ crates/text/src/psd.rs | 25 +++++++++++++++++++++-- crates/ui-egui/src/type_transform.rs | 2 +- 5 files changed, 68 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/type_area_cmds/tests.rs b/crates/engine/src/type_area_cmds/tests.rs index e8e72953bd..2c43125731 100644 --- a/crates/engine/src/type_area_cmds/tests.rs +++ b/crates/engine/src/type_area_cmds/tests.rs @@ -128,6 +128,25 @@ fn release_turns_area_type_into_box_text_over_the_path() { assert!(matches!(text(&s, id).shape, TextShape::Area { .. })); } +#[test] +fn release_with_a_path_that_is_not_finite_is_an_error() { + let mut s = session(8); + let id = text_layer(&mut s, WORDS); + // A file can carry any coordinates: one NaN or infinite point must not become a NaN text box. + for bad in [f64::NAN, f64::INFINITY] { + let path = Path::new(vec![Subpath::polygon(&[(0.0, 0.0), (100.0, bad), (100.0, 100.0)])]); + s.edit("area", |doc, _| { + if let Some(LayerContent::Text(t)) = doc.layer_mut(id).map(|l| &mut l.content) { + t.shape = TextShape::Area { path }; + } + Ok(()) + }) + .unwrap(); + assert!(s.execute("type.detachFromPath", json!({})).is_err(), "{bad}"); + assert!(matches!(text(&s, id).shape, TextShape::Area { .. }), "unchanged"); + } +} + #[test] fn area_type_saves_to_psd_as_paragraph_text_with_a_warning() { let mut s = session(8); diff --git a/crates/engine/src/type_extra_cmds.rs b/crates/engine/src/type_extra_cmds.rs index 533958c64d..c0d4f1c8a5 100644 --- a/crates/engine/src/type_extra_cmds.rs +++ b/crates/engine/src/type_extra_cmds.rs @@ -410,7 +410,8 @@ fn detach_from_path(s: &mut Session, p: &Value) -> Result { } // Area type keeps wrapping, in a text box over the path's bounds. TextShape::Area { path } => { - let (x0, y0, x1, y1) = path.control_bounds().ok_or_else(|| EngineError::Other("the area type's path is empty".into()))?; + let (x0, y0, x1, y1) = photocraft_text::area::path_bounds(path) + .ok_or_else(|| EngineError::Other("the area type's path is empty or has coordinates that aren't finite".into()))?; t.shape = TextShape::Box { x: x0 as f32, y: y0 as f32, width: ((x1 - x0) as f32).max(1.0), height: ((y1 - y0) as f32).max(1.0) }; } _ => return Err(EngineError::Other("the type layer is not on a path".into())), diff --git a/crates/text/src/area.rs b/crates/text/src/area.rs index 806b3df22b..c616a02bba 100644 --- a/crates/text/src/area.rs +++ b/crates/text/src/area.rs @@ -291,6 +291,18 @@ impl AreaShape { } } +/// Bounds `(x0, y0, x1, y1)` of an area type path's anchors and control points, when every point +/// is finite and within the area coordinate limit (`1e7`), the same paths [`AreaShape::new`] +/// accepts. `None` for an empty path or one with a NaN, infinite or huge coordinate, so callers +/// that turn the bounds into a text box or a PSD rectangle never write NaN. +pub fn path_bounds(path: &Path) -> Option<(f64, f64, f64, f64)> { + let ok = |p: Point| p.x.is_finite() && p.y.is_finite() && p.x.abs() <= MAX_COORD && p.y.abs() <= MAX_COORD; + if !path.subpaths.iter().flat_map(|s| &s.knots).all(|k| ok(k.anchor) && ok(k.in_ctrl) && ok(k.out_ctrl)) { + return None; + } + path.control_bounds() +} + /// Boolean combination of two sorted, disjoint interval lists, in one linear merge. fn boolean(a: &[(f32, f32)], b: &[(f32, f32)], f: impl Fn(bool, bool) -> bool) -> Vec<(f32, f32)> { let ends = |v: &[(f32, f32)]| -> Vec { v.iter().flat_map(|&(l, r)| [l, r]).collect() }; @@ -489,6 +501,17 @@ mod tests { assert!(AreaShape::new(&Path::new(over), false).is_none()); } + #[test] + fn path_bounds_need_finite_small_points() { + assert_eq!(path_bounds(&poly(&[(1.0, 2.0), (30.0, 2.0), (30.0, 40.0)])), Some((1.0, 2.0, 30.0, 40.0))); + assert_eq!(path_bounds(&Path::default()), None); + for bad in [f64::NAN, f64::INFINITY, -f64::INFINITY, 2e7] { + // Anywhere in the path, not just the first point (`f64::min` skips a NaN). + assert_eq!(path_bounds(&poly(&[(0.0, 0.0), (10.0, bad), (10.0, 10.0)])), None, "{bad}"); + assert_eq!(path_bounds(&poly(&[(bad, 0.0), (10.0, 0.0), (10.0, 10.0)])), None, "{bad}"); + } + } + #[test] fn next_row_skips_the_narrow_top() { let a = AreaShape::new(&poly(&[(50.0, 0.0), (100.0, 100.0), (0.0, 100.0)]), false).unwrap(); diff --git a/crates/text/src/psd.rs b/crates/text/src/psd.rs index 4c8c966ac4..c3eb714c28 100644 --- a/crates/text/src/psd.rs +++ b/crates/text/src/psd.rs @@ -1194,7 +1194,7 @@ pub fn build_engine_data(layer: &TextLayer, template: Option, dpi: f32) -> E TextShape::Box { x, y, width, height } => (1, Some([*x, *y, x + width, y + height])), // PSD area type is not written yet: the layer saves as paragraph text over the path's // bounds, so Photoshop opens it with the same text wrapping in a rectangle. - TextShape::Area { path } => match path.control_bounds() { + TextShape::Area { path } => match crate::area::path_bounds(path) { Some((x0, y0, x1, y1)) => (1, Some([x0 as f32, y0 as f32, x1 as f32, y1 as f32])), None => (0, None), }, @@ -1310,7 +1310,7 @@ pub fn build_tysh(layer: &TextLayer, dpi: f32, ink: Option<[f32; 4]>) -> Vec ), ); let area = match &layer.shape { - TextShape::Area { path } => path.control_bounds().map(|(x0, y0, x1, y1)| [x0 as f32, y0 as f32, x1 as f32, y1 as f32]), + TextShape::Area { path } => crate::area::path_bounds(path).map(|(x0, y0, x1, y1)| [x0 as f32, y0 as f32, x1 as f32, y1 as f32]), _ => None, }; let [l, t, r, b] = match (&layer.shape, area, ink) { @@ -1373,6 +1373,27 @@ mod nonfinite_tests { assert_eq!(char_style(None, &d, &[], 1.0).size_pt, 24.0); } + #[test] + fn area_path_that_is_not_finite_saves_as_point_text() { + let path = photocraft_doc::vector::Path::new(vec![photocraft_doc::vector::Subpath::polygon(&[(0.0, 0.0), (f64::NAN, 0.0), (10.0, f64::INFINITY)])]); + let layer = TextLayer { + text: "x".into(), + runs: vec![TextRun { len: 1, style: CharStyle { size_pt: 12.0, ..Default::default() } }], + shape: TextShape::Area { path }, + ..Default::default() + }; + let out = String::from_utf8_lossy(&crate::engine_data::write(&build_engine_data(&layer, None, 72.0))).into_owned(); + assert!(out.contains("/PointBase") && !out.contains("/BoxBounds"), "{out}"); + assert!(!out.to_ascii_lowercase().contains("nan") && !out.to_ascii_lowercase().contains("inf"), "{out}"); + let t = parse_tysh(&build_tysh(&layer, 72.0, None)).unwrap(); + for key in ["bounds", "boundingBox"] { + let Some(D::Descriptor(d)) = t.text.get(key) else { panic!("no {key}") }; + for side in ["Left", "Top ", "Rght", "Btom"] { + assert!(matches!(d.get(side), Some(D::UnitFloat { value, .. }) if value.is_finite()), "{key} {side}: {:?}", d.get(side)); + } + } + } + #[test] fn infinite_dpi_does_not_write_a_zero_size() { let layer = diff --git a/crates/ui-egui/src/type_transform.rs b/crates/ui-egui/src/type_transform.rs index 890e4b9687..f634db30cc 100644 --- a/crates/ui-egui/src/type_transform.rs +++ b/crates/ui-egui/src/type_transform.rs @@ -93,7 +93,7 @@ pub(crate) fn frame(app: &mut PhotocraftApp) -> Option { return None; } let area = match &shape { - TextShape::Area { path } => path.control_bounds(), + TextShape::Area { path } => photocraft_text::area::path_bounds(path), _ => None, }; let rect = match (shape, area) { From da1764082edaa42cdbbcaaea909b76d850158dbf Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 08:52:38 -0700 Subject: [PATCH 096/649] fix(type): refuse area paths over 4096 anchors as too many anchor points type.fillPath accepted up to 100,000 anchors, but each curved segment flattens to 16 edges against a 65,536-edge cap, so a big curved path failed with the misleading "the path encloses no area". The anchor limit now lives in photocraft_text::area as MAX_AREA_KNOTS (4096, the Type tool's existing click cap) and the edge cap is derived from it (4096 x 17), so every path within the limit fits even with every segment curved, and a bigger one gets "the path has too many anchor points". The Type tool's click cap now names the same constant, so a path it offers as an area target can always be filled. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/type_area_cmds.rs | 5 ++-- crates/engine/src/type_area_cmds/tests.rs | 31 +++++++++++++++++++++++ crates/text/src/area.rs | 7 ++++- crates/ui-egui/src/type_tool.rs | 5 ++-- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/type_area_cmds.rs b/crates/engine/src/type_area_cmds.rs index 09b22b0fca..af04aaa4f0 100644 --- a/crates/engine/src/type_area_cmds.rs +++ b/crates/engine/src/type_area_cmds.rs @@ -13,8 +13,9 @@ use crate::{EngineError, Result, Session}; const CMD: &str = "type.fillPath"; -/// Largest total anchor count of a path area type can fill (as for type on a path). -const MAX_AREA_KNOTS: usize = 100_000; +// Largest total anchor count of a path area type can fill. Within it every path fits the area +// edge cap, so a big curved path gets "too many anchor points" rather than "encloses no area". +use photocraft_text::area::MAX_AREA_KNOTS; fn bad(m: &str) -> EngineError { EngineError::BadParams { cmd: CMD.into(), msg: m.into() } diff --git a/crates/engine/src/type_area_cmds/tests.rs b/crates/engine/src/type_area_cmds/tests.rs index 2c43125731..7ca20cf7c6 100644 --- a/crates/engine/src/type_area_cmds/tests.rs +++ b/crates/engine/src/type_area_cmds/tests.rs @@ -166,3 +166,34 @@ fn area_type_saves_to_psd_as_paragraph_text_with_a_warning() { assert!(matches!(t.shape, TextShape::Box { width, height, .. } if (width - 200.0).abs() < 0.5 && (height - 150.0).abs() < 0.5), "{:?}", t.shape); let _ = id; } + +#[test] +fn too_many_anchors_is_its_own_error() { + // A ring of `n` smooth (curved) anchors around (200, 150). + let ring = |n: usize| { + let p = |a: f64, r: f64| photocraft_geom::Point::new(200.0 + r * a.cos(), 150.0 + r * a.sin()); + let step = std::f64::consts::TAU / n as f64; + let knots = (0..n) + .map(|i| { + let a = i as f64 * step; + let (anchor, d) = (p(a, 100.0), 100.0 * step / 3.0); + let (tx, ty) = (-a.sin() * d, a.cos() * d); + let at = |k: f64| photocraft_geom::Point::new(anchor.x + k * tx, anchor.y + k * ty); + photocraft_doc::vector::Knot::smooth(anchor, at(-1.0), at(1.0)) + }) + .collect(); + Path::new(vec![Subpath { closed: true, knots, op: PathOp::Combine }]) + }; + let mut s = session(8); + let id = text_layer(&mut s, WORDS); + // Every anchor up to the limit fits, even with every segment curved. + set_work_path(&mut s, ring(MAX_AREA_KNOTS)); + s.execute("type.fillPath", json!({})).unwrap(); + assert!(matches!(text(&s, id).shape, TextShape::Area { .. })); + // One more is refused for what it is, not as a path that encloses nothing. + let id = text_layer(&mut s, WORDS); + set_work_path(&mut s, ring(MAX_AREA_KNOTS + 1)); + let e = s.execute("type.fillPath", json!({})).unwrap_err().to_string(); + assert!(e.contains("too many anchor points"), "{e}"); + assert_eq!(text(&s, id).shape, TextShape::Point); +} diff --git a/crates/text/src/area.rs b/crates/text/src/area.rs index c616a02bba..407065355d 100644 --- a/crates/text/src/area.rs +++ b/crates/text/src/area.rs @@ -12,8 +12,13 @@ use photocraft_geom::Point; /// Pieces each curved segment is cut into (about 0.1 px off a 300 px bubble's curve). const CURVE_PIECES: usize = 16; +/// Most anchors an area path can have: the most `type.fillPath` accepts and a Type tool click +/// targets (`path_target` in ui-egui). +pub const MAX_AREA_KNOTS: usize = 4096; /// Largest number of edges an area keeps, so a hostile path can't make every line scan millions. -pub const MAX_AREA_EDGES: usize = 65_536; +/// A closed subpath of `n` anchors gives at most `CURVE_PIECES * n + 1` edges, so every path +/// within [`MAX_AREA_KNOTS`] fits, even with every segment curved. +pub const MAX_AREA_EDGES: usize = MAX_AREA_KNOTS * (CURVE_PIECES + 1); /// Most shape components an area keeps: every row folds each one in, so a path of thousands of /// tiny shapes can't make each line cost thousands of interval merges. pub const MAX_AREA_COMPONENTS: usize = 4096; diff --git a/crates/ui-egui/src/type_tool.rs b/crates/ui-egui/src/type_tool.rs index f790625531..a8f4058fb1 100644 --- a/crates/ui-egui/src/type_tool.rs +++ b/crates/ui-egui/src/type_tool.rs @@ -342,8 +342,9 @@ pub(crate) fn path_target(app: &PhotocraftApp, x: f64, y: f64) -> Option MAX_TARGET_KNOTS { return None; } From cfe8f19202245e3fc1c40a9b8ec5cea86ab923d3 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 08:52:38 -0700 Subject: [PATCH 097/649] docs: say what area type does with paths over 4096 anchors The TYPE-218-10 note said type.fillPath still worked on paths beyond the Type tool's click cap; it never did for curved paths, and it now refuses them with "too many anchor points". The note says what a click and the command each do, and docs/scorecard.md is regenerated. Co-Authored-By: Claude Opus 5.5 --- docs/scorecard.md | 2 +- scorecard/type.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/scorecard.md b/docs/scorecard.md index 44593bca06..af9db78e63 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -220,7 +220,7 @@ Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_w | TYPE-218-7 | Warp Text dialog previews live and opens with the layer's current warp | missing | [#218](https://github.com/storytold/photocraft/issues/218) | view_cmds.rs:834 always seeds arc, bend 50 | | TYPE-218-8 | Text editing: select all, double/triple/quadruple-click selection, paste, with tests | done | [#218](https://github.com/storytold/photocraft/issues/218) | Like Photoshop, 2 clicks select the word, 3 the laid-out line (a column in vertical type), 4 the paragraph up to the hard return, 5 all text, and the next quick click starts over (#3493; type_tool.rs next_click_count, click_selection, multi_click). Tested through real canvas clicks in point, paragraph and vertical type, with paste replacing the selection and Cmd+A selecting all (type_tool_tests.rs multi_click_selects_word_line_paragraph_and_all_in_point_text, multi_click_separates_wrapped_lines_from_paragraphs, click_counts_cycle_and_restart, click_selection_without_layout_and_on_hostile_input, multi_click_without_a_session_does_nothing) | | TYPE-218-9 | Distort/Perspective/Warp on live type as in Photoshop (was: offer 'Rasterize and continue?'; Photoshop doesn't prompt) | done | [#218](https://github.com/storytold/photocraft/issues/218) | Photoshop 2026 prompts for none of these: Edit › Transform › Warp on live type stays enabled with no rasterize prompt and offers only the warp styles (the mesh can't be dragged), so the type stays editable; Distort, Perspective and the split warps are greyed. PhotoCraft does the same: Warp on type commits the layer's Warp Text in one step (transform_tool.rs enter_type_warp, warp_cmds.rs warp_type_layer, #3004; warp_on_type_takes_a_style_and_keeps_the_type_editable), Distort/Perspective greyed (enable_rules.rs, #2701) | -| TYPE-218-10 | Area type: Type tool click inside a closed path or shape wraps text inside it, holes and dents included, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; a Type tool click only targets paths with at most 4096 anchors (a bigger path gets point text on click, though type.fillPath still works on it); a word too wide for every span in the shape overflows its span the way box text does | +| TYPE-218-10 | Area type: Type tool click inside a closed path or shape wraps text inside it, holes and dents included, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; area type takes paths of at most 4096 anchors: beyond that a Type tool click makes point text (the pointer shows the plain I-beam), and type.fillPath refuses the path with "the path has too many anchor points" (type.attachToPath still takes a subpath of up to 100,000 anchors); a word too wide for every span in the shape overflows its span the way box text does | ## Automation diff --git a/scorecard/type.toml b/scorecard/type.toml index 1a9e2ee164..18241bfbc5 100644 --- a/scorecard/type.toml +++ b/scorecard/type.toml @@ -72,4 +72,4 @@ id = "TYPE-218-10" target = "Area type: Type tool click inside a closed path or shape wraps text inside it, holes and dents included, PSD round trip" status = "partial" issue = 218 -note = "TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; a Type tool click only targets paths with at most 4096 anchors (a bigger path gets point text on click, though type.fillPath still works on it); a word too wide for every span in the shape overflows its span the way box text does" +note = "TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; area type takes paths of at most 4096 anchors: beyond that a Type tool click makes point text (the pointer shows the plain I-beam), and type.fillPath refuses the path with \"the path has too many anchor points\" (type.attachToPath still takes a subpath of up to 100,000 anchors); a word too wide for every span in the shape overflows its span the way box text does" From c157572fa394259d0ef2cc06a9d0e2999ad8c37b Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 08:55:51 -0700 Subject: [PATCH 098/649] refactor(engine): drop type.fillPath's second lock check with_text already refuses a locked type layer (check_text_unlocked, the same effective-lock test), so the check in fill_path only duplicated it with a different message. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/type_area_cmds.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/engine/src/type_area_cmds.rs b/crates/engine/src/type_area_cmds.rs index af04aaa4f0..8bba8c9eca 100644 --- a/crates/engine/src/type_area_cmds.rs +++ b/crates/engine/src/type_area_cmds.rs @@ -56,9 +56,7 @@ fn area_source(doc: &Document, p: &Value) -> Result { fn fill_path(s: &mut Session, p: &Value) -> Result { let id = layer_param(s, p)?; let doc = &s.active().ok_or(EngineError::NoDocument)?.doc; - if doc.effective_locks(id).all { - return Err(EngineError::Other("the type layer is locked".into())); - } + // `with_text` refuses a locked layer. let source = area_source(doc, p)?; let n = source.subpaths.len(); with_text(s, p, "Area Type", |t, _| { From a6a9b1b039d2bdab96337b0ccf72e41de88bd2e3 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 08:55:51 -0700 Subject: [PATCH 099/649] test(engine): drop a leftover unused binding in the area PSD test Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/type_area_cmds/tests.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/engine/src/type_area_cmds/tests.rs b/crates/engine/src/type_area_cmds/tests.rs index 7ca20cf7c6..ffc154968f 100644 --- a/crates/engine/src/type_area_cmds/tests.rs +++ b/crates/engine/src/type_area_cmds/tests.rs @@ -150,7 +150,7 @@ fn release_with_a_path_that_is_not_finite_is_an_error() { #[test] fn area_type_saves_to_psd_as_paragraph_text_with_a_warning() { let mut s = session(8); - let id = text_layer(&mut s, WORDS); + text_layer(&mut s, WORDS); set_work_path(&mut s, Path::new(vec![Subpath::polygon(&[(100.0, 100.0), (300.0, 100.0), (300.0, 250.0), (100.0, 250.0)])])); s.execute("type.fillPath", json!({})).unwrap(); let doc = s.active().unwrap().doc.clone(); @@ -164,7 +164,6 @@ fn area_type_saves_to_psd_as_paragraph_text_with_a_warning() { let t = t.expect("still a type layer"); assert_eq!(t.text, WORDS); assert!(matches!(t.shape, TextShape::Box { width, height, .. } if (width - 200.0).abs() < 0.5 && (height - 150.0).abs() < 0.5), "{:?}", t.shape); - let _ = id; } #[test] From 361cb5af9ee32a43a623fb9e1101f0271601dad3 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 08:57:42 -0700 Subject: [PATCH 100/649] refactor(text): share one per-line metrics helper for stacking and area planning area_metrics copied the line loop's ascent, descent and leading rules, so a change to one would silently desynchronise area rows from the lines stacked on them. Both now call line_metrics. No behaviour change: the fallback style is the same paragraph-start style, and the line loop's style lookup now uses get() instead of indexing. Co-Authored-By: Claude Opus 5.5 --- crates/text/src/layout.rs | 104 +++++++++++++++----------------------- 1 file changed, 41 insertions(+), 63 deletions(-) diff --git a/crates/text/src/layout.rs b/crates/text/src/layout.rs index 58db511fb0..f62c57fe6e 100644 --- a/crates/text/src/layout.rs +++ b/crates/text/src/layout.rs @@ -652,7 +652,7 @@ impl Layouter { // Area type: the first row goes no higher than one leading (plus paragraph spacing) // below the previous paragraph's last line. let space_before = if prev_baseline.is_some() { ps.space_before_pt * k } else { 0.0 }; - let area_from = |m: AreaMetrics| match (&area, prev_baseline) { + let area_from = |m: LineMetrics| match (&area, prev_baseline) { (Some(_), Some(b)) => b + m.leading + pending_space + space_before, (Some(a), None) => a.bounds[1] + m.ascent, (None, _) => 0.0, @@ -723,39 +723,12 @@ impl Layouter { break; } let m = *line.metrics(); - // Largest leading among the glyph runs of the line. - let mut leading = 0.0f32; - for item in line.items() { - if let PositionedLayoutItem::GlyphRun(gr) = item { - let st = &out.styles[gr.style().brush.0 as usize]; - let px = gr.run().font_size(); - leading = leading.max(st.leading_pt.map_or(ps.auto_leading * px, |l| l * k)); - } - } - if leading == 0.0 { - let st = &out.styles[style_at(prange.start)]; - leading = st.leading_pt.map_or(ps.auto_leading * st.size_pt * k, |l| l * k); - } - // Vertical type: half the column width (the largest em on the column). - let col_half = line - .items() - .filter_map(|it| match it { - PositionedLayoutItem::GlyphRun(gr) => Some(gr.run().font_size() * 0.5), - _ => None, - }) - .fold(0.0f32, f32::max); - let col_half = if col_half > 0.0 { col_half } else { first_px * 0.5 }; - let (ascent, descent) = if vertical { - (col_half, col_half) - } else if m.ascent > 0.0 || m.descent > 0.0 { - (m.ascent, m.descent) - } else { - (first_px * 0.8, first_px * 0.2) - }; + let LineMetrics { ascent, descent, leading } = line_metrics(&line, &out.styles, &ps, k, first_style, vertical); let baseline = match (slot, prev_baseline) { (Some(s), _) => s.baseline, // The first column's right edge touches the box's right edge. - (None, None) if is_box && vertical => -(box_rect.0 + box_rect.2) + col_half, + // (In vertical type the ascent is half the column width.) + (None, None) if is_box && vertical => -(box_rect.0 + box_rect.2) + ascent, // Photoshop's "first baseline: ascent": the top of the tallest ascender // (height of 'd') touches the box top, not the font's hhea ascent. (None, None) if is_box => box_rect.1 + first_ascent(&line).unwrap_or(ascent), @@ -1104,9 +1077,9 @@ struct Slot { span: usize, } -/// Line metrics an area paragraph is planned with. +/// A line's ascent, descent and leading (px); for area type, the largest over a paragraph. #[derive(Clone, Copy, Debug)] -struct AreaMetrics { +struct LineMetrics { ascent: f32, descent: f32, leading: f32, @@ -1129,7 +1102,7 @@ thread_local! { /// (lazily) and shared by every pass. struct AreaRows<'a> { area: &'a crate::area::AreaShape, - m: AreaMetrics, + m: LineMetrics, min_width: f32, /// Where the search for the next row starts. next: f32, @@ -1189,7 +1162,7 @@ fn break_area( layout: &mut Layout, area: &crate::area::AreaShape, from: f32, - m: AreaMetrics, + m: LineMetrics, indents: (f32, f32), min_width: f32, budget: &std::cell::Cell, @@ -1275,37 +1248,42 @@ fn break_area_pass(layout: &mut Layout, rows: &mut AreaRows<'_>, inset (slots, overflow) } -/// Largest ascent, descent and leading over the lines of a broken paragraph, computed the same -/// way the line loop does, so an area paragraph's rows can be planned with its real metrics. -fn area_metrics(layout: &Layout, styles: &[CharStyle], ps: &ParagraphStyle, k: f32, fallback: &CharStyle, vertical: bool) -> AreaMetrics { +/// One laid-out line's ascent, descent and leading, as the line loop stacks it. `fallback` is +/// the paragraph's first style, used for a line with no glyph runs. +fn line_metrics(line: &parley::Line<'_, RunBrush>, styles: &[CharStyle], ps: &ParagraphStyle, k: f32, fallback: &CharStyle, vertical: bool) -> LineMetrics { let first_px = fallback.size_pt * k; - let mut out = AreaMetrics { ascent: 0.0, descent: 0.0, leading: 0.0 }; - for line in layout.lines() { - let m = *line.metrics(); - let mut leading = 0.0f32; - let mut half = 0.0f32; - for item in line.items() { - if let PositionedLayoutItem::GlyphRun(gr) = item { - let px = gr.run().font_size(); - half = half.max(px * 0.5); - let lp = styles.get(gr.style().brush.0 as usize).and_then(|st| st.leading_pt); - leading = leading.max(lp.map_or(ps.auto_leading * px, |l| l * k)); - } + let m = line.metrics(); + // Largest leading among the glyph runs, and half the largest em (a vertical column's half width). + let mut leading = 0.0f32; + let mut half = 0.0f32; + for item in line.items() { + if let PositionedLayoutItem::GlyphRun(gr) = item { + let px = gr.run().font_size(); + half = half.max(px * 0.5); + let lp = styles.get(gr.style().brush.0 as usize).and_then(|st| st.leading_pt); + leading = leading.max(lp.map_or(ps.auto_leading * px, |l| l * k)); } - if leading == 0.0 { - leading = fallback.leading_pt.map_or(ps.auto_leading * first_px, |l| l * k); - } - let (a, d) = if vertical { - let h = if half > 0.0 { half } else { first_px * 0.5 }; - (h, h) - } else if m.ascent > 0.0 || m.descent > 0.0 { - (m.ascent, m.descent) - } else { - (first_px * 0.8, first_px * 0.2) - }; - out = AreaMetrics { ascent: out.ascent.max(a), descent: out.descent.max(d), leading: out.leading.max(leading) }; } - out + if leading == 0.0 { + leading = fallback.leading_pt.map_or(ps.auto_leading * first_px, |l| l * k); + } + let (ascent, descent) = if vertical { + let h = if half > 0.0 { half } else { first_px * 0.5 }; + (h, h) + } else if m.ascent > 0.0 || m.descent > 0.0 { + (m.ascent, m.descent) + } else { + (first_px * 0.8, first_px * 0.2) + }; + LineMetrics { ascent, descent, leading } +} + +/// Largest ascent, descent and leading over the lines of a broken paragraph, by +/// [`line_metrics`], so an area paragraph's rows are planned with the metrics it is stacked with. +fn area_metrics(layout: &Layout, styles: &[CharStyle], ps: &ParagraphStyle, k: f32, fallback: &CharStyle, vertical: bool) -> LineMetrics { + layout.lines().map(|line| line_metrics(&line, styles, ps, k, fallback, vertical)).fold(LineMetrics { ascent: 0.0, descent: 0.0, leading: 0.0 }, |a, b| { + LineMetrics { ascent: a.ascent.max(b.ascent), descent: a.descent.max(b.descent), leading: a.leading.max(b.leading) } + }) } /// A tab as line breaking saw it: its shaped advance (before horizontal scale), the horizontal From d0019d3f6831bc31bd45f905e72e1b86cb5566d1 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 08:59:19 -0700 Subject: [PATCH 101/649] test(text): cover area type's span skipping, paragraphs and justify Three area layouts had no test: a word too wide for a U's narrow arm starting the text in the wide arm on the same row, two paragraphs stacked one leading plus space-before apart inside a shape, and justified lines filling their spans in an ellipse with the last line left flush. The justify test fails when the paragraph is set flush left. Co-Authored-By: Claude Opus 5.5 --- crates/text/src/tests.rs | 76 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/crates/text/src/tests.rs b/crates/text/src/tests.rs index 79ccfbac64..8c0c88e586 100644 --- a/crates/text/src/tests.rs +++ b/crates/text/src/tests.rs @@ -2164,3 +2164,79 @@ fn single_size_area_paragraph_breaks_in_one_pass() { // Rows are planned with the paragraph's real metrics: no re-plan and no skipped spans. assert_eq!(crate::layout::AREA_PASSES.with(|c| c.get()), 1); } + +#[test] +fn area_word_skips_a_narrow_span_for_a_wider_one_on_the_same_row() { + let mut e = TextEngine::new(); + let mut t = point("Wonderful things happen in speech bubbles every single day.", 12.0); + // A U: a 24 px left arm and a wide right arm above y = 150, joined below it. + let path = area_poly(&[(0.0, 0.0), (24.0, 0.0), (24.0, 150.0), (80.0, 150.0), (80.0, 0.0), (300.0, 0.0), (300.0, 200.0), (0.0, 200.0)]); + t.shape = TextShape::Area { path: path.clone() }; + let l = e.layout(&t, 72.0); + assert_lines_inside(&l, &path); + let first = l.lines.first().expect("the text is shown"); + // "Wonderful" is wider than the left arm: it starts the text in the right arm, on the first + // row, and nothing is put in the left arm's span on that row. + assert_eq!(first.range.start, 0); + assert!(first.x0 >= 79.5, "{first:?}"); + assert!(first.baseline < 30.0, "first row: {first:?}"); + assert_eq!(l.lines.iter().filter(|line| (line.baseline - first.baseline).abs() < 1e-3).count(), 1, "{:?}", l.lines); + assert_eq!(l.lines.last().map(|line| line.range.end), Some(t.text.len()), "nothing hidden"); +} + +#[test] +fn area_stacks_paragraphs_with_leading_and_space_before() { + let mut e = TextEngine::new(); + let text = "First paragraph of the bubble text.\nSecond paragraph goes right after it."; + let mut t = point(text, 12.0); + let style = ParagraphStyle { space_before_pt: 6.0, ..Default::default() }; + let leading = style.auto_leading * 12.0; + t.paragraphs = vec![ParagraphRun { len: text.len(), style }]; + let path = area_poly(&[(0.0, 0.0), (120.0, 0.0), (120.0, 300.0), (0.0, 300.0)]); + t.shape = TextShape::Area { path: path.clone() }; + let l = e.layout(&t, 72.0); + assert_lines_inside(&l, &path); + let (p0, p1): (Vec<_>, Vec<_>) = l.lines.iter().partition(|line| line.paragraph == 0); + assert!(p0.len() >= 2 && p1.len() >= 2, "both paragraphs wrap: {:?}", l.lines); + assert!(p1.iter().all(|line| line.paragraph == 1)); + // The second paragraph starts right after the break, one leading plus space before lower. + let second = text.find('\n').unwrap() + 1; + assert_eq!(p1[0].range.start, second); + let gap = p1[0].baseline - p0.last().unwrap().baseline; + assert!((gap - (leading + 6.0)).abs() < 1.0, "gap {gap}, want {}", leading + 6.0); + // Lines within a paragraph are one leading apart. + for w in p0.windows(2) { + assert!((w[1].baseline - w[0].baseline - leading).abs() < 1.0, "{w:?}"); + } + assert_eq!(l.lines.last().map(|line| line.range.end), Some(text.len())); +} + +#[test] +fn area_justify_fills_each_span_but_the_last_line() { + let mut e = TextEngine::new(); + let mut t = point(&BUBBLE_TEXT.repeat(2), 12.0); + t.paragraphs = vec![ParagraphRun { len: t.text.len(), style: ParagraphStyle { align: TextAlign::JustifyLeft, ..Default::default() } }]; + let path = area_ellipse(0.0, 0.0, 260.0, 160.0); + t.shape = TextShape::Area { path: path.clone() }; + let l = e.layout(&t, 72.0); + assert!(l.lines.len() >= 4, "{}", l.lines.len()); + assert_lines_inside(&l, &path); + let a = crate::area::AreaShape::new(&path, false).unwrap(); + let span_of = |line: &crate::LineInfo| { + a.spans(line.baseline - line.ascent, line.baseline + line.descent, 0.0) + .into_iter() + .find(|&(s0, s1)| line.x0 >= s0 - 0.5 && line.x1 <= s1 + 0.5) + .unwrap() + }; + let (last, rest) = l.lines.split_last().unwrap(); + for line in rest { + // Justified: the glyphs run from one edge of the line's span to the other. + let (s0, s1) = span_of(line); + let ink = l.glyphs.iter().filter(|g| (g.y - line.baseline).abs() < 1e-3).map(|g| g.x).fold(f32::MIN, f32::max); + assert!((line.x0 - s0).abs() < 1.0, "{line:?} in {s0}..{s1}"); + assert!(ink > s1 - 12.0, "last glyph at {ink}, span ends {s1}: {line:?}"); + } + // The last line is set flush left, not stretched. + let (s0, s1) = span_of(last); + assert!((last.x0 - s0).abs() < 1.0 && last.x1 < s1 - 12.0, "{last:?} in {s0}..{s1}"); +} From 6f74cace1ae22f71259c0d0771cd568ffb9bfbc4 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 09:00:04 -0700 Subject: [PATCH 102/649] docs: refresh the Type scorecard count in gaps and target-app parity Both quoted stale Type checklist counts (3/2/4 and 0/3/6); the regenerated scorecard has 4 done, 4 partial, 2 missing with area type (TYPE-218-10) as partial. The Type figure (40%) is an estimate this work does not re-measure, so it and every percentage stay as they were; the parity doc gets its status line and a revision-history row, per AGENTS.md section 4. Co-Authored-By: Claude Opus 5.5 --- docs/gaps.md | 4 ++-- docs/target-app-parity.md | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/gaps.md b/docs/gaps.md index ebfbb39ea5..70f6076f4a 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -84,7 +84,7 @@ what an agent can't finish alone. (TYPE-218-7, #2689), "rasterize and continue" for distort/perspective on type (TYPE-218-9), text free transform (#2630), area type in PSD (TYPE-218-10). Done since the re-measure: manual and optical kerning with PSD round trip (TYPE-218-6, #206), variable-font axes (TYPE-218-4, #2985). -- **Evidence:** scorecard Type: 3 done, 2 partial, 4 missing. 2026-10-11: 2/3/4/5 clicks select +- **Evidence:** scorecard Type (2026-10-15): 4 done, 4 partial, 2 missing. 2026-10-11: 2/3/4/5 clicks select word, line, paragraph and all text, with tests (TYPE-218-8, #3493). 2026-10-15: area type, type inside a closed path or shape, with holes (TYPE-218-10). The Type tool froze the app for 60 s on one macOS machine (#2518). @@ -271,7 +271,7 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| -| 2026-10-15 | minor | G8: area type: Type tool click inside a closed path or shape wraps text inside it (TYPE-218-10); Type tool click on a path's outline (TYPE-218-1) | +| 2026-10-15 | minor | G8: area type: Type tool click inside a closed path or shape wraps text inside it (TYPE-218-10); Type tool click on a path's outline (TYPE-218-1); Type scorecard count refreshed to 4 done, 4 partial, 2 missing | | 2026-10-14 | minor | G1: a PSD smart object's filter mask shows when the file opens (Photoshop stores the filtered pixels unmasked); export stores them that way too; Photoshop-oracle floor 185 → 188 of 258 | | 2026-10-13 | minor | G14: D90 image area measured (4288 × 2848 at (10, 10)); gap remains open | | 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index c798116f89..504f47db01 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,6 +1,6 @@ # PhotoCraft vs Adobe Photoshop: target-app parity -> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-13 · **Change:** minor (on-canvas corner radius widgets, TOOL-214-12; `.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 +> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-15 · **Change:** minor (area type, TYPE-218-10 partial, Type scorecard 4 / 4 / 2; on-canvas corner radius widgets, TOOL-214-12; `.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); @@ -75,7 +75,7 @@ Weights reflect what a working Photoshop user depends on (photographers, retouch | Dimension | Weight | % ready | Remaining (agent-h) | Evidence | Detail | |---|---:|---:|---:|---|---| -| Features in depth (tools, layers, selections, type, filters, transforms) | 25% | 55% | 600–1,000 | Scorecard checklists: Tools 20 done / 15 partial / 6 missing, Type 0 / 3 / 6, Automation 3 / 2 / 6. 14 tools missing; Select and Mask, Vanishing Point and Content-Aware Fill are parameter dialogs, not workspaces; type on a path, manual kerning, RTL paragraphs missing | [gaps.md](gaps.md) | +| Features in depth (tools, layers, selections, type, filters, transforms) | 25% | 55% | 600–1,000 | Scorecard checklists: Tools 20 done / 15 partial / 6 missing, Type 4 / 4 / 2 (2026-10-15, area type partial), Automation 3 / 2 / 6. 14 tools missing; Select and Mask, Vanishing Point and Content-Aware Fill are parameter dialogs, not workspaces; type on a path, manual kerning, RTL paragraphs missing | [gaps.md](gaps.md) | | UI / UX fidelity and feel | 15% | 40% | 350–600 | ~150 open UI issues; Workspace checklist 13 / 5 / 5 (2026-10-12; 5 / 7 / 11 on 2026-10-10); 27 of 156 preferences do nothing (was 46 of 149); no floating panel groups, thin Color panel, brush lag and pressure jumps reported | [ui-parity.md](ui-parity.md), [brush-parity.md](brush-parity.md) | | File formats and fidelity | 15% | 60% | 300–500 | PSD oracle on Photoshop-authored files 133/256 (52%); io corpus 146/170 (86%); psd-tools 236/309 (76%); round trips ~100% of corpus; but users report Photoshop refusing our files (#1281, #2469; a text-layer case, #2374, was fixed 2026-10-10); no Photoshop PDF, EPS, JPEG 2000, JPEG XL, AVIF read, CR3 | [file-format-parity.md](file-format-parity.md) | | Performance | 10% | 25% | 200–350 | 3 of 25 budgeted scenarios meet budget (baseline 2026-10-05); 150-layer nudge crashes the GPU path (P12); layer move on 15000×10000 16-bit 2.7 s p50; users report brush and cursor lag (#2619, #2566, #1994) | [scorecard.md](scorecard.md#performance) | @@ -565,6 +565,7 @@ See [method, raw measurements and reproduction](five-algorithm-performance.md). | Date | Change | Summary | |---|---|---| +| 2026-10-15 | minor | Type: area type, text wrapping inside a closed path or shape with holes and dents (TYPE-218-10, partial: PSD saves it as paragraph text); Type scorecard count refreshed to 4 done / 4 partial / 2 missing; Type figure (40%) and percentages unchanged | | 2026-10-13 | minor | Vector shapes: on-canvas corner radius widgets on live rectangles (TOOL-214-12); estimates unchanged | | 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 | From 3c0b472573a7d55cdd77969c2fe4561e3cdc6cb1 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 09:25:38 -0700 Subject: [PATCH 103/649] docs: match the Type features cell to its scorecard count The cell's count was refreshed to 4/4/2 but its prose still called manual kerning and type on a path missing; the scorecard has kerning done and type on a path partial. Co-Authored-By: Claude Opus 5.5 --- docs/target-app-parity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 504f47db01..9a7faa984d 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -75,7 +75,7 @@ Weights reflect what a working Photoshop user depends on (photographers, retouch | Dimension | Weight | % ready | Remaining (agent-h) | Evidence | Detail | |---|---:|---:|---:|---|---| -| Features in depth (tools, layers, selections, type, filters, transforms) | 25% | 55% | 600–1,000 | Scorecard checklists: Tools 20 done / 15 partial / 6 missing, Type 4 / 4 / 2 (2026-10-15, area type partial), Automation 3 / 2 / 6. 14 tools missing; Select and Mask, Vanishing Point and Content-Aware Fill are parameter dialogs, not workspaces; type on a path, manual kerning, RTL paragraphs missing | [gaps.md](gaps.md) | +| Features in depth (tools, layers, selections, type, filters, transforms) | 25% | 55% | 600–1,000 | Scorecard checklists: Tools 20 done / 15 partial / 6 missing, Type 4 / 4 / 2 (2026-10-15, area type partial), Automation 3 / 2 / 6. 14 tools missing; Select and Mask, Vanishing Point and Content-Aware Fill are parameter dialogs, not workspaces; type on a path partial; RTL paragraph direction UI and live Warp Text preview missing | [gaps.md](gaps.md) | | UI / UX fidelity and feel | 15% | 40% | 350–600 | ~150 open UI issues; Workspace checklist 13 / 5 / 5 (2026-10-12; 5 / 7 / 11 on 2026-10-10); 27 of 156 preferences do nothing (was 46 of 149); no floating panel groups, thin Color panel, brush lag and pressure jumps reported | [ui-parity.md](ui-parity.md), [brush-parity.md](brush-parity.md) | | File formats and fidelity | 15% | 60% | 300–500 | PSD oracle on Photoshop-authored files 133/256 (52%); io corpus 146/170 (86%); psd-tools 236/309 (76%); round trips ~100% of corpus; but users report Photoshop refusing our files (#1281, #2469; a text-layer case, #2374, was fixed 2026-10-10); no Photoshop PDF, EPS, JPEG 2000, JPEG XL, AVIF read, CR3 | [file-format-parity.md](file-format-parity.md) | | Performance | 10% | 25% | 200–350 | 3 of 25 budgeted scenarios meet budget (baseline 2026-10-05); 150-layer nudge crashes the GPU path (P12); layer move on 15000×10000 16-bit 2.7 s p50; users report brush and cursor lag (#2619, #2566, #1994) | [scorecard.md](scorecard.md#performance) | From dc90b480269d3f5baea17f0029e4917570b87eb8 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Thu, 15 Oct 2026 10:00:38 -0700 Subject: [PATCH 104/649] docs: cite PR #6230 in the TYPE-218-1 note Co-Authored-By: Claude Opus 5.5 --- docs/scorecard.md | 2 +- scorecard/type.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/scorecard.md b/docs/scorecard.md index af9db78e63..6f8b387344 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -211,7 +211,7 @@ Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_w | Id | Target | Status | Issue | Note | |---|---|---|---|---| -| TYPE-218-1 | Type on a path: path shape, glyphs along the curve, caret follows, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip. Type tool click on a path's outline starts type there (type_tool.rs path_target, #218 area-type PR). Missing: the caret and selection following the curve, and PSD path text (it saves as point text) | +| TYPE-218-1 | Type on a path: path shape, glyphs along the curve, caret follows, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip. Type tool click on a path's outline starts type there (type_tool.rs path_target, #6230). Missing: the caret and selection following the curve, and PSD path text (it saves as point text) | | TYPE-218-2 | Paragraph direction (Auto/LTR/RTL) in the panel and options bar; visual RTL caret | missing | [#218](https://github.com/storytold/photocraft/issues/218) | Engine has TextDirection (text.rs:155); no UI | | TYPE-218-3 | Thai/Khmer/Indic fallback fonts; golden shaping tests for complex scripts and RTL | partial | [#218](https://github.com/storytold/photocraft/issues/218) | Fallback fonts are covered for Thai, Khmer, Lao, Myanmar (THAI_FAMILIES, KHMER_FAMILIES, LAO_FAMILIES, MYANMAR_FAMILIES in fonts.rs; #1909, #3259), the nine Indic scripts (INDIC_FAMILIES: Nirmala UI, Kohinoor and Sangam MN, Noto Sans) and Arabic and Hebrew. Still missing: per-script golden shaping tests against reference output (only smoke tests that an installed font shapes without .notdef, plus a bidi test) | | TYPE-218-4 | Variable font axis sliders from the font's axes; opsz follows the point size | done | [#218](https://github.com/storytold/photocraft/issues/218) | One slider per axis of the style's font in the Character section (Properties and Window > Character), setting type.setStyle variations; opsz follows the type size unless set (layout.rs variation_list); a style or weight resets the wght axis (#2985). PSD does not round-trip axis values yet | diff --git a/scorecard/type.toml b/scorecard/type.toml index 18241bfbc5..ef3701b414 100644 --- a/scorecard/type.toml +++ b/scorecard/type.toml @@ -9,7 +9,7 @@ id = "TYPE-218-1" target = "Type on a path: path shape, glyphs along the curve, caret follows, PSD round trip" status = "partial" issue = 218 -note = "TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip. Type tool click on a path's outline starts type there (type_tool.rs path_target, #218 area-type PR). Missing: the caret and selection following the curve, and PSD path text (it saves as point text)" +note = "TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip. Type tool click on a path's outline starts type there (type_tool.rs path_target, #6230). Missing: the caret and selection following the curve, and PSD path text (it saves as point text)" [[item]] id = "TYPE-218-2" From 08868afc55b8f46cfdb4d4d100928cc34ba8f594 Mon Sep 17 00:00:00 2001 From: highperfocused Date: Thu, 15 Oct 2026 20:06:10 +0200 Subject: [PATCH 105/649] =?UTF-8?q?Selection:=20=E2=87=A7=20mid-drag=20loc?= =?UTF-8?q?ks=20a=20selection-tool=20move=20to=20the=20axis=20(#6231)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/ui-egui/src/canvas.rs | 8 +++++++ crates/ui-egui/src/marquee_tests.rs | 35 +++++++++++++++++++++++++++++ crates/ui-egui/src/move_mods.rs | 16 +++++++++++++ 3 files changed, 59 insertions(+) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 391ad464fd..0c67689c33 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -165,6 +165,9 @@ pub struct Drag { /// `Some(false)` moves the outline, `Some(true)` moves the floating piece (`select.float`), as /// every Move-tool drag with a selection does (`move_ui::moves_selected_pixels_with`). pub sel_move: Option, + /// The last ⇧-locked offset of a selection-tool drag of the selection (`move_mods`, #6231); + /// keeps the locked axis stable between events. The Move tool's own drags use `move_mods`. + pub sel_axis: Option<[f64; 2]>, pub lasso: Option, } @@ -182,6 +185,7 @@ impl Drag { released: egui::Modifiers::NONE, reposition: false, sel_move: None, + sel_axis: None, lasso: None, } } @@ -5053,6 +5057,9 @@ fn tool_move(app: &mut PhotocraftApp, x: f64, y: f64, pressure: f32, mods: egui: // ⇧: straight 0/45/90° strokes, 45° gradient angles (stroke_constraint.rs). let last = d.points.last().map_or(d.start, |p| [p[0], p[1]]); let [x, y] = crate::stroke_constraint::constrain(d.tool, &mut d.constrain, d.start, last, [x, y], mods.shift, zoom); + // ⇧: a selection-tool drag of the selection locks to the dominant axis (#6231). The Move + // tool's own drags were already locked by `move_mods::filter_event`. + let [x, y] = crate::move_mods::selection_drag_to(d, [x, y], mods.shift && tool != Tool::Move); let moved = d.points.last().is_none_or(|p| (p[0] - x).abs() + (p[1] - y).abs() > 0.25); // A held pen repeats its point now and then, so the stroke's time keeps advancing. let held = app.stylus.last_point_ms().is_some_and(|t| app.stylus.clock_ms - t >= HOLD_REPEAT_MS) @@ -5473,6 +5480,7 @@ pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers) } let last = d.points.last().map_or(d.start, |p| [p[0], p[1]]); let [x, y] = crate::stroke_constraint::constrain(d.tool, &mut d.constrain, d.start, last, [x, y], mods.shift, zoom); + let [x, y] = crate::move_mods::selection_drag_to(&mut d, [x, y], mods.shift && app.active_tool() != Tool::Move); // A Move-tool click (released where it was pressed) selects, it never moves: snapping // the release point would otherwise nudge the layer onto a nearby edge. if d.tool == Tool::Move && d.points.len() < 2 && matches!(raw, ToolEvent::Up { x, y } if [x, y] == d.start) { diff --git a/crates/ui-egui/src/marquee_tests.rs b/crates/ui-egui/src/marquee_tests.rs index 169d4588b9..67862d9dc2 100644 --- a/crates/ui-egui/src/marquee_tests.rs +++ b/crates/ui-egui/src/marquee_tests.rs @@ -500,6 +500,41 @@ fn drag_inside_the_selection_moves_the_outline() { assert_eq!(sel(&app), None); } +/// #6231: ⇧ held during a selection-tool drag of the selection locks the move to the dominant +/// axis (⇧ at the press still means add-to-selection, so the lock only applies mid-drag). +#[test] +fn shift_constrains_a_selection_drag_to_an_axis() { + use crate::canvas::{ToolEvent, tool_event}; + let (mut app, _layer) = painted(); + let sel = |app: &PhotocraftApp| app.session.active().unwrap().doc.selection.as_ref().map(|s| s.content_bounds()); + let drag_shift = |app: &mut PhotocraftApp, from: [f64; 2], to: [f64; 2]| { + tool_event(app, ToolEvent::Down { x: from[0], y: from[1], pressure: 1.0 }, Modifiers::NONE); + tool_event(app, ToolEvent::Move { x: to[0], y: to[1], pressure: 1.0 }, Modifiers::SHIFT); + tool_event(app, ToolEvent::Up { x: to[0], y: to[1] }, Modifiers::SHIFT); + }; + drag_shift(&mut app, [20.0, 20.0], [40.0, 26.0]); + assert_eq!(sel(&app), Some(Rect::new(30, 10, 50, 30)), "near-horizontal drag moves x only"); + drag_shift(&mut app, [40.0, 20.0], [44.0, 36.0]); + assert_eq!(sel(&app), Some(Rect::new(30, 26, 50, 46)), "near-vertical drag moves y only"); + // Without ⇧ the drag is free (the outline already sits at (30,26,50,46)). + drag(&mut app, [40.0, 30.0], [50.0, 20.0], Modifiers::NONE); + assert_eq!(sel(&app), Some(Rect::new(40, 16, 60, 36)), "plain drag moves both axes"); +} + +/// #6231: ⇧ also locks a ⌘-drag of the selected pixels to the dominant axis. +#[test] +fn shift_constrains_a_floating_selection_drag() { + use crate::canvas::{ToolEvent, tool_event}; + let (mut app, _layer) = painted(); + let offset = |app: &PhotocraftApp| photocraft_engine::float_cmds::floating(app.session.active().unwrap()).map(|f| f.offset); + let cmd_shift = Modifiers::COMMAND | Modifiers::SHIFT; + tool_event(&mut app, ToolEvent::Down { x: 20.0, y: 20.0, pressure: 1.0 }, Modifiers::COMMAND); + tool_event(&mut app, ToolEvent::Move { x: 34.0, y: 28.0, pressure: 1.0 }, cmd_shift); + tool_event(&mut app, ToolEvent::Up { x: 34.0, y: 28.0 }, cmd_shift); + assert_eq!(offset(&app), Some((14, 0)), "locked to the horizontal axis"); + app.run("select.drop", json!({})).unwrap(); +} + /// ⌘-drag cuts the selected pixels into a floating piece (`select.float`): shown at the pointer /// while dragging, moved again by plain drags, put back by Undo, dropped by Deselect. #[test] diff --git a/crates/ui-egui/src/move_mods.rs b/crates/ui-egui/src/move_mods.rs index 64b3a65603..32bd9e2f0a 100644 --- a/crates/ui-egui/src/move_mods.rs +++ b/crates/ui-egui/src/move_mods.rs @@ -152,6 +152,22 @@ fn drag_to(app: &mut PhotocraftApp, p: [f64; 2], mods: egui::Modifiers) -> [f64; [start[0] + d[0], start[1] + d[1]] } +/// ⇧ while a selection tool drags the selection (#6231): lock the move to the dominant axis, as +/// the Move tool's layer drags do. The caller skips this when [`filter_event`] has already +/// rewritten the event (the Move tool itself); it covers the `sel_move` drags the marquee and +/// lasso tools start, including ⌘-drags of the selected pixels. The locked offset is kept on the +/// drag between events so the axis doesn't flicker near 45°. +pub(crate) fn selection_drag_to(d: &mut crate::canvas::Drag, p: [f64; 2], shift: bool) -> [f64; 2] { + if d.sel_move.is_none() || !shift { + d.sel_axis = None; + return p; + } + let delta = [p[0] - d.start[0], p[1] - d.start[1]]; + let locked = constrain(delta, d.sel_axis, MOVE_DIRECTIONS); + d.sel_axis = Some(locked); + [d.start[0] + locked[0], d.start[1] + locked[1]] +} + /// Call after the Move tool finished its drag: an ⌥-drag's copy and move become one step. pub fn finish(app: &mut PhotocraftApp) { let st = std::mem::take(&mut app.move_mods); From 14a2844fad442c765b635b50e1588128fc9859cd Mon Sep 17 00:00:00 2001 From: vangel76 Date: Thu, 15 Oct 2026 22:31:11 +0200 Subject: [PATCH 106/649] Regenerate docs/scorecard.md Co-Authored-By: Claude Opus 5.5 --- docs/scorecard.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/scorecard.md b/docs/scorecard.md index 1e0576ba02..052558a8ef 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -7,7 +7,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js | Area | Done | Partial | Missing | Key numbers | |---|---:|---:|---:|---| | [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 | 14 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | +| [File compatibility](#file-compatibility) | 8 | 14 | 5 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | | [Tools](#tools) | 33 | 11 | 0 | | | [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 166 (target 0) | | [Type](#type) | 4 | 3 | 2 | | @@ -100,7 +100,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t |---|---|---|---|---| | FILE-215-1 | Smart Objects export as embedded Smart Objects (SoLd + lnk2), not flat pixels | done | [#215](https://github.com/storytold/photocraft/issues/215) | psd_export.rs smart_blocks: PlLd + SoLd, source in lnk2 (.pcraft -> PSB); engine tests/smart_psd.rs; Photoshop 2026 opens 8/16-bit exports as live smart objects. Linked files are embedded | | FILE-215-2 | Smart Filters survive PSD save and re-open (filterFX descriptor read and written) | partial | [#215](https://github.com/storytold/photocraft/issues/215) | smart_map.rs: 14 filters plus a verified Camera Raw subset mapped both ways, others kept verbatim, mask in FEid; io tests/smart_corpus.rs. PhotoCraft-only filters (Twirl, Liquify…) and unmapped Camera Raw settings are left out of filterFX with a warning | -| FILE-215-3 | Filter mask can be painted directly, with undo | missing | [#215](https://github.com/storytold/photocraft/issues/215) | smart_cmds.rs:382 mask only from the selection | +| FILE-215-3 | Filter mask can be painted directly, with undo | done | [#215](https://github.com/storytold/photocraft/issues/215) | Clicking the filter mask thumbnail on the Smart Filters row targets it (ui.filterMaskTarget, smart_ui.rs). Painting, fills, filters and adjustments with "target":"filterMask" then edit it (a white mask starts on the first stroke) and re-render the smart object, one undo step per stroke (channel_cmds Target::FilterMask, Session::edit). ⌥-click shows it (view.layerMask "mask":"filter"), ⇧-click disables it. Kept through .pcraft and PSD FEid (smart_cmds/tests/filter_mask_paint.rs) | | FILE-215-4 | Adjustments (Hue/Sat + Colorize, Curves, Levels, Shadows/Highlights) apply as Smart Filters | done | [#215](https://github.com/storytold/photocraft/issues/215) | Image › Adjustments on a smart object records image.adjustments. as a smart filter (adjust_cmds.rs adjust_as_smart_filter; the selection becomes the filter mask), re-rendered from the source by adjust_as_filter and re-editable with layer.smartFilter.setParams; PSD maps Levels/Curves/Shadows-Highlights both ways (smart_map.rs). Opening the editor from the smart-filter row is FILE-215-5's row work | | FILE-215-5 | Smart Filter rows: collapse, mask thumb, blend icon, drag reorder, context menu, live preview | partial | [#215](https://github.com/storytold/photocraft/issues/215) | smart_ui.rs:31 rows + visibility + editor; no collapse, drag or context menu | | FILE-215-6 | Smart Object corner skew and perspective (quad or homography transform) | done | [#215](https://github.com/storytold/photocraft/issues/215) | #426: SmartObject.perspective holds the projective map (transform keeps its affine approximation); Distort / Perspective on a smart object set it (transform_cmds.rs, smart_cmds::set_placement), it re-renders from the source through the homography, Warp composes with it, and the PSD placement reads and writes nonAffineTransform / Trnf (io/blocks.rs placed_projective, smart_map.rs); tests distort_survives_edit_contents, warp_on_a_distorted_smart_object_follows_the_corners, placement survives the save | From e9ad9e728e8345ecdd0e82edbc46ae8216c49a97 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Thu, 15 Oct 2026 22:34:57 +0200 Subject: [PATCH 107/649] Regenerate docs/scorecard.md Co-Authored-By: Claude Opus 5.5 --- docs/scorecard.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/scorecard.md b/docs/scorecard.md index 1e0576ba02..e91525ee49 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -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 | 14 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | -| [Tools](#tools) | 33 | 11 | 0 | | +| [Tools](#tools) | 34 | 10 | 0 | | | [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 166 (target 0) | | [Type](#type) | 4 | 3 | 2 | | | [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) | @@ -158,7 +158,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t | TOOL-214-11 | Stroke Path dialog: pick any brush-based tool, Simulate Pressure | done | [#214](https://github.com/storytold/photocraft/issues/214) | path.stroke tool: Brush, Pencil, Eraser and every other brush-based tool (Background Eraser, Clone/Pattern Stamp, Healing/Spot Healing Brush, History Brush, Blur, Sharpen, Smudge, Dodge, Burn, Sponge, Color Replacement, Mixer Brush: their paint.* command along the path, one step) plus simulatePressure (taper both ends); Stroke Path dialog from the Pen menu, the Paths panel menu and Alt-click on its Stroke button (#2978) | | TOOL-214-12 | Shapes: on-canvas corner radius handles, shape feather, selection to shape with tolerance | partial | [#214](https://github.com/storytold/photocraft/issues/214) | On-canvas corner radius widgets on every selected live rectangle with Path Selection, the Rectangle tool and Move + Show Transform Controls: drag rounds every corner of every selected rectangle alike, Alt that corner on each, corner radius cursor and R: readout, one history step (corner_radius.rs, 2026-10-13); select.convertToShape with tolerance (vector_cmds.rs:1256). Missing: shape feather | | TOOL-214-13 | Mask Properties: Density and Feather controls | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Vector-mask density/feather in the engine (vector_cmds.rs:948); no UI controls | -| TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | partial | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15); on-canvas plane editor (vp_ui.rs: Create/Edit Plane, edge nodes, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane on OK); clone stamp, marquee and tear-off planes in the window still missing | +| TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | done | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15); on-canvas window (vp_ui.rs: Create/Edit Plane, edge nodes, Ctrl/Cmd-drag tear-off planes with depth and Alt-drag angle, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane, Stamp tool cloning in perspective with live preview, all applied on OK as one step); the window's Marquee tool and the Stamp's Heal modes are still missing | | TOOL-214-15 | Content-Aware Fill workspace: paint the sampling area, preview, rotate/scale/mirror, new layer | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Engine sampling auto, rect, custom (edit_menu_cmds.rs:324); generic dialog | | TOOL-214-16 | Liquify: redo (Cmd+Shift+Z) | done | [#214](https://github.com/storytold/photocraft/issues/214) | liquify_ui.rs supports bounded redo through Cmd+Shift+Z and the control channel; new strokes clear redo | | TOOL-213-17 | Red Eye tool: click a pupil to neutralize the red reflection | done | [#213](https://github.com/storytold/photocraft/issues/213) | paint.redEye (redeye_cmds.rs) + Tool::RedEye in the J flyout; Pupil Size and Darken Amount; catchlights kept; a miss is an error | From acb8dbdb4756e6c368c8756b4d38fd0f6381a48f Mon Sep 17 00:00:00 2001 From: geduful Date: Thu, 15 Oct 2026 20:59:54 +0000 Subject: [PATCH 108/649] fix(gpu): poll non-blockingly when recording a caught error DeviceHealth::caught polled with PollType::Wait and no timeout, blocking the UI thread until every in-flight submission drained, or forever on a wedged device, immediately after a failed frame. A non-blocking poll loses nothing here: wgpu-core only enters the fence wait when a submission index is given, so PollType::Poll still reads the fence and fires the device-lost callback for a lost device, it just never blocks waiting for one. Adds the regression test review asked for: a watched device forced into a synchronous validation error must return Err and fault health, not panic. Confirmed to fail without the caught() call. --- crates/gpu/src/health.rs | 8 +++++++- crates/gpu/tests/device_loss.rs | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/crates/gpu/src/health.rs b/crates/gpu/src/health.rs index a7238e0b1d..aa85f39170 100644 --- a/crates/gpu/src/health.rs +++ b/crates/gpu/src/health.rs @@ -105,12 +105,18 @@ impl DeviceHealth { /// this a watched device would keep being handed to a GPU that has already failed. Polls /// first: a lost device is a [`Fault::Lost`], and its callback may not have run yet (it fires /// on a poll, and `Device::poll` panics on a lost device). + /// + /// The poll is a single non-blocking check, never a fence wait. This runs on the UI thread + /// immediately after a failed frame, so `PollType::Wait` with no timeout would stall the app + /// until every in-flight submission drained (or forever, if the device is wedged). A + /// non-blocking poll loses nothing here: wgpu still reads the fence and fires the + /// device-lost callback for a lost device, it just never blocks waiting for one. pub fn caught(&self, device: &wgpu::Device, error: &wgpu::Error) { if !self.is_ok() { return; } #[cfg(not(target_arch = "wasm32"))] - self.wait(device, None); + self.poll(device); #[cfg(target_arch = "wasm32")] let _ = device; if !self.is_ok() { diff --git a/crates/gpu/tests/device_loss.rs b/crates/gpu/tests/device_loss.rs index 689a787280..82bedf7a20 100644 --- a/crates/gpu/tests/device_loss.rs +++ b/crates/gpu/tests/device_loss.rs @@ -1,6 +1,7 @@ //! The compositor on a lost device (#243): renders return `Unsupported` (so callers use the CPU -//! compositor) instead of panicking with "Buffer 'pc_compose_uniforms' is invalid". Skips when no -//! GPU adapter exists. +//! compositor) instead of panicking with "Buffer 'pc_compose_uniforms' is invalid". Also covers a +//! caught validation error on a watched device, which must fault the health flag so callers stop +//! issuing GPU work. Skips when no GPU adapter exists. use photocraft_color::{Color, ColorMode, SampleType}; use photocraft_doc::{Document, Layer, LayerContent}; @@ -163,6 +164,34 @@ fn a_captured_render_error_preserves_the_device_for_a_later_render() { } } +#[test] +fn a_watched_validation_error_faults_health_instead_of_panicking() { + let _lock = GPU_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let Some((adapter, device, queue)) = device() else { return }; + let Ok(mut comp) = Compositor::try_new_with_format(&device, Compositor::preferred_acc_format(&adapter)) else { return }; + let health = DeviceHealth::watch(&device); + comp.set_health(health.clone()); + let d = doc(); + assert!(health.is_ok(), "a fresh watched device starts healthy"); + let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + comp.render(&device, &queue, &d, d.bounds(), |_, _| { + // A buffer past the device's valid limit is rejected synchronously, so the error + // reaches the compositor's error scope and never the uncaptured-error callback a + // watched device would otherwise record it with. + let _ = device.create_buffer(&wgpu::BufferDescriptor { + label: Some("synthetic_invalid_buffer"), + size: device.limits().max_buffer_size + 1, + usage: wgpu::BufferUsages::COPY_DST, + mapped_at_creation: false, + }); + }) + })); + assert!(result.is_ok(), "a caught validation error must return Err instead of reaching wgpu's panic handler"); + assert!(result.unwrap().is_err(), "the invalid buffer must fail this render"); + assert!(!health.is_ok(), "the caught error must fault the device's health so callers stop issuing GPU work"); + assert!(health.fault().is_some(), "the fault must be reportable"); +} + fn assert_recovery_after_invalid_encoder(encode_only: bool) { let _lock = GPU_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner); let Some((adapter, device, queue)) = device() else { return }; From bd0061e2a8dfeda22532eb96638cc865396e9450 Mon Sep 17 00:00:00 2001 From: Omar Saidahmed Date: Thu, 15 Oct 2026 18:15:09 -0400 Subject: [PATCH 109/649] honor lock all on layer mask commands --- crates/engine/src/commands.rs | 4 +- crates/engine/src/layer_menu_cmds.rs | 2 + crates/engine/tests/mask_lock_all.rs | 71 ++++++++++++++++++++++++ crates/ui-egui/src/layer_row_ui/tests.rs | 2 +- 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 crates/engine/tests/mask_lock_all.rs diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs index edb60b06dc..6ff685f0ad 100644 --- a/crates/engine/src/commands.rs +++ b/crates/engine/src/commands.rs @@ -80,7 +80,7 @@ pub(crate) fn paint_surface<'a>(doc: &'a mut Document, id: LayerId, p: &Value) - } } -fn check_all_unlocked(doc: &Document, id: LayerId) -> Result<()> { +pub(crate) fn check_all_unlocked(doc: &Document, id: LayerId) -> Result<()> { let locks = doc.effective_locks(id); let l = doc.layer(id).ok_or(EngineError::NoLayer(id))?; if locks.all { @@ -390,6 +390,7 @@ fn destructive_adjust(s: &mut Session, label: &str, adj: Adjustment, p: &Value) // The targeted layer mask (#780): ⌘I inverts it, as in Photoshop. let id = layer_param(s, &Value::Null)?; return s.edit(label, |doc, _| { + check_all_unlocked(doc, id)?; let sel = doc.selection.clone(); let l = doc.layer_mut(id).ok_or(EngineError::NoLayer(id))?; let mask = l.mask.as_mut().ok_or_else(|| EngineError::Other("layer has no mask".into()))?; @@ -1535,6 +1536,7 @@ fn set_mask_with(s: &mut Session, p: &Value, label: &str, mask: Option Result { mask.surface.write_region(bounds, &v); mask.surface.prune(); for id in ids { + crate::commands::check_all_unlocked(doc, id)?; crate::extra_cmds::background_to_layer_for_mask(doc, id); doc.layer_mut(id).ok_or(EngineError::NoLayer(id))?.mask = Some(mask.clone()); } @@ -217,6 +218,7 @@ fn mask_all_objects(s: &mut Session, p: &Value) -> Result { let id = layer_param(s, p)?; let d = s.active().ok_or(EngineError::NoDocument)?; let doc = d.doc.clone(); + crate::commands::check_all_unlocked(&doc, id)?; let layer = doc.layer(id).ok_or(EngineError::NoLayer(id))?; let region: Option = match layer.surface() { Some(surf) if matches!(layer.content, LayerContent::Raster(_)) => { diff --git a/crates/engine/tests/mask_lock_all.rs b/crates/engine/tests/mask_lock_all.rs new file mode 100644 index 0000000000..f0334619f1 --- /dev/null +++ b/crates/engine/tests/mask_lock_all.rs @@ -0,0 +1,71 @@ +use photocraft_doc::LayerMask; +use photocraft_engine::Session; +use serde_json::json; + +const COMMANDS: [&str; 7] = [ + "layer.layerMask.revealAll", + "layer.layerMask.hideAll", + "layer.layerMask.revealSelection", + "layer.layerMask.hideSelection", + "layer.layerMask.delete", + "layer.maskAllObjects", + "image.adjustments.invert", +]; + +fn masked(all: bool) -> Session { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 40, "height": 30})).unwrap(); + s.execute("layer.new.layer", json!({})).unwrap(); + s.execute("paint.stroke", json!({"points": [[5, 10], [20, 10]], "size": 8, "hardness": 1.0, "color": "#ff0000"})).unwrap(); + s.execute("layer.layerMask.revealAll", json!({})).unwrap(); + s.execute("paint.stroke", json!({"points": [[25, 20], [35, 20]], "size": 6, "hardness": 1.0, "color": "#000000", "target": "mask"})).unwrap(); + s.execute("select.rect", json!({"x": 2, "y": 2, "width": 20, "height": 15})).unwrap(); + s.execute("layer.setProps", json!({"locks": {"all": all}})).unwrap(); + s +} + +fn mask(s: &Session) -> Option { + let st = s.active().unwrap(); + st.doc.layer(st.active_layer.unwrap()).unwrap().mask.clone() +} + +fn undo_depth(s: &Session) -> usize { + s.active().unwrap().history.past_len() +} + +#[test] +fn lock_all_refuses_every_mask_command() { + for cmd in COMMANDS { + let mut s = masked(true); + let before = mask(&s); + let undo = undo_depth(&s); + let err = s.execute(cmd, json!({"target": "mask"})).unwrap_err(); + assert_eq!(err.to_string(), "Could not complete your request because the layer \"Layer 1\" is locked", "{cmd}"); + assert_eq!(mask(&s), before, "{cmd} left the mask unchanged"); + assert_eq!(undo_depth(&s), undo, "{cmd} added no history step"); + } +} + +#[test] +fn unlocked_layers_still_take_every_mask_command() { + for cmd in COMMANDS { + let mut s = masked(false); + let before = mask(&s); + s.execute(cmd, json!({"target": "mask"})).unwrap_or_else(|e| panic!("{cmd}: {e}")); + assert_ne!(mask(&s), before, "{cmd} changed the mask"); + } +} + +#[test] +fn a_locked_layer_among_the_selected_layers_refuses_the_whole_mask() { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 40, "height": 30})).unwrap(); + s.execute("layer.new.layer", json!({})).unwrap(); + let first = s.active().unwrap().active_layer.unwrap(); + s.execute("layer.new.layer", json!({})).unwrap(); + s.execute("layer.setProps", json!({"locks": {"all": true}})).unwrap(); + s.execute("layer.select", json!({"layer": first.0, "mode": "add"})).unwrap(); + assert_eq!(s.active().unwrap().selected_layers.len(), 2); + assert!(s.execute("layer.layerMask.hideAll", json!({})).is_err()); + assert!(s.active().unwrap().doc.walk().iter().all(|(_, _, l)| l.mask.is_none()), "no layer got a mask"); +} diff --git a/crates/ui-egui/src/layer_row_ui/tests.rs b/crates/ui-egui/src/layer_row_ui/tests.rs index 6ec1241b46..19aededc04 100644 --- a/crates/ui-egui/src/layer_row_ui/tests.rs +++ b/crates/ui-egui/src/layer_row_ui/tests.rs @@ -23,8 +23,8 @@ fn busy() -> photocraft_engine::Session { s.execute("layer.layerStyle.dropShadow", json!({"layer": a})).unwrap(); // #153: the vector mask thumbnail and both link chains take row width too. s.execute("layer.vectorMask.revealAll", json!({"layer": a})).unwrap(); - s.execute("layer.setProps", json!({"layer": a, "blend": "Multiply", "locks": {"all": true}})).unwrap(); s.execute("layer.layerMask.revealAll", json!({"layer": a})).unwrap(); + s.execute("layer.setProps", json!({"layer": a, "blend": "Multiply", "locks": {"all": true}})).unwrap(); let b = s.execute("layer.new.layer", json!({"name": format!("{LONG} b{depth}")})).unwrap()["layer"].as_u64().unwrap(); s.execute("layer.setProps", json!({"layer": b, "clipped": true})).unwrap(); s.execute("layer.select", json!({"layer": a})).unwrap(); From de73a4da181455dd52cc8b4395fdac6a2ff8ad90 Mon Sep 17 00:00:00 2001 From: 00xJ0 <56056764+00xJ0@users.noreply.github.com> Date: Fri, 16 Oct 2026 19:05:31 -0700 Subject: [PATCH 110/649] Fix the build: restore export_presets in load_presets_json (#5344 x #5616) #5344 added the export_presets field to Persisted; #5616 rewrote load_presets_json to read each set with take() and its Persisted initializer lacked the new field, so main stopped compiling (E0063 at presets/mod.rs:180). Read export_presets the same way as the other sets; the existing load step and round-trip test cover it. --- crates/engine/src/presets/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/engine/src/presets/mod.rs b/crates/engine/src/presets/mod.rs index 03696291dd..81382b418a 100644 --- a/crates/engine/src/presets/mod.rs +++ b/crates/engine/src/presets/mod.rs @@ -186,6 +186,7 @@ impl Session { tool_presets: take(&mut m, "tool_presets"), documents: take(&mut m, "documents"), recent_documents: take(&mut m, "recent_documents"), + export_presets: take(&mut m, "export_presets"), custom_shapes: take(&mut m, "custom_shapes"), layer_defaults: take(&mut m, "layer_defaults"), swatches: take(&mut m, "swatches"), From c907301d274323e4977d1da42c3b9067a1419a58 Mon Sep 17 00:00:00 2001 From: hogawish <60434858+hogawish@users.noreply.github.com> Date: Sat, 17 Oct 2026 19:28:31 +0900 Subject: [PATCH 111/649] perf(canvas): skip occluded checker on CPU textures --- crates/ui-egui/src/canvas.rs | 27 ++- .../src/canvas_cpu_background_tests.rs | 180 ++++++++++++++++++ docs/development.md | 12 ++ 3 files changed, 215 insertions(+), 4 deletions(-) create mode 100644 crates/ui-egui/src/canvas_cpu_background_tests.rs diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 914d395acc..d6f7b927ee 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -142,6 +142,9 @@ pub struct CanvasCache { /// `revision`, so the Navigator never shows a stale CPU image after GPU-path edits. pub tex_revision: u64, pub tex_preview_key: u64, + /// All uploaded texels are opaque: the checker behind this image cannot be seen. Updated + /// with uploads, never by scanning the document during a pan or other unchanged frame. + pub texture_opaque: bool, /// The CPU path's pixel grid for the part of the document in view (pixel_grid.rs). pub grid: Option, } @@ -1423,6 +1426,7 @@ pub fn ensure_texture(app: &mut PhotocraftApp, ctx: &egui::Context, idx: usize, on_gpu: false, tex_revision: 0, tex_preview_key: 0, + texture_opaque: false, grid: None, }); if cache.tex_revision != revision || cache.texture.is_none() || cache.tex_preview_key != preview_key { @@ -1438,7 +1442,11 @@ pub fn ensure_texture(app: &mut PhotocraftApp, ctx: &egui::Context, idx: usize, let r = buf.rect; if !r.is_empty() { let t1 = crate::gpu_canvas::now_ms(); - t.set_partial([r.x0 as usize, r.y0 as usize], display_image(display.as_deref(), &buf), canvas_texture_options(factor)); + let image = display_image(display.as_deref(), &buf); + // Partial uploads can disprove opacity. Once transparent, conservatively keep + // the checker until a full upload proves the whole texture opaque again. + cache.texture_opaque &= image.pixels.iter().all(|p| p.is_opaque()); + t.set_partial([r.x0 as usize, r.y0 as usize], image, canvas_texture_options(factor)); let px = (r.width() as u64 * r.height() as u64).saturating_mul(u64::from(factor).pow(2)); app.perf.record("rect", px, t1 - t0, crate::gpu_canvas::now_ms() - t1); } @@ -1447,6 +1455,7 @@ pub fn ensure_texture(app: &mut PhotocraftApp, ctx: &egui::Context, idx: usize, let full = photocraft_compose::render_reduced(&doc, w, h); let t1 = crate::gpu_canvas::now_ms(); let (img, scale) = (display_image(display.as_deref(), &full), 1.0 / factor as f32); + cache.texture_opaque = img.pixels.iter().all(|p| p.is_opaque()); match cache.texture.as_mut() { Some(t) if t.size() == img.size => t.set(img, canvas_texture_options(factor)), _ => cache.texture = Some(ctx.load_texture(format!("canvas-{}-{}", id.0, cache_key(id, output).1), img, canvas_texture_options(factor))), @@ -1612,6 +1621,7 @@ fn ensure_gpu(app: &mut PhotocraftApp, ctx: &egui::Context, idx: usize, visible: on_gpu: false, tex_revision: 0, tex_preview_key: 0, + texture_opaque: false, grid: None, }); let present = cache.on_gpu && gpu.has(id.0, size); @@ -3089,9 +3099,10 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: let rotated = view.rotation.abs() > 0.05; let checkerboard = app.session.prefs().transparency_and_gamut.square().map(|square| (checker(app, &ctx), square)); let tex = ensure_texture(app, &ctx, idx, output).map(|(tex, _scale)| tex); - paint_cpu_document(&painter, &xf, doc.bounds(), rotated, checkerboard, tex); + let opaque = app.canvases.get(&cache_key(doc.id, output)).is_some_and(|c| c.texture_opaque) && tex.is_some(); + paint_cpu_document(&painter, &xf, doc.bounds(), rotated, checkerboard, tex, opaque); for &c in &pattern { - paint_cpu_document(&painter, &pattern_xf(&xf, c, size), doc.bounds(), rotated, checkerboard, tex); + paint_cpu_document(&painter, &pattern_xf(&xf, c, size), doc.bounds(), rotated, checkerboard, tex, opaque); } } // Channels panel: alpha / Quick Mask overlays and single-channel views (channel_view.rs). @@ -4242,11 +4253,12 @@ fn paint_cpu_document( rotated: bool, checker: Option<(egui::TextureId, f32)>, tex: Option, + opaque: bool, ) { let size = [bounds.width() as f32, bounds.height() as f32]; let img_rect = xf.doc_rect(bounds); match checker { - Some((checker_id, square)) => { + Some((checker_id, square)) if !opaque || tex.is_none() => { if rotated { let tiles = vec2(size[0], size[1]) / (2.0 * square); paint_mapped_image(painter, xf, checker_id, Rect::from_min_max(Pos2::ZERO, pos2(tiles.x, tiles.y)), size, Color32::WHITE); @@ -4255,6 +4267,9 @@ fn paint_cpu_document( painter.image(checker_id, img_rect, Rect::from_min_max(Pos2::ZERO, pos2(tiles.x, tiles.y)), Color32::WHITE); } } + // On software window adapters this hidden full-canvas pass is CPU rasterization too. + // Keep the white-background branch unchanged (its antialiased outer edge is visible). + Some(_) => {} None => { if rotated { paint_mapped_quad(painter, xf, size, Color32::WHITE); @@ -8705,3 +8720,7 @@ mod rotation_preview_isolation_tests { #[cfg(test)] #[path = "canvas_display_memo_tests.rs"] mod display_memo_tests; + +#[cfg(test)] +#[path = "canvas_cpu_background_tests.rs"] +mod cpu_background_tests; diff --git a/crates/ui-egui/src/canvas_cpu_background_tests.rs b/crates/ui-egui/src/canvas_cpu_background_tests.rs new file mode 100644 index 0000000000..ed0ac98dc5 --- /dev/null +++ b/crates/ui-egui/src/canvas_cpu_background_tests.rs @@ -0,0 +1,180 @@ +//! CPU-canvas opacity invalidation and the software renderer's hidden checker pass. +use super::*; +use serde_json::json; + +#[test] +fn cpu_canvas_omits_only_a_checker_hidden_by_an_opaque_texture() { + let ctx = egui::Context::default(); + let image = ctx.load_texture("image", egui::ColorImage::filled([2, 2], Color32::WHITE), TextureOptions::LINEAR); + let checker = ctx.load_texture("checker-test", egui::ColorImage::filled([2, 2], Color32::GRAY), TextureOptions::NEAREST); + for rotated in [false, true] { + for (opaque, texture, want_checker) in [(true, Some(image.id()), false), (false, Some(image.id()), true), (true, None, true)] { + let mut output = ctx.run_ui(Default::default(), |ui| { + let xf = ViewXform { + rect: Rect::from_min_size(Pos2::ZERO, vec2(300.0, 240.0)), + zoom: 1.0, + center: [50.0, 40.0], + flip: false, + rotation: if rotated { 23.0 } else { 0.0 }, + aspect: 1.0, + }; + paint_cpu_document(ui.painter(), &xf, DRect::new(0, 0, 100, 80), rotated, Some((checker.id(), 8.0)), texture, opaque); + }); + let drawn = output.shapes.iter().any(|s| matches!(&s.shape, egui::Shape::Mesh(m) if m.texture_id == checker.id())); + assert_eq!(drawn, want_checker, "rotated={rotated}, opaque={opaque}, texture={texture:?}"); + output.textures_delta.clear(); + } + } +} + +#[test] +fn cpu_texture_opacity_follows_full_and_partial_uploads() { + for depth in [8, 16, 32] { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + let ctx = egui::Context::default(); + app.run("file.new", json!({"width": 32, "height": 24, "depth": depth, "background": "transparent"})).unwrap(); + let key = cache_key(app.session.documents()[0].doc.id, None); + ensure_texture(&mut app, &ctx, 0, None).unwrap(); + assert!(!app.canvases[&key].texture_opaque, "{depth}: transparent canvas needs its checker"); + app.run("edit.fill", json!({"color": "#2050d0"})).unwrap(); + // Force a full upload to classify the complete image, as the first opaque image does. + app.canvases.get_mut(&key).unwrap().texture = None; + ensure_texture(&mut app, &ctx, 0, None).unwrap(); + assert!(app.canvases[&key].texture_opaque); + app.run("select.rect", json!({"x": 2, "y": 3, "width": 4, "height": 5})).unwrap(); + ensure_texture(&mut app, &ctx, 0, None).unwrap(); + app.run("edit.fill", json!({"color": "#e04010"})).unwrap(); + ensure_texture(&mut app, &ctx, 0, None).unwrap(); + assert_eq!(app.perf.last_refresh, "rect"); + assert!(app.canvases[&key].texture_opaque, "an opaque patch keeps the guarantee"); + app.run("edit.clear", json!({})).unwrap(); + ensure_texture(&mut app, &ctx, 0, None).unwrap(); + assert_eq!(app.perf.last_refresh, "rect"); + assert!(!app.canvases[&key].texture_opaque, "erasing a patch must show the checker again"); + app.run("edit.undo", json!({})).unwrap(); + ensure_texture(&mut app, &ctx, 0, None).unwrap(); + app.canvases.get_mut(&key).unwrap().texture = None; + ensure_texture(&mut app, &ctx, 0, None).unwrap(); + assert!(app.canvases[&key].texture_opaque, "a full opaque upload can omit the checker again"); + app.perf.last_refresh = ""; + ensure_texture(&mut app, &ctx, 0, None).unwrap(); + assert_eq!(app.perf.last_refresh, "", "unchanged frames do not upload or classify pixels"); + } +} + +type Harness = egui_kittest::Harness<'static, PhotocraftApp>; + +fn harness(size: [u32; 2], background: &str) -> Harness { + let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_pixels_per_point(1.0).with_max_steps(64).wgpu().build_eframe(|cc| { + PhotocraftApp::setup_context(&cc.egui_ctx, Default::default()); + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + if let Some(rs) = &cc.wgpu_render_state { + app.perf.gpu_info.set_adapter(&rs.adapter.get_info()); + } + // app.gpu remains None: compose on the CPU, use the harness's software window adapter. + app.run("file.new", json!({"width": size[0], "height": size[1], "background": background})).unwrap(); + app.run("select.rect", json!({"x": size[0] / 2, "y": size[1] / 2, "width": size[0] / 10, "height": size[1] / 10})).unwrap(); + app.run("edit.fill", json!({"color": "#2050d0"})).unwrap(); + app.run("select.deselect", json!({})).unwrap(); + app + }); + h.run_steps(12); + let key = cache_key(h.state().session.documents()[0].doc.id, None); + assert!(h.state().session.prefs().transparency_and_gamut.square().is_some()); + assert_eq!(h.state().canvases[&key].texture_opaque, background == "white", "fixture opacity"); + h +} + +/// Draw the unchanged reference path by temporarily disabling only the opacity guarantee. +fn reference_frame(h: &mut Harness) { + let flags: Vec<_> = h.state().canvases.iter().map(|(k, c)| (*k, c.texture_opaque)).collect(); + for c in h.state_mut().canvases.values_mut() { + c.texture_opaque = false; + } + h.step(); + for (k, opaque) in flags { + if let Some(c) = h.state_mut().canvases.get_mut(&k) { + c.texture_opaque = opaque; + } + } +} + +#[test] +fn omitting_an_occluded_checker_preserves_cpu_canvas_pixels() { + let Ok(mut h) = std::panic::catch_unwind(|| harness([320, 240], "white")) else { + eprintln!("skipping: no offscreen graphics adapter"); + return; + }; + for (rotation, flip, pattern) in [(0.0, false, false), (23.0, false, false), (0.0, true, false), (0.0, false, true)] { + h.state_mut().ui.views[0].rotation = rotation; + h.state_mut().ui.view.flip_horizontal = flip; + h.state_mut().ui.view.pattern_preview = pattern; + reference_frame(&mut h); + let reference = h.render().unwrap(); + h.step(); + let optimized = h.render().unwrap(); + assert!(reference == optimized, "rotation={rotation} flip={flip} pattern={pattern}"); + } +} + +#[test] +#[ignore = "manual release benchmark: 24 MP CPU canvas on the offscreen software adapter"] +fn cpu_canvas_background_benchmark() { + use std::time::Instant; + let mut results = Vec::new(); + let output = std::env::var_os("PHOTOCRAFT_CPU_BENCH_OUTPUT").map(std::path::PathBuf::from); + for background in ["white", "transparent"] { + let mut h = harness([6000, 4000], background); + let v = &mut h.state_mut().ui.views[0]; + v.zoom = 1.0; + v.center = [3000.0, 2000.0]; + v.fit_pending = false; + v.fill_pending = false; + for _ in 0..3 { + h.step(); + h.render().unwrap(); + } + let mut before = Vec::new(); + let mut after = Vec::new(); + // Alternate order to reduce warm-up/thermal bias. Same cached image and UI in both paths. + for n in 0..24 { + for reference in if n % 2 == 0 { [true, false] } else { [false, true] } { + h.state_mut().ui.views[0].center[0] = 3000.0 + if n % 2 == 0 { -3.0 } else { 3.0 }; + let t = Instant::now(); + if reference { + reference_frame(&mut h); + } else { + h.step(); + } + h.render().unwrap(); + (if reference { &mut before } else { &mut after }).push(t.elapsed().as_secs_f64() * 1000.0); + } + } + reference_frame(&mut h); + let old = h.render().unwrap(); + h.step(); + let new = h.render().unwrap(); + assert!(old == new, "{background}: same rendered pixels"); + if let Some(dir) = &output { + std::fs::create_dir_all(dir).unwrap(); + old.save(dir.join(format!("cpu-{background}-before.png"))).unwrap(); + new.save(dir.join(format!("cpu-{background}-after.png"))).unwrap(); + } + before.sort_by(f64::total_cmp); + after.sort_by(f64::total_cmp); + results.push(json!({ + "background": background, "document_pixels": 24_000_000, "viewport": [1440, 900], + "opaque_texture": background == "white", "checker_enabled": true, + "adapter": h.state().perf.gpu_info, "samples_per_path": before.len(), + "reference_p50_ms": before[11], "reference_p95_ms": before[22], + "optimized_p50_ms": after[11], "optimized_p95_ms": after[22], + "reference_ms": before, "optimized_ms": after, + "includes": "UI frame, cached CPU canvas rasterization and synchronous readback; no document recomposite", + })); + } + let report = serde_json::to_string_pretty(&results).unwrap(); + println!("{report}"); + if let Some(dir) = output { + std::fs::write(dir.join("cpu-background-benchmark.json"), report).unwrap(); + } +} diff --git a/docs/development.md b/docs/development.md index 035efbbcf0..017df8056e 100644 --- a/docs/development.md +++ b/docs/development.md @@ -307,6 +307,18 @@ translations do not affect the denominator. Unregistered locale TSV files are ig ## Performance notes +- The CPU canvas records whether an uploaded image is entirely opaque, so software window + adapters do not rasterize a transparency checker that the image completely hides. An edit + that introduces transparency restores the checker; partial uploads conservatively retain it + until a full upload proves the image opaque again. Pan/zoom frames reuse this metadata. + Compare the old checker pass with the optimized path on a synthetic 24 MP document using + `cargo test --release -p photocraft-ui-egui --lib cpu_canvas_background_benchmark -- --ignored --nocapture`. + The benchmark alternates both paths on the same cached image and reports the adapter and + per-frame p50/p95, including offscreen rasterization and synchronous readback. It checks + identical rendered pixels for opaque and transparent images. This measures warm canvas + presentation, not input-to-photon latency or document recompositing. Set the test-only + `PHOTOCRAFT_CPU_BENCH_OUTPUT` to a directory to save its JSON and before/after PNGs. + - The canvas is presented by a custom WGSL shader (`ui-egui/src/gpu_canvas.rs`): mip-mapped/nearest sampling, procedural checkerboard, pixel grid, tiling. Brush strokes upload only their damage rect. - **The canvas composites on the GPU** (`photocraft-gpu`, driven from `gpu_canvas.rs`), layer effects included. What the planner can't express returns `Unsupported` and the canvas falls back to the CPU compositor (`photocraft-compose`, also the reference for export and tests): Multichannel documents, and documents or effect regions over the texture limit. Pieces the GPU can't derive itself are rasterised once on the CPU and cached (`compose::masks` for vector masks, `compose::shape_split` for stroked shapes with clipped layers, effect distance fields). Timings of the interactive paths: `cargo run --release -p photocraft-ui-egui --example interactive_bench`; effects: `--example fx_bench` (`--compare files…` for GPU vs CPU); the cost of changing a chisel bevel's size (a dragged slider, GPU and CPU, ellipse and text): `--example bevel_bench`; large documents (open, refresh, thumbnails, a filter, a stroke, saves; one operation per run so `/usr/bin/time -l` gives its peak memory): `--example large_image_bench -- --size 14000x14000 --op psd`. The app requests the adapter's own texture limit (egui's default is 8192 px; see `gpu_canvas::use_adapter_limits`); beyond it the CPU fallback composites and uploads in bands (`compose::render_bands`), and exports, thumbnails and flattening stream bands too, so no full-size float composite is ever held. Rendering fidelity: `cargo run --release -p photocraft-io --example oracle_diff -- corpus/psd` (the whole PSD oracle table in seconds). `ui.inspect` → `perf.timings.gpuFallback` names the reason (`null` on the GPU path). - **Layer effects on the GPU** (`gpu/src/fx.rs`, kernels in `gpu/src/compose.wgsl`). Every enabled effect becomes a *map program* over the layer's effect region (shift, dilate, Gaussian blur, glow ramp, bevel height and shading, contour, stroke band), mirroring `compose::effects` step by step; the chunked composite then paints through the maps, clipped to that region, and copies the result back into the backdrop in place, so a small text layer costs only its own pixels. The layer's shape (`compose::layer_shape`) and its distance fields (`compose::effects::distance_field`: a transform whose tie-breaking a parallel GPU pass can't reproduce bit for bit) come from compose on the CPU: bands computed in parallel, except the Euclidean fields of precise glows and chiselled bevels (a halo as tall as the bevel size would make most of a band's work redundant), which are one window whose passes run on all threads, the CPU compositor's own way. Everything is cached per layer state: an unrelated edit, or an effect's colour or opacity, rebuilds nothing; a brush dab recomputes the touched 256² tiles grown by the effect reach; changing one effect's geometry rebuilds that effect only. Cache budget `gpu::FX_BUDGET` (1.5 GB, least recently drawn layers evicted first). `PHOTOCRAFT_FX_TRACE=1` prints the CPU time of each rebuild. From bd6f18d76695239034f02b92daec742a19914a97 Mon Sep 17 00:00:00 2001 From: hogawish <60434858+hogawish@users.noreply.github.com> Date: Sat, 17 Oct 2026 19:36:50 +0900 Subject: [PATCH 112/649] test(canvas): keep fixture assertions outside adapter skip --- crates/ui-egui/src/canvas_cpu_background_tests.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/canvas_cpu_background_tests.rs b/crates/ui-egui/src/canvas_cpu_background_tests.rs index ed0ac98dc5..e7e6bc1d22 100644 --- a/crates/ui-egui/src/canvas_cpu_background_tests.rs +++ b/crates/ui-egui/src/canvas_cpu_background_tests.rs @@ -79,10 +79,13 @@ fn harness(size: [u32; 2], background: &str) -> Harness { app }); h.run_steps(12); + h +} + +fn assert_fixture(h: &Harness, background: &str) { let key = cache_key(h.state().session.documents()[0].doc.id, None); assert!(h.state().session.prefs().transparency_and_gamut.square().is_some()); assert_eq!(h.state().canvases[&key].texture_opaque, background == "white", "fixture opacity"); - h } /// Draw the unchanged reference path by temporarily disabling only the opacity guarantee. @@ -105,6 +108,8 @@ fn omitting_an_occluded_checker_preserves_cpu_canvas_pixels() { eprintln!("skipping: no offscreen graphics adapter"); return; }; + // Fixture failures must fail the test, outside the missing-adapter skip above. + assert_fixture(&h, "white"); for (rotation, flip, pattern) in [(0.0, false, false), (23.0, false, false), (0.0, true, false), (0.0, false, true)] { h.state_mut().ui.views[0].rotation = rotation; h.state_mut().ui.view.flip_horizontal = flip; @@ -125,6 +130,7 @@ fn cpu_canvas_background_benchmark() { let output = std::env::var_os("PHOTOCRAFT_CPU_BENCH_OUTPUT").map(std::path::PathBuf::from); for background in ["white", "transparent"] { let mut h = harness([6000, 4000], background); + assert_fixture(&h, background); let v = &mut h.state_mut().ui.views[0]; v.zoom = 1.0; v.center = [3000.0, 2000.0]; From 85760b1c36c6ef66674133591ac7505defce55d7 Mon Sep 17 00:00:00 2001 From: abc2cb <271337822+abc2cb@users.noreply.github.com> Date: Sat, 17 Oct 2026 16:24:48 +0300 Subject: [PATCH 113/649] PSD Wave smart filters: keep more than 64 generators verbatim The Wave renderer clamps the generator count to 64 (the command allows up to 999), but a Photoshop Wave with Scale 100% mapped to filter.distort.wave whatever its Number of Generators. A file with 332 generators opened as a supported, editable Wave and, once its cached pixels were re-rendered, drew 64. Treat it like a scaled Wave: a Wave with fewer than 1 or more than 64 generators stays Photoshop's, descriptor kept verbatim and written back unchanged. The limit is photocraft_algo::MAX_WAVE_GENERATORS, which the renderer now clamps to as well, so the two cannot drift. Tests: the 332-generator Wave stays unsupported and round-trips its descriptor; a new boundary test maps 1 and 64 generators and keeps 65, 999, 0 and -1 verbatim. Co-Authored-By: Claude Opus 5.5 --- crates/algo/src/distort.rs | 6 +++- crates/algo/src/lib.rs | 1 + crates/io/src/smart_map.rs | 60 ++++++++++++++++++++++++++++---------- docs/file-format-parity.md | 2 +- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/crates/algo/src/distort.rs b/crates/algo/src/distort.rs index 664169afa4..f16145256b 100644 --- a/crates/algo/src/distort.rs +++ b/crates/algo/src/distort.rs @@ -95,6 +95,10 @@ pub(crate) fn spherize(src: &Image, out: Rect, ctx: &Ctx, amount: f32, mode: Sph }) } +/// The most Wave generators the renderer models: it clamps the setting to this, so a file asking +/// for more (the command allows up to 999) would render differently from how it was authored. +pub const MAX_WAVE_GENERATORS: u32 = 64; + /// Wave generator settings. pub(crate) struct WaveSpec { pub generators: u32, @@ -121,7 +125,7 @@ fn shape(t: WaveType, phase: f32) -> f32 { } pub(crate) fn wave(src: &Image, out: Rect, ctx: &Ctx, w: WaveSpec) -> Vec { - let n = w.generators.clamp(1, 64); + let n = w.generators.clamp(1, MAX_WAVE_GENERATORS); let lerp = |(a, b): (f32, f32), t: f32| a + (b - a).max(0.0) * t; let gens: Vec<(f32, f32, f32, f32)> = (0..n) .map(|i| { diff --git a/crates/algo/src/lib.rs b/crates/algo/src/lib.rs index 49ab15871c..377bb92810 100644 --- a/crates/algo/src/lib.rs +++ b/crates/algo/src/lib.rs @@ -85,6 +85,7 @@ pub mod warp; pub mod wideangle; pub use artistic::{GALLERY_CATEGORIES, GalleryEffect, GalleryFilter, GalleryParam, GalleryParamKind}; +pub use distort::MAX_WAVE_GENERATORS; pub use image::{Edge, Image}; pub use params_ext::*; diff --git a/crates/io/src/smart_map.rs b/crates/io/src/smart_map.rs index a9bce47273..0d78f2ffcc 100644 --- a/crates/io/src/smart_map.rs +++ b/crates/io/src/smart_map.rs @@ -304,13 +304,17 @@ fn known_params(class: &str, f: Option<&Descriptor>) -> Option<(&'static str, J) ("Plr ", Some(f)) => json!({"mode": enum_param(f, "Cnvr", &POLAR_MODE)?}), ("ZgZg", Some(f)) => json!({"amount": int(f, "Amnt")?, "ridges": int(f, "NmbR")?, "style": enum_param(f, "ZZTy", &ZIGZAG_STYLE)?}), ("Wave", Some(f)) => { - // PhotoCraft's Wave has no Scale: a scaled wave stays verbatim rather than lose it. - if int(f, "SclH")? != 100 || int(f, "SclV")? != 100 { + // PhotoCraft's Wave has no Scale: a scaled wave stays verbatim rather than lose it. The + // same for more generators than the renderer models, which would draw fewer than + // Photoshop did (and than the file asks for, once its cached pixels are re-rendered). + let generators = int(f, "NmbG")?; + let modelled = u32::try_from(generators).is_ok_and(|g| (1..=photocraft_algo::MAX_WAVE_GENERATORS).contains(&g)); + if int(f, "SclH")? != 100 || int(f, "SclV")? != 100 || !modelled { return None; } json!({ "type": enum_param(f, "Wvtp", &WAVE_TYPE)?, - "generators": int(f, "NmbG")?, + "generators": generators, "wavelengthMin": int(f, "WLMn")?, "wavelengthMax": int(f, "WLMx")?, "amplitudeMin": int(f, "AmMn")?, @@ -1233,24 +1237,48 @@ mod tests { let f = filter_from_item(&item); assert_eq!(f.command, UNSUPPORTED_FILTER); assert_eq!(item_for_filter(&f).unwrap().get("Fltr"), item.get("Fltr")); - // Unscaled, it opens as PhotoCraft's Wave (Triangle, the other settings as stored). + // Unscaled, but with 332 generators (the renderer draws 64 at most), it stays Photoshop's too. let mut unscaled = match item.get("Fltr") { Some(Value::Descriptor(d)) => d.clone(), other => panic!("wave: no Fltr ({other:?})"), }; set(&mut unscaled, "SclV", Value::Integer(100)); - let f = filter_from_item(&photoshop_item(unscaled.clone())); - assert_eq!( - (f.command.as_str(), &f.params), - ( - "filter.distort.wave", - &json!({"type": "triangle", "generators": 332, "wavelengthMin": 213, "wavelengthMax": 214, "amplitudeMin": 240, "amplitudeMax": 241, - "undefinedAreas": "wrap", "seed": 1270346}) - ) - ); - match item_for_filter(&f).unwrap().get("Fltr") { - Some(Value::Descriptor(ours)) => assert_eq!((&ours.class_id, &ours.items), (&unscaled.class_id, &unscaled.items)), - other => panic!("wave: no Fltr ({other:?})"), + let item = photoshop_item(unscaled); + let f = filter_from_item(&item); + assert_eq!(f.command, UNSUPPORTED_FILTER); + assert_eq!(item_for_filter(&f).unwrap().get("Fltr"), item.get("Fltr")); + } + + /// An unscaled Wave opens as PhotoCraft's Wave (Triangle, the other settings as stored) up to + /// the generators the renderer models; one more and it stays Photoshop's, unchanged. + #[test] + fn wave_maps_up_to_the_generators_the_renderer_models() { + let max = i32::try_from(photocraft_algo::MAX_WAVE_GENERATORS).unwrap(); + assert_eq!(max, 64); + let mut wave = Descriptor::from_bytes(&from_hex(PHOTOSHOP_WAVE).unwrap()).unwrap(); + set(&mut wave, "SclV", Value::Integer(100)); + for (generators, mapped) in [(1, true), (max, true), (max + 1, false), (999, false), (0, false), (-1, false)] { + set(&mut wave, "NmbG", Value::Integer(generators)); + let item = photoshop_item(wave.clone()); + let f = filter_from_item(&item); + if mapped { + assert_eq!( + (f.command.as_str(), &f.params), + ( + "filter.distort.wave", + &json!({"type": "triangle", "generators": generators, "wavelengthMin": 213, "wavelengthMax": 214, "amplitudeMin": 240, + "amplitudeMax": 241, "undefinedAreas": "wrap", "seed": 1270346}) + ), + "{generators} generators" + ); + match item_for_filter(&f).unwrap().get("Fltr") { + Some(Value::Descriptor(ours)) => assert_eq!((&ours.class_id, &ours.items), (&wave.class_id, &wave.items), "{generators} generators"), + other => panic!("wave: no Fltr ({other:?})"), + } + } else { + assert_eq!(f.command, UNSUPPORTED_FILTER, "{generators} generators"); + assert_eq!(item_for_filter(&f).unwrap().get("Fltr"), item.get("Fltr"), "{generators} generators"); + } } } diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 2b6c62be6d..2eeac93a76 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -145,7 +145,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings. | 2026-10-14 | minor | PSD smart filter masks: Photoshop stores a smart object's filtered pixels without its filter mask and mixes the unfiltered ones (`FEid`) back in; import now mixes them and export writes them that way, so sf-filter-mask-hard, -gradient and sf-stack-blend-and-mask pass; Photoshop-oracle floor 185 → 188 of 258 | | 2026-10-13 | minor | Lossy DNG (compression 34892) decodes: 8-bit baseline JPEG tiles and strips, CFA and LinearRaw, partial edge tiles; the stored values take the normal levels and LinearizationTable (FILE-215-11, lossy DNG part) | | 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 | -| 2026-10-13 | minor | PSD smart filters: Pinch, Polar Coordinates, Ripple, Spherize, Twirl, Wave, ZigZag and Invert open as editable filters and are saved instead of dropped (checked against a Photoshop 27 file); a scaled Wave and Shear stay verbatim | +| 2026-10-13 | minor | PSD smart filters: Pinch, Polar Coordinates, Ripple, Spherize, Twirl, Wave, ZigZag and Invert open as editable filters and are saved instead of dropped (checked against a Photoshop 27 file); a scaled Wave, a Wave with more than 64 generators and Shear stay verbatim | | 2026-10-13 | minor | CMYK Hue/Saturation (not Colorize) and Color Balance work on C, M and Y as inverted RGB with black kept, on the inks for display, export and destructive edits; cmyk8/16 hue-saturation 100% → 0.4–0.7% bad pixels, color-balance 74% → 25% | | 2026-10-13 | minor | CMYK Posterize works on the stored values (1 − ink), as Photoshop does: psd-tools posterize_cmyk passes (13.8 % → 0 of pixels off on the ink path); psd-tools floor → 242 of 309 | | 2026-10-13 | minor | CMYK documents whose layers are plain raster layers plus Invert, Posterize, Threshold, Brightness/Contrast, Levels or Curves layers composite on their own inks for display, export and flattening: the cmyk8/16 oracles for those seven adjustments pass; Photoshop-oracle floor 151 → 165 of 258 | From 5d552d4a605fca75f7d0923829f89af4622f2cf2 Mon Sep 17 00:00:00 2001 From: Jeremy Yao Date: Sat, 17 Oct 2026 11:52:09 -0400 Subject: [PATCH 114/649] Animation Effects: one wheel fix, readers split by platform, clearer names - wheel_nav: unsmooth is the one place that stops the wheel glide. main's read_with(smooth) from #5883 did the same for the canvas only, and only for plain scrolling; with unsmooth running first in PhotocraftApp::logic it no longer changed anything, so read() is the single reader again and the canvas calls it as before. #5883's test now drives unsmooth and sits with the other Animation Effects tests. - wheel_nav: arrived and touch become unsmoothed_scroll and in_gesture, with plainer docs. - animations.rs: the Linux/BSD settings parsers move to animations/freedesktop.rs (plain functions, tested on every platform), so animations.rs reads as one short reader per platform under a table of where each one reads from. - prefs_ui: Runtime::reduce_motion becomes animations_off, to match animations_on(); the long animation test is split into three focused ones. No change in behaviour. Co-Authored-By: Claude Opus 5.5 --- apps/photocraft/src/animations.rs | 341 +++++------------- apps/photocraft/src/animations/freedesktop.rs | 150 ++++++++ crates/ui-egui/src/canvas.rs | 4 +- crates/ui-egui/src/lib.rs | 5 +- crates/ui-egui/src/prefs_ui.rs | 84 +++-- crates/ui-egui/src/wheel_nav.rs | 182 +++++----- 6 files changed, 377 insertions(+), 389 deletions(-) create mode 100644 apps/photocraft/src/animations/freedesktop.rs diff --git a/apps/photocraft/src/animations.rs b/apps/photocraft/src/animations.rs index 62d138e756..bae69370b0 100644 --- a/apps/photocraft/src/animations.rs +++ b/apps/photocraft/src/animations.rs @@ -1,36 +1,30 @@ //! The operating system's animation setting, for Preferences › Interface › Animation Effects › -//! Use System Setting (`Services::system_animations`). +//! Use System Setting (`Services::system_animations`). `None` means the platform gave no answer; +//! the app then keeps animations on. //! -//! - **Windows**: Settings › Accessibility › Visual effects › Animation effects, through -//! `UISettings.AnimationsEnabled`. It answers for the session, so a Remote Desktop connection -//! that turns animations off counts too. -//! - **macOS**: System Settings › Accessibility › Display › Reduce motion -//! (`NSWorkspace.accessibilityDisplayShouldReduceMotion`). -//! - **Linux**: the settings portal: `reduced-motion`, then GNOME's `enable-animations` and KDE's -//! `AnimationDurationFactor` as the portal passes them on. Its change signal keeps the value -//! current, and it works inside a Flatpak sandbox. -//! - **Linux without the portal, FreeBSD and the other BSDs**: the desktop's setting where it is -//! stored: KDE's `kdeglobals`, GNOME's or MATE's `enable-animations` (`gsettings`), then GTK's -//! `gtk-enable-animations`. There is no change signal to follow, so it is read at start-up and -//! again whenever the window gets the focus back. -//! -//! `None` means the platform gave no answer; the shell then keeps animations on. +//! | Platform | Read from | +//! |---|---| +//! | Windows | Settings › Accessibility › Visual effects › Animation effects (`UISettings.AnimationsEnabled`) | +//! | macOS | System Settings › Accessibility › Display › Reduce motion | +//! | Linux | The settings portal, followed as it changes; it also works inside a Flatpak | +//! | Linux without the portal, the BSDs | The desktop's own files and `gsettings` (`freedesktop.rs`), read again when the window gets the focus back | //! //! No `unsafe`: every OS call goes through a safe binding. +#[cfg(any(test, all(unix, not(target_os = "macos"))))] +mod freedesktop; + pub use platform::service; -/// Windows and macOS answer at once, so the setting is simply asked for again: at most this -/// often, and only on frames that run anyway (coming back from the system's settings is one). -#[cfg(any(target_os = "windows", target_os = "macos"))] -const POLL: std::time::Duration = std::time::Duration::from_secs(1); - +/// Windows and macOS answer at once, so the setting is asked for again on frames that run anyway +/// (coming back from the system's settings is one), at most once a second. #[cfg(any(target_os = "windows", target_os = "macos"))] fn polled(read: fn() -> Option) -> photocraft_ui_egui::SystemAnimationsFn { + const INTERVAL: std::time::Duration = std::time::Duration::from_secs(1); let last = std::cell::Cell::new(None::<(std::time::Instant, Option)>); Box::new(move |_| { if let Some((at, animations)) = last.get() - && at.elapsed() < POLL + && at.elapsed() < INTERVAL { return animations; } @@ -42,12 +36,12 @@ fn polled(read: fn() -> Option) -> photocraft_ui_egui::SystemAnimationsFn #[cfg(target_os = "windows")] mod platform { - use photocraft_ui_egui::SystemAnimationsFn; - - pub fn service() -> Option { + pub fn service() -> Option { Some(super::polled(read)) } + /// A safe WinRT call; it reports what Windows applies to this session, so a Remote Desktop + /// connection with animations off counts too. pub(super) fn read() -> Option { windows::UI::ViewManagement::UISettings::new().and_then(|settings| settings.AnimationsEnabled()).ok() } @@ -55,9 +49,7 @@ mod platform { #[cfg(target_os = "macos")] mod platform { - use photocraft_ui_egui::SystemAnimationsFn; - - pub fn service() -> Option { + pub fn service() -> Option { Some(super::polled(read)) } @@ -66,42 +58,37 @@ mod platform { } } -#[cfg(not(any(unix, target_os = "windows")))] -mod platform { - pub fn service() -> Option { - None - } -} - +/// Linux and the BSDs. Reading the setting can mean waiting for the session bus or running +/// `gsettings`, so a worker thread does it and the UI reads its latest answer. #[cfg(all(unix, not(target_os = "macos")))] mod platform { use std::sync::atomic::{AtomicU8, Ordering}; use std::sync::{Arc, OnceLock, mpsc}; - use photocraft_ui_egui::SystemAnimationsFn; + use super::freedesktop; - /// Follows the desktop's setting on a worker thread, so a slow session bus or `gsettings` - /// never holds up a frame. Until the first answer lands the setting is unknown. - pub fn service() -> Option { - let value = Arc::new(AtomicU8::new(super::code_of(None))); + pub fn service() -> Option { + let latest = Arc::new(AtomicU8::new(encode(None))); let wake: Arc> = Arc::new(OnceLock::new()); let (refresh, refreshes) = mpsc::channel::<()>(); - let publisher = Publisher { value: Arc::clone(&value), wake: Arc::clone(&wake) }; + let publisher = Publisher { latest: Arc::clone(&latest), wake: Arc::clone(&wake) }; std::thread::Builder::new().name("animations-setting".into()).spawn(move || worker(&publisher, &refreshes)).ok()?; - let focused = std::cell::Cell::new(true); + let last_focus = std::cell::Cell::new(true); Some(Box::new(move |ctx| { let _ = wake.set(ctx.clone()); - let now = ctx.input(|i| i.focused); - let was = focused.replace(now); - // Back from the desktop's settings, perhaps: the worker reads again unless it has - // the portal's change signal (then nobody listens, and the send fails quietly). - if now && !was { + let focused = ctx.input(|i| i.focused); + let was_focused = last_focus.replace(focused); + // Back from the desktop's settings, perhaps: read again. With the portal's change + // signal nobody listens for this, and the send fails quietly. + if focused && !was_focused { let _ = refresh.send(()); } - super::decode(value.load(Ordering::Relaxed)) + decode(latest.load(Ordering::Relaxed)) })) } + /// Follows the portal when it has an answer; otherwise reads the desktop's own setting now + /// and on every refresh request. fn worker(publisher: &Publisher, refreshes: &mpsc::Receiver<()>) { #[cfg(target_os = "linux")] if portal::follow(publisher) { @@ -113,16 +100,16 @@ mod platform { } } - /// The worker's handle on the shared value. A change wakes the registered UI. + /// The worker's side of the latest answer. A change wakes the UI. struct Publisher { - value: Arc, + latest: Arc, wake: Arc>, } impl Publisher { fn publish(&self, animations: Option) { - let code = super::code_of(animations); - if self.value.swap(code, Ordering::Relaxed) != code + let code = encode(animations); + if self.latest.swap(code, Ordering::Relaxed) != code && let Some(ctx) = self.wake.get() { ctx.request_repaint(); @@ -130,21 +117,37 @@ mod platform { } } + fn encode(animations: Option) -> u8 { + match animations { + None => 0, + Some(true) => 1, + Some(false) => 2, + } + } + + fn decode(code: u8) -> Option { + match code { + 1 => Some(true), + 2 => Some(false), + _ => None, + } + } + #[cfg(target_os = "linux")] mod portal { use zbus::zvariant::{OwnedValue, Value}; - use super::super::{duration_factor, enabled, reduced_motion}; + use super::freedesktop; - /// Whether animations are on according to a setting's value. - type Reads = fn(&str) -> Option; + /// Reads a setting's value as animations on or off. + type Parse = fn(&str) -> Option; - /// The settings the portal may answer for and how each one's value reads, most general - /// first: the cross-desktop one, then the two desktops' own that older portals pass on. - const SETTINGS: [(&str, &str, Reads); 3] = [ - ("org.freedesktop.appearance", "reduced-motion", reduced_motion), - ("org.gnome.desktop.interface", "enable-animations", enabled), - ("org.kde.kdeglobals.KDE", "AnimationDurationFactor", duration_factor), + /// The settings the portal may answer for, most general first: the cross-desktop one, + /// then GNOME's and KDE's own, which older portals pass on. + const SETTINGS: [(&str, &str, Parse); 3] = [ + ("org.freedesktop.appearance", "reduced-motion", freedesktop::from_reduced_motion), + ("org.gnome.desktop.interface", "enable-animations", freedesktop::from_enabled), + ("org.kde.kdeglobals.KDE", "AnimationDurationFactor", freedesktop::from_duration_factor), ]; /// Publishes the portal's answer, then every change to it. `false` when the portal has @@ -168,14 +171,14 @@ mod platform { } fn read(proxy: &zbus::blocking::Proxy<'_>) -> Option { - SETTINGS.iter().find_map(|(namespace, key, animations)| { + SETTINGS.iter().find_map(|(namespace, key, parse)| { let value: OwnedValue = proxy.call("Read", &(*namespace, *key)).ok()?; - animations(&text(value)?) + parse(&as_text(value)?) }) } /// A setting's value as the text a settings file would hold. - fn text(value: OwnedValue) -> Option { + fn as_text(value: OwnedValue) -> Option { let mut value: Value<'_> = value.into(); // The Settings.Read result is a variant; some portals nest another variant inside it. for _ in 0..4 { @@ -203,42 +206,36 @@ mod platform { #[test] fn portal_values_read_as_text() { let nested = Value::Value(Box::new(Value::Value(Box::new(Value::U32(1))))); - assert_eq!(text(owned(nested)).as_deref(), Some("1")); - assert_eq!(text(owned(Value::from(false))).as_deref(), Some("false")); - assert_eq!(text(owned(Value::from("0.5"))).as_deref(), Some("0.5")); - assert_eq!(text(owned(Value::from(vec![1u32, 2]))), None); - // Each setting reads its own type of value, the cross-desktop one first. - let [(_, motion, reduced), (_, _, on), (_, _, factor)] = SETTINGS; - assert_eq!(motion, "reduced-motion"); - assert_eq!(reduced(&text(owned(Value::U32(1))).unwrap()), Some(false)); - assert_eq!(reduced(&text(owned(Value::U32(0))).unwrap()), Some(true)); - assert_eq!(on(&text(owned(Value::from(false))).unwrap()), Some(false)); - assert_eq!(factor(&text(owned(Value::from("0"))).unwrap()), Some(false)); - assert_eq!(factor(&text(owned(Value::F64(0.5))).unwrap()), Some(true)); + assert_eq!(as_text(owned(nested)).as_deref(), Some("1")); + assert_eq!(as_text(owned(Value::from(false))).as_deref(), Some("false")); + assert_eq!(as_text(owned(Value::F64(0.5))).as_deref(), Some("0.5")); + assert_eq!(as_text(owned(Value::from("0"))).as_deref(), Some("0")); + assert_eq!(as_text(owned(Value::from(vec![1u32, 2]))), None); + assert_eq!(SETTINGS[0].1, "reduced-motion", "the cross-desktop setting is asked first"); } } } + /// The desktop's own setting, without the portal. mod desktop { use std::path::PathBuf; + use super::freedesktop; + /// A settings file is a few kilobytes; a larger one isn't read. const MAX_CONFIG_BYTES: u64 = 1 << 20; pub fn read() -> Option { let desktop = std::env::var("XDG_CURRENT_DESKTOP").unwrap_or_default(); - super::super::desktop_setting(&desktop, &config_file, &gsettings) - } - - fn config_home() -> Option { - let dir = |key: &str| std::env::var_os(key).filter(|v| !v.is_empty()).map(PathBuf::from); - dir("XDG_CONFIG_HOME").filter(|path| path.is_absolute()).or_else(|| dir("HOME").map(|home| home.join(".config"))) + freedesktop::without_portal(&desktop, &config_file, &gsettings) } fn config_file(name: &str) -> Option { use std::io::Read as _; + let dir = |key: &str| std::env::var_os(key).filter(|v| !v.is_empty()).map(PathBuf::from); + let config_home = dir("XDG_CONFIG_HOME").filter(|path| path.is_absolute()).or_else(|| dir("HOME").map(|home| home.join(".config")))?; let mut text = String::new(); - std::fs::File::open(config_home()?.join(name)).ok()?.take(MAX_CONFIG_BYTES).read_to_string(&mut text).ok()?; + std::fs::File::open(config_home.join(name)).ok()?.take(MAX_CONFIG_BYTES).read_to_string(&mut text).ok()?; Some(text) } @@ -257,188 +254,22 @@ mod platform { } } -/// `true` or `false` (GSettings, the portal), `1` or `0` (a GTK settings file): animations are on. -#[cfg(any(test, all(unix, not(target_os = "macos"))))] -fn enabled(value: &str) -> Option { - match value.trim().to_ascii_lowercase().as_str() { - "true" | "1" => Some(true), - "false" | "0" => Some(false), - _ => None, +#[cfg(not(any(unix, target_os = "windows")))] +mod platform { + pub fn service() -> Option { + None } } -/// KDE's animation speed factor: 0 turns animations off. -#[cfg(any(test, all(unix, not(target_os = "macos"))))] -fn duration_factor(value: &str) -> Option { - value.trim().parse::().ok().filter(|factor| factor.is_finite()).map(|factor| factor > 0.0) -} - -/// The portal's `reduced-motion`: 1 asks for less motion; 0 and the values it may grow don't. -#[cfg(any(test, target_os = "linux"))] -fn reduced_motion(value: &str) -> Option { - value.trim().parse::().ok().map(|code| code != 1) -} - -/// The last value of `key` in `[section]` of an INI-style file (KDE's config, GTK's settings). -#[cfg(any(test, all(unix, not(target_os = "macos"))))] -fn ini_value<'a>(text: &'a str, section: &str, key: &str) -> Option<&'a str> { - let mut inside = false; - let mut found = None; - for line in text.lines() { - let line = line.trim(); - if let Some(name) = line.strip_prefix('[').and_then(|rest| rest.strip_suffix(']')) { - inside = name == section; - } else if inside && let Some((name, value)) = line.split_once('=') { - // KDE marks an entry the user may not change as `Key[$i]=value`. - let name = name.split_once('[').map_or(name, |(name, _)| name); - if name.trim() == key { - found = Some(value.trim()); - } - } - } - found -} - -/// The desktop's setting without the portal. `desktop` is `XDG_CURRENT_DESKTOP`, `file` reads a -/// file under the user's config directory and `gsettings` runs `gsettings get `. -#[cfg(any(test, all(unix, not(target_os = "macos"))))] -fn desktop_setting(desktop: &str, file: &dyn Fn(&str) -> Option, gsettings: &dyn Fn(&str, &str) -> Option) -> Option { - let running = |name: &str| desktop.split(':').any(|part| part.eq_ignore_ascii_case(name)); - let in_file = |name: &str, section: &str, key: &str, animations: fn(&str) -> Option| animations(ini_value(&file(name)?, section, key)?); - if running("KDE") - && let Some(animations) = in_file("kdeglobals", "KDE", "AnimationDurationFactor", duration_factor) - { - return Some(animations); - } - let schema = if running("MATE") { "org.mate.interface" } else { "org.gnome.desktop.interface" }; - let shell = gsettings(schema, "enable-animations").and_then(|out| enabled(&out)); - if shell == Some(false) { - return shell; - } - // `true` may only be the schema's default on a desktop that doesn't use it. GTK's own file - // is what a bare window manager's user writes, and what KDE keeps in step with its setting. - ["gtk-4.0/settings.ini", "gtk-3.0/settings.ini"].iter().find_map(|name| in_file(name, "Settings", "gtk-enable-animations", enabled)).or(shell) -} - -#[cfg(any(test, all(unix, not(target_os = "macos"))))] -fn code_of(animations: Option) -> u8 { - match animations { - None => 0, - Some(true) => 1, - Some(false) => 2, - } -} - -#[cfg(any(test, all(unix, not(target_os = "macos"))))] -fn decode(code: u8) -> Option { - match code { - 1 => Some(true), - 2 => Some(false), - _ => None, - } -} - -#[cfg(test)] +#[cfg(all(test, target_os = "windows"))] mod tests { - use super::*; - - #[test] - fn each_setting_reads_its_own_values() { - for (s, animations) in - [("true\n", Some(true)), ("false\n", Some(false)), ("1", Some(true)), ("0", Some(false)), ("FALSE", Some(false)), ("", None), ("maybe", None)] - { - assert_eq!(enabled(s), animations, "{s:?}"); - } - for (s, animations) in [ - ("0", Some(false)), - ("0.0", Some(false)), - ("0.5", Some(true)), - ("1", Some(true)), - ("-1", Some(false)), - ("", None), - ("fast", None), - ("NaN", None), - ("inf", None), - ] { - assert_eq!(duration_factor(s), animations, "{s:?}"); - } - // reduced-motion: only 1 asks for less motion; unknown values mean no preference. - for (s, animations) in [("0", Some(true)), ("1", Some(false)), ("2", Some(true)), ("true", None), ("-1", None), ("", None)] { - assert_eq!(reduced_motion(s), animations, "{s:?}"); - } - // The shared value round-trips, and a stray code is "unknown". - for animations in [None, Some(true), Some(false)] { - assert_eq!(decode(code_of(animations)), animations); - } - assert_eq!(decode(9), None); - } - - #[test] - fn ini_values_come_from_their_own_section() { - let kde = "[General]\nAnimationDurationFactor=3\n\n[KDE]\nSingleClick=false\n AnimationDurationFactor = 0 \n[KDE][Sub]\nAnimationDurationFactor=7\n"; - assert_eq!(ini_value(kde, "KDE", "AnimationDurationFactor"), Some("0")); - assert_eq!(ini_value(kde, "KDE", "Missing"), None); - assert_eq!(ini_value("[KDE]\nAnimationDurationFactor[$i]=0.5\n", "KDE", "AnimationDurationFactor"), Some("0.5"), "an immutable entry"); - assert_eq!( - ini_value("[Settings]\ngtk-enable-animations=1\ngtk-enable-animations=0\n", "Settings", "gtk-enable-animations"), - Some("0"), - "the last one wins" - ); - // Hostile text: no section, no `=`, stray brackets, non-ASCII. - for junk in ["", "AnimationDurationFactor=0", "[KDE", "[KDE]\n=\n[]\n]]][[[\n", "[KDE]\nклавиша=значение\n\u{0}\u{feff}"] { - assert_eq!(ini_value(junk, "KDE", "AnimationDurationFactor"), None, "{junk:?}"); - } - } - - #[test] - fn the_desktop_setting_is_read_where_each_desktop_keeps_it() { - let files = |kde: Option<&'static str>, gtk: Option<&'static str>| { - move |name: &str| match name { - "kdeglobals" => kde.map(String::from), - "gtk-3.0/settings.ini" => gtk.map(String::from), - _ => None, - } - }; - let none = |_: &str, _: &str| -> Option { None }; - let gnome = |on: &'static str| { - move |schema: &str, key: &str| (schema == "org.gnome.desktop.interface" && key == "enable-animations").then(|| format!("{on}\n")) - }; - let kde_off = Some("[KDE]\nAnimationDurationFactor=0\n"); - let gtk_off = Some("[Settings]\ngtk-enable-animations=false\n"); - - // KDE Plasma: its own file, only when Plasma is the desktop running. - assert_eq!(desktop_setting("KDE", &files(kde_off, None), &none), Some(false)); - assert_eq!(desktop_setting("KDE", &files(Some("[KDE]\nAnimationDurationFactor=0.5\n"), gtk_off), &none), Some(true)); - assert_eq!(desktop_setting("ubuntu:GNOME", &files(kde_off, None), &gnome("true")), Some(true), "a leftover kdeglobals is not GNOME's setting"); - // Plasma without the entry (animations at their default speed) falls through to GTK's file. - assert_eq!(desktop_setting("KDE", &files(Some("[KDE]\nSingleClick=false\n"), gtk_off), &none), Some(false)); - // GNOME and the desktops that share its schema. - assert_eq!(desktop_setting("GNOME", &files(None, None), &gnome("false")), Some(false)); - assert_eq!(desktop_setting("GNOME", &files(None, None), &gnome("true")), Some(true)); - // MATE keeps the same key in its own schema. - let mate = |schema: &str, _: &str| (schema == "org.mate.interface").then(|| "false\n".to_string()); - assert_eq!(desktop_setting("MATE", &files(None, None), &mate), Some(false)); - assert_eq!(desktop_setting("GNOME", &files(None, None), &mate), None); - // A bare window manager: GTK's settings file, which also outranks a schema default. - assert_eq!(desktop_setting("sway", &files(None, gtk_off), &none), Some(false)); - assert_eq!(desktop_setting("", &files(None, gtk_off), &gnome("true")), Some(false)); - assert_eq!(desktop_setting("", &files(None, Some("[Settings]\ngtk-enable-animations=1\n")), &none), Some(true)); - // Nothing to read, or nothing readable: unknown, never a panic. - assert_eq!(desktop_setting("", &files(None, None), &none), None); - assert_eq!( - desktop_setting("KDE:\u{0}::", &files(Some("\u{0}[[[=]]]"), Some("=\n[Settings]\ngtk-enable-animations=perhaps")), &|_, _| Some("\u{fffd}".into())), - None - ); - } - /// The real setting of the machine the tests run on: whatever it is, reading it doesn't /// panic and the service passes it on (`--nocapture` shows it). - #[cfg(target_os = "windows")] #[test] fn windows_reports_its_animation_setting() { - let animations = platform::read(); + let animations = super::platform::read(); println!("UISettings.AnimationsEnabled: {animations:?}"); - let service = platform::service().expect("service"); + let service = super::platform::service().expect("service"); assert_eq!(service(&egui::Context::default()), animations); } } diff --git a/apps/photocraft/src/animations/freedesktop.rs b/apps/photocraft/src/animations/freedesktop.rs new file mode 100644 index 0000000000..437ab5c42a --- /dev/null +++ b/apps/photocraft/src/animations/freedesktop.rs @@ -0,0 +1,150 @@ +//! Where Linux and BSD desktops keep their animation setting, and how to read its value. +//! +//! Plain functions over text, so the tests run on every platform. Each one answers whether +//! animations are on, or `None` when the value doesn't parse (the next source is asked then). + +/// GSettings' and the portal's `true`/`false`, or GTK's `1`/`0`. +pub fn from_enabled(value: &str) -> Option { + match value.trim().to_ascii_lowercase().as_str() { + "true" | "1" => Some(true), + "false" | "0" => Some(false), + _ => None, + } +} + +/// KDE's animation speed factor: 0 turns animations off. +pub fn from_duration_factor(value: &str) -> Option { + value.trim().parse::().ok().filter(|factor| factor.is_finite()).map(|factor| factor > 0.0) +} + +/// The settings portal's `reduced-motion`: 1 asks for less motion; 0 and any value added later +/// mean no preference. +#[cfg(any(test, target_os = "linux"))] +pub fn from_reduced_motion(value: &str) -> Option { + value.trim().parse::().ok().map(|code| code != 1) +} + +/// The desktop's setting when there is no settings portal to ask. `desktop` is +/// `XDG_CURRENT_DESKTOP`, `config_file` reads a file in the user's config directory and +/// `gsettings` runs `gsettings get `. +pub fn without_portal(desktop: &str, config_file: &dyn Fn(&str) -> Option, gsettings: &dyn Fn(&str, &str) -> Option) -> Option { + let running = |name: &str| desktop.split(':').any(|part| part.eq_ignore_ascii_case(name)); + let in_file = |file: &str, section: &str, key: &str, parse: fn(&str) -> Option| parse(ini_value(&config_file(file)?, section, key)?); + + // KDE Plasma keeps it in its own file. A kdeglobals left over from another desktop doesn't count. + if running("KDE") + && let Some(animations) = in_file("kdeglobals", "KDE", "AnimationDurationFactor", from_duration_factor) + { + return Some(animations); + } + // GNOME and the desktops built on it, or MATE's copy of the same key. + let schema = if running("MATE") { "org.mate.interface" } else { "org.gnome.desktop.interface" }; + let gnome = gsettings(schema, "enable-animations").and_then(|out| from_enabled(&out)); + if gnome == Some(false) { + return gnome; + } + // `true` may only be the schema's default on a desktop that doesn't use it, so GTK's own + // file comes first: it is what a bare window manager's user writes, and what KDE keeps in step. + ["gtk-4.0/settings.ini", "gtk-3.0/settings.ini"].iter().find_map(|file| in_file(file, "Settings", "gtk-enable-animations", from_enabled)).or(gnome) +} + +/// The last value of `key` in `[section]` of an INI-style file (KDE's config, GTK's settings). +pub fn ini_value<'a>(text: &'a str, section: &str, key: &str) -> Option<&'a str> { + let mut in_section = false; + let mut found = None; + for line in text.lines().map(str::trim) { + if let Some(name) = line.strip_prefix('[').and_then(|rest| rest.strip_suffix(']')) { + in_section = name == section; + } else if in_section && let Some((name, value)) = line.split_once('=') { + // KDE marks an entry the user may not change as `Key[$i]=value`. + let name = name.split_once('[').map_or(name, |(name, _)| name); + if name.trim() == key { + found = Some(value.trim()); + } + } + } + found +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn each_kind_of_value_reads_as_on_or_off() { + for (value, animations) in + [("true\n", Some(true)), ("false\n", Some(false)), ("1", Some(true)), ("0", Some(false)), ("FALSE", Some(false)), ("", None), ("maybe", None)] + { + assert_eq!(from_enabled(value), animations, "{value:?}"); + } + for (value, animations) in [ + ("0", Some(false)), + ("0.0", Some(false)), + ("0.5", Some(true)), + ("1", Some(true)), + ("-1", Some(false)), + ("", None), + ("fast", None), + ("NaN", None), + ("inf", None), + ] { + assert_eq!(from_duration_factor(value), animations, "{value:?}"); + } + for (value, animations) in [("0", Some(true)), ("1", Some(false)), ("2", Some(true)), ("true", None), ("-1", None), ("", None)] { + assert_eq!(from_reduced_motion(value), animations, "{value:?}"); + } + } + + #[test] + fn ini_values_come_from_their_own_section() { + let kde = "[General]\nAnimationDurationFactor=3\n\n[KDE]\nSingleClick=false\n AnimationDurationFactor = 0 \n[KDE][Sub]\nAnimationDurationFactor=7\n"; + assert_eq!(ini_value(kde, "KDE", "AnimationDurationFactor"), Some("0")); + assert_eq!(ini_value(kde, "KDE", "Missing"), None); + assert_eq!(ini_value("[KDE]\nAnimationDurationFactor[$i]=0.5\n", "KDE", "AnimationDurationFactor"), Some("0.5"), "an immutable entry"); + let gtk = "[Settings]\ngtk-enable-animations=1\ngtk-enable-animations=0\n"; + assert_eq!(ini_value(gtk, "Settings", "gtk-enable-animations"), Some("0"), "the last one wins"); + // Hostile text: no section, no `=`, stray brackets, non-ASCII. + for junk in ["", "AnimationDurationFactor=0", "[KDE", "[KDE]\n=\n[]\n]]][[[\n", "[KDE]\nклавиша=значение\n\u{0}\u{feff}"] { + assert_eq!(ini_value(junk, "KDE", "AnimationDurationFactor"), None, "{junk:?}"); + } + } + + #[test] + fn without_the_portal_each_desktop_is_read_where_it_keeps_the_setting() { + let files = |kdeglobals: Option<&'static str>, gtk3: Option<&'static str>| { + move |file: &str| match file { + "kdeglobals" => kdeglobals.map(String::from), + "gtk-3.0/settings.ini" => gtk3.map(String::from), + _ => None, + } + }; + let no_gsettings = |_: &str, _: &str| -> Option { None }; + let gnome = |on: &'static str| { + move |schema: &str, key: &str| (schema == "org.gnome.desktop.interface" && key == "enable-animations").then(|| format!("{on}\n")) + }; + let kde_off = Some("[KDE]\nAnimationDurationFactor=0\n"); + let gtk_off = Some("[Settings]\ngtk-enable-animations=false\n"); + + // KDE Plasma: its own file, only while Plasma is the desktop. + assert_eq!(without_portal("KDE", &files(kde_off, None), &no_gsettings), Some(false)); + assert_eq!(without_portal("KDE", &files(Some("[KDE]\nAnimationDurationFactor=0.5\n"), gtk_off), &no_gsettings), Some(true)); + assert_eq!(without_portal("ubuntu:GNOME", &files(kde_off, None), &gnome("true")), Some(true), "a leftover kdeglobals is not GNOME's setting"); + // Plasma without the entry (animations at their default speed) falls through to GTK's file. + assert_eq!(without_portal("KDE", &files(Some("[KDE]\nSingleClick=false\n"), gtk_off), &no_gsettings), Some(false)); + // GNOME and the desktops that share its schema. + assert_eq!(without_portal("GNOME", &files(None, None), &gnome("false")), Some(false)); + assert_eq!(without_portal("GNOME", &files(None, None), &gnome("true")), Some(true)); + // MATE keeps the same key in its own schema. + let mate = |schema: &str, _: &str| (schema == "org.mate.interface").then(|| "false\n".to_string()); + assert_eq!(without_portal("MATE", &files(None, None), &mate), Some(false)); + assert_eq!(without_portal("GNOME", &files(None, None), &mate), None); + // A bare window manager: GTK's settings file, which also outranks a schema default. + assert_eq!(without_portal("sway", &files(None, gtk_off), &no_gsettings), Some(false)); + assert_eq!(without_portal("", &files(None, gtk_off), &gnome("true")), Some(false)); + assert_eq!(without_portal("", &files(None, Some("[Settings]\ngtk-enable-animations=1\n")), &no_gsettings), Some(true)); + // Nothing to read, or nothing readable: unknown, never a panic. + assert_eq!(without_portal("", &files(None, None), &no_gsettings), None); + let unreadable = files(Some("\u{0}[[[=]]]"), Some("=\n[Settings]\ngtk-enable-animations=perhaps")); + assert_eq!(without_portal("KDE:\u{0}::", &unreadable, &|_, _| Some("\u{fffd}".into())), None); + } +} diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 36dca3dbf5..50f3b47ae4 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -3260,14 +3260,12 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: let bars_id = egui::Id::new(("pc-canvas-bars-hover", idx)); let over_bars = ctx.data(|d| d.get_temp::(bars_id)).unwrap_or(false); let nav_hovered = response.hovered() || free_hover || over_bars; - // Interface › Enable Animations off: the wheel moves the canvas without a glide (#5721). - let wheel = crate::wheel_nav::read_with( + let wheel = crate::wheel_nav::read( &ctx, app.session.prefs().general.zoom_with_scroll_wheel, app.session.prefs().enhanced_controls.zoom_with_trackpad_pinch, response.id.with("wheel"), nav_hovered, - !app.prefs_rt.reduce_motion, ); if nav_hovered { let pointer = ui.input(|i| i.pointer.hover_pos()); diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 13bff3f225..46b15ba93a 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1896,9 +1896,8 @@ impl eframe::App for PhotocraftApp { self.collect_screenshots(ctx); self.issue_screenshots(ctx); prefs_ui::tick(self, ctx); - // Animation Effects off: the wheel scrolls its whole distance at once, before anything - // reads this frame's scroll (wheel_nav.rs). - if self.prefs_rt.reduce_motion { + // Before anything reads this frame's scroll (see `wheel_nav::unsmooth`). + if self.prefs_rt.animations_off { wheel_nav::unsmooth(ctx); } monitor_status::poll_frame(self, ctx, frame); diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs index dc64c84297..4cb90dfafa 100644 --- a/crates/ui-egui/src/prefs_ui.rs +++ b/crates/ui-egui/src/prefs_ui.rs @@ -52,8 +52,8 @@ pub struct Runtime { show_rulers: Option, /// Tool options as last remembered in the preferences (see `tool_memory`). pub(crate) tool_options: Option, - /// Interface › Animation Effects came out as off this frame (see `sync_animations`). - pub(crate) reduce_motion: bool, + /// Interface › Animation Effects resolved to off this frame (see `sync_animations`). + pub(crate) animations_off: bool, pub(crate) selected_tool: Option, } @@ -412,8 +412,8 @@ fn sync_tooltips(app: &PhotocraftApp, ctx: &egui::Context) { } } -/// Interface › Animation Effects, resolved: on or off as chosen, or the operating system's own -/// setting for Use System Setting (on where the platform cannot tell). +/// Interface › Animation Effects, resolved: on or off as chosen, or for Use System Setting what +/// the operating system says (on when it can't tell). fn animations_on(app: &PhotocraftApp, ctx: &egui::Context) -> bool { match app.session.prefs().interface.animation_effects { prefs::AnimationEffects::On => true, @@ -422,13 +422,14 @@ fn animations_on(app: &PhotocraftApp, ctx: &egui::Context) -> bool { } } -/// Interface › Animation Effects: off, egui's fades and slides take no time and scroll areas jump -/// straight to their target (#3273); the wheel's own glide is taken out by `wheel_nav::unsmooth`. -/// Re-checked every frame because a theme change rebuilds the style and the system's setting can -/// change; both the dark and light styles are set, so a system appearance switch keeps it. +/// Interface › Animation Effects: off, egui's fades and slides take no time and `scroll_to` jumps +/// straight to its target (#3273); `PhotocraftApp::logic` takes out the wheel's glide +/// (`wheel_nav::unsmooth`). Checked every frame: a theme change rebuilds the style and the +/// system's setting can change. Both the dark and light styles are set, so an appearance switch +/// keeps it. fn sync_animations(app: &mut PhotocraftApp, ctx: &egui::Context) { let on = animations_on(app, ctx); - app.prefs_rt.reduce_motion = !on; + app.prefs_rt.animations_off = !on; let time = if on { egui::Style::default().animation_time } else { 0.0 }; if ctx.global_style().animation_time != time { let scroll = if on { egui::style::ScrollAnimation::default() } else { egui::style::ScrollAnimation::none() }; @@ -3470,63 +3471,76 @@ mod tests { } } + /// egui's `animation_time` in the dark and the light style. + fn animation_times(ctx: &egui::Context) -> [f32; 2] { + [egui::Theme::Dark, egui::Theme::Light].map(|t| ctx.style_of(t).animation_time) + } + #[test] - fn animation_effects_follow_the_choice_or_the_system_and_are_remembered() { - use std::{cell::Cell, rc::Rc}; + fn animation_effects_off_stops_egui_animations_and_is_remembered() { let on = egui::Style::default().animation_time; - let both = |ctx: &egui::Context| [egui::Theme::Dark, egui::Theme::Light].map(|t| ctx.style_of(t).animation_time); + assert!(on > 0.0, "egui animates by default"); // Saved off: the first frame after a restart applies it to both appearance styles. let (mut app, _) = app_with_saved(Some(json!({"interface": {"animationEffects": "off"}}).to_string())); let ctx = egui::Context::default(); tick(&mut app, &ctx); - assert_eq!(both(&ctx), [0.0, 0.0]); + assert_eq!(animation_times(&ctx), [0.0, 0.0]); assert_eq!(ctx.global_style().scroll_animation.duration.max, 0.0); - assert!(app.prefs_rt.reduce_motion); + assert!(app.prefs_rt.animations_off); // A theme change rebuilds the style; the next frame turns animations off again. app.apply_theme(&ctx, crate::theme::ThemeKind::StudioLight); tick(&mut app, &ctx); - assert_eq!(both(&ctx), [0.0, 0.0]); + assert_eq!(animation_times(&ctx), [0.0, 0.0]); app.run("prefs.set", json!({"values": {"interface.animationEffects": "on"}})).unwrap(); tick(&mut app, &ctx); - assert_eq!(both(&ctx), [on, on]); - assert!(on > 0.0 && ctx.global_style().scroll_animation.duration.max > 0.0 && !app.prefs_rt.reduce_motion); + assert_eq!(animation_times(&ctx), [on, on]); + assert!(ctx.global_style().scroll_animation.duration.max > 0.0 && !app.prefs_rt.animations_off); + } - // Use System Setting, the default, follows the platform as it changes. - let system = Rc::new(Cell::new(Some(false))); + #[test] + fn use_system_setting_follows_the_platform() { + use std::{cell::Cell, rc::Rc}; + let on = egui::Style::default().animation_time; + let system = Rc::new(Cell::new(None)); let (mut app, _) = app_with_store(); - assert_eq!(app.session.prefs().interface.animation_effects, prefs::AnimationEffects::System); let read = system.clone(); app.services.system_animations = Some(Box::new(move |_| read.get())); let ctx = egui::Context::default(); + assert_eq!(app.session.prefs().interface.animation_effects, prefs::AnimationEffects::System, "the default"); + // As the system's setting changes; no answer keeps animations on. for (answer, time) in [(Some(false), 0.0), (Some(true), on), (None, on), (Some(false), 0.0)] { system.set(answer); tick(&mut app, &ctx); - assert_eq!(both(&ctx), [time, time], "the system says {answer:?}"); - assert_eq!(app.prefs_rt.reduce_motion, time == 0.0); + assert_eq!(animation_times(&ctx), [time, time], "the system says {answer:?}"); } // On and Off hold whatever the system says. for (answer, choice, time) in [(Some(false), "on", on), (Some(true), "off", 0.0), (Some(true), "system", on)] { system.set(answer); app.run("prefs.set", json!({"values": {"interface.animationEffects": choice}})).unwrap(); tick(&mut app, &ctx); - assert_eq!(both(&ctx), [time, time], "{choice} while the system says {answer:?}"); + assert_eq!(animation_times(&ctx), [time, time], "{choice} while the system says {answer:?}"); } - // A platform that can't tell (no service): Use System Setting keeps animations on. + // A platform without the service can't tell: animations stay on. let (mut plain, _) = app_with_store(); let ctx = egui::Context::default(); tick(&mut plain, &ctx); - assert_eq!(both(&ctx), [on, on]); - // The Enable Animations checkbox this replaced: a saved "off" is still off. - let (mut old, _) = app_with_saved(Some(json!({"interface": {"enableAnimations": false}}).to_string())); - let ctx = egui::Context::default(); - tick(&mut old, &ctx); - assert_eq!(both(&ctx), [0.0, 0.0]); - // A hand-edited value that is no choice doesn't crash: the defaults stay. - for junk in [json!("nope"), json!(7), json!(null)] { - let (mut bad, _) = app_with_saved(Some(json!({"interface": {"animationEffects": junk}}).to_string())); + assert_eq!(animation_times(&ctx), [on, on]); + } + + #[test] + fn old_and_hand_edited_animation_settings_load_safely() { + let on = egui::Style::default().animation_time; + let after_restart = |interface: Value| { + let (mut app, _) = app_with_saved(Some(json!({"interface": interface}).to_string())); let ctx = egui::Context::default(); - tick(&mut bad, &ctx); - assert_eq!(both(&ctx), [on, on]); + tick(&mut app, &ctx); + animation_times(&ctx) + }; + // The Enable Animations checkbox this replaced: a saved "off" is still off. + assert_eq!(after_restart(json!({"enableAnimations": false})), [0.0, 0.0]); + // A value that is no choice doesn't crash: the defaults stay. + for junk in [json!("nope"), json!(7), json!(null)] { + assert_eq!(after_restart(json!({"animationEffects": junk})), [on, on], "{junk}"); } } diff --git a/crates/ui-egui/src/wheel_nav.rs b/crates/ui-egui/src/wheel_nav.rs index 900ea3779a..67e44ae608 100644 --- a/crates/ui-egui/src/wheel_nav.rs +++ b/crates/ui-egui/src/wheel_nav.rs @@ -170,28 +170,36 @@ pub fn fold_legacy_pinch(ctx: &Context, raw: &mut RawInput) { } } -fn touch_id() -> Id { - Id::new("pc-wheel-touch") +fn gesture_id() -> Id { + Id::new("pc-wheel-gesture") } -/// What this frame's wheel events scroll in all, in points: each one in its unit and folded -/// sideways or upright by its modifiers, as egui does before it smooths them. `touch` follows -/// trackpad gestures (the ones with a begin and an end phase). `None` leaves egui's own value -/// alone: for a frame with part of such a gesture, which egui applies as it arrives (and whose -/// modifiers it holds from the start), for a wheel event that zooms, and for a hostile sum. -fn arrived(events: &[Event], options: &egui::InputOptions, page: f32, touch: &mut bool) -> Option { - let mut gesture = *touch; +/// What this frame's wheel events scroll in all, in points, each folded sideways or upright by +/// its modifiers as egui folds it. `in_gesture` carries from frame to frame whether a trackpad +/// gesture (one with begin and end phases) is in progress. +/// +/// `None` keeps egui's own scroll: in a frame with any part of such a gesture, which egui applies +/// at once and with the modifiers it started with; for a wheel event that zooms; and for a sum +/// that isn't finite. +fn unsmoothed_scroll(events: &[Event], options: &egui::InputOptions, page: f32, in_gesture: &mut bool) -> Option { + let mut gesture_frame = *in_gesture; let mut sum = Vec2::ZERO; for event in events { let Event::MouseWheel { unit, delta, phase, modifiers } = event else { continue }; match phase { - TouchPhase::Start => (*touch, gesture) = (true, true), - TouchPhase::End | TouchPhase::Cancel => (*touch, gesture) = (false, true), + TouchPhase::Start => { + *in_gesture = true; + gesture_frame = true; + } + TouchPhase::End | TouchPhase::Cancel => { + *in_gesture = false; + gesture_frame = true; + } TouchPhase::Move => { if modifiers.matches_any(options.zoom_modifier) { return None; } - let delta = *delta + let points = *delta * match unit { MouseWheelUnit::Point => 1.0, MouseWheelUnit::Line => options.line_scroll_speed, @@ -200,35 +208,32 @@ fn arrived(events: &[Event], options: &egui::InputOptions, page: f32, touch: &mu let sideways = modifiers.matches_any(options.horizontal_scroll_modifier); let upright = modifiers.matches_any(options.vertical_scroll_modifier); sum += match (sideways, upright) { - (true, false) => Vec2::new(delta.x + delta.y, 0.0), - (false, true) => Vec2::new(0.0, delta.x + delta.y), - _ => delta, + (true, false) => Vec2::new(points.x + points.y, 0.0), + (false, true) => Vec2::new(0.0, points.x + points.y), + _ => points, }; } } } - (!gesture && sum.x.is_finite() && sum.y.is_finite()).then_some(sum) + (!gesture_frame && sum.x.is_finite() && sum.y.is_finite()).then_some(sum) } -/// Interface › Animation Effects off: scroll the whole distance of a wheel notch in the frame -/// it arrives. egui spreads a notch over the next several frames (a glide of about 0.2 s, with -/// no setting to turn it off), so this replaces the frame's smoothed scroll with everything its -/// wheel events add up to; the frames after it carry only the rest of that glide and no wheel -/// events, and so scroll nothing. Call it once a frame before anything reads the scroll -/// (`PhotocraftApp::logic`). Zooming already reads the wheel events themselves ([`read`]). +/// Interface › Animation Effects off: a wheel notch scrolls its whole distance in the frame it +/// arrives. egui spreads each notch over about 0.2 s and has no setting to stop it, so this +/// replaces the frame's smoothed scroll with what the frame's own wheel events add up to. The +/// frames after a notch carry only the rest of egui's glide, and so scroll nothing. +/// +/// Call it once a frame, before anything reads the scroll (`PhotocraftApp::logic` does). pub fn unsmooth(ctx: &Context) { let options = ctx.options(|o| o.input_options); - let was = ctx.data(|d| d.get_temp::(touch_id())).unwrap_or(false); - let mut touch = was; + let mut in_gesture = ctx.data(|d| d.get_temp::(gesture_id())).unwrap_or(false); ctx.input_mut(|i| { let page = i.viewport_rect().height(); - if let Some(scroll) = arrived(&i.events, &options, page, &mut touch) { + if let Some(scroll) = unsmoothed_scroll(&i.events, &options, page, &mut in_gesture) { i.smooth_scroll_delta = scroll; } }); - if touch != was { - ctx.data_mut(|d| d.insert_temp(touch_id(), touch)); - } + ctx.data_mut(|d| d.insert_temp(gesture_id(), in_gesture)); } fn alt_id() -> Id { @@ -262,13 +267,6 @@ const SNAP_IDLE_TIMEOUT: f64 = 0.5; /// accumulator per viewport. `hovered` gates accumulation: only the viewport receiving /// navigation may add raw input to the snap residual. pub fn read(ctx: &Context, zoom_with_wheel: bool, pinch_zooms: bool, owner: Id, hovered: bool) -> Option { - read_with(ctx, zoom_with_wheel, pinch_zooms, owner, hovered, true) -} - -/// [`read`], choosing how a plain wheel scroll pans: `smooth` glides it over a few frames (egui's -/// smoothed delta); off, as with Interface › Enable Animations off, the view moves the whole notch -/// in the frame the wheel turns and stops there (#5721), as scroll areas already do. -pub fn read_with(ctx: &Context, zoom_with_wheel: bool, pinch_zooms: bool, owner: Id, hovered: bool, smooth: bool) -> Option { let notch = ctx.options(|o| o.input_options.line_scroll_speed); // --- Modifier tracking (always runs for all callers) --- @@ -387,8 +385,6 @@ pub fn read_with(ctx: &Context, zoom_with_wheel: bool, pinch_zooms: bool, owner: d.remove::(snap_time_id(owner)); }); } - // Unsmoothed, a plain scroll pans by this frame's own wheel events (none: no tail). - let scroll = if smooth || alt || shift { scroll } else { raw }; classify(Input { scroll, raw, zoom_delta, alt, shift, zoom_with_wheel, pinch_zooms, notch }) } } @@ -441,42 +437,6 @@ mod tests { (a - b).length() < 0.01 } - /// #5721: with smoothing off a wheel notch pans the whole notch in the frame it arrives and - /// nothing after; smoothed (the default) it glides, reaching the same total over later frames. - #[test] - fn unsmoothed_wheel_pans_at_once_without_a_glide() { - let pans = |smooth: bool| -> Vec { - let owner = Id::new("test-unsmoothed"); - let ctx = Context::default(); - configure(&ctx); - (0..30) - .map(|n| { - let events = if n == 0 { vec![wheel(Vec2::new(0.0, -1.0), Modifiers::NONE)] } else { Vec::new() }; - let raw = RawInput { time: Some(f64::from(n) / 60.0), predicted_dt: 1.0 / 60.0, events, ..Default::default() }; - let mut pan = Vec2::ZERO; - let mut out = ctx.run_ui(raw, |ui| { - if let Some(Wheel::Pan(d)) = read_with(ui.ctx(), false, true, owner, true, smooth) { - pan = d; - } - }); - out.textures_delta.clear(); - pan - }) - .collect() - }; - let notch = { - let ctx = Context::default(); - configure(&ctx); - ctx.options(|o| o.input_options.line_scroll_speed) - }; - let direct = pans(false); - assert!(near(direct[0], Vec2::new(0.0, -notch)), "the whole notch at once: {:?}", direct[0]); - assert!(direct[1..].iter().all(|p| *p == Vec2::ZERO), "no glide after it"); - let smooth = pans(true); - assert!(smooth[0].y.abs() < notch - 0.5, "smoothed, the first frame moves only part of it: {:?}", smooth[0]); - assert!(smooth[1..].iter().any(|p| p.y != 0.0), "and the rest follows"); - } - #[test] fn plain_scroll_pans() { assert_eq!(classify(input(Vec2::new(3.0, -40.0), false)), Some(Wheel::Pan(Vec2::new(3.0, -40.0)))); @@ -711,6 +671,48 @@ mod tests { assert!(matches!(ev[0], Event::MouseWheel { .. })); } + // --- Interface › Animation Effects off (`unsmooth`) + + /// #5721: with Animation Effects off ([`unsmooth`]) a wheel notch pans the canvas the whole + /// notch in the frame it arrives and nothing after; on, it glides, reaching the same total + /// over later frames. + #[test] + fn unsmoothed_wheel_pans_at_once_without_a_glide() { + let pans = |smooth: bool| -> Vec { + let owner = Id::new("test-unsmoothed"); + let ctx = Context::default(); + configure(&ctx); + (0..30) + .map(|n| { + let events = if n == 0 { vec![wheel(Vec2::new(0.0, -1.0), Modifiers::NONE)] } else { Vec::new() }; + let raw = RawInput { time: Some(f64::from(n) / 60.0), predicted_dt: 1.0 / 60.0, events, ..Default::default() }; + let mut pan = Vec2::ZERO; + let mut out = ctx.run_ui(raw, |ui| { + if !smooth { + unsmooth(ui.ctx()); + } + if let Some(Wheel::Pan(d)) = read(ui.ctx(), false, true, owner, true) { + pan = d; + } + }); + out.textures_delta.clear(); + pan + }) + .collect() + }; + let notch = { + let ctx = Context::default(); + configure(&ctx); + ctx.options(|o| o.input_options.line_scroll_speed) + }; + let direct = pans(false); + assert!(near(direct[0], Vec2::new(0.0, -notch)), "the whole notch at once: {:?}", direct[0]); + assert!(direct[1..].iter().all(|p| *p == Vec2::ZERO), "no glide after it"); + let smooth = pans(true); + assert!(smooth[0].y.abs() < notch - 0.5, "smoothed, the first frame moves only part of it: {:?}", smooth[0]); + assert!(smooth[1..].iter().any(|p| p.y != 0.0), "and the rest follows"); + } + /// `smooth_scroll_delta` as the UI reads it on each of 30 frames at 60 fps, in a context set /// up like the app's; `off` is Animation Effects off ([`unsmooth`] at the start of the frame). fn scrolled(frames: Vec>, off: bool) -> Vec { @@ -769,23 +771,17 @@ mod tests { let glide = total(&scrolled(vec![events.clone()], false)); assert!((glide - want).length() < 1.0, "the same distance as with animations on: {events:?}: {glide:?}"); } - // The canvas pans by all of it on that frame too, and Alt + wheel still zooms one step. + // Alt + wheel still zooms one step, and doesn't pan as well. let ctx = Context::default(); configure(&ctx); + let raw = RawInput { time: Some(0.0), predicted_dt: 1.0 / 60.0, events: vec![wheel(Vec2::new(0.0, 1.0), Modifiers::ALT)], ..Default::default() }; let mut seen = None; - for (time, modifiers) in [(0.0, Modifiers::NONE), (1.0, Modifiers::ALT)] { - let raw = RawInput { time: Some(time), predicted_dt: 1.0 / 60.0, events: vec![wheel(Vec2::new(0.0, 1.0), modifiers)], ..Default::default() }; - let mut out = ctx.run_ui(raw, |ui| { - unsmooth(ui.ctx()); - seen = read(ui.ctx(), false, true, Id::new("test-unsmooth"), true); - }); - out.textures_delta.clear(); - if modifiers.alt { - assert!(matches!(seen, Some(Wheel::Zoom(f)) if (f - 1.1).abs() < 1e-4), "{seen:?}"); - } else { - assert_eq!(seen, Some(Wheel::Pan(Vec2::new(0.0, 40.0)))); - } - } + let mut out = ctx.run_ui(raw, |ui| { + unsmooth(ui.ctx()); + seen = read(ui.ctx(), false, true, Id::new("test-alt"), true); + }); + out.textures_delta.clear(); + assert!(matches!(seen, Some(Wheel::Zoom(f)) if (f - 1.1).abs() < 1e-4), "{seen:?}"); } /// What the setting is for: an egui scroll area (panels, lists, long menus) is at its new @@ -852,23 +848,23 @@ mod tests { #[test] fn unsmoothing_skips_zoom_and_hostile_numbers() { let options = egui::InputOptions::default(); - let mut touch = false; + let mut in_gesture = false; let zoom = [wheel(Vec2::new(0.0, 1.0), CTRL)]; - assert_eq!(arrived(&zoom, &options, 600.0, &mut touch), None, "egui's default: ⌘/Ctrl + wheel zooms"); + assert_eq!(unsmoothed_scroll(&zoom, &options, 600.0, &mut in_gesture), None, "egui's default: ⌘/Ctrl + wheel zooms"); let plain = [wheel(Vec2::new(0.0, 1.0), Modifiers::NONE)]; - assert_eq!(arrived(&plain, &options, 600.0, &mut touch), Some(Vec2::new(0.0, options.line_scroll_speed))); - assert_eq!(arrived(&[], &options, 600.0, &mut touch), Some(Vec2::ZERO), "no wheel event: the rest of a glide is dropped"); + assert_eq!(unsmoothed_scroll(&plain, &options, 600.0, &mut in_gesture), Some(Vec2::new(0.0, options.line_scroll_speed))); + assert_eq!(unsmoothed_scroll(&[], &options, 600.0, &mut in_gesture), Some(Vec2::ZERO), "no wheel event: the rest of a glide is dropped"); for bad in [f32::NAN, f32::INFINITY, -f32::INFINITY, f32::MAX] { for page in [600.0, f32::NAN, f32::INFINITY, 0.0, -1.0] { for unit in [MouseWheelUnit::Point, MouseWheelUnit::Line, MouseWheelUnit::Page] { let events = [Event::MouseWheel { unit, delta: Vec2::new(bad, bad), phase: TouchPhase::Move, modifiers: Modifiers::SHIFT }]; - if let Some(sum) = arrived(&events, &options, page, &mut touch) { + if let Some(sum) = unsmoothed_scroll(&events, &options, page, &mut in_gesture) { assert!(sum.x.is_finite() && sum.y.is_finite(), "{sum:?} from {bad} {page} {unit:?}"); } } } } - assert!(!touch, "no gesture phase was seen"); + assert!(!in_gesture, "no gesture phase was seen"); } #[test] From 52ad01f426910e1780ee9419c9cb1b4c80eeb035 Mon Sep 17 00:00:00 2001 From: highperfocused Date: Sat, 17 Oct 2026 14:58:30 +0200 Subject: [PATCH 115/649] Eyedropper: a large sampling ring that reads on any colour (#6973) --- crates/ui-egui/src/canvas.rs | 61 ++++++---- crates/ui-egui/tests/eyedropper_ring.rs | 143 ++++++++++++++++++++++++ 2 files changed, 181 insertions(+), 23 deletions(-) create mode 100644 crates/ui-egui/tests/eyedropper_ring.rs diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 914d395acc..8de3b7ff4b 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -650,11 +650,13 @@ pub(crate) fn eyedropper_ring_colors(app: &mut PhotocraftApp, x: f64, y: f64) -> Some((display_color(new), display_color([fg[0], fg[1], fg[2]]))) } -/// Draw the Eyedropper's comparison ring at `p`: the sampled colour on the upper arc, the -/// current one below, both over a thin dark outline so they read on any image (#213). Like -/// Photoshop it shows only while the mouse button is held (`held`): hovering shows the plain -/// crosshair and samples nothing. `None` when not held, there is nothing to sample, or the -/// Precise-cursor preference wants the plain crosshair. +/// Draw the Eyedropper's comparison ring at `p`: an opaque neutral grey band around the +/// pointer with the sampled colour on its upper half and the current one on the lower, +/// framed by thin dark and light hairlines so every edge reads on any image, and the +/// pipette at its centre marking the sampled pixel (#213, #6973). Like Photoshop it shows +/// only while the mouse button is held (`held`): hovering shows the plain pipette and +/// samples nothing. `None` when not held, there is nothing to sample, or the Precise-cursor +/// preference wants the plain crosshair. fn eyedropper_ring(app: &mut PhotocraftApp, painter: &egui::Painter, xf: &ViewXform, p: Pos2, held: bool) -> Option { // The options bar's Show Sampling Ring turns it off (#1649). if !held || !app.ui.tool_options.eyedropper_ring || app.session.prefs().cursors.other == photocraft_engine::prefs::OtherCursor::Precise { @@ -662,27 +664,40 @@ fn eyedropper_ring(app: &mut PhotocraftApp, painter: &egui::Painter, xf: &ViewXf } let [x, y] = xf.to_doc(p); let (new, current) = eyedropper_ring_colors(app, x, y)?; - // Two arcs with a small gap at 3 and 9 o'clock. Screen y grows down, so PI..TAU is the - // upper half (the new colour) and 0..PI the lower (the current one). + // Photoshop's proportions (#6973): a ring about 210 pt across whose opaque grey outer + // band and coloured inner band are each about 17 pt wide, over a transparent centre. + // In points, so the ring scales with Interface › UI Scale like the rest of the cursor. + let (r_out, band) = (105.0_f32, 17.0_f32); + let r_in = r_out - 2.0 * band; + // Screen y grows down, so PI..TAU is the upper half (the sampled colour) and 0..PI the + // lower (the current one); the halves meet at 3 and 9 o'clock, as in Photoshop. use std::f32::consts::{PI, TAU}; - let (r, w, gap) = (11.0_f32, 4.0_f32, 0.16_f32); - let arc = |a0: f32, a1: f32| -> Vec { - (0..=24) - .map(|i| { - let a = a0 + (a1 - a0) * i as f32 / 24.0; - p + vec2(a.cos(), a.sin()) * r - }) - .collect() - }; - let outline = crate::theme::Tokens::get(painter.ctx()).shadow; - for (a0, a1, colour) in [(PI + gap, TAU - gap, new), (gap, PI - gap, current)] { - let points = arc(a0, a1); - painter.add(egui::Shape::line(points.clone(), Stroke::new(w + 1.5, outline))); - painter.add(egui::Shape::line(points, Stroke::new(w, colour))); - } - Some(egui::CursorIcon::None) + let upper: Vec = (0..=48) + .map(|i| { + let a = PI + (TAU - PI) * i as f32 / 48.0; + p + vec2(a.cos(), a.sin()) * (r_in + band / 2.0) + }) + .collect(); + // `circle_stroke` paints its stroke outside the radius, `Shape::line` centres it. + painter.circle_stroke(p, r_in, Stroke::new(band, current)); + painter.add(egui::Shape::line(upper, Stroke::new(band, new))); + painter.circle_stroke(p, r_in + band, Stroke::new(band, RING_GREY)); + // Thin dark and light hairlines on the ring's two edges, one physical pixel wide, so it + // reads on any colour including a flat mid-grey that matches the band itself (#6973). + let px = 1.0 / painter.ctx().pixels_per_point().max(1.0); + let (dark, light) = (Stroke::new(px, Color32::from_black_alpha(160)), Stroke::new(px, Color32::from_white_alpha(160))); + painter.circle_stroke(p, r_out, dark); + painter.circle_stroke(p, r_out + px, light); + painter.circle_stroke(p, r_in - px, dark); + painter.circle_stroke(p, r_in - 2.0 * px, light); + // Photoshop keeps the pipette visible at the centre, its tip on the sampled pixel; a + // ring this size says nothing about where it samples without it. + Some(pipette_cursor(painter.ctx(), p)) } +/// The Eyedropper ring's opaque neutral grey, as Photoshop measures it (#6973). +const RING_GREY: Color32 = Color32::from_gray(127); + fn begin_live_stroke(app: &PhotocraftApp) -> Option { static STROKES: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0); let st = app.session.active()?; diff --git a/crates/ui-egui/tests/eyedropper_ring.rs b/crates/ui-egui/tests/eyedropper_ring.rs new file mode 100644 index 0000000000..74c2321178 --- /dev/null +++ b/crates/ui-egui/tests/eyedropper_ring.rs @@ -0,0 +1,143 @@ +//! #6973: the Eyedropper's sampling ring must read over a flat area of any colour, including one +//! that matches the ring itself. The ring is Photoshop's large one: an opaque grey outer band with +//! the sampled colour above and the current one below, framed by thin dark and light hairlines. +//! These tests render the real app offscreen and read pixels back. They skip when no GPU adapter +//! is available (like `checker_canvas.rs`). + +use egui::{Modifiers, PointerButton, Pos2}; +use photocraft_ui_egui::PhotocraftApp; +use photocraft_ui_egui::control::{ControlRequest, handle}; +use serde_json::{Value, json}; + +type Harness = egui_kittest::Harness<'static, PhotocraftApp>; + +/// The ring geometry `eyedropper_ring` draws: outer radius and band width, in points. +const R_OUT: i32 = 105; +const BAND: i32 = 17; +/// The flat mid-grey the document is filled with: exactly the ring's own grey, the worst case. +const BG: u8 = 0x7f; + +fn harness() -> Option { + let built = std::panic::catch_unwind(|| { + egui_kittest::Harness::builder().with_size(egui::vec2(1400.0, 800.0)).with_pixels_per_point(1.0).with_max_steps(64).wgpu().build_eframe(|cc| { + PhotocraftApp::setup_context(&cc.egui_ctx, Default::default()); + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + if let Some(rs) = cc.wgpu_render_state.as_ref() { + app.set_wgpu(rs.clone()); + } + app + }) + }); + match built { + Ok(h) => Some(h), + Err(_) => { + eprintln!("skipping: no GPU adapter"); + None + } + } +} + +fn control(h: &mut Harness, method: &str, params: Value) { + let ctx = h.ctx.clone(); + let (req, _rx) = ControlRequest::new(method, params); + handle(h.state_mut(), &ctx, &req); + h.run_steps(3); +} + +/// A 400 × 400 flat mid-grey document, the Eyedropper active and centred in the view. +fn setup(h: &mut Harness) -> Pos2 { + { + let app = h.state_mut(); + while app.session.active().is_some() { + app.run("file.close", json!({"discard": true})).expect("close"); + } + app.run("file.new", json!({"width": 400, "height": 400, "background": "white"})).expect("new"); + app.run("edit.fill", json!({"color": format!("#{BG:02x}{BG:02x}{BG:02x}")})).expect("fill"); + app.sync_views(); + } + control(h, "ui.set", json!({"tool": "eyedropper", "zoom": 1.0, "center": [200.0, 200.0]})); + h.run_steps(3); + let r = h.state().last_canvas_rect; + r.center() +} + +fn pointer_at(h: &mut Harness, p: Pos2) { + h.event(egui::Event::PointerMoved(p)); + h.step(); +} + +fn button_at(h: &mut Harness, p: Pos2, pressed: bool) { + h.event(egui::Event::PointerButton { pos: p, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }); + h.step(); +} + +/// A rendered screen. +struct Shot { + w: u32, + px: Vec, +} + +impl Shot { + fn at(&self, x: i32, y: i32) -> [u8; 4] { + let i = ((y.max(0) as u32 * self.w + x.max(0) as u32) * 4) as usize; + [self.px[i], self.px[i + 1], self.px[i + 2], self.px[i + 3]] + } +} + +fn shot(h: &mut Harness) -> Shot { + let rendered = h.render().expect("render"); + Shot { w: rendered.width(), px: rendered.into_raw() } +} + +/// The largest channel difference from the flat document grey. +fn off_bg(p: [u8; 4]) -> i32 { + [p[0], p[1], p[2]].iter().map(|v| (*v as i32 - BG as i32).abs()).max().unwrap_or(0) +} + +/// Walking out from the centre along `-y`, the first pixel above the ring's outer edge that +/// differs from the background: the ring's outer hairline. `None` when nothing does within the +/// band's neighbourhood, i.e. the ring is invisible over the flat grey. +fn outer_edge_reads(img: &Shot, c: Pos2) -> bool { + let (cx, cy) = (c.x as i32, c.y as i32); + // The hairlines sit at r_out + 0.5 and + 1.5 px; scan a little either side of them. + (R_OUT - 2..R_OUT + 4).any(|d| off_bg(img.at(cx, cy - d)) >= 30) +} + +#[test] +fn ring_reads_over_a_flat_area_of_its_own_colour() { + let Some(mut h) = harness() else { return }; + h.run_steps(4); + let c = setup(&mut h); + pointer_at(&mut h, c); + button_at(&mut h, c, true); + h.run_steps(2); + let img = shot(&mut h); + // The old 22 pt ring left nothing at this radius; the hairlines must not. + assert!(outer_edge_reads(&img, c), "the ring's outer edge is invisible over a flat mid-grey"); + // And the inner edge, where the transparent centre meets the coloured band. + let r_in = R_OUT - 2 * BAND; + let (cx, cy) = (c.x as i32, c.y as i32); + assert!((r_in - 3..r_in + 2).any(|d| off_bg(img.at(cx, cy - d)) >= 30), "the ring's inner edge is invisible over a flat mid-grey"); + // The pipette stays visible at the centre, marking the sampled pixel. + let pipette = (-12..12).any(|dy| (-12..12).any(|dx| off_bg(img.at(cx + dx, cy + dy)) >= 30)); + assert!(pipette, "no pipette drawn at the ring's centre"); + button_at(&mut h, c, false); +} + +#[test] +fn show_sampling_ring_off_draws_nothing() { + let Some(mut h) = harness() else { return }; + h.run_steps(4); + let c = setup(&mut h); + control(&mut h, "ui.set", json!({"eyedropperRing": false})); + pointer_at(&mut h, c); + button_at(&mut h, c, true); + h.run_steps(2); + let img = shot(&mut h); + let (cx, cy) = (c.x as i32, c.y as i32); + // Nothing of the ring: the whole ring neighbourhood is the flat document grey, apart from the + // pipette cursor the tool draws at the pointer anyway. + let quiet = (R_OUT - 2..R_OUT + 4).all(|d| off_bg(img.at(cx, cy - d)) < 30) && (R_OUT - 2..R_OUT + 4).all(|d| off_bg(img.at(cx, cy + d)) < 30); + assert!(quiet, "the ring is drawn although Show Sampling Ring is off"); + button_at(&mut h, c, false); +} From 89305c1d174eaa42dc2a93a7ba25fe8fc49190f7 Mon Sep 17 00:00:00 2001 From: deniskhud Date: Sat, 17 Oct 2026 23:13:00 +0200 Subject: [PATCH 116/649] Shape tools: gradient Fill and Stroke from the swatches, with an editable stops strip The shape Fill / Stroke swatches (options bar and Properties) offer No Color, Solid and Gradient, as Photoshop's popover does, for the next shape and the selected one. The Gradient tab (shape_gradient_ui.rs) has a Recent row, the preset library, a stops strip (click to add a colour or opacity stop, drag to move, drag off to delete, midpoints) with the selected stop's colour, opacity, location and Delete, and style, angle, scale, Reverse and Align with layer. Stop edits reuse the Gradient Editor's apply_stop. shape.create / shape.edit take and report every gradient field (opacityStops, midpoints, offset, dither, align), so editing an imported gradient keeps the rest. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/vector_cmds.rs | 38 +- crates/engine/src/vector_cmds/tests.rs | 29 ++ crates/ui-egui/src/gradient_ui.rs | 4 +- crates/ui-egui/src/shape_gradient_ui.rs | 470 +++++++++++++++++++++++ crates/ui-egui/src/state.rs | 11 + crates/ui-egui/src/tool_reset.rs | 2 +- crates/ui-egui/src/vector_paint_tests.rs | 219 +++++++++++ crates/ui-egui/src/vector_ui.rs | 121 +++++- docs/scorecard.md | 2 +- docs/shape-strokes.md | 20 +- scorecard/tools.toml | 2 +- 11 files changed, 886 insertions(+), 32 deletions(-) create mode 100644 crates/ui-egui/src/shape_gradient_ui.rs diff --git a/crates/engine/src/vector_cmds.rs b/crates/engine/src/vector_cmds.rs index 14579e5954..34f2f260da 100644 --- a/crates/engine/src/vector_cmds.rs +++ b/crates/engine/src/vector_cmds.rs @@ -247,15 +247,17 @@ pub fn path_json(p: &Path) -> Value { fn fill_json(f: &Fill) -> Value { match f { Fill::Solid(c) => json!(hex(c)), - Fill::Gradient { stops, angle, scale, style, reverse, .. } => json!({ "gradient": { + Fill::Gradient { stops, angle, scale, style, reverse, opacity_stops, midpoints, offset, dither, align } => json!({ "gradient": { "stops": stops.iter().map(|(t, c)| json!([t, hex(c)])).collect::>(), - "angle": angle, "scale": scale * 100.0, "style": format!("{style:?}").to_ascii_lowercase(), "reverse": reverse } }), + "angle": angle, "scale": scale * 100.0, "style": format!("{style:?}").to_ascii_lowercase(), "reverse": reverse, + "opacityStops": opacity_stops, "midpoints": midpoints, "offset": [offset.0, offset.1], "dither": dither, "align": align } }), Fill::Pattern { name, scale, .. } => json!({ "pattern": name, "scale": scale * 100.0 }), } } -/// `"#rrggbb"` / `[r,g,b,a]` / `{"gradient":{"stops":[[t,"#hex"],…],"angle","scale","style","reverse"}}` / -/// `{"pattern":name,"scale"}`. `null` → `Ok(None)` (no fill). +/// `"#rrggbb"` / `[r,g,b,a]` / `{"gradient":{"stops":[[t,"#hex"|[r,g,b,a]],…],"angle","scale","style","reverse", +/// "opacityStops":[[t,0..1],…],"midpoints":[0..1,…],"offset":[x,y],"dither","align"}}` / `{"pattern":name,"scale"}`. +/// `null` → `Ok(None)` (no fill). fn parse_fill(v: &Value) -> std::result::Result, String> { if v.is_null() { return Ok(None); @@ -276,13 +278,35 @@ fn parse_fill(v: &Value) -> std::result::Result, String> { "diamond" => GradientStyle::Diamond, _ => GradientStyle::Linear, }; - return Ok(Some(Fill::gradient( + let mut fill = Fill::gradient( stops, f64p(g, "angle").unwrap_or(90.0) as f32, f64p(g, "scale").unwrap_or(100.0) as f32 / 100.0, style, g.get("reverse").and_then(Value::as_bool).unwrap_or(false), - ))); + ); + // The rest of a gradient, so a read-modify-write (the shape swatches) loses nothing. + if let Fill::Gradient { opacity_stops, midpoints, offset, dither, align, .. } = &mut fill { + let unit = |v: &Value| v.as_f64().map(|n| n.clamp(0.0, 1.0) as f32); + if let Some(a) = g.get("opacityStops").and_then(Value::as_array) { + *opacity_stops = a.iter().filter_map(|s| Some((unit(s.get(0)?)?, unit(s.get(1)?)?))).collect(); + opacity_stops.sort_by(|a, b| a.0.total_cmp(&b.0)); + } + if let Some(a) = g.get("midpoints").and_then(Value::as_array) { + *midpoints = a.iter().filter_map(unit).collect(); + } + if let Some(o) = g.get("offset") { + let at = |i: usize| o.get(i).and_then(Value::as_f64).map(|n| n.clamp(-1000.0, 1000.0) as f32); + *offset = (at(0).ok_or("gradient offset must be [x, y]")?, at(1).ok_or("gradient offset must be [x, y]")?); + } + if let Some(d) = g.get("dither").and_then(Value::as_bool) { + *dither = d; + } + if let Some(a) = g.get("align").and_then(Value::as_bool) { + *align = a; + } + } + return Ok(Some(fill)); } if let Some(name) = v.get("pattern").and_then(Value::as_str) { return Ok(Some(Fill::Pattern { @@ -1676,7 +1700,7 @@ pub(crate) fn leak(s: String) -> &'static str { pub fn specs() -> Vec { let stroke = r##""stroke":{"width":px,"color":"#rrggbb"|fill,"opacity":0..100,"align":"inside|center|outside","cap":"butt|round|square","join":"miter|round|bevel","miterLimit":n,"dashes":[multiples of width],"dashOffset":n}|null"##; - let fill = r##""fill":"#rrggbb"|[r,g,b,a]|{"gradient":{"stops":[[t,"#hex"]],"angle":deg,"scale":%,"style":"linear|radial|angle|reflected|diamond","reverse":bool}}|{"pattern":name}|null (no fill)"##; + let fill = r##""fill":"#rrggbb"|[r,g,b,a]|{"gradient":{"stops":[[t,"#hex"|[r,g,b,a]]],"angle":deg,"scale":%,"style":"linear|radial|angle|reflected|diamond","reverse":bool,"opacityStops":[[t,0..1]]?,"midpoints":[0..1]?,"offset":[x,y]?,"dither":bool?,"align":bool?}}|{"pattern":name}|null (no fill)"##; vec![ spec!( "shape.create", diff --git a/crates/engine/src/vector_cmds/tests.rs b/crates/engine/src/vector_cmds/tests.rs index 7e1c871dff..bacd1b8869 100644 --- a/crates/engine/src/vector_cmds/tests.rs +++ b/crates/engine/src/vector_cmds/tests.rs @@ -27,6 +27,8 @@ fn stroke_validation_rejects_hostile_values_without_editing_history() { json!({"dashOffset": 1e100}), json!({"width": "4"}), json!({"width": 0.00001, "dashes": [0.01, 0.01]}), + json!({"color": {"gradient": {"offset": [0.5]}}}), + json!({"color": {"gradient": {"offset": "centre"}}}), ]; for stroke in invalid { assert!(s.execute("shape.edit", json!({"layer": id, "stroke": stroke})).is_err(), "{stroke}"); @@ -38,6 +40,33 @@ fn stroke_validation_rejects_hostile_values_without_editing_history() { assert_eq!(s.active().unwrap().doc, before); } +/// A gradient stroke keeps every gradient field through `shape.edit`, and `shape.info` reports +/// them, so the shape swatches can change one setting without dropping the rest. +#[test] +fn gradient_stroke_round_trips_every_gradient_field() { + let mut s = session(100, 80, 16); + let id = s.execute("shape.create", json!({"rect": [20, 20, 50, 30], "stroke": {"width": 6}})).unwrap()["layer"].as_u64().unwrap(); + let gradient = json!({"gradient": { + "stops": [[0.0, [0.25, 0.5, 0.75, 1.0]], [1.0, [1.0, 0.125, 0.0, 0.5]]], + "angle": 30.0, "scale": 50.0, "style": "radial", "reverse": true, + "opacityStops": [[1.0, 0.25], [0.0, 1.0]], "midpoints": [0.25], "offset": [0.125, -0.25], "dither": true, "align": false, + }}); + let r = s.execute("shape.edit", json!({"layer": id, "stroke": {"color": gradient}})).unwrap(); + let Some(Fill::Gradient { stops, angle, scale, style, reverse, opacity_stops, midpoints, offset, dither, align }) = shape(&s, id).stroke.map(|st| st.paint) else { + panic!("a gradient stroke") + }; + assert_eq!(stops, vec![(0.0, Color::rgba(0.25, 0.5, 0.75, 1.0)), (1.0, Color::rgba(1.0, 0.125, 0.0, 0.5))]); + assert_eq!((angle, scale, style, reverse), (30.0, 0.5, GradientStyle::Radial, true)); + assert_eq!(opacity_stops, vec![(0.0, 1.0), (1.0, 0.25)], "opacity stops are sorted"); + assert_eq!((midpoints, offset, dither, align), (vec![0.25], (0.125, -0.25), true, false)); + let g = &r["stroke"]["fill"]["gradient"]; + assert_eq!((g["style"].as_str(), g["midpoints"].clone(), g["align"].as_bool()), (Some("radial"), json!([0.25]), Some(false))); + // A partial gradient keeps the defaults it always had. + s.execute("shape.edit", json!({"layer": id, "stroke": {"color": {"gradient": {"stops": [[0, "#000000"], [1, "#ffffff"]]}}}})).unwrap(); + let Some(Fill::Gradient { opacity_stops, midpoints, offset, dither, align, .. }) = shape(&s, id).stroke.map(|st| st.paint) else { panic!("a gradient stroke") }; + assert_eq!((opacity_stops, midpoints, offset, dither, align), (Vec::new(), Vec::new(), (0.0, 0.0), false, true)); +} + #[test] fn complete_stroke_edits_preserve_paint_and_geometry_and_undo_at_every_depth() { for depth in [8, 16, 32] { diff --git a/crates/ui-egui/src/gradient_ui.rs b/crates/ui-egui/src/gradient_ui.rs index be35f66028..2ffcf0f1e7 100644 --- a/crates/ui-egui/src/gradient_ui.rs +++ b/crates/ui-egui/src/gradient_ui.rs @@ -446,7 +446,7 @@ fn line(painter: &egui::Painter, a: Pos2, b: Pos2) { painter.line_segment([a, b], Stroke::new(1.5, Color32::WHITE)); } -fn diamond(painter: &egui::Painter, c: Pos2, r: f32, fill: Color32, outline: Color32) { +pub(crate) fn diamond(painter: &egui::Painter, c: Pos2, r: f32, fill: Color32, outline: Color32) { let pts = vec![pos2(c.x, c.y - r), pos2(c.x + r, c.y), pos2(c.x, c.y + r), pos2(c.x - r, c.y)]; painter.add(egui::Shape::convex_polygon(pts, fill, Stroke::new(1.0, outline))); } @@ -508,7 +508,7 @@ pub fn draw_overlay(app: &PhotocraftApp, painter: &egui::Painter, xf: &ViewXform // ---------------------------------------------------------------- options bar /// A ramp of RGBA stops over a checkerboard in `r`. -fn paint_ramp(p: &egui::Painter, r: Rect, sample: impl Fn(f32) -> [f32; 4]) { +pub(crate) fn paint_ramp(p: &egui::Painter, r: Rect, sample: impl Fn(f32) -> [f32; 4]) { // The tessellator snaps the checker's rects to pixels but not the mesh: snap both alike, or a // half-pixel offset leaves a row of checker showing under the ramp (#4577). let r = r.round_to_pixels(p.pixels_per_point()); diff --git a/crates/ui-egui/src/shape_gradient_ui.rs b/crates/ui-egui/src/shape_gradient_ui.rs new file mode 100644 index 0000000000..d0556754ce --- /dev/null +++ b/crates/ui-egui/src/shape_gradient_ui.rs @@ -0,0 +1,470 @@ +//! The shape Fill / Stroke swatches' Gradient tab, as Photoshop's popover: the recently used +//! gradients and the preset library, a stops strip (click to add a stop, drag one to move it or +//! off the strip to delete it, drag a midpoint), the selected stop's colour, opacity and +//! location, and the gradient's style, angle, scale, reverse and Align with layer. Stop edits use +//! the Gradient Editor's grammar ([`apply_stop`]); the tab returns the edited gradient and the +//! swatch's caller applies it to the next shape or as one `shape.edit`. + +use egui::{Pos2, Rect, Sense, Stroke, StrokeKind, pos2, vec2}; +use photocraft_compose::gradient_fill as gf; +use photocraft_doc::{Fill, GradientStyle}; +use photocraft_engine::gradient_fill_cmds::apply_stop; +use photocraft_engine::presets::Group; +use photocraft_engine::presets::gradients::GradientPreset; +use serde_json::{Value, json}; + +use super::{picker_color, picker_rgba, rgba_of}; +use crate::theme::Tokens; + +/// Width of the tab's rows (the strip, the swatch grids). +const WIDTH: f32 = 228.0; +/// How many gradients the Recent row keeps. +const RECENT: usize = 8; + +/// What a swatch's Gradient tab offers: the recently used gradients, the preset library, and the +/// Gradient tool's current gradient (what a colour switches to), with the tool colours that +/// resolve their Foreground / Background stops. +pub(super) struct GradientChoices<'a> { + pub presets: &'a [Group], + pub current: &'a GradientPreset, + /// Newest first ([`GradientChoices::remember`]). + pub recent: &'a mut Vec, + pub fg: [f32; 4], + pub bg: [f32; 4], +} + +impl GradientChoices<'_> { + /// Photoshop's shape gradient default: the current gradient, linear at 90°, 100%. + pub(super) fn default_fill(&self) -> Fill { + let mut fill = Fill::gradient(Vec::new(), 90.0, 1.0, GradientStyle::Linear, false); + take_preset(&mut fill, self.current, self.fg, self.bg); + fill + } + + /// Puts `gradient`'s stops at the front of the Recent row; a gradient already there moves up. + pub(super) fn remember(&mut self, gradient: &Fill) { + let Fill::Gradient { .. } = gradient else { return }; + self.recent.retain(|f| !same_stops(f, gradient)); + self.recent.insert(0, gradient.clone()); + self.recent.truncate(RECENT); + } +} + +/// Whether two gradients have the same colour stops, opacity stops and midpoints. +fn same_stops(a: &Fill, b: &Fill) -> bool { + match (a, b) { + (Fill::Gradient { stops: s1, opacity_stops: o1, midpoints: m1, .. }, Fill::Gradient { stops: s2, opacity_stops: o2, midpoints: m2, .. }) => { + s1 == s2 && o1 == o2 && m1 == m2 + } + _ => false, + } +} + +/// `fill` takes `preset`'s colour and opacity stops (live colours resolved now), as a Gradient +/// Fill layer made from it holds them; its old midpoints belonged to the old stops. +pub(super) fn take_preset(fill: &mut Fill, preset: &GradientPreset, fg: [f32; 4], bg: [f32; 4]) { + if let Fill::Gradient { stops, opacity_stops, midpoints, .. } = fill { + (*stops, *opacity_stops) = preset.fill_stops(fg, bg); + midpoints.clear(); + } +} + +/// `fill` takes `from`'s colour stops, opacity stops and midpoints (a Recent pick). +fn take_stops(fill: &mut Fill, from: &Fill) { + if let (Fill::Gradient { stops, opacity_stops, midpoints, .. }, Fill::Gradient { stops: s, opacity_stops: o, midpoints: m, .. }) = (fill, from) { + (*stops, *opacity_stops, *midpoints) = (s.clone(), o.clone(), m.clone()); + } +} + +/// The Gradient tab of the swatch `id`. Returns the edited gradient. +pub(super) fn gradient_tab(ui: &mut egui::Ui, fill: &Fill, choices: &GradientChoices, id: egui::Id) -> Option { + let Fill::Gradient { angle, scale, style, reverse, align, .. } = fill else { return None }; + let t = Tokens::get(ui.ctx()); + let mut out: Option = None; + egui::ScrollArea::vertical().id_salt(id.with("gradient-presets")).max_height(120.0).show(ui, |ui| { + ui.set_width(WIDTH); + let group_label = |ui: &mut egui::Ui, s: &str| ui.label(egui::RichText::new(s).color(t.text_dim).size(11.0)); + if !choices.recent.is_empty() { + group_label(ui, tl!("Recent")); + ui.horizontal_wrapped(|ui| { + ui.spacing_mut().item_spacing = vec2(3.0, 3.0); + for (i, recent) in choices.recent.iter().enumerate() { + let (r, resp) = ui.allocate_exact_size(vec2(32.0, 18.0), Sense::click()); + paint_fill_ramp(ui, r, recent, resp.hovered()); + let name = format!("{} {}", tl!("Recent"), i + 1); + resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, &name)); + if resp.clicked() { + take_stops(edited(&mut out, fill), recent); + } + } + }); + } + for group in choices.presets { + // Group and preset names are the library's data, shown as they are. + group_label(ui, &group.name); + ui.horizontal_wrapped(|ui| { + ui.spacing_mut().item_spacing = vec2(3.0, 3.0); + for preset in &group.items { + let (r, resp) = ui.allocate_exact_size(vec2(32.0, 18.0), Sense::click()); + crate::preset_panels::paint_gradient(ui, r, &preset.resolve(choices.fg, choices.bg)); + let border = if resp.hovered() { t.text_dim } else { t.field_border }; + ui.painter().rect_stroke(r, 0.0, Stroke::new(1.0, border), StrokeKind::Outside); + resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, &preset.name)); + if resp.on_hover_text(&preset.name).clicked() { + take_preset(edited(&mut out, fill), preset, choices.fg, choices.bg); + } + } + }); + } + }); + ui.add_space(6.0); + if let Some(f) = stops_strip(ui, out.as_ref().unwrap_or(fill), id, choices.fg, choices.bg) { + out = Some(f); + } + if let Some(f) = stop_fields(ui, out.as_ref().unwrap_or(fill), id, choices.fg, choices.bg) { + out = Some(f); + } + ui.add_space(4.0); + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing.x = 2.0; + for (s, icon, tip) in [ + (GradientStyle::Linear, "gradient", tl!("Linear Gradient")), + (GradientStyle::Radial, "circle", tl!("Radial Gradient")), + (GradientStyle::Angle, "rotate-cw", tl!("Angle Gradient")), + (GradientStyle::Reflected, "arrow-left-right", tl!("Reflected Gradient")), + (GradientStyle::Diamond, "diamond", tl!("Diamond Gradient")), + ] { + if crate::icons::button(ui, icon, 22.0, *style == s, tip).clicked() + && *style != s + && let Fill::Gradient { style, .. } = edited(&mut out, fill) + { + *style = s; + } + } + }); + let label = |ui: &mut egui::Ui, s: &str| ui.label(egui::RichText::new(s).color(t.text_dim).size(12.0)); + ui.horizontal(|ui| { + label(ui, tl!("Angle")); + let mut a = *angle; + if crate::widgets::value_field(ui, &mut a, -180.0..=180.0, "°", 52.0).changed() + && let Fill::Gradient { angle, .. } = edited(&mut out, fill) + { + *angle = a; + } + label(ui, tl!("Scale")); + let mut sc = *scale * 100.0; + if crate::widgets::value_field(ui, &mut sc, 10.0..=150.0, "%", 52.0).changed() + && let Fill::Gradient { scale, .. } = edited(&mut out, fill) + { + *scale = sc / 100.0; + } + }); + ui.horizontal(|ui| { + let mut rev = *reverse; + if crate::widgets::checkbox(ui, &mut rev, tl!("Reverse")).changed() + && let Fill::Gradient { reverse, .. } = edited(&mut out, fill) + { + *reverse = rev; + } + let mut al = *align; + if crate::widgets::checkbox(ui, &mut al, tl!("Align with layer")).changed() + && let Fill::Gradient { align, .. } = edited(&mut out, fill) + { + *align = al; + } + }); + out +} + +/// The gradient being edited this frame: `fill` until a control changes it. +fn edited<'a>(out: &'a mut Option, fill: &Fill) -> &'a mut Fill { + out.get_or_insert_with(|| fill.clone()) +} + +/// A gradient's ramp in `r` (un-reversed, as the stops strip shows it), outlined. +fn paint_fill_ramp(ui: &egui::Ui, r: Rect, fill: &Fill, hovered: bool) { + let t = Tokens::get(ui.ctx()); + if let Some(ramp) = gf::Ramp::new(&unreversed(fill)) { + crate::gradient_ui::paint_ramp(ui.painter(), r, |u| ramp.sample(u)); + } + let border = if hovered { t.text_dim } else { t.field_border }; + ui.painter().rect_stroke(r, 0.0, Stroke::new(1.0, border), StrokeKind::Outside); +} + +fn unreversed(fill: &Fill) -> Fill { + let mut f = fill.clone(); + if let Fill::Gradient { reverse, .. } = &mut f { + *reverse = false; + } + f +} + +/// A marker of the stops strip. +#[derive(Clone, Copy, Debug, PartialEq)] +enum Marker { + Color(usize), + Opacity(usize), + /// The midpoint of the segment after colour stop `i`. + Mid(usize), +} + +/// A drag in progress: the marker and the gradient as it was when the drag began. Each frame +/// re-applies the move to that gradient, so a stop dragged past another stays the one dragged. +#[derive(Clone)] +struct Drag { + marker: Marker, + start: Fill, +} + +/// Colour stops, opacity stops and midpoints. +type Stops = (Vec<(f32, photocraft_doc::Color)>, Vec<(f32, f32)>, Vec); + +/// The colour stops (sorted), opacity stops (sorted; two opaque ones when the gradient has none, +/// as [`apply_stop`] counts them) and midpoints of `fill`. +fn sorted_stops(fill: &Fill) -> Stops { + let Fill::Gradient { stops, opacity_stops, midpoints, .. } = fill else { return (Vec::new(), Vec::new(), Vec::new()) }; + let mut cs = stops.clone(); + cs.sort_by(|a, b| a.0.total_cmp(&b.0)); + let mut os = if opacity_stops.is_empty() { vec![(0.0, 1.0), (1.0, 1.0)] } else { opacity_stops.clone() }; + os.sort_by(|a, b| a.0.total_cmp(&b.0)); + (cs, os, midpoints.clone()) +} + +/// Where a stop moved to `location` lands once the stops are sorted again: the selection follows it. +fn index_after_move(locations: &[f32], moved: usize, location: f32) -> usize { + locations.iter().enumerate().filter(|(i, l)| *i != moved && (**l < location || (**l == location && *i < moved))).count() +} + +fn apply(fill: &Fill, edit: &Value, fg: [f32; 4], bg: [f32; 4]) -> Option { + apply_stop(fill, edit, fg, bg).ok() +} + +/// The stops strip: the ramp with opacity stops above and colour stops below (Photoshop's). +fn stops_strip(ui: &mut egui::Ui, fill: &Fill, id: egui::Id, fg: [f32; 4], bg: [f32; 4]) -> Option { + let t = Tokens::get(ui.ctx()); + let (outer, resp) = ui.allocate_exact_size(vec2(WIDTH, 58.0), Sense::click_and_drag()); + resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), tl!("Gradient stops"))); + let top = outer.top() + 16.0; + let bar = Rect::from_min_max(pos2(outer.left() + 8.0, top), pos2(outer.right() - 8.0, top + 24.0)); + let x_of = |loc: f32| bar.left() + loc.clamp(0.0, 1.0) * bar.width(); + let loc_of = |x: f32| ((x - bar.left()) / bar.width().max(1.0)).clamp(0.0, 1.0); + if let Some(ramp) = gf::Ramp::new(&unreversed(fill)) { + crate::gradient_ui::paint_ramp(ui.painter(), bar, |u| ramp.sample(u)); + } + ui.painter().rect_stroke(bar, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Outside); + let (cs, os, mids) = sorted_stops(fill); + let (drag_key, selection_key) = (id.with("stops-drag"), id.with("stops-selected")); + let drag: Option = ui.data(|d| d.get_temp(drag_key)); + let selected: Option = drag.as_ref().map(|d| d.marker).or_else(|| ui.data(|d| d.get_temp(selection_key))); + let p = ui.painter(); + let outline = |sel: bool| if sel { t.accent } else { t.text_dim }; + for (i, (loc, c)) in cs.iter().enumerate() { + let x = x_of(*loc); + let sel = selected == Some(Marker::Color(i)); + let body = Rect::from_center_size(pos2(x, bar.bottom() + 10.0), vec2(10.0, 10.0)); + p.add(egui::Shape::convex_polygon(vec![pos2(x, bar.bottom() + 1.0), pos2(x + 5.0, body.top()), pos2(x - 5.0, body.top())], outline(sel), Stroke::NONE)); + let [r, g, b, _] = rgba_of(c); + p.rect_filled(body, 1.0, super::rgba32([r, g, b, 1.0])); + p.rect_stroke(body, 1.0, Stroke::new(1.0, outline(sel)), StrokeKind::Outside); + } + let mid_x = |i: usize| -> Option { + let (a, b) = (cs.get(i)?.0, cs.get(i + 1)?.0); + (b - a > 1e-3).then(|| x_of(a + (b - a) * mids.get(i).copied().unwrap_or(0.5))) + }; + for i in 0..cs.len().saturating_sub(1) { + if let Some(x) = mid_x(i) { + let sel = selected == Some(Marker::Mid(i)); + crate::gradient_ui::diamond(p, pos2(x, bar.bottom() + 6.0), 3.0, if sel { t.accent } else { t.text_faint }, t.text_faint); + } + } + for (i, (loc, a)) in os.iter().enumerate() { + let x = x_of(*loc); + let sel = selected == Some(Marker::Opacity(i)); + let body = Rect::from_center_size(pos2(x, bar.top() - 10.0), vec2(10.0, 10.0)); + p.add(egui::Shape::convex_polygon(vec![pos2(x, bar.top() - 1.0), pos2(x + 5.0, body.bottom()), pos2(x - 5.0, body.bottom())], outline(sel), Stroke::NONE)); + p.rect_filled(body, 1.0, egui::Color32::from_gray((a.clamp(0.0, 1.0) * 255.0) as u8)); + p.rect_stroke(body, 1.0, Stroke::new(1.0, outline(sel)), StrokeKind::Outside); + } + let hit = |pos: Pos2| -> Option { + if pos.y > bar.bottom() { + if pos.y >= bar.bottom() + 3.0 + && let Some(i) = cs.iter().position(|(l, _)| (x_of(*l) - pos.x).abs() <= 6.0) + { + return Some(Marker::Color(i)); + } + return (0..cs.len().saturating_sub(1)).find(|i| mid_x(*i).is_some_and(|x| (x - pos.x).abs() <= 4.0)).map(Marker::Mid); + } + if pos.y < bar.top() { + return os.iter().position(|(l, _)| (x_of(*l) - pos.x).abs() <= 6.0).map(Marker::Opacity); + } + None + }; + let mut out = None; + if resp.drag_started() + && let Some(pos) = ui.input(|i| i.pointer.press_origin()) + && let Some(marker) = hit(pos) + { + ui.data_mut(|d| { + d.insert_temp(drag_key, Drag { marker, start: fill.clone() }); + d.insert_temp(selection_key, marker); + }); + } + if let Some(drag) = ui.data(|d| d.get_temp::(drag_key)) { + let (start_cs, start_os, _) = sorted_stops(&drag.start); + let pos = resp.interact_pointer_pos(); + if let Some(pos) = pos { + // Dragged well off the strip, a stop is deleted (while at least two remain), as in Photoshop. + let off = pos.y > bar.bottom() + 28.0 || pos.y < bar.top() - 26.0; + let loc = loc_of(pos.x); + let edit = match drag.marker { + Marker::Color(i) if off && start_cs.len() > 2 => json!({"action": "delete", "index": i}), + Marker::Color(i) => json!({"action": "move", "index": i, "location": loc}), + Marker::Opacity(i) if off && start_os.len() > 2 => json!({"action": "delete", "kind": "opacity", "index": i}), + Marker::Opacity(i) => json!({"action": "move", "kind": "opacity", "index": i, "location": loc}), + Marker::Mid(i) => { + let (a, b) = (start_cs.get(i).map_or(0.0, |s| s.0), start_cs.get(i + 1).map_or(1.0, |s| s.0)); + json!({"action": "midpoint", "index": i, "location": ((loc - a) / (b - a).max(1e-4)).clamp(0.05, 0.95)}) + } + }; + out = apply(&drag.start, &edit, fg, bg); + if resp.drag_stopped() { + let moved = edit.get("location").and_then(Value::as_f64).map(|l| l as f32); + let selection = match (drag.marker, edit.get("action").and_then(Value::as_str), moved) { + (Marker::Color(i), Some("move"), Some(l)) => Some(Marker::Color(index_after_move(&start_cs.iter().map(|s| s.0).collect::>(), i, l))), + (Marker::Opacity(i), Some("move"), Some(l)) => Some(Marker::Opacity(index_after_move(&start_os.iter().map(|s| s.0).collect::>(), i, l))), + (Marker::Mid(i), ..) => Some(Marker::Mid(i)), + _ => None, + }; + ui.data_mut(|d| match selection { + Some(m) => { + d.insert_temp(selection_key, m); + } + None => d.remove::(selection_key), + }); + } + } + if resp.drag_stopped() || pos.is_none() { + ui.data_mut(|d| d.remove::(drag_key)); + } + return out; + } + if resp.clicked() + && let Some(pos) = resp.interact_pointer_pos() + { + if let Some(marker) = hit(pos) { + ui.data_mut(|d| d.insert_temp(selection_key, marker)); + return None; + } + // A click on the ramp adds a stop there: an opacity stop above its middle, a colour stop below. + let loc = loc_of(pos.x); + let opacity = pos.y < bar.center().y; + let (edit, marker) = if opacity { + (json!({"action": "add", "kind": "opacity", "location": loc}), Marker::Opacity(os.iter().filter(|s| s.0 <= loc).count())) + } else { + (json!({"action": "add", "location": loc}), Marker::Color(cs.iter().filter(|s| s.0 <= loc).count())) + }; + out = apply(fill, &edit, fg, bg); + if out.is_some() { + ui.data_mut(|d| d.insert_temp(selection_key, marker)); + } + } + out +} + +/// The selected stop's fields under the strip: a colour stop's colour (an inline picker opened +/// from its swatch), an opacity stop's opacity, a midpoint's position; Location and Delete. +fn stop_fields(ui: &mut egui::Ui, fill: &Fill, id: egui::Id, fg: [f32; 4], bg: [f32; 4]) -> Option { + let t = Tokens::get(ui.ctx()); + let selection_key = id.with("stops-selected"); + let selected: Marker = ui.data(|d| d.get_temp(selection_key)).unwrap_or(Marker::Color(0)); + let (cs, os, mids) = sorted_stops(fill); + let label = |ui: &mut egui::Ui, s: &str| ui.label(egui::RichText::new(s).color(t.text_dim).size(12.0)); + let mut edit: Option = None; + let mut reselect: Option = None; + let (locations, index): (Vec, usize) = match selected { + Marker::Color(i) => (cs.iter().map(|s| s.0).collect(), i), + Marker::Opacity(i) => (os.iter().map(|s| s.0).collect(), i), + Marker::Mid(i) => (Vec::new(), i), + }; + let picker_key = id.with("stop-picker-open"); + let mut picker_open = ui.data(|d| d.get_temp::(picker_key)).unwrap_or(false); + ui.horizontal(|ui| match selected { + Marker::Color(i) => { + let Some((_, c)) = cs.get(i) else { return }; + label(ui, tl!("Color")); + let (r, resp) = ui.allocate_exact_size(vec2(40.0, 20.0), Sense::click()); + let [cr, cg, cb, _] = rgba_of(c); + ui.painter().rect_filled(r.shrink(1.0), t.radius_sm, super::rgba32([cr, cg, cb, 1.0])); + ui.painter().rect_stroke(r, t.radius_sm, Stroke::new(1.0, if picker_open { t.accent } else { t.field_border }), StrokeKind::Inside); + resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::ColorButton, true, tl!("Color"))); + if resp.on_hover_text(tl!("Color")).clicked() { + picker_open = !picker_open; + } + } + Marker::Opacity(i) => { + let Some((_, a)) = os.get(i) else { return }; + label(ui, tl!("Opacity")); + let mut v = a * 100.0; + if crate::widgets::value_field(ui, &mut v, 0.0..=100.0, "%", 52.0).changed() { + edit = Some(json!({"action": "opacity", "kind": "opacity", "index": i, "opacity": v})); + } + } + Marker::Mid(i) => { + if cs.get(i.saturating_add(1)).is_none() { + return; + } + label(ui, tl!("Location")); + let mut v = mids.get(i).copied().unwrap_or(0.5) * 100.0; + if crate::widgets::value_field(ui, &mut v, 5.0..=95.0, "%", 52.0).changed() { + edit = Some(json!({"action": "midpoint", "index": i, "location": v / 100.0})); + } + } + }); + if let Some(loc) = locations.get(index).copied() { + let kind = if matches!(selected, Marker::Opacity(_)) { "opacity" } else { "color" }; + ui.horizontal(|ui| { + label(ui, tl!("Location")); + let mut v = loc * 100.0; + if crate::widgets::value_field(ui, &mut v, 0.0..=100.0, "%", 52.0).changed() { + let to = v / 100.0; + edit = Some(json!({"action": "move", "kind": kind, "index": index, "location": to})); + reselect = Some(match selected { + Marker::Opacity(_) => Marker::Opacity(index_after_move(&locations, index, to)), + _ => Marker::Color(index_after_move(&locations, index, to)), + }); + } + // A gradient keeps at least two stops of each kind. + if locations.len() > 2 && crate::widgets::secondary_button(ui, tl!("Delete"), 0.0).clicked() { + edit = Some(json!({"action": "delete", "kind": kind, "index": index})); + reselect = Some(match selected { + Marker::Opacity(_) => Marker::Opacity(index.saturating_sub(1)), + _ => Marker::Color(index.saturating_sub(1)), + }); + } + }); + } + if let (Marker::Color(i), true) = (selected, picker_open) + && let Some((_, c)) = cs.get(i) + { + // The stop's colour keeps its own alpha; transparency belongs to the opacity stops. + let rgba = rgba_of(c); + let cache = id.with(("stop-hsva", i)); + let mut hsva = ui.data(|d| d.get_temp::<([f32; 4], egui::ecolor::Hsva)>(cache)).filter(|(previous, _)| *previous == rgba).map_or_else(|| picker_color(rgba), |(_, h)| h); + if egui::color_picker::color_picker_hsva_2d(ui, &mut hsva, egui::color_picker::Alpha::Opaque) { + let [r, g, b, _] = picker_rgba(hsva); + if [r, g, b].iter().zip(rgba).any(|(a, b)| (a - b).abs() > 0.000001) { + let color = [r, g, b, rgba[3]]; + edit = Some(json!({"action": "color", "index": i, "color": color})); + ui.data_mut(|d| d.insert_temp(cache, (color, hsva))); + } + } else { + ui.data_mut(|d| d.insert_temp(cache, (rgba, hsva))); + } + } + ui.data_mut(|d| d.insert_temp(picker_key, picker_open)); + let out = apply(fill, &edit?, fg, bg)?; + if let Some(m) = reselect { + ui.data_mut(|d| d.insert_temp(selection_key, m)); + } + Some(out) +} diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index d464cb3cc8..4ecf504d72 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -586,6 +586,10 @@ pub struct ToolOptions { pub stroke_width: f32, #[serde(default)] pub shape_stroke: crate::shape_stroke_ui::StrokeOptions, + /// Shape tools: the gradient the next shape's fill / stroke takes (the swatches' Gradient + /// tab) instead of the foreground / background colour; `None` = the colour. + pub shape_fill_gradient: Option, + pub shape_stroke_gradient: Option, pub corner_radius: f32, pub polygon_sides: u32, pub line_weight: f32, @@ -812,6 +816,8 @@ impl Default for ToolOptions { shape_fill: true, stroke_width: 0.0, shape_stroke: Default::default(), + shape_fill_gradient: None, + shape_stroke_gradient: None, corner_radius: 0.0, polygon_sides: 5, line_weight: 3.0, @@ -1254,6 +1260,10 @@ pub struct UiState { pub selection_mode: u8, #[serde(default)] pub tool_options: ToolOptions, + /// The shape Fill / Stroke swatches' recently used gradients, newest first (the Gradient + /// tab's Recent row). + #[serde(default)] + pub recent_gradients: Vec, /// In-progress polygonal lasso vertices (document coordinates). #[serde(default)] pub polygon: Vec<[f64; 2]>, @@ -1377,6 +1387,7 @@ impl Default for UiState { brushes_panel: Default::default(), selection_mode: 0, tool_options: ToolOptions::default(), + recent_gradients: Vec::new(), polygon: Vec::new(), polygon_mode: String::new(), polygon_doc: None, diff --git a/crates/ui-egui/src/tool_reset.rs b/crates/ui-egui/src/tool_reset.rs index 27e9622ab3..d567d64bcc 100644 --- a/crates/ui-egui/src/tool_reset.rs +++ b/crates/ui-egui/src/tool_reset.rs @@ -167,7 +167,7 @@ pub fn reset_options(o: &mut ToolOptions, tool: Tool) { Tool::CurvaturePen => reset!(vector_mode), Tool::FreeformPen => reset!(vector_mode, curve_fit), Tool::Rectangle | Tool::EllipseShape | Tool::Triangle | Tool::Polygon | Tool::Line | Tool::CustomShape => { - reset!(vector_mode, shape_fill, stroke_width, shape_stroke, corner_radius, polygon_sides, line_weight) + reset!(vector_mode, shape_fill, stroke_width, shape_stroke, shape_fill_gradient, shape_stroke_gradient, corner_radius, polygon_sides, line_weight) } Tool::ColorSampler | Tool::Ruler diff --git a/crates/ui-egui/src/vector_paint_tests.rs b/crates/ui-egui/src/vector_paint_tests.rs index c62277fb1e..8cb1c20c9d 100644 --- a/crates/ui-egui/src/vector_paint_tests.rs +++ b/crates/ui-egui/src/vector_paint_tests.rs @@ -316,3 +316,222 @@ fn options_bar_fill_swatch_recolours_the_shape_just_drawn() { h.state_mut().run("edit.undo", json!({})).unwrap(); assert_eq!(shape(h.state()).fill, original.fill); } + +fn test_gradient() -> photocraft_doc::Fill { + photocraft_doc::Fill::Gradient { + stops: vec![(0.0, photocraft_doc::Color::rgba(0.123456, 0.5, 0.75, 1.0)), (1.0, photocraft_doc::Color::rgba(0.9, 0.2, 0.1, 0.6))], + angle: 30.0, + scale: 0.5, + style: photocraft_doc::GradientStyle::Radial, + reverse: true, + opacity_stops: vec![(0.0, 1.0), (1.0, 0.25)], + midpoints: vec![0.3], + offset: (0.125, -0.25), + dither: true, + align: false, + } +} + +/// A gradient picked for the next shape's stroke and fill (the swatches' Gradient tab) reaches +/// the drag preview and the committed shape exactly, every gradient field kept; a colour picked +/// afterwards replaces it. +#[test] +fn tool_gradient_paints_reach_the_preview_and_the_next_shape() { + for (mode, depth) in [("rgb", 8), ("rgb", 32), ("gray", 16)] { + let mut app = app(mode, depth); + set_tool_paint(&mut app, true, PaintChange::Gradient(test_gradient())).unwrap(); + set_tool_paint(&mut app, false, PaintChange::Gradient(test_gradient())).unwrap(); + assert_eq!(app.ui.tool_options.stroke_width, 3.0, "a gradient enables the stroke"); + assert!(app.ui.tool_options.shape_fill); + let preview = shape_preview(&app, Tool::Rectangle, [20.0, 20.0], [100.0, 80.0], Modifiers::NONE).unwrap(); + finish_shape(&mut app, Tool::Rectangle, [20.0, 20.0], [100.0, 80.0], Modifiers::NONE); + let committed = shape(&app).clone(); + assert_eq!(preview.fill, committed.fill); + assert_eq!(preview.stroke, committed.stroke); + assert_eq!(committed.stroke.as_ref().unwrap().paint, test_gradient(), "{mode}/{depth}"); + assert_eq!(committed.fill, Some(test_gradient())); + let doc = &app.session.active().unwrap().doc; + let rendered = photocraft_vector::render_shape(&preview, doc.pixel_format(), doc.bounds()); + assert_eq!(committed.cache.as_ref().unwrap(), &rendered, "{mode}/{depth}"); + set_tool_paint(&mut app, true, PaintChange::Color([0.0, 1.0, 0.0, 1.0])).unwrap(); + assert!(app.ui.tool_options.shape_stroke_gradient.is_none()); + finish_shape(&mut app, Tool::Rectangle, [20.0, 20.0], [100.0, 80.0], Modifiers::NONE); + assert_eq!(shape(&app).stroke.as_ref().unwrap().paint, solid_paint([0.0, 1.0, 0.0, 1.0])); + assert_eq!(shape(&app).fill, Some(test_gradient()), "the fill keeps its gradient"); + } +} + +/// Options bar › Stroke › Gradient: the Rectangle tool's next stroke takes the current gradient, +/// a preset's colours and a style, without editing the document. +#[test] +fn stroke_swatch_gradient_tab_sets_the_next_shapes_stroke() { + let mut h = harness(app("rgb", 8), false); + h.get_by_label("Stroke color").click(); + h.run_steps(3); + h.get_by_label("Gradient").click(); + h.run_steps(3); + let stroke_gradient = |h: &Harness<'_, PhotocraftApp>| match h.state().ui.tool_options.shape_stroke_gradient.clone() { + Some(photocraft_doc::Fill::Gradient { stops, style, angle, .. }) => (stops, style, angle), + other => panic!("a stroke gradient, not {other:?}"), + }; + let (_, style, angle) = stroke_gradient(&h); + assert_eq!((style, angle), (photocraft_doc::GradientStyle::Linear, 90.0)); + assert_eq!(h.state().ui.tool_options.stroke_width, 3.0, "choosing a gradient enables the stroke"); + h.get_by_label("Blue 01").click(); + h.run_steps(2); + let presets = h.state().session.presets.gradients.clone(); + let blue = presets.iter().flat_map(|g| &g.items).find(|p| p.name == "Blue 01").unwrap(); + let (fg, bg) = (h.state().session.tools.foreground, h.state().session.tools.background); + let blue_stops = blue.fill_stops(fg, bg).0; + assert_eq!(stroke_gradient(&h).0, blue_stops); + h.get_by_label("Radial Gradient").click(); + h.run_steps(2); + let (stops, style, _) = stroke_gradient(&h); + assert_eq!((stops, style), (blue_stops, photocraft_doc::GradientStyle::Radial), "the style keeps the colours"); + assert_eq!(h.state().session.active().unwrap().history.past_len(), 0, "tool defaults do not edit the document"); + h.get_by_label("Solid").click(); + h.run_steps(2); + assert!(h.state().ui.tool_options.shape_stroke_gradient.is_none(), "Solid goes back to the colour"); +} + +/// Properties › Stroke › Gradient gives the selected shape a gradient stroke in one undoable +/// step, keeping its width; a style change keeps its colours. +#[test] +fn properties_stroke_swatch_gives_the_selected_shape_a_gradient_stroke() { + let mut app = app("rgb", 16); + app.run("shape.create", json!({"rect": [20, 20, 60, 40], "stroke": {"width": 4, "color": [1.0, 0.0, 0.0, 1.0]}})).unwrap(); + let history = app.session.active().unwrap().history.past_len(); + let mut h = harness(app, true); + h.get_by_label("Set shape stroke type").click(); + h.run_steps(3); + h.get_by_label("Gradient").click(); + h.run_steps(3); + let stroke = shape(h.state()).stroke.clone().unwrap(); + let photocraft_doc::Fill::Gradient { stops, .. } = &stroke.paint else { panic!("a gradient stroke, not {:?}", stroke.paint) }; + assert_eq!(stroke.width, 4.0); + assert_eq!(h.state().session.active().unwrap().history.past_len(), history + 1); + h.get_by_label("Reflected Gradient").click(); + h.run_steps(3); + let photocraft_doc::Fill::Gradient { stops: after, style, .. } = shape(h.state()).stroke.clone().unwrap().paint else { panic!("still a gradient stroke") }; + assert_eq!((&after, style), (stops, photocraft_doc::GradientStyle::Reflected)); + while h.state().session.active().unwrap().history.past_len() > history { + h.state_mut().run("edit.undo", json!({})).unwrap(); + } + assert_eq!(shape(h.state()).stroke.as_ref().unwrap().paint, solid_paint([1.0, 0.0, 0.0, 1.0])); +} + +fn tool_stroke_gradient(h: &Harness<'_, PhotocraftApp>) -> photocraft_doc::Fill { + h.state().ui.tool_options.shape_stroke_gradient.clone().expect("a stroke gradient") +} + +fn gradient_stops(f: &photocraft_doc::Fill) -> photocraft_engine::presets::gradients::FillStops { + match f { + photocraft_doc::Fill::Gradient { stops, opacity_stops, .. } => (stops.clone(), opacity_stops.clone()), + other => panic!("a gradient, not {other:?}"), + } +} + +/// Opens Options bar › Stroke › Gradient and returns the stops strip's rect. +fn open_stroke_gradient(h: &mut Harness<'_, PhotocraftApp>) -> Rect { + h.get_by_label("Stroke color").click(); + h.run_steps(3); + if h.state().ui.tool_options.shape_stroke_gradient.is_none() || h.state().ui.tool_options.stroke_width <= 0.0 { + h.get_by_label("Gradient").click(); + h.run_steps(3); + } + h.get_by_label("Gradient stops").rect() +} + +fn click(h: &mut Harness<'_, PhotocraftApp>, pos: Pos2) { + h.hover_at(pos); + h.step(); + pointer(h, pos, true); + pointer(h, pos, false); + h.run_steps(2); +} + +/// The Gradient tab's strip edits the stops as Photoshop's popover does: a click below the ramp +/// adds a colour stop, above it an opacity stop; Delete removes the selected one; dragging a stop +/// moves it; the selected colour stop's swatch opens an inline picker that recolours only it. +#[test] +fn gradient_tab_strip_adds_moves_recolours_and_deletes_stops() { + let mut h = harness(app("rgb", 16), false); + let strip = open_stroke_gradient(&mut h); + let (bar_left, bar_right, bar_top, bar_bottom) = (strip.left() + 8.0, strip.right() - 8.0, strip.top() + 16.0, strip.top() + 40.0); + let x_at = |loc: f32| bar_left + (bar_right - bar_left) * loc; + let (stops, opacity) = gradient_stops(&tool_stroke_gradient(&h)); + assert_eq!((stops.len(), opacity.len()), (2, 0)); + // A colour stop added in the middle takes the colour the gradient has there. + click(&mut h, pos2(x_at(0.5), bar_bottom - 4.0)); + let (stops, _) = gradient_stops(&tool_stroke_gradient(&h)); + assert_eq!(stops.len(), 3, "{stops:?}"); + assert!(stops.iter().any(|(l, _)| (l - 0.5).abs() < 0.02), "{stops:?}"); + // It is selected: Delete removes it again. + h.get_by_label("Delete").click(); + h.run_steps(2); + assert_eq!(gradient_stops(&tool_stroke_gradient(&h)).0.len(), 2); + // An opacity stop above the ramp (the two implicit opaque ends become real stops). + click(&mut h, pos2(x_at(0.25), bar_top + 4.0)); + let (_, opacity) = gradient_stops(&tool_stroke_gradient(&h)); + assert_eq!(opacity.len(), 3, "{opacity:?}"); + // Drag the first colour stop to 30 %. + let from = pos2(x_at(0.0), bar_bottom + 10.0); + let to = pos2(x_at(0.3), bar_bottom + 10.0); + h.hover_at(from); + h.step(); + pointer(&mut h, from, true); + for k in 1..=4 { + h.event(Event::PointerMoved(from + (to - from) * (k as f32 / 4.0))); + h.step(); + } + pointer(&mut h, to, false); + h.run_steps(2); + let (stops, _) = gradient_stops(&tool_stroke_gradient(&h)); + let mut locations: Vec = stops.iter().map(|s| s.0).collect(); + locations.sort_by(f32::total_cmp); + assert!((locations[0] - 0.3).abs() < 0.03 && locations[1] == 1.0, "{locations:?}"); + // The selected stop's colour: its swatch opens the picker; a drag in it recolours that stop. + let before = gradient_stops(&tool_stroke_gradient(&h)).0; + let swatch = h.get(egui_kittest::kittest::by().label("Color").role(egui::accesskit::Role::ColorWell)).rect(); + click(&mut h, swatch.center()); + h.run_steps(2); + // The inline picker opens under the stop's rows (readouts, preview, then the saturation / + // value field); a click in that field. + let field = pos2(swatch.left() + 30.0, h.get_by_label("Location").rect().bottom() + 120.0); + click(&mut h, field); + let after = gradient_stops(&tool_stroke_gradient(&h)).0; + assert_eq!(after.len(), before.len()); + let changed: Vec<_> = before.iter().zip(&after).filter(|(a, b)| a != b).collect(); + assert_eq!(changed.len(), 1, "only the selected stop changes colour: {before:?} → {after:?}"); + assert_eq!(h.state().session.active().unwrap().history.past_len(), 0, "tool defaults do not edit the document"); +} + +/// Align with layer is a checkbox of the tab, and the gradient a popup closes on is offered again +/// in its Recent row. +#[test] +fn gradient_tab_align_with_layer_and_recent_row() { + let mut h = harness(app("rgb", 8), false); + open_stroke_gradient(&mut h); + let align = |h: &Harness<'_, PhotocraftApp>| matches!(tool_stroke_gradient(h), photocraft_doc::Fill::Gradient { align: true, .. }); + assert!(align(&h)); + h.get_by_label("Align with layer").click(); + h.run_steps(2); + assert!(!align(&h)); + h.get_by_label("Blue 01").click(); + h.run_steps(2); + let blue = gradient_stops(&tool_stroke_gradient(&h)); + assert!(h.query_by_label("Recent 1").is_none(), "nothing is recent yet"); + h.key_press(Key::Escape); + h.run_steps(3); + assert_eq!(h.state().ui.recent_gradients.len(), 1, "closing the popup remembers its gradient"); + open_stroke_gradient(&mut h); + h.get_by_label("Black, White").click(); + h.run_steps(2); + assert_ne!(gradient_stops(&tool_stroke_gradient(&h)), blue); + h.get_by_label("Recent 1").click(); + h.run_steps(2); + assert_eq!(gradient_stops(&tool_stroke_gradient(&h)), blue, "a Recent pick restores its stops"); + h.key_press(Key::Escape); + h.run_steps(3); + assert_eq!(h.state().ui.recent_gradients.len(), 1, "the same stops are remembered once"); +} diff --git a/crates/ui-egui/src/vector_ui.rs b/crates/ui-egui/src/vector_ui.rs index 8b5e914af2..019b301834 100644 --- a/crates/ui-egui/src/vector_ui.rs +++ b/crates/ui-egui/src/vector_ui.rs @@ -63,10 +63,42 @@ fn stroke_param(app: &PhotocraftApp) -> Value { } let mut p = o.shape_stroke.params(); p["width"] = json!(o.stroke_width); - p["color"] = json!(app.session.tools.background); + p["color"] = tool_paint_param(app, true); p } +/// The paint the next shape's fill (`stroke` false) or stroke takes: the options bar's gradient, +/// else the foreground / background colour. +fn tool_paint(app: &PhotocraftApp, stroke: bool) -> photocraft_doc::Fill { + let (gradient, color) = tool_paint_source(app, stroke); + gradient.clone().unwrap_or_else(|| solid_paint(color)) +} + +/// [`tool_paint`] as `shape.create` takes it. +fn tool_paint_param(app: &PhotocraftApp, stroke: bool) -> Value { + let (gradient, color) = tool_paint_source(app, stroke); + gradient.as_ref().map_or_else(|| json!(color), paint_param) +} + +fn tool_paint_source(app: &PhotocraftApp, stroke: bool) -> (&Option, [f32; 4]) { + let o = &app.ui.tool_options; + if stroke { (&o.shape_stroke_gradient, app.session.tools.background) } else { (&o.shape_fill_gradient, app.session.tools.foreground) } +} + +/// A solid or gradient paint exactly as `shape.create` / `shape.edit` take it: float RGBA and +/// every gradient field, so a swatch edit (angle, style…) keeps the rest of the gradient. The +/// swatches never hand it a pattern (they don't offer one). +fn paint_param(f: &photocraft_doc::Fill) -> Value { + match f { + photocraft_doc::Fill::Gradient { stops, angle, scale, style, reverse, opacity_stops, midpoints, offset, dither, align } => json!({"gradient": { + "stops": stops.iter().map(|(t, c)| json!([t, rgba_of(c)])).collect::>(), + "angle": angle, "scale": scale * 100.0, "style": format!("{style:?}").to_ascii_lowercase(), "reverse": reverse, + "opacityStops": opacity_stops, "midpoints": midpoints, "offset": [offset.0, offset.1], "dither": dither, "align": align, + }}), + other => json!(color_of(other)), + } +} + /// Geometry of a Shape-tool drag as `shape.create` params, without fill and stroke (None when too /// small): ⇧ constrains proportions, ⌥ draws from the centre. Custom shapes give their box as a `rect`. fn shape_geometry(o: &ToolOptions, tool: Tool, start: [f64; 2], end: [f64; 2], mods: egui::Modifiers) -> Option { @@ -135,7 +167,7 @@ pub fn finish_shape(app: &mut PhotocraftApp, tool: Tool, start: [f64; 2], end: [ } fn fill_param(app: &PhotocraftApp) -> Value { - if app.ui.tool_options.shape_fill { json!(app.session.tools.foreground) } else { Value::Null } + if app.ui.tool_options.shape_fill { tool_paint_param(app, false) } else { Value::Null } } /// Create a shape layer from `shape.create` geometry with the options bar's fill and stroke: the @@ -160,8 +192,8 @@ fn shape_preview(app: &PhotocraftApp, tool: Tool, start: [f64; 2], end: [f64; 2] }; Some(photocraft_doc::ShapeLayer { path, - fill: o.shape_fill.then(|| solid_paint(app.session.tools.foreground)), - stroke: (o.stroke_width > 0.0).then(|| o.shape_stroke.stroke(o.stroke_width, solid_paint(app.session.tools.background))), + fill: o.shape_fill.then(|| tool_paint(app, false)), + stroke: (o.stroke_width > 0.0).then(|| o.shape_stroke.stroke(o.stroke_width, tool_paint(app, true))), ..Default::default() }) } @@ -1180,8 +1212,14 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo let (fg, bg) = (app.session.tools.foreground, app.session.tools.background); let (mut has_fill, fill, stroke) = match &target { Some(s) => (s.fill.is_some(), s.fill.clone(), s.stroke.clone()), - None => (o.shape_fill, o.shape_fill.then(|| solid_paint(fg)), (o.stroke_width > 0.0).then(|| o.shape_stroke.stroke(o.stroke_width, solid_paint(bg)))), + None => { + let fill = o.shape_fill_gradient.clone().unwrap_or_else(|| solid_paint(fg)); + let stroke = o.shape_stroke_gradient.clone().unwrap_or_else(|| solid_paint(bg)); + (o.shape_fill, o.shape_fill.then_some(fill), (o.stroke_width > 0.0).then(|| o.shape_stroke.stroke(o.stroke_width, stroke))) + } }; + let mut gradients = + GradientChoices { presets: &app.session.presets.gradients, current: &app.session.presets.gradient, recent: &mut app.ui.recent_gradients, fg, bg }; let mut width = stroke.as_ref().map_or(0.0, |s| s.width); let style = stroke.as_ref().map_or_else(|| o.shape_stroke.clone(), crate::shape_stroke_ui::StrokeOptions::from); let key = |k: &str| target.as_ref().map(|s| format!("shape-options-{:?}-{}-{k}", s.doc, s.layer.0)); @@ -1189,11 +1227,11 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo lbl(ui, tl!("Fill:")); if crate::widgets::checkbox(ui, &mut has_fill, "").changed() { o.shape_fill = has_fill; - edit = Some(json!({"fill": if has_fill { json!(fg) } else { Value::Null }})); + edit = Some(json!({"fill": if has_fill { o.shape_fill_gradient.as_ref().map_or_else(|| json!(fg), paint_param) } else { Value::Null }})); } - let fill_color = swatch(ui, fill.as_ref(), fg, tl!("Fill color")); + let fill_color = swatch(ui, fill.as_ref(), fg, tl!("Fill color"), &mut gradients); lbl(ui, tl!("Stroke:")); - let stroke_color = swatch(ui, stroke.as_ref().map(|s| &s.paint), bg, tl!("Stroke color")); + let stroke_color = swatch(ui, stroke.as_ref().map(|s| &s.paint), bg, tl!("Stroke color"), &mut gradients); if crate::widgets::value_field(ui, &mut width, 0.0..=288.0, "px", 58.0).changed() { o.stroke_width = width; let mut p = json!({"width": width}); @@ -1262,15 +1300,17 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo } for (is_stroke, change) in [(false, fill_color), (true, stroke_color)] { let Some(change) = change else { continue }; - if let Err(e) = set_tool_paint(app, is_stroke, change) { + if let Err(e) = set_tool_paint(app, is_stroke, change.clone()) { app.ui.status = e; app.ui.status_error = true; } edit = Some(match (is_stroke, change) { (false, PaintChange::None) => json!({"fill": null}), (false, PaintChange::Color(color)) => json!({"fill": color, "coalesce": key("fill")}), + (false, PaintChange::Gradient(g)) => json!({"fill": paint_param(&g), "coalesce": key("fill")}), (true, PaintChange::None) => json!({"stroke": null}), (true, PaintChange::Color(color)) => json!({"stroke": {"color": color, "width": enabled_stroke_width(width)}, "coalesce": key("stroke")}), + (true, PaintChange::Gradient(g)) => json!({"stroke": {"color": paint_param(&g), "width": enabled_stroke_width(width)}, "coalesce": key("stroke")}), }); } if let (Some(mut p), Some(s)) = (edit, &target) { @@ -1310,17 +1350,21 @@ fn solid_paint(c: [f32; 4]) -> photocraft_doc::Fill { fn color_of(f: &photocraft_doc::Fill) -> Option<[f32; 4]> { match f { - photocraft_doc::Fill::Solid(c) => { - let [r, g, b] = c.to_rgb(); - Some([r, g, b, c.alpha]) - } + photocraft_doc::Fill::Solid(c) => Some(rgba_of(c)), _ => None, } } -#[derive(Clone, Copy, Debug, PartialEq)] +fn rgba_of(c: &photocraft_doc::Color) -> [f32; 4] { + let [r, g, b] = c.to_rgb(); + [r, g, b, c.alpha] +} + +#[derive(Clone, Debug, PartialEq)] enum PaintChange { Color([f32; 4]), + /// A `Fill::Gradient` (the swatch's Gradient tab). + Gradient(photocraft_doc::Fill), None, } @@ -1330,6 +1374,14 @@ fn enabled_stroke_width(width: f32) -> f32 { /// Tool-bar paint changes affect the next shape; Properties edits the selected shape instead. fn set_tool_paint(app: &mut PhotocraftApp, stroke: bool, change: PaintChange) -> Result<(), String> { + // A colour takes the place of a gradient; No Color keeps it for when the paint comes back. + let o = &mut app.ui.tool_options; + let gradient = if stroke { &mut o.shape_stroke_gradient } else { &mut o.shape_fill_gradient }; + match &change { + PaintChange::Gradient(g) => *gradient = Some(g.clone()), + PaintChange::Color(_) => *gradient = None, + PaintChange::None => {} + } if let PaintChange::Color(color) = change { app.run("tools.setColors", if stroke { json!({"background": color}) } else { json!({"foreground": color}) })?; } @@ -1360,7 +1412,7 @@ fn picker_rgba(hsva: egui::ecolor::Hsva) -> [f32; 4] { /// The shared compact picker keeps the float RGB paint and its alpha. Color32 is only display /// data: opening the picker must never quantize an existing high-depth colour or enable paint. -fn swatch(ui: &mut egui::Ui, fill: Option<&photocraft_doc::Fill>, fallback: [f32; 4], tip: &str) -> Option { +fn swatch(ui: &mut egui::Ui, fill: Option<&photocraft_doc::Fill>, fallback: [f32; 4], tip: &str, gradients: &mut GradientChoices) -> Option { let t = Tokens::get(ui.ctx()); let (r, resp) = ui.allocate_exact_size(vec2(30.0, 22.0), Sense::click()); resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::ColorButton, ui.is_enabled(), tip)); @@ -1419,7 +1471,9 @@ fn swatch(ui: &mut egui::Ui, fill: Option<&photocraft_doc::Fill>, fallback: [f32 if let Some(PaintChange::Color(color)) = out { hsva = picker_color(color); } - crate::widgets::swatch_popup(&resp).show(|ui| { + let gradient = fill.filter(|f| matches!(f, photocraft_doc::Fill::Gradient { .. })); + let popup_id = resp.id; + let shown = crate::widgets::swatch_popup(&resp).show(|ui| { ui.horizontal(|ui| { if ui.selectable_label(fill.is_none(), tl!("No Color")).clicked() && fill.is_some() { out = Some(PaintChange::None); @@ -1427,8 +1481,17 @@ fn swatch(ui: &mut egui::Ui, fill: Option<&photocraft_doc::Fill>, fallback: [f32 if ui.selectable_label(current.is_some(), tl!("Solid")).clicked() && current.is_none() { out = Some(PaintChange::Color(original)); } + if ui.selectable_label(gradient.is_some(), tl!("Gradient")).clicked() && gradient.is_none() { + out = Some(PaintChange::Gradient(gradients.default_fill())); + } }); ui.separator(); + if let Some(g) = gradient { + if let Some(edited) = shape_gradient::gradient_tab(ui, g, gradients, popup_id) { + out = Some(PaintChange::Gradient(edited)); + } + return; + } let before = picker_rgba(hsva); if egui::color_picker::color_picker_hsva_2d(ui, &mut hsva, egui::color_picker::Alpha::OnlyBlend) { let color = picker_rgba(hsva); @@ -1442,6 +1505,16 @@ fn swatch(ui: &mut egui::Ui, fill: Option<&photocraft_doc::Fill>, fallback: [f32 hsva = picker_color([rgb[0], rgb[1], rgb[2], original[3]]); } }); + // The gradient a swatch's popup closes on joins the Gradient tab's Recent row. + let open_key = popup_id.with("open"); + let was_open = ui.data(|d| d.get_temp::(open_key)).unwrap_or(false); + let open = shown.is_some(); + if was_open && !open + && let Some(g) = gradient + { + gradients.remember(g); + } + ui.data_mut(|d| d.insert_temp(open_key, open)); let cached_color = match out { Some(PaintChange::Color(color)) => color, _ => original, @@ -1450,6 +1523,10 @@ fn swatch(ui: &mut egui::Ui, fill: Option<&photocraft_doc::Fill>, fallback: [f32 out } +#[path = "shape_gradient_ui.rs"] +mod shape_gradient; +use shape_gradient::GradientChoices; + /// One corner of the live rectangle, preserving the other three radii. /// The engine takes the full [top-left, top-right, bottom-right, bottom-left] array. fn corner_radii_patch(radii: [f64; 4], corner: usize, radius: f32) -> Value { @@ -1501,19 +1578,25 @@ pub fn shape_properties(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: photocra if crate::props_layout::section(ui, "appearance", crate::i18n::tr_ctx(crate::i18n::current(), "shape", "Appearance")) { ui.horizontal(|ui| { ui.label(egui::RichText::new(tl!("Fill")).color(t.text_dim).size(12.0)); - if let Some(change) = swatch(ui, sh.fill.as_ref(), app.session.tools.foreground, tl!("Set shape fill type")) { + let (fg, bg) = (app.session.tools.foreground, app.session.tools.background); + let mut gradients = + GradientChoices { presets: &app.session.presets.gradients, current: &app.session.presets.gradient, recent: &mut app.ui.recent_gradients, fg, bg }; + if let Some(change) = swatch(ui, sh.fill.as_ref(), fg, tl!("Set shape fill type"), &mut gradients) { let fill = match change { PaintChange::None => Value::Null, PaintChange::Color(color) => json!(color), + PaintChange::Gradient(g) => paint_param(&g), }; edit = Some(json!({"fill": fill, "coalesce": coalesce("fill")})); } ui.add_space(12.0); ui.label(egui::RichText::new(tl!("Stroke")).color(t.text_dim).size(12.0)); - if let Some(change) = swatch(ui, sh.stroke.as_ref().map(|s| &s.paint), app.session.tools.foreground, tl!("Set shape stroke type")) { + if let Some(change) = swatch(ui, sh.stroke.as_ref().map(|s| &s.paint), fg, tl!("Set shape stroke type"), &mut gradients) { + let width = enabled_stroke_width(sh.stroke.as_ref().map_or(0.0, |s| s.width)); let stroke = match change { PaintChange::None => Value::Null, - PaintChange::Color(color) => json!({"color": color, "width": enabled_stroke_width(sh.stroke.as_ref().map_or(0.0, |s| s.width))}), + PaintChange::Color(color) => json!({"color": color, "width": width}), + PaintChange::Gradient(g) => json!({"color": paint_param(&g), "width": width}), }; edit = Some(json!({"stroke": stroke, "coalesce": coalesce("stroke")})); } diff --git a/docs/scorecard.md b/docs/scorecard.md index 377ce8583d..a3e7bda59c 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -172,7 +172,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t | TOOL-214-21 | Crop: Straighten button in the options bar and Cmd/Ctrl-drag draw a line; the frame turns so the line ends up level (or plumb when nearer vertical), with an angle readout | done | [#1919](https://github.com/storytold/photocraft/issues/1919) | crop_straighten.rs: one-shot options-bar button, Cmd/Ctrl held is a temporary Straighten (ui.pointer command flag); the Ruler's straighten_angle convention; the frame is fitted to the largest of its proportions inside the image (Classic Mode); a pending edit committed by Enter | | TOOL-214-22 | Crop gear menu: Show Cropped Area (H), Enable Crop Shield with Match Canvas / custom colour, opacity and Auto Adjust Opacity | done | [#1919](https://github.com/storytold/photocraft/issues/1919) | crop_shield.rs: fill() resolves the shield (canvas.rs paints it around upright and turned frames), gear popup in the options bar, H ahead of the Hand key in shortcuts.rs, Custom… opens the Color Picker; ToolOptions crop_shield, ui.set cropShield. Use Classic Mode / Auto Center Preview: TOOL-214-23 | | TOOL-214-23 | Crop: Photoshop's default mode (the image turns and moves behind an upright box, Auto Center Preview keeps a resized box's centre in place and centres a drawn one) and Use Classic Mode (P) in the gear menu | done | [#1919](https://github.com/storytold/photocraft/issues/1919) | crop_mode.rs: the crop model (crop_rect + crop_angle) and image.crop are shared by both modes; default mode sets the view's rotation to -crop_angle while the tool shows a frame (picking the tool, in either mode, turns a Rotate View turn upright about the view centre, not restored after Enter/Esc or by P; Classic Mode keeps the camera upright with the frame drawn turned; as Photoshop 25.1), pivoting so the box stays put, moves view and frame together for drags inside and arrow keys, keeps a resized box's centre in place live (Auto Center Preview; a drawn box is centred on release, a moved one never), readout = the image's turn; gear menu order and Classic Mode greying as Photoshop 25.1; CropShield classic_mode / auto_center_preview (ui.set cropShield), P ahead of the Pen key | -| TOOL-1053-1 | Shape stroke controls: solid/dashed/dotted, custom dash/gap/offset, caps, joins, alignment, miter limit and opacity | done | [#1053](https://github.com/storytold/photocraft/issues/1053) | shape_stroke_ui.rs: shared staged editor, renderer samples, cached Properties canvas preview; existing shape.create/edit/info; serde tool defaults, ui.set shapeStroke; pcraft and vstk style round trips. Gradient fill UI and saved stroke libraries remain open; Line retains filled-bar geometry | +| TOOL-1053-1 | Shape stroke controls: solid/dashed/dotted, custom dash/gap/offset, caps, joins, alignment, miter limit and opacity | done | [#1053](https://github.com/storytold/photocraft/issues/1053) | shape_stroke_ui.rs: shared staged editor, renderer samples, cached Properties canvas preview; existing shape.create/edit/info; serde tool defaults, ui.set shapeStroke; pcraft and vstk style round trips. vector_ui.rs: the Fill and Stroke swatches (options bar and Properties) have a Gradient tab (shape_gradient_ui.rs: Recent row, presets, an editable stops strip with the selected stop's colour/opacity/location, style, angle, scale, reverse, Align with layer) for the next shape and the selected one. Pattern paint UI and saved stroke libraries remain open; Line retains filled-bar geometry | | TOOL-213-19 | Remove tool: paint over an object (or circle it) and it is filled from its surroundings | partial | [#213](https://github.com/storytold/photocraft/issues/213) | paint.remove (retouch_cmds/remove.rs, background job) + Tool::Remove in the J flyout; loops close over what they enclose; fill by non-local patch completion with texture features, onion-peel start, best-patch copy and gradient-domain seam hiding (algo/nonlocal.rs, Newson et al. IPOL 2017); sparse holes in tiles (algo/remove.rs). remove_quality on 20 holes in public-domain photos: the fill keeps 0.89 of the texture it replaces (0.54 with Content-Aware Fill's completion), edge gradient 1.03 of the original's; remove_bench 24 MP: 100 px ring 120 ms, 1000 px ring 2.5 s, 3000 px line 1.7 s. Options bar: Sample All Layers, Create a new layer (the fill on a new layer above, `newLayer`), Remove after each stroke off (strokes collect as a tint and ↩ applies them as one `strokes` job, Esc drops them). Missing: generative AI mode, live preview of the result | | TOOL-2259-1 | Arrow-key nudges of one thing (layers, the selection outline, the Free Transform box) that follow each other are one History state, with a preference to turn it off | done | [#2259](https://github.com/storytold/photocraft/issues/2259) | nudge_bundle.rs: a run shares one `coalesce` key while each nudge comes within Tools > Nudge Bundle Pause (1 s) and nothing else touched the document (an edit, Undo/Redo, a layer selection, a save end it); move_mods.rs runs layer.translate and select.transformSelection through it, transform_tool.rs folds box nudges into one session step. Tools > Bundle Arrow-Key Nudges off gives every press its own state. Selected pixels float until dropped, which is one state already; ⌥-nudges (a copy each) never join a run | | TOOL-1045-1 | Color Replacement tool on the toolbar | done | [#1045](https://github.com/storytold/photocraft/issues/1045) | Tool::ColorReplacement in the Brush (B) flyout after the Mixer Brush; Mode/Sampling/Limits/Tolerance/Anti-alias options drive paint.colorReplacement with the foreground colour; live preview (LiveDab with the stroke's finishing dab), one History step; color_replacement_tests.rs | diff --git a/docs/shape-strokes.md b/docs/shape-strokes.md index 835eff76c2..a69ab79196 100644 --- a/docs/shape-strokes.md +++ b/docs/shape-strokes.md @@ -74,6 +74,23 @@ zero. Set tool colours with `tools.setColors`. `ui.inspect` reports `toolOptions `toolOptions.stroke_width`, and the transient `strokeEditor`. Keyboard focus, standard number fields, colour pickers, and ComboBoxes remain native egui controls. +## Paint + +The Fill and Stroke swatches (options bar and Properties) offer No Color, Solid and Gradient, +as Photoshop's shape Fill/Stroke popover does. Gradient starts from the Gradient tool's current +gradient (linear, 90°, 100%). Its tab (`shape_gradient_ui.rs`) has a Recent row (the gradients +the popups last closed on, `ui.recent_gradients`) above the preset library (a pick takes the +preset's colour and opacity stops, as a Gradient Fill layer made from it does), a stops strip +(click below the ramp to add a colour stop, above it an opacity stop; drag a stop to move it or +off the strip to delete it; drag a midpoint), the selected stop's colour (an inline picker), +opacity, location and Delete, and the style, angle, scale, Reverse and Align with layer. Stop +edits use the Gradient Editor's grammar (`gradient_fill_cmds::apply_stop`). With no +shape selected the choice is the next shape's (`toolOptions.shape_fill_gradient` / +`shape_stroke_gradient`; a colour replaces it, No Color keeps it); with one selected it is one +`shape.edit`. The swatches send every gradient field (`opacityStops`, `midpoints`, `offset`, +`dither`, `align`), so changing the angle of an imported gradient keeps the rest. Pattern paint is +not offered yet. + ## Upstream and public references - [PR #2218](https://github.com/storytold/photocraft/pull/2218) introduced these controls with @@ -82,7 +99,8 @@ fields, colour pickers, and ComboBoxes remain native egui controls. parity, including selected-shape editing from the options bar and additional fill types; those remain separate work. - [Issue #1053](https://github.com/storytold/photocraft/issues/1053) documents the missing - stroke controls and existing engine/model support. Gradient fill UI remains separate work. + stroke controls and existing engine/model support. The Fill and Stroke swatches now have a + Gradient tab (see Paint below); a pattern paint UI remains separate work. - [Issue #1931](https://github.com/storytold/photocraft/issues/1931) requests sharp stroke options. - [PR #233](https://github.com/storytold/photocraft/pull/233), [#397](https://github.com/storytold/photocraft/pull/397), and diff --git a/scorecard/tools.toml b/scorecard/tools.toml index 51f6b1cf33..ae0e3e9af0 100644 --- a/scorecard/tools.toml +++ b/scorecard/tools.toml @@ -290,7 +290,7 @@ id = "TOOL-1053-1" target = "Shape stroke controls: solid/dashed/dotted, custom dash/gap/offset, caps, joins, alignment, miter limit and opacity" status = "done" issue = 1053 -note = "shape_stroke_ui.rs: shared staged editor, renderer samples, cached Properties canvas preview; existing shape.create/edit/info; serde tool defaults, ui.set shapeStroke; pcraft and vstk style round trips. Gradient fill UI and saved stroke libraries remain open; Line retains filled-bar geometry" +note = "shape_stroke_ui.rs: shared staged editor, renderer samples, cached Properties canvas preview; existing shape.create/edit/info; serde tool defaults, ui.set shapeStroke; pcraft and vstk style round trips. vector_ui.rs: the Fill and Stroke swatches (options bar and Properties) have a Gradient tab (shape_gradient_ui.rs: Recent row, presets, an editable stops strip with the selected stop's colour/opacity/location, style, angle, scale, reverse, Align with layer) for the next shape and the selected one. Pattern paint UI and saved stroke libraries remain open; Line retains filled-bar geometry" [[item]] id = "TOOL-213-19" From 7deeaeeba1638353a0fe6abdcd534a198c144cb0 Mon Sep 17 00:00:00 2001 From: Unemars <62496697+Unemars@users.noreply.github.com> Date: Sun, 18 Oct 2026 01:16:29 +0200 Subject: [PATCH 117/649] Brush: large tips rasterize, accumulate and composite in parallel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A 2000 px soft tip is a 12 MP dab, and every dab ran on one thread: the tip's coverage (92 ms), its accumulation into the stroke's tiles (44 ms) and the composite of the dirty tiles into the layer (177 ms), about 300 ms a dab, so a stroke across a 24 MP photo lagged by a quarter second per frame. Photoshop keeps such strokes fluid by spreading them over the cores. Each stage is independent per row (the round tip's coverage) or per tile (the accumulation, the composite), so they now run on the thread pool from 256² pixels of work up, to the same pixels: the per-pixel maths is untouched, the dither and Dissolve hash positions, and a test renders a 700 px soft stroke, a Dissolve stroke and a per-dab-colour stroke (with a selection, 8-bit) both ways and compares every pixel. Below the threshold, and on the web, nothing changes. The composite's writes to the layer stay in order; its tiles are composited in batches so the pending regions stay small. `examples/big_dab_bench.rs` prints the stages of one dab. On a loaded 16-thread machine the 12 MP dab went from about 300 ms to 100–140 ms; the hard 2000 px tip from 75 to 35 ms. Co-Authored-By: Claude Fable 5.1 --- crates/paint/Cargo.toml | 4 + crates/paint/examples/big_dab_bench.rs | 44 ++++ crates/paint/src/brush_tests.rs | 53 +++++ crates/paint/src/render.rs | 307 ++++++++++++++++--------- 4 files changed, 297 insertions(+), 111 deletions(-) create mode 100644 crates/paint/examples/big_dab_bench.rs diff --git a/crates/paint/Cargo.toml b/crates/paint/Cargo.toml index afb9a196d0..4f4ca359e6 100644 --- a/crates/paint/Cargo.toml +++ b/crates/paint/Cargo.toml @@ -13,5 +13,9 @@ photocraft-color = { workspace = true } photocraft-raster = { workspace = true } serde = { workspace = true } +# Large tips rasterize, accumulate and composite in parallel (the same pixels as serially). +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +rayon = { workspace = true } + [dev-dependencies] serde_json = { workspace = true } diff --git a/crates/paint/examples/big_dab_bench.rs b/crates/paint/examples/big_dab_bench.rs new file mode 100644 index 0000000000..a31265224c --- /dev/null +++ b/crates/paint/examples/big_dab_bench.rs @@ -0,0 +1,44 @@ +//! Where a large brush's time goes: one dab of a 2000 px tip, by stage. +//! `cargo run --release -p photocraft-paint --example big_dab_bench [size] [hardness]` +use photocraft_color::PixelFormat; +use photocraft_geom::Rect; +use photocraft_paint::{BrushContext, BrushSettings, Dab, StrokePoint, StrokeRenderer}; +use photocraft_raster::Surface; +use std::time::Instant; + +fn main() { + let args: Vec = std::env::args().collect(); + let size: f32 = args.get(1).and_then(|s| s.parse().ok()).unwrap_or(2000.0); + let hardness: f32 = args.get(2).and_then(|s| s.parse().ok()).unwrap_or(0.0); + let brush = BrushSettings { size, hardness, spacing: 0.25, color: [1.0, 0.0, 0.0, 1.0], ..Default::default() }; + let fmt = PixelFormat::RGBA8; + let mut pre = Surface::new(fmt); + pre.fill_rect(Rect::new(0, 0, 4928, 3280), &[0.5, 0.5, 0.5, 1.0]); + let mut target = pre.clone(); + // Stage 1: the tip's coverage alone. + let ctx = BrushContext::new(&brush); + let dab = Dab::round(photocraft_geom::Point::new(2464.0, 1640.0), size / 2.0, 1.0); + let rect = ctx.dab_rect(&dab, false); + let mut cov = Vec::new(); + let t = Instant::now(); + ctx.rasterize(&dab, false, rect, &mut cov); + let raster = t.elapsed(); + println!("tip {size} px, hardness {hardness}: dab rect {}x{} = {:.1} MP", rect.width(), rect.height(), rect.width() as f64 * rect.height() as f64 / 1e6); + println!(" rasterize (coverage): {:>7.1} ms", raster.as_secs_f64() * 1e3); + // Stage 2+3: push through the renderer (rasterize + accumulate), then composite. + let mut r = StrokeRenderer::new(&brush, Some(fmt), 1.0); + let t = Instant::now(); + // Two points a pixel apart: the generator places the first dab at once (a lone point waits). + r.push(&[StrokePoint::new(2464.0, 1640.0, 1.0), StrokePoint::new(2465.0, 1640.0, 1.0)]); + let push = t.elapsed(); + println!(" push (rasterize+accumulate): {:>5.1} ms (accumulate ≈ {:.1} ms)", push.as_secs_f64() * 1e3, push.saturating_sub(raster).as_secs_f64() * 1e3); + let t = Instant::now(); + let dmg = r.composite(&pre, &mut target, None, false, false); + let comp = t.elapsed(); + println!(" composite (dirty tiles): {:>7.1} ms over {}x{}", comp.as_secs_f64() * 1e3, dmg.width(), dmg.height()); + // A second dab half a spacing away, as a stroke does: the same again. + let t = Instant::now(); + r.push(&[StrokePoint::new(2464.0 + f64::from(size) * 0.25, 1640.0, 1.0), StrokePoint::new(2466.0 + f64::from(size) * 0.25, 1640.0, 1.0)]); + let dmg = r.composite(&pre, &mut target, None, false, false); + println!(" next dab push+composite: {:>7.1} ms over {}x{}", t.elapsed().as_secs_f64() * 1e3, dmg.width(), dmg.height()); +} diff --git a/crates/paint/src/brush_tests.rs b/crates/paint/src/brush_tests.rs index d0d7de4110..90e1e64f50 100644 --- a/crates/paint/src/brush_tests.rs +++ b/crates/paint/src/brush_tests.rs @@ -1493,3 +1493,56 @@ fn an_aliased_stroke_at_partial_opacity_is_one_flat_colour() { assert_eq!(s.rgba(x, 5), first, "pixel {x} of the Pencil line"); } } + +/// Large tips rasterize, accumulate and composite in parallel (rows of a dab, tiles of a stroke); +/// the pixels are the ones the serial path gives, with 8-bit dithering, a selection, Dissolve and +/// per-dab colour included. +#[cfg(not(target_arch = "wasm32"))] +#[test] +fn large_tips_render_the_same_in_parallel_and_serially() { + let mut sel = Surface::new(PixelFormat::GRAY8); + sel.fill_rect(Rect::new(0, 0, 900, 700), &[1.0]); + sel.fill_rect(Rect::new(300, 0, 400, 700), &[0.0]); + let strokes: Vec<(BrushSettings, Vec)> = vec![ + (BrushSettings { size: 700.0, hardness: 0.0, flow: 0.6, color: [0.9, 0.2, 0.1, 1.0], ..brush() }, line(200.0, 700.0, 350.0)), + ( + BrushSettings { size: 420.0, hardness: 1.0, opacity: 0.5, mode: BlendMode::Dissolve, color: [0.1, 0.5, 0.9, 1.0], ..brush() }, + line(150.0, 750.0, 300.0), + ), + ( + BrushSettings { + size: 500.0, + hardness: 0.3, + color_dynamics: ColorDynamics { enabled: true, hue_jitter: 0.5, per_tip: true, ..Default::default() }, + color: [0.2, 0.8, 0.3, 1.0], + ..brush() + }, + line(100.0, 800.0, 400.0), + ), + ]; + let render = |parallel_from: usize| -> Vec> { + crate::render::set_parallel_min_pixels(parallel_from); + strokes + .iter() + .map(|(b, pts)| { + let mut s = Surface::new(PixelFormat::RGBA8); + s.fill_rect(Rect::new(0, 0, 900, 700), &[0.5, 0.5, 0.5, 1.0]); + let (mut with_sel, mut plain) = (s.clone(), s); + render_stroke(&mut with_sel, b, pts, Some(&sel), false, 1.0); + render_stroke(&mut plain, b, pts, None, false, 1.0); + let mut px = with_sel.read_region(Rect::new(0, 0, 900, 700)); + px.extend(plain.read_region(Rect::new(0, 0, 900, 700))); + px + }) + .collect() + }; + let parallel = render(0); + let serial = render(usize::MAX); + crate::render::set_parallel_min_pixels(256 * 256); + for (i, (p, s)) in parallel.iter().zip(&serial).enumerate() { + assert_eq!(p.len(), s.len()); + let diff = p.iter().zip(s).filter(|(a, b)| a != b).count(); + assert_eq!(diff, 0, "stroke {i}: {diff} pixels differ between the parallel and the serial render"); + assert!(p.iter().any(|v| (*v - 0.5).abs() > 0.1), "stroke {i} painted something"); + } +} diff --git a/crates/paint/src/render.rs b/crates/paint/src/render.rs index 5f59aafad1..b0fa7d64ea 100644 --- a/crates/paint/src/render.rs +++ b/crates/paint/src/render.rs @@ -39,6 +39,66 @@ fn dither8(px: &mut [f32], x: i32, y: i32) { /// Edge of a stroke-buffer tile. pub const COV_TILE: i32 = 64; + +/// Work on at least this many pixels runs in parallel (rows of a dab, tiles of a stroke): below +/// it the threads cost more than they save. A large soft tip is tens of megapixels per dab, and +/// every stage of it is independent per row or tile, so the pixels come out the same. +#[cfg(not(target_arch = "wasm32"))] +static PARALLEL_MIN_PIXELS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(256 * 256); + +/// Whether `pixels` of independent work are worth the thread pool (never on the web). +fn parallel(pixels: usize) -> bool { + #[cfg(not(target_arch = "wasm32"))] + { + pixels >= PARALLEL_MIN_PIXELS.load(std::sync::atomic::Ordering::Relaxed) + } + #[cfg(target_arch = "wasm32")] + { + let _ = pixels; + false + } +} + +/// Tests: the pixel count from which work runs in parallel (`usize::MAX` keeps everything serial). +#[cfg(all(test, not(target_arch = "wasm32")))] +pub(crate) fn set_parallel_min_pixels(n: usize) { + PARALLEL_MIN_PIXELS.store(n, std::sync::atomic::Ordering::Relaxed); +} + +/// `f(row index, row)` over the rows of `out` (`w` values each), in parallel when worth it. +fn for_each_row(out: &mut [f32], w: usize, f: impl Fn(usize, &mut [f32]) + Sync) { + if w == 0 { + return; + } + #[cfg(not(target_arch = "wasm32"))] + if parallel(out.len()) { + use rayon::prelude::*; + out.par_chunks_exact_mut(w).enumerate().for_each(|(i, row)| f(i, row)); + return; + } + out.chunks_exact_mut(w).enumerate().for_each(|(i, row)| f(i, row)); +} + +/// `f` over `items`, in parallel when `pixels` are worth it. +fn for_each_item(items: &mut [T], pixels: usize, f: impl Fn(&mut T) + Sync) { + #[cfg(not(target_arch = "wasm32"))] + if parallel(pixels) { + use rayon::prelude::*; + items.par_iter_mut().for_each(&f); + return; + } + items.iter_mut().for_each(&f); +} + +/// `f` over `items`, collecting its results in order, in parallel when `pixels` are worth it. +fn map_items(items: &[T], pixels: usize, f: impl Fn(&T) -> R + Sync) -> Vec { + #[cfg(not(target_arch = "wasm32"))] + if parallel(pixels) { + use rayon::prelude::*; + return items.par_iter().map(&f).collect(); + } + items.iter().map(&f).collect() +} /// Computed tips with a smaller radius (in pixels) are rasterised by area, not at pixel centres. const SMALL_TIP_RADIUS: f32 = 3.0; /// Sub-pixel sample offsets (a 4×4 grid) for the area coverage of small tips. @@ -466,61 +526,71 @@ impl CoverageMap { let (t0x, t0y) = (rect.x0.div_euclid(COV_TILE), rect.y0.div_euclid(COV_TILE)); let (t1x, t1y) = ((rect.x1 - 1).div_euclid(COV_TILE), (rect.y1 - 1).div_euclid(COV_TILE)); let want_col = color.is_some() && nc > 0; + // The tiles this dab touches (a tile with no value in it is skipped), each independent of + // the others: a large dab's tiles accumulate in parallel, to the same values. + let mut keys: Vec<((i32, i32), Rect)> = Vec::new(); for ty in t0y..=t1y { for tx in t0x..=t1x { let tr = Rect::new(tx * COV_TILE, ty * COV_TILE, (tx + 1) * COV_TILE, (ty + 1) * COV_TILE).intersect(&rect); if tr.is_empty() { continue; } - // Skip tiles this dab doesn't touch. - let any = (tr.y0..tr.y1).any(|y| { - let row = (y - rect.y0) as usize * w; - vals[row + (tr.x0 - rect.x0) as usize..row + (tr.x1 - rect.x0) as usize].iter().any(|&v| v > 0.0) - }); - if !any { - continue; - } - let tile = self.tiles.entry((tx, ty)).or_insert_with(|| CovTile { - cov: vec![0.0; (COV_TILE * COV_TILE) as usize], - depth: Vec::new(), - col: if want_col { vec![0.0; (COV_TILE * COV_TILE) as usize * nc] } else { Vec::new() }, - }); - if want_col && tile.col.is_empty() { - tile.col = vec![0.0; (COV_TILE * COV_TILE) as usize * nc]; - } - if depth.is_some() && tile.depth.is_empty() { - tile.depth = vec![0.0; (COV_TILE * COV_TILE) as usize]; - } - self.dirty.insert((tx, ty)); - for y in tr.y0..tr.y1 { - let row = (y - rect.y0) as usize * w; - let trow = ((y - ty * COV_TILE) * COV_TILE) as usize; - for x in tr.x0..tr.x1 { - let v = vals[row + (x - rect.x0) as usize]; - if v <= 0.0 { - continue; - } - let ti = trow + (x - tx * COV_TILE) as usize; - if let (Some(dv), Some(slot)) = (depth.and_then(|dp| dp.get(row + (x - rect.x0) as usize)), tile.depth.get_mut(ti)) { - *slot = slot.max(*dv); - } - let c = tile.cov[ti]; - let nv = if ceil > c { c + v * (ceil - c) } else { c }; - if nv <= c { - continue; - } - if let (true, Some(col)) = (want_col, color) { - let k = if c < 1.0 { (nv - c) / (1.0 - c) } else { 0.0 }; - let p = &mut tile.col[ti * nc..(ti + 1) * nc]; - for i in 0..nc { - p[i] = col[i] * k + p[i] * (1.0 - k); - } - } - tile.cov[ti] = nv; - } - } + keys.push(((tx, ty), tr)); } } + let touched = map_items(&keys, keys.len() * (COV_TILE * COV_TILE) as usize, |(_, tr)| { + (tr.y0..tr.y1).any(|y| { + let row = (y - rect.y0) as usize * w; + vals[row + (tr.x0 - rect.x0) as usize..row + (tr.x1 - rect.x0) as usize].iter().any(|&v| v > 0.0) + }) + }); + let keys: Vec<((i32, i32), Rect)> = keys.into_iter().zip(touched).filter(|(_, t)| *t).map(|(k, _)| k).collect(); + for (key, _) in &keys { + let tile = self.tiles.entry(*key).or_insert_with(|| CovTile { + cov: vec![0.0; (COV_TILE * COV_TILE) as usize], + depth: Vec::new(), + col: if want_col { vec![0.0; (COV_TILE * COV_TILE) as usize * nc] } else { Vec::new() }, + }); + if want_col && tile.col.is_empty() { + tile.col = vec![0.0; (COV_TILE * COV_TILE) as usize * nc]; + } + if depth.is_some() && tile.depth.is_empty() { + tile.depth = vec![0.0; (COV_TILE * COV_TILE) as usize]; + } + self.dirty.insert(*key); + } + let wanted: HashMap<(i32, i32), Rect> = keys.into_iter().collect(); + let mut tiles: Vec<(Rect, (i32, i32), &mut CovTile)> = self.tiles.iter_mut().filter_map(|(k, t)| Some((*wanted.get(k)?, *k, t))).collect(); + for_each_item(&mut tiles, wanted.len() * (COV_TILE * COV_TILE) as usize, |(tr, (tx, ty), tile)| { + let (tx, ty) = (*tx, *ty); + for y in tr.y0..tr.y1 { + let row = (y - rect.y0) as usize * w; + let trow = ((y - ty * COV_TILE) * COV_TILE) as usize; + for x in tr.x0..tr.x1 { + let v = vals[row + (x - rect.x0) as usize]; + if v <= 0.0 { + continue; + } + let ti = trow + (x - tx * COV_TILE) as usize; + if let (Some(dv), Some(slot)) = (depth.and_then(|dp| dp.get(row + (x - rect.x0) as usize)), tile.depth.get_mut(ti)) { + *slot = slot.max(*dv); + } + let c = tile.cov[ti]; + let nv = if ceil > c { c + v * (ceil - c) } else { c }; + if nv <= c { + continue; + } + if let (true, Some(col)) = (want_col, color) { + let k = if c < 1.0 { (nv - c) / (1.0 - c) } else { 0.0 }; + let p = &mut tile.col[ti * nc..(ti + 1) * nc]; + for i in 0..nc { + p[i] = col[i] * k + p[i] * (1.0 - k); + } + } + tile.cov[ti] = nv; + } + } + }); } fn take_dirty(&mut self) -> Vec<(i32, i32)> { @@ -989,75 +1059,88 @@ impl StrokeRenderer { // colour, as in Photoshop, not grain that a tolerance-0 Magic Wand or Paint Bucket trips on. let dither = fmt.sample == SampleType::U8 && !b.aliased; let mut dmg = Rect::EMPTY; - let mut region = Vec::new(); - for (tx, ty) in keys { - let Some(tile) = self.cov.tiles.get(&(tx, ty)) else { continue }; - let tr = Rect::new(tx * COV_TILE, ty * COV_TILE, (tx + 1) * COV_TILE, (ty + 1) * COV_TILE).intersect(&bounds); - if tr.is_empty() { - continue; - } - pre.read_region_into(tr, &mut region); - let sel = selection.map(|s| (s.channels(), s.read_region(tr))); - let w = tr.width() as usize; - for y in tr.y0..tr.y1 { - for x in tr.x0..tr.x1 { - let ti = ((y - ty * COV_TILE) * COV_TILE + (x - tx * COV_TILE)) as usize; - let c = tile.cov[ti]; - if c <= 0.0 { - continue; - } - let i = (y - tr.y0) as usize * w + (x - tr.x0) as usize; - let m = self.ctx.stroke_mask_wet(c, tile.depth.get(ti).copied(), self.dual.as_ref().map(|d| d.get(x, y)), x, y); - let s = sel.as_ref().map_or(1.0, |(sc, v)| v[i * sc]); - let mut k = (m * opacity * s).min(1.0); - if k <= 0.0 { - continue; - } - if b.mode == BlendMode::Dissolve { - k = if hash2(x, y, b.seed) < k { 1.0 } else { 0.0 }; - if k == 0.0 { + // Each tile composites on its own (a large stroke's tiles in parallel, to the same + // pixels); the writes to the target go one by one. Batches keep the pending regions small. + const BATCH: usize = 256; + for batch in keys.chunks(BATCH) { + let regions: Vec<(Rect, Vec)> = map_items(batch, batch.len() * (COV_TILE * COV_TILE) as usize, |&(tx, ty)| { + let Some(tile) = self.cov.tiles.get(&(tx, ty)) else { return (Rect::EMPTY, Vec::new()) }; + let tr = Rect::new(tx * COV_TILE, ty * COV_TILE, (tx + 1) * COV_TILE, (ty + 1) * COV_TILE).intersect(&bounds); + if tr.is_empty() { + return (Rect::EMPTY, Vec::new()); + } + let mut region = Vec::new(); + pre.read_region_into(tr, &mut region); + let sel = selection.map(|s| (s.channels(), s.read_region(tr))); + // Per-dab colour rewrites the source per pixel: a copy per tile. + let mut src = src; + let w = tr.width() as usize; + for y in tr.y0..tr.y1 { + for x in tr.x0..tr.x1 { + let ti = ((y - ty * COV_TILE) * COV_TILE + (x - tx * COV_TILE)) as usize; + let c = tile.cov[ti]; + if c <= 0.0 { continue; } - } - let px = &mut region[i * n..(i + 1) * n]; - if b.erase { - if let (Some(a), false) = (a_idx, lock_transparency) { - px[a] *= 1.0 - k; + let i = (y - tr.y0) as usize * w + (x - tr.x0) as usize; + let m = self.ctx.stroke_mask_wet(c, tile.depth.get(ti).copied(), self.dual.as_ref().map(|d| d.get(x, y)), x, y); + let s = sel.as_ref().map_or(1.0, |(sc, v)| v[i * sc]); + let mut k = (m * opacity * s).min(1.0); + if k <= 0.0 { + continue; + } + if b.mode == BlendMode::Dissolve { + k = if hash2(x, y, b.seed) < k { 1.0 } else { 0.0 }; + if k == 0.0 { + continue; + } + } + let px = &mut region[i * n..(i + 1) * n]; + if b.erase { + if let (Some(a), false) = (a_idx, lock_transparency) { + px[a] *= 1.0 - k; + } + if dither { + dither8(px, x, y); + } + continue; + } + if lock_transparency && a_idx.is_some_and(|a| px[a] <= 0.0) { + continue; + } + if self.per_dab_color && !tile.col.is_empty() { + let p = &tile.col[ti * nc..(ti + 1) * nc]; + for ch in 0..nc { + src[ch] = p[ch] / c; + } + } + if matches!(b.mode, BlendMode::Normal | BlendMode::Dissolve) { + over_native(&fmt, px, &src[..n], k, lock_transparency); + } else { + let d = to_rgba(&fmt, px); + let sr = to_rgba(&fmt, &src[..n]); + let mut o = photocraft_color::blend::composite(b.mode, d, sr, k); + if lock_transparency { + o[3] = d[3]; + } + let mut enc = [0.0f32; 8]; + from_rgba_into(&fmt, o, &mut enc); + px.copy_from_slice(&enc[..n]); } if dither { dither8(px, x, y); } - continue; - } - if lock_transparency && a_idx.is_some_and(|a| px[a] <= 0.0) { - continue; - } - if self.per_dab_color && !tile.col.is_empty() { - let p = &tile.col[ti * nc..(ti + 1) * nc]; - for ch in 0..nc { - src[ch] = p[ch] / c; - } - } - if matches!(b.mode, BlendMode::Normal | BlendMode::Dissolve) { - over_native(&fmt, px, &src[..n], k, lock_transparency); - } else { - let d = to_rgba(&fmt, px); - let sr = to_rgba(&fmt, &src[..n]); - let mut o = photocraft_color::blend::composite(b.mode, d, sr, k); - if lock_transparency { - o[3] = d[3]; - } - let mut enc = [0.0f32; 8]; - from_rgba_into(&fmt, o, &mut enc); - px.copy_from_slice(&enc[..n]); - } - if dither { - dither8(px, x, y); } } + (tr, region) + }); + for (tr, region) in regions { + if tr.is_empty() { + continue; + } + target.write_region(tr, ®ion); + dmg = dmg.union(&tr); } - target.write_region(tr, ®ion); - dmg = dmg.union(&tr); } if all { bounds } else { dmg } } @@ -1091,23 +1174,25 @@ fn rasterize_round(d: &Dab, rect: Rect, out: &mut [f32], hardness: f32, aliased: let w = rect.width() as usize; let reach = if aliased { rm } else { tip_reach(rm, hardness).max(rm) }; let reach2 = (reach + 0.5) * (reach + 0.5); - for (yy, row) in out.chunks_exact_mut(w).enumerate() { + let alpha = d.alpha; + // Rows are independent: a large tip's rows run in parallel, to the same values. + for_each_row(out, w, |yy, row| { let dy = (rect.y0 + yy as i32) as f32 + 0.5 - cy; if aliased { for (xx, dst) in row.iter_mut().enumerate() { let dx = (rect.x0 + xx as i32) as f32 + 0.5 - cx; let d2 = (dx * ro).powi(2) + dy * dy; - *dst = if d2 < reach2 && d2.sqrt() <= rm { d.alpha } else { 0.0 }; + *dst = if d2 < reach2 && d2.sqrt() <= rm { alpha } else { 0.0 }; } } else { for (xx, dst) in row.iter_mut().enumerate() { let dx = (rect.x0 + xx as i32) as f32 + 0.5 - cx; let d2 = (dx * ro).powi(2) + dy * dy; let val = if d2 >= reach2 { 0.0 } else { tip_falloff(d2.sqrt(), rm, hardness) }; - *dst = if val <= 0.0 { 0.0 } else { val * d.alpha }; + *dst = if val <= 0.0 { 0.0 } else { val * alpha }; } } - } + }); } #[cfg(test)] From ac1bc012ef0965396ea2d4dbe68f07e943950d7e Mon Sep 17 00:00:00 2001 From: seotarek Date: Thu, 15 Oct 2026 04:50:19 +0300 Subject: [PATCH 118/649] fix(compose): prevent outside stroke from bleeding into opaque character interior (#5861) --- crates/compose/src/effects.rs | 22 ++++----------- crates/compose/src/stroke_tests.rs | 45 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/crates/compose/src/effects.rs b/crates/compose/src/effects.rs index 5acdd79314..550cb398aa 100644 --- a/crates/compose/src/effects.rs +++ b/crates/compose/src/effects.rs @@ -2093,23 +2093,8 @@ pub(crate) fn composite_with_effects_prepared( let mut share = vec![0.0f32; w * h]; for (i, sh) in share.iter_mut().enumerate() { let band = (out_w + 0.5 - d[i]).clamp(0.0, 1.0); - let k = if maps.outline { - band * outline_share(shape.v[i], lay.px[i][3]) - } else if inside(shape.v[i]) { - if vector_shape { - 0.0 - } else { - // The stroke lies outside the layer's pixels. Beneath the layer it may show - // only through the part of the pixel the shape doesn't cover (1 - a); the - // layer composited on top covers c = a × fill, so the share beneath is - // (1 - a) / (1 - c). At 100 % fill that is 1 (the layer hides the rest, as - // before); at 0 % fill the interior stays clear (Fill 0 % + Outside stroke). - let c = lay.px[i][3].clamp(0.0, 1.0); - if c >= 1.0 { 1.0 } else { ((1.0 - shape.v[i].clamp(0.0, 1.0)) / (1.0 - c)).clamp(0.0, 1.0) } - } - } else { - band - }; + let k = + if inside(shape.v[i]) { if vector_shape && !maps.outline { 0.0 } else { band * outline_share(shape.v[i], lay.px[i][3]) } } else { band }; *sh = k * st.common.opacity * (1.0 - cover[i]); cover[i] += *sh; } @@ -2185,6 +2170,9 @@ pub(crate) fn composite_with_effects_prepared( /// layer, `share + l (1 - share) = (1 - cov) + l`. pub fn outline_share(cov: f32, l: f32) -> f32 { let outside = (1.0 - cov.clamp(0.0, 1.0)).max(0.0); + if outside <= 1e-6 { + return 0.0; + } let rest = 1.0 - l.clamp(0.0, 1.0); if rest <= 1e-6 { 1.0 } else { (outside / rest).min(1.0) } } diff --git a/crates/compose/src/stroke_tests.rs b/crates/compose/src/stroke_tests.rs index ab265fa208..97a0ee8c0b 100644 --- a/crates/compose/src/stroke_tests.rs +++ b/crates/compose/src/stroke_tests.rs @@ -91,6 +91,7 @@ fn outline_share_treats_stroke_and_shape_as_disjoint_areas() { // Outside the shape the stroke covers the pixel; inside it nothing. assert_eq!(effects::outline_share(0.0, 0.0), 1.0); assert_eq!(effects::outline_share(1.0, 0.3), 0.0); + assert_eq!(effects::outline_share(1.0, 1.0), 0.0); // Beneath an opaque edge pixel the result ends opaque: share + l (1 - share) = 1 - cov + l. let (cov, l) = (0.6, 0.6); let s = effects::outline_share(cov, l); @@ -247,3 +248,47 @@ fn hairline_vector_stroke_keeps_the_files_edge_pixel_colour() { assert!(close4(px(&d, 20, 20), [fill, fill, fill, 1.0]), "{sample:?} {:?}", px(&d, 20, 20)); } } + +#[test] +fn outside_stroke_on_raster_layer_does_not_paint_inside_opaque_pixels() { + let mut d = doc(40, 40); + let mut pixels = photocraft_raster::Surface::new(PixelFormat::RGBA8); + pixels.fill_rect(Rect::new(15, 15, 25, 25), &[1.0, 0.0, 0.0, 1.0]); + let mut l = Layer::new("raster", LayerContent::Raster(pixels)); + l.effects.items = vec![stroke(3.0, StrokePosition::Outside, blue())]; + d.layers.push(l); + let center = px(&d, 20, 20); + assert!(close4(center, [1.0, 0.0, 0.0, 1.0]), "interior must stay red, got: {center:?}"); + let stroke_pixel = px(&d, 13, 20); + assert!(close4(stroke_pixel, [0.0, 0.0, 1.0, 1.0]), "outside stroke must be blue, got: {stroke_pixel:?}"); +} + +#[test] +fn outside_stroke_on_zero_fill_raster_layer_keeps_interior_clear() { + let mut d = Document::new("t", Size::new(40, 40), ColorMode::Rgb, SampleType::U8); + let mut pixels = photocraft_raster::Surface::new(PixelFormat::RGBA8); + pixels.fill_rect(Rect::new(15, 15, 25, 25), &[1.0, 0.0, 0.0, 1.0]); + let mut l = Layer::new("raster", LayerContent::Raster(pixels)); + l.fill_opacity = 0.0; + l.effects.items = vec![stroke(3.0, StrokePosition::Outside, blue())]; + d.layers.push(l); + let center = px(&d, 20, 20); + assert_eq!(center[3], 0.0, "interior with 0% fill must stay clear: {center:?}"); + let stroke_pixel = px(&d, 13, 20); + assert!(close4(stroke_pixel, [0.0, 0.0, 1.0, 1.0]), "outside stroke must be blue: {stroke_pixel:?}"); +} + +#[test] +fn outside_stroke_on_partial_fill_raster_layer_keeps_interior_free_of_stroke() { + let mut d = Document::new("t", Size::new(40, 40), ColorMode::Rgb, SampleType::U8); + let mut pixels = photocraft_raster::Surface::new(PixelFormat::RGBA8); + pixels.fill_rect(Rect::new(15, 15, 25, 25), &[1.0, 0.0, 0.0, 1.0]); + let mut l = Layer::new("raster", LayerContent::Raster(pixels)); + l.fill_opacity = 0.5; + l.effects.items = vec![stroke(3.0, StrokePosition::Outside, blue())]; + d.layers.push(l); + let center = px(&d, 20, 20); + assert!(close4(center, [1.0, 0.0, 0.0, 0.5]), "interior must be 50% red: {center:?}"); + let stroke_pixel = px(&d, 13, 20); + assert!(close4(stroke_pixel, [0.0, 0.0, 1.0, 1.0]), "outside stroke must be blue: {stroke_pixel:?}"); +} From 2a003d51ea11a2dbe7cbdfb1750aa87ea4087513 Mon Sep 17 00:00:00 2001 From: Unemars <62496697+Unemars@users.noreply.github.com> Date: Sun, 18 Oct 2026 01:24:26 +0200 Subject: [PATCH 119/649] Cargo.lock: rayon for photocraft-paint Co-Authored-By: Claude Fable 5.1 --- Cargo.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.lock b/Cargo.lock index 43a4a44f65..2ed70ab879 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4913,6 +4913,7 @@ dependencies = [ "photocraft-color", "photocraft-geom", "photocraft-raster", + "rayon", "serde", "serde_json", ] From cfe8ae5c09ee88e7d19e37d16aa20e1e787fb296 Mon Sep 17 00:00:00 2001 From: Jeremy Yao Date: Sat, 17 Oct 2026 22:20:54 -0400 Subject: [PATCH 120/649] Animation Effects: plainer Linux/BSD reader - The worker thread shares its latest answer with the UI as a plain Option behind a mutex, instead of a byte that needed encode and decode helpers. - Finding the user's config directory is its own small function. - In freedesktop.rs, the two dense one-liners in without_portal are split into named steps, and the parsers are pub(super) (ini_value private): only the animations module uses them. No change in behaviour. Co-Authored-By: Claude Opus 5.5 --- apps/photocraft/src/animations.rs | 40 ++++++++----------- apps/photocraft/src/animations/freedesktop.rs | 18 +++++---- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/apps/photocraft/src/animations.rs b/apps/photocraft/src/animations.rs index bae69370b0..b6067fd25d 100644 --- a/apps/photocraft/src/animations.rs +++ b/apps/photocraft/src/animations.rs @@ -62,13 +62,12 @@ mod platform { /// `gsettings`, so a worker thread does it and the UI reads its latest answer. #[cfg(all(unix, not(target_os = "macos")))] mod platform { - use std::sync::atomic::{AtomicU8, Ordering}; - use std::sync::{Arc, OnceLock, mpsc}; + use std::sync::{Arc, Mutex, MutexGuard, OnceLock, PoisonError, mpsc}; use super::freedesktop; pub fn service() -> Option { - let latest = Arc::new(AtomicU8::new(encode(None))); + let latest = Arc::new(Mutex::new(None)); let wake: Arc> = Arc::new(OnceLock::new()); let (refresh, refreshes) = mpsc::channel::<()>(); let publisher = Publisher { latest: Arc::clone(&latest), wake: Arc::clone(&wake) }; @@ -83,7 +82,7 @@ mod platform { if focused && !was_focused { let _ = refresh.send(()); } - decode(latest.load(Ordering::Relaxed)) + *lock(&latest) })) } @@ -102,14 +101,14 @@ mod platform { /// The worker's side of the latest answer. A change wakes the UI. struct Publisher { - latest: Arc, + latest: Arc>>, wake: Arc>, } impl Publisher { fn publish(&self, animations: Option) { - let code = encode(animations); - if self.latest.swap(code, Ordering::Relaxed) != code + let previous = std::mem::replace(&mut *lock(&self.latest), animations); + if previous != animations && let Some(ctx) = self.wake.get() { ctx.request_repaint(); @@ -117,20 +116,9 @@ mod platform { } } - fn encode(animations: Option) -> u8 { - match animations { - None => 0, - Some(true) => 1, - Some(false) => 2, - } - } - - fn decode(code: u8) -> Option { - match code { - 1 => Some(true), - 2 => Some(false), - _ => None, - } + /// The latest answer; a panic elsewhere while holding it doesn't lose it. + fn lock(latest: &Mutex>) -> MutexGuard<'_, Option> { + latest.lock().unwrap_or_else(PoisonError::into_inner) } #[cfg(target_os = "linux")] @@ -230,12 +218,16 @@ mod platform { freedesktop::without_portal(&desktop, &config_file, &gsettings) } + /// `$XDG_CONFIG_HOME`, or `~/.config` when it isn't set. + fn config_home() -> Option { + let var = |key: &str| std::env::var_os(key).filter(|value| !value.is_empty()).map(PathBuf::from); + var("XDG_CONFIG_HOME").filter(|path| path.is_absolute()).or_else(|| Some(var("HOME")?.join(".config"))) + } + fn config_file(name: &str) -> Option { use std::io::Read as _; - let dir = |key: &str| std::env::var_os(key).filter(|v| !v.is_empty()).map(PathBuf::from); - let config_home = dir("XDG_CONFIG_HOME").filter(|path| path.is_absolute()).or_else(|| dir("HOME").map(|home| home.join(".config")))?; let mut text = String::new(); - std::fs::File::open(config_home.join(name)).ok()?.take(MAX_CONFIG_BYTES).read_to_string(&mut text).ok()?; + std::fs::File::open(config_home()?.join(name)).ok()?.take(MAX_CONFIG_BYTES).read_to_string(&mut text).ok()?; Some(text) } diff --git a/apps/photocraft/src/animations/freedesktop.rs b/apps/photocraft/src/animations/freedesktop.rs index 437ab5c42a..d5b4fbe626 100644 --- a/apps/photocraft/src/animations/freedesktop.rs +++ b/apps/photocraft/src/animations/freedesktop.rs @@ -4,7 +4,7 @@ //! animations are on, or `None` when the value doesn't parse (the next source is asked then). /// GSettings' and the portal's `true`/`false`, or GTK's `1`/`0`. -pub fn from_enabled(value: &str) -> Option { +pub(super) fn from_enabled(value: &str) -> Option { match value.trim().to_ascii_lowercase().as_str() { "true" | "1" => Some(true), "false" | "0" => Some(false), @@ -13,23 +13,26 @@ pub fn from_enabled(value: &str) -> Option { } /// KDE's animation speed factor: 0 turns animations off. -pub fn from_duration_factor(value: &str) -> Option { +pub(super) fn from_duration_factor(value: &str) -> Option { value.trim().parse::().ok().filter(|factor| factor.is_finite()).map(|factor| factor > 0.0) } /// The settings portal's `reduced-motion`: 1 asks for less motion; 0 and any value added later /// mean no preference. #[cfg(any(test, target_os = "linux"))] -pub fn from_reduced_motion(value: &str) -> Option { +pub(super) fn from_reduced_motion(value: &str) -> Option { value.trim().parse::().ok().map(|code| code != 1) } /// The desktop's setting when there is no settings portal to ask. `desktop` is /// `XDG_CURRENT_DESKTOP`, `config_file` reads a file in the user's config directory and /// `gsettings` runs `gsettings get `. -pub fn without_portal(desktop: &str, config_file: &dyn Fn(&str) -> Option, gsettings: &dyn Fn(&str, &str) -> Option) -> Option { +pub(super) fn without_portal(desktop: &str, config_file: &dyn Fn(&str) -> Option, gsettings: &dyn Fn(&str, &str) -> Option) -> Option { let running = |name: &str| desktop.split(':').any(|part| part.eq_ignore_ascii_case(name)); - let in_file = |file: &str, section: &str, key: &str, parse: fn(&str) -> Option| parse(ini_value(&config_file(file)?, section, key)?); + let in_file = |file: &str, section: &str, key: &str, parse: fn(&str) -> Option| { + let text = config_file(file)?; + parse(ini_value(&text, section, key)?) + }; // KDE Plasma keeps it in its own file. A kdeglobals left over from another desktop doesn't count. if running("KDE") @@ -45,11 +48,12 @@ pub fn without_portal(desktop: &str, config_file: &dyn Fn(&str) -> Option(text: &'a str, section: &str, key: &str) -> Option<&'a str> { +fn ini_value<'a>(text: &'a str, section: &str, key: &str) -> Option<&'a str> { let mut in_section = false; let mut found = None; for line in text.lines().map(str::trim) { From 47ff3a99bff56e8265b0f321b34d48b1a9fb6f21 Mon Sep 17 00:00:00 2001 From: SBaksa Date: Sun, 18 Oct 2026 17:11:35 +1100 Subject: [PATCH 121/649] CMYK ink compositing: keep layers without an alpha channel The ink compositor skipped a layer with no tiles in the rect whose default pixel was all zeros, reading the last value as alpha. A CMYK layer without an alpha channel defaults to no ink, which is opaque blank paper, so under an adjustment (Threshold, Invert, ...) its untouched pixels composited as transparent. Skip only surfaces with an alpha channel and a transparent default, as `empty_in` does. --- crates/compose/src/native.rs | 5 ++++- crates/compose/src/tests.rs | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/compose/src/native.rs b/crates/compose/src/native.rs index 31e17f3ea2..f837842920 100644 --- a/crates/compose/src/native.rs +++ b/crates/compose/src/native.rs @@ -189,7 +189,10 @@ impl<'a> InkStack<'a> { match item { Item::Layer(surf, opacity, mask) => { let opacity = *opacity; - if opacity <= 0.0 || (surf.content_bounds().intersect(&rect).is_empty() && surf.default_pixel().iter().all(|v| *v == 0.0)) { + // Nothing to draw only where the surface is transparent: without an alpha + // channel its default pixel is opaque (no ink is blank paper, not nothing). + let clear = surf.format().alpha && surf.default_pixel().last().is_some_and(|a| *a <= 0.0); + if opacity <= 0.0 || (clear && surf.content_bounds().intersect(&rect).is_empty()) { continue; } let sf = surf.format(); diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rs index ddd4871548..bad0c50e72 100644 --- a/crates/compose/src/tests.rs +++ b/crates/compose/src/tests.rs @@ -742,6 +742,19 @@ fn cmyk_ink_compositing_inlines_open_groups() { assert!(close4(px(&d, 3, 1), [c[0], c[1], c[2], 1.0]), "outside the group's layer"); } +/// A CMYK layer without an alpha channel is opaque everywhere, its untouched pixels blank paper +/// (no ink): the ink compositor keeps it under an adjustment rather than skipping it as empty. +#[test] +fn cmyk_ink_compositing_keeps_blank_paper_without_alpha() { + let mut d = Document::new("paper", Size::new(4, 4), ColorMode::Cmyk, SampleType::U8); + d.layers.push(Layer::raster("paper", PixelFormat::new(ColorMode::Cmyk, SampleType::U8, false))); + d.layers.push(Layer::new("t", LayerContent::Adjustment(Adjustment::Threshold { level: 0.5 }))); + assert!(native::render_cmyk(&d, d.bounds(), 64).is_some()); + // Paper is white, so Threshold keeps it paper. + let white = photocraft_color::convert::cmyk_to_rgb([0.0; 4]); + assert!(close4(px(&d, 2, 2), [white[0], white[1], white[2], 1.0]), "{:?}", px(&d, 2, 2)); +} + #[test] fn cmyk_document_renders_via_rgb() { let mut d = Document::new("c", Size::new(2, 2), ColorMode::Cmyk, SampleType::U8); From af08ca8df86dd3229e44f6af5e2100d8e150b995 Mon Sep 17 00:00:00 2001 From: deniskhud Date: Sun, 18 Oct 2026 08:32:05 +0200 Subject: [PATCH 122/649] Shape gradient paint: cargo fmt Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/vector_cmds/tests.rs | 7 +++++-- crates/ui-egui/src/shape_gradient_ui.rs | 15 ++++++++++++--- crates/ui-egui/src/vector_ui.rs | 12 +++++++++--- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/crates/engine/src/vector_cmds/tests.rs b/crates/engine/src/vector_cmds/tests.rs index bacd1b8869..9329d8dd27 100644 --- a/crates/engine/src/vector_cmds/tests.rs +++ b/crates/engine/src/vector_cmds/tests.rs @@ -52,7 +52,8 @@ fn gradient_stroke_round_trips_every_gradient_field() { "opacityStops": [[1.0, 0.25], [0.0, 1.0]], "midpoints": [0.25], "offset": [0.125, -0.25], "dither": true, "align": false, }}); let r = s.execute("shape.edit", json!({"layer": id, "stroke": {"color": gradient}})).unwrap(); - let Some(Fill::Gradient { stops, angle, scale, style, reverse, opacity_stops, midpoints, offset, dither, align }) = shape(&s, id).stroke.map(|st| st.paint) else { + let Some(Fill::Gradient { stops, angle, scale, style, reverse, opacity_stops, midpoints, offset, dither, align }) = shape(&s, id).stroke.map(|st| st.paint) + else { panic!("a gradient stroke") }; assert_eq!(stops, vec![(0.0, Color::rgba(0.25, 0.5, 0.75, 1.0)), (1.0, Color::rgba(1.0, 0.125, 0.0, 0.5))]); @@ -63,7 +64,9 @@ fn gradient_stroke_round_trips_every_gradient_field() { assert_eq!((g["style"].as_str(), g["midpoints"].clone(), g["align"].as_bool()), (Some("radial"), json!([0.25]), Some(false))); // A partial gradient keeps the defaults it always had. s.execute("shape.edit", json!({"layer": id, "stroke": {"color": {"gradient": {"stops": [[0, "#000000"], [1, "#ffffff"]]}}}})).unwrap(); - let Some(Fill::Gradient { opacity_stops, midpoints, offset, dither, align, .. }) = shape(&s, id).stroke.map(|st| st.paint) else { panic!("a gradient stroke") }; + let Some(Fill::Gradient { opacity_stops, midpoints, offset, dither, align, .. }) = shape(&s, id).stroke.map(|st| st.paint) else { + panic!("a gradient stroke") + }; assert_eq!((opacity_stops, midpoints, offset, dither, align), (Vec::new(), Vec::new(), (0.0, 0.0), false, true)); } diff --git a/crates/ui-egui/src/shape_gradient_ui.rs b/crates/ui-egui/src/shape_gradient_ui.rs index d0556754ce..032fbfc24b 100644 --- a/crates/ui-egui/src/shape_gradient_ui.rs +++ b/crates/ui-egui/src/shape_gradient_ui.rs @@ -281,7 +281,11 @@ fn stops_strip(ui: &mut egui::Ui, fill: &Fill, id: egui::Id, fg: [f32; 4], bg: [ let x = x_of(*loc); let sel = selected == Some(Marker::Opacity(i)); let body = Rect::from_center_size(pos2(x, bar.top() - 10.0), vec2(10.0, 10.0)); - p.add(egui::Shape::convex_polygon(vec![pos2(x, bar.top() - 1.0), pos2(x + 5.0, body.bottom()), pos2(x - 5.0, body.bottom())], outline(sel), Stroke::NONE)); + p.add(egui::Shape::convex_polygon( + vec![pos2(x, bar.top() - 1.0), pos2(x + 5.0, body.bottom()), pos2(x - 5.0, body.bottom())], + outline(sel), + Stroke::NONE, + )); p.rect_filled(body, 1.0, egui::Color32::from_gray((a.clamp(0.0, 1.0) * 255.0) as u8)); p.rect_stroke(body, 1.0, Stroke::new(1.0, outline(sel)), StrokeKind::Outside); } @@ -331,7 +335,9 @@ fn stops_strip(ui: &mut egui::Ui, fill: &Fill, id: egui::Id, fg: [f32; 4], bg: [ let moved = edit.get("location").and_then(Value::as_f64).map(|l| l as f32); let selection = match (drag.marker, edit.get("action").and_then(Value::as_str), moved) { (Marker::Color(i), Some("move"), Some(l)) => Some(Marker::Color(index_after_move(&start_cs.iter().map(|s| s.0).collect::>(), i, l))), - (Marker::Opacity(i), Some("move"), Some(l)) => Some(Marker::Opacity(index_after_move(&start_os.iter().map(|s| s.0).collect::>(), i, l))), + (Marker::Opacity(i), Some("move"), Some(l)) => { + Some(Marker::Opacity(index_after_move(&start_os.iter().map(|s| s.0).collect::>(), i, l))) + } (Marker::Mid(i), ..) => Some(Marker::Mid(i)), _ => None, }; @@ -449,7 +455,10 @@ fn stop_fields(ui: &mut egui::Ui, fill: &Fill, id: egui::Id, fg: [f32; 4], bg: [ // The stop's colour keeps its own alpha; transparency belongs to the opacity stops. let rgba = rgba_of(c); let cache = id.with(("stop-hsva", i)); - let mut hsva = ui.data(|d| d.get_temp::<([f32; 4], egui::ecolor::Hsva)>(cache)).filter(|(previous, _)| *previous == rgba).map_or_else(|| picker_color(rgba), |(_, h)| h); + let mut hsva = ui + .data(|d| d.get_temp::<([f32; 4], egui::ecolor::Hsva)>(cache)) + .filter(|(previous, _)| *previous == rgba) + .map_or_else(|| picker_color(rgba), |(_, h)| h); if egui::color_picker::color_picker_hsva_2d(ui, &mut hsva, egui::color_picker::Alpha::Opaque) { let [r, g, b, _] = picker_rgba(hsva); if [r, g, b].iter().zip(rgba).any(|(a, b)| (a - b).abs() > 0.000001) { diff --git a/crates/ui-egui/src/vector_ui.rs b/crates/ui-egui/src/vector_ui.rs index 019b301834..8bdf325071 100644 --- a/crates/ui-egui/src/vector_ui.rs +++ b/crates/ui-egui/src/vector_ui.rs @@ -1509,7 +1509,8 @@ fn swatch(ui: &mut egui::Ui, fill: Option<&photocraft_doc::Fill>, fallback: [f32 let open_key = popup_id.with("open"); let was_open = ui.data(|d| d.get_temp::(open_key)).unwrap_or(false); let open = shown.is_some(); - if was_open && !open + if was_open + && !open && let Some(g) = gradient { gradients.remember(g); @@ -1579,8 +1580,13 @@ pub fn shape_properties(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: photocra ui.horizontal(|ui| { ui.label(egui::RichText::new(tl!("Fill")).color(t.text_dim).size(12.0)); let (fg, bg) = (app.session.tools.foreground, app.session.tools.background); - let mut gradients = - GradientChoices { presets: &app.session.presets.gradients, current: &app.session.presets.gradient, recent: &mut app.ui.recent_gradients, fg, bg }; + let mut gradients = GradientChoices { + presets: &app.session.presets.gradients, + current: &app.session.presets.gradient, + recent: &mut app.ui.recent_gradients, + fg, + bg, + }; if let Some(change) = swatch(ui, sh.fill.as_ref(), fg, tl!("Set shape fill type"), &mut gradients) { let fill = match change { PaintChange::None => Value::Null, From 5306423a8e91402fe87986b31ed9a0db601cd6ed Mon Sep 17 00:00:00 2001 From: Khawar Zamman Wani Date: Sun, 18 Oct 2026 12:17:30 +0530 Subject: [PATCH 123/649] perf(retouch): releasing a Blur/Smudge/Dodge stroke takes its live pixels Releasing a Dodge, Burn, Sponge, Blur, Sharpen or Smudge stroke ran every dab of the stroke again on the UI thread (70-350 ms for a 960 px stroke on 24 MP, growing with stroke length). The Brush, Clone Stamp and History Brush already hand their live pixels to the commit; LiveDab didn't, and its preview wasn't the commit's pixels anyway: its working copy was a native-depth Surface rounded after every dab (at 8-bit a live Blur differed on 21% of pixels by up to 3 levels), the finishing dabs weren't run, and canvas points carried tilt/times the commands don't take. - LiveDab keeps its working copy in f32 tiles (WorkTiles), drops tilt and times like LiveRetouch, and into_commit runs the finishing dabs. - Session::offer_live_dab; dab_cmd takes a matching offer ("fromLive"). Refused when the brush, tool options or layer changed mid-stroke, and for Color Replacement. - mix_back leaves pixels the dabs didn't change exactly as they were. - The canvas offers the live stroke on release. Release: Blur 20/70/140/303 ms -> 0.2-0.4 ms at 50/150/300/600 px; Smudge and Dodge likewise. Live frame cost unchanged. Co-Authored-By: Claude Opus 5.5 --- .../engine/examples/bench_live_dab_release.rs | 87 ++++++++ crates/engine/src/lib.rs | 9 + crates/engine/src/retouch_cmds.rs | 186 ++++++++++++++++-- crates/engine/src/retouch_cmds/tests.rs | 113 +++++++++++ crates/paint/src/retouch.rs | 4 + crates/ui-egui/src/canvas.rs | 30 ++- crates/ui-egui/src/stroke_timing_tests.rs | 40 ++++ 7 files changed, 442 insertions(+), 27 deletions(-) create mode 100644 crates/engine/examples/bench_live_dab_release.rs diff --git a/crates/engine/examples/bench_live_dab_release.rs b/crates/engine/examples/bench_live_dab_release.rs new file mode 100644 index 0000000000..f6935d3210 --- /dev/null +++ b/crates/engine/examples/bench_live_dab_release.rs @@ -0,0 +1,87 @@ +//! Release cost of a live sequential-dab stroke on a 24 MP layer, in release mode: the commit +//! rendering the stroke again (no offer) against taking the live pixels (`offer_live_dab`, which +//! runs the finishing dabs, plus the commit). Also the live stroke's per-frame cost while drawn. +use std::time::Instant; + +use photocraft_engine::{EngineError, Session, paint::StrokePoint, retouch_cmds::LiveDab}; +use photocraft_geom::Rect; +use serde_json::json; + +const FRAMES: usize = 60; + +fn ms(t: Instant) -> f64 { + t.elapsed().as_secs_f64() * 1e3 +} + +fn run() -> Result<(), Box> { + let mut s = Session::new(); + s.execute("file.new", json!({"width":6000,"height":4000,"depth":8,"mode":"rgb"}))?; + s.execute("layer.new.layer", json!({}))?; + s.edit("stripes", |doc, active| { + let id = active.ok_or_else(|| EngineError::Other("no layer".into()))?; + let surface = doc.layer_mut(id).and_then(|l| l.surface_mut()).ok_or_else(|| EngineError::Other("no surface".into()))?; + for x in (0..6000).step_by(64) { + let c = if x % 128 == 0 { [0.9, 0.3, 0.1, 1.0] } else { [0.1, 0.4, 0.8, 1.0] }; + surface.fill_rect(Rect::new(x, 0, (x + 64).min(6000), 4000), &c); + } + Ok(()) + })?; + // ~1000 px/s at 60 fps: 16 px of drag per frame, in four samples. + let pts: Vec<[f64; 2]> = std::iter::once([1000.0, 2000.0]) + .chain((1..=FRAMES).flat_map(|f| (1..=4).map(move |k| [1000.0 + (f as f64 - 1.0) * 16.0 + k as f64 * 4.0, 2000.0]))) + .collect(); + for cmd in ["paint.blur", "paint.smudge", "paint.dodge"] { + for size in [50, 150, 300, 600] { + let p = |v: &[[f64; 2]]| json!({"points": v, "size": size, "hardness": 0, "strength": 50, "spacing": 25}); + let draw = |s: &Session| -> Result<(LiveDab, Vec), Box> { + let mut live = LiveDab::begin(s, cmd, &p(&pts[..1]))?; + let mut frames = Vec::new(); + for batch in pts[1..].chunks(4) { + let b: Vec<_> = batch.iter().map(|q| StrokePoint::new(q[0], q[1], 1.0)).collect(); + let t = Instant::now(); + live.push(&b)?; + frames.push(ms(t)); + } + Ok((live, frames)) + }; + let (mut before, mut after) = (Vec::new(), Vec::new()); + let mut frames = Vec::new(); + for _ in 0..3 { + let (_, f) = draw(&s)?; + frames.extend(f); + let t = Instant::now(); + s.execute(cmd, p(&pts))?; + before.push(ms(t)); + s.execute("edit.undo", json!({}))?; + let (live, _) = draw(&s)?; + let t = Instant::now(); + s.offer_live_dab(live)?; + let r = s.execute(cmd, p(&pts))?; + after.push(ms(t)); + if r.get("fromLive").is_none() { + return Err("the commit didn't take the live pixels".into()); + } + s.execute("edit.undo", json!({}))?; + } + before.sort_by(f64::total_cmp); + after.sort_by(f64::total_cmp); + frames.sort_by(f64::total_cmp); + let total: f64 = frames.iter().sum::() / 3.0; + println!( + "{cmd:12} size={size:4} release: render again={:7.1} ms take live={:6.1} ms | live frames: max={:6.2} ms total={:7.1} ms", + before[1], + after[1], + frames.last().copied().unwrap_or(0.0), + total + ); + } + } + Ok(()) +} + +fn main() { + if let Err(e) = run() { + eprintln!("{e}"); + std::process::exit(1); + } +} diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index b076769040..4066557692 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -672,6 +672,15 @@ impl Session { Ok(()) } + /// [`Self::offer_live_stroke`] for a live Dodge, Burn, Sponge, Blur, Sharpen or Smudge stroke, + /// taken by the command it was drawn for: the stroke's finishing dabs are run first. Refused + /// when the brush, tool options or layer changed during the stroke. + pub fn offer_live_dab(&mut self, live: retouch_cmds::LiveDab) -> Result<()> { + let commit = live.into_commit(self)?; + self.live_commit = Some(commit); + Ok(()) + } + /// Withdraw an offer the command didn't take. pub fn clear_live_stroke(&mut self) { self.live_commit = None; diff --git a/crates/engine/src/retouch_cmds.rs b/crates/engine/src/retouch_cmds.rs index 9ea7fd5975..fdbee1cb21 100644 --- a/crates/engine/src/retouch_cmds.rs +++ b/crates/engine/src/retouch_cmds.rs @@ -900,7 +900,7 @@ fn tone_range(p: &Value, cmd: &str) -> Result { /// A sequential-dab tool's settings (Dodge, Burn, Sponge, Blur, Sharpen, Smudge), parsed once and /// turned into its per-dab effect, for the commit and the live preview alike. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] enum DabTool { Tone { burn: bool, range: ToneRange, exposure: f32, protect: bool }, Sponge { saturate: bool, vibrance: bool }, @@ -1008,7 +1008,15 @@ fn dab_cmd(s: &mut Session, p: &Value, cmd: &str) -> Result { let (stroke, id) = parse_brush(s, p, cmd)?; let (tool, label) = DabTool::parse(s, cmd, p, &stroke)?; let all = matches!(tool, DabTool::Focus { .. } | DabTool::Smudge { .. }) && sample_all_layers(p); + // The live stroke the canvas already drew for exactly this commit (`LiveDab::into_commit`): + // take its pixels instead of running every dab again (the hitch on release). + let live = s.live_commit.take().filter(|l| l.matches(s, cmd, p, &stroke.points)); + let from_live = live.is_some(); let dmg = run_stroke(s, label, id, p, |pre, surf, sel, lock| { + if let Some(l) = live { + *surf = l.surface; + return Ok(l.bounds); + } let fmt = surf.format(); let mut effect = tool.effect(fmt, stroke.brush.spacing); let mut sampler = all.then(|| AllLayers::new(pre, fmt)); @@ -1017,12 +1025,93 @@ fn dab_cmd(s: &mut Session, p: &Value, cmd: &str) -> Result { None => effect(work, fp), })) })?; - Ok(json!({ "damage": damage_json(dmg) })) + let mut r = json!({ "damage": damage_json(dmg) }); + if from_live { + r["fromLive"] = json!(true); + } + Ok(r) +} + +/// Side of the tiles a live sequential-dab stroke keeps its working pixels in ([`WorkTiles`]). +const WORK_TILE: i32 = 128; + +/// The working copy of a live sequential-dab stroke: the target's native channels as `f32`, in +/// tiles copied from the pre-stroke surface the first time a dab writes to them. Unlike a +/// `Surface`, it isn't rounded to the document's depth between dabs, so each dab sees what the +/// commit's working copy (`apply_dab_stroke`) holds and the preview is the commit's pixels. +struct WorkTiles { + ch: usize, + tiles: std::collections::HashMap<(i32, i32), Vec>, +} + +impl WorkTiles { + fn new(ch: usize) -> Self { + Self { ch, tiles: std::collections::HashMap::new() } + } + + fn tile_rect((tx, ty): (i32, i32)) -> Rect { + Rect::new(tx * WORK_TILE, ty * WORK_TILE, tx * WORK_TILE + WORK_TILE, ty * WORK_TILE + WORK_TILE) + } + + /// The tiles `r` overlaps. + fn coords(r: Rect) -> impl Iterator { + let (x0, x1) = (r.x0.div_euclid(WORK_TILE), (r.x1 - 1).div_euclid(WORK_TILE)); + let (y0, y1) = (r.y0.div_euclid(WORK_TILE), (r.y1 - 1).div_euclid(WORK_TILE)); + let empty = r.is_empty(); + (y0..=y1).filter(move |_| !empty).flat_map(move |ty| (x0..=x1).map(move |tx| (tx, ty))) + } + + /// The working pixels of `r`: the pre-stroke pixels `pre` where no dab has written yet. + fn read(&self, pre: &Surface, r: Rect) -> Region { + let mut out = Region::new(r, self.ch); + let n = self.ch; + let mut buf = Vec::new(); + for c in Self::coords(r) { + let tr = Self::tile_rect(c); + let part = r.intersect(&tr); + let w = part.width() as usize * n; + let tile = self.tiles.get(&c); + if tile.is_none() { + pre.read_region_into(part, &mut buf); + } + for y in part.y0..part.y1 { + let src = match tile { + Some(t) => t.get(((y - tr.y0) * WORK_TILE + (part.x0 - tr.x0)) as usize * n..).and_then(|s| s.get(..w)), + None => buf.get((y - part.y0) as usize * w..).and_then(|s| s.get(..w)), + }; + let dst = out.index(part.x0, y) * n; + if let (Some(s), Some(d)) = (src, out.data.get_mut(dst..dst + w)) { + d.copy_from_slice(s); + } + } + } + out + } + + /// Store `region` as the working pixels of its rectangle. + fn write(&mut self, pre: &Surface, region: &Region) { + let (r, n) = (region.rect, self.ch); + for c in Self::coords(r) { + let tr = Self::tile_rect(c); + let tile = self.tiles.entry(c).or_insert_with(|| pre.read_region(tr)); + let part = r.intersect(&tr); + let w = part.width() as usize * n; + for y in part.y0..part.y1 { + let dst = ((y - tr.y0) * WORK_TILE + (part.x0 - tr.x0)) as usize * n; + let src = region.index(part.x0, y) * n; + if let (Some(s), Some(d)) = (region.data.get(src..src + w), tile.get_mut(dst..dst + w)) { + d.copy_from_slice(s); + } + } + } + } } /// A Dodge, Burn, Sponge, Blur, Sharpen or Smudge stroke shown while it is drawn: each new dab /// runs the tool's effect on a working copy of the target, in order, and the changed area is /// mixed back over the original at the brush opacity, as `apply_dab_stroke` does on release. +/// The working copy keeps full precision ([`WorkTiles`]), so the pixels are the commit's, and the +/// commit takes them over ([`Session::offer_live_dab`]) instead of running every dab again. /// Sample All Layers isn't previewed (its composite spans the whole stroke). pub struct LiveDab { /// The active document with the stroke so far. @@ -1033,7 +1122,7 @@ pub struct LiveDab { effect: DabEffect, halo: i32, pre_surf: Surface, - work: Surface, + work: WorkTiles, id: Option, params: Value, opacity: f32, @@ -1047,6 +1136,14 @@ pub struct LiveDab { preview_tail: bool, /// Where the shown tail is. tail: Rect, + /// The tool and brush the stroke started with, which its commit must still have: the + /// document revision doesn't cover the session's brush or foreground colour. `None` for + /// strokes whose commit renders itself (Color Replacement). + tool: Option<(DabTool, Box)>, + /// The document and revision the stroke started on. + base: (photocraft_doc::DocId, u64), + /// Every point rendered so far, in order. + points: Vec, } impl LiveDab { @@ -1058,8 +1155,11 @@ impl LiveDab { } let (stroke, id) = parse_brush(s, p, cmd)?; let (tool, _) = DabTool::parse(s, cmd, p, &stroke)?; - let (halo, spacing) = (tool.halo(), stroke.brush.spacing); - Self::with_effect(s, cmd, p, stroke, id, halo, |pre| tool.effect(pre.format(), spacing)) + let (halo, spacing, brush) = (tool.halo(), stroke.brush.spacing, Box::new(stroke.brush.clone())); + let effect = tool.clone(); + let mut live = Self::with_effect(s, cmd, p, stroke, id, halo, |pre| effect.effect(pre.format(), spacing))?; + live.tool = Some((tool, brush)); + Ok(live) } /// Start a live stroke of `cmd` that runs `effect` (made from the target before the stroke) @@ -1073,7 +1173,9 @@ impl LiveDab { halo: i32, effect: impl FnOnce(&Surface) -> DabEffect, ) -> Result { - let mut doc = (*s.active().ok_or(EngineError::NoDocument)?.doc).clone(); + let st = s.active().ok_or(EngineError::NoDocument)?; + let base = (st.doc.id, st.revision); + let mut doc = (*st.doc).clone(); let sel = doc.selection.clone(); let (surf, lock) = crate::channel_cmds::target_surface(&mut doc, id, p)?; let pre_surf = surf.clone(); @@ -1087,7 +1189,7 @@ impl LiveDab { done: 0, effect, halo, - work: pre_surf.clone(), + work: WorkTiles::new(pre_surf.channels()), pre_surf, id, params: p.clone(), @@ -1097,6 +1199,9 @@ impl LiveDab { bounds: Rect::EMPTY, preview_tail: false, tail: Rect::EMPTY, + tool: None, + base, + points: Vec::new(), }; live.push(&stroke.points)?; Ok(live) @@ -1114,11 +1219,9 @@ impl LiveDab { self.bounds } - /// Render more points; returns the rectangle that changed. - /// Invalid coordinates reject the whole batch without changing the preview. - pub fn push(&mut self, pts: &[StrokePoint]) -> Result { - crate::brush_cmds::check_coords(pts, &self.cmd)?; - self.renderer.push(pts); + /// Run the dabs the renderer has generated since the last call on the working copy; returns + /// the rectangle they changed. + fn run_new_dabs(&mut self) -> Rect { let ctx = self.renderer.ctx.clone(); let new: Vec<_> = self.renderer.dabs().get(self.done..).unwrap_or_default().to_vec(); let mut dmg = Rect::EMPTY; @@ -1127,19 +1230,39 @@ impl LiveDab { if r.is_empty() { continue; } - let mut region = Region::read(&self.work, r.inflate(self.halo)); + let mut region = self.work.read(&self.pre_surf, r.inflate(self.halo)); (self.effect)(&mut region, &ctx.footprint(d, self.done + k)); - region.crop(r).write(&mut self.work); + self.work.write(&self.pre_surf, ®ion.crop(r)); dmg = dmg.union(&r); } self.done += new.len(); + dmg + } + + /// Mix the working pixels of `r` back over the original into the shown document. + fn show(&mut self, r: Rect, work: &Region) -> Result<()> { + let (surf, _) = crate::channel_cmds::target_surface(std::sync::Arc::make_mut(&mut self.doc), self.id, &self.params)?; + photocraft_paint::retouch::mix_back(surf, &Region::read(&self.pre_surf, r), work, r, self.opacity, self.sel.as_ref(), self.lock); + Ok(()) + } + + /// Render more points; returns the rectangle that changed. + /// Invalid coordinates reject the whole batch without changing the preview. + /// Only the position and pressure of `pts` are used: the commands take no tilt or times. + pub fn push(&mut self, pts: &[StrokePoint]) -> Result { + crate::brush_cmds::check_coords(pts, &self.cmd)?; + let pts: Vec<_> = pts.iter().map(|q| StrokePoint::new(q.x, q.y, q.pressure)).collect(); + self.points.extend_from_slice(&pts); + self.renderer.push(&pts); + let dmg = self.run_new_dabs(); + let ctx = self.renderer.ctx.clone(); // The finishing dabs, run on a scratch copy of the working pixels. let mut tail = None; if self.preview_tail { let ds = self.renderer.tail_dabs(); let r = ds.iter().fold(Rect::EMPTY, |a, d| a.union(&ctx.dab_rect(d, false))); if !r.is_empty() { - let mut region = Region::read(&self.work, r.inflate(self.halo)); + let mut region = self.work.read(&self.pre_surf, r.inflate(self.halo)); for (k, d) in ds.iter().enumerate() { (self.effect)(&mut region, &ctx.footprint(d, self.done + k)); } @@ -1154,17 +1277,42 @@ impl LiveDab { return Ok(Rect::EMPTY); } self.bounds = self.bounds.union(&dmg).union(&tail_rect); - let (surf, _) = crate::channel_cmds::target_surface(std::sync::Arc::make_mut(&mut self.doc), self.id, &self.params)?; if !shown.is_empty() { - let (orig, work) = (Region::read(&self.pre_surf, shown), Region::read(&self.work, shown)); - photocraft_paint::retouch::mix_back(surf, &orig, &work, shown, self.opacity, self.sel.as_ref(), self.lock); + let work = self.work.read(&self.pre_surf, shown); + self.show(shown, &work)?; } if let Some((r, work)) = tail { - photocraft_paint::retouch::mix_back(surf, &Region::read(&self.pre_surf, r), &work, r, self.opacity, self.sel.as_ref(), self.lock); + self.show(r, &work)?; self.tail = r; } Ok(shown.union(&tail_rect)) } + + /// The finished stroke as its commit would take it over ([`Session::offer_live_dab`]): the + /// finishing dabs are run, and the pixels are the ones the command with the same params and + /// points paints. Only while the brush, tool settings and layer are still the ones the stroke + /// started with: the document revision doesn't cover those. + pub(crate) fn into_commit(mut self, s: &Session) -> Result { + let Some((tool, brush)) = self.tool.take() else { + return Err(bad(&self.cmd, "this stroke's commit renders itself")); + }; + let (stroke, id) = parse_brush(s, &self.params, &self.cmd)?; + let (now, _) = DabTool::parse(s, &self.cmd, &self.params, &stroke)?; + if now != tool || stroke.brush != *brush || id != self.id { + return Err(bad(&self.cmd, "the brush, tool options or layer changed during the stroke")); + } + self.renderer.finish(); + let dmg = self.run_new_dabs(); + let shown = dmg.union(&self.tail); + if !shown.is_empty() { + let work = self.work.read(&self.pre_surf, shown); + self.show(shown, &work)?; + } + self.bounds = self.bounds.union(&dmg); + let (surf, _) = crate::channel_cmds::target_surface(std::sync::Arc::make_mut(&mut self.doc), self.id, &self.params)?; + let surface = surf.clone(); + Ok(crate::brush_cmds::LiveCommit { cmd: self.cmd, base: self.base, params: self.params, seed: None, points: self.points, surface, bounds: self.bounds }) + } } /// "Sample All Layers" for Spot Healing, Blur, Sharpen and Smudge (layer pixels only: a mask or diff --git a/crates/engine/src/retouch_cmds/tests.rs b/crates/engine/src/retouch_cmds/tests.rs index e20706857a..c25228d0b4 100644 --- a/crates/engine/src/retouch_cmds/tests.rs +++ b/crates/engine/src/retouch_cmds/tests.rs @@ -1601,6 +1601,119 @@ fn live_dodge_matches_the_commit_across_cells() { assert!(worst <= 2e-4, "live and commit differ by {worst}"); } +/// The sequential-dab tools' options for the live hand-off tests. +fn dab_cases() -> [(&'static str, Value); 6] { + [ + ("paint.dodge", json!({"exposure": 60, "range": "midtones"})), + ("paint.burn", json!({"exposure": 40, "range": "shadows", "protectTones": false})), + ("paint.sponge", json!({"mode": "saturate"})), + ("paint.blur", json!({"strength": 80})), + ("paint.sharpen", json!({"strength": 60})), + ("paint.smudge", json!({"strength": 70})), + ] +} + +/// A stroke's params: `points`, a 40 px brush of `hardness`, and the tool's options. +fn dab_opts(points: &[[f64; 2]], hardness: u32, extra: &Value) -> Value { + let mut o = json!({"points": points, "size": 40, "hardness": hardness, "spacing": 25}); + for (k, v) in extra.as_object().unwrap() { + o[k] = v.clone(); + } + o +} + +/// The active layer's pixels over the whole canvas. +fn layer_pixels(s: &Session) -> Vec { + let st = s.active().unwrap(); + st.doc.layer(st.active_layer.unwrap()).unwrap().surface().unwrap().read_region(st.doc.bounds()) +} + +/// Draw `points` live as the canvas does (the first with `begin`, the rest in pen batches that +/// carry tilt and times, which the commands don't take) and offer the stroke to its commit. +fn offer_live(s: &mut Session, cmd: &str, points: &[[f64; 2]], hardness: u32, extra: &Value) { + let mut live = LiveDab::begin(s, cmd, &dab_opts(&points[..1], hardness, extra)).unwrap(); + for (i, batch) in points[1..].chunks(2).enumerate() { + let pts: Vec<_> = batch + .iter() + .map(|q| { + let mut p = StrokePoint::new(q[0], q[1], 1.0); + (p.tilt_x, p.time) = (25.0, 16.0 * i as f64); + p + }) + .collect(); + live.push(&pts).unwrap(); + } + s.offer_live_dab(live).unwrap(); +} + +/// Releasing a live Dodge, Burn, Sponge, Blur, Sharpen or Smudge stroke commits the pixels it +/// already drew instead of running every dab again, and they are exactly what the command paints +/// on its own: at every depth (the live working copy isn't rounded between dabs), soft and hard, +/// over semi-transparent pixels and where the stroke doubles back. +#[test] +fn live_dab_strokes_commit_their_pixels_and_they_are_the_commands() { + let points = [[10.0, 40.0], [100.0, 60.0], [180.0, 40.0], [60.0, 30.0], [150.0, 70.0], [151.0, 70.5], [-15.0, 85.0]]; + for depth in DEPTHS { + let mut s = session(200, 90, depth, "rgb"); + s.execute("layer.new.layer", json!({})).unwrap(); + paint_layer(&mut s, |x, y| { + let mut c = texture(x, y); + c[3] = if (x / 23 + y / 17) % 4 == 0 { 0.0 } else { 0.35 + 0.065 * ((x * 7 + y * 3) % 11) as f32 }; + c + }); + let before = layer_pixels(&s); + for (cmd, extra) in dab_cases() { + for hardness in [0, 100] { + let rendered = s.execute(cmd, dab_opts(&points, hardness, &extra)).unwrap(); + let want = layer_pixels(&s); + assert_ne!(want, before, "{cmd} {depth} {hardness}: the stroke changes pixels"); + s.execute("edit.undo", json!({})).unwrap(); + assert!(rendered.get("fromLive").is_none()); + + offer_live(&mut s, cmd, &points, hardness, &extra); + let taken = s.execute(cmd, dab_opts(&points, hardness, &extra)).unwrap(); + assert_eq!(taken["fromLive"], json!(true), "{cmd} {depth} {hardness}"); + assert_eq!(taken["damage"], rendered["damage"], "{cmd} {depth} {hardness}"); + assert!(layer_pixels(&s) == want, "{cmd} at {depth}-bit, hardness {hardness}: the live pixels aren't the command's"); + s.execute("edit.undo", json!({})).unwrap(); + assert!(layer_pixels(&s) == before, "{cmd} {depth} {hardness}: undo restores the layer"); + } + } + } +} + +/// The offer is only taken by its own stroke: another stroke, a brush or option changed during +/// the stroke, or a stroke whose commit renders itself (Color Replacement) render as before. +#[test] +fn live_dab_offers_are_refused_or_dropped_when_they_dont_match() { + let points = [[10.0, 40.0], [100.0, 60.0], [180.0, 40.0]]; + let blur = json!({"strength": 80}); + let mut s = session(200, 90, 8, "rgb"); + paint_layer(&mut s, texture); + // Another stroke drops the offer and renders itself. + offer_live(&mut s, "paint.blur", &points, 0, &blur); + let other = [[10.0, 40.0], [100.0, 61.0], [180.0, 40.0]]; + let r = s.execute("paint.blur", dab_opts(&other, 0, &blur)).unwrap(); + assert!(r.get("fromLive").is_none()); + assert!(s.live_commit.is_none(), "the offer is used up"); + s.execute("edit.undo", json!({})).unwrap(); + // The session brush (not in the params) changed during the stroke. + let live = LiveDab::begin(&s, "paint.blur", &dab_opts(&points, 0, &blur)).unwrap(); + let roundness = s.tools.brush.roundness; + s.tools.brush.roundness = roundness * 0.5; + assert!(s.offer_live_dab(live).is_err()); + s.tools.brush.roundness = roundness; + // Finger Painting's colour changed during the stroke. + let finger = json!({"strength": 70, "fingerPainting": true}); + let live = LiveDab::begin(&s, "paint.smudge", &dab_opts(&points, 0, &finger)).unwrap(); + s.tools.foreground = [0.9, 0.1, 0.1, 1.0]; + assert!(s.offer_live_dab(live).is_err()); + // Color Replacement's live stroke runs on `LiveDab` too, but its commit renders itself. + let live = crate::brush_cmds::live_color_replacement(&s, &json!({"points": points, "color": [1.0, 0.0, 0.0, 1.0]})).unwrap(); + assert!(s.offer_live_dab(live).is_err()); + assert!(s.live_commit.is_none()); +} + #[test] fn retouch_strokes_refuse_absurd_point_coordinates() { // #976: a segment to (1e300, 0) has an infinite length and the dab walker would never stop, so diff --git a/crates/paint/src/retouch.rs b/crates/paint/src/retouch.rs index 9ef837c0c0..16d52e1d5b 100644 --- a/crates/paint/src/retouch.rs +++ b/crates/paint/src/retouch.rs @@ -263,6 +263,10 @@ pub fn mix_back(target: &mut Surface, orig: &Region, work: &Region, rect: Rect, let wv = work.px(x, y); let i = out.index(x, y) * n; let o = &mut out.data[i..i + n]; + // Untouched by the dabs: keep the pixel exactly (the premultiplied mix can round it). + if *o == *wv { + continue; + } match a { // Alpha changes: mix premultiplied, so colour under transparent pixels doesn't bleed in. Some(a) if !lock_transparency => mix_premultiplied(o, wv, a, k), diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 9ca0bac7c2..a5eb6ed98f 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -755,16 +755,30 @@ pub(crate) fn live_retouch_points(app: &PhotocraftApp) -> Option = d.points.get(fed..).unwrap_or_default().iter().map(|q| photocraft_engine::paint::StrokePoint::new(q[0], q[1], q[2] as f32)).collect(); - if rest.is_empty() || live.push(&rest).is_ok() { - let _ = app.session.offer_live_retouch(live); + // A refused offer (the brush changed mid-stroke, say) leaves the commit to render the stroke. + match stroke { + EngineStroke::Retouch(mut live) if !dab => { + if rest.is_empty() || live.push(&rest).is_ok() { + let _ = app.session.offer_live_retouch(live); + } + } + EngineStroke::Dab(mut live) if dab => { + if rest.is_empty() || live.push(&rest).is_ok() { + let _ = app.session.offer_live_dab(live); + } + } + _ => {} } } @@ -5819,8 +5833,8 @@ pub(crate) fn finish_gesture(app: &mut PhotocraftApp, d: Drag) { { app.last_stroke_end = Some((st.doc.id, end)); } - // A live Clone Stamp preview ends here; the commit below replaces it (the Clone Stamp's and - // History Brush's with the pixels it already drew). + // A live retouching preview ends here; the commit below replaces it (the Clone Stamp's, + // History Brush's and sequential-dab tools' with the pixels it already drew). offer_live_retouch(app, &d); if live_retouch_command(d.tool).is_some() || crate::retouch_ui::dab_params(app, d.tool).is_some() || d.tool == Tool::ColorReplacement { app.live_stroke = None; diff --git a/crates/ui-egui/src/stroke_timing_tests.rs b/crates/ui-egui/src/stroke_timing_tests.rs index a472a4125c..e800887962 100644 --- a/crates/ui-egui/src/stroke_timing_tests.rs +++ b/crates/ui-egui/src/stroke_timing_tests.rs @@ -425,3 +425,43 @@ fn releasing_a_clone_stamp_stroke_commits_what_a_replay_paints() { assert_eq!(a.px.len(), b.px.len()); assert!(a.px.iter().zip(&b.px).all(|(x, y)| x == y), "live commit and replay differ"); } + +/// A Blur, Smudge or Dodge stroke through the canvas: releasing it commits the pixels its live +/// stroke drew (`Session::offer_live_dab`), which are what replaying the journaled command paints. +#[test] +fn releasing_a_sequential_dab_stroke_commits_what_a_replay_paints() { + for (tool, cmd) in [(Tool::Blur, "paint.blur"), (Tool::Smudge, "paint.smudge"), (Tool::Dodge, "paint.dodge")] { + let setup = |run: &mut dyn FnMut(&str, Value)| { + run("tools.setBrush", json!({"brush": {"size": 24, "hardness": 0.2}})); + run("paint.stroke", json!({"points": [[10, 20], [190, 80]], "size": 30, "hardness": 0.5, "color": "#2060c0"})); + }; + let mut h = harness(); + setup(&mut |id, p| { + h.state_mut().run(id, p).unwrap(); + }); + h.state_mut().ui.tool = tool; + h.run_steps(1); + move_to(&mut h, 40.0, 30.0); + button(&mut h, 40.0, 30.0, true); + for (x, y) in [(70.0, 40.0), (100.0, 55.0), (130.0, 50.0), (160.0, 70.0)] { + move_to(&mut h, x, y); + } + assert!(h.state().live_stroke.is_some(), "{cmd}: a live stroke"); + button(&mut h, 160.0, 70.0, false); + h.run_steps(2); + let app = h.state(); + let (_, p) = app.session.journal.iter().rev().find(|(id, _)| id == cmd).cloned().expect("a committed stroke"); + let mut fresh = photocraft_engine::Session::new(); + fresh.execute("file.new", json!({"width": 200, "height": 100, "background": "white"})).unwrap(); + setup(&mut |id, p| { + fresh.execute(id, p).unwrap(); + }); + let replayed = fresh.execute(cmd, p).unwrap(); + assert!(replayed.get("fromLive").is_none()); + let st = app.session.active().unwrap(); + let a = photocraft_compose::render(&st.doc, st.doc.bounds()); + let b = photocraft_compose::render(&fresh.active().unwrap().doc, st.doc.bounds()); + assert_eq!(a.px.len(), b.px.len()); + assert!(a.px.iter().zip(&b.px).all(|(x, y)| x == y), "{cmd}: live commit and replay differ"); + } +} From defec592030db5234ca284652c3d28243e5e9c94 Mon Sep 17 00:00:00 2001 From: Khawar Zamman Wani Date: Sun, 18 Oct 2026 12:43:51 +0530 Subject: [PATCH 124/649] review: a refused live-dab offer withdraws the previous one; test the canvas hand-off - Session::offer_live_dab clears any earlier offer before converting, so a refused offer can't leave an older one behind (test fails without it). - retouch_ui::finish_stroke records whether the commit took the live pixels (PhotocraftApp::retouch_from_live), and the ui-egui release test asserts it, so a second render on release can't pass unnoticed. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/lib.rs | 2 ++ crates/engine/src/retouch_cmds/tests.rs | 5 ++++- crates/ui-egui/src/lib.rs | 4 ++++ crates/ui-egui/src/retouch_ui.rs | 4 +++- crates/ui-egui/src/stroke_timing_tests.rs | 2 ++ 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 4066557692..ec24dab33b 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -676,6 +676,8 @@ impl Session { /// taken by the command it was drawn for: the stroke's finishing dabs are run first. Refused /// when the brush, tool options or layer changed during the stroke. pub fn offer_live_dab(&mut self, live: retouch_cmds::LiveDab) -> Result<()> { + // A refused offer withdraws the previous one too. + self.live_commit = None; let commit = live.into_commit(self)?; self.live_commit = Some(commit); Ok(()) diff --git a/crates/engine/src/retouch_cmds/tests.rs b/crates/engine/src/retouch_cmds/tests.rs index c25228d0b4..556bead4b2 100644 --- a/crates/engine/src/retouch_cmds/tests.rs +++ b/crates/engine/src/retouch_cmds/tests.rs @@ -1697,11 +1697,14 @@ fn live_dab_offers_are_refused_or_dropped_when_they_dont_match() { assert!(r.get("fromLive").is_none()); assert!(s.live_commit.is_none(), "the offer is used up"); s.execute("edit.undo", json!({})).unwrap(); - // The session brush (not in the params) changed during the stroke. + // The session brush (not in the params) changed during the stroke; the refusal also + // withdraws an earlier offer. + offer_live(&mut s, "paint.blur", &points, 0, &blur); let live = LiveDab::begin(&s, "paint.blur", &dab_opts(&points, 0, &blur)).unwrap(); let roundness = s.tools.brush.roundness; s.tools.brush.roundness = roundness * 0.5; assert!(s.offer_live_dab(live).is_err()); + assert!(s.live_commit.is_none(), "a refused offer leaves no earlier one behind"); s.tools.brush.roundness = roundness; // Finger Painting's colour changed during the stroke. let finger = json!({"strength": 70, "fingerPainting": true}); diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index e6685b9b77..a129469b1d 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -591,6 +591,9 @@ pub struct PhotocraftApp { /// A live stroke just committed with its own pixels: the canvas caches that showed it /// refresh only what it drew after the step they showed (`canvas::damage_since`). committed_stroke: Option, + /// Whether the last retouching stroke's commit took the pixels its live stroke drew + /// (`"fromLive"`) instead of rendering the stroke again (`retouch_ui::finish_stroke`). + pub(crate) retouch_from_live: bool, /// Footprint trail of a retouching drag (see `stroke_trail`). trail: Option, /// Remove tool strokes waiting to be applied together (Remove after each stroke off), the @@ -863,6 +866,7 @@ impl PhotocraftApp { tool_override: None, live_stroke: None, committed_stroke: None, + retouch_from_live: false, trail: None, remove_pending: Vec::new(), remove_pending_doc: None, diff --git a/crates/ui-egui/src/retouch_ui.rs b/crates/ui-egui/src/retouch_ui.rs index adf3c8cf69..ad9befbe81 100644 --- a/crates/ui-egui/src/retouch_ui.rs +++ b/crates/ui-egui/src/retouch_ui.rs @@ -144,7 +144,9 @@ pub fn finish_stroke(app: &mut PhotocraftApp, tool: Tool, points: &[[f64; 3]], m p["points"] = pts; // The layer mask, an alpha channel or the Quick Mask when targeted, as the Brush paints. p["target"] = crate::canvas::paint_target(app); - match app.run(cmd, p) { + let result = app.run(cmd, p); + app.retouch_from_live = matches!(&result, Ok(r) if r.get("fromLive").and_then(Value::as_bool) == Some(true)); + match result { Ok(r) if matches!(tool, Tool::Healing | Tool::CloneStamp) => { // Aligned: keep the offset for later strokes; non-aligned: every stroke restarts at the source. app.ui.clone_offset = r.get("offset").and_then(|v| serde_json::from_value(v.clone()).ok()).filter(|_| o.clone_aligned); diff --git a/crates/ui-egui/src/stroke_timing_tests.rs b/crates/ui-egui/src/stroke_timing_tests.rs index e800887962..93dd466561 100644 --- a/crates/ui-egui/src/stroke_timing_tests.rs +++ b/crates/ui-egui/src/stroke_timing_tests.rs @@ -447,9 +447,11 @@ fn releasing_a_sequential_dab_stroke_commits_what_a_replay_paints() { move_to(&mut h, x, y); } assert!(h.state().live_stroke.is_some(), "{cmd}: a live stroke"); + h.state_mut().retouch_from_live = false; button(&mut h, 160.0, 70.0, false); h.run_steps(2); let app = h.state(); + assert!(app.retouch_from_live, "{cmd}: the release took the live pixels instead of rendering the stroke again"); let (_, p) = app.session.journal.iter().rev().find(|(id, _)| id == cmd).cloned().expect("a committed stroke"); let mut fresh = photocraft_engine::Session::new(); fresh.execute("file.new", json!({"width": 200, "height": 100, "background": "white"})).unwrap(); From ce1d7576cf8a990a682b86d55964f4667d8a1f09 Mon Sep 17 00:00:00 2001 From: deniskhud Date: Sun, 18 Oct 2026 09:35:06 +0200 Subject: [PATCH 125/649] Shape gradient paint: cap gradient stop lists; keep the selected stop's colour row shape.create / shape.edit refuse more than 1024 colour stops, opacity stops or midpoints, as gradient.fill.stop does (an error, not a cut). The Gradient tab's selected stop was an index that could outlive the stops (a preset with fewer stops, another shape): the Color and Location rows vanished. An invalid selection falls back to the first colour stop, a preset or Recent pick starts there, and double-clicking a colour stop opens its colour, as in Photoshop. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/vector_cmds.rs | 17 +++++--- crates/engine/src/vector_cmds/tests.rs | 7 ++++ crates/ui-egui/src/shape_gradient_ui.rs | 53 +++++++++++++++++++++--- crates/ui-egui/src/vector_paint_tests.rs | 48 ++++++++++++++++++++- 4 files changed, 114 insertions(+), 11 deletions(-) diff --git a/crates/engine/src/vector_cmds.rs b/crates/engine/src/vector_cmds.rs index 34f2f260da..b0eb24ee69 100644 --- a/crates/engine/src/vector_cmds.rs +++ b/crates/engine/src/vector_cmds.rs @@ -255,6 +255,10 @@ fn fill_json(f: &Fill) -> Value { } } +/// The most colour stops, opacity stops or midpoints a gradient fill takes, as the gradient stop +/// edits (`gradient.fill.stop`, `gradient.presets.stop`) cap them. +const MAX_GRADIENT_STOPS: usize = 1024; + /// `"#rrggbb"` / `[r,g,b,a]` / `{"gradient":{"stops":[[t,"#hex"|[r,g,b,a]],…],"angle","scale","style","reverse", /// "opacityStops":[[t,0..1],…],"midpoints":[0..1,…],"offset":[x,y],"dither","align"}}` / `{"pattern":name,"scale"}`. /// `null` → `Ok(None)` (no fill). @@ -266,9 +270,12 @@ fn parse_fill(v: &Value) -> std::result::Result, String> { return Ok(Some(Fill::Solid(c))); } if let Some(g) = v.get("gradient") { - let stops: Vec<(f32, Color)> = g - .get("stops") - .and_then(Value::as_array) + // Stop lists are capped as `gradient.fill.stop` caps them: more is an error, not a cut. + let list = |key: &str, what: &str| match g.get(key).and_then(Value::as_array) { + Some(a) if a.len() > MAX_GRADIENT_STOPS => Err(format!("too many {what} (max {MAX_GRADIENT_STOPS})")), + a => Ok(a), + }; + let stops: Vec<(f32, Color)> = list("stops", "colour stops")? .map(|a| a.iter().filter_map(|s| Some((s.get(0)?.as_f64()? as f32, color(s.get(1)?)?))).collect()) .unwrap_or_else(|| vec![(0.0, Color::BLACK), (1.0, Color::WHITE)]); let style = match g.get("style").and_then(Value::as_str).unwrap_or("linear") { @@ -288,11 +295,11 @@ fn parse_fill(v: &Value) -> std::result::Result, String> { // The rest of a gradient, so a read-modify-write (the shape swatches) loses nothing. if let Fill::Gradient { opacity_stops, midpoints, offset, dither, align, .. } = &mut fill { let unit = |v: &Value| v.as_f64().map(|n| n.clamp(0.0, 1.0) as f32); - if let Some(a) = g.get("opacityStops").and_then(Value::as_array) { + if let Some(a) = list("opacityStops", "opacity stops")? { *opacity_stops = a.iter().filter_map(|s| Some((unit(s.get(0)?)?, unit(s.get(1)?)?))).collect(); opacity_stops.sort_by(|a, b| a.0.total_cmp(&b.0)); } - if let Some(a) = g.get("midpoints").and_then(Value::as_array) { + if let Some(a) = list("midpoints", "midpoints")? { *midpoints = a.iter().filter_map(unit).collect(); } if let Some(o) = g.get("offset") { diff --git a/crates/engine/src/vector_cmds/tests.rs b/crates/engine/src/vector_cmds/tests.rs index 9329d8dd27..654e035c76 100644 --- a/crates/engine/src/vector_cmds/tests.rs +++ b/crates/engine/src/vector_cmds/tests.rs @@ -29,6 +29,10 @@ fn stroke_validation_rejects_hostile_values_without_editing_history() { json!({"width": 0.00001, "dashes": [0.01, 0.01]}), json!({"color": {"gradient": {"offset": [0.5]}}}), json!({"color": {"gradient": {"offset": "centre"}}}), + // Stop lists past the gradient stop edits' 1024 cap are refused, not cut. + json!({"color": {"gradient": {"stops": vec![json!([0.5, "#ff0000"]); 1025]}}}), + json!({"color": {"gradient": {"opacityStops": vec![json!([0.5, 1.0]); 1025]}}}), + json!({"color": {"gradient": {"midpoints": vec![0.5; 1025]}}}), ]; for stroke in invalid { assert!(s.execute("shape.edit", json!({"layer": id, "stroke": stroke})).is_err(), "{stroke}"); @@ -38,6 +42,9 @@ fn stroke_validation_rejects_hostile_values_without_editing_history() { } assert!(s.execute("shape.edit", json!({"layer": id, "rect": [1e100, 0, 20, 20]})).is_err()); assert_eq!(s.active().unwrap().doc, before); + // The cap itself is accepted. + let at_cap = json!({"color": {"gradient": {"opacityStops": vec![json!([0.5, 1.0]); 1024], "midpoints": vec![0.5; 1024]}}}); + s.execute("shape.edit", json!({"layer": id, "stroke": at_cap})).unwrap(); } /// A gradient stroke keeps every gradient field through `shape.edit`, and `shape.info` reports diff --git a/crates/ui-egui/src/shape_gradient_ui.rs b/crates/ui-egui/src/shape_gradient_ui.rs index 032fbfc24b..915b7161c4 100644 --- a/crates/ui-egui/src/shape_gradient_ui.rs +++ b/crates/ui-egui/src/shape_gradient_ui.rs @@ -81,6 +81,7 @@ pub(super) fn gradient_tab(ui: &mut egui::Ui, fill: &Fill, choices: &GradientCho let Fill::Gradient { angle, scale, style, reverse, align, .. } = fill else { return None }; let t = Tokens::get(ui.ctx()); let mut out: Option = None; + let mut picked = false; egui::ScrollArea::vertical().id_salt(id.with("gradient-presets")).max_height(120.0).show(ui, |ui| { ui.set_width(WIDTH); let group_label = |ui: &mut egui::Ui, s: &str| ui.label(egui::RichText::new(s).color(t.text_dim).size(11.0)); @@ -95,6 +96,7 @@ pub(super) fn gradient_tab(ui: &mut egui::Ui, fill: &Fill, choices: &GradientCho resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, &name)); if resp.clicked() { take_stops(edited(&mut out, fill), recent); + picked = true; } } }); @@ -112,11 +114,16 @@ pub(super) fn gradient_tab(ui: &mut egui::Ui, fill: &Fill, choices: &GradientCho resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, &preset.name)); if resp.on_hover_text(&preset.name).clicked() { take_preset(edited(&mut out, fill), preset, choices.fg, choices.bg); + picked = true; } } }); } }); + if picked { + // New stops: start from the first colour stop, its colour row showing. + ui.data_mut(|d| d.insert_temp(selection_key(id), Marker::Color(0))); + } ui.add_space(6.0); if let Some(f) = stops_strip(ui, out.as_ref().unwrap_or(fill), id, choices.fg, choices.bg) { out = Some(f); @@ -239,6 +246,29 @@ fn apply(fill: &Fill, edit: &Value, fg: [f32; 4], bg: [f32; 4]) -> Option apply_stop(fill, edit, fg, bg).ok() } +/// Where swatch `id` keeps its selected marker. +fn selection_key(id: egui::Id) -> egui::Id { + id.with("stops-selected") +} + +/// Where swatch `id` keeps whether the selected colour stop's inline picker is open. +fn picker_key(id: egui::Id) -> egui::Id { + id.with("stop-picker-open") +} + +/// The selected marker, when it still names a stop of `fill`; else the first colour stop. The +/// marker is an index, so a preset with fewer stops, a deleted stop or another shape would +/// otherwise leave it pointing past the stops (and the stop's fields would vanish). +fn selection(ui: &egui::Ui, id: egui::Id, fill: &Fill) -> Marker { + let (cs, os, _) = sorted_stops(fill); + let valid = |m: &Marker| match *m { + Marker::Color(i) => i < cs.len(), + Marker::Opacity(i) => i < os.len(), + Marker::Mid(i) => i.saturating_add(1) < cs.len(), + }; + ui.data(|d| d.get_temp::(selection_key(id))).filter(valid).unwrap_or(Marker::Color(0)) +} + /// The stops strip: the ramp with opacity stops above and colour stops below (Photoshop's). fn stops_strip(ui: &mut egui::Ui, fill: &Fill, id: egui::Id, fg: [f32; 4], bg: [f32; 4]) -> Option { let t = Tokens::get(ui.ctx()); @@ -253,9 +283,9 @@ fn stops_strip(ui: &mut egui::Ui, fill: &Fill, id: egui::Id, fg: [f32; 4], bg: [ } ui.painter().rect_stroke(bar, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Outside); let (cs, os, mids) = sorted_stops(fill); - let (drag_key, selection_key) = (id.with("stops-drag"), id.with("stops-selected")); + let (drag_key, selection_key) = (id.with("stops-drag"), selection_key(id)); let drag: Option = ui.data(|d| d.get_temp(drag_key)); - let selected: Option = drag.as_ref().map(|d| d.marker).or_else(|| ui.data(|d| d.get_temp(selection_key))); + let selected: Option = Some(drag.as_ref().map_or_else(|| selection(ui, id, fill), |d| d.marker)); let p = ui.painter(); let outline = |sel: bool| if sel { t.accent } else { t.text_dim }; for (i, (loc, c)) in cs.iter().enumerate() { @@ -354,6 +384,19 @@ fn stops_strip(ui: &mut egui::Ui, fill: &Fill, id: egui::Id, fg: [f32; 4], bg: [ } return out; } + // Double-clicking a colour stop opens its colour, as Photoshop's opens the Color Picker. egui + // counts a click within 0.6 s of the one before last as a triple click (a preset picked just + // before), which is a double click on the stop all the same. + if (resp.double_clicked() || resp.triple_clicked()) + && let Some(pos) = resp.interact_pointer_pos() + && let Some(marker @ Marker::Color(_)) = hit(pos) + { + ui.data_mut(|d| { + d.insert_temp(selection_key, marker); + d.insert_temp(picker_key(id), true); + }); + return None; + } if resp.clicked() && let Some(pos) = resp.interact_pointer_pos() { @@ -381,8 +424,8 @@ fn stops_strip(ui: &mut egui::Ui, fill: &Fill, id: egui::Id, fg: [f32; 4], bg: [ /// from its swatch), an opacity stop's opacity, a midpoint's position; Location and Delete. fn stop_fields(ui: &mut egui::Ui, fill: &Fill, id: egui::Id, fg: [f32; 4], bg: [f32; 4]) -> Option { let t = Tokens::get(ui.ctx()); - let selection_key = id.with("stops-selected"); - let selected: Marker = ui.data(|d| d.get_temp(selection_key)).unwrap_or(Marker::Color(0)); + let selection_key = selection_key(id); + let selected = selection(ui, id, fill); let (cs, os, mids) = sorted_stops(fill); let label = |ui: &mut egui::Ui, s: &str| ui.label(egui::RichText::new(s).color(t.text_dim).size(12.0)); let mut edit: Option = None; @@ -392,7 +435,7 @@ fn stop_fields(ui: &mut egui::Ui, fill: &Fill, id: egui::Id, fg: [f32; 4], bg: [ Marker::Opacity(i) => (os.iter().map(|s| s.0).collect(), i), Marker::Mid(i) => (Vec::new(), i), }; - let picker_key = id.with("stop-picker-open"); + let picker_key = picker_key(id); let mut picker_open = ui.data(|d| d.get_temp::(picker_key)).unwrap_or(false); ui.horizontal(|ui| match selected { Marker::Color(i) => { diff --git a/crates/ui-egui/src/vector_paint_tests.rs b/crates/ui-egui/src/vector_paint_tests.rs index 8cb1c20c9d..4a8f7765b5 100644 --- a/crates/ui-egui/src/vector_paint_tests.rs +++ b/crates/ui-egui/src/vector_paint_tests.rs @@ -35,7 +35,14 @@ fn assert_saved_path(saved: &Path, original: &Path) { } fn harness(app: PhotocraftApp, properties: bool) -> Harness<'static, PhotocraftApp> { - let mut h = Harness::builder().with_size(vec2(1000.0, 700.0)).build_ui_state( + // kittest's default step: 0.25 s a frame. + harness_stepped(app, properties, 0.25) +} + +/// [`harness`] advancing `step_dt` seconds a frame (1/60 lets two clicks fall within egui's +/// 0.3 s double-click window, as they do in the app). +fn harness_stepped(app: PhotocraftApp, properties: bool, step_dt: f32) -> Harness<'static, PhotocraftApp> { + let mut h = Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(step_dt).build_ui_state( move |ui, app: &mut PhotocraftApp| { crate::screen_picker::tick(app, ui.ctx()); if !ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { @@ -535,3 +542,42 @@ fn gradient_tab_align_with_layer_and_recent_row() { h.run_steps(3); assert_eq!(h.state().ui.recent_gradients.len(), 1, "the same stops are remembered once"); } + +/// #7176 review: the selected stop is an index; after taking a preset with fewer stops it pointed +/// past them and the Color / Location rows vanished, leaving no way to recolour a stop. They stay, +/// and double-clicking a colour stop opens its colour, as Photoshop's opens the Color Picker. +#[test] +fn gradient_tab_keeps_the_stop_colour_after_a_preset_with_fewer_stops() { + let mut h = harness_stepped(app("rgb", 8), false, 1.0 / 60.0); + let strip = open_stroke_gradient(&mut h); + let (bar_left, bar_right, bar_bottom) = (strip.left() + 8.0, strip.right() - 8.0, strip.top() + 40.0); + let x_at = |loc: f32| bar_left + (bar_right - bar_left) * loc; + // Three colour stops, the last one selected. + click(&mut h, pos2(x_at(0.5), bar_bottom - 4.0)); + click(&mut h, pos2(x_at(1.0), bar_bottom + 10.0)); + assert_eq!(gradient_stops(&tool_stroke_gradient(&h)).0.len(), 3); + h.get_by_label("Blue 01").click(); + h.run_steps(3); + assert_eq!(gradient_stops(&tool_stroke_gradient(&h)).0.len(), 2); + assert!(h.query_by_label("Location").is_some(), "the selected stop's rows stay after a preset with fewer stops"); + let color_well = egui_kittest::kittest::by().label("Color").role(egui::accesskit::Role::ColorWell); + assert!(h.query(color_well).is_some()); + // Double-click the right colour stop: its picker opens, and a click in it recolours only that stop. + let stop = pos2(x_at(1.0), bar_bottom + 10.0); + h.hover_at(stop); + // A second later, so the two clicks are a double click and not a triple with the preset pick. + h.run_steps(60); + for _ in 0..2 { + pointer(&mut h, stop, true); + pointer(&mut h, stop, false); + } + h.run_steps(2); + let before = gradient_stops(&tool_stroke_gradient(&h)).0; + let swatch = h.get(egui_kittest::kittest::by().label("Color").role(egui::accesskit::Role::ColorWell)).rect(); + let field = pos2(swatch.left() + 30.0, h.get_by_label("Location").rect().bottom() + 120.0); + click(&mut h, field); + let after = gradient_stops(&tool_stroke_gradient(&h)).0; + assert_eq!(after[0], before[0], "the left stop keeps its colour"); + assert_ne!(after[1].1, before[1].1, "the double-clicked right stop is recoloured"); + assert_eq!(after[1].0, before[1].0); +} From 8fb5d94d2b121893ea7e5d8b7c62212332d70afe Mon Sep 17 00:00:00 2001 From: oRE-o <42003350+oRE-o@users.noreply.github.com> Date: Sun, 18 Oct 2026 18:36:30 +0900 Subject: [PATCH 126/649] Gradient Overlay: expose interpolation methods and retain source stops --- crates/compose/src/tests.rs | 8 +- crates/doc/src/effects.rs | 18 ++- crates/engine/src/color_cmds.rs | 7 +- crates/engine/src/layer_style.rs | 14 +- .../src/layer_style/gradient_overlay.rs | 126 ++++++++++++++++++ crates/format/tests/common/mod.rs | 7 +- crates/format/tests/roundtrip.rs | 40 ++++++ crates/gpu/tests/parity.rs | 5 +- crates/io/src/effects_map.rs | 8 +- crates/ui-egui/src/layer_style.rs | 61 ++++++++- .../src/layer_style/gradient_method_tests.rs | 64 +++++++++ crates/ui-egui/tests/support/layout_doc.rs | 1 + docs/control-protocol.md | 1 + 13 files changed, 340 insertions(+), 20 deletions(-) create mode 100644 crates/engine/src/layer_style/gradient_overlay.rs create mode 100644 crates/ui-egui/src/layer_style/gradient_method_tests.rs diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rs index ddd4871548..6588ced47b 100644 --- a/crates/compose/src/tests.rs +++ b/crates/compose/src/tests.rs @@ -1085,13 +1085,19 @@ fn glow_gradient_follows_the_shape() { #[test] fn gradient_overlay_follows_angle_and_reverse() { let g = Gradient { stops: vec![(0.0, Color::BLACK), (1.0, Color::WHITE)], angle: 0.0, ..Gradient::default() }; - let d = fx_doc(vec![Effect::GradientOverlay { common: FxCommon::new(photocraft_color::BlendMode::Normal, 1.0), gradient: g.clone(), dither: false }]); + let d = fx_doc(vec![Effect::GradientOverlay { + common: FxCommon::new(photocraft_color::BlendMode::Normal, 1.0), + gradient: g.clone(), + dither: false, + interpolation: None, + }]); let (l, r) = (px(&d, 10, 20), px(&d, 29, 20)); assert!(l[0] < 0.1 && r[0] > 0.9, "{l:?} {r:?}"); let d = fx_doc(vec![Effect::GradientOverlay { common: FxCommon::new(photocraft_color::BlendMode::Normal, 1.0), gradient: Gradient { reverse: true, style: GradientStyle::Linear, ..g }, dither: false, + interpolation: None, }]); assert!(px(&d, 10, 20)[0] > 0.9); } diff --git a/crates/doc/src/effects.rs b/crates/doc/src/effects.rs index 6ae790e26c..1f9e8a6a3c 100644 --- a/crates/doc/src/effects.rs +++ b/crates/doc/src/effects.rs @@ -37,6 +37,15 @@ pub struct Gradient { pub offset: (f32, f32), } +/// Editable colour stops behind a Gradient Overlay's baked render stops. +/// Older documents have no interpolation record and keep their existing appearance. +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct GradientInterpolation { + pub method: String, + pub smoothness: f32, + pub stops: Vec<(f32, Color)>, +} + impl Default for Gradient { fn default() -> Self { Gradient { @@ -272,6 +281,8 @@ pub enum Effect { common: FxCommon, gradient: Gradient, dither: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + interpolation: Option, }, PatternOverlay { common: FxCommon, @@ -307,7 +318,12 @@ impl Effect { Effect::OuterGlow(g) | Effect::InnerGlow(g) => paint(&mut g.paint), Effect::Stroke(s) => paint(&mut s.paint), Effect::ColorOverlay { color, .. } => cc(color), - Effect::GradientOverlay { gradient, .. } => gradient.stops.iter_mut().for_each(|s| cc(&mut s.1)), + Effect::GradientOverlay { gradient, interpolation, .. } => { + gradient.stops.iter_mut().for_each(|s| cc(&mut s.1)); + if let Some(source) = interpolation { + source.stops.iter_mut().for_each(|s| cc(&mut s.1)); + } + } Effect::Satin(s) => cc(&mut s.color), Effect::BevelEmboss(b) => { cc(&mut b.highlight_color); diff --git a/crates/engine/src/color_cmds.rs b/crates/engine/src/color_cmds.rs index d3a6d36931..9dfc5a9215 100644 --- a/crates/engine/src/color_cmds.rs +++ b/crates/engine/src/color_cmds.rs @@ -700,7 +700,12 @@ fn convert_layer_colors(l: &mut Layer, cc: &mut dyn FnMut(&mut Color)) { Effect::OuterGlow(g) | Effect::InnerGlow(g) => paint_colors(&mut g.paint, cc), Effect::Stroke(s) => paint_colors(&mut s.paint, cc), Effect::ColorOverlay { color, .. } => cc(color), - Effect::GradientOverlay { gradient, .. } => gradient.stops.iter_mut().for_each(|s| cc(&mut s.1)), + Effect::GradientOverlay { gradient, interpolation, .. } => { + gradient.stops.iter_mut().for_each(|s| cc(&mut s.1)); + if let Some(source) = interpolation { + source.stops.iter_mut().for_each(|s| cc(&mut s.1)); + } + } Effect::Satin(s) => cc(&mut s.color), Effect::BevelEmboss(b) => { cc(&mut b.highlight_color); diff --git a/crates/engine/src/layer_style.rs b/crates/engine/src/layer_style.rs index 95b5476850..5384738171 100644 --- a/crates/engine/src/layer_style.rs +++ b/crates/engine/src/layer_style.rs @@ -12,6 +12,8 @@ use crate::commands::{CommandSpec, blend_from_str}; use crate::presets::{always, bad}; use crate::{EngineError, Result, Session}; +mod gradient_overlay; + /// Parses a gradient style name (`linear`, `radial`, `angle`, `reflected`, `diamond`). pub fn gradient_style(s: &str) -> GradientStyle { match s.to_ascii_lowercase().as_str() { @@ -94,7 +96,7 @@ pub fn effect_defaults(kind: &str) -> Value { "stroke" => json!({"size": 3, "position": "outside", "blend": "Normal", "opacity": 100, "color": "#000000"}), "colorOverlay" => json!({"blend": "Normal", "color": "#ff0000", "opacity": 100}), "gradientOverlay" => { - json!({"blend": "Normal", "opacity": 100, "from": "#000000", "to": "#ffffff", "reverse": false, "style": "linear", "angle": 90, "scale": 100}) + json!({"blend": "Normal", "opacity": 100, "from": "#000000", "to": "#ffffff", "reverse": false, "style": "linear", "angle": 90, "scale": 100, "method": "custom"}) } "patternOverlay" => json!({"blend": "Normal", "opacity": 100, "pattern": "", "angle": 0, "scale": 100, "link": true}), "bevelEmboss" => { @@ -512,7 +514,9 @@ fn fresh_effect(kind: &str) -> Option { paint: FxPaint::Color(Color::rgb(1.0, 0.0, 0.0)), }), "colorOverlay" => Effect::ColorOverlay { common: FxCommon::new(BlendMode::Normal, 1.0), color: Color::rgb(1.0, 0.0, 0.0) }, - "gradientOverlay" => Effect::GradientOverlay { common: FxCommon::new(BlendMode::Normal, 1.0), gradient: Gradient::default(), dither: false }, + "gradientOverlay" => { + Effect::GradientOverlay { common: FxCommon::new(BlendMode::Normal, 1.0), gradient: Gradient::default(), dither: false, interpolation: None } + } "patternOverlay" => Effect::PatternOverlay { common: FxCommon::new(BlendMode::Normal, 1.0), name: String::new(), @@ -700,9 +704,9 @@ pub fn overlay_effect(fx: &mut Effect, p: &Value) { common(c, p); set_color(p, "color", color); } - Effect::GradientOverlay { common: c, gradient: g, dither } => { + Effect::GradientOverlay { common: c, gradient: g, dither, interpolation } => { common(c, p); - overlay_gradient(g, p); + gradient_overlay::overlay(g, interpolation, p); if let Some(x) = b_of(p, "dither") { *dither = x; } @@ -1011,7 +1015,7 @@ pub fn specs() -> Vec { style_cmd!( "gradientOverlay", "Gradient Overlay…", - r##"{"from":"#rrggbb","to":"#rrggbb","method":"classic|perceptual|linear|smooth"? (Photoshop's interpolation; omitted: straight stops),"smoothness":0..100=100,"style":"linear|radial|angle|reflected|diamond","angle":deg=90,"scale":10..150=100,"reverse":bool,"opacity":0..100,"blend":str,"add":bool}"## + r##"{"from":"#rrggbb","to":"#rrggbb","method":"classic|perceptual|linear|smooth"? (Photoshop's interpolation; omitted on new effects: straight stops; edits retain the recorded method),"smoothness":0..100=100,"style":"linear|radial|angle|reflected|diamond","angle":deg=90,"scale":10..150=100,"reverse":bool,"opacity":0..100,"blend":str,"add":bool}"## ), style_cmd!( "patternOverlay", diff --git a/crates/engine/src/layer_style/gradient_overlay.rs b/crates/engine/src/layer_style/gradient_overlay.rs new file mode 100644 index 0000000000..45b4a6d868 --- /dev/null +++ b/crates/engine/src/layer_style/gradient_overlay.rs @@ -0,0 +1,126 @@ +//! Keep editable stops separate from the dense stops used by the compositors. + +use photocraft_doc::effects::GradientInterpolation; +use photocraft_doc::{Color, Gradient}; +use serde_json::Value; + +use super::{color_of, f_of, overlay_gradient}; + +fn edit_endpoint(stop: Option<&mut (f32, Color)>, params: &Value, key: &str) { + if let (Some(stop), Some(color)) = (stop, color_of(params, key)) { + // The dialog displays hex colours. Opening it must not quantize the saved source. + if !params.get(key).is_some_and(Value::is_string) || color.to_rgba8() != stop.1.to_rgba8() { + stop.1 = color; + } + } +} + +pub(super) fn overlay(gradient: &mut Gradient, interpolation: &mut Option, params: &Value) { + let requested = params.get("method").and_then(Value::as_str).filter(|name| photocraft_io::GradientMethod::from_name(name).is_some()); + if interpolation.is_none() && requested.is_none() { + overlay_gradient(gradient, params); + return; + } + let previous = interpolation.clone(); + let source = interpolation.get_or_insert_with(|| GradientInterpolation { + method: requested.unwrap_or("classic").to_ascii_lowercase(), + smoothness: 100.0, + stops: gradient.stops.clone(), + }); + if let Some(method) = requested { + source.method = method.to_ascii_lowercase(); + } + if let Some(smoothness) = f_of(params, "smoothness").filter(|n| n.is_finite()) { + source.smoothness = smoothness.clamp(0.0, 100.0); + } + edit_endpoint(source.stops.first_mut(), params, "from"); + edit_endpoint(source.stops.last_mut(), params, "to"); + if previous.as_ref() != Some(source) + && let Some(method) = photocraft_io::GradientMethod::from_name(&source.method) + { + // Missing midpoint entries mean 50 %, including for multi-stop source gradients. + gradient.stops = photocraft_io::bake_gradient(source.stops.clone(), &[], source.smoothness / 100.0, method); + } + // Geometry edits must not replace just the ends of the baked curve. + let mut geometry = params.clone(); + if let Some(object) = geometry.as_object_mut() { + for key in ["method", "smoothness", "from", "to"] { + object.remove(key); + } + } + overlay_gradient(gradient, &geometry); +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_json::json; + + #[test] + fn changing_method_keeps_all_source_stops_and_transparency() { + let mut gradient = Gradient { + stops: vec![(0.0, Color::rgb(1.0, 0.0, 0.0)), (0.3, Color::rgb(0.0, 1.0, 0.0)), (1.0, Color::rgb(0.0, 0.0, 1.0))], + opacity_stops: vec![(0.0, 0.25), (1.0, 0.8)], + align: false, + offset: (0.2, -0.1), + ..Gradient::default() + }; + let original = gradient.clone(); + let mut source = None; + for method in ["classic", "smooth", "perceptual", "linear", "classic"] { + overlay(&mut gradient, &mut source, &json!({"method": method})); + let source = source.as_ref().unwrap(); + assert_eq!(source.method, method); + assert_eq!(source.stops, original.stops); + let expected = photocraft_io::bake_gradient(original.stops.clone(), &[0.5, 0.5], 1.0, photocraft_io::GradientMethod::from_name(method).unwrap()); + assert_eq!(gradient.stops, expected); + assert_eq!(gradient.opacity_stops, original.opacity_stops); + assert_eq!(gradient.align, original.align); + assert_eq!(gradient.offset, original.offset); + } + } + + #[test] + fn colour_edit_rebakes_the_curve_and_geometry_edits_leave_it_exact() { + let mut gradient = Gradient::default(); + let mut source = None; + overlay(&mut gradient, &mut source, &json!({"method": "smooth", "from": "#ff0000", "to": "#0000ff"})); + let before = gradient.stops.clone(); + overlay(&mut gradient, &mut source, &json!({"from": "#00ff00", "angle": 45})); + assert_ne!(gradient.stops, before); + let expected = photocraft_io::bake_gradient( + vec![(0.0, Color::rgb(0.0, 1.0, 0.0)), (1.0, Color::rgb(0.0, 0.0, 1.0))], + &[0.5], + 1.0, + photocraft_io::GradientMethod::Smooth, + ); + assert_eq!(gradient.stops, expected); + overlay(&mut gradient, &mut source, &json!({"angle": 90, "reverse": true, "scale": 75})); + assert_eq!(gradient.stops, expected); + assert_eq!(gradient.angle, 90.0); + assert!(gradient.reverse); + assert_eq!(gradient.scale, 0.75); + } + + #[test] + fn reopening_does_not_quantize_source_colours_or_rebake() { + let mut gradient = Gradient::default(); + let mut source = None; + overlay(&mut gradient, &mut source, &json!({"from": [0.123456, 0.234567, 0.345678], "method": "perceptual"})); + let before = (gradient.clone(), source.clone()); + let [r, g, b, _] = source.as_ref().unwrap().stops[0].1.to_rgba8(); + overlay(&mut gradient, &mut source, &json!({"from": format!("#{r:02x}{g:02x}{b:02x}"), "to": "#ffffff", "method": "perceptual", "smoothness": 100})); + assert_eq!((gradient, source), before); + } + + #[test] + fn old_gradients_are_unchanged_until_a_method_is_chosen() { + let mut gradient = Gradient::default(); + gradient.stops.insert(1, (0.4, Color::rgb(0.1, 0.9, 0.2))); + let original = gradient.clone(); + let mut source = None; + overlay(&mut gradient, &mut source, &json!({"method": "custom", "opacity": 50})); + assert_eq!(gradient, original); + assert!(source.is_none()); + } +} diff --git a/crates/format/tests/common/mod.rs b/crates/format/tests/common/mod.rs index 8d5641d9cd..0efa073931 100644 --- a/crates/format/tests/common/mod.rs +++ b/crates/format/tests/common/mod.rs @@ -66,7 +66,12 @@ pub fn rich_doc(mode: ColorMode, depth: SampleType) -> Document { mask.linked = false; paint.mask = Some(mask); paint.effects.items.push(Effect::ColorOverlay { common: FxCommon::new(BlendMode::Normal, 0.8), color: Color::rgb(1.0, 0.2, 0.1) }); - paint.effects.items.push(Effect::GradientOverlay { common: FxCommon::new(BlendMode::Normal, 0.8), gradient: Gradient::default(), dither: true }); + paint.effects.items.push(Effect::GradientOverlay { + common: FxCommon::new(BlendMode::Normal, 0.8), + gradient: Gradient::default(), + dither: true, + interpolation: None, + }); paint.effects.psd_raw = Some(blob(3, 64)); paint.psd_blocks.push((*b"vmsk", blob(4, 40))); paint.psd_blocks.push((*b"lnsr", blob(5, 4))); diff --git a/crates/format/tests/roundtrip.rs b/crates/format/tests/roundtrip.rs index f78e93947e..cb0b9bbf91 100644 --- a/crates/format/tests/roundtrip.rs +++ b/crates/format/tests/roundtrip.rs @@ -11,6 +11,46 @@ use photocraft_raster::Rgba8Image; const MODES: [ColorMode; 4] = [ColorMode::Rgb, ColorMode::Grayscale, ColorMode::Cmyk, ColorMode::Lab]; +#[test] +fn gradient_overlay_interpolation_roundtrips_in_native_documents() { + use photocraft_doc::effects::GradientInterpolation; + use photocraft_doc::{Color, Effect, FxCommon, Gradient}; + + for mode in MODES { + for depth in [SampleType::U8, SampleType::U16, SampleType::F32] { + let mut doc = rich_doc(mode, depth); + let source = GradientInterpolation { + method: "smooth".into(), + smoothness: 73.0, + stops: vec![(0.0, Color::rgb(0.123456, 0.4, 0.9)), (0.4, Color::WHITE), (1.0, Color::BLACK)], + }; + let effect = Effect::GradientOverlay { + common: FxCommon::new(photocraft_doc::BlendMode::Normal, 1.0), + gradient: Gradient::default(), + dither: true, + interpolation: Some(source), + } + .in_mode(mode); + doc.layers.first_mut().unwrap().effects.items.push(effect); + let bytes = save_to_bytes(&doc, &SaveOptions::default()).unwrap(); + assert_eq!(load_from_bytes(&bytes).unwrap(), doc); + } + } +} + +#[test] +fn old_effect_snapshots_need_no_interpolation_record() { + let effect = photocraft_doc::Effect::GradientOverlay { + common: photocraft_doc::FxCommon::new(photocraft_doc::BlendMode::Normal, 1.0), + gradient: photocraft_doc::Gradient::default(), + dither: false, + interpolation: None, + }; + let json = serde_json::to_value(&effect).unwrap(); + assert!(json["GradientOverlay"].get("interpolation").is_none()); + assert_eq!(serde_json::from_value::(json).unwrap(), effect); +} + #[test] fn custom_shape_stroke_roundtrip_keeps_every_style_field() { for mode in MODES { diff --git a/crates/gpu/tests/parity.rs b/crates/gpu/tests/parity.rs index 84d3d0e937..209d40bc0b 100644 --- a/crates/gpu/tests/parity.rs +++ b/crates/gpu/tests/parity.rs @@ -854,7 +854,7 @@ fn hard_stop_effects_and_gradient_maps_request_cpu() { } let paint = FxPaint::Gradient(gradient.clone()); let effects = [ - Effect::GradientOverlay { common: FxCommon::new(BlendMode::Normal, 1.0), gradient, dither: false }, + Effect::GradientOverlay { common: FxCommon::new(BlendMode::Normal, 1.0), gradient, dither: false, interpolation: None }, Effect::Stroke(StrokeFx { common: FxCommon::new(BlendMode::Normal, 1.0), size: 1.0, position: StrokePosition::Inside, paint: paint.clone() }), Effect::InnerGlow(glow(paint.clone(), GlowTechnique::Softer, 1.0, 0.0, GlowSource::Edge)), Effect::OuterGlow(glow(paint, GlowTechnique::Softer, 1.0, 0.0, GlowSource::Edge)), @@ -1464,6 +1464,7 @@ fn effect_cases() -> Vec<(&'static str, Vec)> { common: FxCommon::new(BlendMode::Normal, 0.8), gradient: Gradient { style: GradientStyle::Radial, ..gradient() }, dither: false, + interpolation: None, }], ), ( @@ -1535,7 +1536,7 @@ fn effect_cases() -> Vec<(&'static str, Vec)> { invert: false, }), Effect::ColorOverlay { common: FxCommon::new(BlendMode::SoftLight, 0.5), color: Color::rgb(0.9, 0.3, 0.2) }, - Effect::GradientOverlay { common: FxCommon::new(BlendMode::Overlay, 0.4), gradient: gradient(), dither: false }, + Effect::GradientOverlay { common: FxCommon::new(BlendMode::Overlay, 0.4), gradient: gradient(), dither: false, interpolation: None }, Effect::Stroke(stroke(3.0, StrokePosition::Outside, FxPaint::Color(Color::rgb(0.0, 0.0, 0.0)))), ], ), diff --git a/crates/io/src/effects_map.rs b/crates/io/src/effects_map.rs index 00815e2c83..cb374f9353 100644 --- a/crates/io/src/effects_map.rs +++ b/crates/io/src/effects_map.rs @@ -263,7 +263,9 @@ fn parse_one(key: &str, d: &Descriptor) -> Option { "IrGl" => Effect::InnerGlow(parse_glow(d, true)), "FrFX" => Effect::Stroke(parse_stroke(d)), "SoFi" => Effect::ColorOverlay { common: common(d, BlendMode::Normal, 1.0), color: color(d, "Clr ") }, - "GrFl" => Effect::GradientOverlay { common: common(d, BlendMode::Normal, 1.0), gradient: gradient_from(d), dither: bool_of(d, "Dthr") }, + "GrFl" => { + Effect::GradientOverlay { common: common(d, BlendMode::Normal, 1.0), gradient: gradient_from(d), dither: bool_of(d, "Dthr"), interpolation: None } + } "patternFill" => { let (name, id) = pattern_ref(d); let (angle, link, phase) = pattern_placement(d); @@ -425,7 +427,7 @@ fn write_one(e: &Effect) -> (&'static str, Descriptor) { ("FrFX", d) } Effect::ColorOverlay { common: c, color } => ("SoFi", with_common(Descriptor::new("SoFi"), c).with("Clr ", Value::Descriptor(color_to_desc(color)))), - Effect::GradientOverlay { common: c, gradient, dither } => { + Effect::GradientOverlay { common: c, gradient, dither, .. } => { ("GrFl", gradient_keys(with_common(Descriptor::new("GrFl"), c), gradient).with("Dthr", Value::Boolean(*dither))) } Effect::PatternOverlay { common: c, name, id, scale, angle, link, phase } => ( @@ -688,7 +690,7 @@ mod tests { paint: FxPaint::Gradient(g.clone()), }), Effect::ColorOverlay { common: FxCommon::new(BlendMode::Overlay, 0.5), color: Color::rgb(0.0, 0.0, 1.0) }, - Effect::GradientOverlay { common: FxCommon::new(BlendMode::Normal, 1.0), gradient: g, dither: true }, + Effect::GradientOverlay { common: FxCommon::new(BlendMode::Normal, 1.0), gradient: g, dither: true, interpolation: None }, Effect::PatternOverlay { common: FxCommon::new(BlendMode::Normal, 1.0), name: "Bubbles".into(), diff --git a/crates/ui-egui/src/layer_style.rs b/crates/ui-egui/src/layer_style.rs index d876c18278..fbc36898f2 100644 --- a/crates/ui-egui/src/layer_style.rs +++ b/crates/ui-egui/src/layer_style.rs @@ -23,6 +23,8 @@ use crate::{PhotocraftApp, widgets}; pub(crate) mod color_picker; mod contour; +#[cfg(test)] +mod gradient_method_tests; #[derive(Clone, Copy)] enum P { @@ -30,6 +32,7 @@ enum P { Color, Blend, Choice(&'static [(&'static str, &'static str)]), + GradientMethod, Check, Angle, /// A pattern from the dialog's `patternList` field (`[[id, name], …]`). @@ -153,6 +156,7 @@ fn spec(kind: &str) -> &'static [(&'static str, &'static str, P)] { ("style", "Style", P::Choice(GSTYLE)), ("angle", "Angle", P::Angle), ("scale", "Scale", P::Slider(10.0, 150.0, "%")), + ("method", "Method", P::GradientMethod), ], "patternOverlay" => &[ ("blend", "Blend Mode", P::Blend), @@ -279,14 +283,21 @@ fn values_of(e: &Effect, light: f32) -> Value { set(&mut v, "opacity", json!((common.opacity * 100.0).round())); set(&mut v, "color", json!(hex(color))); } - Effect::GradientOverlay { common, gradient: g, .. } => { + Effect::GradientOverlay { common, gradient: g, interpolation, .. } => { set(&mut v, "blend", json!(common.blend.label())); set(&mut v, "opacity", json!((common.opacity * 100.0).round())); - // The From/To fields model a plain two-stop gradient; anything richer - // (more stops, transparency stops) is carried by the snapshot instead. - if g.stops.len() == 2 && g.opacity_stops.is_empty() { - set(&mut v, "from", json!(hex(&g.stops[0].1))); - set(&mut v, "to", json!(hex(&g.stops[1].1))); + let stops = interpolation.as_ref().map_or(&g.stops, |source| &source.stops); + if let Some(source) = interpolation { + set(&mut v, "method", json!(source.method)); + set(&mut v, "smoothness", json!(source.smoothness)); + } + // Recorded interpolation exposes the original endpoint colours. Other rich + // imported curves are still carried by the snapshot, as before. + if (interpolation.is_some() || (stops.len() == 2 && g.opacity_stops.is_empty())) + && let (Some(first), Some(last)) = (stops.first(), stops.last()) + { + set(&mut v, "from", json!(hex(&first.1))); + set(&mut v, "to", json!(hex(&last.1))); set(&mut v, "reverse", json!(g.reverse)); set( &mut v, @@ -1019,6 +1030,44 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map { + ui.horizontal(|ui| { + ui.label(RichText::new(tl!("Method")).color(t.text_dim)); + let mut current = disp.get(key).and_then(Value::as_str).unwrap_or("custom").to_string(); + let mut options = vec![ + ("smooth".to_string(), "Smooth"), + ("perceptual".to_string(), "Perceptual"), + ("linear".to_string(), "Linear"), + ("classic".to_string(), "Classic"), + ]; + // Old/imported curves have no method record. Preserve them until + // the user explicitly chooses an interpolation method. + if photocraft_io::GradientMethod::from_name(¤t).is_none() { + current = "custom".into(); + options.insert(0, ("custom".into(), "Custom")); + } + if widgets::dropdown(ui, "fx-gradientOverlay-method", &mut current, &options, 150.0) { + // The older dialog deliberately omits From/To for rich imported + // curves. Once a method is chosen, show the real source ends. + let snapshot = entry(f, &selected).and_then(|e| e.get("fx")).cloned(); + if let Some(Effect::GradientOverlay { gradient, interpolation, .. }) = + snapshot.and_then(|v| serde_json::from_value::(v).ok()) + { + let stops = interpolation.as_ref().map_or(&gradient.stops, |source| &source.stops); + for (key, stop) in [("from", stops.first()), ("to", stops.last())] { + if entry(f, &selected).and_then(|e| e.get("params")).and_then(|p| p.get(key)).is_none() + && let Some(stop) = stop + { + set_param(f, &selected, key, json!(hex(&stop.1))); + } + } + } + let value = json!(current); + disp[key] = value.clone(); + set_param(f, &selected, key, value); + } + }); + } P::Pattern => { let list: Vec<(String, String)> = f .get("patternList") diff --git a/crates/ui-egui/src/layer_style/gradient_method_tests.rs b/crates/ui-egui/src/layer_style/gradient_method_tests.rs new file mode 100644 index 0000000000..52eb8b08d4 --- /dev/null +++ b/crates/ui-egui/src/layer_style/gradient_method_tests.rs @@ -0,0 +1,64 @@ +use egui_kittest::kittest::Queryable; + +use super::*; + +fn app() -> PhotocraftApp { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 32, "height": 32})).unwrap(); + app.run("layer.new.layer", json!({})).unwrap(); + app +} + +fn effect(app: &PhotocraftApp) -> &Effect { + let state = app.session.active().unwrap(); + &state.doc.layer(state.active_layer.unwrap()).unwrap().effects.items[0] +} + +fn fields(app: &PhotocraftApp) -> Map { + let state = app.session.active().unwrap(); + initial_fields(state.doc.layer(state.active_layer.unwrap()).unwrap(), Some("gradientOverlay"), 120.0) +} + +#[test] +fn method_picker_is_pending_until_confirm_and_survives_reopening() { + let mut app = app(); + app.run("layer.layerStyle.gradientOverlay", json!({"from": "#ff0000", "to": "#0000ff"})).unwrap(); + let original = effect(&app).clone(); + let pending_fields = fields(&app); + let mut harness = egui_kittest::Harness::builder() + .with_size(vec2(1000.0, 1000.0)) + .build_ui_state(|ui, state: &mut (PhotocraftApp, Map)| body(&mut state.0, ui, &mut state.1), (app, pending_fields)); + PhotocraftApp::setup_context(&harness.ctx, crate::theme::ThemeKind::ALL[0]); + harness.run_steps(3); + harness.get_by_label("Custom").click(); + harness.run_steps(2); + harness.get_by_label("Smooth").click(); + harness.run_steps(2); + assert_eq!(effect(&harness.state().0), &original, "cancel can still discard all pending edits"); + assert_eq!(harness.state().1["effects"][0]["params"]["method"], "smooth"); + let (app, pending) = harness.state_mut(); + confirm(app, pending).unwrap(); + let saved = effect(app).clone(); + app.run("edit.undo", json!({})).unwrap(); + assert_eq!(effect(app), &original); + app.run("edit.redo", json!({})).unwrap(); + assert_eq!(effect(app), &saved); + let reopened = fields(app); + assert_eq!(reopened["effects"][0]["params"]["method"], "smooth"); + assert_eq!(reopened["effects"][0]["params"]["from"], "#ff0000"); + confirm(app, &reopened).unwrap(); + assert_eq!(effect(app), &saved, "OK without edits leaves the rendered curve exact"); +} + +#[test] +fn all_four_methods_roundtrip_through_the_dialog() { + for method in ["classic", "linear", "perceptual", "smooth"] { + let mut app = app(); + app.run("layer.layerStyle.gradientOverlay", json!({"from": [0.123456, 0.234567, 0.345678], "to": "#abcdef", "method": method})).unwrap(); + let before = effect(&app).clone(); + let fields = fields(&app); + assert_eq!(fields["effects"][0]["params"]["method"], method); + confirm(&mut app, &fields).unwrap(); + assert_eq!(effect(&app), &before); + } +} diff --git a/crates/ui-egui/tests/support/layout_doc.rs b/crates/ui-egui/tests/support/layout_doc.rs index f44fac16a6..cce50ca5b9 100644 --- a/crates/ui-egui/tests/support/layout_doc.rs +++ b/crates/ui-egui/tests/support/layout_doc.rs @@ -96,6 +96,7 @@ fn gradient_overlay(a: [f32; 3], b: [f32; 3]) -> Effect { common: FxCommon::new(BlendMode::Normal, 0.6), gradient: Gradient { stops: vec![(0.0, Color::rgb(a[0], a[1], a[2])), (1.0, Color::rgb(b[0], b[1], b[2]))], angle: 90.0, ..Default::default() }, dither: false, + interpolation: None, } } diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 15334ac3a2..96200a8a73 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -67,6 +67,7 @@ The transport is `apps/photocraft/src/control_server.rs`, and the handlers are i - The shell's own dialogs (Window › Workspace › New Workspace / Delete Workspace, View › Pixel Aspect Ratio › Custom Pixel Aspect Ratio…, View › Show › Show Extras Options…, View › 32-bit Preview Options…) are listed in `ui.inspect`'s `dialogs` with the id `"shell"` (at most one is open). `ui.dialog.set`, `ui.dialog.confirm` and `ui.dialog.cancel` take `{"dialog": "shell"}`; OK runs the dialog's command and keeps the dialog open if it fails - The unsaved-changes prompt (closing a document, Revert, quitting with unsaved work) is listed in `ui.inspect`'s `dialogs` with the id `"discard"` while it is up: `fields` gives the waiting `command` (`file.close`, `file.exit`…), the `document` it asks about, how many are `remaining`, and its `choices`. `ui.dialog.confirm` takes `{"dialog": "discard", "choice": "save" | "dontSave" | "cancel"}` (default `save`; Revert takes `dontSave` or `cancel`) and answers it as the window's buttons do, one document at a time; `ui.dialog.cancel` with `{"dialog": "discard"}` cancels it. Save of an untitled document opens the save dialog first, so the reply's `fileDialog` is true and the prompt stays open until that is answered. - Layer Style (`layerStyle {effect?}` opens on that effect kind): the fields hold the dialog's whole state, so agents read and drive it like a user. `effects` lists every effect instance in the layer's order as `{id, kind, on, params, fx}` (`fx` is the effect snapshot the dialog loaded; OK edits that snapshot with `params`, so anything the dialog doesn't model survives). `selected` picks the page (`blendingOptions` or an instance id), `preview` (default on) gates the live canvas preview, `p:blendingOptions` edits blend mode/opacity/fill opacity, and `patternList` names the usable patterns. OK replaces the layer's effects in one step (`layer.layerStyle.replace`); Cancel discards. "New Style…" saves the pending state via `style.presets.new {effects}`, a swatch click applies a style preset, and Make/Reset Default use `layer.layerStyle.makeDefault` / `layer.layerStyle.defaultFor` + - Gradient Overlay exposes `params.method` (`smooth`, `perceptual`, `linear`, `classic`). `custom` denotes an existing curve without a recorded method and preserves it. Choosing a method retains the full source colour-stop list; later endpoint edits rebuild the colour curve using that method. The source stops, smoothness and method survive dialog reopening, undo/redo, style presets and native `.pcraft` saves. PSD export continues to write the baked appearance; reopening that PSD shows Custom because editable interpolation metadata is not exported yet. Opacity interpolation and the multi-stop editor are separate work. - Preferences (`ui.menu.invoke {id: "edit.preferences.interface"}`) exposes the sections in its `values` field. Apply (`ui.dialog.apply`) and OK (`ui.dialog.confirm`) on Preferences are refused over control because automation denies whole-preferences updates and filesystem-bearing preference sections. A refused `ui.dialog.apply` returns an error and keeps the dialog open; a refused `ui.dialog.confirm` returns an error but closes and removes the dialog. `ui.dialog.cancel` closes the dialog without saving. Individual safe preferences can instead be changed with `engine.execute` using `prefs.set` (e.g. `{"command": "prefs.set", "params": {"path": "interface.showTooltips", "value": false}}`). Settings marked for the next launch still require a restart. - Edit › Fill… (`ui.menu.invoke {id: "edit.fill"}`, Shift+F5, Shift+Backspace) opens the Fill dialog; its fields are `edit.fill`'s params (`contents`, `color`, `pattern`, `colorAdaptation`, `mode`, `opacity`, `preserveTransparency`), and OK remembers them in the preferences (`dialogs["edit.fill"]`). - Save for Web (`ui.menu.invoke {id: "file.export.saveForWebLegacy"}`) is resizable with independently scrolling settings. Dialog fields `__view` (`original|optimized|2up|4up`), `__zoom` (`null` = Fit, otherwise a factor; 1 = 100% in physical display pixels), and `__center: [u,v]` control the shared preview navigation. `__previewRects` reports pane rectangles in screen points. Drag a preview to pan, scroll/pinch to zoom at the pointer, or double-click to fit. GIF/PNG-8 expose `colorTable: ["#rrggbb", …]` (opaque source entries) and `colorTableEdits: {"0":"#rrggbb", …}` (zero-based replacements after quantization). A swatch opens a color picker; edits update the preview and saved file without remapping pixel indices or changing the document. Reset clears replacements. Changing palette/size/matte/transparency settings regenerates the table and clears index-based edits. Previews and generated tables use a bounded 2048-pixel proxy; full-size export uses that explicit table unchanged. `__paletteApproximate` reports proxy-derived palette generation, and enlarged proxy previews are labelled. The engine export command accepts the same table/edit parameters; its no-path estimate returns the source `colorTable` and `transparentIndex` as well as size statistics. Opening a new dialog does not carry a previous image's table across. From 27ad078860a2a894999c0c61b6731634d3177321 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Sun, 18 Oct 2026 02:47:01 -0700 Subject: [PATCH 127/649] fix(text): area type breaks at the span width divided by horizontal scale Horizontal scale is applied after shaping, so box text already breaks at the box width divided by it (#5565). Area text broke at the full span width, so widened text ran past its spans and outside the shape, and centred lines were off by the same amount. Lines now break at span / scale and the overflow check compares scaled widths. Raised in review on #6230. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01V5GRiHVR8XvTrbL1j8y9jW --- crates/text/src/layout.rs | 25 +++++++++++++++---------- crates/text/src/tests.rs | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/crates/text/src/layout.rs b/crates/text/src/layout.rs index f43209f83f..f0256986c1 100644 --- a/crates/text/src/layout.rs +++ b/crates/text/src/layout.rs @@ -658,9 +658,9 @@ impl Layouter { let (line_origin, line_len) = if vertical { (box_rect.1, box_rect.3) } else { (box_rect.0, box_rect.2) }; let avail = if is_box { Some((line_len - indent_start - indent_end).max(1.0)) } else { None }; // Horizontal scale is applied after shaping, so paragraph text breaks at the box - // width divided by it (#5565). Mixed scales break at the largest, so no line - // overflows the box. - let break_scale = if is_box { + // (or area span) width divided by it (#5565). Mixed scales break at the largest, so + // no line overflows the box. + let break_scale = if wraps { let si0 = style_at(prange.start); (0..out.styles.len()) .filter(|&ri| { @@ -698,7 +698,7 @@ impl Layouter { // out taller than the row it was planned in and no second plan is needed. layout.break_all_lines(None); let m = area_metrics(layout, &out.styles, &ps, k, first_style, vertical); - break_area(layout, a, area_from(m), m, (indent_start, indent_end), first_px, &area_budget) + break_area(layout, a, area_from(m), m, (indent_start, indent_end), first_px, break_scale, &area_budget) }; // Paragraph text: a tab is never wider than a space plus one tab interval, so breaking // lines at that width keeps the expanded tabs inside the box, but can wrap early. @@ -1198,6 +1198,10 @@ struct Need { /// later span holds overflows its span, as in a text box. Parley doesn't report a line's /// trailing whitespace while breaking, so overflowing lines are found after a pass and the /// paragraph broken again; `budget` (shared by the paragraph's calls) bounds the passes. +/// +/// Horizontal scale applies after shaping, so each line breaks at its span width divided by +/// `scale`; widths compared with spans are the scaled ones. +#[allow(clippy::too_many_arguments)] fn break_area( layout: &mut Layout, area: &crate::area::AreaShape, @@ -1205,23 +1209,24 @@ fn break_area( m: LineMetrics, indents: (f32, f32), min_width: f32, + scale: f32, budget: &std::cell::Cell, ) -> (Vec, bool) { let inset = indents.0 + indents.1; let mut rows = AreaRows { area, m, min_width, next: from, rows: Vec::new(), done: false }; let mut needs: Vec = Vec::new(); loop { - let (slots, overflow) = break_area_pass(layout, &mut rows, inset, &needs); + let (slots, overflow) = break_area_pass(layout, &mut rows, inset, scale, &needs); budget.set(budget.get().saturating_sub(1)); if budget.get() == 0 { return (slots, overflow); } - // Each line's text start and width without its trailing whitespace. + // Each line's text start and scaled width without its trailing whitespace. let lines: Vec<(usize, f32)> = layout .lines() .map(|l| { let lm = l.metrics(); - (l.text_range().start, lm.advance - lm.trailing_whitespace) + (l.text_range().start, (lm.advance - lm.trailing_whitespace) * scale) }) .collect(); // A line that now starts elsewhere (an earlier line changed) no longer needs its span. @@ -1246,7 +1251,7 @@ fn break_area( /// One pass of [`break_area`]: each line in the next span, skipping spans too narrow for a /// line in `needs` when a later span holds it. -fn break_area_pass(layout: &mut Layout, rows: &mut AreaRows<'_>, inset: f32, needs: &[Need]) -> (Vec, bool) { +fn break_area_pass(layout: &mut Layout, rows: &mut AreaRows<'_>, inset: f32, scale: f32, needs: &[Need]) -> (Vec, bool) { #[cfg(test)] AREA_PASSES.with(|c| c.set(c.get() + 1)); let mut slots: Vec = Vec::new(); @@ -1275,12 +1280,12 @@ fn break_area_pass(layout: &mut Layout, rows: &mut AreaRows<'_>, inset (row, span) = (r, j); continue; } - br.state_mut().set_line_max_advance(width); + br.state_mut().set_line_max_advance(width / scale); if br.break_next().is_none() { break; } // Parley aligns each line within the width it was broken at. - br.set_prior_line_width(width); + br.set_prior_line_width(width / scale); slots.push(Slot { baseline, x: x0, width, row, span }); span += 1; } diff --git a/crates/text/src/tests.rs b/crates/text/src/tests.rs index ef07037208..5672f3728b 100644 --- a/crates/text/src/tests.rs +++ b/crates/text/src/tests.rs @@ -2125,6 +2125,27 @@ fn area_lines_center_in_their_span() { } } +/// Horizontal scale applies after shaping, so area lines break at the span width divided by it: +/// widened text stays inside the shape and centred lines stay centred (#5565). +#[test] +fn horizontally_scaled_area_text_stays_inside_its_spans() { + let mut e = TextEngine::new(); + let style = CharStyle { font_family: "Inter".into(), size_pt: 12.0, horizontal_scale: 1.5, ..Default::default() }; + let mut t = styled(BUBBLE_TEXT, style); + let path = area_ellipse(0.0, 0.0, 240.0, 200.0); + t.shape = TextShape::Area { path: path.clone() }; + let l = e.layout(&t, 72.0); + assert!(l.lines.len() >= 3, "{:?}", l.lines); + assert_lines_inside(&l, &path); + t.paragraphs = vec![ParagraphRun { len: t.text.len(), style: ParagraphStyle { align: TextAlign::Center, ..Default::default() } }]; + t.shape = TextShape::Area { path: area_poly(&[(100.0, 0.0), (200.0, 100.0), (100.0, 200.0), (0.0, 100.0)]) }; + let l = e.layout(&t, 72.0); + assert!(l.lines.len() >= 2, "{:?}", l.lines); + for line in &l.lines { + assert!(((line.x0 + line.x1) / 2.0 - 100.0).abs() < 1.5, "{line:?}"); + } +} + #[test] fn area_rows_split_around_a_hole() { use photocraft_doc::vector::{PathOp, Subpath}; From 80e3ea0be5c2c27c5e0ad0a9765807c8a0fa18b0 Mon Sep 17 00:00:00 2001 From: PanPDX Date: Sun, 18 Oct 2026 02:47:42 -0700 Subject: [PATCH 128/649] test(engine): refused type.fillPath calls leave history and the layer alone Bad params, a non-shape layer and a locked layer only checked is_err(); a failure path that wrote the shape or a history step first would have passed. Raised in review on #6230. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01V5GRiHVR8XvTrbL1j8y9jW --- crates/engine/src/type_area_cmds/tests.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/type_area_cmds/tests.rs b/crates/engine/src/type_area_cmds/tests.rs index ffc154968f..daa60edc25 100644 --- a/crates/engine/src/type_area_cmds/tests.rs +++ b/crates/engine/src/type_area_cmds/tests.rs @@ -103,15 +103,20 @@ fn fill_path_rejects_bad_paths_without_history() { assert_eq!(history(&s), h, "no history step on error"); assert_eq!(text(&s, id).shape, TextShape::Point); } - for p in [json!({"shape": "x"}), json!({"shape": u64::MAX}), json!({"layer": u64::MAX})] { - assert!(s.execute("type.fillPath", p).is_err()); + // Bad params, a shape param that is not a shape layer, and a locked layer: each refused + // without a history step or a change to the layer. + let refused = |s: &mut Session, p: serde_json::Value| { + let h = history(s); + assert!(s.execute("type.fillPath", p.clone()).is_err(), "{p}"); + assert_eq!(history(s), h, "no history step on error: {p}"); + assert_eq!(text(s, id).shape, TextShape::Point, "{p}"); + }; + for p in [json!({"shape": "x"}), json!({"shape": u64::MAX}), json!({"layer": u64::MAX}), json!({"shape": id.0})] { + refused(&mut s, p); } - // A shape param that is not a shape layer. - assert!(s.execute("type.fillPath", json!({"shape": id.0})).is_err()); - // Locked layer. set_work_path(&mut s, Path::new(vec![Subpath::polygon(&[(0.0, 0.0), (200.0, 0.0), (200.0, 200.0)])])); s.execute("layer.setProps", json!({"layer": id.0, "locked": true})).unwrap(); - assert!(s.execute("type.fillPath", json!({})).is_err()); + refused(&mut s, json!({})); } #[test] From f89ce5ce073fbc49b6f648f26eb4dfa15336ae94 Mon Sep 17 00:00:00 2001 From: Khawar Zamman Wani Date: Sun, 18 Oct 2026 15:52:34 +0530 Subject: [PATCH 129/649] Color panel state: still read Only Web Colors under its old web_only key (#6000) Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/color_panel_tests.rs | 9 +++++++++ crates/ui-egui/src/state.rs | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/color_panel_tests.rs b/crates/ui-egui/src/color_panel_tests.rs index 65239d6a19..1152561d9f 100644 --- a/crates/ui-egui/src/color_panel_tests.rs +++ b/crates/ui-egui/src/color_panel_tests.rs @@ -326,3 +326,12 @@ fn control_sets_the_mode_ramp_and_web_safe_ramp() { assert_eq!(app.ui.color_panel, cp, "{bad}: nothing changes"); } } + +/// Only Web Colors is `webOnly` now that the state is camelCase; state saved before still loads. +#[test] +fn web_only_reads_its_old_snake_case_key() { + let old: crate::state::ColorPanelState = serde_json::from_value(json!({"background": true, "web_only": true})).unwrap(); + assert!(old.background && old.web_only); + let new = serde_json::to_value(old).unwrap(); + assert_eq!((new.get("webOnly"), new.get("web_only")), (Some(&json!(true)), None)); +} diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 07c49f9098..8f1adf3ece 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -1054,8 +1054,9 @@ pub struct DockTabs { pub struct ColorPanelState { /// The panel edits the background colour (its chip was clicked), not the foreground. pub background: bool, - /// Color Picker › Only Web Colors, kept across opens like Photoshop (#4995). - #[serde(default)] + /// Color Picker › Only Web Colors, kept across opens like Photoshop (#4995). `web_only` is + /// its name before the camelCase rename (#6000). + #[serde(default, alias = "web_only")] pub web_only: bool, /// What the panel shows, picked from its panel menu as in Photoshop (#6000). pub mode: ColorPanelMode, From 9e1310edb94b004dfaeae1f2107e7becd94eefe9 Mon Sep 17 00:00:00 2001 From: oRE-o <42003350+oRE-o@users.noreply.github.com> Date: Sun, 18 Oct 2026 19:30:05 +0900 Subject: [PATCH 130/649] Preserve endpoint colour metadata and restore factory interpolation --- .../src/layer_style/gradient_overlay.rs | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/layer_style/gradient_overlay.rs b/crates/engine/src/layer_style/gradient_overlay.rs index 45b4a6d868..e46109d86f 100644 --- a/crates/engine/src/layer_style/gradient_overlay.rs +++ b/crates/engine/src/layer_style/gradient_overlay.rs @@ -9,13 +9,25 @@ use super::{color_of, f_of, overlay_gradient}; fn edit_endpoint(stop: Option<&mut (f32, Color)>, params: &Value, key: &str) { if let (Some(stop), Some(color)) = (stop, color_of(params, key)) { // The dialog displays hex colours. Opening it must not quantize the saved source. - if !params.get(key).is_some_and(Value::is_string) || color.to_rgba8() != stop.1.to_rgba8() { - stop.1 = color; + let [r, g, b, _] = color.to_rgba8(); + let [sr, sg, sb, _] = stop.1.to_rgba8(); + if !params.get(key).is_some_and(Value::is_string) || [r, g, b] != [sr, sg, sb] { + let mut edited = color.in_mode(stop.1.mode); + edited.alpha = stop.1.alpha; + stop.1 = edited; } } } pub(super) fn overlay(gradient: &mut Gradient, interpolation: &mut Option, params: &Value) { + // Reset to Default restores the factory's unbaked interpolation too. + if params.get("method").and_then(Value::as_str) == Some("custom") { + if let Some(source) = interpolation.take() { + gradient.stops = source.stops; + } + overlay_gradient(gradient, params); + return; + } let requested = params.get("method").and_then(Value::as_str).filter(|name| photocraft_io::GradientMethod::from_name(name).is_some()); if interpolation.is_none() && requested.is_none() { overlay_gradient(gradient, params); @@ -105,9 +117,11 @@ mod tests { #[test] fn reopening_does_not_quantize_source_colours_or_rebake() { let mut gradient = Gradient::default(); + gradient.stops[0].1.alpha = 0.37; let mut source = None; overlay(&mut gradient, &mut source, &json!({"from": [0.123456, 0.234567, 0.345678], "method": "perceptual"})); let before = (gradient.clone(), source.clone()); + assert_eq!(source.as_ref().unwrap().stops[0].1.alpha, 0.37); let [r, g, b, _] = source.as_ref().unwrap().stops[0].1.to_rgba8(); overlay(&mut gradient, &mut source, &json!({"from": format!("#{r:02x}{g:02x}{b:02x}"), "to": "#ffffff", "method": "perceptual", "smoothness": 100})); assert_eq!((gradient, source), before); @@ -123,4 +137,25 @@ mod tests { assert_eq!(gradient, original); assert!(source.is_none()); } + + #[test] + fn endpoint_edits_keep_the_source_colour_model() { + for mode in [photocraft_doc::ColorMode::Grayscale, photocraft_doc::ColorMode::Cmyk, photocraft_doc::ColorMode::Lab] { + let mut gradient = Gradient { stops: vec![(0.0, Color::BLACK.in_mode(mode)), (1.0, Color::WHITE.in_mode(mode))], ..Gradient::default() }; + let mut source = None; + overlay(&mut gradient, &mut source, &json!({"method": "classic"})); + overlay(&mut gradient, &mut source, &json!({"from": "#ff0000"})); + assert!(source.as_ref().unwrap().stops.iter().all(|s| s.1.mode == mode)); + } + } + + #[test] + fn reset_to_factory_defaults_removes_the_recorded_method() { + let mut gradient = Gradient::default(); + let mut source = None; + overlay(&mut gradient, &mut source, &json!({"method": "smooth", "from": "#ff0000"})); + overlay(&mut gradient, &mut source, &super::super::effect_defaults("gradientOverlay")); + assert!(source.is_none()); + assert_eq!(gradient, Gradient::default()); + } } From e85d8b244216b4a9072b6b592112ce9cca607840 Mon Sep 17 00:00:00 2001 From: oRE-o <42003350+oRE-o@users.noreply.github.com> Date: Sun, 18 Oct 2026 19:46:05 +0900 Subject: [PATCH 131/649] Set up the Layer Style UI regression before interacting with its Method combo --- .../src/layer_style/gradient_method_tests.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/layer_style/gradient_method_tests.rs b/crates/ui-egui/src/layer_style/gradient_method_tests.rs index 52eb8b08d4..ef5d062f9a 100644 --- a/crates/ui-egui/src/layer_style/gradient_method_tests.rs +++ b/crates/ui-egui/src/layer_style/gradient_method_tests.rs @@ -25,12 +25,18 @@ fn method_picker_is_pending_until_confirm_and_survives_reopening() { app.run("layer.layerStyle.gradientOverlay", json!({"from": "#ff0000", "to": "#0000ff"})).unwrap(); let original = effect(&app).clone(); let pending_fields = fields(&app); - let mut harness = egui_kittest::Harness::builder() - .with_size(vec2(1000.0, 1000.0)) - .build_ui_state(|ui, state: &mut (PhotocraftApp, Map)| body(&mut state.0, ui, &mut state.1), (app, pending_fields)); + let mut harness = egui_kittest::Harness::builder().with_size(vec2(1000.0, 1000.0)).build_ui_state( + |ui, state: &mut (PhotocraftApp, Map)| { + // The harness draws once before setup_context installs the app fonts. + if ui.ctx().fonts(|fonts| fonts.families().contains(&egui::FontFamily::Name("semibold".into()))) { + body(&mut state.0, ui, &mut state.1); + } + }, + (app, pending_fields), + ); PhotocraftApp::setup_context(&harness.ctx, crate::theme::ThemeKind::ALL[0]); harness.run_steps(3); - harness.get_by_label("Custom").click(); + harness.get_by_value("Custom").click(); harness.run_steps(2); harness.get_by_label("Smooth").click(); harness.run_steps(2); From 445e645ea1d2064964bc64fd3034349290246645 Mon Sep 17 00:00:00 2001 From: oRE-o <42003350+oRE-o@users.noreply.github.com> Date: Sun, 18 Oct 2026 20:14:14 +0900 Subject: [PATCH 132/649] Translate the Method label in the Chinese catalogs --- crates/ui-egui/src/i18n/zh-hans.tsv | 1 + crates/ui-egui/src/i18n/zh-hant.tsv | 1 + 2 files changed, 2 insertions(+) diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 01e0d57051..e5491208e2 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2798,6 +2798,7 @@ curves Smooth 平滑 Darken Interface 界面变暗 Lighten Interface 界面变亮 # Bevel & Emboss Technique. + Method 方法 Technique 方法 Chisel Hard 雕刻清晰 Chisel Soft 雕刻柔和 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 2d9ad2905a..db9190916c 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2783,6 +2783,7 @@ curves Smooth 平滑 Darken Interface 介面變暗 Lighten Interface 介面變亮 # Bevel & Emboss Technique. + Method 方法 Technique 方法 Chisel Hard 雕刻清晰 Chisel Soft 雕刻柔和 From 7cd48cbaa3950f5826b820a044752df8bf0d32f0 Mon Sep 17 00:00:00 2001 From: oRE-o <42003350+oRE-o@users.noreply.github.com> Date: Sun, 18 Oct 2026 20:26:18 +0900 Subject: [PATCH 133/649] Document the Gradient Overlay Method control with offscreen captures --- ATTRIBUTION.md | 1 + docs/images/gradient-overlay-method-after.png | Bin 0 -> 166597 bytes docs/images/gradient-overlay-method-before.png | Bin 0 -> 168477 bytes .../images/gradient-overlay-method-options.png | Bin 0 -> 168079 bytes 4 files changed, 1 insertion(+) create mode 100644 docs/images/gradient-overlay-method-after.png create mode 100644 docs/images/gradient-overlay-method-before.png create mode 100644 docs/images/gradient-overlay-method-options.png diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index cbbbe069a5..3a139e0328 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -84,6 +84,7 @@ The other built-in ICC profiles and the generated LUT looks are produced by code | `docs/brand/` (all files) | ArtCraft name, wordmark and mark | ArtCraft Team | getartcraft.com | Not open source; trademarks of the ArtCraft Team, [`docs/brand/LICENSE-brand.txt`](docs/brand/LICENSE-brand.txt) | | `docs/images/photocraft-*.jpg` | PhotoCraft screenshots | PhotoCraft contributors (UI) | Rendered offscreen with the `snapshot` example | MIT OR Apache-2.0 (UI); the artwork in each is public domain, listed below | | `docs/images/preferences-apply-*.png` | Preferences before and after adding Apply (no artwork) | PhotoCraft contributors | PhotoCraft control-channel capture and offscreen `snapshot` example | MIT OR Apache-2.0 | +| `docs/images/gradient-overlay-method-*.png` | Gradient Overlay Method selector, before and after (synthetic gradient) | @oRE-o | Rendered offscreen with the `snapshot` example; no external artwork | MIT OR Apache-2.0 | Artwork shown in the screenshots (all public domain, via Wikimedia Commons; details in [`docs/images/SOURCES.md`](docs/images/SOURCES.md)): diff --git a/docs/images/gradient-overlay-method-after.png b/docs/images/gradient-overlay-method-after.png new file mode 100644 index 0000000000000000000000000000000000000000..8d6107e7ab20fb01346f7b0dc273ca13a0efa6cf GIT binary patch literal 166597 zcmceRSP-H5Yn$|X>vcv;2wL6fRky%n6pfYtADk>Qu!whQXDJ3;C zQ^9hpZGDx@6w!gfBc7)+MFSbmqaw@w_OS|&-2{( zeO>EXYhBl~4@i^c|9ed zzA$i8pSQj^Zc~yQmY+DYZT84XyQY`yyY+wXf135hOF3Cj4D8k5`Y88K<^2Eqt8Zpscq4Y=od5iXGIY=7PnR$6@WIXr zO-j*|qq_I#u{$m&wd3f&zBJvM%hQfe8&p-`ZkUueVfF8pES)q zyDX#p`J10d>%vtL19Zz<7Fmqm%80V1#g~gb)$QZ`;)}ex!S6=_7OTy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ev>s4 zV!U?h&X@j;V>iS^&p>Bjw%EtvXSu52XRAR_ z&;=fB3wvf*eRmhQ4;o6Q3ekTYieADuXZ_BFe52<^l(UW$Oa6vp0OO`6ATj8Frthc^lmEhQYR1@AvGx;Uw_z8 z`YNeOD!oXhUe$Csl}^U~Q$cwGD3B!N{;5moZosGR%vVMYc{r7#5v(@PQ$Pamreu~O zmZph1nALlo)YL}QUcuIB$wv4joqhUgBYSUrwl6a_YMQtac`@#Pm`^3A<4^LK!J>!o2~LxxkTmhzYkB1uG5oVem;D^8=ZH=#96y}?>BAc8 z4oT+5ylvpQdm~oD&p@_%+d?~(jHS8C@~J$d>6caBK5K_ME;L%=w!!akjkcB6 zn9#)n(h>p0pVrgrZO1^Oe&?MdnJ--aH@^Da-uy3MaqhsI#^w%)kG`$Oz<;8KJ~-r) I!4u~FFV4-htN;K2 literal 0 HcmV?d00001 diff --git a/docs/images/gradient-overlay-method-options.png b/docs/images/gradient-overlay-method-options.png new file mode 100644 index 0000000000000000000000000000000000000000..1c7aaed68c766272a6be6f692f29f8d95ce08c8d GIT binary patch literal 168079 zcmceRSP-H5Yn$|X>vcv;2wL6fRky%n6pfYtADk>Qu!whQXDJ3;C zQ^9hpZGDx@6w!gfBc7)+MFSbmqaw@w_OS|&-2{( zeO>EXYhBl~K<^2Eqt8Zpscq4Y=od5iXGIY=7PnR$6@WIXr zO-j*|qq_I#u{$m&wd3f&zBJvM%hQfe8&p-`ZkUueVfF8pES)q zyDX#p`J10d>%vtL19Zz<7Fmqm%80V1#g~gb)$QZ`;)}ex!S6=_7OTy?S$V}#G5$! zrLXrMzr9FJ2IG;?=Ep*P)p5(!)jeWv>mEq@>N0gnwO`RKNskSIS3mzRl zM)$zqm6vj_eALg>G(G;vV|RHDhx_hNbhgb2EG#m(?lv{|Fc}l{E&c7^Mn`>`<6IDA z&kMJY>7G^}T(eeN6Op;yY z?3(&w?SL@HtgxaSr6tE6p|eM*^i{(OdWSc^8-6_LVEw)l=L(DS?kLx4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: [PATCH 134/649] Clarify Gradient Overlay source loss when saving styles --- docs/control-protocol.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 96200a8a73..453db7d13a 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -67,7 +67,7 @@ The transport is `apps/photocraft/src/control_server.rs`, and the handlers are i - The shell's own dialogs (Window › Workspace › New Workspace / Delete Workspace, View › Pixel Aspect Ratio › Custom Pixel Aspect Ratio…, View › Show › Show Extras Options…, View › 32-bit Preview Options…) are listed in `ui.inspect`'s `dialogs` with the id `"shell"` (at most one is open). `ui.dialog.set`, `ui.dialog.confirm` and `ui.dialog.cancel` take `{"dialog": "shell"}`; OK runs the dialog's command and keeps the dialog open if it fails - The unsaved-changes prompt (closing a document, Revert, quitting with unsaved work) is listed in `ui.inspect`'s `dialogs` with the id `"discard"` while it is up: `fields` gives the waiting `command` (`file.close`, `file.exit`…), the `document` it asks about, how many are `remaining`, and its `choices`. `ui.dialog.confirm` takes `{"dialog": "discard", "choice": "save" | "dontSave" | "cancel"}` (default `save`; Revert takes `dontSave` or `cancel`) and answers it as the window's buttons do, one document at a time; `ui.dialog.cancel` with `{"dialog": "discard"}` cancels it. Save of an untitled document opens the save dialog first, so the reply's `fileDialog` is true and the prompt stays open until that is answered. - Layer Style (`layerStyle {effect?}` opens on that effect kind): the fields hold the dialog's whole state, so agents read and drive it like a user. `effects` lists every effect instance in the layer's order as `{id, kind, on, params, fx}` (`fx` is the effect snapshot the dialog loaded; OK edits that snapshot with `params`, so anything the dialog doesn't model survives). `selected` picks the page (`blendingOptions` or an instance id), `preview` (default on) gates the live canvas preview, `p:blendingOptions` edits blend mode/opacity/fill opacity, and `patternList` names the usable patterns. OK replaces the layer's effects in one step (`layer.layerStyle.replace`); Cancel discards. "New Style…" saves the pending state via `style.presets.new {effects}`, a swatch click applies a style preset, and Make/Reset Default use `layer.layerStyle.makeDefault` / `layer.layerStyle.defaultFor` - - Gradient Overlay exposes `params.method` (`smooth`, `perceptual`, `linear`, `classic`). `custom` denotes an existing curve without a recorded method and preserves it. Choosing a method retains the full source colour-stop list; later endpoint edits rebuild the colour curve using that method. The source stops, smoothness and method survive dialog reopening, undo/redo, style presets and native `.pcraft` saves. PSD export continues to write the baked appearance; reopening that PSD shows Custom because editable interpolation metadata is not exported yet. Opacity interpolation and the multi-stop editor are separate work. + - Gradient Overlay exposes `params.method` (`smooth`, `perceptual`, `linear`, `classic`). `custom` denotes an existing curve without a recorded method and preserves it. Choosing a method retains the full source colour-stop list; later endpoint edits rebuild the colour curve using that method. The source stops, smoothness and method survive dialog reopening, undo/redo and native `.pcraft` saves. Saving a style preset through "New Style…" may lose the multi-stop source curve: it passes only params to `style.presets.new`, and `effect_from_params` rebuilds the effect from the default gradient. PSD export continues to write the baked appearance; reopening that PSD shows Custom because editable interpolation metadata is not exported yet. Opacity interpolation and the multi-stop editor are separate work. - Preferences (`ui.menu.invoke {id: "edit.preferences.interface"}`) exposes the sections in its `values` field. Apply (`ui.dialog.apply`) and OK (`ui.dialog.confirm`) on Preferences are refused over control because automation denies whole-preferences updates and filesystem-bearing preference sections. A refused `ui.dialog.apply` returns an error and keeps the dialog open; a refused `ui.dialog.confirm` returns an error but closes and removes the dialog. `ui.dialog.cancel` closes the dialog without saving. Individual safe preferences can instead be changed with `engine.execute` using `prefs.set` (e.g. `{"command": "prefs.set", "params": {"path": "interface.showTooltips", "value": false}}`). Settings marked for the next launch still require a restart. - Edit › Fill… (`ui.menu.invoke {id: "edit.fill"}`, Shift+F5, Shift+Backspace) opens the Fill dialog; its fields are `edit.fill`'s params (`contents`, `color`, `pattern`, `colorAdaptation`, `mode`, `opacity`, `preserveTransparency`), and OK remembers them in the preferences (`dialogs["edit.fill"]`). - Save for Web (`ui.menu.invoke {id: "file.export.saveForWebLegacy"}`) is resizable with independently scrolling settings. Dialog fields `__view` (`original|optimized|2up|4up`), `__zoom` (`null` = Fit, otherwise a factor; 1 = 100% in physical display pixels), and `__center: [u,v]` control the shared preview navigation. `__previewRects` reports pane rectangles in screen points. Drag a preview to pan, scroll/pinch to zoom at the pointer, or double-click to fit. GIF/PNG-8 expose `colorTable: ["#rrggbb", …]` (opaque source entries) and `colorTableEdits: {"0":"#rrggbb", …}` (zero-based replacements after quantization). A swatch opens a color picker; edits update the preview and saved file without remapping pixel indices or changing the document. Reset clears replacements. Changing palette/size/matte/transparency settings regenerates the table and clears index-based edits. Previews and generated tables use a bounded 2048-pixel proxy; full-size export uses that explicit table unchanged. `__paletteApproximate` reports proxy-derived palette generation, and enlarged proxy previews are labelled. The engine export command accepts the same table/edit parameters; its no-path estimate returns the source `colorTable` and `transparentIndex` as well as size statistics. Opening a new dialog does not carry a previous image's table across. From 4b06b0cc5a311ed595aaa3c0405d19ebca945d67 Mon Sep 17 00:00:00 2001 From: Unemars <62496697+Unemars@users.noreply.github.com> Date: Sun, 18 Oct 2026 15:53:07 +0200 Subject: [PATCH 135/649] Brush: small tips keep their speed next to the parallel large ones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first version slowed small brushes by about a third (reviewer's measurement: a 20 px soft zigzag 856 → 1736 ms over 6000 dabs), for three reasons, all gone: - `CoverageMap::accumulate` looked the dab's tiles up by walking the whole tile map (`iter_mut().filter_map`) on every dab, so a long stroke's thousands of tiles taxed every small dab. The touched tiles now leave the map (`remove`), accumulate, and go back: one to four lookups for a small tip. - The composite allocated a fresh 64 KB buffer per tile per frame (6872 `brk` calls per 3000 dabs against main's 542): the heap grew and trimmed every frame. The buffers live in a pool on the renderer (`RegionPool`, emptied on clone) and are reused from composite to composite. - The row / tile bodies passed as closures to the helpers cost a 20 px tip's `rasterize` half as much again (7.5 → 11.6 µs). They are `#[inline(always)]` steps on `Copy` structs (`RoundTip::row`, `DabValues::tile`), called from plain loops below the threshold and from rayon above it; `rasterize` is back to main's time. `examples/stroke_bench.rs` times a long zigzag stroke of one tip, push + composite per point (best of four, loaded machine; main → now): 20 px 667 → 706 ms, 50 px 1805 → 1734 ms, 150 px 11 017 → 5163 ms. Comments: the per-tile copy of `src` in the composite is the intended reading (a tile without per-dab colour only occurs in strokes without per-dab colour, where `src` is never rewritten), and `set_parallel_min_pixels` changes a process-wide static harmlessly. `parallel()` and the helpers' `pixels` are `cfg`'d so the wasm build has no unused warnings. Co-Authored-By: Claude Fable 5.1 --- crates/paint/examples/stroke_bench.rs | 64 ++++++ crates/paint/src/render.rs | 280 +++++++++++++++++--------- 2 files changed, 247 insertions(+), 97 deletions(-) create mode 100644 crates/paint/examples/stroke_bench.rs diff --git a/crates/paint/examples/stroke_bench.rs b/crates/paint/examples/stroke_bench.rs new file mode 100644 index 0000000000..2a6b59cfa7 --- /dev/null +++ b/crates/paint/examples/stroke_bench.rs @@ -0,0 +1,64 @@ +//! A long stroke of one tip, timed per dab: a zigzag over a 4928×3280 RGBA8 document that sweeps +//! the whole page, `push` then `composite` after every point, as painting does per frame. Small +//! tips are the everyday case; a long stroke grows the stroke's tile map to thousands of tiles, +//! and the time per dab must not grow with it. +//! `cargo run --release -p photocraft-paint --example stroke_bench -- [size] [hardness] [dabs]` +use photocraft_color::PixelFormat; +use photocraft_geom::Rect; +use photocraft_paint::{BrushSettings, StrokePoint, StrokeRenderer}; +use photocraft_raster::Surface; +use std::time::Instant; + +fn main() { + let args: Vec = std::env::args().collect(); + let size: f32 = args.get(1).and_then(|s| s.parse().ok()).unwrap_or(20.0); + let hardness: f32 = args.get(2).and_then(|s| s.parse().ok()).unwrap_or(0.0); + let dabs: usize = args.get(3).and_then(|s| s.parse().ok()).unwrap_or(6000); + let (w, h) = (4928.0f64, 3280.0f64); + let brush = BrushSettings { size, hardness, spacing: 0.25, color: [1.0, 0.0, 0.0, 1.0], ..Default::default() }; + let fmt = PixelFormat::RGBA8; + let mut pre = Surface::new(fmt); + pre.fill_rect(Rect::new(0, 0, w as i32, h as i32), &[0.5, 0.5, 0.5, 1.0]); + let mut target = pre.clone(); + // Segments from the top margin to the bottom one and back, advancing across the width so that + // `dabs` dabs at the brush's spacing sweep the document once. + let step = f64::from(size) * 0.25; + let margin = f64::from(size); + let span = h - 2.0 * margin; + let segments = ((dabs as f64 * step) / span).ceil().max(1.0) as usize; + let dx = (w - 2.0 * margin) / segments as f64; + let mut r = StrokeRenderer::new(&brush, Some(fmt), 1.0); + let (mut t_push, mut t_comp) = (0.0f64, 0.0f64); + let t_all = Instant::now(); + let mut pos = (margin, margin); + r.push(&[StrokePoint::new(pos.0, pos.1, 1.0)]); + let mut pushes = 0usize; + 'stroke: for seg in 0..segments { + let (x0, y0) = pos; + let (x1, y1) = (margin + (seg + 1) as f64 * dx, if seg % 2 == 0 { h - margin } else { margin }); + let n = (((x1 - x0).powi(2) + (y1 - y0).powi(2)).sqrt() / step).ceil().max(1.0) as usize; + for i in 1..=n { + let f = i as f64 / n as f64; + let t = Instant::now(); + r.push(&[StrokePoint::new(x0 + (x1 - x0) * f, y0 + (y1 - y0) * f, 1.0)]); + let tp = t.elapsed().as_secs_f64(); + r.composite(&pre, &mut target, None, false, false); + t_comp += t.elapsed().as_secs_f64() - tp; + t_push += tp; + pushes += 1; + if r.dab_count() >= dabs { + break 'stroke; + } + } + pos = (x1, y1); + } + let total = t_all.elapsed().as_secs_f64(); + let placed = r.dab_count(); + println!( + "tip {size} px, hardness {hardness}: {placed} dabs in {pushes} pushes over {segments} segments: {:.0} ms (push {:.0}, composite {:.0}), {:.1} µs per dab", + total * 1e3, + t_push * 1e3, + t_comp * 1e3, + total * 1e6 / placed.max(1) as f64 + ); +} diff --git a/crates/paint/src/render.rs b/crates/paint/src/render.rs index b0fa7d64ea..f58594c185 100644 --- a/crates/paint/src/render.rs +++ b/crates/paint/src/render.rs @@ -46,39 +46,22 @@ pub const COV_TILE: i32 = 64; #[cfg(not(target_arch = "wasm32"))] static PARALLEL_MIN_PIXELS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(256 * 256); -/// Whether `pixels` of independent work are worth the thread pool (never on the web). +/// Whether `pixels` of independent work are worth the thread pool (the web has none: there every +/// stage takes its serial path). +#[cfg(not(target_arch = "wasm32"))] fn parallel(pixels: usize) -> bool { - #[cfg(not(target_arch = "wasm32"))] - { - pixels >= PARALLEL_MIN_PIXELS.load(std::sync::atomic::Ordering::Relaxed) - } - #[cfg(target_arch = "wasm32")] - { - let _ = pixels; - false - } + pixels >= PARALLEL_MIN_PIXELS.load(std::sync::atomic::Ordering::Relaxed) } /// Tests: the pixel count from which work runs in parallel (`usize::MAX` keeps everything serial). +/// The static is process-wide, so brush tests on other threads see the change too; that is +/// harmless, because every stage gives the same pixels serially and in parallel (the point of +/// the test that uses this), so no test can tell which way it ran. #[cfg(all(test, not(target_arch = "wasm32")))] pub(crate) fn set_parallel_min_pixels(n: usize) { PARALLEL_MIN_PIXELS.store(n, std::sync::atomic::Ordering::Relaxed); } -/// `f(row index, row)` over the rows of `out` (`w` values each), in parallel when worth it. -fn for_each_row(out: &mut [f32], w: usize, f: impl Fn(usize, &mut [f32]) + Sync) { - if w == 0 { - return; - } - #[cfg(not(target_arch = "wasm32"))] - if parallel(out.len()) { - use rayon::prelude::*; - out.par_chunks_exact_mut(w).enumerate().for_each(|(i, row)| f(i, row)); - return; - } - out.chunks_exact_mut(w).enumerate().for_each(|(i, row)| f(i, row)); -} - /// `f` over `items`, in parallel when `pixels` are worth it. fn for_each_item(items: &mut [T], pixels: usize, f: impl Fn(&mut T) + Sync) { #[cfg(not(target_arch = "wasm32"))] @@ -87,6 +70,8 @@ fn for_each_item(items: &mut [T], pixels: usize, f: impl Fn(&mut T) + S items.par_iter_mut().for_each(&f); return; } + #[cfg(target_arch = "wasm32")] + let _ = pixels; items.iter_mut().for_each(&f); } @@ -97,6 +82,8 @@ fn map_items(items: &[T], pixels: usize, f: impl Fn(&T) -> R + use rayon::prelude::*; return items.par_iter().map(&f).collect(); } + #[cfg(target_arch = "wasm32")] + let _ = pixels; items.iter().map(&f).collect() } /// Computed tips with a smaller radius (in pixels) are rasterised by area, not at pixel centres. @@ -544,53 +531,44 @@ impl CoverageMap { vals[row + (tr.x0 - rect.x0) as usize..row + (tr.x1 - rect.x0) as usize].iter().any(|&v| v > 0.0) }) }); - let keys: Vec<((i32, i32), Rect)> = keys.into_iter().zip(touched).filter(|(_, t)| *t).map(|(k, _)| k).collect(); - for (key, _) in &keys { - let tile = self.tiles.entry(*key).or_insert_with(|| CovTile { - cov: vec![0.0; (COV_TILE * COV_TILE) as usize], - depth: Vec::new(), - col: if want_col { vec![0.0; (COV_TILE * COV_TILE) as usize * nc] } else { Vec::new() }, - }); - if want_col && tile.col.is_empty() { - tile.col = vec![0.0; (COV_TILE * COV_TILE) as usize * nc]; - } - if depth.is_some() && tile.depth.is_empty() { - tile.depth = vec![0.0; (COV_TILE * COV_TILE) as usize]; - } - self.dirty.insert(*key); - } - let wanted: HashMap<(i32, i32), Rect> = keys.into_iter().collect(); - let mut tiles: Vec<(Rect, (i32, i32), &mut CovTile)> = self.tiles.iter_mut().filter_map(|(k, t)| Some((*wanted.get(k)?, *k, t))).collect(); - for_each_item(&mut tiles, wanted.len() * (COV_TILE * COV_TILE) as usize, |(tr, (tx, ty), tile)| { - let (tx, ty) = (*tx, *ty); - for y in tr.y0..tr.y1 { - let row = (y - rect.y0) as usize * w; - let trow = ((y - ty * COV_TILE) * COV_TILE) as usize; - for x in tr.x0..tr.x1 { - let v = vals[row + (x - rect.x0) as usize]; - if v <= 0.0 { - continue; - } - let ti = trow + (x - tx * COV_TILE) as usize; - if let (Some(dv), Some(slot)) = (depth.and_then(|dp| dp.get(row + (x - rect.x0) as usize)), tile.depth.get_mut(ti)) { - *slot = slot.max(*dv); - } - let c = tile.cov[ti]; - let nv = if ceil > c { c + v * (ceil - c) } else { c }; - if nv <= c { - continue; - } - if let (true, Some(col)) = (want_col, color) { - let k = if c < 1.0 { (nv - c) / (1.0 - c) } else { 0.0 }; - let p = &mut tile.col[ti * nc..(ti + 1) * nc]; - for i in 0..nc { - p[i] = col[i] * k + p[i] * (1.0 - k); - } - } - tile.cov[ti] = nv; + // The touched tiles leave the map while they accumulate and go back after: the dab's cost + // follows the tiles under it (one to four for a small tip), not the size of the map, which a + // long stroke grows to thousands of tiles. + let n = (COV_TILE * COV_TILE) as usize; + let mut tiles: Vec<(Rect, (i32, i32), CovTile)> = keys + .into_iter() + .zip(touched) + .filter(|(_, t)| *t) + .map(|((key, tr), _)| { + let mut tile = self.tiles.remove(&key).unwrap_or_else(|| CovTile { cov: vec![0.0; n], depth: Vec::new(), col: Vec::new() }); + if want_col && tile.col.is_empty() { + tile.col = vec![0.0; n * nc]; } + if depth.is_some() && tile.depth.is_empty() { + tile.depth = vec![0.0; n]; + } + self.dirty.insert(key); + (tr, key, tile) + }) + .collect(); + let dab = DabValues { vals, rect, w, ceil, color: if want_col { color } else { None }, depth, nc }; + // The serial path stays a plain loop over an inlined step (see `rasterize_round`). + #[cfg(not(target_arch = "wasm32"))] + if parallel(tiles.len() * n) { + use rayon::prelude::*; + tiles.par_iter_mut().for_each(|(tr, key, tile)| dab.tile(*tr, *key, tile)); + } else { + for (tr, key, tile) in &mut tiles { + dab.tile(*tr, *key, tile); } - }); + } + #[cfg(target_arch = "wasm32")] + for (tr, key, tile) in &mut tiles { + dab.tile(*tr, *key, tile); + } + for (_, key, tile) in tiles { + self.tiles.insert(key, tile); + } } fn take_dirty(&mut self) -> Vec<(i32, i32)> { @@ -657,6 +635,55 @@ impl UnionLive { } } +/// One dab's coverage (`vals` over `rect`, `w` wide) as [`CoverageMap::accumulate`] adds it to +/// a tile: the dab's opacity ceiling, its colour when the stroke has per-dab colour (`nc` channels), +/// its Wet Edges depth. +#[derive(Clone, Copy)] +struct DabValues<'a> { + vals: &'a [f32], + rect: Rect, + w: usize, + ceil: f32, + color: Option<&'a [f32]>, + depth: Option<&'a [f32]>, + nc: usize, +} + +impl DabValues<'_> { + /// Adds the dab over `tr` (within tile `(tx, ty)`) to `tile`. + #[inline(always)] + fn tile(self, tr: Rect, (tx, ty): (i32, i32), tile: &mut CovTile) { + let DabValues { vals, rect, w, ceil, color, depth, nc } = self; + for y in tr.y0..tr.y1 { + let row = (y - rect.y0) as usize * w; + let trow = ((y - ty * COV_TILE) * COV_TILE) as usize; + for x in tr.x0..tr.x1 { + let v = vals[row + (x - rect.x0) as usize]; + if v <= 0.0 { + continue; + } + let ti = trow + (x - tx * COV_TILE) as usize; + if let (Some(dv), Some(slot)) = (depth.and_then(|dp| dp.get(row + (x - rect.x0) as usize)), tile.depth.get_mut(ti)) { + *slot = slot.max(*dv); + } + let c = tile.cov[ti]; + let nv = if ceil > c { c + v * (ceil - c) } else { c }; + if nv <= c { + continue; + } + if let Some(col) = color { + let k = if c < 1.0 { (nv - c) / (1.0 - c) } else { 0.0 }; + let p = &mut tile.col[ti * nc..(ti + 1) * nc]; + for i in 0..nc { + p[i] = col[i] * k + p[i] * (1.0 - k); + } + } + tile.cov[ti] = nv; + } + } + } +} + /// Incremental stroke rendering: feed points, composite dirty tiles from the pre-stroke pixels. #[derive(Clone, Debug)] pub struct StrokeRenderer { @@ -673,6 +700,19 @@ pub struct StrokeRenderer { dab_buf: Vec, dual_buf: Vec, all_dabs: Option>, + regions: RegionPool, +} + +/// The tile buffers [`StrokeRenderer::composite`] works in, kept from one composite to the next: +/// a small stroke's few tiles reuse theirs instead of growing and trimming the heap every frame +/// (that cost a 50 px stroke a third of its time). A clone starts with none. +#[derive(Debug, Default)] +struct RegionPool(Vec>); + +impl Clone for RegionPool { + fn clone(&self) -> Self { + Self::default() + } } impl StrokeRenderer { @@ -765,6 +805,7 @@ impl StrokeRenderer { dab_buf: Vec::new(), dual_buf: Vec::new(), all_dabs: None, + regions: RegionPool::default(), }) } Some(m) => { @@ -816,6 +857,7 @@ impl StrokeRenderer { dab_buf: Vec::new(), dual_buf: Vec::new(), all_dabs: None, + regions: RegionPool::default(), } } @@ -946,6 +988,7 @@ impl StrokeRenderer { dab_buf: dabs, dual_buf: duals, all_dabs: None, + regions: RegionPool::default(), }; t.raster_pending(); // Tiles whose coverage the tail doesn't change still composite the same: redraw them all. @@ -1059,20 +1102,29 @@ impl StrokeRenderer { // colour, as in Photoshop, not grain that a tolerance-0 Magic Wand or Paint Bucket trips on. let dither = fmt.sample == SampleType::U8 && !b.aliased; let mut dmg = Rect::EMPTY; - // Each tile composites on its own (a large stroke's tiles in parallel, to the same - // pixels); the writes to the target go one by one. Batches keep the pending regions small. + // Each tile composites into a buffer of its own (a large stroke's tiles in parallel, to + // the same pixels); the writes to the target go one by one, in order. Batches keep the + // pending buffers few, and the pool keeps them from one composite to the next. const BATCH: usize = 256; + let mut pool = std::mem::take(&mut self.regions.0); for batch in keys.chunks(BATCH) { - let regions: Vec<(Rect, Vec)> = map_items(batch, batch.len() * (COV_TILE * COV_TILE) as usize, |&(tx, ty)| { - let Some(tile) = self.cov.tiles.get(&(tx, ty)) else { return (Rect::EMPTY, Vec::new()) }; + let mut items: Vec<((i32, i32), Rect, Vec)> = batch.iter().map(|&key| (key, Rect::EMPTY, pool.pop().unwrap_or_default())).collect(); + for_each_item(&mut items, batch.len() * (COV_TILE * COV_TILE) as usize, |(key, done, region)| { + let (tx, ty) = *key; + let Some(tile) = self.cov.tiles.get(&(tx, ty)) else { return }; let tr = Rect::new(tx * COV_TILE, ty * COV_TILE, (tx + 1) * COV_TILE, (ty + 1) * COV_TILE).intersect(&bounds); if tr.is_empty() { - return (Rect::EMPTY, Vec::new()); + return; } - let mut region = Vec::new(); - pre.read_region_into(tr, &mut region); + pre.read_region_into(tr, region); let sel = selection.map(|s| (s.channels(), s.read_region(tr))); - // Per-dab colour rewrites the source per pixel: a copy per tile. + // Per-dab colour rewrites the source per pixel, so each tile works on its own copy + // that starts from the brush colour. (Before the tiles ran in parallel, one `src` + // carried over from tile to tile; a tile without per-dab colour then painted with + // whatever colour the previous tile's last pixel had left in it. Such a tile only + // occurs when the stroke has no per-dab colour at all, and then `src` is never + // rewritten, so the pixels are the same either way; the copy per tile is the + // intended reading.) let mut src = src; let w = tr.width() as usize; for y in tr.y0..tr.y1 { @@ -1132,16 +1184,17 @@ impl StrokeRenderer { } } } - (tr, region) + *done = tr; }); - for (tr, region) in regions { - if tr.is_empty() { - continue; + for (_, tr, region) in items { + if !tr.is_empty() { + target.write_region(tr, ®ion); + dmg = dmg.union(&tr); } - target.write_region(tr, ®ion); - dmg = dmg.union(&tr); + pool.push(region); } } + self.regions.0 = pool; if all { bounds } else { dmg } } } @@ -1172,27 +1225,60 @@ fn rasterize_round(d: &Dab, rect: Rect, out: &mut [f32], hardness: f32, aliased: let ro = d.roundness.max(0.5 / d.radius).min(1.0); let rm = (d.radius * ro).max(0.5); let w = rect.width() as usize; + if w == 0 { + return; + } let reach = if aliased { rm } else { tip_reach(rm, hardness).max(rm) }; - let reach2 = (reach + 0.5) * (reach + 0.5); - let alpha = d.alpha; - // Rows are independent: a large tip's rows run in parallel, to the same values. - for_each_row(out, w, |yy, row| { - let dy = (rect.y0 + yy as i32) as f32 + 0.5 - cy; - if aliased { + let tip = RoundTip { cx, cy, ro, rm, reach2: (reach + 0.5) * (reach + 0.5), hardness, alpha: d.alpha, aliased, x0: rect.x0, y0: rect.y0 }; + // Rows are independent: a large tip's rows run in parallel, to the same values. The serial + // path stays a plain loop over an inlined row: the same code as before the threads (a closure + // passed to a helper cost a small tip half its rasterization time). + #[cfg(not(target_arch = "wasm32"))] + if parallel(out.len()) { + use rayon::prelude::*; + out.par_chunks_exact_mut(w).enumerate().for_each(|(yy, row)| tip.row(yy, row)); + return; + } + for (yy, row) in out.chunks_exact_mut(w).enumerate() { + tip.row(yy, row); + } +} + +/// A round tip's coverage, computed row by row (see [`rasterize_round`]). +#[derive(Clone, Copy)] +struct RoundTip { + cx: f32, + cy: f32, + ro: f32, + rm: f32, + reach2: f32, + hardness: f32, + alpha: f32, + aliased: bool, + x0: i32, + y0: i32, +} + +impl RoundTip { + /// Row `yy` of the tip's rectangle into `row`. + #[inline(always)] + fn row(self, yy: usize, row: &mut [f32]) { + let dy = (self.y0 + yy as i32) as f32 + 0.5 - self.cy; + if self.aliased { for (xx, dst) in row.iter_mut().enumerate() { - let dx = (rect.x0 + xx as i32) as f32 + 0.5 - cx; - let d2 = (dx * ro).powi(2) + dy * dy; - *dst = if d2 < reach2 && d2.sqrt() <= rm { alpha } else { 0.0 }; + let dx = (self.x0 + xx as i32) as f32 + 0.5 - self.cx; + let d2 = (dx * self.ro).powi(2) + dy * dy; + *dst = if d2 < self.reach2 && d2.sqrt() <= self.rm { self.alpha } else { 0.0 }; } } else { for (xx, dst) in row.iter_mut().enumerate() { - let dx = (rect.x0 + xx as i32) as f32 + 0.5 - cx; - let d2 = (dx * ro).powi(2) + dy * dy; - let val = if d2 >= reach2 { 0.0 } else { tip_falloff(d2.sqrt(), rm, hardness) }; - *dst = if val <= 0.0 { 0.0 } else { val * alpha }; + let dx = (self.x0 + xx as i32) as f32 + 0.5 - self.cx; + let d2 = (dx * self.ro).powi(2) + dy * dy; + let val = if d2 >= self.reach2 { 0.0 } else { tip_falloff(d2.sqrt(), self.rm, self.hardness) }; + *dst = if val <= 0.0 { 0.0 } else { val * self.alpha }; } } - }); + } } #[cfg(test)] From df17ad7520901dc95735a1c6ef23c18c59c25b79 Mon Sep 17 00:00:00 2001 From: SBaksa Date: Mon, 19 Oct 2026 01:25:39 +1100 Subject: [PATCH 136/649] CMYK ink compositing: isolated groups keep the special Fill rule An isolated group in one of the special eight blend modes below 100% Fill blended with Fill as plain coverage on the exact ink path, while the compositor (and so the split route) keeps Fill apart from opacity, so its inks differed from the canvas. Blend groups through blend_into_fill like other layers, and drop the group exclusion from the test reference. --- crates/compose/src/cmyk.rs | 3 ++- crates/compose/src/cmyk_tests.rs | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/crates/compose/src/cmyk.rs b/crates/compose/src/cmyk.rs index 1e0f6c844c..db5a2c791e 100644 --- a/crates/compose/src/cmyk.rs +++ b/crates/compose/src/cmyk.rs @@ -514,7 +514,8 @@ fn composite_layer(l: &Layer, clipped: &[Layer], backdrop: &mut CmykBuffer, cx: composite_stack(&g.children, &mut content, cx); apply_mask(l, &mut content, cx); composite_clipped(clipped, &mut content, cx); - blend_into(backdrop, &content, l.blend, opacity, 1.0); + // As the compositor blends an isolated group: Fill apart from opacity for the special eight. + blend_into_fill(backdrop, &content, l, 1.0); return; } // Adjustment layers transform the backdrop, then blend the result back in. diff --git a/crates/compose/src/cmyk_tests.rs b/crates/compose/src/cmyk_tests.rs index 962f266ebb..4618429dee 100644 --- a/crates/compose/src/cmyk_tests.rs +++ b/crates/compose/src/cmyk_tests.rs @@ -295,8 +295,8 @@ fn ref_layer(l: &Layer, clipped: &[Layer], x: i32, y: i32, b: Cmyka) -> Cmyka { _ => ref_own(l, x, y), }; content = ref_clip(clipped, content, x, y); - // A layer's own blend (not a group's) for the special eight below 100% Fill. - if l.fill_opacity < 1.0 && crate::psblend::fill_is_special(l.blend) && !matches!(l.content, LayerContent::Group(_)) { + // The special eight below 100% Fill, a layer's own blend and an isolated group's alike. + if l.fill_opacity < 1.0 && crate::psblend::fill_is_special(l.blend) { return over_special_fill(l, b, content); } over_layer(l, b, content, op, Some((x, y))) @@ -372,6 +372,24 @@ fn masks_groups_and_clipping_match_the_reference() { assert_matches_reference(&d); } +/// An isolated group in one of the special eight below 100% Fill blends with Fill apart from +/// opacity, as the compositor blends it (the split route runs the compositor on stand-ins). +#[test] +fn isolated_groups_keep_the_special_fill_rule() { + for mode in [BlendMode::Difference, BlendMode::LinearBurn, BlendMode::LinearDodge, BlendMode::LinearLight, BlendMode::ColorDodge] { + assert!(crate::psblend::fill_is_special(mode), "{mode:?}"); + let mut d = doc(4, 2); + d.layers.push(paper(4, 2, [0.2, 0.5, 0.1, 0.1])); + let mut g = Layer::group("iso", vec![layer(&[(Rect::new(0, 0, 3, 2), [0.6, 0.1, 0.4, 0.2, 0.8])])]); + g.blend = mode; + g.opacity = 0.9; + g.fill_opacity = 0.4; + d.layers.push(g); + assert_matches_reference(&d); + assert_routes_agree(&d); + } +} + #[test] fn unsupported_documents_fall_back() { let simple = || { From 1e0673432b735c8b957a15cbb9be865d73071ac9 Mon Sep 17 00:00:00 2001 From: SBaksa Date: Mon, 19 Oct 2026 01:25:39 +1100 Subject: [PATCH 137/649] CMYK split route: convert stand-ins a band at a time, skip hidden layers A layer's stand-in surface converted every stored tile to floats before writing any, a transient several times the layer's stored size (twice, once per stand-in). Convert about BAND_PIXELS of tiles at a time instead, and leave hidden layers unconverted, since the compositor never draws them. --- crates/compose/src/cmyk_split.rs | 77 ++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/crates/compose/src/cmyk_split.rs b/crates/compose/src/cmyk_split.rs index 89153b6366..cf41a509d1 100644 --- a/crates/compose/src/cmyk_split.rs +++ b/crates/compose/src/cmyk_split.rs @@ -90,6 +90,11 @@ fn stand_in_color(c: &Color, planes: Planes) -> Color { /// A CMYK surface as an RGB one (same depth and alpha) holding the planes' brightness. fn stand_in_surface(s: &Surface, planes: Planes) -> Surface { + stand_in_surface_in(s, planes, crate::BAND_PIXELS) +} + +/// [`stand_in_surface`], converting about `budget` pixels' worth of tiles at a time. +fn stand_in_surface_in(s: &Surface, planes: Planes, budget: u64) -> Surface { let from = s.format(); if from.mode != ColorMode::Cmyk { return s.clone(); @@ -130,15 +135,30 @@ fn stand_in_surface(s: &Surface, planes: Planes) -> Surface { map(&src, &mut dst); (*r, dst) }; - #[cfg(not(target_arch = "wasm32"))] - let tiles: Vec<(Rect, Vec)> = { - use rayon::prelude::*; - rects.par_iter().map(convert).collect() - }; - #[cfg(target_arch = "wasm32")] - let tiles: Vec<(Rect, Vec)> = rects.iter().map(convert).collect(); - for (r, data) in &tiles { - out.write_region(*r, data); + // Converted a band's worth of tiles at a time, so the float samples in flight stay about + // one render band's, not the whole layer's. + let mut start = 0; + while start < rects.len() { + let mut end = start; + let mut pixels = 0u64; + while let Some(r) = rects.get(end) + && (end == start || pixels < budget) + { + pixels = pixels.saturating_add(u64::from(r.width()) * u64::from(r.height())); + end += 1; + } + let batch = rects.get(start..end).unwrap_or_default(); + #[cfg(not(target_arch = "wasm32"))] + let tiles: Vec<(Rect, Vec)> = { + use rayon::prelude::*; + batch.par_iter().map(convert).collect() + }; + #[cfg(target_arch = "wasm32")] + let tiles: Vec<(Rect, Vec)> = batch.iter().map(convert).collect(); + for (r, data) in &tiles { + out.write_region(*r, data); + } + start = end; } out } @@ -202,6 +222,10 @@ fn stand_in_effect(e: &mut Effect, planes: Planes) { } fn stand_in_layer(l: &mut Layer, planes: Planes, depth: SampleType, canvas: Rect) { + // The compositor never draws a hidden layer (nor what is clipped to it): no stand-in needed. + if !l.visible { + return; + } let cache = |c: &mut Option| { if let Some(s) = c { *s = stand_in_surface(s, planes); @@ -311,3 +335,38 @@ pub(super) fn render_planes(doc: &Document, rect: Rect, planes: Planes) -> Buffe s.prepare(rect); s.tile(rect) } + +#[cfg(test)] +mod batch_tests { + use super::*; + + /// A surface over many tiles converts alike one tile at a time or all at once, and a hidden + /// layer is left unconverted (the compositor never draws it). + #[test] + fn stand_ins_convert_in_batches_and_skip_hidden_layers() { + let fmt = PixelFormat::new(ColorMode::Cmyk, SampleType::U8, true); + let mut s = Surface::with_default(fmt, &[0.0; 5]); + let size = photocraft_geom::TILE_SIZE * 3 + 7; + s.fill_rect(Rect::new(0, 0, size, size / 2), &[0.2, 0.4, 0.6, 0.1, 1.0]); + s.fill_rect(Rect::new(5, size / 3, size, size), &[0.0, 0.9, 0.0, 0.5, 0.5]); + assert!(s.tiles().count() > 4); + let bounds = Rect::new(0, 0, size, size); + let read = |s: &Surface| { + let mut v = Vec::new(); + s.read_region_into(bounds, &mut v); + v + }; + for planes in [CMY, K] { + let whole = stand_in_surface_in(&s, planes, u64::MAX); + assert_eq!(read(&stand_in_surface_in(&s, planes, 1)), read(&whole)); + assert_eq!(read(&stand_in_surface(&s, planes)), read(&whole)); + } + let mut d = Document::new("d", photocraft_geom::Size::new(4, 4), ColorMode::Cmyk, SampleType::U8); + let mut hidden = Layer::raster("hidden", fmt); + hidden.visible = false; + d.layers.extend([Layer::raster("shown", fmt), hidden]); + let st = stand_in(&d, CMY); + let mode = |l: &Layer| l.surface().map(|s| s.format().mode); + assert_eq!(st.layers.iter().map(mode).collect::>(), [Some(ColorMode::Rgb), Some(ColorMode::Cmyk)]); + } +} From 24d844d77143d836a9a4fd5aff35c5dd362ef5a3 Mon Sep 17 00:00:00 2001 From: abc2cb <271337822+abc2cb@users.noreply.github.com> Date: Sun, 18 Oct 2026 17:52:57 +0300 Subject: [PATCH 138/649] PSD export: Wave writes the generators PhotoCraft rendered A Wave made or edited in PhotoCraft can hold up to 999 generators, but the renderer draws at most MAX_WAVE_GENERATORS (64), so the PSD got a NmbG that makes Photoshop draw more waves than the user saw. Write the count clamped to 1..=MAX_WAVE_GENERATORS. This matches the import side, which keeps a Photoshop Wave with more generators verbatim instead of mapping it. Co-Authored-By: Claude Opus 5.5 --- crates/io/src/smart_map.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/io/src/smart_map.rs b/crates/io/src/smart_map.rs index 0d78f2ffcc..785f89be5d 100644 --- a/crates/io/src/smart_map.rs +++ b/crates/io/src/smart_map.rs @@ -673,8 +673,11 @@ fn fltr_for(k: &Known, p: &J) -> Result, String> { } "Wave" => { let seed = p.get("seed").and_then(J::as_u64).and_then(|s| u32::try_from(s).ok()).unwrap_or(0); + // The renderer draws at most MAX_WAVE_GENERATORS: write what PhotoCraft rendered, so + // Photoshop doesn't draw more generators than the user saw. + let generators = pf(p, "generators", 5.0).round().clamp(1.0, f64::from(photocraft_algo::MAX_WAVE_GENERATORS)) as i32; d.with("Wvtp", enum_value(p, "type", "sine", "Wvtp", &WAVE_TYPE)?) - .with("NmbG", pi(p, "generators", 5.0)) + .with("NmbG", Value::Integer(generators)) .with("WLMn", pi(p, "wavelengthMin", 10.0)) .with("WLMx", pi(p, "wavelengthMax", 120.0)) .with("AmMn", pi(p, "amplitudeMin", 5.0)) @@ -1282,6 +1285,24 @@ mod tests { } } + /// PhotoCraft draws at most `MAX_WAVE_GENERATORS` generators, so a Wave edited past that exports + /// the 64 it rendered, and a count below 1 exports 1, instead of Photoshop drawing more. + #[test] + fn wave_export_writes_only_the_generators_the_renderer_draws() { + let max = i32::try_from(photocraft_algo::MAX_WAVE_GENERATORS).unwrap(); + for (stored, written) in [(100, max), (999, max), (max + 1, max), (max, max), (5, 5), (1, 1), (0, 1), (-3, 1)] { + let wave = sf( + "filter.distort.wave", + json!({"type": "sine", "generators": stored, "wavelengthMin": 20, "wavelengthMax": 90, "amplitudeMin": 4, "amplitudeMax": 30}), + ); + let fltr = match item_for_filter(&wave).unwrap().get("Fltr") { + Some(Value::Descriptor(d)) => d.clone(), + other => panic!("wave: no Fltr ({other:?})"), + }; + assert_eq!(int(&fltr, "NmbG"), Some(written), "{stored} generators"); + } + } + /// Invert on a smart object: Photoshop stores no `Fltr`, but `hasoptions` and its filter id. #[test] fn invert_smart_filter_reads_and_writes_like_photoshop() { From 9507dafb524f31b2bc08c29ca641abcac3899a0c Mon Sep 17 00:00:00 2001 From: abc2cb <271337822+abc2cb@users.noreply.github.com> Date: Sun, 18 Oct 2026 17:52:57 +0300 Subject: [PATCH 139/649] Smart filter PSD mapping: document the test helper the PR adds CodeRabbit measured the docstring coverage of the PR at 64.71%, under its 80% threshold; photoshop_item was the one function of the PR without a doc comment. Comment only; no code changes. Co-Authored-By: Claude Opus 5.5 --- crates/io/src/smart_map.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/io/src/smart_map.rs b/crates/io/src/smart_map.rs index 785f89be5d..c12390707b 100644 --- a/crates/io/src/smart_map.rs +++ b/crates/io/src/smart_map.rs @@ -1208,6 +1208,7 @@ mod tests { /// Photoshop's Wave with Scale 100% / 28%: PhotoCraft's Wave has no Scale. const PHOTOSHOP_WAVE: &str = "000000050057006100760065000000000000576176650000000a0000000057767470656e756d00000000577674700000000057765472000000004e6d62476c6f6e670000014c00000000574c4d6e6c6f6e67000000d500000000574c4d786c6f6e67000000d600000000416d4d6e6c6f6e67000000f000000000416d4d786c6f6e67000000f10000000053636c486c6f6e67000000640000000053636c566c6f6e670000001c00000000556e6441656e756d00000000556e6441000000005772704100000000526e64536c6f6e670013624a"; + /// A `filterFX` list item as Photoshop writes it (enabled, Normal at 100%, with options), wrapping the `Fltr` descriptor `fltr`. fn photoshop_item(fltr: Descriptor) -> Descriptor { let id = code(fltr.class_id.as_bytes().try_into().unwrap()); Descriptor::new("filterFX") From 834d759b2eb30711be132876a082d7940570a29f Mon Sep 17 00:00:00 2001 From: abc2cb <271337822+abc2cb@users.noreply.github.com> Date: Sun, 18 Oct 2026 17:54:18 +0300 Subject: [PATCH 140/649] Wave and smart filter PSD mapping: document the neighbouring functions CodeRabbit counts the functions around the lines a PR changes, not only the changed ones, so the PR's docstring coverage stays low (64.71%, threshold 80%) unless the untouched neighbours are documented too. Comments only; no code changes. Co-Authored-By: Claude Opus 5.5 --- crates/algo/src/distort.rs | 1 + crates/io/src/smart_map.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/crates/algo/src/distort.rs b/crates/algo/src/distort.rs index 1d4e38406c..4f8356f60d 100644 --- a/crates/algo/src/distort.rs +++ b/crates/algo/src/distort.rs @@ -141,6 +141,7 @@ fn shape(t: WaveType, phase: f32) -> f32 { } } +/// Wave: displace `src` over `out` by the average of `w.generators` seeded waves (at most `MAX_WAVE_GENERATORS`) along each axis. pub(crate) fn wave(src: &Image, out: Rect, ctx: &Ctx, w: WaveSpec) -> Vec { let n = w.generators.clamp(1, MAX_WAVE_GENERATORS); let lerp = |(a, b): (f32, f32), t: f32| a + (b - a).max(0.0) * t; diff --git a/crates/io/src/smart_map.rs b/crates/io/src/smart_map.rs index c12390707b..730d25cfca 100644 --- a/crates/io/src/smart_map.rs +++ b/crates/io/src/smart_map.rs @@ -140,6 +140,7 @@ struct Known { command: &'static str, } +/// A four-character PSD code as the big-endian integer Photoshop stores it as. const fn code(c: &[u8; 4]) -> i32 { i32::from_be_bytes(*c) } @@ -194,6 +195,7 @@ fn enum_value(p: &J, key: &str, default: &str, type_id: &str, table: &[(&[u8; 4] Ok(Value::Enumerated { type_id: Id::new(type_id), value: Id::Code(**code) }) } +/// The PSD filter record that PhotoCraft's `command` is written as, if it has one. fn known_by_command(command: &str) -> Option<&'static Known> { KNOWN.iter().find(|k| k.command == command) } @@ -202,10 +204,12 @@ fn known_by_command(command: &str) -> Option<&'static Known> { /// composite: top-level keys). const CHANNELS: [(&[u8; 4], &str); 4] = [(b"Cmps", ""), (b"Rd ", "red"), (b"Grn ", "green"), (b"Bl ", "blue")]; +/// A numeric descriptor item as a finite number; `None` when it is absent, not a number, or not finite. fn px(d: &Descriptor, key: &str) -> Option { num(d.get(key)).filter(|v| v.is_finite()) } +/// An integer descriptor item; `None` when it is absent or of another type. fn int(d: &Descriptor, key: &str) -> Option { match d.get(key)? { Value::Integer(i) => Some(*i), @@ -1324,6 +1328,7 @@ mod tests { assert_eq!(back.get("Nm "), Some(&Value::Text(UnicodeString::new_nul("Invert")))); } + /// A filter PhotoCraft doesn't model, or a known one with settings it doesn't, is kept verbatim; only its visibility and blend change. #[test] fn unknown_filters_keep_their_descriptor() { let item = Descriptor::new("filterFX") @@ -1502,6 +1507,7 @@ mod tests { } } + /// Filters with no PSD equivalent are skipped with a warning each, and the writable ones around them still export. #[test] fn unwritable_filters_are_reported_not_fatal() { let stack = FilterStack { From cc574bcf17fc5a55afe6c9f4aea516dd4b133c0c Mon Sep 17 00:00:00 2001 From: Khawar Zamman Wani Date: Sun, 18 Oct 2026 21:04:58 +0530 Subject: [PATCH 141/649] photocraft-cli run: refuse an --out that is the input file unless --in-place (#7437) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `run --cmd … --out ` silently replaced the original, so a lossy re-encode couldn't be undone; `batch` already refuses an --out that is its --in folder unless --in-place (#492). `run` now takes --in-place and, with a and an --out, refuses before opening the file or running any command when the two are the same file by `file_cmds::same_file` (same name, ./ spelling, absolute path, hard or symbolic link). --new runs have no input and are unaffected. It uses the `refuse_overwriting_input` helper the `convert` fix adds. Co-Authored-By: Claude Opus 5.5 --- apps/photocraft-cli/src/lib.rs | 11 ++++++--- apps/photocraft-cli/tests/cli.rs | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/apps/photocraft-cli/src/lib.rs b/apps/photocraft-cli/src/lib.rs index 69bc1a9632..752d14aef4 100644 --- a/apps/photocraft-cli/src/lib.rs +++ b/apps/photocraft-cli/src/lib.rs @@ -26,9 +26,10 @@ USAGE: --dpx-bits sets a DPX's bits per sample. Without it: 8 for an 8-bit document, else 16. photocraft-cli info [--compact] Print the document as JSON (size, mode, depth, layer tree). - photocraft-cli run ( | --new ) --cmd [--params ] [--cmd …] [--out ] [--format ] [--quality <1-100>] [--tiff-layers] [--tga-bits <24|32>] [--dpx-bits <8|10|12|16>] + photocraft-cli run ( | --new ) --cmd [--params ] [--cmd …] [--out ] [--format ] [--quality <1-100>] [--in-place] [--tiff-layers] [--tga-bits <24|32>] [--dpx-bits <8|10|12|16>] Open a file, run engine commands in order, save the result. Each --params - applies to the preceding --cmd. Prints each command's JSON result. + applies to the preceding --cmd. Prints each command's JSON result. An --out that is the + is refused, as the result would replace the original; --in-place allows it. photocraft-cli batch --actions [--action ] --in

--out [--format ] [--quality <1-100>] [--in-place] [--tiff-layers] [--tga-bits <24|32>] [--dpx-bits <8|10|12|16>] Apply an action list to every image in a directory. A Photoshop Actions file (.atn) is a set: its action --action names plays, as below. JSON steps are [id, params] pairs, @@ -76,7 +77,7 @@ const SUBCOMMANDS: &[Subcommand] = &[ Subcommand { name: "run", values: &["--new", "--cmd", "--params", "--out", "--format", "--quality", "--tga-bits", "--dpx-bits"], - bare: &["--tiff-layers"], + bare: &["--in-place", "--tiff-layers"], run: run_cmds, }, Subcommand { @@ -317,6 +318,10 @@ fn run_cmds(a: &Args, out: &mut dyn Write, err: &mut dyn Write) -> R { let mut reported_fonts = std::collections::HashSet::::new(); match (a.positional.as_slice(), a.get("--new")) { ([file], None) => { + // Refused before the file is read or any command runs. + if let Some(out) = a.get("--out") { + refuse_overwriting_input(a, file, out)?; + } let o = h.open(Path::new(file)).map_err(|e| e.to_string())?; let ws: Vec = serde_json::from_value(o["warnings"].clone()).unwrap_or_default(); reported_fonts.extend(ws.iter().cloned()); diff --git a/apps/photocraft-cli/tests/cli.rs b/apps/photocraft-cli/tests/cli.rs index b8aa434b3e..6687d082f7 100644 --- a/apps/photocraft-cli/tests/cli.rs +++ b/apps/photocraft-cli/tests/cli.rs @@ -520,6 +520,46 @@ fn tga_bits_choose_the_targa_depth() { } } +/// #7437: `run --out` to that same file, however `--out` is spelt, is refused before the +/// file is read or any command runs, unless `--in-place` asks for it (as `batch` does, #492). +#[test] +fn run_refuses_to_write_over_its_input() { + let d = tmp("run-in-place"); + write_png(&d.join("in.png"), 8, 4, 7); + let before = std::fs::read(d.join("in.png")).unwrap(); + let run = |out: &Path, extra: &[&str]| { + bin().current_dir(&d).args(["run", "in.png", "--cmd", "image.adjustments.invert", "--out"]).arg(out).args(extra).output().unwrap() + }; + let mut outs = vec![PathBuf::from("in.png"), PathBuf::from("./in.png"), d.join("in.png"), d.join(".").join("in.png")]; + std::fs::hard_link(d.join("in.png"), d.join("hard.png")).unwrap(); + outs.push(PathBuf::from("hard.png")); + #[cfg(unix)] + { + std::os::unix::fs::symlink(d.join("in.png"), d.join("soft.png")).unwrap(); + outs.push(PathBuf::from("soft.png")); + } + for out in &outs { + for extra in [&[][..], &["--format", "png"][..]] { + let o = run(out, extra); + let (stdout, err) = (String::from_utf8_lossy(&o.stdout), String::from_utf8_lossy(&o.stderr)); + assert_eq!(o.status.code(), Some(1), "--out {} {extra:?}: {err}", out.display()); + assert!(err.contains("is the input file") && err.contains("--in-place"), "{err}"); + assert!(stdout.is_empty(), "--out {} {extra:?} ran commands: {stdout}", out.display()); + assert_eq!(std::fs::read(d.join("in.png")).unwrap(), before, "--out {} {extra:?} changed the original", out.display()); + } + } + // Another file is written as before, leaving the original alone. + ok(bin().current_dir(&d).args(["run", "in.png", "--cmd", "image.adjustments.invert", "--out", "out.png"])); + assert!(d.join("out.png").is_file()); + assert_eq!(std::fs::read(d.join("in.png")).unwrap(), before); + // `--in-place` opts in: the inverted result replaces the original, which still opens. + ok(bin().current_dir(&d).args(["run", "in.png", "--cmd", "image.adjustments.invert", "--out", "in.png", "--in-place"])); + assert_ne!(std::fs::read(d.join("in.png")).unwrap(), before, "--in-place left the original unchanged"); + let (out, _) = ok(bin().current_dir(&d).args(["info", "in.png", "--compact"])); + let info: Value = serde_json::from_str(&out).unwrap(); + assert_eq!((info["width"].as_u64(), info["height"].as_u64()), (Some(8), Some(4)), "{info}"); +} + /// #492: an `--out` folder that is the `--in` folder, however it is spelt, is refused before /// anything is written, unless `--in-place` asks for it. #[test] From 24d6150ed4f94dd4b27aa7c81530a050c7e25f48 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Mon, 19 Oct 2026 02:30:52 +0200 Subject: [PATCH 142/649] Regenerate docs/scorecard.md after merging main Co-Authored-By: Claude Sonnet 5.5 --- docs/scorecard.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/scorecard.md b/docs/scorecard.md index b320028936..d22ea47eeb 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -8,7 +8,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js |---|---:|---:|---:|---| | [Performance](#performance) | 3 | 22 | 24 | 58 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 19 not run, 5 not measurable yet (baseline 2026-10-05) | | [File compatibility](#file-compatibility) | 7 | 14 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | -| [Tools](#tools) | 33 | 11 | 0 | | +| [Tools](#tools) | 34 | 10 | 0 | | | [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 25 of 168 (target 0) | | [Type](#type) | 4 | 3 | 2 | | | [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) | @@ -160,7 +160,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t | TOOL-214-11 | Stroke Path dialog: pick any brush-based tool, Simulate Pressure | done | [#214](https://github.com/storytold/photocraft/issues/214) | path.stroke tool: Brush, Pencil, Eraser and every other brush-based tool (Background Eraser, Clone/Pattern Stamp, Healing/Spot Healing Brush, History Brush, Blur, Sharpen, Smudge, Dodge, Burn, Sponge, Color Replacement, Mixer Brush: their paint.* command along the path, one step) plus simulatePressure (taper both ends); Stroke Path dialog from the Pen menu, the Paths panel menu and Alt-click on its Stroke button (#2978) | | TOOL-214-12 | Shapes: on-canvas corner radius handles, shape feather, selection to shape with tolerance | partial | [#214](https://github.com/storytold/photocraft/issues/214) | On-canvas corner radius widgets on every selected live rectangle with Path Selection, the Rectangle tool and Move + Show Transform Controls: drag rounds every corner of every selected rectangle alike, Alt that corner on each, corner radius cursor and R: readout, one history step (corner_radius.rs, 2026-10-13); select.convertToShape with tolerance (vector_cmds.rs:1256). Missing: shape feather | | TOOL-214-13 | Mask Properties: Density and Feather controls | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Vector-mask density/feather in the engine (vector_cmds.rs:948); no UI controls | -| TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | partial | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15); on-canvas plane editor (vp_ui.rs: Create/Edit Plane, edge nodes, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane on OK); clone stamp, marquee and tear-off planes in the window still missing | +| TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | done | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15); on-canvas window (vp_ui.rs: Create/Edit Plane, edge nodes, Ctrl/Cmd-drag tear-off planes with depth and Alt-drag angle, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane, Stamp tool cloning in perspective with live preview, all applied on OK as one step); the window's Marquee tool and the Stamp's Heal modes are still missing | | TOOL-214-15 | Content-Aware Fill workspace: paint the sampling area, preview, rotate/scale/mirror, new layer | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Engine sampling auto, rect, custom (edit_menu_cmds.rs:324); generic dialog | | TOOL-214-16 | Liquify: redo (Cmd+Shift+Z) | done | [#214](https://github.com/storytold/photocraft/issues/214) | liquify_ui.rs supports bounded redo through Cmd+Shift+Z and the control channel; new strokes clear redo | | TOOL-213-17 | Red Eye tool: click a pupil to neutralize the red reflection | done | [#213](https://github.com/storytold/photocraft/issues/213) | paint.redEye (redeye_cmds.rs) + Tool::RedEye in the J flyout; Pupil Size and Darken Amount; catchlights kept; a miss is an error | From 88d7edcb02d2da2cba68751f57db7f04d2e5d76b Mon Sep 17 00:00:00 2001 From: hogawish <60434858+hogawish@users.noreply.github.com> Date: Mon, 19 Oct 2026 12:35:27 +0900 Subject: [PATCH 143/649] fix(canvas): retain legacy checker in Pattern Preview --- crates/ui-egui/src/canvas.rs | 8 ++- .../src/canvas_cpu_background_tests.rs | 61 ++++++++++++++++++- docs/development.md | 6 ++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index d6f7b927ee..54cfaa374a 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -142,8 +142,8 @@ pub struct CanvasCache { /// `revision`, so the Navigator never shows a stale CPU image after GPU-path edits. pub tex_revision: u64, pub tex_preview_key: u64, - /// All uploaded texels are opaque: the checker behind this image cannot be seen. Updated - /// with uploads, never by scanning the document during a pan or other unchanged frame. + /// All uploaded texels are opaque. Screen coverage is checked separately before omitting + /// the checker. Updated with uploads, never by scanning during an unchanged frame. pub texture_opaque: bool, /// The CPU path's pixel grid for the part of the document in view (pixel_grid.rs). pub grid: Option, @@ -3099,7 +3099,9 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: let rotated = view.rotation.abs() > 0.05; let checkerboard = app.session.prefs().transparency_and_gamut.square().map(|square| (checker(app, &ctx), square)); let tex = ensure_texture(app, &ctx, idx, output).map(|(tex, _scale)| tex); - let opaque = app.canvases.get(&cache_key(doc.id, output)).is_some_and(|c| c.texture_opaque) && tex.is_some(); + // Repeated-quad coverage is not proven identical on all Pattern Preview adapters. + // Retain its legacy checker submissions, including the central document's. + let opaque = !app.ui.view.pattern_preview && app.canvases.get(&cache_key(doc.id, output)).is_some_and(|c| c.texture_opaque) && tex.is_some(); paint_cpu_document(&painter, &xf, doc.bounds(), rotated, checkerboard, tex, opaque); for &c in &pattern { paint_cpu_document(&painter, &pattern_xf(&xf, c, size), doc.bounds(), rotated, checkerboard, tex, opaque); diff --git a/crates/ui-egui/src/canvas_cpu_background_tests.rs b/crates/ui-egui/src/canvas_cpu_background_tests.rs index e7e6bc1d22..3a74a0adc2 100644 --- a/crates/ui-egui/src/canvas_cpu_background_tests.rs +++ b/crates/ui-egui/src/canvas_cpu_background_tests.rs @@ -110,7 +110,10 @@ fn omitting_an_occluded_checker_preserves_cpu_canvas_pixels() { }; // Fixture failures must fail the test, outside the missing-adapter skip above. assert_fixture(&h, "white"); - for (rotation, flip, pattern) in [(0.0, false, false), (23.0, false, false), (0.0, true, false), (0.0, false, true)] { + eprintln!("CPU pixel comparison adapter: {}", serde_json::to_string(&h.state().perf.gpu_info).unwrap()); + for (rotation, flip, pattern) in + [(0.0, false, false), (23.0, false, false), (0.0, true, false), (0.0, false, true), (23.0, false, true), (0.0, true, true), (23.0, true, true)] + { h.state_mut().ui.views[0].rotation = rotation; h.state_mut().ui.view.flip_horizontal = flip; h.state_mut().ui.view.pattern_preview = pattern; @@ -118,10 +121,66 @@ fn omitting_an_occluded_checker_preserves_cpu_canvas_pixels() { let reference = h.render().unwrap(); h.step(); let optimized = h.render().unwrap(); + if let Some(dir) = std::env::var_os("PHOTOCRAFT_CPU_PIXEL_OUTPUT") { + let dir = std::path::PathBuf::from(dir); + std::fs::create_dir_all(&dir).unwrap(); + let tag = format!("rotation-{rotation}-flip-{flip}-pattern-{pattern}"); + reference.save(dir.join(format!("{tag}-reference.png"))).unwrap(); + optimized.save(dir.join(format!("{tag}-optimized.png"))).unwrap(); + let mut changed = 0; + let mut bounds = [u32::MAX, u32::MAX, 0, 0]; + for (x, y, pixel) in reference.enumerate_pixels() { + if pixel != optimized.get_pixel(x, y) { + changed += 1; + bounds = [bounds[0].min(x), bounds[1].min(y), bounds[2].max(x), bounds[3].max(y)]; + } + } + let report = json!({"adapter": h.state().perf.gpu_info, "rotation": rotation, "flip": flip, + "pattern": pattern, "changed_pixels": changed, "difference_bounds": (changed > 0).then_some(bounds)}); + std::fs::write(dir.join(format!("{tag}.json")), serde_json::to_string_pretty(&report).unwrap()).unwrap(); + } assert!(reference == optimized, "rotation={rotation} flip={flip} pattern={pattern}"); } } +#[test] +fn pattern_preview_keeps_the_legacy_checker_for_every_copy() { + let Ok(mut h) = std::panic::catch_unwind(|| harness([320, 240], "white")) else { + eprintln!("skipping: no offscreen graphics adapter"); + return; + }; + assert_fixture(&h, "white"); + let checker = h.state().checker.as_ref().unwrap().id(); + let checker_meshes = |h: &Harness| { + h.output() + .shapes + .iter() + .filter_map(|s| match &s.shape { + egui::Shape::Mesh(m) if m.texture_id == checker => Some(m.clone()), + _ => None, + }) + .collect::>() + }; + for (rotation, flip) in [(0.0, false), (23.0, false), (0.0, true), (23.0, true)] { + h.state_mut().ui.view.pattern_preview = true; + h.state_mut().ui.view.flip_horizontal = flip; + let v = &mut h.state_mut().ui.views[0]; + v.zoom = 1.25; + v.center = [159.25, 119.75]; + v.rotation = rotation; + v.fit_pending = false; + v.fill_pending = false; + reference_frame(&mut h); + let reference = checker_meshes(&h); + assert!(reference.len() > 1, "the document and its visible copies need their checker"); + h.step(); + assert_eq!(checker_meshes(&h), reference, "rotation={rotation} flip={flip}: retain the legacy checker submissions"); + } + h.state_mut().ui.view.pattern_preview = false; + h.step(); + assert!(checker_meshes(&h).is_empty(), "ordinary opaque CPU canvases still omit the hidden checker"); +} + #[test] #[ignore = "manual release benchmark: 24 MP CPU canvas on the offscreen software adapter"] fn cpu_canvas_background_benchmark() { diff --git a/docs/development.md b/docs/development.md index 017df8056e..ee48536618 100644 --- a/docs/development.md +++ b/docs/development.md @@ -311,6 +311,8 @@ translations do not affect the denominator. Unregistered locale TSV files are ig adapters do not rasterize a transparency checker that the image completely hides. An edit that introduces transparency restores the checker; partial uploads conservatively retain it until a full upload proves the image opaque again. Pan/zoom frames reuse this metadata. + Pattern Preview retains every legacy checker pass: opaque texels alone do not establish + identical coverage between repeated copies on every adapter. Compare the old checker pass with the optimized path on a synthetic 24 MP document using `cargo test --release -p photocraft-ui-egui --lib cpu_canvas_background_benchmark -- --ignored --nocapture`. The benchmark alternates both paths on the same cached image and reports the adapter and @@ -318,6 +320,10 @@ translations do not affect the denominator. Unregistered locale TSV files are ig identical rendered pixels for opaque and transparent images. This measures warm canvas presentation, not input-to-photon latency or document recompositing. Set the test-only `PHOTOCRAFT_CPU_BENCH_OUTPUT` to a directory to save its JSON and before/after PNGs. + For the small pixel-identity regression, set `PHOTOCRAFT_CPU_PIXEL_OUTPUT` and run + `cargo test -p photocraft-ui-egui --lib omitting_an_occluded_checker_preserves_cpu_canvas_pixels -- --nocapture`. + This reports the adapter and saves per-view reference/optimized PNGs and exact difference + counts/bounds without relaxing the pixel comparison. - The canvas is presented by a custom WGSL shader (`ui-egui/src/gpu_canvas.rs`): mip-mapped/nearest sampling, procedural checkerboard, pixel grid, tiling. Brush strokes upload only their damage rect. - **The canvas composites on the GPU** (`photocraft-gpu`, driven from `gpu_canvas.rs`), layer effects included. What the planner can't express returns `Unsupported` and the canvas falls back to the CPU compositor (`photocraft-compose`, also the reference for export and tests): Multichannel documents, and documents or effect regions over the texture limit. Pieces the GPU can't derive itself are rasterised once on the CPU and cached (`compose::masks` for vector masks, `compose::shape_split` for stroked shapes with clipped layers, effect distance fields). Timings of the interactive paths: `cargo run --release -p photocraft-ui-egui --example interactive_bench`; effects: `--example fx_bench` (`--compare files…` for GPU vs CPU); the cost of changing a chisel bevel's size (a dragged slider, GPU and CPU, ellipse and text): `--example bevel_bench`; large documents (open, refresh, thumbnails, a filter, a stroke, saves; one operation per run so `/usr/bin/time -l` gives its peak memory): `--example large_image_bench -- --size 14000x14000 --op psd`. The app requests the adapter's own texture limit (egui's default is 8192 px; see `gpu_canvas::use_adapter_limits`); beyond it the CPU fallback composites and uploads in bands (`compose::render_bands`), and exports, thumbnails and flattening stream bands too, so no full-size float composite is ever held. Rendering fidelity: `cargo run --release -p photocraft-io --example oracle_diff -- corpus/psd` (the whole PSD oracle table in seconds). `ui.inspect` → `perf.timings.gpuFallback` names the reason (`null` on the GPU path). From b56b163c8864b4742f2aac49230d4575d0fec48e Mon Sep 17 00:00:00 2001 From: Khawar Zamman Wani Date: Mon, 19 Oct 2026 14:39:52 +0530 Subject: [PATCH 144/649] docs: regenerate the scorecard after merging main Co-Authored-By: Claude Opus 5.5 --- docs/scorecard.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/scorecard.md b/docs/scorecard.md index b320028936..8e365f3587 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -9,7 +9,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js | [Performance](#performance) | 3 | 22 | 24 | 58 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 19 not run, 5 not measurable yet (baseline 2026-10-05) | | [File compatibility](#file-compatibility) | 7 | 14 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | | [Tools](#tools) | 33 | 11 | 0 | | -| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 25 of 168 (target 0) | +| [Workspace and UI](#workspace-and-ui) | 14 | 6 | 3 | settings that do nothing: 25 of 168 (target 0) | | [Type](#type) | 4 | 3 | 2 | | | [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) | | [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 30 of 30 crates; panic_hunt present | @@ -201,7 +201,7 @@ Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_w | UI-217-14 | Layers panel: wheel steps blend modes, drop on New/Trash duplicates/deletes, checker behind art | done | [#217](https://github.com/storytold/photocraft/issues/217) | panels.rs: the wheel steps the blend-mode dropdown (widgets::dropdown_wheel_hovered, #1747); rows dropped on New Layer/Group/Delete duplicate/group/delete them (footer_drop, #736), effect rows dropped on Delete delete that effect or the whole style (fx_trash_drop, #3102); pixel thumbnails draw widgets::checker behind the art; Shift+Plus/Minus step the layer's or the painting tool's blend mode (blend_keys.rs, #3102) | | UI-217-15 | Curves: smoothing / pencil mode, black/grey/white eyedroppers, tooltips | done | [#217](https://github.com/storytold/photocraft/issues/217) | Curves editor (adjust_editors.rs, dialog and Properties): Edit points / Draw (pencil) buttons and Smooth, all with tooltips; pencil curves are 256-level maps (Adjustment::Curves pencil, params pencil/smooth, PSD curv map form and smart-filter Mpng; #3088). Set Black/Neutral Gray/White Point eyedroppers in the Image > Adjustments > Curves dialog (adjust_dialog.rs, #873) and in a Curves adjustment layer's Properties panel (layer_picker.rs: a click on the image is one layer.setAdjustment with the eyedropper param, sampling below the layer; Esc or another tool disarms; #3110) | | UI-217-16 | Hue/Saturation: Saturation and Lightness sliders get hue-following colour tracks | done | [#217](https://github.com/storytold/photocraft/issues/217) | saturation_track/lightness_track (adjust_editors.rs): grey -> the hue and black -> the hue -> white, recolouring as the Hue slider moves; saturation_and_lightness_tracks_follow_the_hue | -| UI-217-17 | Color panel: wheel plus RGB/HSB/CMYK/Lab/Gray/Web slider modes; resizes with its group | missing | [#217](https://github.com/storytold/photocraft/issues/217) | panels.rs:1837 single field + hex/RGB readout | +| UI-217-17 | Color panel: wheel plus RGB/HSB/CMYK/Lab/Gray/Web slider modes; resizes with its group | done | [#217](https://github.com/storytold/photocraft/issues/217) | color_panel_ui.rs: Hue/Brightness Cube, Color Wheel, Grayscale/RGB/HSB/CMYK/Lab/Web sliders, ramp; the same in every theme (#6000); color_panel_tests.rs | | UI-217-18 | Alt+wheel zooms in gentle ~5 % steps; zoom controls uncramped | missing | [#217](https://github.com/storytold/photocraft/issues/217) | canvas.rs:1107-1125 no Alt handling | | UI-217-19 | Shortcut hints rendered per platform; Reveal label per OS | done | [#217](https://github.com/storytold/photocraft/issues/217) | hints and tooltips go through shortcuts::pretty (6266b7a9, #262; pretty_uses_the_platform_notation); menus::reveal_label names Reveal in Finder per OS (Show in Explorer / Show in Folder) in the Smart Objects menu and the tab menu; reveal_label_names_the_platform_file_manager + smart_objects_reveal_item_names_the_platform_file_manager | | UI-217-20 | 'Show rulers in new documents' preference; guides stored as f64 | done | [#217](https://github.com/storytold/photocraft/issues/217) | View › Rulers is remembered in unitsAndRulers.showRulers and applied at launch and on change (#2918; rulers_open_as_last_set_after_a_restart); doc Guides are Vec through New Guide, .pcraft and PSD 1032 (guides_keep_sub_pixel_positions_through_pcraft_and_psd) | From 2a9842dd4d2fc8ad1f126d592de04f1c4dc1bfdd Mon Sep 17 00:00:00 2001 From: Cl4VD3 <344569071+Cl4VD3@users.noreply.github.com> Date: Mon, 19 Oct 2026 22:10:23 +0200 Subject: [PATCH 145/649] Menu bar: a held Alt's auto-repeat doesn't re-arm the Alt tap Holding Alt after Alt+wheel (zooming) for more than the key-repeat delay sent repeated Alt presses, and each one set alt_tap again, so releasing Alt still put the keyboard on the menu bar and the following Space (the Hand) opened File. Only Alt's first press starts a tap; its repeats neither re-arm nor spend it, so a long press of Alt alone is still a tap. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/menu_keys.rs | 4 +++ crates/ui-egui/src/menu_keys_tests.rs | 43 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/crates/ui-egui/src/menu_keys.rs b/crates/ui-egui/src/menu_keys.rs index c1536d8ee6..cb0b2b84de 100644 --- a/crates/ui-egui/src/menu_keys.rs +++ b/crates/ui-egui/src/menu_keys.rs @@ -210,6 +210,10 @@ impl Keys { let mut tap = false; for e in &events { match e { + // A held Alt auto-repeats (after about half a second on Windows): only its first + // press starts a tap. A repeat must neither re-arm a tap that Alt+wheel or a key + // already spent, nor spend one itself (holding Alt alone is still a tap). + Event::Key { key: Key::AltLeft | Key::AltRight, pressed: true, repeat: true, .. } => self.alt_down = true, Event::Key { key: Key::AltLeft | Key::AltRight, pressed: true, .. } => { self.alt_down = true; self.alt_tap = true; diff --git a/crates/ui-egui/src/menu_keys_tests.rs b/crates/ui-egui/src/menu_keys_tests.rs index 0298cb470f..1d980fa1ff 100644 --- a/crates/ui-egui/src/menu_keys_tests.rs +++ b/crates/ui-egui/src/menu_keys_tests.rs @@ -107,6 +107,49 @@ fn alt_with_a_wheel_scroll_or_a_lost_focus_is_no_tap() { assert_eq!(Keys::current(&h.ctx).focus, None, "Alt that went to the desktop leaves the bar alone"); } +/// Alt's own auto-repeat (holding it after Alt+wheel) doesn't make the release a tap again, and +/// holding Alt alone long enough to repeat is still a tap. +#[test] +fn a_held_alt_repeating_after_the_wheel_is_no_tap() { + let repeat = |h: &mut Harness<'static, PhotocraftApp>| { + h.event_modifiers( + egui::Event::Key { key: egui::Key::AltLeft, physical_key: None, pressed: true, repeat: true, modifiers: egui::Modifiers::ALT }, + egui::Modifiers::ALT, + ); + h.run_steps(1); + }; + let mut h = bar(); + h.key_down(egui::Key::AltLeft); + h.run_steps(2); + h.event_modifiers( + egui::Event::MouseWheel { + unit: egui::MouseWheelUnit::Line, + delta: egui::vec2(0.0, 1.0), + modifiers: egui::Modifiers::ALT, + phase: egui::TouchPhase::Move, + }, + egui::Modifiers::ALT, + ); + h.run_steps(2); + for _ in 0..5 { + repeat(&mut h); + } + h.key_up(egui::Key::AltLeft); + h.run_steps(3); + assert_eq!(Keys::current(&h.ctx).focus, None, "Alt held on after the wheel: still no tap"); + key(&mut h, egui::Key::Space); + assert!(!is_open(&h.ctx), "Space opens no menu"); + // Alt alone, held long enough to repeat, is still a tap. + h.key_down(egui::Key::AltLeft); + h.run_steps(1); + for _ in 0..5 { + repeat(&mut h); + } + h.key_up(egui::Key::AltLeft); + h.run_steps(3); + assert_eq!(Keys::current(&h.ctx).focus, Some(0), "a long press of Alt alone focuses the bar"); +} + #[test] fn a_second_alt_or_esc_or_a_click_takes_the_keyboard_off_the_bar() { let mut h = bar(); From 7bf4cc0739307dc1a930c828cfa7080837abe874 Mon Sep 17 00:00:00 2001 From: ersoynarin-code Date: Tue, 20 Oct 2026 01:54:27 +0300 Subject: [PATCH 146/649] perf(photomerge): track multiband timing and peak memory --- crates/algo/examples/bench_multiband.rs | 181 ++++++++++++++++++++---- docs/scorecard.md | 3 +- perf/budgets.toml | 19 +++ 3 files changed, 176 insertions(+), 27 deletions(-) diff --git a/crates/algo/examples/bench_multiband.rs b/crates/algo/examples/bench_multiband.rs index 9d58b81a54..d3dcdc2f0b 100644 --- a/crates/algo/examples/bench_multiband.rs +++ b/crates/algo/examples/bench_multiband.rs @@ -1,42 +1,171 @@ -//! Time and peak memory of the Photomerge multi-band blend: `n` RGB sources of `mp` megapixels -//! (3:2), each overlapping the next by half its width. -//! `cargo run --release -p photocraft-algo --example bench_multiband [n] [mp]` (default 4 × 24 MP). -//! Peak memory is the growth of the process's high-water mark during the blend (Linux only). +//! Time and peak memory of Photomerge's multi-band blend on overlapping RGB sources. +//! Backwards compatible: `cargo run --release -p photocraft-algo --example bench_multiband [n] [mp]`. +//! `cargo xtask perf --bench bench_multiband --quick` also collects repeatable JSON timings. +//! The peak is the entire process's resident-set high-water mark, not an estimate of allocations +//! by the blend alone. Available on Linux and Windows; other platforms report no peak value. +use std::path::PathBuf; use std::time::Instant; use photocraft_algo::panorama::{self, RoiImage}; +use serde_json::json; -/// The process's peak resident set in MiB (`VmHWM`), where `/proc` has it. -fn peak_mib() -> Option { - let s = std::fs::read_to_string("/proc/self/status").ok()?; - let kb: f64 = s.lines().find(|l| l.starts_with("VmHWM:"))?.split_whitespace().nth(1)?.parse().ok()?; - Some(kb / 1024.0) +const ROW: &str = "Photomerge multiband blend"; + +#[derive(Debug, PartialEq)] +struct Options { + n: usize, + mp: f64, + reps: usize, + json: Option, } -fn main() { - let mut args = std::env::args().skip(1); - let n: usize = args.next().and_then(|a| a.parse().ok()).unwrap_or(4).max(1); - let mp: f64 = args.next().and_then(|a| a.parse().ok()).unwrap_or(24.0); - let sh = ((mp * 1e6 / 1.5).sqrt().round() as usize).max(2); +fn options(args: impl IntoIterator) -> Result { + let mut out = Options { n: 4, mp: 24.0, reps: 1, json: None }; + let mut positional = Vec::new(); + let mut it = args.into_iter(); + while let Some(arg) = it.next() { + match arg.as_str() { + "--json" => out.json = Some(PathBuf::from(it.next().ok_or("--json needs a file path")?)), + "--reps" => { + out.reps = it.next().ok_or("--reps needs an integer")?.parse().map_err(|_| "--reps needs an integer")?; + } + _ if !arg.starts_with('-') => positional.push(arg), + _ => return Err(format!("unknown option: {arg}")), + } + } + if positional.len() > 2 { + return Err("expected at most [n] [mp]".into()); + } + if let Some(n) = positional.first() { + out.n = n.parse().map_err(|_| "n must be an integer")?; + } + if let Some(mp) = positional.get(1) { + out.mp = mp.parse().map_err(|_| "mp must be a number")?; + } + if !(1..=16).contains(&out.n) || !(1..=25).contains(&out.reps) || !out.mp.is_finite() || !(0.01..=24.0).contains(&out.mp) { + return Err("expected 1..=16 images, 0.01..=24 MP per image and 1..=25 repetitions".into()); + } + Ok(out) +} + +/// Peak resident set size in bytes (Linux: VmHWM; Windows: PeakWorkingSet64). +/// Called outside the timed code. This metric includes input buffers and output buffers. +fn peak_rss_bytes() -> Option { + #[cfg(target_os = "linux")] + { + let s = std::fs::read_to_string("/proc/self/status").ok()?; + let kb: u64 = s.lines().find(|l| l.starts_with("VmHWM:"))?.split_whitespace().nth(1)?.parse().ok()?; + return kb.checked_mul(1024); + } + #[cfg(target_os = "windows")] + { + // A standard Windows system utility; no unsafe FFI or new crate is needed in this + // performance example. Its process-launch cost is outside the measurement window. + let cmd = format!("(Get-Process -Id {}).PeakWorkingSet64", std::process::id()); + let out = std::process::Command::new("powershell.exe").args(["-NoProfile", "-NonInteractive", "-Command", &cmd]).output().ok()?; + return out.status.success().then_some(out.stdout).and_then(|v| String::from_utf8(v).ok())?.trim().parse().ok(); + } + #[cfg(not(any(target_os = "linux", target_os = "windows")))] + None +} + +fn run() -> Result<(), String> { + let o = options(std::env::args().skip(1))?; + let sh = ((o.mp * 1e6 / 1.5).sqrt().round() as usize).max(2); let sw = sh * 3 / 2; let step = sw / 2; - let (cw, ch) = (step * (n - 1) + sw, sh); - let rois: Vec = (0..n) + let (cw, ch) = (step * (o.n - 1) + sw, sh); + let rois: Vec = (0..o.n) .map(|k| { let px = (0..sw * sh * 3).map(|i| ((i / 3 % sw * 7 + i / 3 / sw * 3 + k * 31 + i % 3 * 50) % 251) as f32 / 251.0).collect(); RoiImage { x0: (step * k) as i32, y0: 0, w: sw, h: sh, ch: 3, px, alpha: vec![1.0; sw * sh] } }) .collect(); - // Each canvas column belongs to the image whose centre is nearest, as a seam would split it. - let wts: Vec> = (0..n) - .map(|k| (0..sw * sh).map(|i| if ((step * k + i % sw + step / 2) / step).saturating_sub(1).min(n - 1) == k { 1.0 } else { 0.0 }).collect()) + let wts: Vec> = (0..o.n) + .map(|k| (0..sw * sh).map(|i| if ((step * k + i % sw + step / 2) / step).saturating_sub(1).min(o.n - 1) == k { 1.0 } else { 0.0 }).collect()) .collect(); let levels = panorama::blend_levels(cw, ch).min(7); - let before = peak_mib(); - let t0 = Instant::now(); - let (px, cov) = panorama::multiband(cw, ch, &rois, &wts, levels); - let ms = t0.elapsed().as_secs_f64() * 1000.0; - let peak = peak_mib().zip(before).map_or("n/a".to_string(), |(a, b)| format!("{:.0} MiB", a - b)); - println!("{n} × {sw}×{sh} ({mp} MP) RGB, canvas {cw}×{ch}, {levels} levels: {ms:.0} ms, peak +{peak} during the blend"); - std::hint::black_box((px, cov)); + let before = peak_rss_bytes(); + let mut samples_ms = Vec::with_capacity(o.reps); + for _ in 0..o.reps { + let t0 = Instant::now(); + let output = panorama::multiband(cw, ch, &rois, &wts, levels); + samples_ms.push(t0.elapsed().as_secs_f64() * 1000.0); + std::hint::black_box(&output); + } + let peak = peak_rss_bytes(); + let delta = before.zip(peak).map(|(a, b)| b.saturating_sub(a) as f64 / (1024.0 * 1024.0)); + let med = { + let mut sorted = samples_ms.clone(); + sorted.sort_by(f64::total_cmp); + sorted[sorted.len() / 2] + }; + println!( + "{} × {}×{} ({:.2} MP) RGB, canvas {}×{}, {} levels: {:.1} ms median ({} runs), peak +{}", + o.n, + sw, + sh, + o.mp, + cw, + ch, + levels, + med, + o.reps, + delta.map_or("n/a".to_string(), |m| format!("{m:.0} MiB")) + ); + if let Some(path) = o.json { + let report = json!({ + "context": {"sources": o.n, "mp_per_source": o.mp, "canvas_width": cw, "canvas_height": ch, "levels": levels}, + "process_peak_rss_bytes": peak, + "rows": [{"name": ROW, "samples_ms": samples_ms, "peak_rss_bytes": peak}] + }); + if let Some(parent) = path.parent() { + std::fs::create_dir_all(parent).map_err(|e| format!("create {}: {e}", parent.display()))?; + } + std::fs::write(&path, serde_json::to_vec_pretty(&report).map_err(|e| e.to_string())?).map_err(|e| format!("write {}: {e}", path.display()))?; + } + Ok(()) +} + +fn main() { + if let Err(e) = run() { + eprintln!("bench_multiband: {e}"); + std::process::exit(2); + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn parse(args: &[&str]) -> Result { + options(args.iter().map(|s| s.to_string())) + } + + #[test] + fn parses_old_positional_args_and_perf_runner_args() { + assert_eq!(parse(&[]).unwrap().n, 4); + assert_eq!( + parse(&["2", "0.25", "--reps", "3", "--json", "out.json"]).unwrap(), + Options { n: 2, mp: 0.25, reps: 3, json: Some(PathBuf::from("out.json")) } + ); + } + + #[test] + fn rejects_bad_benchmark_args() { + for args in [ + vec!["0"], + vec!["17"], + vec!["2", "0"], + vec!["2", "NaN"], + vec!["2", "inf"], + vec!["--reps", "0"], + vec!["--reps", "26"], + vec!["--json"], + vec!["--reps"], + vec!["--unknown"], + ] { + assert!(parse(&args).is_err(), "{args:?}"); + } + } } diff --git a/docs/scorecard.md b/docs/scorecard.md index c4b53a20f8..b9902151c8 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -6,7 +6,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js | Area | Done | Partial | Missing | Key numbers | |---|---:|---:|---:|---| -| [Performance](#performance) | 3 | 22 | 24 | 58 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 19 not run, 5 not measurable yet (baseline 2026-10-05) | +| [Performance](#performance) | 3 | 22 | 25 | 59 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 20 not run, 5 not measurable yet (baseline 2026-10-05) | | [File compatibility](#file-compatibility) | 7 | 14 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | | [Tools](#tools) | 33 | 11 | 0 | | | [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 25 of 169 (target 0) | @@ -24,6 +24,7 @@ Baseline: 2026-10-05, commit `f5d2bcb54a`, Apple M4 Pro (48 GB), GPU Apple M4 Pr | Id | Scenario | Target | p50 ms | p95 ms | max ms | Peak RSS | GPU | Status | Issue | |---|---|---|---:|---:|---:|---:|---:|---|---| +| P62 | Photomerge multi-band blend, synthetic | track timing and peak RSS; no calibrated performance budget | – | – | – | – | – | not run | [#7758](https://github.com/storytold/photocraft/issues/7758) | | P1 | Move a layer with layer styles (per drag update) | ≤ 25 ms p95 | 321 | 535 | 535 | 825 MB | 409 MB | over budget (target not met yet) | [#209](https://github.com/storytold/photocraft/issues/209) | | P2 | Change layer opacity | ≤ 20 ms p95 | 276 | 443 | 443 | 639 MB | 409 MB | over budget (target not met yet) | [#209](https://github.com/storytold/photocraft/issues/209) | | P3 | Change layer fill | ≤ 20 ms p95 | 279 | 467 | 467 | 506 MB | 409 MB | over budget (target not met yet) | [#209](https://github.com/storytold/photocraft/issues/209) | diff --git a/perf/budgets.toml b/perf/budgets.toml index da47aa0503..86ab5a7b4f 100644 --- a/perf/budgets.toml +++ b/perf/budgets.toml @@ -69,6 +69,25 @@ requires = "crates/ui-egui/examples/layout_bench.rs" quick_args = [] note = "layout PSDs with many styled layers (#125/#128)" +# Photomerge (#7758): the bounded-band algorithm must remain fast and its process-level +# resident-set high-water mark is tracked (on Linux and Windows). No uncalibrated budget is +# enforced. Full mode uses 4 x 2 MP so ordinary CI machines do not allocate multi-GB blends; +# use the stand-alone example for the 4 x 24 MP stress test. +[[bench]] +name = "bench_multiband" +package = "photocraft-algo" +args = ["4", "2", "--reps", "5"] +quick_args = ["2", "0.25", "--reps", "3"] +note = "synthetic Photomerge multi-band blend; resident-set peak includes input/output buffers" + +[[scenario]] +id = "P62" +title = "Photomerge multi-band blend, synthetic" +issue = 7758 +bench = "bench_multiband" +row = "Photomerge multiband blend" +target = "track timing and peak RSS; no calibrated performance budget" + # ---- #209: interactive edits on layered documents (20 MP, styled layers) --------------------- [[scenario]] From 037177abde9c58c77680247cc9272650c87ac42b Mon Sep 17 00:00:00 2001 From: vangel76 Date: Tue, 20 Oct 2026 01:21:45 +0200 Subject: [PATCH 147/649] docs: regenerate the scorecard after merging main Co-Authored-By: Claude Sonnet 5.5 --- docs/scorecard.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/scorecard.md b/docs/scorecard.md index c4b53a20f8..8bdea9ae72 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -8,7 +8,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js |---|---:|---:|---:|---| | [Performance](#performance) | 3 | 22 | 24 | 58 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 19 not run, 5 not measurable yet (baseline 2026-10-05) | | [File compatibility](#file-compatibility) | 7 | 14 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | -| [Tools](#tools) | 33 | 11 | 0 | | +| [Tools](#tools) | 34 | 10 | 0 | | | [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 25 of 169 (target 0) | | [Type](#type) | 4 | 3 | 2 | | | [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) | @@ -160,7 +160,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t | TOOL-214-11 | Stroke Path dialog: pick any brush-based tool, Simulate Pressure | done | [#214](https://github.com/storytold/photocraft/issues/214) | path.stroke tool: Brush, Pencil, Eraser and every other brush-based tool (Background Eraser, Clone/Pattern Stamp, Healing/Spot Healing Brush, History Brush, Blur, Sharpen, Smudge, Dodge, Burn, Sponge, Color Replacement, Mixer Brush: their paint.* command along the path, one step) plus simulatePressure (taper both ends); Stroke Path dialog from the Pen menu, the Paths panel menu and Alt-click on its Stroke button (#2978) | | TOOL-214-12 | Shapes: on-canvas corner radius handles, shape feather, selection to shape with tolerance | partial | [#214](https://github.com/storytold/photocraft/issues/214) | On-canvas corner radius widgets on every selected live rectangle with Path Selection, the Rectangle tool and Move + Show Transform Controls: drag rounds every corner of every selected rectangle alike, Alt that corner on each, corner radius cursor and R: readout, one history step (corner_radius.rs, 2026-10-13); select.convertToShape with tolerance (vector_cmds.rs:1256). Missing: shape feather | | TOOL-214-13 | Mask Properties: Density and Feather controls | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Vector-mask density/feather in the engine (vector_cmds.rs:948); no UI controls | -| TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | partial | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15); on-canvas plane editor (vp_ui.rs: Create/Edit Plane, edge nodes, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane on OK); clone stamp, marquee and tear-off planes in the window still missing | +| TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | done | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15); on-canvas window (vp_ui.rs: Create/Edit Plane, edge nodes, Ctrl/Cmd-drag tear-off planes with depth and Alt-drag angle, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane, Stamp tool cloning in perspective with live preview, all applied on OK as one step); the window's Marquee tool and the Stamp's Heal modes are still missing | | TOOL-214-15 | Content-Aware Fill workspace: paint the sampling area, preview, rotate/scale/mirror, new layer | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Engine sampling auto, rect, custom (edit_menu_cmds.rs:324); generic dialog | | TOOL-214-16 | Liquify: redo (Cmd+Shift+Z) | done | [#214](https://github.com/storytold/photocraft/issues/214) | liquify_ui.rs supports bounded redo through Cmd+Shift+Z and the control channel; new strokes clear redo | | TOOL-213-17 | Red Eye tool: click a pupil to neutralize the red reflection | done | [#213](https://github.com/storytold/photocraft/issues/213) | paint.redEye (redeye_cmds.rs) + Tool::RedEye in the J flyout; Pupil Size and Darken Amount; catchlights kept; a miss is an error | From c9cbe6a416a9dba53f8e8be1f79b1b82eeb9f402 Mon Sep 17 00:00:00 2001 From: ersoynarin-code Date: Tue, 20 Oct 2026 02:22:44 +0300 Subject: [PATCH 148/649] docs(photomerge): document benchmark helpers --- crates/algo/examples/bench_multiband.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/algo/examples/bench_multiband.rs b/crates/algo/examples/bench_multiband.rs index d3dcdc2f0b..064abeba51 100644 --- a/crates/algo/examples/bench_multiband.rs +++ b/crates/algo/examples/bench_multiband.rs @@ -19,6 +19,8 @@ struct Options { json: Option, } +/// Parses legacy `[n] [mp]` arguments and the perf runner's `--reps`/`--json` flags. +/// Rejects missing, out-of-range, or non-finite values before allocating images. fn options(args: impl IntoIterator) -> Result { let mut out = Options { n: 4, mp: 24.0, reps: 1, json: None }; let mut positional = Vec::new(); @@ -69,6 +71,8 @@ fn peak_rss_bytes() -> Option { None } +/// Builds deterministic overlapping RGB inputs and times each multi-band blend. +/// Writes individual samples and whole-process peak RSS to JSON when requested. fn run() -> Result<(), String> { let o = options(std::env::args().skip(1))?; let sh = ((o.mp * 1e6 / 1.5).sqrt().round() as usize).max(2); @@ -127,6 +131,7 @@ fn run() -> Result<(), String> { Ok(()) } +/// Runs the benchmark, reporting argument or output errors with a failing exit status. fn main() { if let Err(e) = run() { eprintln!("bench_multiband: {e}"); @@ -138,10 +143,12 @@ fn main() { mod tests { use super::*; + /// Converts borrowed argument slices for the owned-string command-line parser. fn parse(args: &[&str]) -> Result { options(args.iter().map(|s| s.to_string())) } + /// Confirms backwards compatibility with the positional and perf-runner forms. #[test] fn parses_old_positional_args_and_perf_runner_args() { assert_eq!(parse(&[]).unwrap().n, 4); @@ -151,6 +158,7 @@ mod tests { ); } + /// Checks invalid counts, non-finite sizes, repetitions, and missing flag values. #[test] fn rejects_bad_benchmark_args() { for args in [ From 4d3af32e0f85f1e3f6b370ea4a1a6ae809ae63a3 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Tue, 20 Oct 2026 01:35:56 +0200 Subject: [PATCH 149/649] fix(mask-view): turning one mask view off keeps the other mask's view --- crates/engine/src/mask_view_cmds.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/src/mask_view_cmds.rs b/crates/engine/src/mask_view_cmds.rs index 8414fa71c8..4312f92f6c 100644 --- a/crates/engine/src/mask_view_cmds.rs +++ b/crates/engine/src/mask_view_cmds.rs @@ -135,7 +135,7 @@ fn set_view(s: &mut Session, p: &Value) -> Result { let st = s.active_mut().ok_or(EngineError::NoDocument)?; let next = want.map(|mode| LayerMaskView { layer, mode, filter }); // "off" for a layer whose mask isn't the one shown leaves the other view alone. - let applies = next.is_some() || st.channel_view.layer_mask.is_some_and(|v| v.layer == layer); + let applies = next.is_some() || st.channel_view.layer_mask.is_some_and(|v| v.layer == layer && v.filter == filter); if applies && st.channel_view.layer_mask != next { st.channel_view.layer_mask = next; // Hiding the mask while every colour channel is off would leave a blank canvas. From 0741b128ff6c0c027681f7a5552e97aab1469467 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Tue, 20 Oct 2026 01:37:13 +0200 Subject: [PATCH 150/649] fix(vp): keep the Vanishing Point session when commit fails --- crates/ui-egui/src/vp_ui.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/vp_ui.rs b/crates/ui-egui/src/vp_ui.rs index 1a466e7bc4..c3dc645dd9 100644 --- a/crates/ui-egui/src/vp_ui.rs +++ b/crates/ui-egui/src/vp_ui.rs @@ -750,11 +750,18 @@ pub fn commit(app: &mut PhotocraftApp) -> Result { return Err(msg.into()); } let params = s.params(); - app.distort.vanishing = None; + let session = app.distort.vanishing.take(); if params.get("paste").is_none() && params.get("clone").is_none() { return Ok(json!({"committed": false})); } - app.run(VP, params).map(|r| json!({"committed": true, "result": r})) + match app.run(VP, params) { + Ok(r) => Ok(json!({"committed": true, "result": r})), + Err(e) => { + // Keep the planes, source and strokes so the user can fix the cause and retry. + app.distort.vanishing = session; + Err(e) + } + } } /// Control channel: `filter.vanishingPoint {"ui": {...}}` while the mode is active. From ee0fe906a20adfbd631ceb620cd37ff158fdfb22 Mon Sep 17 00:00:00 2001 From: mweinbach Date: Mon, 19 Oct 2026 14:58:18 -0400 Subject: [PATCH 151/649] gpu, docs: fix timing test skip guard and document Windows ARM64 build on RTX Spark - Subtract submit_ms when checking the execution window in gpu_time_tracks_execution_not_submission (wall_ms - submit_ms < 3.0 * submit_ms). - Document clang-cl requirement for Windows on ARM64 (aarch64-pc-windows-msvc) builds in docs/development.md. - Add [people.mweinbach] to contributors/people.toml per AGENTS.md. --- contributors/people.toml | 3 +++ crates/gpu/tests/timing.rs | 8 +++++--- docs/development.md | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/contributors/people.toml b/contributors/people.toml index bc3533777b..5fd8631b91 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -72,6 +72,9 @@ sync_github_name = true [people.maxm11] sync_github_name = true +[people.mweinbach] +sync_github_name = true + [people.skraus2] sync_github_name = true diff --git a/crates/gpu/tests/timing.rs b/crates/gpu/tests/timing.rs index 24c2057253..19ee824d86 100644 --- a/crates/gpu/tests/timing.rs +++ b/crates/gpu/tests/timing.rs @@ -138,9 +138,11 @@ fn gpu_time_tracks_execution_not_submission() { assert_eq!(t.px, area(full), "the measurement carries the pixels of the refresh it measured"); assert!(t.spans >= 1, "at least one command buffer was timed"); - // The premise: on this adapter the refresh really is dominated by GPU execution. A machine - // fast enough that it isn't cannot tell the two timings apart, so say so instead of failing. - if wall_ms < 3.0 * submit_ms { + // The premise: on this adapter the refresh really is dominated by GPU execution. `wall_ms` + // includes `submit_ms`, so the GPU execution window is `wall_ms - submit_ms`; a machine fast + // enough that this window isn't well above `3.0 * submit_ms` cannot tell the two timings + // apart, so say so instead of failing. + if wall_ms - submit_ms < 3.0 * submit_ms { eprintln!("SKIP the comparison: this GPU finishes a 6 MP composite in {wall_ms:.1} ms against {submit_ms:.1} ms of encoding"); return; } diff --git a/docs/development.md b/docs/development.md index 6891e88a9c..77c677d7cc 100644 --- a/docs/development.md +++ b/docs/development.md @@ -12,7 +12,9 @@ ### Windows source builds Use the Rust MSVC toolchain and install Visual Studio or Microsoft C++ Build Tools with the -**Desktop development with C++** workload. Follow Microsoft's +**Desktop development with C++** workload (on Windows on ARM64 / `aarch64-pc-windows-msvc`, such +as NVIDIA RTX Spark, also select **C++ Clang Compiler for Windows** or ensure `clang-cl.exe` is on +`PATH`, as `aws-lc-sys` needs it to assemble ARMv8 crypto routines). Follow Microsoft's [Rust setup guide](https://learn.microsoft.com/en-us/windows/dev-environment/rust/setup), then open a new terminal and check `cargo --version` and `rustc --version`. From 4e2c107ac5138872daff0ac3b28a1694d33b94e0 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sat, 17 Oct 2026 04:02:48 +0000 Subject: [PATCH 152/649] Stored paths: use resolve_absolute before opening linked files --- crates/io/src/doc_path.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/crates/io/src/doc_path.rs b/crates/io/src/doc_path.rs index 37e7daf214..ce6cc0fdcb 100644 --- a/crates/io/src/doc_path.rs +++ b/crates/io/src/doc_path.rs @@ -35,13 +35,11 @@ impl std::error::Error for NotFollowed {} /// a relative `document` is taken from the working directory, where it was opened from. pub fn resolve(stored: &str, document: Option<&Path>) -> Result { let document = document.map(|d| if d.is_relative() { std::path::absolute(d).unwrap_or_else(|_| d.to_path_buf()) } else { d.to_path_buf() }); - let path = craft_docpath::resolve(stored, document.as_deref()).map_err(NotFollowed::Refused)?; - // A path that is still relative would be taken from the working directory, which the - // document does not choose. - if path.is_relative() { - return Err(NotFollowed::NoDocumentFolder); - } - Ok(path) + craft_docpath::resolve_absolute(stored, document.as_deref()).map_err(|r| match r { + // Without a document, a relative path resolves but stays relative. + Refused::Invalid if document.is_none() && craft_docpath::resolve(stored, None).is_ok() => NotFollowed::NoDocumentFolder, + r => NotFollowed::Refused(r), + }) } #[cfg(test)] @@ -55,5 +53,17 @@ mod tests { assert_eq!(resolve("logo.png", None), Err(NotFollowed::NoDocumentFolder)); assert_eq!(resolve(r"\\192.0.2.1\share\x.png", Some(&doc)), Err(NotFollowed::Refused(Refused::Network))); assert_eq!(resolve("//192.0.2.1/share/x.png", None), Err(NotFollowed::Refused(Refused::Network))); + assert_eq!(resolve("jar:logo.png", None), Err(NotFollowed::Refused(Refused::Url))); + // Colons in names: an alternate data stream or a URL on Windows, a plain character elsewhere. + if cfg!(windows) { + assert_eq!(resolve("img/fig:1.png", Some(&doc)), Err(NotFollowed::Refused(Refused::Invalid))); + assert_eq!(resolve("chapter1:intro.png", None), Err(NotFollowed::Refused(Refused::Url))); + } else { + assert_eq!(resolve("img/fig:1.png", Some(&doc)), Ok(std::env::temp_dir().join("art").join("img").join("fig:1.png"))); + assert_eq!(resolve("chapter1:intro.png", None), Err(NotFollowed::NoDocumentFolder)); + } + // On Unix a Windows path names no file: it is refused, not reported as relative. + #[cfg(unix)] + assert_eq!(resolve(r"C:\art\logo.png", Some(&doc)), Err(NotFollowed::Refused(Refused::Invalid))); } } From 6401cfdbe18ae5d9301cb610fedf356d6f773193 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sat, 17 Oct 2026 04:02:48 +0000 Subject: [PATCH 153/649] CI: check that git dependencies come from storytold --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba8243353d..07f54982a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,6 +50,11 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Git dependencies come from storytold + run: | + if grep -E '^source = "git\+' Cargo.lock | grep -v '"git+https://github.com/storytold/'; then + echo "Cargo.lock has a git dependency outside github.com/storytold"; exit 1 + fi - id: pick env: EVENT: ${{ github.event_name }} From 8f9ebc3136c549f8c09121cb15a8d35fc78e4ef2 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sat, 17 Oct 2026 04:07:06 +0000 Subject: [PATCH 154/649] CI: release only with git dependencies from storytold --- .github/workflows/release.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bfdca9e3e9..4666f5a851 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,21 @@ concurrency: cancel-in-progress: false jobs: + git-sources: + name: Git dependencies come from storytold + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + - name: Check Cargo.lock + run: | + if grep -E '^source = "git\+' Cargo.lock | grep -v '"git+https://github.com/storytold/'; then + echo "Cargo.lock has a git dependency outside github.com/storytold"; exit 1 + fi + release: + needs: git-sources # Intentionally tracked at @main (not SHA-pinned) so org-wide CI improvements, security fixes, and build optimizations propagate without PR churn across all craftapp repos. uses: storytold/craft-common-actions/.github/workflows/release.yml@main with: From ed9bf013c093a9f98426329559f1558eb19574eb Mon Sep 17 00:00:00 2001 From: Khawar Zamman Wani Date: Wed, 21 Oct 2026 01:17:04 +0530 Subject: [PATCH 155/649] CLI: reject ignored or conflicting mcp/serve launch options `mcp` and `serve` silently accepted positional arguments, repeated options, empty values, credential flags for an inactive transport, and (in bridge mode) root flags the desktop process owns. They are now usage errors (exit 2, stderr only) before any server starts or token file is created. The shared parser also refuses another long flag or `-h` as a missing value. Co-Authored-By: Claude Opus 5.5 --- apps/photocraft-cli/src/lib.rs | 43 +++++++++++++++++++- apps/photocraft-cli/tests/cli.rs | 67 ++++++++++++++++++++++++++++++++ book/src/automation/cli.md | 5 +++ docs/mcp.md | 11 ++++++ 4 files changed, 124 insertions(+), 2 deletions(-) diff --git a/apps/photocraft-cli/src/lib.rs b/apps/photocraft-cli/src/lib.rs index 0e3429d074..20eea19d51 100644 --- a/apps/photocraft-cli/src/lib.rs +++ b/apps/photocraft-cli/src/lib.rs @@ -45,15 +45,20 @@ USAGE: photocraft-cli mcp [--bridge <127.0.0.1:port>] [--control-token <64-hex> | --control-token-file ] [--automation-read-root ] [--automation-write-root ] Run the MCP server on stdio (headless engine, or bridge to a running `photocraft --control `). + Headless: each root grants that direction of file access; an omitted root denies it. + Prefer absolute root paths in MCP client configurations. + Bridge: set roots on the desktop app; CLI root flags are rejected. Explicit token flags + require --bridge; credentials can also use PHOTOCRAFT_CONTROL_TOKEN or PHOTOCRAFT_CONTROL_TOKEN_FILE. photocraft-cli serve [--port ] [--control-token <64-hex> | --control-token-file ] [--automation-read-root ] [--automation-write-root ] Keep one headless session open and answer JSON lines ({\"id\",\"method\",\"params\"}) on stdio, or on 127.0.0.1:. Methods: engine.execute, jobs.list/cancel, engine.commands, doc.open/new/place/save/exportLayers/exportDataSets/importDataSets/inspect/render/select/close, session.list, batch, methods (docs/control-protocol.md#headless-server). + Explicit token flags require --port. Stdio needs no control token. photocraft-cli --help (or -h) prints this text. A flag the subcommand doesn't take is - an error. + an error. mcp and serve take no positional arguments; their options cannot be repeated or empty. "; struct Args { @@ -124,7 +129,7 @@ fn parse(sub: &Subcommand, args: &[String]) -> Result, String> { } a.flags.push((k.to_owned(), Some(v.to_owned()))); } else if sub.values.contains(&s.as_str()) { - let v = args.get(i + 1).ok_or_else(|| format!("{s} needs a value"))?; + let v = args.get(i + 1).filter(|v| !v.starts_with("--") && v.as_str() != "-h").ok_or_else(|| format!("{s} needs a value"))?; a.flags.push((s.clone(), Some(v.clone()))); i += 1; } else if sub.bare.contains(&s.as_str()) { @@ -136,9 +141,43 @@ fn parse(sub: &Subcommand, args: &[String]) -> Result, String> { } i += 1; } + validate_server_args(sub.name, &a)?; Ok(Some(a)) } +/// Refuse launch options that would otherwise be silently ignored. In particular, bridge +/// roots belong to the desktop process: accepting them here promises authority we cannot set. +fn validate_server_args(sub: &str, a: &Args) -> R { + if !matches!(sub, "mcp" | "serve") { + return Ok(()); + } + if !a.positional.is_empty() { + return Err(format!("{sub} does not take positional arguments")); + } + let mut seen = std::collections::HashSet::new(); + for (flag, value) in &a.flags { + if !seen.insert(flag) { + return Err(format!("{flag} may only be specified once")); + } + if value.as_deref().is_none_or(str::is_empty) { + return Err(format!("{flag} needs a non-empty value")); + } + } + if a.has("--control-token") && a.has("--control-token-file") { + return Err("use either --control-token or --control-token-file, not both".into()); + } + let transport = if sub == "mcp" { "--bridge" } else { "--port" }; + for flag in ["--control-token", "--control-token-file"] { + if a.has(flag) && !a.has(transport) { + return Err(format!("{flag} requires {transport}")); + } + } + if sub == "mcp" && a.has("--bridge") && (a.has("--automation-read-root") || a.has("--automation-write-root")) { + return Err("configure automation roots on the desktop app; --automation-read-root and --automation-write-root require headless MCP mode".into()); + } + Ok(()) +} + impl Args { fn get(&self, k: &str) -> Option<&str> { self.flags.iter().rev().find(|(f, _)| f == k).and_then(|(_, v)| v.as_deref()) diff --git a/apps/photocraft-cli/tests/cli.rs b/apps/photocraft-cli/tests/cli.rs index 6c62e40804..78ac2177e0 100644 --- a/apps/photocraft-cli/tests/cli.rs +++ b/apps/photocraft-cli/tests/cli.rs @@ -105,6 +105,73 @@ fn unknown_flags_are_usage_errors() { assert!(!out.trim().contains('\n'), "compact JSON is one line"); } +fn server_usage_error(args: &[&str], expected: &str) { + let o = bin().args(args).env_remove("PHOTOCRAFT_CONTROL_TOKEN").env_remove("PHOTOCRAFT_CONTROL_TOKEN_FILE").stdin(Stdio::null()).output().unwrap(); + let err = String::from_utf8_lossy(&o.stderr); + assert_eq!(o.status.code(), Some(2), "{args:?}: {err}"); + assert!(o.stdout.is_empty(), "usage errors must leave protocol stdout empty: {args:?}"); + assert!(err.contains(expected), "{args:?}: expected {expected:?} in {err}"); +} + +#[test] +fn server_modes_reject_ignored_or_conflicting_options() { + for sub in ["mcp", "serve"] { + server_usage_error(&[sub, "stray.psd"], "does not take positional arguments"); + for flag in ["--control-token", "--control-token-file"] { + server_usage_error(&[sub, flag, "unused"], if sub == "mcp" { "requires --bridge" } else { "requires --port" }); + } + for flag in ["--automation-read-root", "--automation-write-root"] { + server_usage_error(&[sub, flag, ".", flag, "."], "may only be specified once"); + server_usage_error(&[sub, &format!("{flag}=")], "needs a non-empty value"); + server_usage_error(&[sub, flag, "--automation-write-root", "."], &format!("{flag} needs a value")); + server_usage_error(&["mcp", "--bridge", "127.0.0.1:7878", flag, "."], "configure automation roots on the desktop app"); + } + let transport = if sub == "mcp" { "--bridge" } else { "--port" }; + for flag in [transport, "--control-token", "--control-token-file"] { + server_usage_error(&[sub, flag, "one", &format!("{flag}=two")], "may only be specified once"); + server_usage_error(&[sub, flag, ""], "needs a non-empty value"); + } + server_usage_error( + &[sub, transport, "7878", "--control-token", "unused", "--control-token-file", "unused"], + "use either --control-token or --control-token-file", + ); + } +} + +#[test] +fn server_validation_does_not_consume_stdio_or_create_files() { + let d = tmp("server-validation"); + let token = d.join("must-not-be-created.token"); + let mut child = bin() + .args(["serve", "--port", "0", "--control-token-file"]) + .arg(&token) + .arg("stray") + .env_remove("PHOTOCRAFT_CONTROL_TOKEN") + .env_remove("PHOTOCRAFT_CONTROL_TOKEN_FILE") + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .unwrap(); + // Keep stdin open: invalid launch arguments must fail before starting a server. + let input = child.stdin.take().unwrap(); + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5); + while child.try_wait().unwrap().is_none() && std::time::Instant::now() < deadline { + std::thread::sleep(std::time::Duration::from_millis(10)); + } + if child.try_wait().unwrap().is_none() { + child.kill().unwrap(); + child.wait().unwrap(); + panic!("invalid configuration started a server"); + } + drop(input); + let o = child.wait_with_output().unwrap(); + assert_eq!(o.status.code(), Some(2), "{}", String::from_utf8_lossy(&o.stderr)); + assert!(o.stdout.is_empty()); + assert!(!token.exists(), "validation must happen before creating credentials"); + std::fs::remove_dir_all(d).unwrap(); +} + #[test] fn convert_png_pcraft_png_is_lossless() { let d = tmp("convert"); diff --git a/book/src/automation/cli.md b/book/src/automation/cli.md index 05a7c3da27..71091736bc 100644 --- a/book/src/automation/cli.md +++ b/book/src/automation/cli.md @@ -64,3 +64,8 @@ layers because that would lose their group's blending semantics. Paths supplied to the current CLI are ordinary operating-system paths. The CLI does not restrict them to a workspace root. Batch output creates the requested output directory, and save operations may create parent directories. `batch` refuses an output directory that is its input directory (the results would replace the originals) unless `--in-place` is given. Run untrusted action files only in an appropriately isolated account or environment. CLI parsing reports malformed flags and JSON as errors, and a flag the subcommand doesn't take (a typo such as `--fromat`) is a usage error (exit status 2) rather than being ignored. It is not a security policy layer. Engine commands remain responsible for validating their own parameters. + +`mcp` and `serve` reject positional arguments, repeated options, empty values and options for +the wrong mode before starting a server. Explicit control-token flags require `mcp --bridge` +or `serve --port`. Configure automation roots on the desktop process when using bridge mode; +the CLI rejects root flags there. See the [MCP launch guide](mcp.md) for examples. diff --git a/docs/mcp.md b/docs/mcp.md index 9a8c573ce6..df8eb012bb 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -57,6 +57,17 @@ Paths are relative to the corresponding root, or absolute paths beneath it; with filesystem authority is absent. Bridge mode uses `--bridge` and `--control-token-file` as described in [development.md](development.md). UI tools require a running desktop app. +Use absolute root paths in MCP client configurations, since a relative root is resolved from +the client's launch directory. In bridge mode, configure roots on the **desktop app**; root +flags on `photocraft-cli mcp --bridge` are rejected. Explicit `--control-token` and +`--control-token-file` flags require `--bridge` and are mutually exclusive. Bridge credentials +can also come from `PHOTOCRAFT_CONTROL_TOKEN` or `PHOTOCRAFT_CONTROL_TOKEN_FILE`. + +MCP and `serve` launch options take one non-empty value each and cannot be repeated. Missing +values, stray positional arguments and options for the wrong mode are usage errors (exit 2), +reported on stderr before the server starts; stdout stays available for protocol messages. +For `serve`, explicit credential flags require `--port`; stdio needs no control token. + ## Tools and resources - `command_list`: discover engine ids, parameter docs and current enabled state; accepts From 9af7b2416f9728f9a98835292120d6992d56b12b Mon Sep 17 00:00:00 2001 From: Khawar Zamman Wani Date: Wed, 21 Oct 2026 01:19:01 +0530 Subject: [PATCH 156/649] CLI: help wins over a missing value; widen launch-validation tests `--help` or `-h` where a flag's value should be prints usage rather than a "needs a value" error, in every subcommand. Tests cover the missing-value rule outside mcp/serve and the `--flag=--value` form, and the stdin test checks each launch line that used to create a token file. The book's MCP page documents the launch rules. Co-Authored-By: Claude Opus 5.5 --- apps/photocraft-cli/src/lib.rs | 7 ++- apps/photocraft-cli/tests/cli.rs | 84 ++++++++++++++++++++++---------- book/src/automation/mcp.md | 8 +++ 3 files changed, 71 insertions(+), 28 deletions(-) diff --git a/apps/photocraft-cli/src/lib.rs b/apps/photocraft-cli/src/lib.rs index 20eea19d51..51aac5299b 100644 --- a/apps/photocraft-cli/src/lib.rs +++ b/apps/photocraft-cli/src/lib.rs @@ -129,7 +129,12 @@ fn parse(sub: &Subcommand, args: &[String]) -> Result, String> { } a.flags.push((k.to_owned(), Some(v.to_owned()))); } else if sub.values.contains(&s.as_str()) { - let v = args.get(i + 1).filter(|v| !v.starts_with("--") && v.as_str() != "-h").ok_or_else(|| format!("{s} needs a value"))?; + // A flag where the value should be is a missing value, not the value; help still wins. + let v = args.get(i + 1); + if v.is_some_and(|v| v == "--help" || v == "-h") { + return Ok(None); + } + let v = v.filter(|v| !v.starts_with("--")).ok_or_else(|| format!("{s} needs a value"))?; a.flags.push((s.clone(), Some(v.clone()))); i += 1; } else if sub.bare.contains(&s.as_str()) { diff --git a/apps/photocraft-cli/tests/cli.rs b/apps/photocraft-cli/tests/cli.rs index 78ac2177e0..e472e02530 100644 --- a/apps/photocraft-cli/tests/cli.rs +++ b/apps/photocraft-cli/tests/cli.rs @@ -56,6 +56,12 @@ fn every_subcommand_answers_help() { assert!(out.contains("USAGE") && out.contains("photocraft-cli batch"), "{sub} {help}: {out}"); } } + // Help where a flag's value should be is still help, not a missing value or a file named `-h`. + for args in [&["run", "x.png", "--out", "--help"][..], &["commands", "--filter", "-h"], &["mcp", "--bridge", "-h"], &["serve", "--port", "--help"]] { + let o = bin().current_dir(&d).args(args).stdin(Stdio::null()).output().unwrap(); + assert_eq!(o.status.code(), Some(0), "{args:?}: {}", String::from_utf8_lossy(&o.stderr)); + assert!(String::from_utf8_lossy(&o.stdout).contains("USAGE"), "{args:?}"); + } assert_eq!(std::fs::read_dir(&d).unwrap().count(), 0, "help wrote nothing"); } @@ -87,6 +93,22 @@ fn unknown_flags_are_usage_errors() { let o = bin().args(["commands", "--json=yes"]).output().unwrap(); assert_eq!(o.status.code(), Some(2)); assert!(String::from_utf8_lossy(&o.stderr).contains("--json takes no value")); + // A flag can't be a value: a missing value is reported, not filled with the next flag. + let o = bin() + .args(["batch", "--actions"]) + .arg(&actions) + .arg("--in") + .arg(&input) + .arg("--out") + .arg(&out_dir) + .args(["--format", "--quality", "80"]) + .output() + .unwrap(); + assert_eq!(o.status.code(), Some(2)); + assert!(String::from_utf8_lossy(&o.stderr).contains("--format needs a value")); + assert!(!out_dir.exists(), "nothing written"); + // `--flag=value` still passes a value that starts with `--`. + ok(bin().args(["commands", "--filter=--json"])); // Every flag still works in both forms. let (out, _) = ok(bin().args(["commands", "--json", "--filter=gaussian"])); assert!(out.contains("filter.blur.gaussianBlur"), "{out}"); @@ -124,7 +146,6 @@ fn server_modes_reject_ignored_or_conflicting_options() { server_usage_error(&[sub, flag, ".", flag, "."], "may only be specified once"); server_usage_error(&[sub, &format!("{flag}=")], "needs a non-empty value"); server_usage_error(&[sub, flag, "--automation-write-root", "."], &format!("{flag} needs a value")); - server_usage_error(&["mcp", "--bridge", "127.0.0.1:7878", flag, "."], "configure automation roots on the desktop app"); } let transport = if sub == "mcp" { "--bridge" } else { "--port" }; for flag in [transport, "--control-token", "--control-token-file"] { @@ -136,39 +157,48 @@ fn server_modes_reject_ignored_or_conflicting_options() { "use either --control-token or --control-token-file", ); } + for flag in ["--automation-read-root", "--automation-write-root"] { + server_usage_error(&["mcp", "--bridge", "127.0.0.1:7878", flag, "."], "configure automation roots on the desktop app"); + } } +/// Each launch line would, before validation, have started a TCP server and written the token file. #[test] fn server_validation_does_not_consume_stdio_or_create_files() { let d = tmp("server-validation"); let token = d.join("must-not-be-created.token"); - let mut child = bin() - .args(["serve", "--port", "0", "--control-token-file"]) - .arg(&token) - .arg("stray") - .env_remove("PHOTOCRAFT_CONTROL_TOKEN") - .env_remove("PHOTOCRAFT_CONTROL_TOKEN_FILE") - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - .unwrap(); - // Keep stdin open: invalid launch arguments must fail before starting a server. - let input = child.stdin.take().unwrap(); - let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5); - while child.try_wait().unwrap().is_none() && std::time::Instant::now() < deadline { - std::thread::sleep(std::time::Duration::from_millis(10)); + let other = d.join("other.token"); + let token_flag = format!("--control-token-file={}", token.display()); + let other_flag = format!("--control-token-file={}", other.display()); + for tail in [&["stray"][..], &["--automation-read-root", ".", "--automation-read-root", "."], &["--port", "0"], &[&other_flag]] { + let mut child = bin() + .current_dir(&d) + .args(["serve", "--port", "0", &token_flag]) + .args(tail) + .env_remove("PHOTOCRAFT_CONTROL_TOKEN") + .env_remove("PHOTOCRAFT_CONTROL_TOKEN_FILE") + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .unwrap(); + // Keep stdin open: invalid launch arguments must fail before starting a server. + let input = child.stdin.take().unwrap(); + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5); + while child.try_wait().unwrap().is_none() && std::time::Instant::now() < deadline { + std::thread::sleep(std::time::Duration::from_millis(10)); + } + if child.try_wait().unwrap().is_none() { + child.kill().unwrap(); + child.wait().unwrap(); + panic!("{tail:?}: invalid configuration started a server"); + } + drop(input); + let o = child.wait_with_output().unwrap(); + assert_eq!(o.status.code(), Some(2), "{tail:?}: {}", String::from_utf8_lossy(&o.stderr)); + assert!(o.stdout.is_empty(), "{tail:?}"); + assert!(!token.exists() && !other.exists(), "{tail:?}: validation must happen before creating credentials"); } - if child.try_wait().unwrap().is_none() { - child.kill().unwrap(); - child.wait().unwrap(); - panic!("invalid configuration started a server"); - } - drop(input); - let o = child.wait_with_output().unwrap(); - assert_eq!(o.status.code(), Some(2), "{}", String::from_utf8_lossy(&o.stderr)); - assert!(o.stdout.is_empty()); - assert!(!token.exists(), "validation must happen before creating credentials"); std::fs::remove_dir_all(d).unwrap(); } diff --git a/book/src/automation/mcp.md b/book/src/automation/mcp.md index 2c36b464c2..9f4b5e5ace 100644 --- a/book/src/automation/mcp.md +++ b/book/src/automation/mcp.md @@ -20,6 +20,14 @@ Bridge to a running desktop application with the same private token file used by photocraft-cli mcp --bridge 127.0.0.1:7878 --control-token-file /private/path/control.token ``` +Use absolute root paths in MCP client configurations, since a relative root is resolved from the +client's launch directory. In bridge mode the roots are configured on the desktop app, and root +flags on `photocraft-cli mcp --bridge` are rejected. Explicit `--control-token` and +`--control-token-file` flags require `--bridge` and are mutually exclusive; bridge credentials can +also come from `PHOTOCRAFT_CONTROL_TOKEN` or `PHOTOCRAFT_CONTROL_TOKEN_FILE`. Each launch option +takes one non-empty value and cannot be repeated. Stray positional arguments, missing values and +options for the wrong mode are usage errors (exit 2) reported on stderr before the server starts. + Tools cover session/document operations, command discovery and execution, batching, and—when bridged—UI inspection and control. Tool schemas improve correctness but are not authorization boundaries. ## From an installed release From ec9b6b7ee55927f7180a2dac37227f40449f22e0 Mon Sep 17 00:00:00 2001 From: Khawar Zamman Wani Date: Wed, 21 Oct 2026 01:32:14 +0530 Subject: [PATCH 157/649] Docs: launch-option wording for missing values and --help Name missing values alongside empty ones, and say `--help`/`-h` are the options that take no value (CodeRabbit review on #8035). Co-Authored-By: Claude Opus 5.5 --- book/src/automation/cli.md | 8 ++++---- book/src/automation/mcp.md | 5 +++-- docs/mcp.md | 9 +++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/book/src/automation/cli.md b/book/src/automation/cli.md index 71091736bc..d33a8baad4 100644 --- a/book/src/automation/cli.md +++ b/book/src/automation/cli.md @@ -65,7 +65,7 @@ Paths supplied to the current CLI are ordinary operating-system paths. The CLI d CLI parsing reports malformed flags and JSON as errors, and a flag the subcommand doesn't take (a typo such as `--fromat`) is a usage error (exit status 2) rather than being ignored. It is not a security policy layer. Engine commands remain responsible for validating their own parameters. -`mcp` and `serve` reject positional arguments, repeated options, empty values and options for -the wrong mode before starting a server. Explicit control-token flags require `mcp --bridge` -or `serve --port`. Configure automation roots on the desktop process when using bridge mode; -the CLI rejects root flags there. See the [MCP launch guide](mcp.md) for examples. +`mcp` and `serve` reject positional arguments, repeated options, missing or empty values and +options for the wrong mode before starting a server. Explicit control-token flags require +`mcp --bridge` or `serve --port`. Configure automation roots on the desktop process when using +bridge mode; the CLI rejects root flags there. See the [MCP launch guide](mcp.md) for examples. diff --git a/book/src/automation/mcp.md b/book/src/automation/mcp.md index 9f4b5e5ace..9b2e8d7c52 100644 --- a/book/src/automation/mcp.md +++ b/book/src/automation/mcp.md @@ -25,8 +25,9 @@ client's launch directory. In bridge mode the roots are configured on the deskto flags on `photocraft-cli mcp --bridge` are rejected. Explicit `--control-token` and `--control-token-file` flags require `--bridge` and are mutually exclusive; bridge credentials can also come from `PHOTOCRAFT_CONTROL_TOKEN` or `PHOTOCRAFT_CONTROL_TOKEN_FILE`. Each launch option -takes one non-empty value and cannot be repeated. Stray positional arguments, missing values and -options for the wrong mode are usage errors (exit 2) reported on stderr before the server starts. +except `--help`/`-h` takes one non-empty value and cannot be repeated. Stray positional arguments, +missing values and options for the wrong mode are usage errors (exit 2) reported on stderr before +the server starts. Tools cover session/document operations, command discovery and execution, batching, and—when bridged—UI inspection and control. Tool schemas improve correctness but are not authorization boundaries. diff --git a/docs/mcp.md b/docs/mcp.md index df8eb012bb..f5c0b24e11 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -63,10 +63,11 @@ flags on `photocraft-cli mcp --bridge` are rejected. Explicit `--control-token` `--control-token-file` flags require `--bridge` and are mutually exclusive. Bridge credentials can also come from `PHOTOCRAFT_CONTROL_TOKEN` or `PHOTOCRAFT_CONTROL_TOKEN_FILE`. -MCP and `serve` launch options take one non-empty value each and cannot be repeated. Missing -values, stray positional arguments and options for the wrong mode are usage errors (exit 2), -reported on stderr before the server starts; stdout stays available for protocol messages. -For `serve`, explicit credential flags require `--port`; stdio needs no control token. +MCP and `serve` launch options (all but `--help`/`-h`) take one non-empty value each and cannot +be repeated. Missing values, stray positional arguments and options for the wrong mode are +usage errors (exit 2), reported on stderr before the server starts; stdout stays available for +protocol messages. For `serve`, explicit credential flags require `--port`; stdio needs no +control token. ## Tools and resources From 8317acae04b80dbe985f24cb2e6eca60c1e65e34 Mon Sep 17 00:00:00 2001 From: David Mann Date: Tue, 20 Oct 2026 22:50:58 +0200 Subject: [PATCH 158/649] Integration: Lefx class, linear style names, keep built-in groups, dialog opacity (#4049) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Export wrote each style's effects object with class `null` (a layer's `lfx2` class). Style libraries use class `Lefx` (Krita's reader takes a `null` descriptor as the start of the next style). Test: exported_effects_object_has_class_lefx. - Repeated style names were numbered by rescanning every taken name for every candidate: an .asl of 10 000 styles all named "A" (about 0.7 MB) froze the import for minutes. Now a set plus a next number per name, as the .abr import does. Test: many_identical_names_import_quickly. - Importing "Basics.asl" (or any file named like a built-in group) replaced and deleted that built-in group, with no undo. It now goes to "Basics 2". - The Layer Style dialog's New Style… saved the layer's opacity instead of the dialog's pending one, and picking a style swatch there ignored the style's opacity. - Serbian strings for the Styles panel menu (sr.tsv came with main), and a rustfmt line in the merged workspace.rs. Co-authored-by: Brandon Thomas <39263+echelon@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/automation/src/workspace.rs | 8 +++- crates/engine/src/style_asl_cmds.rs | 19 ++++++++- crates/io/src/asl_map.rs | 66 +++++++++++++++++++++++------ crates/ui-egui/src/i18n/sr.tsv | 7 +++ crates/ui-egui/src/layer_style.rs | 7 +++ docs/file-format-parity.md | 2 +- 6 files changed, 92 insertions(+), 17 deletions(-) diff --git a/crates/automation/src/workspace.rs b/crates/automation/src/workspace.rs index 658cd8bd50..fca762a9c3 100644 --- a/crates/automation/src/workspace.rs +++ b/crates/automation/src/workspace.rs @@ -380,7 +380,13 @@ fn preference_uses_ambient_filesystem(path: &str) -> bool { fn command_uses_ambient_path(id: &str, params: &Value) -> bool { match id { - "actions.load" | "brush.presets.importAbr" | "brush.presets.importImage" | "gradient.presets.importGrd" | "plugin.install" | "swatches.import" | "style.presets.importAsl" => { + "actions.load" + | "brush.presets.importAbr" + | "brush.presets.importImage" + | "gradient.presets.importGrd" + | "plugin.install" + | "swatches.import" + | "style.presets.importAsl" => { // `data` wins over `path` in these commands; any `path` without it reads the filesystem. params.get("data").is_none() && params.get("path").is_some() } diff --git a/crates/engine/src/style_asl_cmds.rs b/crates/engine/src/style_asl_cmds.rs index e942df7d35..8d80c816a1 100644 --- a/crates/engine/src/style_asl_cmds.rs +++ b/crates/engine/src/style_asl_cmds.rs @@ -44,6 +44,9 @@ fn import(s: &mut Session, p: &Value) -> Result { None => true, Some(v) => v.as_bool().ok_or_else(|| bad(IMPORT, "`replace` must be a boolean"))?, }; + // A file named like a built-in group ("Basics.asl") goes to "Basics 2": built-ins are never replaced. + let builtin: Vec = crate::presets::styles::builtin().into_iter().map(|g| g.name).collect(); + let group = if builtin.contains(&group) { (2..).map(|i| format!("{group} {i}")).find(|g| !builtin.contains(g)).unwrap_or(group) } else { group }; let imp = asl_map::read_asl(&bytes).map_err(|e| bad(IMPORT, e))?; if imp.styles.is_empty() { return Err(bad(IMPORT, "the file holds no styles")); @@ -143,7 +146,7 @@ pub fn specs() -> Vec { label: "Import Styles…", menu: &[], shortcut: None, - params: r##"{"path":".asl file"?,"data":base64 bytes?,"group":string?=file name,"replace":bool=true (replace a group of the same name)} → {group, imported, count, patterns (ids added to the pattern library), warnings}"##, + params: r##"{"path":".asl file"?,"data":base64 bytes?,"group":string?=file name (a built-in group's name becomes " 2": built-ins are never replaced),"replace":bool=true (replace a group of the same name)} → {group, imported, count, patterns (ids added to the pattern library), warnings}"##, enabled: always, run: import, journal: true, @@ -201,6 +204,20 @@ mod tests { assert_eq!(s.presets.styles.len(), groups); } + #[test] + fn a_file_named_like_a_built_in_group_keeps_that_group() { + let mut s = session(); + let basics = s.presets.styles.iter().find(|g| g.name == "Basics").unwrap().items.clone(); + let data = s.execute(EXPORT, json!({"group": "Text Effects"})).unwrap()["data"].as_str().unwrap().to_string(); + for _ in 0..2 { + let r = s.execute(IMPORT, json!({"data": data, "group": "Basics"})).unwrap(); + assert_eq!(r["group"], "Basics 2"); + } + assert_eq!(s.presets.styles.iter().find(|g| g.name == "Basics").unwrap().items, basics); + // Re-importing replaces the copy instead of adding another. + assert_eq!(s.presets.styles.iter().filter(|g| g.name.starts_with("Basics")).count(), 2); + } + #[test] fn blending_options_survive_and_apply() { let mut s = session(); diff --git a/crates/io/src/asl_map.rs b/crates/io/src/asl_map.rs index 7c254099a9..76e9e11757 100644 --- a/crates/io/src/asl_map.rs +++ b/crates/io/src/asl_map.rs @@ -9,12 +9,12 @@ //! effects scale other than 100 %) is left out with a warning naming the style, and the rest of //! the file still imports. -use std::collections::BTreeSet; +use std::collections::{BTreeSet, HashMap, HashSet}; use photocraft_color::BlendMode; use photocraft_doc::{Effect, FxPaint, Pattern}; use photocraft_psd::asl::{self, AslFile}; -use photocraft_psd::descriptor::{Descriptor, Value}; +use photocraft_psd::descriptor::{Descriptor, Id, Value}; use crate::blocks::{enum_of, get_desc, num}; use crate::effects_map::{blend_from_id, blend_value, effects_descriptor, effects_from_descriptor, is_known_effects_key}; @@ -76,12 +76,27 @@ fn pct(d: &Descriptor, key: &str) -> Option { num(d.get(key)).filter(|v| v.is_finite()).map(|v| (v as f32 / 100.0).clamp(0.0, 1.0)) } -fn unique(name: &str, taken: &[String]) -> String { - let free = |n: &str| !taken.iter().any(|t| t.eq_ignore_ascii_case(n)); - if free(name) { - return name.to_string(); +/// Style names in use within one file (ASCII-lowercased), with the next number to try for each +/// repeated name, so a file of identical names stays linear. +#[derive(Default)] +struct Taken { + names: HashSet, + next: HashMap, +} + +impl Taken { + /// `name`, else `name 2`, `name 3`… (case-insensitive); in use from then on. + fn unique(&mut self, name: &str) -> String { + let key = name.to_ascii_lowercase(); + if self.names.insert(key.clone()) { + return name.to_string(); + } + let from = self.next.get(&key).copied().unwrap_or(2); + let i = (from..).find(|i| !self.names.contains(&format!("{key} {i}"))).unwrap_or(from); + self.names.insert(format!("{key} {i}")); + self.next.insert(key, i + 1); + format!("{name} {i}") } - (2..).map(|i| format!("{name} {i}")).find(|n| free(n)).unwrap_or_else(|| name.to_string()) } /// Reads an `.asl` style library. @@ -95,12 +110,11 @@ pub fn read_asl(bytes: &[u8]) -> Result { if skipped_patterns > 0 { out.warnings.push(format!("{skipped_patterns} empty or unreadable patterns were skipped")); } - let mut taken: Vec = Vec::new(); + let mut taken = Taken::default(); let mut missing: BTreeSet = BTreeSet::new(); for (i, s) in file.styles.iter().enumerate() { let base = if s.name.trim().is_empty() { format!("Style {}", i + 1) } else { s.name.trim().to_string() }; - let name = unique(&base, &taken); - taken.push(name.clone()); + let name = taken.unique(&base); let mut style = AslStyle { name: name.clone(), effects: Vec::new(), blend: None, opacity: None, fill_opacity: None }; let mut left_out: Vec = Vec::new(); if let Some(fx) = get_desc(&s.style, "Lefx") { @@ -168,9 +182,11 @@ pub fn write_asl(styles: &[AslStyle], patterns: &[Pattern]) -> Result, S .iter() .enumerate() .map(|(i, s)| { - let mut d = Descriptor::new("Styl") - .with("documentMode", Value::Descriptor(Descriptor::new("documentMode"))) - .with("Lefx", Value::Descriptor(effects_descriptor(true, &s.effects))); + // A style library's effects object has class `Lefx` (a layer's `lfx2` uses `null`). + let mut lefx = effects_descriptor(true, &s.effects); + lefx.class_id = Id::new("Lefx"); + let mut d = + Descriptor::new("Styl").with("documentMode", Value::Descriptor(Descriptor::new("documentMode"))).with("Lefx", Value::Descriptor(lefx)); if s.blend.is_some() || s.opacity.is_some() || s.fill_opacity.is_some() { d = d.with( "blendOptions", @@ -194,7 +210,7 @@ mod tests { use super::*; use photocraft_color::{Color, ColorMode, PixelFormat, SampleType}; use photocraft_doc::{BevelTexture, FxCommon, StrokePosition}; - use photocraft_psd::descriptor::{Id, UnicodeString}; + use photocraft_psd::descriptor::UnicodeString; use photocraft_raster::Surface; fn pattern(id: &str, s: SampleType) -> Pattern { @@ -363,6 +379,28 @@ mod tests { assert!(read_asl(&photocraft_psd::grd::write(&[])).is_err()); } + #[test] + fn exported_effects_object_has_class_lefx() { + let bytes = write_asl(&styles(), &[]).unwrap(); + let file = asl::parse(&bytes).unwrap(); + for s in &file.styles { + let lefx = get_desc(&s.style, "Lefx").unwrap(); + assert_eq!(lefx.class_id, Id::new("Lefx"), "{}", s.name); + } + } + + #[test] + fn many_identical_names_import_quickly() { + let names = vec!["A"; asl::MAX_STYLES]; + let bytes = synthetic(Descriptor::new("Lefx"), None, &names); + let start = std::time::Instant::now(); + let imp = read_asl(&bytes).unwrap(); + assert!(start.elapsed() < std::time::Duration::from_secs(10), "{:?}", start.elapsed()); + assert_eq!(imp.styles.len(), asl::MAX_STYLES); + assert_eq!(imp.styles[1].name, "A 2"); + assert_eq!(imp.styles.last().unwrap().name, format!("A {}", asl::MAX_STYLES)); + } + #[test] fn style_ids_are_uuid_shaped() { let id = style_id(3, "Gold"); diff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsv index 5530f81ce6..09113a7879 100644 --- a/crates/ui-egui/src/i18n/sr.tsv +++ b/crates/ui-egui/src/i18n/sr.tsv @@ -4321,3 +4321,10 @@ shape Appearance Izgled # DDS Options (#1327) DDS Options DDS opcije Generate Mipmaps Generiši mipmape +# Styles panel: Import / Export Styles (.asl) + Import Styles… Uvezi stilove… + Export Selected Styles… Izvezi izabrane stilove… + Export Styles… Izvezi stilove… + {file} is not a style library (.asl) {file} nije biblioteka stilova (.asl) +@plural Imported {n} style from {file}|Imported {n} styles from {file} Uvezen je {n} stil iz {file}|Uvezena su {n} stila iz {file}|Uvezeno je {n} stilova iz {file} +@plural Exported {n} style to {file}|Exported {n} styles to {file} Izvezen je {n} stil u {file}|Izvezena su {n} stila u {file}|Izvezeno je {n} stilova u {file} diff --git a/crates/ui-egui/src/layer_style.rs b/crates/ui-egui/src/layer_style.rs index d876c18278..108327ed7d 100644 --- a/crates/ui-egui/src/layer_style.rs +++ b/crates/ui-egui/src/layer_style.rs @@ -716,6 +716,9 @@ fn apply_style_preset(app: &PhotocraftApp, f: &mut Map, name: &st if let Some(fo) = style.fill_opacity { set_param(f, BLENDING, "fillOpacity", json!((fo * 100.0).round())); } + if let Some(o) = style.opacity { + set_param(f, BLENDING, "opacity", json!((o * 100.0).round())); + } } /// Saves the dialog's pending state (enabled instances + blending page) as a style preset. @@ -742,6 +745,7 @@ fn save_new_style(app: &mut PhotocraftApp, f: &Map) { "effects": entries, "blend": bo.get("blend").cloned().unwrap_or(Value::Null), "fillOpacity": bo.get("fillOpacity").cloned().unwrap_or(Value::Null), + "opacity": bo.get("opacity").cloned().unwrap_or(Value::Null), }), ) { app.ui.status = crate::i18n::fmt(tl!("Style {name} saved"), &[("name", v["name"].as_str().unwrap_or("Style"))]); @@ -2155,9 +2159,11 @@ mod tests { let id = app.session.active().unwrap().active_layer.unwrap(); let mut f = initial_fields(app.session.active().unwrap().doc.layer(id).unwrap(), Some("stroke"), 120.0); set_param(&mut f, "fx1", "size", json!(9)); + set_param(&mut f, BLENDING, "opacity", json!(40)); save_new_style(&mut app, &f); let preset = app.session.presets.styles.iter().flat_map(|g| g.items.iter()).find(|st| st.name == "Style").expect("the preset is created"); assert_eq!(preset.effects.len(), 1, "only the enabled instance is saved"); + assert_eq!(preset.opacity, Some(0.4), "the pending opacity is saved, not the layer's"); // A second layer gets the pending style back through the swatch path. app.run("layer.new.layer", json!({})).unwrap(); let mut f2 = initial_fields(app.session.active().unwrap().doc.layer(app.session.active().unwrap().active_layer.unwrap()).unwrap(), None, 120.0); @@ -2166,6 +2172,7 @@ mod tests { // Swatch clicks update the dialog fields only; document is untouched until confirm. assert_eq!(effects_of(&f2).len(), 1); assert_eq!(effects_of(&f2)[0]["params"]["size"], json!(9.0)); + assert_eq!(f2["p:blendingOptions"]["opacity"], json!(40.0), "the swatch brings the style's opacity"); // Confirming applies the style to the layer. confirm(&mut app, &f2).unwrap(); let st = app.session.active().unwrap(); diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 435bfa80b6..2d8b946e83 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -172,7 +172,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings. | 2026-10-12 | minor | Photoshop Actions `.atn`: read and write, 90 events mapped, the rest kept verbatim (AUTO-219-2) | | 2026-10-12 | minor | Presets table: Contours `.shc` read and write through the Contour Editor (FILE-215-15); `.csh` and `.tpl` stay missing | | 2026-10-12 | minor | Palette BMPs open in Indexed Color mode (#3802) | -| 2026-10-12 | minor | `.asl` layer style libraries: import and export with embedded patterns and blending options | +| 2026-10-20 | minor | `.asl` layer style libraries: import and export with embedded patterns and blending options | | 2026-10-12 | minor | Save writes a JPEG at its own estimated quality and a WebP lossy or lossless as opened (#2399) | | 2026-10-11 | minor | PSD smart filters: Filter Gallery (`GEfc`) maps to `filter.filterGallery` when every effect is modelled (Chrome so far), editable from the Layers panel | | 2026-10-11 | minor | D5100 image area and fitted-look preservation in Camera Raw tuning | From 13733ba3a9a0a350d9f185c7dc840700a7f3e1e3 Mon Sep 17 00:00:00 2001 From: David Mann Date: Tue, 20 Oct 2026 23:10:35 +0200 Subject: [PATCH 159/649] Integration: hide area type that reaches the shape's narrow bottom (#6230) When area type overflowed a closed shape, a word too wide for the narrow bottom rows of an ellipse stayed in its span and was drawn past the outline (a 260x160 bubble at 12 pt drew "misunderstanding" from x 110 to 212 over a 110..149 span). The shape's wider rows would hold such a word, so the shape has just run out of room: that line and the rest are now hidden as overflow. The check looks at every row of the shape, not just the paragraph's own (a later paragraph starts below the wide top of a funnel), and also runs when the line-breaking pass budget is spent. Only a word no span in the shape holds still overflows its span. The TYPE-218-10 note said such a word overflows "the way box text does"; since #6694 box text breaks it at the edge. Corrected, and the other known gaps (first line about 0.24 em lower than box text, PSD area type opening as box text, no handles for the area path) are listed. Co-authored-by: Silly Silk <31193727+SillySilk@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/text/src/layout.rs | 29 ++++++++++++++++++++++------- crates/text/src/tests.rs | 35 ++++++++++++++++++++++++++++++++++- docs/scorecard.md | 2 +- scorecard/type.toml | 2 +- 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/crates/text/src/layout.rs b/crates/text/src/layout.rs index 9164cbaa9f..bf42fdc314 100644 --- a/crates/text/src/layout.rs +++ b/crates/text/src/layout.rs @@ -1200,7 +1200,8 @@ struct Need { /// /// A span too narrow for the word that would start it (the narrow top of an ellipse) is left /// empty and the word goes to the first later span that holds it, as Photoshop does. A word no -/// later span holds overflows its span, as in a text box. Parley doesn't report a line's +/// later span holds but another span of the shape would means the shape is full: it and the rest are +/// hidden. Only a word no span holds overflows its span. Parley doesn't report a line's /// trailing whitespace while breaking, so overflowing lines are found after a pass and the /// paragraph broken again; `budget` (shared by the paragraph's calls) bounds the passes. /// @@ -1219,13 +1220,12 @@ fn break_area( ) -> (Vec, bool) { let inset = indents.0 + indents.1; let mut rows = AreaRows { area, m, min_width, next: from, rows: Vec::new(), done: false }; + // Every row of the shape from its top, whatever paragraph came before (found lazily). + let mut shape_rows = AreaRows { area, m, min_width, next: area.bounds[1], rows: Vec::new(), done: false }; let mut needs: Vec = Vec::new(); loop { let (slots, overflow) = break_area_pass(layout, &mut rows, inset, scale, &needs); budget.set(budget.get().saturating_sub(1)); - if budget.get() == 0 { - return (slots, overflow); - } // Each line's text start and scaled width without its trailing whitespace. let lines: Vec<(usize, f32)> = layout .lines() @@ -1234,6 +1234,20 @@ fn break_area( (l.text_range().start, (lm.advance - lm.trailing_whitespace) * scale) }) .collect(); + // A line still wider than its span that some span of the shape would hold: the shape ran + // out of room for it (the narrow bottom of a full bubble). It and the rest are hidden, as + // overflow; only a word no span holds overflows its span. + let mut ran_out = |slots: Vec, overflow: bool| match lines + .iter() + .zip(&slots) + .position(|(&(_, width), s)| width > s.width + 0.5 && shape_rows.first_fit(0, 0, width, inset).is_some()) + { + Some(li) => (slots.into_iter().take(li).collect(), true), + None => (slots, overflow), + }; + if budget.get() == 0 { + return ran_out(slots, overflow); + } // A line that now starts elsewhere (an earlier line changed) no longer needs its span. let kept = needs.len(); needs.retain(|n| lines.get(n.line).is_some_and(|l| l.0 == n.start)); @@ -1247,10 +1261,11 @@ fn break_area( break; } } - match new { - Some(n) => needs.push(n), - None => return (slots, overflow), + if let Some(n) = new { + needs.push(n); + continue; } + return ran_out(slots, overflow); } } diff --git a/crates/text/src/tests.rs b/crates/text/src/tests.rs index bfa833a3aa..24b2d9cfc8 100644 --- a/crates/text/src/tests.rs +++ b/crates/text/src/tests.rs @@ -2160,6 +2160,39 @@ fn area_overflow_is_hidden() { assert_lines_inside(&l, &path); } +/// A long word that reaches the narrow bottom of a full bubble is hidden with the rest, not +/// drawn past the outline: the wide middle rows would hold it, so the shape just ran out. +#[test] +fn area_overflow_at_the_narrow_bottom_is_hidden() { + let mut e = TextEngine::new(); + let words = "Unfortunately the misunderstanding between representatives continued indefinitely. "; + for (w, h, size) in [(260.0, 160.0, 12.0), (180.0, 140.0, 14.0), (150.0, 220.0, 12.0)] { + let mut t = point(&words.repeat(8), size); + let path = area_ellipse(0.0, 0.0, w, h); + t.shape = TextShape::Area { path: path.clone() }; + let l = e.layout(&t, 72.0); + assert!(!l.lines.is_empty()); + assert!(l.lines.last().unwrap().range.end < t.text.len(), "the rest is hidden"); + assert_lines_inside(&l, &path); + } +} + +/// The same in a later paragraph: its own rows start below the wide top of the shape, but the +/// shape would still hold the word there, so it is hidden rather than drawn past the outline. +#[test] +fn area_overflow_in_a_later_paragraph_is_hidden() { + let mut e = TextEngine::new(); + // A funnel: 300 px wide at the top, a point at the bottom. + let path = area_poly(&[(0.0, 0.0), (300.0, 0.0), (150.0, 300.0)]); + for n in (10..120).step_by(5) { + let text = format!("{}\nmisunderstanding and more", "cat ".repeat(n)); + let mut t = point(&text, 12.0); + t.shape = TextShape::Area { path: path.clone() }; + let l = e.layout(&t, 72.0); + assert_lines_inside(&l, &path); + } +} + #[test] fn area_lines_center_in_their_span() { let mut e = TextEngine::new(); @@ -2254,7 +2287,7 @@ fn area_word_wider_than_every_span_overflows_instead_of_hiding_the_text() { t.shape = TextShape::Area { path }; let l = e.layout(&t, 72.0); let first = l.lines.first().expect("the text is shown"); - // The word overflows its 40 px span, as in a text box, on the first row. + // The word overflows its 40 px span on the first row (box text would break it, #6694). assert!(first.x1 - first.x0 > 40.0 && first.x1 - first.x0 < 200.0, "{first:?}"); assert!(first.x0 >= -0.5, "{first:?}"); // Nothing is hidden. diff --git a/docs/scorecard.md b/docs/scorecard.md index f524872be9..1ff5e0507f 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -222,7 +222,7 @@ Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_w | TYPE-218-7 | Warp Text dialog previews live and opens with the layer's current warp | missing | [#218](https://github.com/storytold/photocraft/issues/218) | view_cmds.rs:834 always seeds arc, bend 50 | | TYPE-218-8 | Text editing: select all, double/triple/quadruple-click selection, paste, with tests | done | [#218](https://github.com/storytold/photocraft/issues/218) | Like Photoshop, 2 clicks select the word, 3 the laid-out line (a column in vertical type), 4 the paragraph up to the hard return, 5 all text, and the next quick click starts over (#3493; type_tool.rs next_click_count, click_selection, multi_click). Tested through real canvas clicks in point, paragraph and vertical type, with paste replacing the selection and Cmd+A selecting all (type_tool_tests.rs multi_click_selects_word_line_paragraph_and_all_in_point_text, multi_click_separates_wrapped_lines_from_paragraphs, click_counts_cycle_and_restart, click_selection_without_layout_and_on_hostile_input, multi_click_without_a_session_does_nothing) | | TYPE-218-9 | Distort/Perspective/Warp on live type as in Photoshop (was: offer 'Rasterize and continue?'; Photoshop doesn't prompt) | done | [#218](https://github.com/storytold/photocraft/issues/218) | Photoshop 2026 prompts for none of these: Edit › Transform › Warp on live type stays enabled with no rasterize prompt and offers only the warp styles (the mesh can't be dragged), so the type stays editable; Distort, Perspective and the split warps are greyed. PhotoCraft does the same: Warp on type commits the layer's Warp Text in one step (transform_tool.rs enter_type_warp, warp_cmds.rs warp_type_layer, #3004; warp_on_type_takes_a_style_and_keeps_the_type_editable), Distort/Perspective greyed (enable_rules.rs, #2701) | -| TYPE-218-10 | Area type: Type tool click inside a closed path or shape wraps text inside it, holes and dents included, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; area type takes paths of at most 4096 anchors: beyond that a Type tool click makes point text (the pointer shows the plain I-beam), and type.fillPath refuses the path with "the path has too many anchor points" (type.attachToPath still takes a subpath of up to 100,000 anchors); a word too wide for every span in the shape overflows its span the way box text does | +| TYPE-218-10 | Area type: Type tool click inside a closed path or shape wraps text inside it, holes and dents included, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; area type takes paths of at most 4096 anchors: beyond that a Type tool click makes point text (the pointer shows the plain I-beam), and type.fillPath refuses the path with "the path has too many anchor points" (type.attachToPath still takes a subpath of up to 100,000 anchors); a word too wide for every span in the shape overflows its span (box text breaks it at the edge, #6694); the first line starts about 0.24 em lower than in a text box of the same size; Photoshop area type in a PSD opens as box text; the area path has no handles to edit it after the type is placed | ## Automation diff --git a/scorecard/type.toml b/scorecard/type.toml index ef3701b414..5703affff5 100644 --- a/scorecard/type.toml +++ b/scorecard/type.toml @@ -72,4 +72,4 @@ id = "TYPE-218-10" target = "Area type: Type tool click inside a closed path or shape wraps text inside it, holes and dents included, PSD round trip" status = "partial" issue = 218 -note = "TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; area type takes paths of at most 4096 anchors: beyond that a Type tool click makes point text (the pointer shows the plain I-beam), and type.fillPath refuses the path with \"the path has too many anchor points\" (type.attachToPath still takes a subpath of up to 100,000 anchors); a word too wide for every span in the shape overflows its span the way box text does" +note = "TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; area type takes paths of at most 4096 anchors: beyond that a Type tool click makes point text (the pointer shows the plain I-beam), and type.fillPath refuses the path with \"the path has too many anchor points\" (type.attachToPath still takes a subpath of up to 100,000 anchors); a word too wide for every span in the shape overflows its span (box text breaks it at the edge, #6694); the first line starts about 0.24 em lower than in a text box of the same size; Photoshop area type in a PSD opens as box text; the area path has no handles to edit it after the type is placed" From 63958b07abb73013a7d7bf4fcf950405a9a5efd0 Mon Sep 17 00:00:00 2001 From: David Mann Date: Wed, 21 Oct 2026 00:23:02 +0200 Subject: [PATCH 160/649] Integration: keep an untouched cylinder on Warp mode's Enter (#5769) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Warp mode shows a smart object's stored cylinder as its 13 x 4 mesh (smart_warp_doc_space), and Enter commits that mesh as edit.transform.warp. The cylinder was then stored as a custom warp, and the next PSD save wrote no warp ("custom warp with more than one patch was written without its warp"). On main the same steps kept Photoshop's warpCylinder (unread, so the SoLd stayed verbatim). Committing exactly what Warp mode shows (the same mesh over the same box) now changes nothing and adds no history step; a moved point or another box still makes it a custom warp. The transform box then treats a `changed: false` commit like an untouched box: a ⌥⌘T copy stays its own step instead of being folded into the step before it (that also held for an unchanged Warp Text on a type copy). Also: the cylinder_warp test takes `as_chunks` (clippy's chunks_exact_to_as_chunks on the current toolchain). Co-authored-by: alvarohn <32224796+alvarohn@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/warp_cmds.rs | 66 ++++++++++++++++++++++++++++ crates/io/tests/cylinder_warp.rs | 2 +- crates/ui-egui/src/transform_tool.rs | 32 ++++++++++++++ 3 files changed, 99 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/warp_cmds.rs b/crates/engine/src/warp_cmds.rs index 3d44a8c34b..2428976713 100644 --- a/crates/engine/src/warp_cmds.rs +++ b/crates/engine/src/warp_cmds.rs @@ -145,6 +145,22 @@ fn cylinder_in_source(w: &Warp, inv: &Homography, sb: [f64; 4]) -> Option Some(Warp::custom(mesh, sb)) } +/// Whether the custom warp `w` is exactly what Warp mode shows for `layer`'s stored cylinder +/// ([`smart_warp_doc_space`]: its mesh over the same box), so committing it untouched changes +/// nothing. Stored as a custom warp instead, the cylinder would be lost, as a PSD keeps it only +/// as `warpCylinder` (#4112). +fn is_stored_cylinder(layer: &Layer, w: &Warp) -> bool { + let LayerContent::Smart(sm) = &layer.content else { return false }; + if w.style != WarpStyle::Custom || sm.warp.as_ref().is_none_or(|s| s.style != WarpStyle::Cylinder) { + return false; + } + let (Some(shown), Some(m)) = (smart_warp_doc_space(layer), w.mesh.as_ref()) else { return false }; + let Some(o) = shown.mesh.as_ref() else { return false }; + let tol = 1e-6 * (1.0 + o.points.iter().flatten().chain(&shown.bounds).fold(0.0f64, |a, v| a.max(v.abs()))); + let near = |a: &[f64], b: &[f64]| a.len() == b.len() && a.iter().zip(b).all(|(x, y)| (x - y).abs() <= tol); + o.us == m.us && o.vs == m.vs && near(&shown.bounds, &w.bounds) && near(o.points.as_flattened(), m.points.as_flattened()) +} + /// A Background is turned into a normal layer by the caller first /// ([`crate::extra_cmds::background_to_layer`]). fn warp_layer(doc_sel: Option<&Surface>, group: Locks, l: &mut Layer, w: &Warp, rect: Rect, interp: Interp, frames: Option<&Frames>) -> Result<()> { @@ -385,6 +401,10 @@ fn apply(s: &mut Session, p: &Value, cmd: &str) -> Result { if w.is_identity() && !is_smart { return Ok(json!({"layer": id.0, "changed": false})); } + // An untouched cylinder (Warp mode, then Enter) stays as it is, with no history step. + if p.get("mesh").is_none() && s.active().and_then(|d| d.doc.layer(id)).is_some_and(|l| is_stored_cylinder(l, &w)) { + return Ok(json!({"layer": id.0, "changed": false})); + } let interp = Interp::parse(p.get("interpolation").and_then(Value::as_str).unwrap_or("bicubic")); let content_knots = p.get("mesh").is_some() && p.get("warp").is_none(); s.edit("Warp", |doc, _| { @@ -800,6 +820,52 @@ mod tests { assert_eq!(w.mesh.as_ref().map(|m| (m.nx(), m.ny())), Some((13, 4))); } + /// Warp mode shows a stored cylinder as its mesh, and Enter commits that mesh untouched: the + /// smart object keeps its cylinder (else the next PSD save writes no warp), while a moved + /// point still makes it a custom warp. + #[test] + fn untouched_cylinder_committed_from_warp_mode_stays_a_cylinder() { + for scale in [100, 150] { + let mut s = session(8); + s.execute("layer.smartObjects.convertToSmartObject", json!({})).unwrap(); + s.execute("edit.transform", json!({"scaleX": scale, "scaleY": 100})).unwrap(); + let id = s.active().unwrap().active_layer.unwrap(); + let rect = warp_bounds(&s.active().unwrap().doc, s.active().unwrap().doc.layer(id).unwrap()); + let [x0, x1] = [f64::from(rect.x0), f64::from(rect.x1)]; + let values = [x0, 40.0, x1, 10.0, 0.3, 0.3, 0.5]; + s.execute("layer.smartObjects.warp", json!({"style": "cylinder", "values": values, "rect": [rect.x0, 10, rect.x1, 40]})).unwrap(); + let stored = |s: &Session| { + let st = s.active().unwrap(); + let LayerContent::Smart(sm) = &st.doc.layer(id).unwrap().content else { panic!("smart") }; + sm.warp.clone().unwrap() + }; + let cylinder = stored(&s); + assert_eq!(cylinder.style, WarpStyle::Cylinder, "{scale}"); + let shown = smart_warp_doc_space(s.active().unwrap().doc.layer(id).unwrap()).unwrap(); + assert_eq!(shown.style, WarpStyle::Custom); + s.execute("select.all", json!({})).unwrap(); + let (sel, steps) = (s.active().unwrap().doc.selection.clone(), s.active().unwrap().history.past_len()); + let r = s.execute("edit.transform.warp", json!({"layer": id.0, "rect": shown.bounds, "warp": shown, "interpolation": "bicubic"})).unwrap(); + assert_eq!(r["changed"], false, "{scale}"); + assert_eq!(stored(&s), cylinder, "{scale}: untouched"); + let st = s.active().unwrap(); + assert!(st.doc.selection == sel && st.history.past_len() == steps, "{scale}: no step, the selection stays"); + // The same mesh over another box is another warp. + let mut wider = shown.clone(); + wider.bounds[2] += 10.0; + s.execute("edit.transform.warp", json!({"layer": id.0, "rect": wider.bounds, "warp": wider})).unwrap(); + assert_eq!(stored(&s).style, WarpStyle::Custom, "{scale}: other box"); + s.execute("edit.undo", json!({})).unwrap(); + assert_eq!(stored(&s), cylinder); + let mut moved = shown.clone(); + if let Some(m) = moved.mesh.as_mut() { + m.points[20][1] += 5.0; + } + s.execute("edit.transform.warp", json!({"layer": id.0, "rect": moved.bounds, "warp": moved})).unwrap(); + assert_eq!(stored(&s).style, WarpStyle::Custom, "{scale}: edited"); + } + } + #[test] fn identity_and_bend_zero_are_no_ops_at_every_depth() { for depth in [8u64, 16, 32] { diff --git a/crates/io/tests/cylinder_warp.rs b/crates/io/tests/cylinder_warp.rs index be75e31505..8ed1caa916 100644 --- a/crates/io/tests/cylinder_warp.rs +++ b/crates/io/tests/cylinder_warp.rs @@ -66,7 +66,7 @@ fn round_trip(doc: &Document) -> (PsdFile, Document) { /// Opaque pixels of the render that are mostly `channel` (0 red, 1 green, 2 blue). fn count(s: &Surface, channel: usize) -> usize { let r = s.content_bounds(); - s.read_region(r).chunks_exact(4).filter(|p| p[3] > 0.5 && p[channel] > 0.5 && (0..3).all(|c| c == channel || p[c] < 0.5)).count() + s.read_region(r).as_chunks::<4>().0.iter().filter(|p| p[3] > 0.5 && p[channel] > 0.5 && (0..3).all(|c| c == channel || p[c] < 0.5)).count() } /// Before #4112 a cylinder was read as no warp: re-rendering the contents drew them flat, the diff --git a/crates/ui-egui/src/transform_tool.rs b/crates/ui-egui/src/transform_tool.rs index 7ae223029d..a0bd3520c7 100644 --- a/crates/ui-egui/src/transform_tool.rs +++ b/crates/ui-egui/src/transform_tool.rs @@ -1093,6 +1093,9 @@ pub fn commit(app: &mut PhotocraftApp) { return; } match r { + // Nothing changed (an untouched cylinder or Warp Text): no step to fold a copy into, so + // it stays its own step, as for an untouched box. + Ok(v) if v.get("changed") == Some(&json!(false)) => {} Ok(_) => finish(app, document, LayerId(t.layer), made, true), Err(e) => keep_open(app, t, preview, e), } @@ -4124,6 +4127,35 @@ mod tests { assert_eq!(app.session.active().unwrap().doc.layers.len(), layers); } + /// #4112: ⌥⌘T on a cylinder smart object, Warp mode, Enter with nothing touched: the copy + /// keeps the cylinder and stays its own step (no warp step to fold into), so one undo takes + /// back the copy and nothing before it. + #[test] + fn untouched_warp_of_a_cylinder_copy_keeps_its_own_step() { + let ctx = egui::Context::default(); + let mut app = app_with_square(64, photocraft_geom::Rect::new(8, 8, 24, 24)); + app.run("layer.smartObjects.convertToSmartObject", json!({})).unwrap(); + app.run("layer.smartObjects.warp", json!({"style": "cylinder", "values": [8, 24, 24, 8, 0.3, 0.3, 0.5], "rect": [8, 8, 24, 24]})).unwrap(); + let warp = |app: &PhotocraftApp, i: usize| match &app.session.active().unwrap().doc.layers[i].content { + photocraft_doc::LayerContent::Smart(sm) => sm.warp.as_ref().map(|w| w.style), + _ => None, + }; + let (layers, steps) = (app.session.active().unwrap().doc.layers.len(), app.session.active().unwrap().history.past_len()); + assert_eq!(warp(&app, layers - 1), Some(WarpStyle::Cylinder)); + crate::menus::invoke(&mut app, &ctx, "edit.freeTransformCopy", json!({})).unwrap(); + enter_warp(&mut app, &ctx); + assert!(app.ui.transform.as_ref().unwrap().warp.is_some(), "Warp mode shows the cylinder"); + commit(&mut app); + assert!(!app.ui.status_error, "{}", app.ui.status); + let st = app.session.active().unwrap(); + assert_eq!((st.doc.layers.len(), st.history.past_len()), (layers + 1, steps + 1)); + assert_eq!(warp(&app, layers), Some(WarpStyle::Cylinder), "the copy is still a cylinder"); + app.session.undo(); + let st = app.session.active().unwrap(); + assert_eq!((st.doc.layers.len(), st.history.past_len()), (layers, steps), "one undo takes back the copy only"); + assert_eq!(warp(&app, layers - 1), Some(WarpStyle::Cylinder)); + } + /// #1099: cancel, frame cleanup and a commit before the next frame all belong to the /// original document, including after tab reordering and with shared layer IDs. #[test] From a05fee0719fe28cb9e22ec7969fb7425cab04e7b Mon Sep 17 00:00:00 2001 From: JGF <44821497+bommerts@users.noreply.github.com> Date: Tue, 13 Oct 2026 15:26:59 -0400 Subject: [PATCH 161/649] Keep adjustment clipping visible in compact Properties panels --- ATTRIBUTION.md | 1 + .../ui-egui/src/clipping_indicator_tests.rs | 111 ++++++++++++++++++ crates/ui-egui/src/panels.rs | 24 ++-- docs/gaps.md | 4 +- docs/images/adjustment-scope-after.png | Bin 0 -> 116268 bytes docs/images/adjustment-scope-before.png | Bin 0 -> 115745 bytes docs/ui-parity.md | 4 +- 7 files changed, 130 insertions(+), 14 deletions(-) create mode 100644 docs/images/adjustment-scope-after.png create mode 100644 docs/images/adjustment-scope-before.png diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index cbbbe069a5..ecb08019ba 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -84,6 +84,7 @@ The other built-in ICC profiles and the generated LUT looks are produced by code | `docs/brand/` (all files) | ArtCraft name, wordmark and mark | ArtCraft Team | getartcraft.com | Not open source; trademarks of the ArtCraft Team, [`docs/brand/LICENSE-brand.txt`](docs/brand/LICENSE-brand.txt) | | `docs/images/photocraft-*.jpg` | PhotoCraft screenshots | PhotoCraft contributors (UI) | Rendered offscreen with the `snapshot` example | MIT OR Apache-2.0 (UI); the artwork in each is public domain, listed below | | `docs/images/preferences-apply-*.png` | Preferences before and after adding Apply (no artwork) | PhotoCraft contributors | PhotoCraft control-channel capture and offscreen `snapshot` example | MIT OR Apache-2.0 | +| `docs/images/adjustment-scope-*.png` | Adjustment scope control before and after moving it above the editor (synthetic blank document, #5231) | PhotoCraft contributors | PhotoCraft offscreen `snapshot` example | MIT OR Apache-2.0 (UI); brand mark retains `docs/brand/LICENSE-brand.txt` | Artwork shown in the screenshots (all public domain, via Wikimedia Commons; details in [`docs/images/SOURCES.md`](docs/images/SOURCES.md)): diff --git a/crates/ui-egui/src/clipping_indicator_tests.rs b/crates/ui-egui/src/clipping_indicator_tests.rs index 7395a533de..92c5e0d2d8 100644 --- a/crates/ui-egui/src/clipping_indicator_tests.rs +++ b/crates/ui-egui/src/clipping_indicator_tests.rs @@ -2,6 +2,7 @@ use egui::{Event, Modifiers, PointerButton, pos2, vec2}; use egui_kittest::Harness; +use egui_kittest::kittest::Queryable; use serde_json::json; use crate::PhotocraftApp; @@ -80,6 +81,116 @@ fn alt_click_clipping_still_creates_releases_and_undoes_without_moving_rows() { assert!(!h.state().session.active().unwrap().doc.layer(active).unwrap().clipped); } +fn adjustment_harness(kind: &str, depth: u32, theme: crate::theme::ThemeKind, scale: f32, gpu: bool) -> Harness<'static, PhotocraftApp> { + let mut session = photocraft_engine::Session::new(); + session.execute("file.new", json!({"width": 16, "height": 8, "depth": depth})).unwrap(); + session.execute("edit.fill", json!({"color": "#b04020"})).unwrap(); + session.execute("layer.new.layer", json!({})).unwrap(); + session.execute("select.rect", json!({"x": 8, "y": 0, "width": 8, "height": 8})).unwrap(); + session.execute("edit.fill", json!({"color": "#208040"})).unwrap(); + session.execute("select.deselect", json!({})).unwrap(); + let mut app = PhotocraftApp::new(session, Default::default()); + app.ui.dock_tabs.properties = 1; + let builder = Harness::builder().with_size(vec2(250.0, 160.0)).with_pixels_per_point(scale); + let builder = if gpu { builder.wgpu() } else { builder }; + let mut h = builder.build_ui_state( + |ui, app: &mut PhotocraftApp| { + if !ui.ctx().fonts(|fonts| fonts.families().contains(&egui::FontFamily::Name("medium".into()))) { + return; + } + crate::i18n::with_language(crate::i18n::Lang::EN, || { + egui::ScrollArea::vertical().show(ui, |ui| { + if app.ui.dock_tabs.properties == 1 { + super::adjustments_grid(app, ui); + } else { + super::properties_body(app, ui); + } + }); + }); + }, + app, + ); + PhotocraftApp::setup_context(&h.ctx, theme); + h.run_steps(4); + h.get_by_label(kind).click(); + h.run_steps(4); + h +} + +#[test] +fn adjustment_scope_control_fits_compact_properties_before_scrolling() { + for theme in crate::theme::ThemeKind::ALL { + for scale in [1.0, 1.5, 2.0] { + for kind in ["Hue/Saturation", "Curves", "Selective Color", "Color Lookup"] { + let h = adjustment_harness(kind, 8, theme, scale, false); + let rect = h.get_by_label("Clip to layer below").rect(); + assert!(egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(250.0, 160.0)).contains_rect(rect), "{theme:?}, {scale}x, {kind}: {rect:?}"); + } + } + } +} + +fn sample(h: &mut Harness<'_, PhotocraftApp>, x: i32) -> Vec { + serde_json::from_value(h.state_mut().run("document.pixel", json!({"x": x, "y": 4})).unwrap()).unwrap() +} + +#[test] +fn panel_adjustment_clips_to_selected_layer_and_scope_undoes_at_all_depths() { + for depth in [8, 16, 32] { + let mut h = adjustment_harness("Hue/Saturation", depth, crate::theme::ThemeKind::Pro, 1.0, false); + let id = h.state().session.active().unwrap().active_layer.unwrap(); + h.state_mut().run("layer.setAdjustment", json!({"layer": id.0, "saturation": -100})).unwrap(); + h.run_steps(4); + let all_layers = sample(&mut h, 2); + assert!((all_layers[0] - all_layers[1]).abs() < 0.01, "unclipped adjustment desaturates the lower layer"); + let adjusted_target = sample(&mut h, 12); + let steps = h.state().session.active().unwrap().history.past_len(); + h.get_by_label("Clip to layer below").click(); + h.run_steps(4); + assert!(h.state().session.active().unwrap().doc.layer(id).unwrap().clipped); + assert_eq!(h.state().session.active().unwrap().history.past_len(), steps + 1); + let lower_layer = sample(&mut h, 2); + assert!(lower_layer[0] - lower_layer[1] > 0.2, "clipping restores the lower layer's colour"); + assert!(sample(&mut h, 12).iter().zip(&adjusted_target).all(|(a, b)| (a - b).abs() <= 1.0 / 255.0), "the selected layer stays adjusted"); + h.state_mut().run("edit.undo", json!({})).unwrap(); + assert_eq!(sample(&mut h, 2), all_layers); + h.state_mut().run("edit.redo", json!({})).unwrap(); + assert_eq!(sample(&mut h, 2), lower_layer); + h.run_steps(4); + h.get_by_label("Clip to layer below").click(); + h.run_steps(4); + assert!(!h.state().session.active().unwrap().doc.layer(id).unwrap().clipped); + assert_eq!(sample(&mut h, 2), all_layers, "scope can be released through the same control"); + } +} + +#[test] +#[ignore = "writes synthetic compact adjustment-panel screenshots for visual inspection"] +fn write_adjustment_scope_preview() { + let phase = std::env::var("PHOTOCRAFT_EVIDENCE_PHASE").unwrap_or_else(|_| "after".into()); + let output = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../plan/evidence/5231"); + std::fs::create_dir_all(&output).unwrap(); + for theme in [crate::theme::ThemeKind::Pro, crate::theme::ThemeKind::Studio] { + let mut h = adjustment_harness("Hue/Saturation", 8, theme, 2.0, true); + h.ctx.send_viewport_cmd(egui::ViewportCommand::Screenshot(Default::default())); + h.step(); + h.step(); + let image = h + .ctx + .input(|input| { + input.events.iter().find_map(|event| match event { + Event::Screenshot { image, .. } => Some(image.clone()), + _ => None, + }) + }) + .unwrap(); + let rgba = image.pixels.iter().flat_map(|pixel| pixel.to_array()).collect(); + let image = photocraft_codecs::Image::from_u8(image.size[0] as u32, image.size[1] as u32, photocraft_codecs::ChannelLayout::Rgba, rgba).unwrap(); + let png = photocraft_codecs::encode(&image, photocraft_codecs::Format::Png, &Default::default()).unwrap(); + std::fs::write(output.join(format!("{phase}-{}.png", theme.id())), png).unwrap(); + } +} + #[test] #[ignore = "writes synthetic English Layers-panel screenshots for before/after inspection"] fn write_clipping_indicator_preview() { diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 04e775439e..89ce01a866 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -3656,20 +3656,20 @@ pub fn properties_window(app: &mut PhotocraftApp, ctx: &egui::Context) { } fn adjustment_controls(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: LayerId, adj: &photocraft_doc::Adjustment) { + // Keep the scope reachable before tall editors and within a compact dock (#5231). + // Adjustment layers affect the stack by default; clipping limits them to their base. + if let Some(mut clip) = app.session.active().and_then(|s| s.doc.layer(id).map(|l| l.clipped)) + && widgets::toggle(ui, &mut clip, tl!("Clip to layer below")).changed() + { + let _ = app.run("layer.setProps", json!({"layer": id.0, "clipped": clip})); + } + ui.add_space(6.0); crate::adjust_editors::layer_editor(app, ui, id, adj); ui.add_space(6.0); - let layer = app.session.active().and_then(|s| s.doc.layer(id).map(|l| (l.visible, l.clipped))); - if let Some((visible, clipped)) = layer { - ui.horizontal(|ui| { - let mut vis = visible; - if widgets::toggle(ui, &mut vis, tl!("Adjustment visible")).changed() { - let _ = app.run("layer.setProps", json!({"layer": id.0, "visible": vis})); - } - let mut clip = clipped; - if widgets::toggle(ui, &mut clip, tl!("Clip to layer below")).changed() { - let _ = app.run("layer.setProps", json!({"layer": id.0, "clipped": clip})); - } - }); + if let Some(mut vis) = app.session.active().and_then(|s| s.doc.layer(id).map(|l| l.visible)) + && widgets::toggle(ui, &mut vis, tl!("Adjustment visible")).changed() + { + let _ = app.run("layer.setProps", json!({"layer": id.0, "visible": vis})); } ui.add_space(6.0); if widgets::secondary_button(ui, tl!("Reset to defaults"), ui.available_width()).clicked() { diff --git a/docs/gaps.md b/docs/gaps.md index 4457a87dde..f043979518 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where PhotoCraft falls short of Photoshop -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-18 · **Change:** minor (G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-20 · **Change:** minor (G9: visible adjustment clipping in compact Properties, #5231; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 @@ -195,6 +195,7 @@ what an agent can't finish alone. - **Estimate:** 60–110 h. ### G9. Panels, preferences and workspace +- **Progress (2026-10-13):** adjustment clipping is reachable above the Properties editor in a compact dock (#5231), with all-theme layout coverage and 8/16/32-bit scope and undo/redo tests. The normal adjustment-layer scope and remaining estimate stay unchanged. - **Progress (2026-10-12):** toolbar tool shortcuts can be reassigned, removed and reset (#4086), with saved bindings, matching toolbar hints and regression coverage (`ui-egui/src/tool_shortcuts.rs`). - **Missing:** 27 of 156 preferences do nothing (scorecard prefs audit); panel groups can't @@ -270,6 +271,7 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| +| 2026-10-20 | minor | G9: adjustment clipping remains visible in compact Properties (#5231); no readiness percentage or estimate changed | | 2026-10-18 | minor | G9: with no selection, Copy takes fill and adjustment layers whole and Paste recreates them (#2344); UI-217-23 stays partial (a single pixel layer copies its pixels only); estimate unchanged | | 2026-10-14 | minor | G1: a PSD smart object's filter mask shows when the file opens (Photoshop stores the filtered pixels unmasked); export stores them that way too; Photoshop-oracle floor 185 → 188 of 258 | | 2026-10-13 | minor | G14: D90 image area measured (4288 × 2848 at (10, 10)); gap remains open | diff --git a/docs/images/adjustment-scope-after.png b/docs/images/adjustment-scope-after.png new file mode 100644 index 0000000000000000000000000000000000000000..a65da5e23cd0ceff46dd1c39667162901bababd2 GIT binary patch literal 116268 zcmbS!3tW`-y7h~wSYFs_rKLitX=a9HiY736v~5<#E_YI1AhU88Dk2%fZ3Z=Onc_7v z5-hjb&Vyv8hysJ6A}UguqJa!|yfQP4Ff%YS@3+=7wa>28KHvGi-*4wuE;H}@fB*mI zSvg-p zd*|TSK0akpW1H5WKDTGd^YivCEI;(i|K9m1{p07d(w`hPu*va$_Pg<4t{xwGF)ROS zdESnk8(;6;cjPyJxX1ULz4YQMVRL@-hkCWk?|zQ|R2Oyp-Our#`oKqj|5ewX?WK*6 z-PiTq%-Jn!(NohNOMQOE-g^TE{=pA^QrdVYsWi!UwP;CB-Pfw-zIC1Uytt#o>j!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E@( zLM8myQ^Tn?u}{Mx#mb9}m2@F(wAC;u3x97~2C&|+Pr!WO;0?A22xoc5h)J|$UCQ`L z{Yr^PDHJl@|8v+aQejJkUOko^jS)7a*9gHmZ31iQ2wW_bAWQw1Yi!nGEk};*DNFC# z_>eOc+zc_5K~TEJZe`qk-%s!YHWA(;ezE{s50IS#83?nyi^`RB2K-z8@mBZDzCSzd zPAv#ICZJ8>gmUv7Q}Y|=IMK(<#6IxIebcuamv>W4H~*+d;{k<`O=*h4g@wD|H$Ju8 zk&xFNU`$8Y=$qNzH`a`&#KL$>Y;d^rc${S4ZPB!jQmD;gy23&`uj{OcKs#`>c#tk@ z!cW0qVM&Hp)4W|R1_xH6AB5jWw_(o+Qg}6J6rnsZ0v+L|%w;%R!l!X^UuNTB4*@dP zmR9=9{@Z?8i`xVna9ZnC^Lh-twQj_2AT14GnWmJv^|3K;oJ=krdFUpUycOYEA=XD9 zbYOcpv&Xo_3&&qr-AhTjkSV1|=yIAT+o=j3^Mls@MtnrrTO7RoHr?R^HywT61sBM8 upuNwRU4TAAE^O_=0VlW5XbHQ7j~#u(kXZ-s3G{!12mXA(yr14U<$nW=HU|;_ literal 0 HcmV?d00001 diff --git a/docs/images/adjustment-scope-before.png b/docs/images/adjustment-scope-before.png new file mode 100644 index 0000000000000000000000000000000000000000..8269ef23596ae42519c8140030a081e460f6a009 GIT binary patch literal 115745 zcmbS!3tW`-y7h~wSYFs_rKLitX=a9HiY736v~5<#E_YI1AhU88Dk2%fZ3Z=Onc_7v z5-hjb&Vyv8hysJ6A}UguqJa!|yfQP4Ff%YS@3+=7wa>28KHvGi-*4wuE;H}@fB*mI zSX8b6KPH~dGP#~AGEvul>xH0kY0r8c#T!R`*N)nz+xkDs2`p=wx)JN$Qd z?lydN@Y~ss=iE^D)GwKuxvfvnV}>8Y@=Z%~)$;tu_5`^5r{=5s6R*rqdc=_9dMjw% zi73~3|AO9zdy|LGxm-P^vi6;=mZ0A+5f;w+Ont=lcS7}@HO;k}v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YkCU^l1)*{FM!1VGdF*rmrT|G0fZo{4tr0{Cc5M}^@>`W4U2xm+9 zG*0gG^X*z;cYOfE)GaSheedNG{1AKqo9~+I0`S&~*d8D)4Pfap?ZY0;!^WrznOr0v z`_3Abyum`9(*DP^z(mzjj`sfg{t1=$9~`PAU2#+?61tp*$#$xOb!oP0LkGje!8>Bp z9dyzNVkz(kJ>J&q%Pv5#As4o`;DBq|X0#-d **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-15 · **Change:** minor (Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-20 · **Change:** minor (adjustment clipping stays visible in compact Properties, #5231; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; 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, @@ -219,6 +219,7 @@ Paragraph; the rest open as in-app floating windows. | Document tabs: overflow, context menu, reorder | done | UI-217-6; middle-click close #2570 | | Layers panel: wheel steps blend modes, drop on New/Trash | partial | UI-217-14 | | Layers panel filter-type dropdown (Kind, Name, Effect, Mode, Attribute, Color, Smart Object, Selected, Artboard) | partial | Kind, Name and Mode; the other six missing. `layer_filter_ui.rs`, `ui.set {layerFilter}` (#5048) | +| Adjustment scope: clipping control visible above tall Properties editors in a compact dock | done (2026-10-13) | `panels.rs`, `clipping_indicator_tests.rs`; #5231; stack-wide default retained | | Smart filter rows: click selects, drag onto another smart object moves, ⌥-drag copies, drag onto Delete removes | done | `smart_ui.rs`, `layer.smartFilter.transfer` (#4271) | | Layers panel: Clip Thumbnails to Layer Bounds (panel menu, `interface.clipThumbnailsToLayerBounds`) | done (2026-10-12) | `layer_thumb_bounds_tests.rs`; #4281. Thumbnail size and the Panel Options dialog to come | | Smart filter rows: drag up or down the stack to reorder (a line marks the drop; the bottom filter is applied first) | done | `smart_ui.rs` `reorder_drop`, `layer.smartFilter.move` | @@ -227,6 +228,7 @@ Paragraph; the rest open as in-app floating windows. | Date | Change | Summary | |---|---|---| +| 2026-10-20 | minor | Adjustment clipping moved above Properties editors to remain visible in compact docks (#5231); scope, undo/redo and 8/16/32-bit pixel regressions; readiness estimate unchanged | | 2026-10-13 | minor | Menu bar from the keyboard: Alt / F10 focus, Alt+letter, underlined mnemonics (#4988) | | 2026-10-13 | minor | Layers panel filter row: Kind is a real dropdown with Kind, Name and Mode filters, drivable by `ui.set {layerFilter}` (#5048); row added as partial | | 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 | From 22c97457bd435142ad91b2cbbe797255cfc26145 Mon Sep 17 00:00:00 2001 From: JGF <44821497+bommerts@users.noreply.github.com> Date: Sat, 17 Oct 2026 10:33:50 -0400 Subject: [PATCH 162/649] docs: align clipping evidence dates and screenshot paths --- crates/ui-egui/src/clipping_indicator_tests.rs | 4 ++-- docs/ui-parity.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/clipping_indicator_tests.rs b/crates/ui-egui/src/clipping_indicator_tests.rs index 92c5e0d2d8..14d8c61d7e 100644 --- a/crates/ui-egui/src/clipping_indicator_tests.rs +++ b/crates/ui-egui/src/clipping_indicator_tests.rs @@ -165,10 +165,10 @@ fn panel_adjustment_clips_to_selected_layer_and_scope_undoes_at_all_depths() { } #[test] -#[ignore = "writes synthetic compact adjustment-panel screenshots for visual inspection"] +#[ignore = "writes synthetic compact adjustment-panel screenshots to log/adjustment-scope"] fn write_adjustment_scope_preview() { let phase = std::env::var("PHOTOCRAFT_EVIDENCE_PHASE").unwrap_or_else(|_| "after".into()); - let output = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../plan/evidence/5231"); + let output = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../log/adjustment-scope"); std::fs::create_dir_all(&output).unwrap(); for theme in [crate::theme::ThemeKind::Pro, crate::theme::ThemeKind::Studio] { let mut h = adjustment_harness("Hue/Saturation", 8, theme, 2.0, true); diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 98ac82c854..12e3c2d3a2 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -219,7 +219,7 @@ Paragraph; the rest open as in-app floating windows. | Document tabs: overflow, context menu, reorder | done | UI-217-6; middle-click close #2570 | | Layers panel: wheel steps blend modes, drop on New/Trash | partial | UI-217-14 | | Layers panel filter-type dropdown (Kind, Name, Effect, Mode, Attribute, Color, Smart Object, Selected, Artboard) | partial | Kind, Name and Mode; the other six missing. `layer_filter_ui.rs`, `ui.set {layerFilter}` (#5048) | -| Adjustment scope: clipping control visible above tall Properties editors in a compact dock | done (2026-10-13) | `panels.rs`, `clipping_indicator_tests.rs`; #5231; stack-wide default retained | +| Adjustment scope: clipping control visible above tall Properties editors in a compact dock | done (2026-10-20) | `panels.rs`, `clipping_indicator_tests.rs`; #5231; stack-wide default retained | | Smart filter rows: click selects, drag onto another smart object moves, ⌥-drag copies, drag onto Delete removes | done | `smart_ui.rs`, `layer.smartFilter.transfer` (#4271) | | Layers panel: Clip Thumbnails to Layer Bounds (panel menu, `interface.clipThumbnailsToLayerBounds`) | done (2026-10-12) | `layer_thumb_bounds_tests.rs`; #4281. Thumbnail size and the Panel Options dialog to come | | Smart filter rows: drag up or down the stack to reorder (a line marks the drop; the bottom filter is applied first) | done | `smart_ui.rs` `reorder_drop`, `layer.smartFilter.move` | From 067ff89befb65336287b9b83e08db1b4a2176f3c Mon Sep 17 00:00:00 2001 From: JGF <44821497+bommerts@users.noreply.github.com> Date: Sat, 17 Oct 2026 10:44:18 -0400 Subject: [PATCH 163/649] ci: validate clipping PR against upstream test-helper fix From 38826b83691c3c176929825a0b586b7a55fce307 Mon Sep 17 00:00:00 2001 From: durtyrobbin <76844303+durtyrobbin@users.noreply.github.com> Date: Tue, 20 Oct 2026 21:07:21 -0400 Subject: [PATCH 164/649] Keep mixer preview limits out of commands and discard stale prepared strokes --- Cargo.lock | 14 ++--- crates/engine/src/brush_cmds.rs | 2 +- crates/engine/src/brush_cmds/mixer_live.rs | 45 ++++++++++---- .../engine/src/brush_cmds/mixer_live_tests.rs | 59 +++++++++++++++++++ crates/engine/src/jobs.rs | 8 +++ crates/ui-egui/src/canvas.rs | 50 ++++++++++++---- docs/mixer-live.md | 16 +++-- 7 files changed, 159 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b5a7bbf9b..33dcbfda3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6033,9 +6033,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.45" +version = "0.23.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" dependencies = [ "aws-lc-rs", "once_cell", @@ -6096,9 +6096,9 @@ checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f" [[package]] name = "rustls-webpki" -version = "0.103.15" +version = "0.103.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" +checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281" dependencies = [ "aws-lc-rs", "ring", @@ -6950,7 +6950,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.4.3", + "getrandom 0.3.4", "once_cell", "rustix 1.1.5", "windows-sys 0.61.2", @@ -7905,9 +7905,9 @@ dependencies = [ [[package]] name = "webpki-root-certs" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b96554aa2acc8ccdb7e1c9a58a7a68dd5d13bccc69cd124cb09406db612a1c9b" +checksum = "58ec80e73fd8baf57bf0d9615554c75348bda990d6d5bbeab964dd068319fecb" dependencies = [ "rustls-pki-types", ] diff --git a/crates/engine/src/brush_cmds.rs b/crates/engine/src/brush_cmds.rs index 6be1ef8428..725e246cab 100644 --- a/crates/engine/src/brush_cmds.rs +++ b/crates/engine/src/brush_cmds.rs @@ -1103,7 +1103,7 @@ pub fn specs() -> Vec { spec!( "paint.mixerBrush", "Mixer Brush", - r##"{"points":[…] (max 65536 samples, 2048px per segment),"brush":{…}?,"preset":name?,"size":0.5..1024 px?,"wet":0..100=brush.mixer.wet,"load":0..100=brush.mixer.load,"mix":0..100=brush.mixer.mix,"flow":0..100=brush.mixer.flow,"color":"#rrggbb"?=foreground,"sampleAllLayers":bool=brush.mixer.sampleAllLayers,"cleanAfterStroke":bool=brush.mixer.cleanAfterStroke,"loadAfterStroke":bool=brush.mixer.reloadAfterStroke,"seed":u64?,"mixerState":{reservoir,amount,pickup,spatial} (optional captured replay state; spatial is null or 4096 RGBA colors)}"##, + r##"{"points":[…] (max 65536 samples; long segments are interpolated),"brush":{…}?,"preset":name?,"size":0.5..1024 px?,"wet":0..100=brush.mixer.wet,"load":0..100=brush.mixer.load,"mix":0..100=brush.mixer.mix,"flow":0..100=brush.mixer.flow,"color":"#rrggbb"?=foreground,"sampleAllLayers":bool=brush.mixer.sampleAllLayers,"cleanAfterStroke":bool=brush.mixer.cleanAfterStroke,"loadAfterStroke":bool=brush.mixer.reloadAfterStroke,"seed":u64?,"mixerState":{reservoir,amount,pickup,spatial} (optional captured replay state; spatial is null or 4096 RGBA colors)}"##, has_paintable, mixer_brush, true diff --git a/crates/engine/src/brush_cmds/mixer_live.rs b/crates/engine/src/brush_cmds/mixer_live.rs index 21bed7d414..ad17b58b23 100644 --- a/crates/engine/src/brush_cmds/mixer_live.rs +++ b/crates/engine/src/brush_cmds/mixer_live.rs @@ -33,6 +33,7 @@ struct Core { pre: Surface, work: Surface, tiles: BTreeSet<(i32, i32)>, + preview_limits: bool, state: MixerState, settings: MixerSettings, layer: Option, @@ -67,7 +68,7 @@ impl Core { for ty in r.y0.div_euclid(TILE)..=(r.y1 - 1).div_euclid(TILE) { for tx in r.x0.div_euclid(TILE)..=(r.x1 - 1).div_euclid(TILE) { if !self.tiles.contains(&(tx, ty)) { - if self.tiles.len() >= MAX_TILES { + if self.preview_limits && self.tiles.len() >= MAX_TILES { return Err(bad(CMD, "Mixer Brush stroke working set exceeds 256 tiles")); } let tile = Rect::new(tx * TILE, ty * TILE, (tx + 1) * TILE, (ty + 1) * TILE); @@ -129,6 +130,10 @@ pub struct LiveMixer { impl LiveMixer { pub fn begin(s: &Session, p: &Value) -> Result { + Self::begin_with_limits(s, p, true) + } + + fn begin_with_limits(s: &Session, p: &Value, preview_limits: bool) -> Result { has_paintable(s).map_err(EngineError::Other)?; if p.get("points").and_then(Value::as_array).is_some_and(|v| v.len() > 65_536) { return Err(bad(CMD, "stroke exceeds 65536 recorded input samples")); @@ -181,6 +186,7 @@ impl LiveMixer { pre, work, tiles: BTreeSet::new(), + preview_limits, state: state.clone(), settings, layer, @@ -221,21 +227,36 @@ impl LiveMixer { if self.points.len().saturating_add(points.len()) > 65_536 { return Err(bad(CMD, "stroke exceeds 65536 recorded input samples")); } - let mut last = self.core.last; - for point in points { - if last.is_some_and(|p| (point.x - p.x).hypot(point.y - p.y) > 2048.0) { - return Err(bad(CMD, "input segment exceeds 2048 pixels; supply interpolated input")); - } - last = Some(*point); - } let cmyk = self.cmyk.clone(); photocraft_color::convert::with_cmyk_space(cmyk.as_ref(), || { let old_tail = self.tail; let mut damage = Rect::EMPTY; for point in points { - let (mut dabs, mut dual) = (Vec::new(), Vec::new()); - self.core.generator.push(&[*point], &mut dabs, &mut dual); - damage = damage.union(&self.core.apply(&dabs)?); + // Bound each temporary dab batch without rejecting sparse mouse events or + // long Shift-click lines. Live and recorded replay use identical interpolation. + let start = self.core.last.unwrap_or(*point); + let steps = ((point.x - start.x).hypot(point.y - start.y) / 2048.0).ceil().max(1.0) as usize; + for step in 1..=steps { + let f = step as f64 / steps as f64; + let ff = f as f32; + let q = if step == steps { + *point + } else { + StrokePoint { + x: start.x + (point.x - start.x) * f, + y: start.y + (point.y - start.y) * f, + pressure: start.pressure + (point.pressure - start.pressure) * ff, + tilt_x: start.tilt_x + (point.tilt_x - start.tilt_x) * ff, + tilt_y: start.tilt_y + (point.tilt_y - start.tilt_y) * ff, + rotation: start.rotation + (point.rotation - start.rotation) * ff, + wheel: start.wheel + (point.wheel - start.wheel) * ff, + time: start.time + (point.time - start.time) * f, + } + }; + let (mut dabs, mut dual) = (Vec::new(), Vec::new()); + self.core.generator.push(&[q], &mut dabs, &mut dual); + damage = damage.union(&self.core.apply(&dabs)?); + } self.core.last = Some(*point); } let mut finished = self.core.clone(); @@ -283,7 +304,7 @@ pub(super) fn run(s: &mut Session, p: &Value) -> Result { }); let live = match cached { Some(live) => live, - None => LiveMixer::begin(s, p)?, + None => LiveMixer::begin_with_limits(s, p, false)?, }; let damage = live.bounds(); s.edit("Mixer Brush", |doc, _| { diff --git a/crates/engine/src/brush_cmds/mixer_live_tests.rs b/crates/engine/src/brush_cmds/mixer_live_tests.rs index bac3a97446..4a823a6c5c 100644 --- a/crates/engine/src/brush_cmds/mixer_live_tests.rs +++ b/crates/engine/src/brush_cmds/mixer_live_tests.rs @@ -1,6 +1,7 @@ use super::mixer_live::LiveMixer; use super::*; use photocraft_color::PixelFormat; +use std::sync::Arc; fn fixture(fmt: PixelFormat) -> Session { let mut s = Session::new(); @@ -240,3 +241,61 @@ fn mixer_large_tip_retains_off_canvas_paint_and_commits_the_live_result() { s.execute("edit.undo", json!({})).unwrap(); assert_eq!(*s.active().unwrap().doc, *source); } + +#[test] +fn mixer_long_segments_are_interpolated_and_replay_matches_live() { + let mut s = fixture(PixelFormat::RGBA8); + let p = json!({"points":[[20,48],[5020,48]],"seed":71,"size":2,"sampleAllLayers":false,"wet":0,"mix":0,"load":100,"color":"#ff0000"}); + let live = LiveMixer::begin(&s, &p).unwrap(); + let id = s.active().unwrap().active_layer.unwrap(); + let expected = live.doc.layer(id).unwrap().surface().unwrap().clone(); + s.execute("paint.mixerBrush", p).unwrap(); + for x in [20, 1020, 2068, 4090, 5019] { + assert_eq!(target(&s).rgba(x, 48), expected.rgba(x, 48)); + assert!(target(&s).rgba(x, 48)[3] > 0.0); + } +} + +#[test] +fn mixer_prepared_offer_is_dropped_on_every_early_dispatch_failure() { + for failure in 0..4 { + let mut s = fixture(PixelFormat::RGBA8); + let live = LiveMixer::begin(&s, &json!({"points":[[20,20]],"size":4})).unwrap(); + let p = live.prepare_commit(&mut s).unwrap(); + let before = s.active().unwrap().doc.clone(); + let result = match failure { + 0 => { + s.authorize = Some(|_, _| Err(EngineError::Other("denied".into()))); + s.execute("paint.mixerBrush", p) + } + 1 => s.execute("paint.mixerBrush", json!("invalid params")), + 2 => s.execute("unknown.command", p), + _ => { + s.active_mut().unwrap().active_layer = None; + s.execute("paint.mixerBrush", p) + } + }; + assert!(result.is_err()); + assert!(s.prepared_mixer.is_none(), "failed dispatch retained the preview: {failure}"); + assert!(Arc::ptr_eq(&s.active().unwrap().doc, &before)); + } +} + +#[test] +fn mixer_command_outgrows_the_preview_tile_budget_without_losing_the_stroke() { + let mut s = fixture(PixelFormat::RGBA8); + let points: Vec<_> = (0..257).map(|i| [128.0 + (i % 17) as f64 * 512.0, 128.0 + (i / 17) as f64 * 512.0]).collect(); + let p = json!({"points":points,"size":2,"brush":{"spacing":10.0,"smoothing":{"amount":0.0}},"seed":44, + "sampleAllLayers":false,"wet":0,"mix":0,"load":100,"color":"#ff0000"}); + let before = s.active().unwrap().doc.clone(); + let err = LiveMixer::begin(&s, &p).err().expect("bounded preview"); + assert!(err.to_string().contains("256 tiles"), "{err}"); + assert!(Arc::ptr_eq(&s.active().unwrap().doc, &before)); + s.execute("paint.mixerBrush", p).unwrap(); + // Spacing deliberately leaves gaps; inspect the final tile's stroke region instead + // of assuming the exact release pixel is a dab center. + let end = Rect::new(600, 7776, 672, 7840); + assert!(target(&s).read_region(end).chunks_exact(4).any(|px| px[3] > 0.0)); + s.execute("edit.undo", json!({})).unwrap(); + assert!(target(&s).read_region(end).chunks_exact(4).all(|px| px[3] == 0.0)); +} diff --git a/crates/engine/src/jobs.rs b/crates/engine/src/jobs.rs index 0ee0573170..c9e2c90bbd 100644 --- a/crates/engine/src/jobs.rs +++ b/crates/engine/src/jobs.rs @@ -714,6 +714,9 @@ impl Session { /// Run the command `id`: inline, or (with `background`) as a job when it is one. pub(crate) fn dispatch(&mut self, id: &str, params: Value, background: bool) -> Result { + // The offer belongs to this one dispatch. Early errors drop it locally, including + // authorization, validation, floating-selection and admission failures. + let prepared_mixer = self.prepared_mixer.take(); let spec = crate::commands::find(id).ok_or_else(|| EngineError::UnknownCommand(id.to_string()))?; // Params are named fields: anything but an object (or null, meaning none) is a caller // mistake, not "use every default". @@ -761,8 +764,12 @@ impl Session { // Last-resort guard (AGENTS.md, Never crash): a command that panics anyway fails with an // error instead of taking the app down. `edit` only commits a document after its closure // returns, so the documents are unchanged. + if id == "paint.mixerBrush" { + self.prepared_mixer = prepared_mixer; + } let r = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| (spec.run)(self, &run_params))) .unwrap_or_else(|_| Err(EngineError::Other(format!("`{id}` failed with an internal error (logged); the document is unchanged")))); + self.prepared_mixer = None; if self.actions.recording.is_none() { self.actions.recording = recording; } @@ -907,6 +914,7 @@ impl Session { .unwrap_or_else(|_| Err(EngineError::Other(format!("`{label}` failed with an internal error (logged); the document is unchanged")))), None => Err(EngineError::Other("internal error: job applied twice".into())), }; + self.prepared_mixer = None; if self.actions.recording.is_none() { self.actions.recording = recording; } diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 801c596b9e..d462baea8a 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -491,6 +491,7 @@ impl EngineStroke { /// A stroke shown while it is drawn: the engine renders the real result onto a copy of the /// document, and the canvas redraws only what each step changed. pub(crate) struct LiveStroke { + preview_failed: bool, stroke: EngineStroke, doc: photocraft_doc::DocId, revision: u64, @@ -705,7 +706,8 @@ fn begin_live_stroke(app: &PhotocraftApp) -> Option { let st = app.session.active()?; let d = app.drag.as_ref()?; let stroke = if d.tool == Tool::MixerBrush { - let p = stroke_params(app, d, &app.stylus.stroke_points(&d.points)); + let points = app.stylus.stroke_points(&d.points); + let p = stroke_params(app, d, points.get(..1)?); EngineStroke::Mixer(Box::new(photocraft_engine::brush_cmds::mixer_live::LiveMixer::begin(&app.session, &p).ok()?)) } else if d.tool == Tool::ColorReplacement { // The params `retouch_ui::finish_stroke` commits. @@ -729,7 +731,15 @@ fn begin_live_stroke(app: &PhotocraftApp) -> Option { }; let n = STROKES.fetch_add(1, std::sync::atomic::Ordering::Relaxed) & 0xff_ffff; let damage = vec![stroke.bounds()]; - Some(LiveStroke { stroke, doc: st.doc.id, revision: st.revision, key: (1 << 44) | (n << 20), damage, fed: d.points.len() }) + Some(LiveStroke { + stroke, + doc: st.doc.id, + revision: st.revision, + key: (1 << 44) | (n << 20), + damage, + fed: if d.tool == Tool::MixerBrush { 1 } else { d.points.len() }, + preview_failed: false, + }) } /// Cancel uncommitted mixer paint when its document, tool or input context goes away. @@ -756,6 +766,9 @@ fn feed_live_stroke(app: &mut PhotocraftApp) { return; } let (Some(l), Some(d)) = (app.live_stroke.as_mut(), app.drag.as_ref()) else { return }; + if l.preview_failed { + return; + } let pose = &app.stylus.stroke; // The same times `stroke_points` gives the commit (from the drag's first point). let t0 = app.stylus.point_ms(0); @@ -777,12 +790,14 @@ fn feed_live_stroke(app: &mut PhotocraftApp) { match l.stroke.push(&pts) { Ok(r) => l.damage.push(r), Err(e) => { - let mixer = d.tool == Tool::MixerBrush; - app.live_stroke = None; - if mixer { - app.drag = None; + if d.tool == Tool::MixerBrush { + // Keep the last valid preview and its document/revision guard. All input + // stays in the drag; release replays it without the preview tile budget. + l.preview_failed = true; app.ui.status = e.to_string(); app.ui.status_error = true; + } else { + app.live_stroke = None; } } } @@ -5696,8 +5711,7 @@ pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers) } app.live_stroke = if strokes_live(tool) { begin_live_stroke(app) } else { None }; if tool == Tool::MixerBrush && app.live_stroke.is_none() { - // A refused mixer stroke must never fall back to a stand-in trail and paint - // unexpectedly on release. Surface the engine's concrete error immediately. + // The first dab itself is invalid. Do not queue an unexpected release edit. if let Some(d) = app.drag.as_ref() { let p = stroke_params(app, d, &app.stylus.stroke_points(&d.points)); if let Err(e) = photocraft_engine::brush_cmds::mixer_live::LiveMixer::begin(&app.session, &p) { @@ -5706,6 +5720,8 @@ pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers) } } app.drag = None; + } else if tool == Tool::MixerBrush { + feed_live_stroke(app); } } ToolEvent::Move { x, y, pressure } => { @@ -6025,6 +6041,13 @@ pub(crate) fn finish_gesture(app: &mut PhotocraftApp, d: Drag) { if let Some(l) = live { let (doc, key, steps) = (l.doc, l.key, l.damage.len() as u64); if let EngineStroke::Mixer(mixer) = l.stroke { + if l.preview_failed { + let mut p = stroke_params(app, &d, &app.stylus.stroke_points(&d.points)); + p["seed"] = json!(mixer.seed); + drop(mixer); + let _ = app.run("paint.mixerBrush", p); + return; + } match mixer.prepare_commit(&mut app.session) { Ok(p) => { if app.run("paint.mixerBrush", p).is_ok() { @@ -7895,7 +7918,7 @@ mod tests { #[test] fn mixer_release_includes_a_new_endpoint_and_deferred_frame_samples() { - for deferred in [false, true] { + for (deferred, failed) in [(false, false), (true, false), (false, true)] { let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); app.run("file.new", json!({"width":120,"height":60,"background":"#00ff00"})).unwrap(); app.run("layer.new.layer", json!({})).unwrap(); @@ -7905,6 +7928,9 @@ mod tests { let m = egui::Modifiers::NONE; tool_event(&mut app, ToolEvent::Down { x: 20.0, y: 30.0, pressure: 1.0 }, m); app.defer_live_stroke = deferred; + if failed { + app.live_stroke.as_mut().unwrap().preview_failed = true; + } tool_event(&mut app, ToolEvent::Move { x: 50.0, y: 30.0, pressure: 1.0 }, m); tool_event(&mut app, ToolEvent::Up { x: 95.0, y: 30.0 }, m); let doc = app.session.active().unwrap().doc.clone(); @@ -7920,7 +7946,7 @@ mod tests { #[test] fn mixer_escape_focus_loss_and_tool_switch_cancel_without_an_edit() { - for mode in 0..3 { + for mode in 0..6 { let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); app.run("file.new", json!({"width":120,"height":60,"background":"#00ff00"})).unwrap(); app.run("layer.new.layer", json!({})).unwrap(); @@ -7929,6 +7955,10 @@ mod tests { let steps = app.session.active().unwrap().history.past_len(); tool_event(&mut app, ToolEvent::Down { x: 30.0, y: 30.0, pressure: 1.0 }, egui::Modifiers::NONE); assert!(app.live_stroke.is_some()); + if mode >= 3 { + app.live_stroke.as_mut().unwrap().preview_failed = true; + } + let mode = mode % 3; let ctx = egui::Context::default(); let mut raw = egui::RawInput { focused: mode != 1, ..Default::default() }; if mode == 0 { diff --git a/docs/mixer-live.md b/docs/mixer-live.md index 577c4b3e2b..53dbe1223d 100644 --- a/docs/mixer-live.md +++ b/docs/mixer-live.md @@ -81,11 +81,17 @@ the six paint-load control labels are translated in all 20 supported catalogs. ## Resource envelope and limitations -Live mixer size is limited to 1024 pixels; dense footprints to 4,194,304 pixels; -one input segment to 2,048 pixels; one stroke to 250,000 dabs and 256 working tiles -(256 x 256 pixels each). Requests beyond these limits return errors. A spatial load -uses 64 KiB of float color data. Document snapshots share untouched tiles. These -limits are explicit initial engineering bounds, not hardware qualification. +Mixer size is limited to 1024 pixels, dense footprints to 4,194,304 pixels, +and a stroke to 65,536 input samples and 250,000 dabs. Long input segments are +interpolated into batches of at most 2,048 pixels instead of being rejected. +The live preview alone is limited to 256 working tiles (256 x 256 pixels each). +If that preview budget is exhausted, the UI retains all stroke input and the +last valid preview, then replays the full stroke atomically on release. The +normal command is not subject to the preview tile budget. Escape, focus loss, +and document/tool changes still cancel the retained gesture. Other invalid +requests return errors without committing partial paint. A spatial load uses +64 KiB of float color data. Document snapshots share untouched tiles. These +bounds do not constitute hardware qualification. No fluid solver or grouped-bristle deformation model is introduced. Existing brush tip/dynamics support is reused. Windows pen tilt/rotation remain limited by the From 93bf47bb36d6754e656426f3b4e61d9e0ac87e85 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Tue, 20 Oct 2026 21:33:51 -0400 Subject: [PATCH 165/649] Preferences: save what loading migrated, with the new version The save merge used the loaded (already migrated) preferences as its base, so a version 1 file that loaded with Use Shift Key for Tool Switch on kept its stored `false` and `version: 1` on every later save. Turning the switch off then wrote `false` under version 1 again, and the next launch migrated it back on. The base is now what the file held, limited to the keys this version writes: whatever loading changed is written by the next save, and keys only the file has (a newer version's) are still kept. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/prefs_ui.rs | 50 ++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs index 5cd2e547d8..3a01e45380 100644 --- a/crates/ui-egui/src/prefs_ui.rs +++ b/crates/ui-egui/src/prefs_ui.rs @@ -234,9 +234,13 @@ pub fn load(app: &mut PhotocraftApp) { } app.prefs_rt.loaded = true; let mut invalid = Vec::new(); + let mut stored = None; if let Some(text) = app.services.load_prefs.as_mut().and_then(|f| f()) { match app.session.load_prefs_json(&text) { - Ok(found) => invalid = found, + Ok(found) => { + invalid = found; + stored = serde_json::from_str::(&text).ok(); + } Err(e) => { let template = "Preferences were reset: {error}"; app.ui.status = crate::i18n::fmt(tl!(template), &[("error", &e)]); @@ -251,12 +255,27 @@ pub fn load(app: &mut PhotocraftApp) { crate::view_cmds::restore(app); app.sync_recent(); app.prefs_rt.saved_rev = app.session.prefs.rev(); - app.prefs_rt.saved_value = Some(app.session.prefs_value()); + let loaded = app.session.prefs_value(); + app.prefs_rt.saved_value = Some(match stored { + Some(stored) => stored_base(&loaded, &stored), + None => loaded, + }); if !invalid.is_empty() { repair_invalid(app, &invalid); } } +/// The save base after loading `stored`: what the file holds, limited to the keys `loaded` (this +/// version's preferences) has. Whatever loading changed there (a migrated default, the file's +/// version) then differs from the base, so the next save writes it rather than keeping the old +/// value under a newer version (#5647). Keys only the file has stay out, so the merge keeps them. +fn stored_base(loaded: &Value, stored: &Value) -> Value { + match (loaded, stored) { + (Value::Object(l), Value::Object(s)) => Value::Object(s.iter().filter_map(|(k, sv)| l.get(k).map(|lv| (k.clone(), stored_base(lv, sv)))).collect()), + _ => stored.clone(), + } +} + /// Some saved values couldn't be read and took their defaults (#6611): say which, and write /// the defaults over them on the next save so the next launch reads a clean file. The save /// base holds the unreadable values, so the three-way merge sees them as changed here and @@ -3193,6 +3212,33 @@ mod tests { assert_eq!(next.session.prefs().file_handling.autosave_minutes, 5); } + #[test] + fn an_old_files_shift_tool_switch_migration_is_saved_with_the_new_version() { + // #5647: a file before version 2 loads with Use Shift Key for Tool Switch on. Saving + // writes that and the current version, so turning it off later isn't taken for the old + // default on the next launch. + let ctx = egui::Context::default(); + for saved in [ + json!({"version": 1, "tools": {"useShiftKeyForToolSwitch": false}, "futureSection": {"kept": true}}), + json!({"tools": {"useShiftKeyForToolSwitch": false}, "futureSection": {"kept": true}}), + ] { + let (mut app, store) = app_with_saved(Some(saved.to_string())); + tick(&mut app, &ctx); + assert!(app.session.prefs().tools.use_shift_key_for_tool_switch, "{saved}"); + app.run("prefs.set", json!({"values": {"performance.historyStates": 12}})).unwrap(); + tick(&mut app, &ctx); + let v = stored(&store); + assert_eq!(v["version"], json!(prefs::PREFS_VERSION), "{saved}"); + assert_eq!(v["tools"]["useShiftKeyForToolSwitch"], true, "{saved}"); + assert_eq!(v["futureSection"]["kept"], true, "keys this version doesn't know survive"); + app.run("prefs.set", json!({"values": {"tools.useShiftKeyForToolSwitch": false}})).unwrap(); + tick(&mut app, &ctx); + let (mut next, _) = app_with_saved(store.lock().unwrap().clone()); + tick(&mut next, &ctx); + assert!(!next.session.prefs().tools.use_shift_key_for_tool_switch, "{saved}: turned off, it stays off"); + } + } + #[test] fn merge_keeps_changes_made_elsewhere() { let base = json!({"a": {"x": 1, "y": 1}, "list": [1], "gone": 1, "kept": 1}); From 3568ede54e79f0b08612d0a693bdfbe289771390 Mon Sep 17 00:00:00 2001 From: 00xJ0 <56056764+00xJ0@users.noreply.github.com> Date: Tue, 20 Oct 2026 18:13:04 -0700 Subject: [PATCH 166/649] GPU compositor: build its pipelines in parallel; DX12's FXC compiles one at a time and took ~8 s on one core (#6419) --- crates/gpu/src/lib.rs | 52 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/crates/gpu/src/lib.rs b/crates/gpu/src/lib.rs index 334944daad..e2cf262ef3 100644 --- a/crates/gpu/src/lib.rs +++ b/crates/gpu/src/lib.rs @@ -642,9 +642,9 @@ impl Compositor { /// to the CPU compositor. Where errors only arrive asynchronously (WebGPU), creation is assumed /// to have worked. pub fn try_new_with_format(device: &wgpu::Device, acc_format: wgpu::TextureFormat) -> Result { - match first_error(device, || Self::new_with_format(device, acc_format)) { - (comp, None) => Ok(comp), - (_, Some(e)) => Err(Unsupported(format!("couldn't build the compositor's pipelines: {e}"))), + match first_error(device, || Self::build(device, acc_format)) { + ((comp, None), None) => Ok(comp), + ((_, Some(e)), _) | (_, Some(e)) => Err(Unsupported(format!("couldn't build the compositor's pipelines: {e}"))), } } @@ -652,6 +652,18 @@ impl Compositor { /// `Rgba16Float` on adapters that can't render to `Rgba32Float` (e.g. some Intel Vulkan drivers), /// which otherwise panics at render-pipeline creation. See `Compositor::preferred_acc_format`. pub fn new_with_format(device: &wgpu::Device, acc_format: wgpu::TextureFormat) -> Self { + let (comp, error) = Self::build(device, acc_format); + if let Some(e) = error { + log::error!("GPU compositor: couldn't build its pipelines: {e}"); + } + comp + } + + /// The compositor and the first error raised building its (non-map) pipelines. They are + /// built in parallel, each inside its own error scope on the thread that builds it (wgpu's + /// scopes are per thread): on DX12, FXC compiles one shader at a time and the ~30 pipelines + /// took about 8 s on one core (#6419). + fn build(device: &wgpu::Device, acc_format: wgpu::TextureFormat) -> (Self, Option) { let module = device.create_shader_module(wgpu::ShaderModuleDescriptor { label: Some("pc_compose"), source: wgpu::ShaderSource::Wgsl(SHADER.into()) }); let bgl0 = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { label: Some("pc_compose_uniforms"), @@ -686,19 +698,40 @@ impl Compositor { cache: None, })) }; - let mut pipelines: HashMap<_, _> = - Kernel::DRAWN.iter().filter(|k| !k.is_map()).filter_map(|&k| Some(((k, acc_format), pipeline(k, acc_format)?))).collect(); // Effect maps render to R32Float / R16Float, which some adapters (e.g. GL without float // render targets) can't: then layer effects use the CPU compositor and the rest stays here. - let maps = Kernel::DRAWN.iter().filter(|k| k.is_map()).flat_map(|&k| [(k, MAP32), (k, MAP16)]); - let (maps, map_error) = first_error(device, || maps.filter_map(|key| Some((key, pipeline(key.0, key.1)?))).collect::>()); + let keys = Kernel::DRAWN.iter().filter(|k| !k.is_map()).map(|&k| (k, acc_format)); + let keys: Vec<_> = keys.chain(Kernel::DRAWN.iter().filter(|k| k.is_map()).flat_map(|&k| [(k, MAP32), (k, MAP16)])).collect(); + let built = fx::par_map(keys, |key| { + let (built, error) = first_error(device, || pipeline(key.0, key.1)); + (key, built, error) + }); + let (mut pipelines, mut maps) = (HashMap::new(), Vec::new()); + let (mut error, mut map_error) = (None, None); + for (key, built, e) in built { + let map = key.0.is_map(); + if let Some(e) = e { + if map { + map_error.get_or_insert(e) + } else { + error.get_or_insert(e) + }; + continue; + } + let Some(p) = built else { continue }; + if map { + maps.push((key, p)); + } else { + pipelines.insert(key, p); + } + } if let Some(e) = &map_error { log::info!("GPU compositor: no effect-map pipelines ({e}); layer effects use the CPU"); } else { pipelines.extend(maps); } let dummy = Tex::new(device, "pc_compose_dummy", 1, 1, wgpu::TextureFormat::Rgba8Unorm, wgpu::TextureUsages::TEXTURE_BINDING).view; - Self { + let comp = Self { kit: Kit { pipelines, bgl0, bgl1, dummy }, pool: Vec::new(), residents: HashMap::new(), @@ -726,7 +759,8 @@ impl Compositor { health: None, timer: None, } - .with_texture_limit(device.limits().max_texture_dimension_2d) + .with_texture_limit(device.limits().max_texture_dimension_2d); + (comp, error) } fn with_texture_limit(mut self, max: u32) -> Self { From d383afe428fa41d4ee34ed88e953eefdc4969b0e Mon Sep 17 00:00:00 2001 From: 00xJ0 <56056764+00xJ0@users.noreply.github.com> Date: Tue, 20 Oct 2026 18:40:26 -0700 Subject: [PATCH 167/649] Test: a compositor pipeline that fails on a worker thread is an error, not a panic (#6419) --- crates/gpu/tests/pipeline_errors.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 crates/gpu/tests/pipeline_errors.rs diff --git a/crates/gpu/tests/pipeline_errors.rs b/crates/gpu/tests/pipeline_errors.rs new file mode 100644 index 0000000000..2ecbb8db74 --- /dev/null +++ b/crates/gpu/tests/pipeline_errors.rs @@ -0,0 +1,22 @@ +//! #6419: the compositor's pipelines are built on several threads. A pipeline the device can't +//! build is still an `Err` from `try_new_with_format`, not a panic from wgpu's default error +//! handler (error scopes are per thread). Skips when no GPU adapter exists. + +use photocraft_gpu::Compositor; + +#[test] +fn a_pipeline_built_on_another_thread_fails_as_an_error() { + let instance = wgpu::Instance::default(); + let Ok(adapter) = pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions::default())) else { + eprintln!("skipping: no adapter"); + return; + }; + let Ok((device, _queue)) = pollster::block_on(adapter.request_device(&wgpu::DeviceDescriptor::default())) else { return }; + // Never a render target, so every accumulation pipeline fails validation. + let Err(e) = Compositor::try_new_with_format(&device, wgpu::TextureFormat::Rgb9e5Ufloat) else { + panic!("a compositor accumulating into Rgb9e5Ufloat"); + }; + assert!(e.0.contains("couldn't build the compositor's pipelines"), "{e:?}"); + // The device is still usable for a compositor it can build. + assert!(Compositor::try_new_with_format(&device, Compositor::preferred_acc_format(&adapter)).is_ok()); +} From a77d513d74576ce8bfedb50f34d64300d5620bb9 Mon Sep 17 00:00:00 2001 From: durtyrobbin <76844303+durtyrobbin@users.noreply.github.com> Date: Tue, 20 Oct 2026 21:58:20 -0400 Subject: [PATCH 168/649] Preserve Mixer load on empty samples and retain Alt-right brush resizing --- crates/engine/src/brush_cmds/mixer_live.rs | 9 +++++---- .../engine/src/brush_cmds/mixer_live_tests.rs | 14 +++++++++++++ crates/ui-egui/src/brush_resize.rs | 20 +++++++++++++++++++ crates/ui-egui/src/canvas.rs | 2 +- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/brush_cmds/mixer_live.rs b/crates/engine/src/brush_cmds/mixer_live.rs index a8e19363cb..23cc0978d0 100644 --- a/crates/engine/src/brush_cmds/mixer_live.rs +++ b/crates/engine/src/brush_cmds/mixer_live.rs @@ -396,10 +396,11 @@ pub(super) fn sample(s: &mut Session, p: &Value) -> Result { } average[3] += c[3]; } - if average[3] > 0.0 { - for k in 0..3 { - average[k] /= average[3]; - } + if average[3] <= 0.0 { + return Err(bad("brush.mixer.sample", "the sampled area contains no paint; the previous brush load is unchanged")); + } + for k in 0..3 { + average[k] /= average[3]; } average[3] = 1.0; s.tools.mixer.load(average); diff --git a/crates/engine/src/brush_cmds/mixer_live_tests.rs b/crates/engine/src/brush_cmds/mixer_live_tests.rs index ec7f1a95d8..fad24b54bc 100644 --- a/crates/engine/src/brush_cmds/mixer_live_tests.rs +++ b/crates/engine/src/brush_cmds/mixer_live_tests.rs @@ -299,3 +299,17 @@ fn mixer_command_outgrows_the_preview_tile_budget_without_losing_the_stroke() { s.execute("edit.undo", json!({})).unwrap(); assert!(target(&s).read_region(end).chunks_exact(4).all(|px| px[3] == 0.0)); } + +#[test] +fn mixer_empty_samples_preserve_the_previous_load_and_document() { + let mut s = fixture(PixelFormat::RGBA8); + s.execute("brush.mixer.sample", json!({"points": [[96,48]], "size": 40})).unwrap(); + let state = s.tools.mixer.clone(); + let doc = s.active().unwrap().doc.clone(); + for params in [json!({"points": [[20,20]], "size": 8, "sampleAllLayers": false}), json!({"points": [[-100,-100]], "size": 8, "sampleAllLayers": true})] { + let error = s.execute("brush.mixer.sample", params).unwrap_err().to_string(); + assert!(error.contains("contains no paint"), "{error}"); + assert_eq!(s.tools.mixer, state); + assert!(Arc::ptr_eq(&s.active().unwrap().doc, &doc)); + } +} diff --git a/crates/ui-egui/src/brush_resize.rs b/crates/ui-egui/src/brush_resize.rs index 7d41aaa1ba..fe02230f42 100644 --- a/crates/ui-egui/src/brush_resize.rs +++ b/crates/ui-egui/src/brush_resize.rs @@ -384,6 +384,26 @@ mod tests { } } + #[test] + fn mixer_alt_right_drag_resizes_without_sampling_or_painting() { + let mut a = app(Tool::MixerBrush); + let before = a.session.tools.mixer.clone(); + a.sync_views(); + let mut h = canvas(a); + let (undo0, size0) = (history(h.state()), h.state().session.tools.brush.size); + let end = alt_right_drag(&mut h, vec2(10.0, 8.0)); + assert!(h.state().brush_resize.is_some_and(|resize| resize.secondary)); + assert!(h.state().session.tools.brush.size > size0); + button(&mut h, end, PointerButton::Secondary, false, Modifiers::ALT); + h.event(egui::Event::ModifiersChanged(Modifiers::NONE)); + h.run_steps(2); + let a = h.state(); + assert!(a.brush_resize.is_none() && !a.brush_resize_armed); + assert_eq!(a.session.tools.mixer, before); + assert_eq!(history(a), undo0); + assert!(!a.session.journal.iter().any(|(id, _)| id == "brush.mixer.sample" || id == "paint.mixerBrush")); + } + #[test] fn plain_right_click_still_opens_the_picker() { let mut a = app(Tool::Brush); diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 16f75cbd72..2c567b94c0 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -5365,7 +5365,7 @@ pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers) return; } // View › Snap / Snap To and smart guides (snap_ui.rs). - if app.ui.tool == Tool::MixerBrush && mods.alt && !mods.ctrl && app.drag.is_none() { + if app.ui.tool == Tool::MixerBrush && mods.alt && !mods.ctrl && app.drag.is_none() && !armed && app.brush_resize.is_none() { if let ToolEvent::Down { x, y, pressure } = ev { let pen = app.stylus.sample().unwrap_or_default(); let p = json!({"points":[[x,y,pressure,pen.tilt_x,pen.tilt_y,pen.rotation]],"target":paint_target(app)}); From b4c5f4da0eefec7ced90dbea6730f562cc9a18d3 Mon Sep 17 00:00:00 2001 From: durtyrobbin <76844303+durtyrobbin@users.noreply.github.com> Date: Tue, 20 Oct 2026 23:08:08 -0400 Subject: [PATCH 169/649] Print: keep dry runs out of live printer discovery --- crates/engine/src/print_cmds.rs | 25 ++++++++++++++++++++----- crates/engine/src/print_cmds/tests.rs | 11 +++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/print_cmds.rs b/crates/engine/src/print_cmds.rs index 9b264f0611..5627b65945 100644 --- a/crates/engine/src/print_cmds.rs +++ b/crates/engine/src/print_cmds.rs @@ -191,6 +191,7 @@ fn cups_spool(job: &PrintJob) -> std::result::Result { /// `craft-print` (`lpstat`, the Windows spooler) where that is the route; over IPP for a named /// server and where there is no `lp` (a sandbox). fn system_printers(_s: &mut Session, p: &Value) -> Result { + require_live_printer_query(p)?; let named = p.get("printServer").and_then(Value::as_str).filter(|v| !v.is_empty()); if named.is_none() && system_spooler().is_some() { let list = craft_print::printers(); @@ -854,7 +855,18 @@ fn print_windows(page: &PrintPage, p: &Value, title: &str, copies: u32) -> Resul ) } -fn printers(_: &mut Session, _: &Value) -> Result { +// Driver discovery/settings are external I/O, even when no page is spooled. A dry run must +// not block on a disconnected printer or a print server (including in the command panic hunt). +fn require_live_printer_query(p: &Value) -> Result<()> { + if p.get("dryRun").and_then(Value::as_bool).unwrap_or(false) { + Err(other("printer queries are unavailable in a dry run; omit dryRun to query the live printer backend")) + } else { + Ok(()) + } +} + +fn printers(_: &mut Session, p: &Value) -> Result { + require_live_printer_query(p)?; match craft_print::rgb::printers() { Ok(list) => Ok(json!({"supported": true, "printers": list.iter().map(|p| json!({"name": p.name, "default": p.default})).collect::>()})), Err(craft_print::rgb::PrintError::Unsupported) => Ok(json!({"supported": false, "printers": []})), @@ -863,6 +875,7 @@ fn printers(_: &mut Session, _: &Value) -> Result { } fn printer_page(_: &mut Session, p: &Value) -> Result { + require_live_printer_query(p)?; // Checked before the printer, so a bad value is the error whether or not a printer answers. let landscape = match p.get("orientation").filter(|v| !v.is_null()) { None => None, @@ -920,7 +933,9 @@ fn print_one_copy(s: &mut Session, p: &Value) -> Result { let mut q = last_print(s).unwrap_or_else(|| json!({})); // A printer remembered from an earlier session may be gone: then the default takes the job, // as the Print dialog falls back (#7410). A list that can't be read decides nothing. - if let Ok(listed) = system_printers(s, &q) { + if !p.get("dryRun").and_then(Value::as_bool).unwrap_or(false) + && let Ok(listed) = system_printers(s, &q) + { let names: Vec<&str> = listed["printers"].as_array().into_iter().flatten().filter_map(|p| p["name"].as_str()).collect(); drop_vanished_printer(&mut q, &names); } @@ -1107,7 +1122,7 @@ pub fn specs() -> Vec { label: "Printers", menu: &[], shortcut: None, - params: r##"{} → {supported, printers: [{name, default}]} (supported: Windows; elsewhere Print spools with lp)"##, + params: r##"{"dryRun":bool=false} → {supported, printers: [{name, default}]} (supported: Windows; elsewhere Print spools with lp; dryRun refuses live device queries)"##, enabled: |_| Ok(()), journal: false, run: printers, @@ -1117,7 +1132,7 @@ pub fn specs() -> Vec { label: "Printer Page", menu: &[], shortcut: None, - params: r##"{"printer":name? (default printer),"printerSettings":hex?,"orientation":"portrait|landscape"? (turn the settings, or the printer's own, that way)} → {printer, paper: [w,h] pt, printable: [x,y,w,h] pt from the top-left, dpi: [x,y], printerSettings: hex (only with orientation: the turned settings)} (Windows)"##, + params: r##"{"printer":name? (default printer),"printerSettings":hex?,"orientation":"portrait|landscape"? (turn the settings, or the printer's own, that way),"dryRun":bool=false (refuse live device queries)} → {printer, paper: [w,h] pt, printable: [x,y,w,h] pt from the top-left, dpi: [x,y], printerSettings: hex (only with orientation: the turned settings)} (Windows)"##, enabled: |_| Ok(()), journal: false, run: printer_page, @@ -1127,7 +1142,7 @@ pub fn specs() -> Vec { label: "Printers", menu: &[], shortcut: None, - params: r##"{} → {printers:[{name, default}], default:name|null} (the system spooler's printers; a name is Print's "printer")"##, + params: r##"{"printServer":str?,"dryRun":bool=false} → {printers:[{name, default}], default:name|null} (the system spooler's printers; a name is Print's "printer"; dryRun refuses live device queries)"##, enabled: crate::commands::always, journal: false, run: system_printers, diff --git a/crates/engine/src/print_cmds/tests.rs b/crates/engine/src/print_cmds/tests.rs index 38567ffb6d..38bd2d1286 100644 --- a/crates/engine/src/print_cmds/tests.rs +++ b/crates/engine/src/print_cmds/tests.rs @@ -869,3 +869,14 @@ fn windows_pdf_component_is_detected_by_loading_its_dll() { fn the_windows_pdf_check_is_a_no_op_elsewhere() { assert!(require_windows_pdf().is_ok()); } + +#[test] +fn printer_queries_refuse_dry_runs_before_contacting_a_backend() { + let mut s = Session::new(); + for command in ["file.printers", "file.print.printers", "file.print.page"] { + for params in [json!({"dryRun": true}), json!({"dryRun": true, "printServer": "127.0.0.1:1", "printer": "Synthetic unavailable printer"})] { + let error = s.execute(command, params).unwrap_err().to_string(); + assert!(error.contains("printer queries are unavailable in a dry run"), "{command}: {error}"); + } + } +} From 9457861bd236b1a985c676caae7abb0d7d00a20f Mon Sep 17 00:00:00 2001 From: durtyrobbin <76844303+durtyrobbin@users.noreply.github.com> Date: Tue, 20 Oct 2026 23:40:41 -0400 Subject: [PATCH 170/649] Mixer Brush: cancel scripted releases after tool changes --- crates/ui-egui/src/canvas.rs | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 2c567b94c0..3903fdf8f2 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -6032,6 +6032,12 @@ fn snap_aliased_tip(app: &PhotocraftApp, tool: Tool, x: f64, y: f64) -> (f64, f6 } pub(crate) fn finish_gesture(app: &mut PhotocraftApp, d: Drag) { + // Control can select a different tool and release before the next frame cancels the drag. + // Cancel before even recording a Shift-stroke anchor, including the preview fallback paths. + if d.tool == Tool::MixerBrush && app.ui.tool != Tool::MixerBrush { + app.live_stroke = None; + return; + } let mut end = d.points.last().copied().unwrap_or([d.start[0], d.start[1], 1.0]); let (sx, sy) = snap_aliased_tip(app, d.tool, end[0], end[1]); end[0] = sx; @@ -7961,6 +7967,40 @@ mod tests { } } + #[test] + fn mixer_control_tool_switch_before_release_cancels_every_preview_path() { + for preview in 0..3 { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width":120,"height":60,"background":"#00ff00"})).unwrap(); + app.run("layer.new.layer", json!({})).unwrap(); + app.run("tools.setBrush", json!({"size":12,"pressureSize":false})).unwrap(); + let before = app.session.active().unwrap().doc.clone(); + let steps = app.session.active().unwrap().history.past_len(); + let anchor = app.last_stroke_end; + let ctx = egui::Context::default(); + let (request, _reply) = crate::control::ControlRequest::new( + "ui.pointer", + json!({"tool":"mixerBrush","events":[{"kind":"down","x":20,"y":30},{"kind":"move","x":50,"y":30}]}), + ); + let _ = crate::control::handle(&mut app, &ctx, &request); + assert!(app.drag.is_some() && app.live_stroke.is_some()); + if preview == 1 { + app.live_stroke.as_mut().unwrap().preview_failed = true; + } else if preview == 2 { + app.live_stroke = None; + } + // No intervening UI frame: control selects the new tool before dispatching Up. + let (request, _reply) = crate::control::ControlRequest::new("ui.pointer", json!({"tool":"brush","events":[{"kind":"up","x":95,"y":30}]})); + let _ = crate::control::handle(&mut app, &ctx, &request); + assert_eq!(app.ui.tool, Tool::Brush); + assert!(app.drag.is_none() && app.live_stroke.is_none()); + assert!(std::sync::Arc::ptr_eq(&before, &app.session.active().unwrap().doc)); + assert_eq!(app.session.active().unwrap().history.past_len(), steps); + assert_eq!(app.last_stroke_end, anchor); + assert!(!app.session.journal.iter().any(|(id, _)| id == "paint.mixerBrush")); + } + } + #[test] fn mixer_escape_focus_loss_and_tool_switch_cancel_without_an_edit() { for mode in 0..6 { From 1ff31fc544c3168e4b07ac7056514ea811f4aa9d Mon Sep 17 00:00:00 2001 From: durtyrobbin <76844303+durtyrobbin@users.noreply.github.com> Date: Tue, 20 Oct 2026 23:50:19 -0400 Subject: [PATCH 171/649] docs: clarify live mixer contracts and qualification fixtures --- crates/engine/examples/mixer_probe.rs | 2 ++ crates/engine/examples/painting_baseline.rs | 3 +++ crates/engine/examples/painting_live.rs | 3 +++ crates/engine/src/brush_cmds/mixer_live.rs | 11 +++++++++++ crates/engine/src/brush_cmds/mixer_live_tests.rs | 3 +++ crates/engine/src/jobs_tests.rs | 1 + crates/engine/src/print_cmds.rs | 5 +++-- crates/paint/src/mixer_reference_tests.rs | 1 + crates/ui-egui/src/canvas.rs | 1 + 9 files changed, 28 insertions(+), 2 deletions(-) diff --git a/crates/engine/examples/mixer_probe.rs b/crates/engine/examples/mixer_probe.rs index d39b297661..29b1dabb85 100644 --- a/crates/engine/examples/mixer_probe.rs +++ b/crates/engine/examples/mixer_probe.rs @@ -9,6 +9,8 @@ use photocraft_raster::Surface; use serde_json::json; use std::time::Instant; +/// Measure live updates and prepared commits on a synthetic 24 MP document against a frozen-source reference. +/// These CPU timings do not measure hardware input or display latency. fn main() -> Result<(), Box> { let mut results = Vec::new(); for size in [16.0, 64.0, 256.0] { diff --git a/crates/engine/examples/painting_baseline.rs b/crates/engine/examples/painting_baseline.rs index a31c5375e1..7884eb8a15 100644 --- a/crates/engine/examples/painting_baseline.rs +++ b/crates/engine/examples/painting_baseline.rs @@ -6,10 +6,12 @@ use photocraft_paint::{BrushSettings, Stroke, StrokePoint}; use serde_json::json; use std::time::Instant; +/// Express monotonic elapsed time in the milliseconds used by the benchmark report. fn ms(start: Instant) -> f64 { start.elapsed().as_secs_f64() * 1000.0 } +/// Report nearest-rank percentiles and the sample count; an empty measurement set yields JSON null. fn stats(mut times: Vec) -> serde_json::Value { if times.is_empty() { return serde_json::Value::Null; @@ -22,6 +24,7 @@ fn stats(mut times: Vec) -> serde_json::Value { "p99_ms":times.get((len as f64 * 0.99).ceil() as usize - 1),"max_ms":times.last(),"samples":len}) } +/// Run one validated size, speed and paint-mode case, excluding fixture construction from the timing report. fn main() -> Result<(), Box> { let args: Vec<_> = std::env::args().collect(); let dim: i32 = args.get(1).ok_or("missing dimension")?.parse()?; diff --git a/crates/engine/examples/painting_live.rs b/crates/engine/examples/painting_live.rs index 2e94d0ac4f..79f3dc4cc3 100644 --- a/crates/engine/examples/painting_live.rs +++ b/crates/engine/examples/painting_live.rs @@ -9,10 +9,12 @@ use photocraft_paint::{BrushSettings, Stroke, StrokePoint}; use serde_json::json; use std::time::Instant; +/// Express monotonic elapsed time in the milliseconds used by the benchmark report. fn ms(start: Instant) -> f64 { start.elapsed().as_secs_f64() * 1000.0 } +/// Report nearest-rank percentiles and the sample count; an empty measurement set yields JSON null. fn stats(mut times: Vec) -> serde_json::Value { if times.is_empty() { return serde_json::Value::Null; @@ -25,6 +27,7 @@ fn stats(mut times: Vec) -> serde_json::Value { "p99_ms":times.get((len as f64 * 0.99).ceil() as usize - 1),"max_ms":times.last(),"samples":len}) } +/// Measure incremental updates and the final prepared commit separately on a deterministic stroke fixture. fn main() -> Result<(), Box> { let args: Vec<_> = std::env::args().collect(); let dim: i32 = args.get(1).ok_or("missing dimension")?.parse()?; diff --git a/crates/engine/src/brush_cmds/mixer_live.rs b/crates/engine/src/brush_cmds/mixer_live.rs index 23cc0978d0..8c8e1d642d 100644 --- a/crates/engine/src/brush_cmds/mixer_live.rs +++ b/crates/engine/src/brush_cmds/mixer_live.rs @@ -14,10 +14,12 @@ const CMD: &str = "paint.mixerBrush"; const MAX_TILES: usize = 256; const TILE: i32 = 256; +/// Accept bounded finite channels, including HDR values, without admitting unsafe arithmetic inputs. fn valid_color(color: &[f32; 4]) -> bool { color.iter().all(|v| v.is_finite() && v.abs() <= 1_000_000.0) } +/// Validate finite paint-load values and the exact 64 by 64 shape of a spatial reservoir. fn valid_state(state: &MixerState) -> bool { state.amount.is_finite() && state.reservoir.as_ref().is_none_or(valid_color) @@ -48,6 +50,8 @@ struct Core { } impl Core { + /// Apply a batch against evolving working pixels and return its damage bounds. + /// The dab and footprint limits always apply; the tile limit applies only to live previews. fn apply(&mut self, dabs: &[Dab]) -> Result { if self.count.saturating_add(dabs.len()) > 250_000 { return Err(bad(CMD, "stroke exceeds 250000 dabs; start another stroke")); @@ -130,10 +134,12 @@ pub struct LiveMixer { } impl LiveMixer { + /// Capture the current document and paint load, then render the initial samples with live-preview limits. pub fn begin(s: &Session, p: &Value) -> Result { Self::begin_with_limits(s, p, true) } + /// Share initialization between live previews and command replay while keeping their tile budgets distinct. fn begin_with_limits(s: &Session, p: &Value, preview_limits: bool) -> Result { has_paintable(s).map_err(EngineError::Other)?; if p.get("points").and_then(Value::as_array).is_some_and(|v| v.len() > 65_536) { @@ -216,9 +222,11 @@ impl LiveMixer { Ok(live) } + /// Return all damaged pixels, including the provisional smoothing tail currently shown by the preview. pub fn bounds(&self) -> Rect { self.core.bounds.union(&self.tail) } + /// Whether the dab generator needs stationary time samples, as for a continuing airbrush stroke. pub fn wants_time(&self) -> bool { self.core.generator.wants_time() } @@ -273,6 +281,7 @@ impl LiveMixer { }) } + /// Serialize recorded points, the original paint load, resolved brush and seed for deterministic replay. fn commit_params(&self) -> Result { let mut params = self.core.params.clone(); params["points"] = serde_json::to_value(&self.points).map_err(|e| bad(CMD, e.to_string()))?; @@ -299,6 +308,8 @@ impl LiveMixer { } } +/// Consume a matching prepared result or replay without the preview tile cap, then commit one history step. +/// The completed stroke also applies the automatic clean/load settings to the stored paint load. pub(super) fn run(s: &mut Session, p: &Value) -> Result { let cached = s.prepared_mixer.take().filter(|live| { s.active().is_some_and(|st| Arc::ptr_eq(&st.doc, &live.original) && (live.core.layer.is_none() || st.active_layer == live.core.layer)) diff --git a/crates/engine/src/brush_cmds/mixer_live_tests.rs b/crates/engine/src/brush_cmds/mixer_live_tests.rs index fad24b54bc..b86d1ef10b 100644 --- a/crates/engine/src/brush_cmds/mixer_live_tests.rs +++ b/crates/engine/src/brush_cmds/mixer_live_tests.rs @@ -3,6 +3,7 @@ use super::*; use photocraft_color::PixelFormat; use std::sync::Arc; +/// Build format-specific red/green sampling layers and an empty painting target. fn fixture(fmt: PixelFormat) -> Session { let mut s = Session::new(); s.execute("file.new", json!({"width":192,"height":96,"background":"#808080"})).unwrap(); @@ -24,6 +25,7 @@ fn fixture(fmt: PixelFormat) -> Session { s } +/// Snapshot the active raster target for exact pixel comparisons without borrowing the session. fn target(s: &Session) -> Surface { let st = s.active().unwrap(); st.doc.layer(st.active_layer.unwrap()).unwrap().surface().unwrap().clone() @@ -242,6 +244,7 @@ fn mixer_large_tip_retains_off_canvas_paint_and_commits_the_live_result() { assert_eq!(*s.active().unwrap().doc, *source); } +/// Large pointer jumps must replay identically instead of turning a valid stroke into an input-limit error. #[test] fn mixer_long_segments_are_interpolated_and_replay_matches_live() { let mut s = fixture(PixelFormat::RGBA8); diff --git a/crates/engine/src/jobs_tests.rs b/crates/engine/src/jobs_tests.rs index 93f2faf841..8876445a6d 100644 --- a/crates/engine/src/jobs_tests.rs +++ b/crates/engine/src/jobs_tests.rs @@ -606,6 +606,7 @@ fn an_inline_job_ctx_lets_another_thread_cancel_inline_work() { s.execute("filter.blur.gaussianBlur", json!({"radius": 2})).unwrap(); } +/// Exercise six terminal job routes so prepared paint snapshots cannot outlive a completed or discarded job. #[test] fn every_job_terminal_path_drops_a_prepared_mixer_stroke() { use crate::brush_cmds::mixer_live::LiveMixer; diff --git a/crates/engine/src/print_cmds.rs b/crates/engine/src/print_cmds.rs index 5627b65945..5ea99d0014 100644 --- a/crates/engine/src/print_cmds.rs +++ b/crates/engine/src/print_cmds.rs @@ -855,8 +855,8 @@ fn print_windows(page: &PrintPage, p: &Value, title: &str, copies: u32) -> Resul ) } -// Driver discovery/settings are external I/O, even when no page is spooled. A dry run must -// not block on a disconnected printer or a print server (including in the command panic hunt). +/// Driver discovery/settings are external I/O, even when no page is spooled. A dry run must +/// not block on a disconnected printer or a print server (including in the command panic hunt). fn require_live_printer_query(p: &Value) -> Result<()> { if p.get("dryRun").and_then(Value::as_bool).unwrap_or(false) { Err(other("printer queries are unavailable in a dry run; omit dryRun to query the live printer backend")) @@ -865,6 +865,7 @@ fn require_live_printer_query(p: &Value) -> Result<()> { } } +/// List native RGB-print destinations only for a live query; dry runs must not contact printer drivers. fn printers(_: &mut Session, p: &Value) -> Result { require_live_printer_query(p)?; match craft_print::rgb::printers() { diff --git a/crates/paint/src/mixer_reference_tests.rs b/crates/paint/src/mixer_reference_tests.rs index cdd86e2a48..d15eba28d7 100644 --- a/crates/paint/src/mixer_reference_tests.rs +++ b/crates/paint/src/mixer_reference_tests.rs @@ -1,5 +1,6 @@ // Frozen pre-optimization dab kernel. Keep independent of the optimized implementation. use super::*; +/// Keep the allocation-heavy scalar kernel independent so optimizations cannot silently change pickup or blending. fn reference( work: &mut crate::retouch::Region, fp: &crate::retouch::Footprint, diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 3903fdf8f2..69c11f7c74 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -7967,6 +7967,7 @@ mod tests { } } + /// Reproduce a tool change and release in one control call, before a UI frame can cancel the old gesture. #[test] fn mixer_control_tool_switch_before_release_cancels_every_preview_path() { for preview in 0..3 { From 6b99ac877c735bb49e3a54f20ed6e593d5f96e65 Mon Sep 17 00:00:00 2001 From: VishnuByrraju Date: Wed, 21 Oct 2026 11:04:23 +0530 Subject: [PATCH 172/649] fix(automation): doc.replaceSmartObject replaces Smart Object contents from the read root (#8061) layer.smartObjects.replaceContents takes an ambient path and is refused in serve/mcp. Add the capability-scoped sibling of doc.place: the file is read beneath --automation-read-root and handed to the command's own core, as an RPC method (doc.replaceSmartObject) and an MCP tool (doc_replace_smart_object). --- crates/automation/src/headless.rs | 24 +++++++++++++ crates/automation/src/rpc.rs | 60 +++++++++++++++++++++++++++++++ crates/automation/src/server.rs | 34 ++++++++++++++++++ crates/automation/tests/mcp.rs | 31 ++++++++++++++++ crates/engine/src/smart_cmds.rs | 7 ++++ docs/architecture.md | 2 +- docs/control-protocol.md | 2 ++ docs/development.md | 2 +- 8 files changed, 160 insertions(+), 2 deletions(-) diff --git a/crates/automation/src/headless.rs b/crates/automation/src/headless.rs index d6b3c17102..b9d36a5993 100644 --- a/crates/automation/src/headless.rs +++ b/crates/automation/src/headless.rs @@ -136,6 +136,30 @@ impl Headless { Ok(file_cmds::place_bytes(&mut self.session, name, bytes, None, &Value::Object(opts))?) } + /// Replace a smart object's contents with a file from the read root: the capability-scoped + /// `layer.smartObjects.replaceContents`, which takes an ambient `path` and is refused in + /// automation (#8061). `params` is the command's own (`layer`). + pub fn replace_smart_object(&mut self, index: Option, path: &str, params: &Value) -> Result { + let i = self.doc_index(index)?; + if self.session.active_index() != Some(i) && !self.session.set_active(i) { + return Err(AutomationError::BadRequest(format!("no document at index {i}"))); + } + let mut opts = params.as_object().cloned().unwrap_or_default(); + opts.insert("path".into(), json!(path)); + if matches!(&self.filesystem, Filesystem::TrustedLocal) { + return self.command_run("layer.smartObjects.replaceContents", Value::Object(opts)); + } + let bytes = match &self.filesystem { + Filesystem::Workspace(workspace) => workspace.read(path)?, + _ => { + return Err(AutomationError::BadRequest("automation filesystem access is not granted: read authority is absent".into())); + } + }; + let name = Path::new(path).file_name().and_then(|name| name.to_str()).unwrap_or(path); + self.sync_jobs(); + Ok(photocraft_engine::smart_cmds::replace_contents_from_bytes(&mut self.session, &Value::Object(opts), name, bytes)?) + } + /// Export each exported layer of a document as its own file beneath the write root: the /// capability-scoped `file.export.layersToFiles`, which takes an ambient `dir` and is /// therefore refused in automation (#3216). The bytes come from the command's own core, so diff --git a/crates/automation/src/rpc.rs b/crates/automation/src/rpc.rs index 3db25c4fdd..b52ecc078a 100644 --- a/crates/automation/src/rpc.rs +++ b/crates/automation/src/rpc.rs @@ -10,6 +10,8 @@ //! - `session.list`, `doc.open {path}`, `doc.new {…file.new params}`, //! `doc.place {path, scale?, fit?, center?, index?}` (#2810: the read root is the scope, //! the counterpart of the refused ambient `file.placeEmbedded`), +//! `doc.replaceSmartObject {path, layer?, index?}` (#8061: the same scope for +//! `layer.smartObjects.replaceContents`), //! `doc.exportLayers {dir, format?, prefix?, visibleOnly?, quality?, index?}`, //! `doc.exportDataSets {dir, format?, dataSets?, naming?, index?}`, //! `doc.importDataSets {path, delimiter?, index?}` (#3216: the same treatment for the export @@ -43,6 +45,7 @@ pub const METHODS: &[&str] = &[ "session.list", "doc.open", "doc.place", + "doc.replaceSmartObject", "doc.new", "doc.save", "doc.exportLayers", @@ -108,6 +111,13 @@ impl Headless { opts.remove("index"); self.place(index_of(&p)?, path, &Value::Object(opts)) } + "doc.replaceSmartObject" => { + let path = str_of(&p, "path").ok_or_else(|| bad("doc.replaceSmartObject needs `path`"))?; + let mut opts = p.as_object().cloned().unwrap_or_default(); + opts.remove("path"); + opts.remove("index"); + self.replace_smart_object(index_of(&p)?, path, &Value::Object(opts)) + } "doc.new" => self.command_run("file.new", p), "doc.save" => { let tga_bits = photocraft_engine::file_cmds::tga_bits_param(&p, "doc.save").map_err(|e| bad(e.to_string()))?; @@ -682,6 +692,56 @@ mod tests { std::fs::remove_dir_all(base).unwrap(); } + #[test] + fn doc_replace_smart_object_reads_through_the_read_root_and_never_outside_it() { + let base = std::env::temp_dir().join(format!("pc-doc-replace-so-{}", std::process::id())); + let root = base.join("workspace"); + let outside = base.join("outside"); + for dir in [&root, &outside] { + std::fs::create_dir_all(dir).unwrap(); + } + let png = |w: u32, h: u32, v: u8| { + let img = photocraft_codecs::Image::from_u8(w, h, photocraft_codecs::ChannelLayout::Rgb, vec![v; (w * h * 3) as usize]).unwrap(); + photocraft_codecs::encode(&img, photocraft_codecs::Format::Png, &Default::default()).unwrap() + }; + std::fs::write(root.join("logo.png"), png(8, 6, 42)).unwrap(); + std::fs::write(root.join("red.png"), png(8, 6, 200)).unwrap(); + std::fs::write(outside.join("red.png"), png(8, 6, 200)).unwrap(); + let absolute = outside.join("red.png").to_string_lossy().into_owned(); + + let mut h = Headless::with_workspace(crate::AuthorizedWorkspace::new(Some(&root), Some(&root)).unwrap()); + h.handle("doc.new", json!({"width": 40, "height": 30})).unwrap(); + let layer = h.handle("doc.place", json!({"path": "logo.png"})).unwrap()["layer"].clone(); + let replaced = h.handle("doc.replaceSmartObject", json!({"path": "red.png", "layer": layer})).unwrap(); + assert_eq!(replaced["layer"], layer, "{replaced}"); + let undo = h.handle("engine.execute", json!({"command": "edit.undo"})); + assert!(undo.is_ok(), "the replacement is one history step: {undo:?}"); + // Outside the read root, a bad layer, a missing path or a file that is no image: refused, nothing changed. + for (params, reason) in [ + (json!({"path": "../outside/red.png"}), "parent traversal"), + (json!({"path": absolute}), "must be inside the automation root"), + (json!({"path": "red.png", "layer": 999_999}), ""), + (json!({}), "needs `path`"), + ] { + let refused = h.handle("doc.replaceSmartObject", params).unwrap_err().to_string(); + assert!(refused.contains(reason), "{refused}"); + } + std::fs::write(root.join("junk.png"), b"not an image").unwrap(); + assert!(h.handle("doc.replaceSmartObject", json!({"path": "junk.png", "layer": layer})).is_err()); + // The ambient command keeps its refusal. + let ambient = h.handle("engine.execute", json!({"command": "layer.smartObjects.replaceContents", "params": {"path": "red.png"}})); + assert!(ambient.unwrap_err().to_string().contains("ambient filesystem paths")); + // Trusted local keeps the ambient command. + let mut t = Headless::trusted_local(); + t.handle("doc.new", json!({"width": 40, "height": 30})).unwrap(); + let tl = t.handle("doc.place", json!({"path": root.join("logo.png").to_string_lossy()})).unwrap()["layer"].clone(); + let trusted = t.handle("doc.replaceSmartObject", json!({"path": root.join("red.png").to_string_lossy(), "layer": tl})).unwrap(); + assert_eq!(trusted["layer"], tl, "{trusted}"); + drop(t); + drop(h); + std::fs::remove_dir_all(base).unwrap(); + } + #[test] fn doc_export_layers_writes_only_beneath_the_write_root() { let base = std::env::temp_dir().join(format!("pc-doc-export-layers-{}", std::process::id())); diff --git a/crates/automation/src/server.rs b/crates/automation/src/server.rs index 567d0b4837..52ba82332e 100644 --- a/crates/automation/src/server.rs +++ b/crates/automation/src/server.rs @@ -71,6 +71,19 @@ pub struct PlaceParams { pub center: Option<[f64; 2]>, } +#[derive(Debug, Default, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +pub struct ReplaceSmartObjectParams { + /// Path beneath the configured automation read root: relative (forward slashes) or absolute. + pub path: String, + /// Document index from `session_list` (default: the active document). + #[serde(default)] + pub index: Option, + /// The Smart Object layer: an id or a name (default: the active layer). + #[serde(default)] + pub layer: Option, +} + #[derive(Debug, Default, Deserialize, JsonSchema)] #[serde(deny_unknown_fields)] pub struct ExportLayersParams { @@ -636,6 +649,27 @@ impl PhotocraftMcp { self.run_command("file.placeEmbedded".into(), bridge_params, true).await } + #[tool( + description = "Replace a Smart Object's contents with the file at `path` beneath the read root, keeping its transform and filters (the capability-scoped Replace Contents). `layer` is the Smart Object's id or name (default: the active layer)." + )] + async fn doc_replace_smart_object(&self, Parameters(p): Parameters) -> Result { + let mut opts = serde_json::Map::new(); + if let Some(v) = p.layer { + opts.insert("layer".into(), v); + } + let opts = Value::Object(opts); + // Bridge mode runs the app on this machine, which reads the path itself like any command. + let mut bridge_params = opts.clone(); + if let Some(o) = bridge_params.as_object_mut() { + o.insert("path".into(), Value::String(p.path.clone())); + } + let (path, index) = (p.path, p.index); + if let Some(r) = self.headless_op(move |h| h.replace_smart_object(index, &path, &opts)).await { + return to_result(r); + } + self.run_command("layer.smartObjects.replaceContents".into(), bridge_params, true).await + } + #[tool( description = "Export each exported layer of the document as its own file beneath the write root (the capability-scoped Layers to Files). A file that already exists is an error, not an overwrite." )] diff --git a/crates/automation/tests/mcp.rs b/crates/automation/tests/mcp.rs index 5a9fa7c56e..68b6b034c5 100644 --- a/crates/automation/tests/mcp.rs +++ b/crates/automation/tests/mcp.rs @@ -80,6 +80,7 @@ async fn lists_expected_tools() { "doc_open", "doc_new", "doc_place", + "doc_replace_smart_object", "doc_export_layers", "doc_export_data_sets", "doc_import_data_sets", @@ -702,6 +703,36 @@ async fn doc_place_is_capability_scoped() { cleanup(&base); } +/// #8061: Replace Contents reads from the read root through `doc_replace_smart_object`; the +/// ambient `layer.smartObjects.replaceContents` stays refused. +#[tokio::test(flavor = "multi_thread")] +async fn doc_replace_smart_object_is_capability_scoped() { + let base = tmp("replace-so"); + let root = base.join("workspace"); + let outside = base.join("outside"); + std::fs::create_dir_all(&root).unwrap(); + std::fs::create_dir_all(&outside).unwrap(); + let img = photocraft_codecs::Image::from_u8(8, 6, photocraft_codecs::ChannelLayout::Rgb, vec![42; 144]).unwrap(); + let bytes = photocraft_codecs::encode(&img, photocraft_codecs::Format::Png, &Default::default()).unwrap(); + std::fs::write(root.join("inside.png"), &bytes).unwrap(); + std::fs::write(outside.join("outside.png"), bytes).unwrap(); + let client = connect(headless_in(&root)).await; + + json_of(&call(&client, "doc_new", json!({"width": 40, "height": 30})).await); + let placed = json_of(&call(&client, "doc_place", json!({"path": "inside.png"})).await); + let layer = placed["layer"].clone(); + let replaced = call(&client, "doc_replace_smart_object", json!({"path": "inside.png", "layer": layer})).await; + assert_ne!(replaced.is_error, Some(true), "{}", text(&replaced)); + let refused = call(&client, "doc_replace_smart_object", json!({"path": outside.join("outside.png").to_string_lossy(), "layer": layer})).await; + assert_eq!(refused.is_error, Some(true)); + assert!(text(&refused).contains("must be inside the automation root"), "{}", text(&refused)); + let ambient = call(&client, "command_run", json!({"id": "layer.smartObjects.replaceContents", "params": {"path": "inside.png", "layer": layer}})).await; + assert_eq!(ambient.is_error, Some(true)); + assert!(text(&ambient).contains("ambient filesystem paths"), "{}", text(&ambient)); + client.cancel().await.unwrap(); + cleanup(&base); +} + /// #3216: the export half of #2810. The write root scopes both exports, the read root the CSV, /// and the three ambient commands keep their refusal. #[tokio::test(flavor = "multi_thread")] diff --git a/crates/engine/src/smart_cmds.rs b/crates/engine/src/smart_cmds.rs index 3ca10083b9..b4f1b267d7 100644 --- a/crates/engine/src/smart_cmds.rs +++ b/crates/engine/src/smart_cmds.rs @@ -841,6 +841,13 @@ fn replace_contents(s: &mut Session, p: &Value) -> Result { replace_contents_bytes(s, id, &base_name(&path), bytes) } +/// Replace Contents with a file the caller already read, for the smart object `p` names (`layer`, +/// else the active layer): the body of the command minus its ambient path read (#8061). +pub fn replace_contents_from_bytes(s: &mut Session, p: &Value, file_name: &str, bytes: Vec) -> Result { + let id = layer_param(s, p)?; + replace_contents_bytes(s, id, file_name, bytes) +} + /// Replace Contents from a file's name and bytes: what the desktop and web file pickers hand over. pub fn replace_contents_bytes(s: &mut Session, id: LayerId, file_name: &str, bytes: Vec) -> Result { decode_source(file_name, &bytes)?; // fail before touching the document diff --git a/docs/architecture.md b/docs/architecture.md index 79c674bf23..2257f270ba 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -467,7 +467,7 @@ psd/src/ - **`automation`:** an MCP server built on `rmcp`. Its tool names use underscores (the dotted names such as `doc.open` belong to the JSON control protocol, `docs/control-protocol.md`). It exposes: - - `session_list`, `doc_open`, `doc_new`, `doc_place` (place from the read root as a Smart Object), + - `session_list`, `doc_open`, `doc_new`, `doc_place` (place from the read root as a Smart Object), `doc_replace_smart_object` (replace a Smart Object's contents from the read root), `doc_export_layers`, `doc_export_data_sets` (write beneath the write root), `doc_import_data_sets` (a CSV from the read root), `doc_save`, `doc_export`, `doc_inspect` (layer tree as JSON), `doc_render_preview` (PNG), `doc_select`, `doc_close`. - `command_list`, `command_run` and `command_batch`, generated from the registry; `jobs_list` and `jobs_cancel` for background jobs. diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 918a9f811b..f752aab3f0 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -318,6 +318,7 @@ How each MCP tool maps onto control methods in bridge mode: | `doc_inspect` | `engine.execute {command: "document.inspect"}` | | `doc_open {path}` | `app.open {path}` | | `doc_place {path, …}` | `engine.execute {command: "file.placeEmbedded", params}` | +| `doc_replace_smart_object {path, layer?, …}` | `engine.execute {command: "layer.smartObjects.replaceContents", params}` | | `doc_export_layers {dir, …}` | `engine.execute {command: "file.export.layersToFiles", params}` | | `doc_export_data_sets {dir, …}` | `engine.execute {command: "file.export.dataSetsAsFiles", params}` | | `doc_import_data_sets {path, …}` | `engine.execute {command: "file.import.variableDataSets", params}` | @@ -375,6 +376,7 @@ no MCP framing, no app start-up per command. Configure its file access with the | `session.list` | open documents and the active index | | `doc.open` / `doc.new` | `{path}` / `file.new` params | | `doc.place` | `{path, scale? (percent), fit? (true), center? ([x, y]), index?}`: places a file as a Smart Object layer above the active one and returns `{layer, scale, bounds}`. `path` resolves beneath the read root, so this is the capability-scoped `file.placeEmbedded` — that command itself still refuses an ambient path | +| `doc.replaceSmartObject` | `{path, layer? (id or name; default the active layer), index?}` → the command's `{layer, instances}`: replaces a Smart Object's contents (one history step, transform and filters kept). `path` resolves beneath the read root, so this is the capability-scoped `layer.smartObjects.replaceContents`, which itself still refuses an ambient path (#8061) | | `doc.exportLayers` | `{dir, format? (png), prefix?, visibleOnly? (true), quality?, index?}` → `{files, count}`: one file per exported layer, named like `file.export.layersToFiles` names them. `dir` resolves beneath the write root, so the ambient command stays refused. The bytes come from the command's own core, so both paths write the same files; the write capability refuses to overwrite an existing file | | `doc.exportDataSets` | `{dir, format? (png), dataSets? (all), naming? ("{name}\|{index}\|{document}"), index?}` → `{files, count}`: the capability-scoped `file.export.dataSetsAsFiles`. The batch is planned first and colliding names are refused before any file is written, as in the command | | `doc.importDataSets` | `{path, delimiter? (,), index?}` → `{imported}`: the capability-scoped `file.import.variableDataSets`; the CSV is read beneath the read root | diff --git a/docs/development.md b/docs/development.md index 4e450daffe..255b51b2fc 100644 --- a/docs/development.md +++ b/docs/development.md @@ -220,7 +220,7 @@ For headless MCP clients, pass absolute paths to deliberately chosen trusted wor Tools: - `session_list` -- `doc_open`, `doc_new`, `doc_place`, `doc_export_layers`, `doc_export_data_sets`, `doc_import_data_sets`, `doc_save`, `doc_export`, `doc_inspect`, `doc_render_preview` (returns a PNG image), `doc_select`, `doc_close` +- `doc_open`, `doc_new`, `doc_place`, `doc_replace_smart_object`, `doc_export_layers`, `doc_export_data_sets`, `doc_import_data_sets`, `doc_save`, `doc_export`, `doc_inspect`, `doc_render_preview` (returns a PNG image), `doc_select`, `doc_close` - `command_list`, `command_run`, `command_batch` (several commands per call) - `jobs_list` (running background jobs with progress, then recently finished ones with their result or error), `jobs_cancel` (one job by id, or every running job) - bridge only: `ui_inspect`, `ui_screenshot`, `ui_pointer`, `ui_menu_invoke`, `ui_set`, `control_call` From 020784da621f7b0f8256db4573dbabaef9b302f6 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Wed, 21 Oct 2026 02:32:12 -0400 Subject: [PATCH 173/649] PSD: type on a path opens on its path and saves back into the file's Txt2 (#7962) Photoshop keeps a path-text layer's path only in its Txt2 frame (EngineData calls it a text box the size of the path's bounds), so it opened as paragraph text. The frame (kind /2 /0 = 2) holds the path as a flat list of cubic segments at /1 /0, mapped to the TySh text space by /2 /2. apply_txt2_path reads it into TextShape::Path (a closed path starting at its last anchor, as Photoshop sets it); malformed or hostile frames keep the box/point shape with an import warning. build_txt2 writes a path layer's path into its object's frame (Photoshop's own frame left byte for byte when the path is unchanged; flip and a moved start written into the path), and a layer taken off its path loses its path frame. A new document still saves path text as point text. Co-Authored-By: Claude Opus 5.5 --- crates/io/src/psd_import.rs | 7 + crates/io/tests/text_corpus.rs | 91 ++++++ crates/text/src/lib.rs | 1 + crates/text/src/psd.rs | 94 ++++-- crates/text/src/psd_path.rs | 517 +++++++++++++++++++++++++++++++++ docs/gaps.md | 7 +- docs/scorecard.md | 2 +- scorecard/type.toml | 2 +- 8 files changed, 697 insertions(+), 24 deletions(-) create mode 100644 crates/text/src/psd_path.rs diff --git a/crates/io/src/psd_import.rs b/crates/io/src/psd_import.rs index 0eca6d704f..02142e1dd5 100644 --- a/crates/io/src/psd_import.rs +++ b/crates/io/src/psd_import.rs @@ -368,10 +368,17 @@ impl Ctx<'_> { let (text, transform) = blocks::parse_tysh(&data).unwrap_or_default(); TextLayer { text, transform, ..Default::default() } }); + let mut path_error = None; if let Some(txt2) = &self.txt2 { photocraft_text::psd::apply_txt2(&mut t, &data, txt2); + // Type on a path keeps its path only in its `Txt2` frame (#7962). + path_error = photocraft_text::psd::apply_txt2_path(&mut t, &data, txt2).err(); photocraft_text::psd::apply_txt2_frame(&mut t, &data, txt2); } + if let Some(e) = path_error { + let shape = if matches!(t.shape, photocraft_doc::text::TextShape::Box { .. }) { "paragraph" } else { "point" }; + self.warn(format!("layer \"{name}\": its type path could not be read ({e}); it opens as {shape} text")); + } // Photoshop's pixels are the cache only when the file has some: ag-psd, GIMP and // other writers leave type layers without image data (Photoshop re-renders them on // open), and an empty cache would show nothing until the layer is edited; the import diff --git a/crates/io/tests/text_corpus.rs b/crates/io/tests/text_corpus.rs index 8597ac49d8..c2ea2b667e 100644 --- a/crates/io/tests/text_corpus.rs +++ b/crates/io/tests/text_corpus.rs @@ -169,6 +169,97 @@ fn corpus_photoshop_txt2_survives_an_unedited_save() { println!("Txt2 kept byte-for-byte in {checked} Photoshop type files"); } +/// #7962: Photoshop's type on a path (`Txt2` frames, EngineData calls it a text box) opens on its +/// path, at the anchors the generator gave Photoshop; the circle re-renders where Photoshop drew +/// it; and a save after an edit (new text, a moved path) reopens on the layer's path. +#[cfg(feature = "corpus")] +#[test] +fn corpus_photoshop_path_text_opens_on_its_path() { + use photocraft_doc::text::TextShape; + use photocraft_geom::Point; + let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../corpus/photoshop/text"); + let k = 0.5522847498 * 96.0; + let cases: [(&str, bool, Vec<[f64; 2]>); 2] = [ + // Photoshop sets the type from the closed path's last anchor (the bottom). + ("path-circle.psd", true, vec![[128.0, 224.0], [32.0, 128.0], [128.0, 32.0], [224.0, 128.0]]), + ("path-wave-open.psd", false, vec![[16.0, 100.0], [160.0, 80.0], [304.0, 60.0]]), + ]; + let mut engine = photocraft_text::TextEngine::with_system_fonts(); + for (file, closed, anchors) in cases { + let f = root.join(file); + let bytes = std::fs::read(&f).unwrap_or_else(|e| panic!("{}: {e}: run `cargo xtask corpus --photoshop`", f.display())); + let imp = photocraft_io::import(file, &bytes).unwrap(); + assert!(!imp.warnings.iter().any(|w| w.contains("type path")), "{file}: {:?}", imp.warnings); + let doc = imp.document; + let mut all = Vec::new(); + walk(&doc.layers, &mut all); + let layer = all.iter().find(|l| matches!(l.content, LayerContent::Text(_))).unwrap(); + let LayerContent::Text(t) = &layer.content else { unreachable!() }; + let doc_anchors = |t: &photocraft_doc::TextLayer| -> Vec { + let TextShape::Path { path, start, flip } = &t.shape else { panic!("{file}: not path text: {:?}", t.shape) }; + assert_eq!((path.closed, *start, *flip), (closed, 0.0, false), "{file}"); + path.knots.iter().map(|k| t.transform.apply(k.anchor)).collect() + }; + let got = doc_anchors(t); + assert_eq!(got.len(), anchors.len(), "{file}"); + for (g, [x, y]) in got.iter().zip(&anchors) { + assert!((g.x - x).abs() < 1e-3 && (g.y - y).abs() < 1e-3, "{file}: anchor {g:?}, want ({x}, {y})"); + } + if closed { + // The circle's handles are the generator's (kappa × r), so the path is the circle. + let TextShape::Path { path, .. } = &t.shape else { unreachable!() }; + let h = t.transform.apply(path.knots[0].out_ctrl); + assert!((h.x - (128.0 - k)).abs() < 1e-3 && (h.y - 224.0).abs() < 1e-3, "{file}: handle {h:?}"); + } + + // Photoshop's pixels (the wave's EngineData text is blank: Photoshop drew nothing). + if let Some(ps) = t.cache.as_ref().filter(|c| !c.content_bounds().is_empty()) { + let ps_rect = ps.content_bounds(); + let (_, ours) = engine.render(t, doc.resolution_dpi, doc.pixel_format()); + let our_rect = ours.surface.content_bounds(); + let u = Rect::new(ps_rect.x0.min(our_rect.x0), ps_rect.y0.min(our_rect.y0), ps_rect.x1.max(our_rect.x1), ps_rect.y1.max(our_rect.y1)); + let (a, b) = (alpha(ps, u), alpha(&ours.surface, u)); + let inter: f32 = a.iter().zip(&b).map(|(x, y)| x.min(*y)).sum(); + let union: f32 = a.iter().zip(&b).map(|(x, y)| x.max(*y)).sum(); + let iou = if union > 0.0 { inter / union } else { 1.0 }; + let edges = [ps_rect.x0 - our_rect.x0, ps_rect.y0 - our_rect.y0, ps_rect.x1 - our_rect.x1, ps_rect.y1 - our_rect.y1]; + println!("{file}: ps={ps_rect:?} ours={our_rect:?} iou={iou:.2} edges={edges:?}"); + assert!(edges.iter().all(|d| d.abs() <= 8), "{file}: ink bounds {our_rect:?}, Photoshop's {ps_rect:?}"); + assert!(iou > 0.2, "{file}: the glyphs sit where Photoshop drew them (IoU {iou:.2})"); + } + + // Edited: new text and the path moved 10 px right; saved and opened again. + let mut edited = doc.clone(); + let id = layer.id; + for l in edited.layers.iter_mut() { + if l.id != id { + continue; + } + let LayerContent::Text(t) = &mut l.content else { continue }; + t.text = format!("{} again", t.text); + if let Some(r) = t.runs.last_mut() { + r.len += " again".len(); + } + t.sync_summary(); + if let TextShape::Path { path, .. } = &mut t.shape { + for k in &mut path.knots { + *k = k.transform(&photocraft_geom::Affine::translate(10.0, 0.0)); + } + } + t.psd_raw = Some(std::sync::Arc::new(photocraft_text::psd::build_tysh(t, edited.resolution_dpi, None))); + } + let out = photocraft_io::export(&edited, file, &Default::default()).unwrap().bytes; + let back = photocraft_io::import(file, &out).unwrap().document; + let mut all = Vec::new(); + walk(&back.layers, &mut all); + let LayerContent::Text(bt) = &all.iter().find(|l| matches!(l.content, LayerContent::Text(_))).unwrap().content else { unreachable!() }; + assert!(bt.text.ends_with(" again"), "{file}: {:?}", bt.text); + for (g, [x, y]) in doc_anchors(bt).iter().zip(&anchors) { + assert!((g.x - (x + 10.0)).abs() < 1e-3 && (g.y - y).abs() < 1e-3, "{file}: saved anchor {g:?}, want ({}, {y})", x + 10.0); + } + } +} + /// A text layer created in PhotoCraft (no PSD data) exports as an editable type layer and /// imports back with the same model. #[test] diff --git a/crates/text/src/lib.rs b/crates/text/src/lib.rs index af4de19f52..48c710b654 100644 --- a/crates/text/src/lib.rs +++ b/crates/text/src/lib.rs @@ -24,6 +24,7 @@ pub mod glyphs; pub mod layout; pub mod optical; pub mod psd; +mod psd_path; pub mod psd_styles; pub mod raster; pub mod render; diff --git a/crates/text/src/psd.rs b/crates/text/src/psd.rs index 99fb2ebf0f..e1b8d8df9f 100644 --- a/crates/text/src/psd.rs +++ b/crates/text/src/psd.rs @@ -214,12 +214,59 @@ pub fn apply_txt2(layer: &mut TextLayer, tysh: &[u8], txt2: &E) { layer.sync_summary(); } -/// The frame (`Txt2 /0 /8 /0` entry) of text object `index`: its rendered frame's `/10` names it. -fn txt2_frame(txt2: &E, index: usize) -> Option<&E> { +/// The frame (`Txt2 /0 /8 /0` entry) of text object `index`: its rendered frame's `/10` names it +/// (with `named`, else the frame its view names; see [`object_frame`]). +fn txt2_frame(txt2: &E, index: usize, named: bool) -> Option<&E> { let object = txt2.path(&["1", "1"]).and_then(E::as_array)?.get(index)?; - let frame = - object.path(&["1", "2"]).and_then(E::as_array)?.first()?.get("6").and_then(E::as_array)?.iter().find_map(|f| f.get("10").and_then(E::as_i64))?; - txt2.path(&["0", "8", "0"]).and_then(E::as_array)?.get(usize::try_from(frame).ok()?)?.get("0") + txt2.path(&["0", "8", "0"]).and_then(E::as_array)?.get(object_frame(object, named)?)?.get("0") +} + +/// The number of the frame the text object `object` is drawn in: its rendered frame's `/10`, else +/// (with `named`) the frame its view names (`/1 /0 [ << /0 n >> ]`). Photoshop leaves the rendered +/// strikes out for type it did not lay out (`text/path-wave-open.psd`, whose EngineData text is +/// blank). +fn object_frame(object: &E, named: bool) -> Option { + let rendered = object + .path(&["1", "2"]) + .and_then(E::as_array) + .and_then(|s| s.first()) + .and_then(|s| s.get("6")) + .and_then(E::as_array) + .and_then(|parts| parts.iter().find_map(|f| f.get("10").and_then(E::as_i64))); + let view = || named.then(|| object.path(&["1", "0"]).and_then(E::as_array).and_then(|f| f.first()).and_then(|f| f.get("0")).and_then(E::as_i64)).flatten(); + usize::try_from(rendered.or_else(view)?).ok() +} + +/// The `TySh` of `tysh` and the `Txt2` frame of its text object (`named`: see [`object_frame`]), +/// when that object still holds `layer`'s text (an edit elsewhere leaves `Txt2` stale). +fn layer_frame<'a>(layer: &TextLayer, tysh: &[u8], txt2: &'a E, named: bool) -> Option<(TySh, &'a E)> { + let t = parse_tysh(tysh)?; + let index = match t.text.get("TextIndex") { + Some(D::Integer(i)) => usize::try_from(*i).ok()?, + _ => return None, + }; + let text = txt2.path(&["1", "1"]).and_then(E::as_array).and_then(|a| a.get(index)).and_then(|o| o.path(&["0", "0"])).and_then(E::as_str)?; + if text.strip_suffix('\r').unwrap_or(text).replace('\r', "\n") != layer.text { + return None; + } + let frame = txt2_frame(txt2, index, named)?; + Some((t, frame)) +} + +/// Puts `layer` on its path when its `Txt2` frame is type on a path (#7962): Photoshop keeps the +/// path only there, and EngineData describes the layer as a text box the size of the path's +/// bounds. The path is read into the `TySh` text space, the type starting where Photoshop starts +/// it (see `psd_path`). `Ok(true)` when the layer is now path text, `Ok(false)` when its frame is +/// no path (or `Txt2` holds another text for it), `Err` with the reason when the path can't be +/// read: the layer then stays the box or point text EngineData describes. +pub fn apply_txt2_path(layer: &mut TextLayer, tysh: &[u8], txt2: &E) -> Result { + let Some((_, frame)) = layer_frame(layer, tysh, txt2, true) else { return Ok(false) }; + if crate::psd_path::frame_kind(frame) != crate::psd_path::PATH_FRAME { + return Ok(false); + } + let path = crate::psd_path::read(frame)?; + layer.shape = TextShape::Path { path, start: 0.0, flip: false }; + Ok(true) } /// Places `layer` where Photoshop draws it when the text object's frame in `Txt2` is moved @@ -231,18 +278,11 @@ fn txt2_frame(txt2: &E, index: usize) -> Option<&E> { /// alignment anchor. Only when the layer's `TextIndex` entry still holds the layer's text, as /// for [`apply_txt2`], and the frame agrees with the `TySh` `bounds`. pub fn apply_txt2_frame(layer: &mut TextLayer, tysh: &[u8], txt2: &E) { - let Some(t) = parse_tysh(tysh) else { return }; - let Some(index) = (match t.text.get("TextIndex") { - Some(D::Integer(i)) => usize::try_from(*i).ok(), - _ => None, - }) else { - return; - }; - let text = txt2.path(&["1", "1"]).and_then(E::as_array).and_then(|a| a.get(index)).and_then(|o| o.path(&["0", "0"])).and_then(E::as_str); - if text.is_none_or(|t| t.strip_suffix('\r').unwrap_or(t).replace('\r', "\n") != layer.text) { + // Type on a path: [`apply_txt2_path`] already read the path through the frame's matrix. + if matches!(layer.shape, TextShape::Path { .. }) { return; } - let Some(frame) = txt2_frame(txt2, index) else { return }; + let Some((t, frame)) = layer_frame(layer, tysh, txt2, false) else { return }; let m = arr_f(frame.path(&["2", "2"])); let matrix = if m.len() == 6 && m.iter().all(|v| v.is_finite()) { Affine { m: [m[0], m[1], m[2], m[3], m[4], m[5]] } } else { Affine::IDENTITY }; let at = match layer.shape { @@ -1111,6 +1151,9 @@ pub fn build_txt2_at(objects: &[(i32, &TextLayer)], previous: Option<&[u8]>, dpi let all_stubs = prev_objects.iter().all(is_stub); // A template is copied once per new layer, so a large one is skipped (the stub is written). let template = prev_objects.iter().rev().find(|o| names_one_frame(o) && fits(o, &mut { TEMPLATE_NODES }) && edited_object(o, "\r").is_some()); + // The frame each written object is drawn in, with its layer's shape (type on a path lives + // only in the frame, #7962). + let mut frame_shapes: Vec<(usize, &TextShape)> = Vec::new(); for (index, layer) in objects { if !(0..=MAX_TEXT_INDEX).contains(index) { continue; @@ -1162,6 +1205,9 @@ pub fn build_txt2_at(objects: &[(i32, &TextLayer)], previous: Option<&[u8]>, dpi _ => model.set("6", E::Dict(vec![("0".into(), E::Array(runs))])), } object.set("0", model); + if let Some(frame) = object_frame(&object, true) { + frame_shapes.push((frame, &layer.shape)); + } if slots.len() <= at { slots.resize(at + 1, E::dict()); } @@ -1173,6 +1219,15 @@ pub fn build_txt2_at(objects: &[(i32, &TextLayer)], previous: Option<&[u8]>, dpi // `/1` whatever it holds beside the text objects. let mut outer = prev.clone().unwrap_or_else(|| E::Dict(vec![("98".into(), E::Dict(vec![("0".into(), E::Int(14))])), ("0".into(), E::dict())])); pad_frames(&mut outer, slots.len()); + // A path layer's frame holds its path; a layer taken off its path loses its path frame. An + // unchanged path leaves the file's frame as it was. + if let Some(E::Array(frames)) = outer.get_mut("0").and_then(|v| v.get_mut("8")).and_then(|v| v.get_mut("0")) { + for (at, shape) in frame_shapes { + if let Some(entry) = frames.get_mut(at) { + crate::psd_path::update_frame(entry, shape); + } + } + } if fonts.len() != fonts_before && let Some(list @ E::Dict(_)) = outer.get_mut("0").and_then(|v| v.get_mut("1")) { @@ -1260,10 +1315,7 @@ fn pad_frames(outer: &mut E, count: usize) { let Some(E::Array(frames)) = outer.get_mut("0").and_then(|v| v.get_mut("8")).and_then(|v| v.get_mut("0")) else { return }; let count = count.min(MAX_TEXT_INDEX as usize + 1); if frames.len() < count { - let kind = E::Dict(vec![("4".into(), E::Int(-1)), ("7".into(), E::Bool(false))]); - let data = E::Dict(vec![("6".into(), E::Array(vec![E::Real(-1.0), E::Real(-1.0)])), ("11".into(), kind)]); - let frame = E::Dict(vec![("0".into(), E::Dict(vec![("2".into(), data)]))]); - frames.resize(count, frame); + frames.resize(count, crate::psd_path::point_frame()); } } @@ -1512,7 +1564,9 @@ pub fn build_engine_data(layer: &TextLayer, template: Option, dpi: f32) -> E dict.set("UseFractionalGlyphWidths", E::Bool(true)); } let (shape_type, box_bounds) = match layer.shape { - // PSD path type is not written yet: the layer saves as point text. + // Type on a path: the path goes into the layer's `Txt2` frame ([`build_txt2`], #7962), + // which only a file that already has a `Txt2` object for the layer gets; EngineData + // keeps it as point text, one line for readers (and files) without that frame. TextShape::Point | TextShape::Path { .. } => (0, None), TextShape::Box { x, y, width, height } => (1, Some([x, y, x + width, y + height])), }; diff --git a/crates/text/src/psd_path.rs b/crates/text/src/psd_path.rs new file mode 100644 index 0000000000..f01807d21e --- /dev/null +++ b/crates/text/src/psd_path.rs @@ -0,0 +1,517 @@ +//! Type on a path in a PSD (#7962): the path lives only in the type layer's frame in the +//! document's `Txt2` block (EngineData marks such a layer as box text, `ShapeType 1`, with the +//! path's bounds as its `BoxBounds`). +//! +//! Observed layout (Photoshop 2026, `text/path-circle.psd` and `text/path-wave-open.psd` in +//! photocraft-corpus): a frame `<< /0 << /1 << /0 [ … ] >> /2 << /0 2 /2 [ matrix ] … >> >> >>` +//! has the kind `/2 /0` (absent for point text, 1 for a text box, 2 for type on a path) and its +//! outline at `/1 /0` as a flat list of cubic Bézier segments, eight numbers each +//! (`p0 c1 c2 p1`, the next segment starting where the previous one ends, a closed path ending +//! where it started), in the frame's space; `/2 /2` maps the frame's space to the `TySh` text +//! space. On a closed path Photoshop sets the type from the path's last anchor (the circle's +//! glyph 0 sits on its fourth anchor and runs on through the first), on an open path from its +//! first. Neither oracle has a moved start or flipped type, so those are written into the path +//! itself (see [`frame_path`]). + +use photocraft_doc::text::TextShape; +use photocraft_doc::vector::{Knot, PathOp, Subpath}; +use photocraft_geom::{Affine, Point}; + +use crate::engine_data::Value as E; + +/// The `Txt2` frame kind (`/2 /0`) of type on a path. +pub(crate) const PATH_FRAME: i64 = 2; +/// The `Txt2` frame kind (`/2 /0`) of a text box. +const BOX_FRAME: i64 = 1; +/// Most cubic segments read from a frame (a hostile file cannot make this large). +const MAX_SEGMENTS: usize = 4096; +/// How close (px) two points must be to count as the same: Photoshop writes a segment's start as +/// an exact copy of the previous segment's end. +const SAME: f64 = 1e-3; + +/// The kind of the frame dictionary `frame` (the entry's `/0`): 0 point text, 1 box, 2 path. +pub(crate) fn frame_kind(frame: &E) -> i64 { + frame.path(&["2", "0"]).and_then(E::as_i64).unwrap_or(0) +} + +/// Every entry of `v` as a finite number, or `None`. +fn numbers(v: &E) -> Option> { + v.as_array()?.iter().map(E::as_f64).collect() +} + +fn same(a: Point, b: Point) -> bool { + (a.x - b.x).hypot(a.y - b.y) <= SAME +} + +/// Whether the handles `a` (in) and `b` (out) of `anchor` are collinear on opposite sides. +fn smooth(anchor: Point, a: Point, b: Point) -> bool { + let (ax, ay, bx, by) = (a.x - anchor.x, a.y - anchor.y, b.x - anchor.x, b.y - anchor.y); + let (la, lb) = (ax.hypot(ay), bx.hypot(by)); + la > SAME && lb > SAME && (ax * by - ay * bx).abs() <= 1e-3 * la * lb && ax * bx + ay * by < 0.0 +} + +fn knot(in_ctrl: Point, anchor: Point, out_ctrl: Point) -> Knot { + Knot { anchor, in_ctrl, out_ctrl, smooth: smooth(anchor, in_ctrl, out_ctrl) } +} + +/// The type path of a path frame `frame` (the entry's `/0`), in the `TySh` text space, with the +/// type starting at its first knot. `Err` says why it can't be read (the caller keeps the box or +/// point text EngineData describes). +pub(crate) fn read(frame: &E) -> Result { + let raw = frame.path(&["1", "0"]).ok_or("the frame has no path")?; + let v = numbers(raw).ok_or("a path coordinate is not a number")?; + if v.is_empty() || v.len() % 8 != 0 { + return Err(format!("its path has {} coordinates, not whole curve segments", v.len())); + } + if v.len() / 8 > MAX_SEGMENTS { + return Err(format!("its path has more than {MAX_SEGMENTS} segments")); + } + let matrix = match frame.path(&["2", "2"]) { + None => Affine::IDENTITY, + Some(m) => { + let Some([a, b, c, d, e, f]) = numbers(m).and_then(|m| <[f64; 6]>::try_from(m).ok()) else { + return Err("its frame matrix is not six numbers".into()); + }; + let m = Affine { m: [a, b, c, d, e, f] }; + let det = m.determinant(); + if !det.is_finite() || det.abs() <= 1e-12 { + return Err("its frame matrix is degenerate".into()); + } + m + } + }; + let pts: Vec = v.as_chunks::<2>().0.iter().map(|&[x, y]| matrix.apply(Point::new(x, y))).collect(); + if pts.iter().any(|p| !p.x.is_finite() || !p.y.is_finite()) { + return Err("its path is out of range".into()); + } + let segs: Vec<[Point; 4]> = pts.as_chunks::<4>().0.to_vec(); + if segs.windows(2).any(|w| matches!(w, [a, b] if !same(a[3], b[0]))) { + return Err("its path has more than one piece".into()); + } + let (Some(first), Some(last)) = (segs.first(), segs.last()) else { return Err("the frame has no path".into()) }; + let (x0, x1) = pts.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |(lo, hi), p| (lo.min(p.x), hi.max(p.x))); + let (y0, y1) = pts.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |(lo, hi), p| (lo.min(p.y), hi.max(p.y))); + if x1 - x0 <= SAME && y1 - y0 <= SAME { + return Err("its path has no length".into()); + } + let closed = same(last[3], first[0]); + let mut knots: Vec = Vec::with_capacity(segs.len() + 1); + for (i, s) in segs.iter().enumerate() { + let prev = match i.checked_sub(1).and_then(|j| segs.get(j)) { + Some(p) => p[2], + None if closed => last[2], + None => s[0], + }; + knots.push(knot(prev, s[0], s[1])); + } + if closed { + // The type starts on the closing segment: from the last anchor. + knots.rotate_right(1); + } else { + knots.push(knot(last[2], last[3], last[3])); + } + Ok(Subpath { closed, knots, op: PathOp::Combine }) +} + +/// `path` with its knots in the opposite order (the segments run backwards). +fn reversed(path: &Subpath) -> Subpath { + let mut knots: Vec = path.knots.iter().rev().map(|k| Knot { anchor: k.anchor, in_ctrl: k.out_ctrl, out_ctrl: k.in_ctrl, smooth: k.smooth }).collect(); + if path.closed { + // Keep the first knot first: k0, k(n-1), …, k1. + knots.rotate_right(1); + } + Subpath { closed: path.closed, knots, op: path.op } +} + +fn lerp(a: Point, b: Point, t: f64) -> Point { + Point::new(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t) +} + +fn cubic(s: &[Point; 4], t: f64) -> Point { + let (a, b, c) = (lerp(s[0], s[1], t), lerp(s[1], s[2], t), lerp(s[2], s[3], t)); + lerp(lerp(a, b, t), lerp(b, c, t), t) +} + +/// Pieces each segment is measured in for [`starting_at`]. +const STEPS: usize = 64; + +/// `path` starting `s` px along it (the type origin moved there): an open path loses the part +/// before `s`, a closed one starts at a new smooth knot there. Unchanged for `s` at or before the +/// start, or (open) at or past the end. +fn starting_at(path: &Subpath, s: f64) -> Subpath { + let segs = path.segments(); + let lengths: Vec = segs + .iter() + .map(|seg| { + (1..=STEPS) + .map(|i| (cubic(seg, (i - 1) as f64 / STEPS as f64), cubic(seg, i as f64 / STEPS as f64))) + .map(|(a, b)| (b.x - a.x).hypot(b.y - a.y)) + .sum() + }) + .collect(); + let total: f64 = lengths.iter().sum(); + if !s.is_finite() || !total.is_finite() || total <= SAME { + return path.clone(); + } + let s = if path.closed { s.rem_euclid(total) } else { s }; + if s <= SAME || (!path.closed && s >= total - SAME) || (path.closed && s >= total - SAME) { + return path.clone(); + } + // The segment and parameter at arc length `s` (linear within a measured piece). + let mut left = s; + let mut at = None; + for (i, (seg, len)) in segs.iter().zip(&lengths).enumerate() { + if left > *len { + left -= len; + continue; + } + let mut walked = 0.0; + for k in 1..=STEPS { + let (t0, t1) = ((k - 1) as f64 / STEPS as f64, k as f64 / STEPS as f64); + let (a, b) = (cubic(seg, t0), cubic(seg, t1)); + let piece = (b.x - a.x).hypot(b.y - a.y); + if walked + piece >= left || k == STEPS { + let f = if piece > 0.0 { ((left - walked) / piece).clamp(0.0, 1.0) } else { 0.0 }; + at = Some((i, t0 + (t1 - t0) * f, *seg)); + break; + } + walked += piece; + } + break; + } + let Some((i, t, seg)) = at else { return path.clone() }; + // de Casteljau: left half p0 a ab m, right half m bc c p3. + let (a, b, c) = (lerp(seg[0], seg[1], t), lerp(seg[1], seg[2], t), lerp(seg[2], seg[3], t)); + let (ab, bc) = (lerp(a, b, t), lerp(b, c, t)); + let m = lerp(ab, bc, t); + let n = path.knots.len(); + if n == 0 { + return path.clone(); + } + let next = (i + 1) % n; + let mut knots = Vec::with_capacity(n + 1); + knots.push(Knot { anchor: m, in_ctrl: if path.closed { ab } else { m }, out_ctrl: bc, smooth: path.closed }); + let count = if path.closed { n } else { n - next }; + for r in 0..count { + let j = (next + r) % n; + let Some(mut k) = path.knots.get(j).copied() else { continue }; + if j == next { + k.in_ctrl = c; + } + if path.closed && j == i { + k.out_ctrl = a; + } + knots.push(k); + } + Subpath { closed: path.closed, knots, op: path.op } +} + +/// The path a frame is written with for `TextShape::Path { path, start, flip }`: flipped type is +/// the path run backwards and a moved start the path from there on (exactly how PhotoCraft lays +/// type on a path out), so Photoshop, which starts at the path's beginning, sets the same type. +pub(crate) fn frame_path(path: &Subpath, start: f32, flip: bool) -> Subpath { + let path = if flip { reversed(path) } else { path.clone() }; + starting_at(&path, f64::from(start)) +} + +fn real(v: f64) -> E { + E::Real(v) +} + +/// The segment list (`/1 /0`) Photoshop reads `path` from: on a closed path the type starts at +/// the last anchor, so the first knot goes last. +fn segment_list(path: &Subpath) -> Option> { + let mut knots = path.knots.clone(); + if path.closed && !knots.is_empty() { + knots.rotate_left(1); + } + let segs = Subpath { closed: path.closed, knots, op: path.op }.segments(); + let out: Vec = segs.iter().flatten().flat_map(|p| [real(p.x), real(p.y)]).collect(); + (!out.is_empty() && segs.iter().flatten().all(|p| p.x.is_finite() && p.y.is_finite())).then_some(out) +} + +/// Whether two type paths are the same within [`SAME`] (the smooth flags aside). +fn same_path(a: &Subpath, b: &Subpath) -> bool { + a.closed == b.closed + && a.knots.len() == b.knots.len() + && a.knots.iter().zip(&b.knots).all(|(p, q)| same(p.anchor, q.anchor) && same(p.in_ctrl, q.in_ctrl) && same(p.out_ctrl, q.out_ctrl)) +} + +/// The point-text frame Photoshop writes (`<< /0 << /2 << /6 [ -1.0 -1.0 ] /11 << /4 -1 /7 false +/// >> >> >> >>`; also what [`crate::psd`] pads the frame list with). +pub(crate) fn point_frame() -> E { + let kind = E::Dict(vec![("4".into(), E::Int(-1)), ("7".into(), E::Bool(false))]); + let data = E::Dict(vec![("6".into(), E::Array(vec![real(-1.0), real(-1.0)])), ("11".into(), kind)]); + E::Dict(vec![("0".into(), E::Dict(vec![("2".into(), data)]))]) +} + +/// A text box's frame as Photoshop writes it (`text/paragraph-box-left.psd`): the rectangle as +/// four straight segments from its top left, clockwise. +fn box_frame(x: f64, y: f64, w: f64, h: f64) -> E { + let c = [(x, y), (x + w, y), (x + w, y + h), (x, y + h), (x, y)]; + let pts: Vec = + c.windows(2).flat_map(|p| p.iter().flat_map(|&(a, b)| [(a, b), (a, b)]).collect::>()).flat_map(|(a, b)| [real(a), real(b)]).collect(); + let kind = E::Dict(vec![("4".into(), E::Int(-2)), ("18".into(), real(-2.0)), ("22".into(), real(0.025))]); + let data = E::Dict(vec![("0".into(), E::Int(BOX_FRAME)), ("6".into(), E::Array(vec![real(-2.0), real(-2.0)])), ("11".into(), kind)]); + E::Dict(vec![("0".into(), E::Dict(vec![("1".into(), E::Dict(vec![("0".into(), E::Array(pts))])), ("2".into(), data)]))]) +} + +/// Brings the frame list entry `entry` (`<< /0 frame >>`) of a type layer up to date with its +/// `shape`: type on a path gets a path frame for its path (left byte for byte when it already +/// holds that path, e.g. Photoshop's own after an unedited save), and a layer no longer on a path +/// loses its path frame (else it would reopen on the path). +pub(crate) fn update_frame(entry: &mut E, shape: &TextShape) { + let frame = entry.get("0"); + let kind = frame.map_or(0, frame_kind); + match shape { + TextShape::Path { path, start, flip } => { + let path = frame_path(path, *start, *flip); + if kind == PATH_FRAME && frame.and_then(|f| read(f).ok()).is_some_and(|p| same_path(&p, &path)) { + return; + } + let Some(list) = segment_list(&path) else { return }; + // Keep the other keys of a path frame; anything else becomes one. + let mut data = match frame.and_then(|f| f.get("2")) { + Some(d @ E::Dict(_)) if kind == PATH_FRAME => d.clone(), + _ => E::Dict(vec![("6".into(), E::Array(vec![real(-1.0), real(-1.0)]))]), + }; + data.set("0", E::Int(PATH_FRAME)); + // The path is written in text space. + data.set("2", E::Array([1.0, 0.0, 0.0, 1.0, 0.0, 0.0].map(real).to_vec())); + let mut frame = match frame { + Some(f @ E::Dict(_)) if kind == PATH_FRAME => f.clone(), + _ => E::dict(), + }; + frame.set("1", E::Dict(vec![("0".into(), E::Array(list))])); + frame.set("2", data); + *entry = E::Dict(vec![("0".into(), frame)]); + } + _ if kind != PATH_FRAME => {} + TextShape::Box { x, y, width, height } => *entry = box_frame(f64::from(*x), f64::from(*y), f64::from(*width), f64::from(*height)), + TextShape::Point => *entry = point_frame(), + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::engine_data::parse; + + fn frame(src: &str) -> E { + parse(src.as_bytes()).unwrap() + } + + /// The frame of `text/path-circle.psd` (Photoshop 2026). + const CIRCLE: &str = "<< /1 << /0 [ 32.0 128.0 32.0 74.98067 74.98067 32.0 128.0 32.0 128.0 32.0 181.01933 32.0 224.0 74.98067 224.0 128.0 224.0 128.0 224.0 181.01933 181.01933 224.0 128.0 224.0 128.0 224.0 74.98067 224.0 32.0 181.01933 32.0 128.0 ] >> /2 << /0 2 /2 [ 1.0 0.0 0.0 1.0 -32.0 -32.0 ] /6 [ -1.0 -1.0 ] >> >>"; + /// The frame of `text/path-wave-open.psd` (Photoshop 2026). + const WAVE: &str = "<< /1 << /0 [ 16.0 100.0 46.0 40.0 120.0 40.0 160.0 80.0 160.0 80.0 200.0 120.0 274.0 100.0 304.0 60.0 ] >> /2 << /0 2 /2 [ 1.0 0.0 0.0 1.0 -16.0 -52.12246 ] /6 [ -1.0 -1.0 ] >> >>"; + + #[test] + fn photoshop_path_frames_read_into_text_space() { + let wave = read(&frame(WAVE)).unwrap(); + assert!(!wave.closed); + assert_eq!(wave.knots.len(), 3); + let p = |x: f64, y: f64| Point::new(x - 16.0, y - 52.12246); + let k = &wave.knots; + assert!(same(k[0].anchor, p(16.0, 100.0)) && same(k[0].in_ctrl, p(16.0, 100.0)) && same(k[0].out_ctrl, p(46.0, 40.0))); + assert!(same(k[1].in_ctrl, p(120.0, 40.0)) && same(k[1].anchor, p(160.0, 80.0)) && same(k[1].out_ctrl, p(200.0, 120.0)) && k[1].smooth); + assert!(same(k[2].in_ctrl, p(274.0, 100.0)) && same(k[2].anchor, p(304.0, 60.0))); + + let circle = read(&frame(CIRCLE)).unwrap(); + assert!(circle.closed); + assert_eq!(circle.knots.len(), 4); + // The type starts at the bottom anchor (Photoshop's glyph 0) and runs to the left one. + assert!(same(circle.knots[0].anchor, Point::new(96.0, 192.0))); + assert!(same(circle.knots[1].anchor, Point::new(0.0, 96.0))); + assert!(circle.knots.iter().all(|k| k.smooth)); + } + + #[test] + fn written_frames_read_back() { + for src in [CIRCLE, WAVE] { + let path = read(&frame(src)).unwrap(); + let mut entry = E::Dict(vec![("0".into(), frame(src))]); + let before = entry.clone(); + update_frame(&mut entry, &TextShape::Path { path: path.clone(), start: 0.0, flip: false }); + assert_eq!(entry, before, "an unchanged path keeps Photoshop's frame"); + let mut moved = path.clone(); + for k in &mut moved.knots { + *k = k.transform(&Affine::translate(5.0, -3.0)); + } + update_frame(&mut entry, &TextShape::Path { path: moved.clone(), start: 0.0, flip: false }); + let back = read(entry.get("0").unwrap()).unwrap(); + assert!(same_path(&back, &moved), "{back:?}"); + assert_eq!(entry.path(&["0", "2", "6"]), before.path(&["0", "2", "6"]), "the frame's other keys stay"); + } + } + + /// Flipped type and a moved start are written into the path, which lays the type out the same. + #[test] + fn flip_and_start_are_baked_into_the_frame() { + use crate::warp::Warp; + for src in [CIRCLE, WAVE] { + let path = read(&frame(src)).unwrap(); + for (start, flip) in [(40.0, false), (0.0, true), (25.0, true)] { + let shape = TextShape::Path { path: path.clone(), start, flip }; + let baked = TextShape::Path { path: frame_path(&path, start, flip), start: 0.0, flip: false }; + let (a, b) = (Warp::on_path(&shape).unwrap(), Warp::on_path(&baked).unwrap()); + for x in [0.0, 10.0, 50.0, 120.0] { + for y in [-12.0, 0.0, 4.0] { + let (p, q) = (a.apply(x, y), b.apply(x, y)); + assert!((p.0 - q.0).hypot(p.1 - q.1) < 0.5, "{src:.10} start {start} flip {flip} at ({x}, {y}): {p:?} vs {q:?}"); + } + } + } + } + } + + #[test] + fn hostile_frames_are_errors() { + for src in [ + "<< /2 << /0 2 >> >>", + "<< /1 << /0 [ ] >> /2 << /0 2 >> >>", + "<< /1 << /0 [ 1.0 2.0 3.0 ] >> /2 << /0 2 >> >>", + "<< /1 << /0 [ 0 0 1 1 2 2 (x) 3 ] >> /2 << /0 2 >> >>", + "<< /1 << /0 [ 0 0 1 1 2 2 1e999 3 ] >> /2 << /0 2 >> >>", + "<< /1 << /0 [ 0 0 1 1 2 2 3 3 ] >> /2 << /0 2 /2 [ 0 0 0 0 0 0 ] >> >>", + "<< /1 << /0 [ 0 0 1 1 2 2 3 3 ] >> /2 << /0 2 /2 [ 1 0 0 ] >> >>", + "<< /1 << /0 [ 0 0 1 1 2 2 3 3 ] >> /2 << /0 2 /2 [ 1e300 0 0 1e300 0 0 ] >> >>", + "<< /1 << /0 [ 0 0 1 1 2 2 3 3 50 50 60 60 70 70 80 80 ] >> /2 << /0 2 >> >>", + "<< /1 << /0 [ 5 5 5 5 5 5 5 5 ] >> /2 << /0 2 >> >>", + "<< /1 << /0 (path) >> /2 << /0 2 >> >>", + ] { + assert!(read(&frame(src)).is_err(), "{src}"); + } + let many = format!("<< /1 << /0 [ {} ] >> /2 << /0 2 >> >>", "0 0 1 1 2 2 0 0 ".repeat(MAX_SEGMENTS + 1)); + assert!(read(&frame(&many)).is_err()); + } + + fn d(items: Vec<(&str, E)>) -> E { + E::Dict(items.into_iter().map(|(k, v)| (k.to_string(), v)).collect()) + } + + /// A Photoshop-shaped `Txt2` block with one point-text object for `text` (`\r` breaks, trailing + /// `\r`) drawn in frame 0. + fn photoshop_txt2(text: &str) -> Vec { + photoshop_txt2_in(text, point_frame()) + } + + /// [`photoshop_txt2`] with the frame list entry `frame`. + fn photoshop_txt2_in(text: &str, frame: E) -> Vec { + let len = text.encode_utf16().count() as i64; + let run = || { + d(vec![("0", d(vec![("0", d(vec![("0", E::String(String::new())), ("6", d(vec![("0", E::Int(0)), ("1", E::Real(12.0))]))]))])), ("1", E::Int(len))]) + }; + let model = d(vec![("0", E::String(text.into())), ("5", d(vec![("0", E::Array(vec![run()]))])), ("6", d(vec![("0", E::Array(vec![run()]))]))]); + let strike = d(vec![("99", E::Name("PC".into())), ("6", E::Array(vec![d(vec![("99", E::Name("F".into())), ("10", E::Int(0))])]))]); + let view = d(vec![ + ("0", E::Array(vec![d(vec![("0", E::Int(0))])])), + ("1", d(vec![("0", E::Array(vec![d(vec![("0", d(vec![("1", E::Int(1))])), ("1", E::Int(len))])]))])), + ("2", E::Array(vec![strike])), + ]); + let object = d(vec![("0", model), ("1", view)]); + crate::engine_data::write_bare(&[ + ("98".into(), d(vec![("0", E::Int(14))])), + ("0".into(), d(vec![("8", d(vec![("0", E::Array(vec![frame]))]))])), + ("1".into(), d(vec![("1", E::Array(vec![object]))])), + ]) + } + + fn layer(text: &str, shape: TextShape) -> photocraft_doc::TextLayer { + use photocraft_doc::text::{CharStyle, TextRun}; + let mut t = photocraft_doc::TextLayer { + text: text.into(), + runs: vec![TextRun { len: text.len(), style: CharStyle { size_pt: 12.0, ..Default::default() } }], + shape, + transform: Affine::translate(32.0, 20.0), + ..Default::default() + }; + t.sync_summary(); + t + } + + /// A layer read back, with what [`crate::psd::apply_txt2_path`] said. + type Opened = (photocraft_doc::TextLayer, Result); + + /// Saves `layers` (object `i` each) into a file whose `Txt2` is `prev`, then reads each back: + /// its `TySh` and what [`crate::psd::apply_txt2_path`] makes of the saved `Txt2`. + fn save_and_open(layers: &[&photocraft_doc::TextLayer], prev: &[u8]) -> (Vec, Vec) { + let objects: Vec<(i32, &photocraft_doc::TextLayer)> = layers.iter().enumerate().map(|(i, l)| (i as i32, *l)).collect(); + let txt2 = crate::psd::build_txt2(&objects, Some(prev)); + let parsed = crate::psd::parse_txt2(&txt2).unwrap(); + let back = objects + .iter() + .map(|(i, l)| { + let tysh = crate::psd::set_text_index(&crate::psd::build_tysh(l, 72.0, None), *i).unwrap(); + let mut back = crate::psd::text_layer_from_tysh(&tysh, 72.0).unwrap(); + crate::psd::apply_txt2(&mut back, &tysh, &parsed); + let applied = crate::psd::apply_txt2_path(&mut back, &tysh, &parsed); + crate::psd::apply_txt2_frame(&mut back, &tysh, &parsed); + (back, applied) + }) + .collect(); + (txt2, back) + } + + /// #7962: type on a path survives a PSD save and open, for the file's own text object and for + /// a layer the file had no object for; a moved start and flipped type come back laid out the + /// same, in the path; a second save changes nothing. + #[test] + fn path_text_round_trips_through_tysh_and_txt2() { + let circle = read(&frame(CIRCLE)).unwrap(); + let wave = read(&frame(WAVE)).unwrap(); + let a = layer("On a circle", TextShape::Path { path: circle.clone(), start: 0.0, flip: false }); + let b = layer("Along a wave", TextShape::Path { path: wave.clone(), start: 30.0, flip: true }); + let prev = photoshop_txt2("On a circle\r"); + let (txt2, back) = save_and_open(&[&a, &b], &prev); + for ((l, applied), (want, start, flip)) in back.iter().zip([(&circle, 0.0, false), (&wave, 30.0, true)]) { + assert_eq!(applied, &Ok(true), "{}", l.text); + let TextShape::Path { path, start: s, flip: f } = &l.shape else { panic!("{}: {:?}", l.text, l.shape) }; + assert_eq!((*s, *f), (0.0, false)); + assert!(same_path(path, &frame_path(want, start, flip)), "{}: {path:?}", l.text); + assert_eq!(l.transform, Affine::translate(32.0, 20.0), "the frame's matrix is not applied twice"); + } + let (again, _) = save_and_open(&[&back[0].0, &back[1].0], &txt2); + assert_eq!(again, txt2, "a re-save of the opened file changes nothing"); + // Off its path, the layer opens as point text again. + let detached = layer("On a circle", TextShape::Point); + let (_, back) = save_and_open(&[&detached], &txt2); + assert_eq!(back[0].1, Ok(false)); + assert_eq!(back[0].0.shape, TextShape::Point); + } + + /// A malformed path frame leaves the layer as EngineData describes it, with the reason. + #[test] + fn a_malformed_path_frame_keeps_the_engine_data_shape() { + let a = layer("Hostile", TextShape::Box { x: 0.0, y: 0.0, width: 50.0, height: 20.0 }); + let tysh = crate::psd::set_text_index(&crate::psd::build_tysh(&a, 72.0, None), 0).unwrap(); + for bad in ["<< /1 << /0 [ 1 2 3 ] >> /2 << /0 2 >> >>", "<< /1 << /0 [ 0 0 1 1 2 2 3 3 ] >> /2 << /0 2 /2 [ 0 0 0 0 0 0 ] >> >>"] { + let entry = E::Dict(vec![("0".into(), frame(bad))]); + let txt2 = crate::psd::parse_txt2(&photoshop_txt2_in("Hostile\r", entry)).unwrap(); + let mut l = crate::psd::text_layer_from_tysh(&tysh, 72.0).unwrap(); + let before = l.shape.clone(); + assert!(crate::psd::apply_txt2_path(&mut l, &tysh, &txt2).is_err(), "{bad}"); + assert_eq!(l.shape, before); + } + } + + /// A layer taken off its path doesn't keep its path frame (it would reopen on the path). + #[test] + fn a_layer_off_its_path_loses_the_path_frame() { + let mut entry = E::Dict(vec![("0".into(), frame(CIRCLE))]); + update_frame(&mut entry, &TextShape::Point); + assert_eq!(entry, point_frame()); + let mut entry = E::Dict(vec![("0".into(), frame(WAVE))]); + update_frame(&mut entry, &TextShape::Box { x: 1.0, y: 2.0, width: 30.0, height: 40.0 }); + assert_eq!(entry.get("0").map(frame_kind), Some(BOX_FRAME)); + assert_eq!( + entry.path(&["0", "1", "0"]).and_then(numbers).unwrap()[..8], + [1.0, 2.0, 1.0, 2.0, 31.0, 2.0, 31.0, 2.0], + "Photoshop's box outline: corners as straight segments from the top left" + ); + // A point or box frame is left alone. + let mut point = point_frame(); + update_frame(&mut point, &TextShape::Point); + assert_eq!(point, point_frame()); + } +} diff --git a/docs/gaps.md b/docs/gaps.md index ab42d0f8ef..e74682cf01 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where PhotoCraft falls short of Photoshop -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-18 · **Change:** minor (G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-21 · **Change:** minor (G8: PSD type on a path opens on its path and saves back into the file's `Txt2`, #7962; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 @@ -82,7 +82,9 @@ what an agent can't finish alone. - **Estimate:** 80–140 h. ### G8. Type depth -- **Missing:** type on a path (TYPE-218-1), paragraph direction UI (TYPE-218-2), complex-script +- **Missing:** type on a path (TYPE-218-1: the Type tool clicking a path, the caret on the curve, + and PSD path text in a new document, which still saves as point text; Photoshop's path text + opens on its path and saves back into the file's `Txt2` since 2026-10-21, #7962), paragraph direction UI (TYPE-218-2), complex-script fallback fonts and golden tests (TYPE-218-3), OpenType Numerals and Stylistic Sets submenus (TYPE-218-5; the Character panel buttons landed 2026-10-11, #3752), live Warp Text preview (TYPE-218-7, #2689), "rasterize and continue" for distort/perspective on type @@ -274,6 +276,7 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| +| 2026-10-21 | minor | G8: Photoshop's type on a path opens on its path (read from the `Txt2` frame) and saves back into the file's `Txt2` object (#7962); TYPE-218-1 stays partial (new documents save path text as point text) | | 2026-10-15 | minor | G1 / #5972 A1: render only provably constant-RGB `GdFl` noise fills; variable noise synthesis remains open | | 2026-10-18 | minor | G9: with no selection, Copy takes fill and adjustment layers whole and Paste recreates them (#2344); UI-217-23 stays partial (a single pixel layer copies its pixels only); estimate unchanged | | 2026-10-14 | minor | G1: a PSD smart object's filter mask shows when the file opens (Photoshop stores the filtered pixels unmasked); export stores them that way too; Photoshop-oracle floor 185 → 188 of 258 | diff --git a/docs/scorecard.md b/docs/scorecard.md index 42ae824b4d..40f2b1bb4c 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -214,7 +214,7 @@ Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_w | Id | Target | Status | Issue | Note | |---|---|---|---|---| -| TYPE-218-1 | Type on a path: path shape, glyphs along the curve, caret follows, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip. Missing: clicking a path with the Type tool, the caret and selection following the curve, and PSD path text (it saves as point text) | +| TYPE-218-1 | Type on a path: path shape, glyphs along the curve, caret follows, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip; PSD path text opens on its path from its Txt2 frame and saves back into the file's Txt2 object (#7962). Missing: clicking a path with the Type tool, the caret and selection following the curve, and PSD path text in a file without Photoshop's Txt2 object for the layer (a new document saves it as point text) | | TYPE-218-2 | Paragraph direction (Auto/LTR/RTL) in the panel and options bar; visual RTL caret | missing | [#218](https://github.com/storytold/photocraft/issues/218) | Engine has TextDirection (text.rs:155); no UI | | TYPE-218-3 | Thai/Khmer/Indic fallback fonts; golden shaping tests for complex scripts and RTL | partial | [#218](https://github.com/storytold/photocraft/issues/218) | Fallback fonts are covered for Thai, Khmer, Lao, Myanmar (THAI_FAMILIES, KHMER_FAMILIES, LAO_FAMILIES, MYANMAR_FAMILIES in fonts.rs; #1909, #3259), the nine Indic scripts (INDIC_FAMILIES: Nirmala UI, Kohinoor and Sangam MN, Noto Sans) and Arabic and Hebrew. Still missing: per-script golden shaping tests against reference output (only smoke tests that an installed font shapes without .notdef, plus a bidi test) | | TYPE-218-4 | Variable font axis sliders from the font's axes; opsz follows the point size | done | [#218](https://github.com/storytold/photocraft/issues/218) | One slider per axis of the style's font in the Character section (Properties and Window > Character), setting type.setStyle variations; opsz follows the type size unless set (layout.rs variation_list); a style or weight resets the wght axis (#2985). PSD does not round-trip axis values yet | diff --git a/scorecard/type.toml b/scorecard/type.toml index ee8a876a41..632503cf33 100644 --- a/scorecard/type.toml +++ b/scorecard/type.toml @@ -9,7 +9,7 @@ id = "TYPE-218-1" target = "Type on a path: path shape, glyphs along the curve, caret follows, PSD round trip" status = "partial" issue = 218 -note = "TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip. Missing: clicking a path with the Type tool, the caret and selection following the curve, and PSD path text (it saves as point text)" +note = "TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip; PSD path text opens on its path from its Txt2 frame and saves back into the file's Txt2 object (#7962). Missing: clicking a path with the Type tool, the caret and selection following the curve, and PSD path text in a file without Photoshop's Txt2 object for the layer (a new document saves it as point text)" [[item]] id = "TYPE-218-2" From b105c6b47f49bfc8627162a7ff77c926d2cfc973 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Wed, 21 Oct 2026 02:37:32 -0400 Subject: [PATCH 174/649] Crop: Content-Aware Fill keeps the pixels a non-deleting crop hid (#8060) A frame pulled back out over pixels an earlier crop with Delete Cropped Pixels off hid treated everything past the old canvas as uncovered, so Content-Aware Fill painted over the hidden image. The fill now snapshots the target layer before the crop and counts its opaque pixels past the canvas as covered (kept and sampled), for unrotated and rotated crops. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/crop_fill.rs | 43 +++++++++++++++-- crates/engine/src/image_cmds.rs | 14 +++++- crates/engine/tests/crop_content_aware.rs | 58 +++++++++++++++++++++++ 3 files changed, 110 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/crop_fill.rs b/crates/engine/src/crop_fill.rs index 6ef0698cea..93b9dfa994 100644 --- a/crates/engine/src/crop_fill.rs +++ b/crates/engine/src/crop_fill.rs @@ -8,9 +8,15 @@ //! layers keep their transparency there, as after a plain crop. Each connected piece of the //! uncovered area (each corner, each edge strip) is filled on its own, with Photoshop's sampling //! window around that piece, and only pixels the image covers are sampled. +//! +//! The image is more than the old canvas: pixels an earlier crop with Delete Cropped Pixels off +//! hid past its edges are still the layer's, and the Crop tool shows them while the frame is +//! pulled out over them. They count as covered, so they are kept (and sampled) rather than filled +//! over (#8060). use photocraft_doc::{Document, LayerId}; use photocraft_geom::Rect; +use photocraft_raster::Surface; use rayon::prelude::*; use crate::{EngineError, Result}; @@ -22,7 +28,7 @@ const SEED: u64 = 1; const MAX_PIXELS: u64 = 400_000_000; /// Where the cropped canvas came from in the original document. -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Debug)] pub(crate) struct Coverage { /// Cropped canvas → original document: `[a, b, c, d, e, f]` with /// `x = a·u + b·v + e`, `y = c·u + d·v + f`. @@ -32,12 +38,22 @@ pub(crate) struct Coverage { pub height: f64, /// Whether the map rotates (its resampled edge is antialiased against the background colour). pub rotated: bool, + /// The filled layer's pixels before the crop (original document px), set by [`Coverage::holding`]: + /// where they lie past the old canvas they are hidden image, not uncovered area. + pub held: Option, } impl Coverage { /// An unrotated crop to `r` (original document px). pub fn crop(r: Rect, width: u32, height: u32) -> Self { - Coverage { map: [1.0, 0.0, 0.0, 1.0, f64::from(r.x0), f64::from(r.y0)], width: f64::from(width), height: f64::from(height), rotated: false } + Coverage { map: [1.0, 0.0, 0.0, 1.0, f64::from(r.x0), f64::from(r.y0)], width: f64::from(width), height: f64::from(height), rotated: false, held: None } + } + + /// Takes the pixels of the layer the fill will go to from `doc` before it is cropped (the + /// surface is shared, not copied), so hidden pixels past the old canvas count as covered. + pub fn holding(mut self, doc: &Document, active: Option) -> Self { + self.held = target_layer(doc, active).ok().and_then(|id| doc.layer(id)).and_then(|l| l.surface()).cloned(); + self } /// Whether the cropped canvas's pixel (u, v) is the original image's: its centre maps inside @@ -48,7 +64,28 @@ impl Coverage { let [a, b, c, d, e, f] = self.map; let (cu, cv) = (f64::from(u) + 0.5, f64::from(v) + 0.5); let (x, y) = (a * cu + b * cv + e, c * cu + d * cv + f); - x >= margin && y >= margin && x <= self.width - margin && y <= self.height - margin + (x >= margin && y >= margin && x <= self.width - margin && y <= self.height - margin) || self.holds(x, y) + } + + /// Whether the layer held an image pixel at original document point (x, y) past the canvas + /// (#8060): mostly opaque there and, for a rotated crop, one pixel around it too (the turned + /// edge is blended with the background colour, as at the canvas edge). Without an alpha channel + /// hidden pixels can't be told from empty ones: nothing is held. + fn holds(&self, x: f64, y: f64) -> bool { + let Some(surf) = &self.held else { return false }; + let format = surf.format(); + if !format.alpha || !(x.is_finite() && y.is_finite()) { + return false; + } + let a = surf.channels().saturating_sub(1); + let at = |x: f64, y: f64| { + let (fx, fy) = (x.floor(), y.floor()); + let limit = f64::from(i32::MAX); + fx.abs() < limit && fy.abs() < limit && surf.sample_channel(fx as i32, fy as i32, a) > 0.5 + }; + const ROUND: [(f64, f64); 5] = [(0.0, 0.0), (-1.0, 0.0), (1.0, 0.0), (0.0, -1.0), (0.0, 1.0)]; + let points = if self.rotated { &ROUND[..] } else { &ROUND[..1] }; + points.iter().all(|&(dx, dy)| at(x + dx, y + dy)) } fn margin(&self) -> f64 { diff --git a/crates/engine/src/image_cmds.rs b/crates/engine/src/image_cmds.rs index 6d5342b931..398c56ab2d 100644 --- a/crates/engine/src/image_cmds.rs +++ b/crates/engine/src/image_cmds.rs @@ -521,9 +521,11 @@ fn crop(s: &mut Session, p: &Value) -> Result { let extension = s.tools.background; s.edit("Crop", |doc, active| { let original = doc.size; + // Taken before the crop: the pixels a Delete Cropped Pixels off crop hid count as image (#8060). + let coverage = content_aware.then(|| crate::crop_fill::Coverage::crop(r, original.width, original.height).holding(doc, *active)); crop_doc(doc, "image.crop", r, delete, extension)?; - if content_aware { - crate::crop_fill::fill_uncovered(doc, *active, &crate::crop_fill::Coverage::crop(r, original.width, original.height))?; + if let Some(coverage) = &coverage { + crate::crop_fill::fill_uncovered(doc, *active, coverage)?; } doc.selection = None; target.apply(doc); @@ -666,6 +668,14 @@ fn rotated_crop(s: &mut Session, r: Rect, angle: f64, delete: bool, content_awar width: f64::from(size.width), height: f64::from(size.height), rotated: true, + held: None, + }; + // The pixels before the turn: a Delete Cropped Pixels off crop's hidden ones count as image (#8060). + let coverage = if content_aware { + let d = s.active().ok_or(EngineError::NoDocument)?; + coverage.holding(&d.doc, d.active_layer) + } else { + coverage }; crate::analysis_cmds::compound(s, "Crop", |s| { // Pixels the crop deletes needn't be turned first: keeping only what lands in the frame diff --git a/crates/engine/tests/crop_content_aware.rs b/crates/engine/tests/crop_content_aware.rs index f41d46a9b5..c9f6c34ff7 100644 --- a/crates/engine/tests/crop_content_aware.rs +++ b/crates/engine/tests/crop_content_aware.rs @@ -157,3 +157,61 @@ fn bad_params_and_unfillable_crops_fail_cleanly() { assert_eq!(s.active().unwrap().history.past_len(), past, "{p}"); } } + +/// `doc` with its left 16 columns red, then cropped to x = 16 keeping the cropped pixels: the red +/// lies hidden past the canvas's left edge. +fn hidden_red(background: &str) -> Session { + let mut s = doc("rgb", 8, background); + s.execute("tools.setColors", json!({"foreground": "#ff0000", "background": "#000000"})).unwrap(); + s.execute("select.rect", json!({"x": 0, "y": 0, "width": 16, "height": 48})).unwrap(); + s.execute("edit.fill", json!({"contents": "foreground"})).unwrap(); + s.execute("select.deselect", json!({})).unwrap(); + s.execute("image.crop", json!({"x": 16, "y": 0, "width": 48, "height": 48, "deleteCroppedPixels": false})).unwrap(); + assert_eq!(size(&s), (48, 48)); + s +} + +const RED: [f32; 4] = [1.0, 0.0, 0.0, 1.0]; + +/// A frame pulled back out over pixels a Delete Cropped Pixels off crop hid keeps them: only what +/// lies past them is filled (#8060). Before, the whole strip past the old canvas was filled over. +#[test] +fn extending_crop_keeps_the_hidden_pixels() { + let mut s = hidden_red("transparent"); + let green = layer(&s).rgba(24, 24); + crop(&mut s, json!({"x": -24, "y": 0, "width": 72, "height": 48, "deleteCroppedPixels": false}), true).unwrap(); + assert_eq!(size(&s), (72, 48)); + let surf = layer(&s); + for y in 0..48 { + for x in 8..24 { + assert_eq!(surf.rgba(x, y), RED, "the hidden red at ({x}, {y}) is kept"); + } + for x in 0..8 { + let px = surf.rgba(x, y); + assert!(px[3] > 0.99, "past the hidden pixels ({x}, {y}) is filled: {px:?}"); + } + assert!(close(surf.rgba(40, y), green, 1e-6), "the canvas is unchanged"); + } +} + +/// A turned frame that reaches over the Background's hidden pixels shows them, not a fill +/// from the canvas (#8060). +#[test] +fn rotated_crop_keeps_the_hidden_pixels() { + let mut s = hidden_red("white"); + // A diamond on the canvas's left edge: its left half lies over the hidden red, all of it inside + // the turned canvas (so nothing takes the background colour). + crop(&mut s, json!({"x": -10, "y": 14, "width": 20, "height": 20, "angle": 45, "deleteCroppedPixels": false}), true).unwrap(); + assert_eq!(size(&s), (20, 20)); + let (w, h) = size(&s); + let surf = layer(&s); + let mut red = 0; + for y in 0..h as i32 { + for x in 0..w as i32 { + let px = surf.rgba(x, y); + assert!(px[0] > 0.5 && px[3] > 0.99, "no background colour or transparency at ({x}, {y}): {px:?}"); + red += usize::from(close(px, RED, 0.06)); + } + } + assert!(red >= 100, "the hidden red shows in the turned frame: {red} red pixels"); +} From b65e0af1979a0f338e3e1fa05702a42feaf3ed73 Mon Sep 17 00:00:00 2001 From: VishnuByrraju Date: Wed, 21 Oct 2026 12:11:59 +0530 Subject: [PATCH 175/649] fix(actions): strict .atn export keeps Apply Image's flat source fields (#7197) --- crates/engine/src/atn_cmds.rs | 8 +++++++- crates/engine/src/atn_cmds/tests.rs | 20 ++++++++++++++++++++ crates/engine/src/channel_cmds.rs | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/atn_cmds.rs b/crates/engine/src/atn_cmds.rs index 9e8eb6cb7c..811d1dbc5e 100644 --- a/crates/engine/src/atn_cmds.rs +++ b/crates/engine/src/atn_cmds.rs @@ -1736,7 +1736,13 @@ fn apply_image_from(d: &Descriptor) -> Mapped { } fn apply_image_to(_: &str, p: &Value) -> Option { - let source = p.get("source").cloned().unwrap_or(json!({})); + // The Apply Image dialog sends flat `sourceLayer`/`sourceChannel`/`sourceInvert` fields; read + // them as the command does, or the export would quietly reset them to the merged composite. + let source = crate::channel_cmds::source_spec(p, "source", "source").unwrap_or(json!({})); + // A source from another open document has no event form here: skip the step, don't rewrite it. + if source.get("document").is_some_and(|d| !d.is_null()) { + return None; + } let channel = jstr(&source, "channel").unwrap_or("composite"); let chan = lookup_back(SOURCE_CHANNELS, channel).or_else(|| lookup_back(CHANNELS, channel))?; let mut items = vec![ReferenceItem::Enumerated { class: class("Chnl"), type_id: code("Chnl"), value: code(chan) }]; diff --git a/crates/engine/src/atn_cmds/tests.rs b/crates/engine/src/atn_cmds/tests.rs index 26865d4060..bbcef0ad54 100644 --- a/crates/engine/src/atn_cmds/tests.rs +++ b/crates/engine/src/atn_cmds/tests.rs @@ -1387,3 +1387,23 @@ fn function_keys_keep_shift_and_command() { } assert_eq!(super::function_key_name(7, false, false), "F7"); } + +/// The Apply Image dialog's flat source fields keep their meaning through a strict `.atn` export +/// (#7197): they used to come back as the merged composite. +#[test] +fn apply_image_flat_source_fields_survive_a_strict_export() { + let flat = json!({"sourceLayer": "Pixels", "sourceChannel": "green", "sourceInvert": true, "blending": "normal", "opacity": 75}); + let item = export_item("image.applyImage", &flat, "S").expect("the flat form exports"); + let event = event_for(&item.event).expect("a known event"); + let Mapped::Steps(steps) = (event.from)(item.descriptor.as_ref().unwrap()) else { panic!("does not import back") }; + assert_eq!(steps.len(), 1); + assert_eq!(steps[0].1["source"], json!({"layer": "Pixels", "channel": "green", "invert": true})); + // The nested form is unchanged, and the "merged" layer of a flat form stays merged. + let merged = json!({"sourceLayer": "merged", "sourceChannel": "red"}); + let item = export_item("image.applyImage", &merged, "S").expect("exports"); + let Mapped::Steps(steps) = (event.from)(item.descriptor.as_ref().unwrap()) else { panic!("does not import back") }; + assert_eq!(steps[0].1["source"], json!({"layer": "merged", "channel": "red"})); + // A source in another document cannot be written: the step is skipped, not rewritten. + assert!(export_item("image.applyImage", &json!({"source": {"document": "Other", "channel": "red"}}), "S").is_none()); + assert!(export_item("image.applyImage", &json!({"sourceDocument": "Other"}), "S").is_none()); +} diff --git a/crates/engine/src/channel_cmds.rs b/crates/engine/src/channel_cmds.rs index 991f40dc0b..91dc94c7e4 100644 --- a/crates/engine/src/channel_cmds.rs +++ b/crates/engine/src/channel_cmds.rs @@ -569,7 +569,7 @@ impl Blending { /// A source spec from `p[key]`, or from flat `Document` / `Layer` / /// `Channel` / `Invert` keys (what the generic dialog form sends). -fn source_spec(p: &Value, key: &str, prefix: &str) -> Option { +pub(crate) fn source_spec(p: &Value, key: &str, prefix: &str) -> Option { if let Some(v) = p.get(key) { return Some(v.clone()); } From 909c0346869c23445aa1e8e5bbd7ba887ca9915b Mon Sep 17 00:00:00 2001 From: paulou-jpg <79102098+paulou-jpg@users.noreply.github.com> Date: Wed, 14 Oct 2026 01:46:02 -0700 Subject: [PATCH 176/649] Blend mode keys: Shift+Alt+letter picks a mode, as in Photoshop Shift+Alt plus Photoshop's letter (N Normal, M Multiply, S Screen, O Overlay, R Clear, P Pass Through...) sets the blend mode. With the Brush, Pencil or Gradient it sets that tool's mode and never the layer's; with a non-painting tool it sets every selected layer in one undo step. Pass Through applies to groups only, Clear to Brush and Pencil only, and the Background is skipped. The typed letter wins, so German Z is still Pin Light; the physical key is the fallback for the characters Option types on a Mac. Shift+Plus/Minus now also step every selected layer, and Brush/Pencil cycling includes Clear after Dissolve, as in the options-bar dropdown. Fixes Shift+Alt+tool letter switching tools: the tool-letter loop's consume_key ignores extra modifiers, so blend_keys now runs before it. Not yet: Behind (Shift+Alt+Q does nothing), and the painting tools without an options-bar Mode (Clone Stamp, Healing, Paint Bucket...) ignore the keys. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/blend_keys.rs | 368 ++++++++++++++++++++++++++++--- crates/ui-egui/src/shortcuts.rs | 5 +- docs/scorecard.md | 2 +- docs/ui-parity.md | 4 +- scorecard/ui.toml | 2 +- 5 files changed, 340 insertions(+), 41 deletions(-) diff --git a/crates/ui-egui/src/blend_keys.rs b/crates/ui-egui/src/blend_keys.rs index d68bc79a11..b047330a66 100644 --- a/crates/ui-egui/src/blend_keys.rs +++ b/crates/ui-egui/src/blend_keys.rs @@ -1,8 +1,12 @@ -//! ⇧+ and ⇧− step through the blend modes, as in Photoshop (#3102): the Brush's or Pencil's mode -//! while one of them is active, the Gradient's with the Gradient tool, and otherwise (Move, the -//! selection tools…) the active layer's. The list wraps at either end. Each press is one call of -//! an engine command (`tools.setBrush`, `layer.setProps`), so it records and undoes like a pick -//! from the dropdown. +//! Blend mode keys, as in Photoshop. ⇧+ and ⇧− step through the modes (#3102), and ⇧⌥ plus a +//! letter picks one (⇧⌥M Multiply, ⇧⌥S Screen…). With a painting tool that has a mode of its own +//! they set that tool's mode and never the layer's: the Brush's or Pencil's (which also offer +//! Clear), the Gradient's; the other painting tools are left alone until their options bar has a +//! Mode. With any other tool (Move, the selection tools…) they set every selected layer's mode. +//! The step list wraps at either end. Each press is one call of an engine command per layer +//! (`tools.setBrush`, `layer.setProps`), coalesced into one undo step. + +use std::sync::atomic::{AtomicU64, Ordering}; use egui::{Event, Key}; use photocraft_color::BlendMode; @@ -13,7 +17,7 @@ use crate::state::Tool; /// The mode `step` places after (or before, when negative) `current` in `modes`, wrapping around. /// A mode that isn't listed steps from the top of the list. -pub fn stepped(modes: &[BlendMode], current: BlendMode, step: i32) -> Option { +pub fn stepped(modes: &[T], current: T, step: i32) -> Option { let n = i32::try_from(modes.len()).ok().filter(|n| *n > 0)?; let at = modes.iter().position(|m| *m == current).and_then(|i| i32::try_from(i).ok()); let next = match at { @@ -24,52 +28,180 @@ pub fn stepped(modes: &[BlendMode], current: BlendMode, step: i32) -> Option Option { + use BlendMode as B; + Some(Pick::Mode(match key { + Key::N => B::Normal, + Key::I => B::Dissolve, + Key::Q => return Some(Pick::Behind), + Key::R => return Some(Pick::Clear), + Key::P => B::PassThrough, + Key::K => B::Darken, + Key::M => B::Multiply, + Key::B => B::ColorBurn, + Key::A => B::LinearBurn, + Key::G => B::Lighten, + Key::S => B::Screen, + Key::D => B::ColorDodge, + Key::W => B::LinearDodge, + Key::O => B::Overlay, + Key::F => B::SoftLight, + Key::H => B::HardLight, + Key::V => B::VividLight, + Key::J => B::LinearLight, + Key::Z => B::PinLight, + Key::L => B::HardMix, + Key::E => B::Difference, + Key::X => B::Exclusion, + Key::U => B::Hue, + Key::T => B::Saturation, + Key::C => B::Color, + Key::Y => B::Luminosity, + _ => return None, + })) +} + +/// One key's request: a step through the list, or a mode picked by letter. +enum Press { + Step(i32), + Pick(Pick), +} + /// Consumes this frame's ⇧+ / ⇧− presses (⇧= on a US layout is `+`; on a German one -/// `layout_keys::apply` has already turned ⇧+ and ⇧- into `+` and `-`) and applies them. +/// `layout_keys::apply` has already turned ⇧+ and ⇧- into `+` and `-`) and ⇧⌥ letters, and +/// applies them. Runs before the tool letters, which would otherwise take ⇧⌥M as M. pub fn handle(app: &mut PhotocraftApp, ctx: &egui::Context) { - let steps: Vec = ctx.input_mut(|i| { + let presses: Vec = ctx.input_mut(|i| { let mut out = Vec::new(); i.events.retain(|e| match e { - Event::Key { key, pressed: true, modifiers, .. } if modifiers.shift && !modifiers.command && !modifiers.ctrl && !modifiers.alt => { - let step = match key { - Key::Plus | Key::Equals => 1, - Key::Minus => -1, - _ => return true, - }; - out.push(step); + Event::Key { key, physical_key, pressed: true, modifiers, .. } if modifiers.shift && !modifiers.command && !modifiers.ctrl => { + if modifiers.alt { + // The layout's letter (⇧⌥Z on a German keyboard is Pin Light), else the + // physical one: on a Mac ⌥ turns the letter into another character (⇧⌥M + // types Â) that may arrive as some other key. + match letter_pick(*key).or_else(|| physical_key.and_then(letter_pick)) { + Some(p) => out.push(Press::Pick(p)), + None => return true, + } + } else { + match key { + Key::Plus | Key::Equals => out.push(Press::Step(1)), + Key::Minus => out.push(Press::Step(-1)), + _ => return true, + } + } false } _ => true, }); out }); - for step in steps { - press(app, step); + for p in presses { + match p { + Press::Step(step) => press(app, step), + Press::Pick(pick) => pick_mode(app, pick), + } } } -/// One ⇧+ (`step` 1) or ⇧− (`step` -1) press. +/// Where the active tool's blend mode keys go. +enum Target { + /// The Brush's or Pencil's mode, Clear included. + Paint, + Gradient, + /// A painting tool whose mode has no options-bar control yet (or the Eraser, which has none): + /// the keys do nothing, and never reach the layer. + Nothing, + Layers, +} + +fn target(tool: Tool) -> Target { + match tool { + Tool::Brush | Tool::Pencil => Target::Paint, + Tool::Gradient => Target::Gradient, + t if t.is_brushlike() || t == Tool::MagicEraser || t == Tool::PaintBucket => Target::Nothing, + _ => Target::Layers, + } +} + +/// The Brush's or Pencil's mode list: the layer modes with Clear (`None`) after Dissolve, as in +/// its options-bar dropdown. +fn paint_modes() -> Vec> { + let mut modes: Vec> = BlendMode::LAYER_MODES.iter().copied().map(Some).collect(); + let at = modes.iter().position(|m| *m == Some(BlendMode::Dissolve)).map_or(modes.len(), |i| i + 1); + modes.insert(at, None); + modes +} + +/// The Brush's or Pencil's Clear flag. +fn clear_flag(app: &mut PhotocraftApp) -> &mut bool { + if app.ui.tool == Tool::Pencil { &mut app.ui.tool_options.pencil_clear } else { &mut app.ui.tool_options.brush_clear } +} + +/// Sets the Brush's or Pencil's mode; `None` is Clear. +fn set_paint_mode(app: &mut PhotocraftApp, mode: Option) { + *clear_flag(app) = mode.is_none(); + if let Some(m) = mode + && let Ok(m) = serde_json::to_value(m) + { + let _ = app.run("tools.setBrush", json!({ "brush": { "mode": m } })); + } +} + +fn set_gradient_mode(app: &mut PhotocraftApp, mode: BlendMode) { + let before = app.ui.tool_options.clone(); + app.ui.tool_options.gradient_blend_mode = mode; + // Live mode: a selected gradient fill layer follows, as with the dropdown. + crate::gradient_ui::options_changed(app, &before); +} + +/// Sets `mode` on every selected layer that can take it, in one undo step: the locked Background +/// has no blend mode, and only groups pass through. +fn set_layers_mode(app: &mut PhotocraftApp, mode: BlendMode) { + static PRESSES: AtomicU64 = AtomicU64::new(0); + let Some(st) = app.session.active() else { return }; + let ids: Vec<_> = st + .selected_layers() + .into_iter() + .filter_map(|id| st.doc.layer(id)) + .filter(|l| !crate::doc_props_ui::is_background(&st.doc, l) && (mode != BlendMode::PassThrough || l.is_group()) && l.blend != mode) + .map(|l| l.id) + .collect(); + let coalesce = format!("blend-keys-{}", PRESSES.fetch_add(1, Ordering::Relaxed)); + for id in ids { + let _ = app.run("layer.setProps", json!({ "layer": id.0, "blend": mode.label(), "coalesce": coalesce })); + } +} + +/// One ⇧+ (`step` 1) or ⇧− (`step` -1) press. Selected layers all take the mode after the active +/// layer's. pub fn press(app: &mut PhotocraftApp, step: i32) { - match app.ui.tool { - Tool::Brush | Tool::Pencil => { - let current = app.session.tools.brush.mode; - if let Some(mode) = stepped(&BlendMode::LAYER_MODES, current, step) - && let Ok(mode) = serde_json::to_value(mode) - { - let _ = app.run("tools.setBrush", json!({ "brush": { "mode": mode } })); + match target(app.ui.tool) { + Target::Paint => { + let current = if *clear_flag(app) { None } else { Some(app.session.tools.brush.mode) }; + if let Some(mode) = stepped(&paint_modes(), current, step) { + set_paint_mode(app, mode); } } - Tool::Gradient => { - let before = app.ui.tool_options.clone(); - if let Some(mode) = stepped(&BlendMode::LAYER_MODES, before.gradient_blend_mode, step) { - app.ui.tool_options.gradient_blend_mode = mode; - // Live mode: a selected gradient fill layer follows, as with the dropdown. - crate::gradient_ui::options_changed(app, &before); + Target::Gradient => { + if let Some(mode) = stepped(&BlendMode::LAYER_MODES, app.ui.tool_options.gradient_blend_mode, step) { + set_gradient_mode(app, mode); } } - // Their blend mode isn't the brush's (the Eraser has none): leave them alone. - t if t.is_brushlike() || t == Tool::MagicEraser || t == Tool::PaintBucket => {} - _ => { + Target::Nothing => {} + Target::Layers => { let Some(st) = app.session.active() else { return }; let Some(layer) = st.active_layer.and_then(|id| st.doc.layer(id)) else { return }; // The locked Background has no blend mode. @@ -78,13 +210,24 @@ pub fn press(app: &mut PhotocraftApp, step: i32) { } let modes: Vec = std::iter::once(BlendMode::PassThrough).filter(|_| layer.is_group()).chain(BlendMode::LAYER_MODES).collect(); if let Some(mode) = stepped(&modes, layer.blend, step) { - let id = layer.id.0; - let _ = app.run("layer.setProps", json!({ "layer": id, "blend": mode.label() })); + set_layers_mode(app, mode); } } } } +/// One ⇧⌥ letter press. A mode the target doesn't have (Clear or Behind for layers, Pass Through +/// for a painting tool) does nothing. +pub fn pick_mode(app: &mut PhotocraftApp, pick: Pick) { + match (target(app.ui.tool), pick) { + (Target::Paint, Pick::Mode(m)) if m != BlendMode::PassThrough => set_paint_mode(app, Some(m)), + (Target::Paint, Pick::Clear) => set_paint_mode(app, None), + (Target::Gradient, Pick::Mode(m)) if m != BlendMode::PassThrough => set_gradient_mode(app, m), + (Target::Layers, Pick::Mode(m)) => set_layers_mode(app, m), + _ => {} + } +} + #[cfg(test)] mod tests { use super::*; @@ -180,4 +323,157 @@ mod tests { let mut none = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); press(&mut none, 1); } + + /// Feeds one ⇧⌥ press of `key`, reported by the platform as `physical` too. + fn alt_shift(app: &mut PhotocraftApp, ctx: &egui::Context, key: Key, physical: Key) { + let m = egui::Modifiers::SHIFT | egui::Modifiers::ALT; + let raw = egui::RawInput { + events: vec![egui::Event::ModifiersChanged(m), egui::Event::Key { key, physical_key: Some(physical), pressed: true, repeat: false, modifiers: m }], + ..Default::default() + }; + ctx.begin_pass(raw); + crate::shortcuts::handle(app, ctx); + ctx.end_pass().textures_delta.clear(); + } + + fn blend_of(app: &PhotocraftApp, i: usize) -> BlendMode { + app.session.active().unwrap().doc.layers[i].blend + } + + /// Photoshop's letters: 26 keys, each a different mode, and the four modes without one. + #[test] + fn every_letter_picks_its_own_mode() { + let keys: Vec = "NIQRPKMBAGSDWOFHVJZLEXUTCY".chars().filter_map(|c| Key::from_name(&c.to_string())).collect(); + assert_eq!(keys.len(), 26); + let picks: Vec = keys.iter().filter_map(|k| letter_pick(*k)).collect(); + assert_eq!(picks.len(), keys.len()); + for (i, p) in picks.iter().enumerate() { + assert!(!picks[..i].contains(p), "{p:?} has two letters"); + } + assert_eq!(letter_pick(Key::M), Some(Pick::Mode(BlendMode::Multiply))); + assert_eq!(letter_pick(Key::W), Some(Pick::Mode(BlendMode::LinearDodge))); + assert_eq!(letter_pick(Key::Y), Some(Pick::Mode(BlendMode::Luminosity))); + for m in [BlendMode::DarkerColor, BlendMode::LighterColor, BlendMode::Subtract, BlendMode::Divide] { + assert!(!picks.contains(&Pick::Mode(m)), "{m:?} has no letter in Photoshop"); + } + for k in [Key::Num1, Key::Space] { + assert_eq!(letter_pick(k), None); + } + } + + /// With the Move tool ⇧⌥M makes the active layer Multiply in one undo step, and doesn't switch + /// to the Marquee tool's M. Clear and Behind are painting modes: a layer ignores them. + #[test] + fn alt_shift_letter_sets_the_layer_mode_and_keeps_the_tool() { + let ctx = egui::Context::default(); + let mut a = app(Tool::Move); + let undo = a.session.active().unwrap().history.past_len(); + alt_shift(&mut a, &ctx, Key::M, Key::M); + assert_eq!(layer_blend(&a), BlendMode::Multiply); + assert_eq!(a.ui.tool, Tool::Move, "not the Marquee tool"); + assert_eq!(a.session.active().unwrap().history.past_len(), undo + 1); + alt_shift(&mut a, &ctx, Key::R, Key::R); + alt_shift(&mut a, &ctx, Key::Q, Key::Q); + alt_shift(&mut a, &ctx, Key::P, Key::P); + assert_eq!(layer_blend(&a), BlendMode::Multiply, "no Clear, Behind or Pass Through on a layer"); + assert_eq!(a.ui.tool, Tool::Move); + // ⇧⌥ letters that are tool keys pick modes too. + alt_shift(&mut a, &ctx, Key::S, Key::S); + assert_eq!(layer_blend(&a), BlendMode::Screen); + assert_eq!(a.ui.tool, Tool::Move); + } + + /// A Mac's ⌥ turns the letter into another character; egui then reports the physical key. + /// A German layout's Z (physical Y) is still Pin Light: the typed letter wins. + #[test] + fn the_typed_letter_wins_and_the_physical_key_is_the_fallback() { + let ctx = egui::Context::default(); + let mut a = app(Tool::Move); + alt_shift(&mut a, &ctx, Key::Backtick, Key::O); + assert_eq!(layer_blend(&a), BlendMode::Overlay); + alt_shift(&mut a, &ctx, Key::Z, Key::Y); + assert_eq!(layer_blend(&a), BlendMode::PinLight); + } + + /// Every selected layer takes the mode, all in one undo step; the Background keeps Normal. + /// ⇧+ steps them all to the mode after the active layer's. + #[test] + fn mode_keys_set_every_selected_layer_in_one_undo_step() { + let ctx = egui::Context::default(); + let mut a = app(Tool::Move); + let ids: Vec = a.session.active().unwrap().doc.layers.iter().map(|l| l.id.0).collect(); + a.run("layer.new.layer", json!({})).unwrap(); + for id in &ids { + a.run("layer.select", json!({"layer": id, "mode": "add"})).unwrap(); + } + assert_eq!(a.session.active().unwrap().selected_layers().len(), 3); + let undo = a.session.active().unwrap().history.past_len(); + alt_shift(&mut a, &ctx, Key::S, Key::S); + assert_eq!([blend_of(&a, 0), blend_of(&a, 1), blend_of(&a, 2)], [BlendMode::Normal, BlendMode::Screen, BlendMode::Screen]); + assert_eq!(a.session.active().unwrap().history.past_len(), undo + 1, "one undo step for both layers"); + key(&mut a, &ctx, Key::Plus, egui::Modifiers::SHIFT); + assert_eq!([blend_of(&a, 1), blend_of(&a, 2)], [BlendMode::ColorDodge, BlendMode::ColorDodge]); + assert_eq!(a.session.active().unwrap().history.past_len(), undo + 2); + a.session.undo(); + assert_eq!([blend_of(&a, 1), blend_of(&a, 2)], [BlendMode::Screen, BlendMode::Screen]); + } + + /// ⇧⌥P is Pass Through, for groups only. + #[test] + fn pass_through_is_for_groups() { + let ctx = egui::Context::default(); + let mut a = app(Tool::Move); + a.run("layer.new.group", json!({})).unwrap(); + alt_shift(&mut a, &ctx, Key::N, Key::N); + assert_eq!(layer_blend(&a), BlendMode::Normal); + alt_shift(&mut a, &ctx, Key::P, Key::P); + assert_eq!(layer_blend(&a), BlendMode::PassThrough); + } + + /// With the Brush the letters set the brush's mode, Clear included, and never the layer's; + /// ⇧+ from Dissolve reaches Clear, as in the dropdown. The Pencil keeps its own Clear. + #[test] + fn with_a_painting_tool_the_letters_set_only_its_mode() { + let ctx = egui::Context::default(); + let mut a = app(Tool::Brush); + alt_shift(&mut a, &ctx, Key::M, Key::M); + assert_eq!(a.session.tools.brush.mode, BlendMode::Multiply); + assert_eq!(layer_blend(&a), BlendMode::Normal, "the layer is untouched"); + assert_eq!(a.ui.tool, Tool::Brush); + alt_shift(&mut a, &ctx, Key::R, Key::R); + assert!(a.ui.tool_options.brush_clear); + alt_shift(&mut a, &ctx, Key::P, Key::P); + assert!(a.ui.tool_options.brush_clear, "no Pass Through for a brush"); + alt_shift(&mut a, &ctx, Key::I, Key::I); + assert!(!a.ui.tool_options.brush_clear); + assert_eq!(a.session.tools.brush.mode, BlendMode::Dissolve); + key(&mut a, &ctx, Key::Plus, egui::Modifiers::SHIFT); + assert!(a.ui.tool_options.brush_clear, "Clear follows Dissolve"); + key(&mut a, &ctx, Key::Plus, egui::Modifiers::SHIFT); + assert!(!a.ui.tool_options.brush_clear); + assert_eq!(a.session.tools.brush.mode, BlendMode::Darken); + assert!(!a.ui.tool_options.pencil_clear); + a.ui.tool = Tool::Pencil; + alt_shift(&mut a, &ctx, Key::R, Key::R); + assert!(a.ui.tool_options.pencil_clear); + assert_eq!(layer_blend(&a), BlendMode::Normal); + } + + /// The Gradient takes the letters; a painting tool without a Mode control yet (Clone Stamp) + /// ignores them rather than changing the layer. + #[test] + fn gradient_takes_the_letters_and_clone_stamp_ignores_them() { + let ctx = egui::Context::default(); + let mut a = app(Tool::Gradient); + alt_shift(&mut a, &ctx, Key::O, Key::O); + assert_eq!(a.ui.tool_options.gradient_blend_mode, BlendMode::Overlay); + alt_shift(&mut a, &ctx, Key::R, Key::R); + assert_eq!(a.ui.tool_options.gradient_blend_mode, BlendMode::Overlay); + a.ui.tool = Tool::CloneStamp; + alt_shift(&mut a, &ctx, Key::M, Key::M); + assert_eq!(layer_blend(&a), BlendMode::Normal); + assert_eq!(a.ui.tool, Tool::CloneStamp); + let mut none = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + pick_mode(&mut none, Pick::Mode(BlendMode::Multiply)); + } } diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rs index 1ad8d6d92a..d9d846f8a6 100644 --- a/crates/ui-egui/src/shortcuts.rs +++ b/crates/ui-egui/src/shortcuts.rs @@ -673,6 +673,9 @@ pub fn handle(app: &mut PhotocraftApp, ctx: &egui::Context) { } return; } + // ⇧+ / ⇧− step the blend mode and ⇧⌥ letters pick one (`blend_keys`). Before the tool + // letters: `consume_key` ignores extra ⇧ and ⌥, so ⇧⌥M would otherwise pick a tool. + crate::blend_keys::handle(app, ctx); // Tool keys; pressing the key of the current group cycles within it. With Preferences › // Tools › Use Shift Key for Tool Switch, only ⇧+key cycles and the plain key keeps the // group's current tool. From another group, the key picks the group's last-used tool. @@ -706,8 +709,6 @@ pub fn handle(app: &mut PhotocraftApp, ctx: &egui::Context) { } // 1–0 set opacity, ⇧1–0 flow or fill (`opacity_keys`). crate::opacity_keys::handle(app, ctx); - // ⇧+ / ⇧− step the blend mode (`blend_keys`). - crate::blend_keys::handle(app, ctx); } #[cfg(test)] diff --git a/docs/scorecard.md b/docs/scorecard.md index 42ae824b4d..6e928d793b 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -199,7 +199,7 @@ Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_w | UI-217-11 | Soft dark and soft light themes with picker previews; outlined knobs in light themes | partial | [#217](https://github.com/storytold/photocraft/issues/217) | theme.rs ThemeKind has fourteen themes: the twelve earlier ones plus Soft Dark and Soft Light (low-contrast Studio-layout palettes, text at 4.5:1, selectable in Preferences with the existing theme-card previews, ui.set {theme}, Window > Theme); outlined knobs in the light themes are still missing | | UI-217-12 | Save custom New Document presets; a real Recent category | done | [#217](https://github.com/storytold/photocraft/issues/217) | document_preset_cmds.rs and new_doc_ui.rs: named presets save/select/delete through preferences; Recent lists Clipboard, the last 20 documents created in the dialog (document.recent.*, persisted with the presets, newest first, deduplicated) and the uncovered defaults (#3131); created_documents_fill_the_recent_category | | UI-217-13 | Numeric fields accept arithmetic and units; scrubby labels; double-click resets a slider | done | [#217](https://github.com/storytold/photocraft/issues/217) | widgets::value_field: arithmetic plus units (1in, 5mm, 72pt, 50%) converted at the document resolution (#3099); widgets::scrub_label makes options-bar, slider-row and Character labels scrubby (Shift x10, Alt fine); slider rows with a known default reset on double-click | -| UI-217-14 | Layers panel: wheel steps blend modes, drop on New/Trash duplicates/deletes, checker behind art | done | [#217](https://github.com/storytold/photocraft/issues/217) | panels.rs: the wheel steps the blend-mode dropdown (widgets::dropdown_wheel_hovered, #1747); rows dropped on New Layer/Group/Delete duplicate/group/delete them (footer_drop, #736), effect rows dropped on Delete delete that effect or the whole style (fx_trash_drop, #3102); pixel thumbnails draw widgets::checker behind the art; Shift+Plus/Minus step the layer's or the painting tool's blend mode (blend_keys.rs, #3102) | +| UI-217-14 | Layers panel: wheel steps blend modes, drop on New/Trash duplicates/deletes, checker behind art | done | [#217](https://github.com/storytold/photocraft/issues/217) | panels.rs: the wheel steps the blend-mode dropdown (widgets::dropdown_wheel_hovered, #1747); rows dropped on New Layer/Group/Delete duplicate/group/delete them (footer_drop, #736), effect rows dropped on Delete delete that effect or the whole style (fx_trash_drop, #3102); pixel thumbnails draw widgets::checker behind the art; Shift+Plus/Minus step the layer's or the painting tool's blend mode (blend_keys.rs, #3102), and Shift+Alt+letter picks one (Photoshop's letters; every selected layer, one undo step) | | UI-217-15 | Curves: smoothing / pencil mode, black/grey/white eyedroppers, tooltips | done | [#217](https://github.com/storytold/photocraft/issues/217) | Curves editor (adjust_editors.rs, dialog and Properties): Edit points / Draw (pencil) buttons and Smooth, all with tooltips; pencil curves are 256-level maps (Adjustment::Curves pencil, params pencil/smooth, PSD curv map form and smart-filter Mpng; #3088). Set Black/Neutral Gray/White Point eyedroppers in the Image > Adjustments > Curves dialog (adjust_dialog.rs, #873) and in a Curves adjustment layer's Properties panel (layer_picker.rs: a click on the image is one layer.setAdjustment with the eyedropper param, sampling below the layer; Esc or another tool disarms; #3110) | | UI-217-16 | Hue/Saturation: Saturation and Lightness sliders get hue-following colour tracks | done | [#217](https://github.com/storytold/photocraft/issues/217) | saturation_track/lightness_track (adjust_editors.rs): grey -> the hue and black -> the hue -> white, recolouring as the Hue slider moves; saturation_and_lightness_tracks_follow_the_hue | | UI-217-17 | Color panel: wheel plus RGB/HSB/CMYK/Lab/Gray/Web slider modes; resizes with its group | missing | [#217](https://github.com/storytold/photocraft/issues/217) | panels.rs:1837 single field + hex/RGB readout | diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 793f09840c..7e53ba4c45 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI parity: tools, handles, modifiers and feel -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-15 · **Change:** minor (Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-15 · **Change:** minor (⇧⌥ blend mode letters; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; 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, @@ -195,6 +195,7 @@ Triangle and Curvature Pen (minus legacy Rounded Rectangle and Targeted Adjustme | Tool keys: ← / → turn the brush tip (1°, ⇧ 15°), ⇧-click with Type starts new text over old, Space+F / ⇧Space+F cycle the pasteboard colour | done (2026-10-11) | | | Type formatting keys while editing text | done: ⇧⌘K, U, B, I and / toggle All Caps, Underline, Faux Bold, Faux Italic, Strikethrough (off when every selected character has it, else on); ⌥↑/↓ leading ∓2 pt, ⇧⌥↑/↓ baseline shift ±2 pt (10 with ⌘); ⌥←/→ tracking ±20 over a selection (100 with ⌘; a collapsed caret still kerns); ⌥⇧⌘H toggles Hyphenate for the touched paragraphs. One `type.setStyle` step per press (new `leadingBy`/`baselineShiftBy`/`trackingBy`; auto leading starts from its laid-out value); the global ⇧⌘K/U/B/I never fire while typing. Differs: a collapsed caret in non-empty text changes nothing, since the model can't hold a pending style for the next characters typed (empty text takes it as its typing style) (`type_tool.rs`, `input_tests.rs` `type_tool_format_keys_*`) | | | Guides: click selects, Delete deletes, right-click menu, ⌥-click turns a guide, double-click opens Guides, Grid & Slices | done (2026-10-12) | | +| Blend mode keys: ⇧⌥ + letter picks a mode (N Normal, I Dissolve, R Clear, P Pass Through, K M B A darken, G S D W lighten, O F H V J Z L contrast, E X difference, U T C Y component), ⇧+ / ⇧− step through them | done (2026-10-14): Brush, Pencil and Gradient take them as their own mode (Clear on Brush and Pencil only), any non-painting tool sets every selected layer in one undo step (Pass Through on groups only; the Background is skipped); the typed letter wins, the physical key is the fallback for ⌥ characters on a Mac. ⇧⌥ letters no longer switch tools. Differs: Behind (⇧⌥Q) is not implemented; Clone Stamp, Pattern Stamp, History Brush, Healing, Paint Bucket and Magic Eraser ignore the keys until their options bar has a Mode | `blend_keys.rs` | ## Panels and workspace @@ -257,3 +258,4 @@ Paragraph; the rest open as in-app floating windows. | 2026-10-14 | minor | Last selected tool restored across launches; temporary overrides excluded, explicit Eraser choices retained, and final selection flushed on normal exit | | 2026-10-13 | minor | Free Transform with a selection: the box is the selection's rectangle, and the marching ants follow it while it is transformed (#5297) | | 2026-10-14 | minor | Move › Show Transform Controls frames every selected layer and outlines the selected shapes | +| 2026-10-14 | minor | ⇧⌥ + letter blend mode keys for the painting tool or every selected layer; ⇧+ / ⇧− now step every selected layer and include Clear for Brush and Pencil | diff --git a/scorecard/ui.toml b/scorecard/ui.toml index 7eff90c3ca..9caeb519fe 100644 --- a/scorecard/ui.toml +++ b/scorecard/ui.toml @@ -101,7 +101,7 @@ id = "UI-217-14" target = "Layers panel: wheel steps blend modes, drop on New/Trash duplicates/deletes, checker behind art" status = "done" issue = 217 -note = "panels.rs: the wheel steps the blend-mode dropdown (widgets::dropdown_wheel_hovered, #1747); rows dropped on New Layer/Group/Delete duplicate/group/delete them (footer_drop, #736), effect rows dropped on Delete delete that effect or the whole style (fx_trash_drop, #3102); pixel thumbnails draw widgets::checker behind the art; Shift+Plus/Minus step the layer's or the painting tool's blend mode (blend_keys.rs, #3102)" +note = "panels.rs: the wheel steps the blend-mode dropdown (widgets::dropdown_wheel_hovered, #1747); rows dropped on New Layer/Group/Delete duplicate/group/delete them (footer_drop, #736), effect rows dropped on Delete delete that effect or the whole style (fx_trash_drop, #3102); pixel thumbnails draw widgets::checker behind the art; Shift+Plus/Minus step the layer's or the painting tool's blend mode (blend_keys.rs, #3102), and Shift+Alt+letter picks one (Photoshop's letters; every selected layer, one undo step)" [[item]] id = "UI-217-15" From 5430f29e21e9240f937000da2200cac99466d7a4 Mon Sep 17 00:00:00 2001 From: paulou-jpg <79102098+paulou-jpg@users.noreply.github.com> Date: Thu, 15 Oct 2026 13:24:24 -0700 Subject: [PATCH 177/649] Blend mode and number keys work while a transform or warp is open With a Free Transform box, Puppet Warp or Perspective Warp open, Shift+Alt letters, Shift+Plus/Minus and the number keys go where the active tool sends them (the Brush's mode and opacity with the Brush, the layer's with the Move tool) and never close the box. Puppet and Perspective Warp no longer swallow those keys. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/blend_keys.rs | 53 ++++++++++++++++++++++++++++++++ crates/ui-egui/src/distort_ui.rs | 12 ++++++++ docs/ui-parity.md | 3 +- 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/blend_keys.rs b/crates/ui-egui/src/blend_keys.rs index b047330a66..81bd10026d 100644 --- a/crates/ui-egui/src/blend_keys.rs +++ b/crates/ui-egui/src/blend_keys.rs @@ -476,4 +476,57 @@ mod tests { let mut none = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); pick_mode(&mut none, Pick::Mode(BlendMode::Multiply)); } + + /// With a Free Transform box or a Puppet Warp open, ⇧⌥ letters, ⇧+ / ⇧− and the number keys + /// still go where the tool sends them: the Brush's mode and opacity with the Brush, the + /// layer's with the Move tool. They never pick a tool, so the box stays open, and Enter keeps + /// both the transform and the layer's new mode. + #[test] + fn keys_follow_the_tool_while_a_transform_or_warp_is_open() { + let ctx = egui::Context::default(); + let mut a = app(Tool::Brush); + a.run("select.rect", json!({"x": 4, "y": 4, "width": 12, "height": 12})).unwrap(); + a.run("edit.fill", json!({"color": "#ff0000"})).unwrap(); + a.run("select.deselect", json!({})).unwrap(); + a.sync_views(); + crate::transform_tool::begin(&mut a, &ctx).unwrap(); + crate::transform_tool::nudge(&mut a, 3.0, 0.0); + let shift_alt = egui::Modifiers::SHIFT | egui::Modifiers::ALT; + let opacity = |a: &PhotocraftApp| { + let st = a.session.active().unwrap(); + st.doc.layer(st.active_layer.unwrap()).unwrap().opacity + }; + // The Brush: its own mode and opacity. + key(&mut a, &ctx, Key::M, shift_alt); + assert_eq!(a.session.tools.brush.mode, BlendMode::Multiply); + key(&mut a, &ctx, Key::Num5, egui::Modifiers::NONE); + assert!((a.session.tools.brush.opacity - 0.5).abs() < 1e-6); + assert_eq!((layer_blend(&a), opacity(&a)), (BlendMode::Normal, 1.0), "the layer is left alone"); + assert!(a.ui.transform.is_some(), "the box stays open"); + assert_eq!(a.ui.tool, Tool::Brush, "no tool letter"); + // The Move tool: the layer's. + a.ui.tool = Tool::Move; + a.opacity_keys = None; + key(&mut a, &ctx, Key::E, shift_alt); + key(&mut a, &ctx, Key::Num7, egui::Modifiers::NONE); + assert_eq!(layer_blend(&a), BlendMode::Difference); + assert!((opacity(&a) - 0.7).abs() < 1e-6, "{}", opacity(&a)); + assert!(a.ui.transform.is_some()); + key(&mut a, &ctx, Key::Enter, egui::Modifiers::NONE); + assert!(a.ui.transform.is_none()); + let st = a.session.active().unwrap(); + let l = st.doc.layer(st.active_layer.unwrap()).unwrap(); + assert_eq!(l.blend, BlendMode::Difference, "the commit keeps it"); + assert_eq!(l.surface().unwrap().content_bounds().x0, 7, "and the move"); + // Puppet Warp keeps the other keys to itself, but these still reach the tool or layer. + crate::distort_ui::menu(&mut a, &ctx, "edit.puppetWarp", &json!({})).unwrap().unwrap(); + assert!(a.distort.puppet.is_some()); + key(&mut a, &ctx, Key::S, shift_alt); + assert_eq!(layer_blend(&a), BlendMode::Screen); + a.ui.tool = Tool::Brush; + key(&mut a, &ctx, Key::H, shift_alt); + assert_eq!(a.session.tools.brush.mode, BlendMode::HardLight); + assert_eq!(layer_blend(&a), BlendMode::Screen); + assert!(a.distort.puppet.is_some(), "the warp stays open"); + } } diff --git a/crates/ui-egui/src/distort_ui.rs b/crates/ui-egui/src/distort_ui.rs index 4987d8cc4d..61608c920a 100644 --- a/crates/ui-egui/src/distort_ui.rs +++ b/crates/ui-egui/src/distort_ui.rs @@ -160,6 +160,14 @@ pub fn pointer(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers) -> false } +/// Puppet Warp and Perspective Warp keep the keys to themselves, except the blend mode keys (⇧⌥ +/// letters, ⇧+ / ⇧−) and the number keys, which go on working as with Free Transform: on the +/// active tool's mode and opacity (the Brush's with the Brush), else on the layer's. +fn tool_keys(app: &mut PhotocraftApp, ctx: &egui::Context) { + crate::blend_keys::handle(app, ctx); + crate::opacity_keys::handle(app, ctx); +} + /// Keyboard: ↩ commits, Esc cancels (and Liquify's own shortcuts). True when the key handling /// of the rest of the app should be skipped. pub fn keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool { @@ -202,6 +210,8 @@ pub fn keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool { p.redo(); } else if ctx.input_mut(|i| i.consume_key(egui::Modifiers::COMMAND, egui::Key::Z)) { p.undo(); + } else { + tool_keys(app, ctx); } return true; } @@ -210,6 +220,8 @@ pub fn keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool { crate::perspective_ui::commit(app); } else if esc(ctx) { app.distort.perspective = None; + } else { + tool_keys(app, ctx); } return true; } diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 7e53ba4c45..c01aee5c4d 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -195,7 +195,7 @@ Triangle and Curvature Pen (minus legacy Rounded Rectangle and Targeted Adjustme | Tool keys: ← / → turn the brush tip (1°, ⇧ 15°), ⇧-click with Type starts new text over old, Space+F / ⇧Space+F cycle the pasteboard colour | done (2026-10-11) | | | Type formatting keys while editing text | done: ⇧⌘K, U, B, I and / toggle All Caps, Underline, Faux Bold, Faux Italic, Strikethrough (off when every selected character has it, else on); ⌥↑/↓ leading ∓2 pt, ⇧⌥↑/↓ baseline shift ±2 pt (10 with ⌘); ⌥←/→ tracking ±20 over a selection (100 with ⌘; a collapsed caret still kerns); ⌥⇧⌘H toggles Hyphenate for the touched paragraphs. One `type.setStyle` step per press (new `leadingBy`/`baselineShiftBy`/`trackingBy`; auto leading starts from its laid-out value); the global ⇧⌘K/U/B/I never fire while typing. Differs: a collapsed caret in non-empty text changes nothing, since the model can't hold a pending style for the next characters typed (empty text takes it as its typing style) (`type_tool.rs`, `input_tests.rs` `type_tool_format_keys_*`) | | | Guides: click selects, Delete deletes, right-click menu, ⌥-click turns a guide, double-click opens Guides, Grid & Slices | done (2026-10-12) | | -| Blend mode keys: ⇧⌥ + letter picks a mode (N Normal, I Dissolve, R Clear, P Pass Through, K M B A darken, G S D W lighten, O F H V J Z L contrast, E X difference, U T C Y component), ⇧+ / ⇧− step through them | done (2026-10-14): Brush, Pencil and Gradient take them as their own mode (Clear on Brush and Pencil only), any non-painting tool sets every selected layer in one undo step (Pass Through on groups only; the Background is skipped); the typed letter wins, the physical key is the fallback for ⌥ characters on a Mac. ⇧⌥ letters no longer switch tools. Differs: Behind (⇧⌥Q) is not implemented; Clone Stamp, Pattern Stamp, History Brush, Healing, Paint Bucket and Magic Eraser ignore the keys until their options bar has a Mode | `blend_keys.rs` | +| Blend mode keys: ⇧⌥ + letter picks a mode (N Normal, I Dissolve, R Clear, P Pass Through, K M B A darken, G S D W lighten, O F H V J Z L contrast, E X difference, U T C Y component), ⇧+ / ⇧− step through them | done (2026-10-14): Brush, Pencil and Gradient take them as their own mode (Clear on Brush and Pencil only), any non-painting tool sets every selected layer in one undo step (Pass Through on groups only; the Background is skipped); the typed letter wins, the physical key is the fallback for ⌥ characters on a Mac. ⇧⌥ letters no longer switch tools. While a Free Transform box, Puppet Warp or Perspective Warp is open they, and the number keys, still reach the tool (or the layers) without closing it. Differs: Behind (⇧⌥Q) is not implemented; Clone Stamp, Pattern Stamp, History Brush, Healing, Paint Bucket and Magic Eraser ignore the keys until their options bar has a Mode | `blend_keys.rs` | ## Panels and workspace @@ -259,3 +259,4 @@ Paragraph; the rest open as in-app floating windows. | 2026-10-13 | minor | Free Transform with a selection: the box is the selection's rectangle, and the marching ants follow it while it is transformed (#5297) | | 2026-10-14 | minor | Move › Show Transform Controls frames every selected layer and outlines the selected shapes | | 2026-10-14 | minor | ⇧⌥ + letter blend mode keys for the painting tool or every selected layer; ⇧+ / ⇧− now step every selected layer and include Clear for Brush and Pencil | +| 2026-10-15 | minor | Blend mode and number keys work while a Free Transform, Puppet Warp or Perspective Warp is open | From b1a939f2654f41acd82e584e4d9fd898bb473af5 Mon Sep 17 00:00:00 2001 From: paulou-jpg <79102098+paulou-jpg@users.noreply.github.com> Date: Wed, 14 Oct 2026 02:59:01 -0700 Subject: [PATCH 178/649] Mode dropdowns for Clone Stamp, Pattern Stamp, History Brush, Healing and Paint Bucket Photoshop gives these painting tools a Mode in the options bar; here they always painted in Normal. - Clone Stamp, Pattern Stamp and History Brush offer the layer modes, and Healing its own list (Normal, Multiply, Screen, Darken, Lighten, Color, Luminosity). The mode is kept in each tool's own brush, like its size, and reaches the live stroke and the commit. - Paint Bucket: paint.bucket takes "mode" (any blend mode, or "clear" to erase the filled area). algo's bucket fill gains a FillMode for it. The options bar's Mode has Clear after Dissolve, as the Brush's does. - A tool's first brush now starts in Normal instead of inheriting the previous tool's mode, so a Multiply Brush no longer makes the first Clone Stamp stroke multiply. - The Shift+Alt letter and Shift+Plus/Minus mode keys reach these tools, within each tool's menu. Tools with no blend mode (the Erasers, Mixer Brush, Dodge, Burn, Sponge) now pass the keys to the selected layers. Not yet: Healing's Replace mode, and a Mode for Spot Healing, Color Replacement, Blur, Sharpen and Smudge (they ignore the keys meanwhile). Co-Authored-By: Claude Opus 5.5 --- crates/algo/src/paint.rs | 63 +++-- crates/engine/src/paint_cmds.rs | 54 ++++- crates/ui-egui/src/blend_keys.rs | 219 ++++++++++++++---- crates/ui-egui/src/canvas.rs | 5 +- .../src/options_bar_mode_wheel_tests.rs | 37 ++- crates/ui-egui/src/paint_mouse.rs | 7 +- crates/ui-egui/src/panels.rs | 37 ++- crates/ui-egui/src/retouch_ui.rs | 57 ++++- crates/ui-egui/src/state.rs | 6 + crates/ui-egui/src/tool_reset.rs | 2 +- docs/brush-parity.md | 11 +- docs/ui-parity.md | 5 +- 12 files changed, 410 insertions(+), 93 deletions(-) diff --git a/crates/algo/src/paint.rs b/crates/algo/src/paint.rs index c32f28c648..a206c0c9a3 100644 --- a/crates/algo/src/paint.rs +++ b/crates/algo/src/paint.rs @@ -5,6 +5,14 @@ use photocraft_geom::Rect; use photocraft_raster::{Surface, from_rgba_into}; use serde::{Deserialize, Serialize}; +/// How a fill lays down its colour: blended with a mode, or Clear, which erases what it covers +/// (the Paint Bucket's Mode › Clear). +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum FillMode { + Blend(BlendMode), + Clear, +} + /// Gradient tool shape. #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Default)] #[serde(rename_all = "camelCase")] @@ -59,7 +67,7 @@ pub fn sample_stops(stops: &[(f32, [f32; 4])], t: f32) -> [f32; 4] { fn composite_area( s: &mut Surface, area: Rect, - blend_mode: BlendMode, + mode: FillMode, coverage: impl Fn(i32, i32) -> f32 + Sync, color: impl Fn(i32, i32) -> [f32; 4] + Sync, lock_transparency: bool, @@ -89,7 +97,10 @@ fn composite_area( let i = ((y - r.y0) as usize * w + (x - r.x0) as usize) * n; let px = &mut region[i..i + n]; let d = photocraft_raster::to_rgba(&fmt, px); - let mut o = blend::composite(blend_mode, d, color(x, y), k); + let mut o = match mode { + FillMode::Blend(m) => blend::composite(m, d, color(x, y), k), + FillMode::Clear => [d[0], d[1], d[2], d[3] * (1.0 - k.min(1.0))], + }; if lock_transparency { o[3] = d[3]; } @@ -97,7 +108,7 @@ fn composite_area( // A colour picked as CMYK inks replaces fully covered pixels of a CMYK target as it is. if let Some(i) = inks && fmt.mode == photocraft_color::ColorMode::Cmyk - && blend_mode == BlendMode::Normal + && mode == FillMode::Blend(BlendMode::Normal) && k >= 1.0 { enc[..4].copy_from_slice(&i); @@ -138,7 +149,7 @@ pub fn paint_gradient( composite_area( s, area, - blend_mode, + FillMode::Blend(blend_mode), |x, y| opacity * selection.map_or(1.0, |m| m.sample_channel(x, y, 0)), |x, y| { let t = tool_gradient_t(shape, from, to, x as f32 + 0.5, y as f32 + 0.5); @@ -190,11 +201,12 @@ pub fn bucket_fill_src( lock_transparency: bool, src: impl Fn(i32, i32) -> [f32; 4] + Sync, ) -> bool { - bucket_fill_inks(s, area, seed, tolerance, contiguous, anti_alias, opacity, selection, lock_transparency, src, None) + bucket_fill_inks(s, area, seed, tolerance, contiguous, anti_alias, opacity, selection, lock_transparency, src, None, FillMode::Blend(BlendMode::Normal)) } /// [`bucket_fill_src`] where `inks` (CMYK, 0..1) are what a fully covered pixel of a CMYK target -/// gets instead of `src`'s sRGB stand-in (a colour that was picked as CMYK). +/// gets instead of `src`'s sRGB stand-in (a colour that was picked as CMYK), laid down with `mode` +/// (the options bar's Mode). #[allow(clippy::too_many_arguments)] pub fn bucket_fill_inks( s: &mut Surface, @@ -208,6 +220,7 @@ pub fn bucket_fill_inks( lock_transparency: bool, src: impl Fn(i32, i32) -> [f32; 4] + Sync, inks: Option<[f32; 4]>, + mode: FillMode, ) -> bool { if !area.contains(seed.0, seed.1) { return false; @@ -215,7 +228,7 @@ pub fn bucket_fill_inks( let img = crate::selection::rgba8_image(s, area); let Some(region) = crate::selection::wand_region(&img, area, seed, tolerance, contiguous, anti_alias) else { return false }; drop(img); - bucket_fill_region_inks(s, ®ion, opacity, selection, lock_transparency, src, inks); + bucket_fill_region_inks(s, ®ion, opacity, selection, lock_transparency, src, inks, mode); true } @@ -229,10 +242,11 @@ pub fn bucket_fill_region_src( lock_transparency: bool, src: impl Fn(i32, i32) -> [f32; 4] + Sync, ) { - bucket_fill_region_inks(s, region, opacity, selection, lock_transparency, src, None); + bucket_fill_region_inks(s, region, opacity, selection, lock_transparency, src, None, FillMode::Blend(BlendMode::Normal)); } -/// [`bucket_fill_region_src`] with the CMYK `inks` of [`bucket_fill_inks`]. +/// [`bucket_fill_region_src`] with the CMYK `inks` and the `mode` of [`bucket_fill_inks`]. +#[allow(clippy::too_many_arguments)] pub fn bucket_fill_region_inks( s: &mut Surface, region: &crate::selection::Region, @@ -241,18 +255,11 @@ pub fn bucket_fill_region_inks( lock_transparency: bool, src: impl Fn(i32, i32) -> [f32; 4] + Sync, inks: Option<[f32; 4]>, + mode: FillMode, ) { // Composite only over the filled region's box. let b = region.bbox; - composite_area( - s, - b, - BlendMode::Normal, - |x, y| region.at(x, y) * opacity * selection.map_or(1.0, |m| m.sample_channel(x, y, 0)), - src, - lock_transparency, - inks, - ); + composite_area(s, b, mode, |x, y| region.at(x, y) * opacity * selection.map_or(1.0, |m| m.sample_channel(x, y, 0)), src, lock_transparency, inks); } #[cfg(test)] @@ -320,4 +327,24 @@ mod tests { assert_eq!(s.rgba(-1, 4), [0.0; 4], "outside the selection"); assert_eq!(s.rgba(-4, 4), [0.0; 4], "outside the region"); } + + /// The Paint Bucket's Mode: Multiply darkens what's there, Clear erases it (half at 50 %). + #[test] + fn bucket_mode_blends_or_clears() { + let a = Rect::new(0, 0, 4, 1); + let grey = [0.5, 0.5, 0.5, 1.0]; + for fmt in [PixelFormat::RGBA8, PixelFormat::RGBA16, PixelFormat::RGBA32F] { + let mut s = Surface::new(fmt); + s.fill_rect(a, &grey); + let red = |_, _| [1.0, 0.0, 0.0, 1.0]; + assert!(bucket_fill_inks(&mut s, a, (0, 0), 0.0, true, false, 1.0, None, false, red, None, FillMode::Blend(BlendMode::Multiply))); + let px = s.rgba(1, 0); + assert!((px[0] - 0.5).abs() < 0.01 && px[1] < 0.01 && (px[3] - 1.0).abs() < 1e-3, "{fmt:?} multiply: {px:?}"); + assert!(bucket_fill_inks(&mut s, a, (0, 0), 0.0, true, false, 0.5, None, false, red, None, FillMode::Clear)); + assert!((s.rgba(1, 0)[3] - 0.5).abs() < 0.01, "{fmt:?} clear at 50 %"); + // Locked transparency keeps the alpha, so Clear does nothing. + assert!(bucket_fill_inks(&mut s, a, (0, 0), 0.0, true, false, 1.0, None, true, red, None, FillMode::Clear)); + assert!((s.rgba(1, 0)[3] - 0.5).abs() < 0.01, "{fmt:?} locked"); + } + } } diff --git a/crates/engine/src/paint_cmds.rs b/crates/engine/src/paint_cmds.rs index 497d7f4fb1..7f23c6b8ba 100644 --- a/crates/engine/src/paint_cmds.rs +++ b/crates/engine/src/paint_cmds.rs @@ -1,6 +1,6 @@ //! Paint helpers: Paint Bucket and Gradient tool. -use photocraft_algo::paint::{GradientShape, bucket_fill_inks, bucket_fill_region_inks, bucket_fill_region_src, bucket_fill_src, paint_gradient}; +use photocraft_algo::paint::{FillMode, GradientShape, bucket_fill_inks, bucket_fill_region_inks, paint_gradient}; use serde_json::{Value, json}; use crate::commands::{CommandSpec, blend_from_str}; @@ -41,12 +41,27 @@ fn opacity(p: &Value, cmd: &str) -> Result { Ok(crate::eraser_cmds::number(p, cmd, "opacity", 100.0, 1.0..=100.0)? as f32 / 100.0) } +/// The Paint Bucket's `mode`: a blend mode (not Pass Through, a group's) or `clear`. +fn fill_mode(p: &Value) -> Result { + let bad = |msg: String| EngineError::BadParams { cmd: "paint.bucket".into(), msg }; + match p.get("mode") { + None | Some(Value::Null) => Ok(FillMode::Blend(photocraft_color::BlendMode::Normal)), + Some(Value::String(m)) if m.eq_ignore_ascii_case("clear") => Ok(FillMode::Clear), + Some(Value::String(m)) => blend_from_str(m) + .filter(|m| *m != photocraft_color::BlendMode::PassThrough) + .map(FillMode::Blend) + .ok_or_else(|| bad(format!("unknown blend mode `{m}`"))), + Some(v) => Err(bad(format!("`mode` must be a blend mode name or `clear`, not {v}"))), + } +} + fn bucket(s: &mut Session, p: &Value) -> Result { let fg = s.tools.foreground; let c = color(p.get("color"), fg); let (x, y) = (f(p, "x", 0.0).floor() as i32, f(p, "y", 0.0).floor() as i32); let (tol, contiguous, aa) = (f(p, "tolerance", 32.0), b(p, "contiguous", true), b(p, "antiAlias", true)); let opacity = opacity(p, "paint.bucket")?; + let mode = fill_mode(p)?; let all = b(p, "sampleAllLayers", false) && crate::channel_cmds::target_of(p) == crate::channel_cmds::Target::Pixels; // Other visible layers can define the region, but the fill still writes only to the target. let region = if all { @@ -83,16 +98,16 @@ fn bucket(s: &mut Session, p: &Value) -> Result { let w = area.width() as usize; let src = |px: i32, py: i32| rendered[(py - area.y0) as usize * w + (px - area.x0) as usize]; if let Some(region) = ®ion { - bucket_fill_region_src(surf, region, opacity, sel.as_ref(), lock, src); + bucket_fill_region_inks(surf, region, opacity, sel.as_ref(), lock, src, None, mode); true } else { - bucket_fill_src(surf, area, (x, y), tol, contiguous, aa, opacity, sel.as_ref(), lock, src) + bucket_fill_inks(surf, area, (x, y), tol, contiguous, aa, opacity, sel.as_ref(), lock, src, None, mode) } } else if let Some(region) = ®ion { - bucket_fill_region_inks(surf, region, opacity, sel.as_ref(), lock, |_, _| c, inks); + bucket_fill_region_inks(surf, region, opacity, sel.as_ref(), lock, |_, _| c, inks, mode); true } else { - bucket_fill_inks(surf, area, (x, y), tol, contiguous, aa, opacity, sel.as_ref(), lock, |_, _| c, inks) + bucket_fill_inks(surf, area, (x, y), tol, contiguous, aa, opacity, sel.as_ref(), lock, |_, _| c, inks, mode) }; surf.prune(); Ok(ok) @@ -162,7 +177,7 @@ pub fn specs() -> Vec { label: "Paint Bucket", menu: &[], shortcut: None, - params: r##"{"x":px,"y":px,"tolerance":0..255=32,"contiguous":bool=true,"antiAlias":bool=true,"sampleAllLayers":bool=false,"contents":"foreground|pattern"="foreground","color":"#rrggbb"=foreground,"pattern":id|name (contents=pattern),"scale":%=100,"angle":deg,"opacity":1..100=100,"target":"pixels"|"mask"|"quickMask"|{"channel":i}=Channels panel target}"##, + params: r##"{"x":px,"y":px,"tolerance":0..255=32,"contiguous":bool=true,"antiAlias":bool=true,"sampleAllLayers":bool=false,"contents":"foreground|pattern"="foreground","color":"#rrggbb"=foreground,"pattern":id|name (contents=pattern),"scale":%=100,"angle":deg,"opacity":1..100=100,"mode":"normal|multiply|…|clear (erases the filled area)"="normal","target":"pixels"|"mask"|"quickMask"|{"channel":i}=Channels panel target}"##, enabled: crate::commands::has_paintable, run: bucket, journal: true, @@ -210,6 +225,33 @@ mod tests { (s, bottom) } + /// The options bar's Mode reaches the fill: Multiply over grey, Clear erases, a bad name or + /// Pass Through is an error and changes nothing. + #[test] + fn bucket_mode_multiplies_clears_and_rejects_bad_names() { + for depth in [8, 16, 32] { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 8, "height": 8, "depth": depth})).unwrap(); + s.execute("layer.new.layer", json!({})).unwrap(); + let base = json!({"x": 1, "y": 1, "antiAlias": false, "tolerance": 0}); + let with = |extra: Value| { + let mut p = base.clone(); + p.as_object_mut().unwrap().extend(extra.as_object().unwrap().clone()); + p + }; + s.execute("paint.bucket", with(json!({"color": "#808080"}))).unwrap(); + s.execute("paint.bucket", with(json!({"color": "#ff0000", "mode": "multiply"}))).unwrap(); + let p = px(&s, 3, 3); + assert!((p[0] - 0.5).abs() < 0.01 && p[1] < 0.01 && p[3] > 0.99, "depth {depth}: {p:?}"); + for bad in [json!("passThrough"), json!("sparkle"), json!(3)] { + assert!(s.execute("paint.bucket", with(json!({"mode": bad}))).is_err(), "{bad}"); + } + assert_eq!(px(&s, 3, 3), p, "a refused mode paints nothing"); + s.execute("paint.bucket", with(json!({"mode": "Clear", "opacity": 50}))).unwrap(); + assert!((px(&s, 3, 3)[3] - 0.5).abs() < 0.01, "depth {depth}: half cleared"); + } + } + #[test] fn bucket_sample_all_layers_uses_visible_boundaries_at_all_depths() { for depth in [8, 16, 32] { diff --git a/crates/ui-egui/src/blend_keys.rs b/crates/ui-egui/src/blend_keys.rs index 81bd10026d..8f4af6c363 100644 --- a/crates/ui-egui/src/blend_keys.rs +++ b/crates/ui-egui/src/blend_keys.rs @@ -1,8 +1,8 @@ //! Blend mode keys, as in Photoshop. ⇧+ and ⇧− step through the modes (#3102), and ⇧⌥ plus a -//! letter picks one (⇧⌥M Multiply, ⇧⌥S Screen…). With a painting tool that has a mode of its own -//! they set that tool's mode and never the layer's: the Brush's or Pencil's (which also offer -//! Clear), the Gradient's; the other painting tools are left alone until their options bar has a -//! Mode. With any other tool (Move, the selection tools…) they set every selected layer's mode. +//! letter picks one (⇧⌥M Multiply, ⇧⌥S Screen…). With a painting tool that has a Mode of its own +//! (`tool_modes`: Brush, Pencil, Paint Bucket, Gradient, the stamps, History Brush, Healing) they +//! set that tool's mode within its menu and never the layer's. With a tool that has no blend mode +//! (Move, the selection tools, the Erasers…) they set every selected layer's mode. //! The step list wraps at either end. Each press is one call of an engine command per layer //! (`tools.setBrush`, `layer.setProps`), coalesced into one undo step. @@ -116,43 +116,85 @@ pub fn handle(app: &mut PhotocraftApp, ctx: &egui::Context) { } } +/// Photoshop's Healing Brush modes, less Replace (not implemented yet). +pub const HEALING_MODES: [BlendMode; 7] = + [BlendMode::Normal, BlendMode::Multiply, BlendMode::Screen, BlendMode::Darken, BlendMode::Lighten, BlendMode::Color, BlendMode::Luminosity]; + +/// A painting tool's options-bar Mode menu in order, `None` being Clear (after Dissolve, on the +/// tools Photoshop offers it on). `None` for a tool without a blend mode control. +pub fn tool_modes(tool: Tool) -> Option>> { + let layer = || BlendMode::LAYER_MODES.iter().copied().map(Some).collect::>(); + Some(match tool { + Tool::Brush | Tool::Pencil | Tool::PaintBucket => { + let mut modes = layer(); + let at = modes.iter().position(|m| *m == Some(BlendMode::Dissolve)).map_or(modes.len(), |i| i + 1); + modes.insert(at, None); + modes + } + Tool::Gradient | Tool::CloneStamp | Tool::PatternStamp | Tool::HistoryBrush => layer(), + Tool::Healing => HEALING_MODES.iter().copied().map(Some).collect(), + _ => return None, + }) +} + /// Where the active tool's blend mode keys go. enum Target { - /// The Brush's or Pencil's mode, Clear included. - Paint, - Gradient, - /// A painting tool whose mode has no options-bar control yet (or the Eraser, which has none): - /// the keys do nothing, and never reach the layer. + /// The tool's own Mode, one of these. + Tool(Vec>), + /// A painting tool with a blend mode in Photoshop but no Mode control here yet: the keys do + /// nothing, and never reach the layer. Nothing, Layers, } fn target(tool: Tool) -> Target { + if let Some(modes) = tool_modes(tool) { + return Target::Tool(modes); + } match tool { - Tool::Brush | Tool::Pencil => Target::Paint, - Tool::Gradient => Target::Gradient, - t if t.is_brushlike() || t == Tool::MagicEraser || t == Tool::PaintBucket => Target::Nothing, + Tool::SpotHealing | Tool::ColorReplacement | Tool::Blur | Tool::Sharpen | Tool::Smudge => Target::Nothing, + // No blend mode of their own (the Erasers, Dodge, Sponge…): the layer's, as in Photoshop. _ => Target::Layers, } } -/// The Brush's or Pencil's mode list: the layer modes with Clear (`None`) after Dissolve, as in -/// its options-bar dropdown. -fn paint_modes() -> Vec> { - let mut modes: Vec> = BlendMode::LAYER_MODES.iter().copied().map(Some).collect(); - let at = modes.iter().position(|m| *m == Some(BlendMode::Dissolve)).map_or(modes.len(), |i| i + 1); - modes.insert(at, None); - modes +/// The active tool's mode, `None` being Clear. A brush-based tool's lives in its own brush. +pub fn tool_mode(app: &mut PhotocraftApp) -> Option { + let o = &app.ui.tool_options; + match app.ui.tool { + Tool::Brush if o.brush_clear => None, + Tool::Pencil if o.pencil_clear => None, + Tool::PaintBucket if o.bucket_clear => None, + Tool::PaintBucket => Some(o.bucket_blend_mode), + Tool::Gradient => Some(o.gradient_blend_mode), + _ => { + crate::paint_mouse::sync_tool_brush(app); + Some(app.session.tools.brush.mode) + } + } } -/// The Brush's or Pencil's Clear flag. -fn clear_flag(app: &mut PhotocraftApp) -> &mut bool { - if app.ui.tool == Tool::Pencil { &mut app.ui.tool_options.pencil_clear } else { &mut app.ui.tool_options.brush_clear } -} - -/// Sets the Brush's or Pencil's mode; `None` is Clear. -fn set_paint_mode(app: &mut PhotocraftApp, mode: Option) { - *clear_flag(app) = mode.is_none(); +/// Sets the active tool's mode; `None` is Clear. +fn set_tool_mode(app: &mut PhotocraftApp, mode: Option) { + match app.ui.tool { + Tool::Gradient => { + if let Some(m) = mode { + set_gradient_mode(app, m); + } + return; + } + Tool::PaintBucket => { + app.ui.tool_options.bucket_clear = mode.is_none(); + if let Some(m) = mode { + app.ui.tool_options.bucket_blend_mode = m; + } + return; + } + Tool::Brush => app.ui.tool_options.brush_clear = mode.is_none(), + Tool::Pencil => app.ui.tool_options.pencil_clear = mode.is_none(), + _ => {} + } + crate::paint_mouse::sync_tool_brush(app); if let Some(m) = mode && let Ok(m) = serde_json::to_value(m) { @@ -189,15 +231,10 @@ fn set_layers_mode(app: &mut PhotocraftApp, mode: BlendMode) { /// layer's. pub fn press(app: &mut PhotocraftApp, step: i32) { match target(app.ui.tool) { - Target::Paint => { - let current = if *clear_flag(app) { None } else { Some(app.session.tools.brush.mode) }; - if let Some(mode) = stepped(&paint_modes(), current, step) { - set_paint_mode(app, mode); - } - } - Target::Gradient => { - if let Some(mode) = stepped(&BlendMode::LAYER_MODES, app.ui.tool_options.gradient_blend_mode, step) { - set_gradient_mode(app, mode); + Target::Tool(modes) => { + let current = tool_mode(app); + if let Some(mode) = stepped(&modes, current, step) { + set_tool_mode(app, mode); } } Target::Nothing => {} @@ -216,14 +253,21 @@ pub fn press(app: &mut PhotocraftApp, step: i32) { } } -/// One ⇧⌥ letter press. A mode the target doesn't have (Clear or Behind for layers, Pass Through -/// for a painting tool) does nothing. +/// One ⇧⌥ letter press. A mode the target's menu doesn't have (Clear or Behind for layers, Pass +/// Through for a painting tool, Overlay for the Healing Brush) does nothing. pub fn pick_mode(app: &mut PhotocraftApp, pick: Pick) { - match (target(app.ui.tool), pick) { - (Target::Paint, Pick::Mode(m)) if m != BlendMode::PassThrough => set_paint_mode(app, Some(m)), - (Target::Paint, Pick::Clear) => set_paint_mode(app, None), - (Target::Gradient, Pick::Mode(m)) if m != BlendMode::PassThrough => set_gradient_mode(app, m), - (Target::Layers, Pick::Mode(m)) => set_layers_mode(app, m), + let want = match pick { + Pick::Mode(m) => Some(m), + Pick::Clear => None, + Pick::Behind => return, + }; + match target(app.ui.tool) { + Target::Tool(modes) if modes.contains(&want) => set_tool_mode(app, want), + Target::Layers => { + if let Some(m) = want { + set_layers_mode(app, m); + } + } _ => {} } } @@ -459,20 +503,20 @@ mod tests { assert_eq!(layer_blend(&a), BlendMode::Normal); } - /// The Gradient takes the letters; a painting tool without a Mode control yet (Clone Stamp) - /// ignores them rather than changing the layer. + /// The Gradient takes the letters; Smudge, which has a blend mode in Photoshop but no Mode + /// control here yet, ignores them rather than changing the layer. #[test] - fn gradient_takes_the_letters_and_clone_stamp_ignores_them() { + fn gradient_takes_the_letters_and_smudge_ignores_them() { let ctx = egui::Context::default(); let mut a = app(Tool::Gradient); alt_shift(&mut a, &ctx, Key::O, Key::O); assert_eq!(a.ui.tool_options.gradient_blend_mode, BlendMode::Overlay); alt_shift(&mut a, &ctx, Key::R, Key::R); - assert_eq!(a.ui.tool_options.gradient_blend_mode, BlendMode::Overlay); - a.ui.tool = Tool::CloneStamp; + assert_eq!(a.ui.tool_options.gradient_blend_mode, BlendMode::Overlay, "no Clear for the Gradient"); + a.ui.tool = Tool::Smudge; alt_shift(&mut a, &ctx, Key::M, Key::M); assert_eq!(layer_blend(&a), BlendMode::Normal); - assert_eq!(a.ui.tool, Tool::CloneStamp); + assert_eq!(a.ui.tool, Tool::Smudge); let mut none = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); pick_mode(&mut none, Pick::Mode(BlendMode::Multiply)); } @@ -529,4 +573,81 @@ mod tests { assert_eq!(layer_blend(&a), BlendMode::Screen); assert!(a.distort.puppet.is_some(), "the warp stays open"); } + + /// The stamps and the History Brush keep their mode in their own brush: the keys set it there, + /// never the layer's, and another tool's brush keeps its own. + #[test] + fn clone_stamp_pattern_stamp_and_history_brush_take_the_keys_into_their_own_brush() { + let ctx = egui::Context::default(); + let mut a = app(Tool::Brush); + alt_shift(&mut a, &ctx, Key::M, Key::M); + for (tool, key, mode) in + [(Tool::CloneStamp, Key::S, BlendMode::Screen), (Tool::PatternStamp, Key::O, BlendMode::Overlay), (Tool::HistoryBrush, Key::K, BlendMode::Darken)] + { + a.ui.tool = tool; + assert_eq!(tool_mode(&mut a), Some(BlendMode::Normal), "{tool:?} starts in Normal"); + alt_shift(&mut a, &ctx, key, key); + assert_eq!(tool_mode(&mut a), Some(mode), "{tool:?}"); + alt_shift(&mut a, &ctx, Key::R, Key::R); + assert_eq!(tool_mode(&mut a), Some(mode), "{tool:?} has no Clear"); + key_press(&mut a, &ctx, 1); + assert_ne!(tool_mode(&mut a), Some(mode), "{tool:?} steps"); + assert_eq!(layer_blend(&a), BlendMode::Normal, "{tool:?} leaves the layer alone"); + } + a.ui.tool = Tool::Brush; + assert_eq!(tool_mode(&mut a), Some(BlendMode::Multiply), "the Brush keeps its own mode"); + } + + fn key_press(a: &mut PhotocraftApp, ctx: &egui::Context, step: i32) { + key(a, ctx, if step > 0 { Key::Plus } else { Key::Minus }, egui::Modifiers::SHIFT); + } + + /// The Healing Brush's menu is short: letters outside it do nothing, and ⇧+ steps within it. + #[test] + fn healing_brush_takes_only_its_own_modes() { + let ctx = egui::Context::default(); + let mut a = app(Tool::Healing); + alt_shift(&mut a, &ctx, Key::O, Key::O); + assert_eq!(tool_mode(&mut a), Some(BlendMode::Normal), "Overlay isn't a Healing mode"); + alt_shift(&mut a, &ctx, Key::Y, Key::Y); + assert_eq!(tool_mode(&mut a), Some(BlendMode::Luminosity)); + key_press(&mut a, &ctx, 1); + assert_eq!(tool_mode(&mut a), Some(BlendMode::Normal), "wraps within the Healing list"); + key_press(&mut a, &ctx, 1); + assert_eq!(tool_mode(&mut a), Some(BlendMode::Multiply)); + assert_eq!(layer_blend(&a), BlendMode::Normal); + } + + /// The Paint Bucket has its own Mode, Clear included. + #[test] + fn paint_bucket_takes_the_keys_with_clear() { + let ctx = egui::Context::default(); + let mut a = app(Tool::PaintBucket); + alt_shift(&mut a, &ctx, Key::M, Key::M); + assert_eq!(a.ui.tool_options.bucket_blend_mode, BlendMode::Multiply); + alt_shift(&mut a, &ctx, Key::R, Key::R); + assert!(a.ui.tool_options.bucket_clear); + key_press(&mut a, &ctx, 1); + assert!(!a.ui.tool_options.bucket_clear); + assert_eq!(a.ui.tool_options.bucket_blend_mode, BlendMode::Darken, "Clear is followed by Darken"); + assert_eq!(layer_blend(&a), BlendMode::Normal); + } + + /// Tools without a blend mode of their own (the Erasers, Dodge, the Mixer Brush) pass the keys + /// to the selected layers, as Photoshop does. + #[test] + fn tools_without_a_blend_mode_set_the_layer() { + let ctx = egui::Context::default(); + for (tool, key, mode) in [ + (Tool::Eraser, Key::M, BlendMode::Multiply), + (Tool::MagicEraser, Key::S, BlendMode::Screen), + (Tool::Dodge, Key::O, BlendMode::Overlay), + (Tool::MixerBrush, Key::E, BlendMode::Difference), + ] { + let mut a = app(tool); + alt_shift(&mut a, &ctx, key, key); + assert_eq!(layer_blend(&a), mode, "{tool:?}"); + assert_eq!(a.ui.tool, tool); + } + } } diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index d2e535f3f6..8abfff411e 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -709,7 +709,7 @@ fn begin_live_stroke(app: &PhotocraftApp) -> Option { EngineStroke::Dab(photocraft_engine::retouch_cmds::LiveDab::begin(&app.session, cmd, &p).ok()?) } else if let Some(cmd) = live_retouch_command(d.tool) { // The params `retouch_ui::finish_stroke` commits. - let mut p = if d.tool == Tool::HistoryBrush { json!({}) } else { crate::retouch_ui::clone_params(app)? }; + let mut p = if d.tool == Tool::HistoryBrush { crate::retouch_ui::history_brush_params(app) } else { crate::retouch_ui::clone_params(app)? }; p["points"] = json!(d.points); p["target"] = paint_target(app); EngineStroke::Retouch(photocraft_engine::retouch_cmds::LiveRetouch::begin(&app.session, cmd, &p).ok()?) @@ -5608,7 +5608,8 @@ pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers) Tool::PaintBucket => { let o = app.ui.tool_options.clone(); let contents = if o.bucket_fill_pattern { "pattern" } else { "foreground" }; - let _ = app.run("paint.bucket", json!({"x": x.floor(), "y": y.floor(), "tolerance": o.tolerance, "contiguous": o.contiguous, "antiAlias": o.anti_alias, "sampleAllLayers": o.sample_all.paint_bucket, "opacity": o.fill_opacity, "contents": contents, "target": paint_target(app)})); + let mode = if o.bucket_clear { "clear" } else { o.bucket_blend_mode.label() }; + let _ = app.run("paint.bucket", json!({"x": x.floor(), "y": y.floor(), "tolerance": o.tolerance, "contiguous": o.contiguous, "antiAlias": o.anti_alias, "sampleAllLayers": o.sample_all.paint_bucket, "opacity": o.fill_opacity, "contents": contents, "mode": mode, "target": paint_target(app)})); return; } Tool::RedEye => { diff --git a/crates/ui-egui/src/options_bar_mode_wheel_tests.rs b/crates/ui-egui/src/options_bar_mode_wheel_tests.rs index 068561b4a0..9e6d172a44 100644 --- a/crates/ui-egui/src/options_bar_mode_wheel_tests.rs +++ b/crates/ui-egui/src/options_bar_mode_wheel_tests.rs @@ -1,5 +1,6 @@ -//! #2061: the scroll wheel over the options bar's Mode dropdown (Brush, Pencil, Gradient) steps -//! through the blend modes, as over the Layers panel's (#1747) and as in Photoshop. +//! #2061: the scroll wheel over the options bar's Mode dropdown (Brush, Pencil, Gradient, Paint +//! Bucket, the stamps, History Brush, Healing) steps through the blend modes, as over the Layers +//! panel's (#1747) and as in Photoshop. use egui::accesskit::Role; use egui::{Pos2, Rect, vec2}; @@ -81,3 +82,35 @@ fn the_wheel_over_the_gradient_mode_dropdown_steps_its_blend_mode() { wheel(&mut h, at, 1.0); assert_eq!(h.state().ui.tool_options.gradient_blend_mode, BlendMode::Dissolve); } + +/// The stamps, the History Brush and the Healing Brush have a Mode dropdown of their own brush's +/// mode; the Healing Brush's skips the modes it doesn't have. +#[test] +fn retouch_tools_have_a_mode_dropdown() { + for (tool, after_two) in [ + (Tool::CloneStamp, BlendMode::Darken), + (Tool::PatternStamp, BlendMode::Darken), + (Tool::HistoryBrush, BlendMode::Darken), + (Tool::Healing, BlendMode::Screen), + ] { + let mut h = harness(tool); + let at = mode_dropdown(&h).center(); + wheel(&mut h, at, -2.0); + assert_eq!(brush_mode(&h), after_two, "{tool:?}"); + assert_eq!(h.state().ui.tool, tool); + } +} + +/// The Paint Bucket's Mode dropdown has Clear after Dissolve, as the Brush's does. +#[test] +fn the_paint_bucket_mode_dropdown_has_clear() { + let mut h = harness(Tool::PaintBucket); + let at = mode_dropdown(&h).center(); + wheel(&mut h, at, -1.0); + assert_eq!(h.state().ui.tool_options.bucket_blend_mode, BlendMode::Dissolve); + wheel(&mut h, at, -1.0); + assert!(h.state().ui.tool_options.bucket_clear); + wheel(&mut h, at, -1.0); + assert!(!h.state().ui.tool_options.bucket_clear); + assert_eq!(h.state().ui.tool_options.bucket_blend_mode, BlendMode::Darken); +} diff --git a/crates/ui-egui/src/paint_mouse.rs b/crates/ui-egui/src/paint_mouse.rs index 6a19c9ff77..1188b70398 100644 --- a/crates/ui-egui/src/paint_mouse.rs +++ b/crates/ui-egui/src/paint_mouse.rs @@ -31,8 +31,10 @@ pub fn sync_tool_brush(app: &mut PhotocraftApp) { save_brush(app, app.ui.brush_tool, current.clone()); app.session.tools.brush = match app.ui.tool_brushes.iter().find(|(t, _)| *t == tool) { Some((_, b)) => session_fields(¤t, b), - // A tool seen for the first time takes what the brush has, at Photoshop's smoothing. - None => BrushSettings { smoothing: first_smoothing(), ..current }, + // A tool seen for the first time takes what the brush has, at Photoshop's smoothing, but + // in Normal mode: each tool's Mode starts at Normal, so a Multiply Brush doesn't make the + // first Clone Stamp stroke multiply (or give Healing a mode its menu doesn't have). + None => BrushSettings { smoothing: first_smoothing(), mode: photocraft_color::BlendMode::Normal, ..current }, }; // The picked preset was the outgoing tool's brush: forget it, so Update Brush can't overwrite // that preset with this tool's brush. @@ -611,6 +613,7 @@ mod tests { // Mode, opacity, flow and the dynamics sections are per tool too. app.ui.tool = Tool::CloneStamp; sync_tool_brush(&mut app); + assert_eq!(mode(&brush(&app)), photocraft_color::BlendMode::Normal, "a new tool starts in Normal, not the Brush's Multiply"); app.run("tools.setBrush", json!({"brush": {"mode": "Screen", "opacity": 0.3}})).unwrap(); app.ui.tool = Tool::Brush; sync_tool_brush(&mut app); diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 18cef34c98..6fb870b93e 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -1009,12 +1009,21 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { crate::brush_picker::settings_toggle(app, ui); widgets::vline(ui, 22.0); } - if tool == Tool::CloneStamp { + if matches!(tool, Tool::CloneStamp | Tool::PatternStamp | Tool::HistoryBrush | Tool::Healing) { let before = app.session.tools.brush.clone(); let mut brush = before.clone(); - let width = if t.pro { 62.0 } else { 66.0 }; - percent_field(ui, tl!("Opacity"), &mut brush.opacity, 1.0..=100.0, width); - percent_field(ui, tl!("Flow"), &mut brush.flow, 1.0..=100.0, width); + // Mode is the tool's own brush's, kept per tool like its size. + if let Some(modes) = crate::blend_keys::tool_modes(tool) { + opt_label(ui, tl!("Mode")); + if let Some(Some(m)) = tool_mode_dropdown(ui, "retouch-mode", &modes, Some(brush.mode)) { + brush.mode = m; + } + } + if tool == Tool::CloneStamp { + let width = if t.pro { 62.0 } else { 66.0 }; + percent_field(ui, tl!("Opacity"), &mut brush.opacity, 1.0..=100.0, width); + percent_field(ui, tl!("Flow"), &mut brush.flow, 1.0..=100.0, width); + } crate::brush_panel::commit_gesture(app, ui.ctx(), &before, &brush); widgets::vline(ui, 22.0); } @@ -1267,6 +1276,17 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { if widgets::dropdown(ui, "bucket-src", &mut src, &[(0u8, tl!("Foreground")), (1, tl!("Pattern"))], 100.0) { app.ui.tool_options.bucket_fill_pattern = src == 1; } + opt_label(ui, tl!("Mode")); + if let Some(modes) = crate::blend_keys::tool_modes(tool) { + let o = &mut app.ui.tool_options; + let current = if o.bucket_clear { None } else { Some(o.bucket_blend_mode) }; + if let Some(m) = tool_mode_dropdown(ui, "bucket-mode", &modes, current) { + o.bucket_clear = m.is_none(); + if let Some(m) = m { + o.bucket_blend_mode = m; + } + } + } opt_label(ui, tl!("Opacity")); widgets::value_field(ui, &mut app.ui.tool_options.fill_opacity, 1.0..=100.0, "%", 62.0); opt_label(ui, tl!("Tolerance")); @@ -4099,6 +4119,15 @@ fn brush_tip(p: &egui::Painter, c: egui::Pos2, rad: f32, hardness: f32, color: C /// The Brush's or Pencil's Mode dropdown: the blend modes, with Photoshop's painting-only Clear /// after Dissolve (#3439). Clear erases with the brush (`clear`); it shows while chosen, or while /// `~` is held (`held`). The wheel over it steps the mode, as over the Layers panel's (#2061). +/// A painting tool's Mode dropdown over `modes` (`None` is Clear); the wheel over it steps the +/// mode. Returns the mode picked this frame. +fn tool_mode_dropdown(ui: &mut egui::Ui, id: &str, modes: &[Option], current: Option) -> Option> { + let opts: Vec<(Option, &str)> = modes.iter().map(|m| (*m, m.map_or("Clear", BlendMode::label))).collect(); + let mut mode = current; + let chosen = widgets::dropdown_wheel_hovered(ui, id, &mut mode, &opts, 96.0).0; + chosen.last().copied() +} + fn paint_mode_dropdown(ui: &mut egui::Ui, id: &str, b: &mut photocraft_engine::BrushSettings, clear: &mut bool, held: bool) { let mut opts: Vec<(Option, &str)> = BlendMode::LAYER_MODES.iter().map(|m| (Some(*m), m.label())).collect(); let at = opts.iter().position(|o| o.0 == Some(BlendMode::Dissolve)).map_or(opts.len(), |i| i + 1); diff --git a/crates/ui-egui/src/retouch_ui.rs b/crates/ui-egui/src/retouch_ui.rs index 20efb9bc0b..0f3da83947 100644 --- a/crates/ui-egui/src/retouch_ui.rs +++ b/crates/ui-egui/src/retouch_ui.rs @@ -27,7 +27,8 @@ pub(crate) fn alt_flipped(tool: Tool, alt: bool) -> Tool { /// point is set yet. pub(crate) fn clone_params(app: &PhotocraftApp) -> Option { let o = &app.ui.tool_options; - let mut p = json!({"aligned": o.clone_aligned, "sampleLayer": o.clone_sample}); + // The options bar's Mode is the tool's own brush's. + let mut p = json!({"aligned": o.clone_aligned, "sampleLayer": o.clone_sample, "mode": app.session.tools.brush.mode.label()}); if app.ui.tool == Tool::CloneStamp { p["wrap"] = json!(app.ui.view.pattern_preview); p["opacity"] = json!(app.session.tools.brush.opacity * 100.0); @@ -45,6 +46,12 @@ pub(crate) fn clone_params(app: &PhotocraftApp) -> Option { Some(p) } +/// History Brush params for the live preview and the commit (without `points` and `target`): the +/// options bar's Mode, which is the tool's own brush's. +pub(crate) fn history_brush_params(app: &PhotocraftApp) -> Value { + json!({"mode": app.session.tools.brush.mode.label()}) +} + /// The command and options-bar params (without `points` and `target`) of a sequential-dab tool: /// Blur, Sharpen, Smudge, Dodge, Burn, Sponge. Shared by the live preview and the commit. pub(crate) fn dab_params(app: &PhotocraftApp, tool: Tool) -> Option<(&'static str, Value)> { @@ -100,6 +107,7 @@ pub fn finish_stroke(app: &mut PhotocraftApp, tool: Tool, points: &[[f64; 3]], m "impressionist": o.pattern_stamp_impressionist, "scale": o.pattern_stamp_scale, "angle": o.pattern_stamp_angle, + "mode": app.session.tools.brush.mode.label(), }); if o.pattern_stamp_aligned && let Some(ph) = app.ui.pattern_stamp_phase @@ -125,7 +133,7 @@ pub fn finish_stroke(app: &mut PhotocraftApp, tool: Tool, points: &[[f64; 3]], m }; (if tool == Tool::Healing { "paint.healingBrush" } else { "paint.cloneStamp" }, p) } - Tool::HistoryBrush => ("paint.historyBrush", json!({})), + Tool::HistoryBrush => ("paint.historyBrush", history_brush_params(app)), Tool::Blur | Tool::Sharpen | Tool::Smudge | Tool::Dodge | Tool::Burn | Tool::Sponge => match dab_params(app, tool) { Some(cp) => cp, None => return false, @@ -781,6 +789,51 @@ mod tests { assert_eq!(params["flow"], 50.0); } + /// The options bar's Mode (each tool's own brush's) reaches the stamps', the History Brush's + /// and the Healing Brush's strokes, live and committed. + #[test] + fn retouch_mode_reaches_the_command() { + for (tool, cmd, mode) in [ + (Tool::CloneStamp, "paint.cloneStamp", "Multiply"), + (Tool::Healing, "paint.healingBrush", "Luminosity"), + (Tool::HistoryBrush, "paint.historyBrush", "Screen"), + (Tool::PatternStamp, "paint.patternStamp", "Overlay"), + ] { + let mut app = app(); + app.ui.tool = tool; + crate::paint_mouse::sync_tool_brush(&mut app); + app.run("tools.setBrush", json!({"brush": {"mode": mode}})).unwrap(); + app.ui.clone_source = Some([10.0, 10.0]); + drag(&mut app, tool); + let (id, params) = app.session.journal.last().unwrap(); + assert_eq!((id.as_str(), params["mode"].as_str()), (cmd, Some(mode)), "{tool:?}"); + } + } + + /// The Paint Bucket's Mode reaches the fill: Multiply darkens, Clear erases. + #[test] + fn paint_bucket_mode_reaches_the_fill() { + let mut app = app(); + app.run("layer.new.layer", json!({})).unwrap(); + app.ui.tool = Tool::PaintBucket; + app.session.tools.foreground = [0.5, 0.5, 0.5, 1.0]; + let click = |app: &mut PhotocraftApp| { + let m = egui::Modifiers::NONE; + tool_event(app, ToolEvent::Down { x: 20.0, y: 20.0, pressure: 1.0 }, m); + tool_event(app, ToolEvent::Up { x: 20.0, y: 20.0 }, m); + }; + click(&mut app); + app.session.tools.foreground = [1.0, 0.0, 0.0, 1.0]; + app.ui.tool_options.bucket_blend_mode = photocraft_color::BlendMode::Multiply; + click(&mut app); + let px = active(&app).surface().unwrap().rgba(20, 20); + assert!((px[0] - 0.5).abs() < 0.02 && px[1] < 0.02, "multiplied: {px:?}"); + app.ui.tool_options.bucket_clear = true; + click(&mut app); + assert_eq!(app.session.journal.last().unwrap().1["mode"], "clear"); + assert!(active(&app).surface().unwrap().rgba(20, 20)[3] < 0.01, "cleared"); + } + #[test] fn clone_without_a_source_names_the_platform_modifier() { // Option-click on the Mac, Alt-click elsewhere (#251). diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 974d3fde35..3d4c248f8a 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -535,6 +535,10 @@ pub struct ToolOptions { pub fill_opacity: f32, /// Paint Bucket fill source: false = Foreground colour, true = Pattern (Patterns panel selection). pub bucket_fill_pattern: bool, + /// Paint Bucket › Mode (any layer mode; Clear is `bucket_clear`). + pub bucket_blend_mode: photocraft_color::BlendMode, + /// Paint Bucket › Mode: Clear, which erases the filled area (see `brush_clear`). + pub bucket_clear: bool, /// Type tool: family, style name, size (pt), anti-aliasing and paragraph alignment. pub type_font: String, pub type_style: String, @@ -828,6 +832,8 @@ impl Default for ToolOptions { gradient_blend_mode: photocraft_color::BlendMode::Normal, fill_opacity: 100.0, bucket_fill_pattern: false, + bucket_blend_mode: photocraft_color::BlendMode::Normal, + bucket_clear: false, type_font: "Inter".into(), type_style: "Regular".into(), type_size: 48.0, diff --git a/crates/ui-egui/src/tool_reset.rs b/crates/ui-egui/src/tool_reset.rs index 3c154d3a45..b672b0825f 100644 --- a/crates/ui-egui/src/tool_reset.rs +++ b/crates/ui-egui/src/tool_reset.rs @@ -190,7 +190,7 @@ pub fn option_keys(tool: Tool) -> &'static [&'static str] { Tool::ColorReplacement => reset!(cr_mode, cr_sampling, cr_limits, cr_tolerance, cr_anti_alias), Tool::MagicEraser => reset!(tolerance, anti_alias, contiguous, magic_eraser_opacity), Tool::Gradient => reset!(gradient_style, gradient_reverse, gradient_dither, gradient_classic, gradient_blend_mode, fill_opacity), - Tool::PaintBucket => reset!(bucket_fill_pattern, fill_opacity, tolerance, anti_alias, contiguous), + Tool::PaintBucket => reset!(bucket_fill_pattern, bucket_blend_mode, bucket_clear, fill_opacity, tolerance, anti_alias, contiguous), Tool::Type | Tool::VerticalType | Tool::HorizontalTypeMask | Tool::VerticalTypeMask => reset!(type_font, type_style, type_size, type_aa, type_align), Tool::Zoom => reset!(zoom_scrubby), Tool::SpotHealing => reset!(spot_type), diff --git a/docs/brush-parity.md b/docs/brush-parity.md index 5c75a3e55f..18a62f69f1 100644 --- a/docs/brush-parity.md +++ b/docs/brush-parity.md @@ -1,6 +1,6 @@ # Brush and painting parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (dragged preset tip preview; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (Mode for Clone Stamp, Pattern Stamp, History Brush, Healing and Paint Bucket; dragged preset tip preview; 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 @@ -92,10 +92,10 @@ tablets against Photoshop side by side. |---|---|---| | Brush, Pencil (aliased, Auto Erase), Eraser (Brush/Pencil/Block) | done | Pencil 1 px quality #2139 | | Mixer Brush (Wet, Load, Mix, Flow, Sample All Layers, Current Brush Load with Load Brush and Clean Brush, automatic Load and Clean) | partial | No live result while dragging, no Alt-click loading (#2247) | -| Clone Stamp (opacity, flow, aligned, sample, overlay) | partial | Clone Source W/H link and Alt target cursor (TOOL-213-8) | -| Pattern Stamp (aligned, impressionist) | done | | -| History Brush | done | Art History Brush missing | -| Spot Healing, Healing | partial | grain not matched on flat colour (#2104), "horrible in general" (#1092), stops responding after switching (#1751) | +| Clone Stamp (mode, opacity, flow, aligned, sample, overlay) | partial | Clone Source W/H link and Alt target cursor (TOOL-213-8) | +| Pattern Stamp (mode, aligned, impressionist) | done | | +| History Brush (mode) | done | Art History Brush missing | +| Spot Healing, Healing (Healing mode: Normal, Multiply, Screen, Darken, Lighten, Color, Luminosity) | partial | Healing's Replace mode and Spot Healing's Mode missing; grain not matched on flat colour (#2104), "horrible in general" (#1092), stops responding after switching (#1751) | | Blur, Sharpen, Smudge (premultiplied, Sample All Layers, spacing) | done | BUG-207-2/3, #2171 | | Dodge, Burn, Sponge | done | | | Background Eraser, Magic Eraser | done | | @@ -123,4 +123,5 @@ tablets against Photoshop side by side. | 2026-10-12 | minor | A shaped tip's cursor outline turns and flips with a rotated or flipped view, and follows pixel aspect correction | | 2026-10-13 | minor | Shape Dynamics and Transfer minimum inputs follow their Control and retain their values while disabled (#3825, partial). No brush-feel estimate changed. | | 2026-10-13 | minor | Hue Jitter uses the same themed amount slider as other jitter controls (#3825, partial). No brush-feel estimate changed. | +| 2026-10-14 | minor | Options-bar Mode for Clone Stamp, Pattern Stamp, History Brush and Healing (kept in each tool's brush) and Paint Bucket (with Clear); each tool's first brush starts in Normal. No brush-feel estimate changed. | | 2026-10-13 | minor | Dragging a brush preset shows its cached tip thumbnail and name in the Brushes panel and preset picker (#4225, partial). No brush-feel estimate changed. | diff --git a/docs/ui-parity.md b/docs/ui-parity.md index c01aee5c4d..084bf3f87f 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI parity: tools, handles, modifiers and feel -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-15 · **Change:** minor (⇧⌥ blend mode letters; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-15 · **Change:** minor (⇧⌥ blend mode letters; painting tool Mode menus; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; 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, @@ -195,7 +195,7 @@ Triangle and Curvature Pen (minus legacy Rounded Rectangle and Targeted Adjustme | Tool keys: ← / → turn the brush tip (1°, ⇧ 15°), ⇧-click with Type starts new text over old, Space+F / ⇧Space+F cycle the pasteboard colour | done (2026-10-11) | | | Type formatting keys while editing text | done: ⇧⌘K, U, B, I and / toggle All Caps, Underline, Faux Bold, Faux Italic, Strikethrough (off when every selected character has it, else on); ⌥↑/↓ leading ∓2 pt, ⇧⌥↑/↓ baseline shift ±2 pt (10 with ⌘); ⌥←/→ tracking ±20 over a selection (100 with ⌘; a collapsed caret still kerns); ⌥⇧⌘H toggles Hyphenate for the touched paragraphs. One `type.setStyle` step per press (new `leadingBy`/`baselineShiftBy`/`trackingBy`; auto leading starts from its laid-out value); the global ⇧⌘K/U/B/I never fire while typing. Differs: a collapsed caret in non-empty text changes nothing, since the model can't hold a pending style for the next characters typed (empty text takes it as its typing style) (`type_tool.rs`, `input_tests.rs` `type_tool_format_keys_*`) | | | Guides: click selects, Delete deletes, right-click menu, ⌥-click turns a guide, double-click opens Guides, Grid & Slices | done (2026-10-12) | | -| Blend mode keys: ⇧⌥ + letter picks a mode (N Normal, I Dissolve, R Clear, P Pass Through, K M B A darken, G S D W lighten, O F H V J Z L contrast, E X difference, U T C Y component), ⇧+ / ⇧− step through them | done (2026-10-14): Brush, Pencil and Gradient take them as their own mode (Clear on Brush and Pencil only), any non-painting tool sets every selected layer in one undo step (Pass Through on groups only; the Background is skipped); the typed letter wins, the physical key is the fallback for ⌥ characters on a Mac. ⇧⌥ letters no longer switch tools. While a Free Transform box, Puppet Warp or Perspective Warp is open they, and the number keys, still reach the tool (or the layers) without closing it. Differs: Behind (⇧⌥Q) is not implemented; Clone Stamp, Pattern Stamp, History Brush, Healing, Paint Bucket and Magic Eraser ignore the keys until their options bar has a Mode | `blend_keys.rs` | +| Blend mode keys: ⇧⌥ + letter picks a mode (N Normal, I Dissolve, R Clear, P Pass Through, K M B A darken, G S D W lighten, O F H V J Z L contrast, E X difference, U T C Y component), ⇧+ / ⇧− step through them | done (2026-10-14): Brush, Pencil and Gradient take them as their own mode (Clear on Brush and Pencil only), any non-painting tool sets every selected layer in one undo step (Pass Through on groups only; the Background is skipped); the typed letter wins, the physical key is the fallback for ⌥ characters on a Mac. ⇧⌥ letters no longer switch tools. While a Free Transform box, Puppet Warp or Perspective Warp is open they, and the number keys, still reach the tool (or the layers) without closing it. Clone Stamp, Pattern Stamp, History Brush, Healing (its own short list) and Paint Bucket (with Clear) take them as their own mode; tools without a blend mode (the Erasers, Mixer Brush, Dodge, Burn, Sponge) set the layers. Differs: Behind (⇧⌥Q) is not implemented; Spot Healing, Color Replacement, Blur, Sharpen and Smudge ignore the keys until their options bar has a Mode | `blend_keys.rs` | ## Panels and workspace @@ -260,3 +260,4 @@ Paragraph; the rest open as in-app floating windows. | 2026-10-14 | minor | Move › Show Transform Controls frames every selected layer and outlines the selected shapes | | 2026-10-14 | minor | ⇧⌥ + letter blend mode keys for the painting tool or every selected layer; ⇧+ / ⇧− now step every selected layer and include Clear for Brush and Pencil | | 2026-10-15 | minor | Blend mode and number keys work while a Free Transform, Puppet Warp or Perspective Warp is open | +| 2026-10-14 | minor | Mode dropdowns for Clone Stamp, Pattern Stamp, History Brush, Healing and Paint Bucket; the blend mode keys reach them, and tools without a blend mode pass the keys to the layers | From eabd5c13986ca68efba3f386451e16df86b51e39 Mon Sep 17 00:00:00 2001 From: Marco Arnulfo Date: Fri, 16 Oct 2026 13:23:33 +0200 Subject: [PATCH 179/649] Crop tool: right-click on a pending crop opens its menu: presets, overlays, Cancel and Crop (#6561) --- crates/ui-egui/src/canvas.rs | 4 +- crates/ui-egui/src/canvas_tool_menu.rs | 339 ++++++++++++++++++++- crates/ui-egui/src/control.rs | 46 ++- crates/ui-egui/src/crop_overlay.rs | 13 +- crates/ui-egui/src/crop_presets.rs | 31 +- crates/ui-egui/src/crop_size.rs | 9 + crates/ui-egui/src/panels.rs | 6 +- crates/ui-egui/src/shortcuts.rs | 5 +- crates/ui-egui/src/transform_type_tests.rs | 1 + docs/context-menu-parity.md | 5 +- docs/gaps.md | 6 +- 11 files changed, 434 insertions(+), 31 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index d2e535f3f6..4715613a87 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -3704,9 +3704,11 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: && !crate::layer_pick_ui::is_gesture(tool, mods) && let Some(p) = response.interact_pointer_pos() { + // A pending crop: its menu, also outside the image, where the frame can reach (#6561). // Outside the image: the pasteboard colour menu (#2462), else the tool's own. The view // menu belongs to the selected Zoom or Hand, not to Space or a held zoom key. - if crate::canvas_tool_menu::pasteboard_at(app, tool, xf.to_doc(p)) { + if crate::canvas_tool_menu::open_crop(app, &ctx, tool, [p.x, p.y]) { + } else if crate::canvas_tool_menu::pasteboard_at(app, tool, xf.to_doc(p)) { crate::canvas_tool_menu::open_pasteboard(app, &ctx, tool, [p.x, p.y]); } else if crate::canvas_tool_menu::is_view_tool(tool) { if tool == app.ui.tool { diff --git a/crates/ui-egui/src/canvas_tool_menu.rs b/crates/ui-egui/src/canvas_tool_menu.rs index 43418d5ff9..df77c70976 100644 --- a/crates/ui-egui/src/canvas_tool_menu.rs +++ b/crates/ui-egui/src/canvas_tool_menu.rs @@ -1,6 +1,6 @@ //! Canvas context menus for the selection tools, the Pen, the Zoom and Hand tools, an active Free //! Transform box, text being edited with a Type tool, committed type under a Type tool, the -//! pasteboard (outside the image) and a guide. +//! pasteboard (outside the image), a guide and a pending crop. use egui::Context; use photocraft_doc::LayerContent; @@ -42,6 +42,10 @@ pub struct CanvasToolMenu { /// the menu. #[serde(default)] pub spelling: Option, + /// Opened on a pending crop: the crop menu, listing the saved crop presets by the names they + /// had when it opened. + #[serde(default)] + pub crop: Option>, } /// A misspelled word in the type layer being edited (`edit.checkSpelling`'s `list` entry). @@ -63,7 +67,7 @@ const SPELLING_NONE: &str = "spelling.none"; const SPELLING_ADD: &str = "spelling.add"; /// One menu row: label and command id. `None` is a separator. -pub type Row = Option<(&'static str, &'static str)>; +pub type Row = Option<(S, S)>; /// Right-click while transforming, in Photoshop's order: what the box's handles do, then Rotate /// and Flip, which turn the open box without committing it (`transform_tool::intercept`). @@ -196,6 +200,146 @@ pub const GUIDE_MENU: &[Row] = &[ Some(("Clear Selected Artboard Guides", "view.clearSelectedArtboardGuides")), ]; +/// The crop menu's row ids. A ratio row is `crop.ratio.`, the options bar's preset dropdown +/// key (`crop_size::dropdown_options`); a saved preset is `crop.preset.`, the n-th name the menu +/// opened with; an overlay row is `crop.overlay.` or `crop.overlayShow.`. +const CROP_RATIO: &str = "crop.ratio."; +const CROP_PRESET: &str = "crop.preset."; +const CROP_OVERLAY: &str = "crop.overlay."; +const CROP_SHOW: &str = "crop.overlayShow."; +pub const CROP_CLEAR: &str = "crop.clear"; +pub const CROP_NEW: &str = "crop.newPreset"; +pub const CROP_DELETE: &str = "crop.deletePreset"; +pub const CROP_CANCEL: &str = "crop.cancel"; +pub const CROP_COMMIT: &str = "crop.commit"; + +/// The crop menu (right-click on a pending crop, #6561): the options bar's preset dropdown, in its +/// order, and its Clear; the overlay and when it shows; then Cancel and Crop, the bar's ⊘ and ✓. +/// Built from the bar's own lists, so the two cannot disagree. Empty for any other menu. +pub fn crop_rows(menu: &CanvasToolMenu) -> Vec> { + use crate::crop_overlay::{CropOverlay, OverlayShow}; + let Some(users) = menu.crop.as_ref() else { return Vec::new() }; + let ratio = |(k, l): &(String, &str)| Some((l.to_string(), format!("{CROP_RATIO}{k}"))); + let (before, after): (Vec<_>, Vec<_>) = crate::crop_size::dropdown_options().into_iter().partition(|(k, _)| k != crate::crop_size::FRONT); + let mut rows: Vec> = before.iter().map(ratio).collect(); + rows.extend(users.iter().enumerate().map(|(i, name)| Some((name.clone(), format!("{CROP_PRESET}{i}"))))); + rows.extend(after.iter().map(ratio)); + rows.push(Some(("Clear".into(), CROP_CLEAR.into()))); + rows.push(None); + rows.push(Some(("New Crop Preset…".into(), CROP_NEW.into()))); + rows.push(Some(("Delete Crop Preset…".into(), CROP_DELETE.into()))); + rows.push(None); + rows.extend(CropOverlay::ALL.iter().map(|k| Some((k.label().to_string(), format!("{CROP_OVERLAY}{}", k.id()))))); + rows.push(None); + rows.extend(OverlayShow::ALL.iter().map(|k| Some((k.label().to_string(), format!("{CROP_SHOW}{}", k.id()))))); + rows.push(None); + rows.push(Some(("Cancel".into(), CROP_CANCEL.into()))); + rows.push(Some(("Crop".into(), CROP_COMMIT.into()))); + rows +} + +/// Is a crop row's label UI text (translated), rather than a saved preset's name? +pub fn crop_label_is_ui(id: &str) -> bool { + !id.starts_with(CROP_PRESET) +} + +/// Is `command` one of the crop menu's rows? +fn is_crop(menu: &CanvasToolMenu, command: &str) -> bool { + crop_rows(menu).iter().flatten().any(|(_, id)| id == command) +} + +/// The saved crop preset a `crop.preset.` row picks. +fn crop_preset<'a>(menu: &'a CanvasToolMenu, command: &str) -> Option<&'a String> { + let n = command.strip_prefix(CROP_PRESET)?.parse::().ok()?; + menu.crop.as_ref()?.get(n) +} + +/// The crop menu's checkmarks, as the options bar shows them: the dropdown's entry (a saved +/// preset the fields hold, else the mode or ratio, so a size preset checks W x H x Resolution), +/// the overlay and when it shows. +fn crop_checked(app: &PhotocraftApp, menu: &CanvasToolMenu, command: &str) -> bool { + let o = &app.ui.tool_options; + let user = crate::crop_presets::current_user(app); + if let Some(k) = command.strip_prefix(CROP_RATIO) { + return user.is_none() && k == o.crop_ratio; + } + if command.starts_with(CROP_PRESET) { + return user.is_some() && crop_preset(menu, command) == user.as_ref(); + } + if let Some(k) = command.strip_prefix(CROP_OVERLAY) { + return k == o.crop_overlay.id(); + } + command.strip_prefix(CROP_SHOW).is_some_and(|k| k == o.crop_overlay_show.id()) +} + +fn crop_enabled(app: &PhotocraftApp, menu: &CanvasToolMenu, command: &str) -> bool { + match command { + CROP_NEW => crate::crop_presets::savable(&app.ui.tool_options).is_some(), + CROP_DELETE => menu.crop.as_ref().is_some_and(|u| !u.is_empty()), + c => is_crop(menu, c), + } +} + +/// Right-click with `tool` on a pending crop: the crop menu at screen point `pos`. Only the Crop +/// tool itself, not one held over it (Space's Hand). +pub fn open_crop(app: &mut PhotocraftApp, ctx: &Context, tool: Tool, pos: [f32; 2]) -> bool { + if tool != Tool::Crop || !crate::crop_ui::pending(app) || !pos.iter().all(|v| v.is_finite()) { + return false; + } + app.ui.brush_picker = None; + app.ui.layer_menu = None; + let users = crate::crop_presets::user_presets(app).into_iter().map(|(name, _)| name).collect(); + app.ui.canvas_tool_menu = Some(CanvasToolMenu { + pos, + tool, + has_selection: false, + has_path: false, + path_name: None, + transform: false, + pasteboard: false, + anchor: None, + text: false, + type_layer: false, + guide: false, + spelling: None, + crop: Some(users), + }); + crate::canvas_popup::mark_open(ctx, menu_id()); + true +} + +/// A crop row: each runs what its options-bar twin runs. +fn choose_crop(app: &mut PhotocraftApp, menu: &CanvasToolMenu, command: &str) -> Result<(), String> { + use crate::crop_overlay::{CropOverlay, OverlayShow}; + use crate::crop_presets::{Choice, apply_choice}; + match command { + CROP_CANCEL => crate::crop_ui::cancel(app), + CROP_COMMIT => crate::canvas::commit_crop(app), + CROP_NEW => apply_choice(app, Choice::New), + CROP_DELETE => apply_choice(app, Choice::Delete), + _ => { + let before = crate::crop_ui::preset_ratio(app); + if let Some(k) = command.strip_prefix(CROP_RATIO) { + apply_choice(app, Choice::Builtin(k.to_string())); + } else if let Some(name) = crop_preset(menu, command) { + apply_choice(app, Choice::User(name.clone())); + } else if command == CROP_CLEAR { + crate::crop_size::clear_ratio(&mut app.ui.tool_options); + } else if let Some(k) = command.strip_prefix(CROP_OVERLAY).and_then(CropOverlay::from_id) { + crate::crop_overlay::set_overlay(&mut app.ui.tool_options, k); + } else if let Some(k) = command.strip_prefix(CROP_SHOW).and_then(OverlayShow::from_id) { + app.ui.tool_options.crop_overlay_show = k; + } + // As the options bar does: a saved preset or Clear changes the ratio without refitting + // the frame, so refit it when the ratio (or W x H) the frame follows changed. + if crate::crop_ui::preset_ratio(app) != before { + crate::crop_ui::apply_ratio(app); + } + } + } + Ok(()) +} + /// The pasteboard colours in the menu's order, which Space+F steps through. const CANVAS_COLORS: [CanvasColor; 6] = [CanvasColor::Default, CanvasColor::Black, CanvasColor::DarkGray, CanvasColor::MediumGray, CanvasColor::LightGray, CanvasColor::Custom]; @@ -337,7 +481,10 @@ pub fn selection_rows(has_selection: bool) -> &'static [Row] { /// The rows of an open menu. pub fn rows(menu: &CanvasToolMenu) -> &'static [Row] { - if menu.guide { + if menu.crop.is_some() { + // Built per menu: [`crop_rows`]. + &[] + } else if menu.guide { GUIDE_MENU } else if menu.pasteboard { PASTEBOARD_MENU @@ -358,13 +505,16 @@ pub fn rows(menu: &CanvasToolMenu) -> &'static [Row] { /// Is `command` one of the open menu's rows, and enabled? pub fn available(app: &PhotocraftApp, menu: &CanvasToolMenu, command: &str) -> bool { - (rows(menu).iter().flatten().any(|(_, id)| *id == command) || is_spelling(menu, command)) && entry_enabled(app, menu, command) + (rows(menu).iter().flatten().any(|(_, id)| *id == command) || is_spelling(menu, command) || is_crop(menu, command)) && entry_enabled(app, menu, command) } /// Is `command` the transform box's current mode (checked in the transform menu)? /// Scale stays Free Transform's mode (only Free Transform is checked). Rotate is its own mode. /// Warp is not a box mode (it is its own session), and `for_command` would read it as Free. pub(crate) fn mode_checked(app: &PhotocraftApp, menu: &CanvasToolMenu, command: &str) -> bool { + if menu.crop.is_some() { + return crop_checked(app, menu, command); + } if menu.guide { return command == "view.lockGuides" && app.ui.extras.lock_guides; } @@ -486,6 +636,7 @@ pub fn open_transform(app: &mut PhotocraftApp, ctx: &Context, pos: [f32; 2]) -> type_layer: false, guide: false, spelling: None, + crop: None, }); crate::canvas_popup::mark_open(ctx, menu_id()); true @@ -500,6 +651,9 @@ fn pasteboard_choice(command: &str) -> Option { /// The engine command (and params) a pasteboard row runs, for the automation policy: every row /// changes a preference. pub fn engine_call(app: &PhotocraftApp, menu: &CanvasToolMenu, command: &str) -> (String, Value) { + if menu.crop.is_some() && command == CROP_COMMIT { + return ("image.crop".into(), json!({})); + } if menu.guide { let selected = crate::guide_select::selected(app); return match command { @@ -560,6 +714,7 @@ pub fn open_pasteboard(app: &mut PhotocraftApp, ctx: &Context, tool: Tool, pos: type_layer: false, guide: false, spelling: None, + crop: None, }); crate::canvas_popup::mark_open(ctx, menu_id()); true @@ -590,6 +745,7 @@ pub fn open_guide(app: &mut PhotocraftApp, ctx: &Context, tool: Tool, mods: egui type_layer: false, guide: true, spelling: None, + crop: None, }); crate::canvas_popup::mark_open(ctx, menu_id()); true @@ -617,6 +773,9 @@ fn choose_pasteboard(app: &mut PhotocraftApp, menu: &CanvasToolMenu, command: &s } pub fn entry_enabled(app: &PhotocraftApp, menu: &CanvasToolMenu, command: &str) -> bool { + if menu.crop.is_some() { + return crop_enabled(app, menu, command); + } if menu.guide { return match command { GUIDE_EDIT | GUIDE_CLEAR => crate::guide_select::selected(app).is_some(), @@ -717,6 +876,7 @@ pub fn open_at(app: &mut PhotocraftApp, ctx: &Context, tool: Tool, pos: [f32; 2] type_layer, guide: false, spelling, + crop: None, }); crate::canvas_popup::mark_open(ctx, menu_id()); true @@ -743,6 +903,7 @@ pub fn open_view(app: &mut PhotocraftApp, ctx: &Context, tool: Tool, pos: [f32; type_layer: false, guide: false, spelling: None, + crop: None, }); crate::canvas_popup::mark_open(ctx, menu_id()); true @@ -779,7 +940,9 @@ pub fn choose(app: &mut PhotocraftApp, ctx: &Context, command: &str) { if !available(app, &menu, command) { return; } - let result = if menu.guide { + let result = if menu.crop.is_some() { + choose_crop(app, &menu, command) + } else if menu.guide { choose_guide(app, ctx, command) } else if menu.pasteboard { choose_pasteboard(app, &menu, command) @@ -925,6 +1088,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &Context) { || (menu.transform && app.ui.transform.is_none()) || (menu.text && app.ui.text_edit.is_none()) || (menu.type_layer && app.ui.text_edit.is_some()) + || (menu.crop.is_some() && !crate::crop_ui::pending(app)) { app.ui.canvas_tool_menu = None; return; @@ -959,6 +1123,17 @@ pub fn show(app: &mut PhotocraftApp, ctx: &Context) { if !spelling.is_empty() { ui.separator(); } + for row in crop_rows(&menu) { + let Some((label, command)) = row else { + ui.separator(); + continue; + }; + let text = if crop_label_is_ui(&command) { tl!(&label).to_string() } else { label }; + let item = egui::Button::selectable(mode_checked(app, &menu, &command), text).min_size(egui::vec2(200.0, 20.0)); + if ui.add_enabled(entry_enabled(app, &menu, &command), item).clicked() { + selected = Some(command); + } + } for row in rows(&menu) { let Some((label, command)) = *row else { ui.separator(); @@ -1830,4 +2005,158 @@ mod tests { } assert!(entry_enabled(&app, menu, "path.toSelection")); } + + /// A 32 × 32 document with the Crop tool picked (Classic Mode, so the view stays put) and its + /// untouched default frame. + fn crop_app() -> PhotocraftApp { + let mut app = app(); + app.ui.tool = Tool::Crop; + app.ui.tool_options.crop_shield.classic_mode = true; + app.ui.extras.snap = false; + crate::crop_ui::ensure_frame(&mut app); + app + } + + /// Draws a crop frame from (4, 4) to (28, 28): a pending crop. Returns the frame. + fn draw_crop(app: &mut PhotocraftApp) -> [f64; 4] { + use crate::canvas::{ToolEvent, tool_event}; + tool_event(app, ToolEvent::Down { x: 4.0, y: 4.0, pressure: 1.0 }, Modifiers::NONE); + tool_event(app, ToolEvent::Move { x: 16.0, y: 16.0, pressure: 1.0 }, Modifiers::NONE); + tool_event(app, ToolEvent::Move { x: 28.0, y: 28.0, pressure: 1.0 }, Modifiers::NONE); + tool_event(app, ToolEvent::Up { x: 28.0, y: 28.0 }, Modifiers::NONE); + assert!(crate::crop_ui::pending(app), "the drag draws a pending frame"); + app.ui.crop_rect.unwrap() + } + + fn aspect(r: [f64; 4]) -> f64 { + (r[2] - r[0]) / (r[3] - r[1]) + } + + /// #6561: right-click on a pending crop opens its menu without touching the frame, and a ratio + /// row refits the frame as the options bar's dropdown does. + #[test] + fn right_click_on_a_pending_crop_opens_the_crop_menu_and_a_ratio_refits_the_frame() { + let mut app = crop_app(); + let frame = draw_crop(&mut app); + let mut h = harness(app); + let center = h.state().last_canvas_rect.center(); + right_click(&mut h, center, Modifiers::NONE); + let menu = h.state().ui.canvas_tool_menu.clone().expect("right-click on a pending crop opens a menu"); + assert_eq!(h.state().ui.crop_rect, Some(frame), "the right-click leaves the frame alone"); + assert!(available(h.state(), &menu, "crop.ratio.16:9"), "the menu lists the options bar's ratios"); + let ctx = h.ctx.clone(); + choose(h.state_mut(), &ctx, "crop.ratio.16:9"); + assert_eq!(h.state().ui.tool_options.crop_ratio, "16:9"); + let r = h.state().ui.crop_rect.unwrap(); + assert!((aspect(r) - 16.0 / 9.0).abs() < 1e-9, "the frame is 16 : 9 now: {r:?}"); + assert!(r[0] >= frame[0] && r[1] >= frame[1] && r[2] <= frame[2] && r[3] <= frame[3], "fitted inside the old frame: {r:?}"); + assert!(h.state().ui.canvas_tool_menu.is_none()); + } + + #[test] + fn untouched_crop_frame_has_no_menu_and_a_pending_one_wins_over_the_pasteboard() { + let mut h = harness(crop_app()); + let rect = h.state().last_canvas_rect; + let outside = rect.min + vec2(5.0, 5.0); + right_click(&mut h, rect.center(), Modifiers::NONE); + assert!(h.state().ui.canvas_tool_menu.is_none(), "the tool's untouched frame is no crop in progress"); + right_click(&mut h, outside, Modifiers::NONE); + assert!(h.state().ui.canvas_tool_menu.as_ref().is_some_and(|m| m.pasteboard), "outside: the pasteboard menu, as before"); + h.state_mut().ui.canvas_tool_menu = None; + draw_crop(h.state_mut()); + h.run_steps(2); + right_click(&mut h, outside, Modifiers::NONE); + let menu = h.state().ui.canvas_tool_menu.clone().unwrap(); + assert!(menu.crop.is_some() && !menu.pasteboard, "with a crop pending, its menu also outside the image"); + } + + #[test] + fn esc_closes_only_the_crop_menu() { + let mut app = crop_app(); + let frame = draw_crop(&mut app); + app.sync_views(); + let mut h = Harness::builder().with_size(vec2(1000.0, 700.0)).build_ui_state( + |ui, app: &mut PhotocraftApp| { + let ctx = ui.ctx().clone(); + if !ctx.fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { + return; + } + // The app's order: shortcuts (the crop's Esc among them), then the canvas. + crate::shortcuts::handle(app, &ctx); + egui::CentralPanel::default().show(ui, |ui| crate::canvas::document_area(app, ui)); + }, + app, + ); + PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::default()); + h.run_steps(4); + let center = h.state().last_canvas_rect.center(); + right_click(&mut h, center, Modifiers::NONE); + assert!(h.state().ui.canvas_tool_menu.as_ref().is_some_and(|m| m.crop.is_some())); + h.key_press(egui::Key::Escape); + h.run_steps(2); + assert!(h.state().ui.canvas_tool_menu.is_none(), "Esc closes the menu"); + assert_eq!(h.state().ui.crop_rect, Some(frame), "and only the menu: the crop is not cancelled"); + assert!(crate::crop_ui::pending(h.state())); + } + + #[test] + fn crop_menu_rows_act_like_the_options_bar() { + use crate::crop_overlay::{CropOverlay, OverlayShow}; + let ctx = Context::default(); + let mut app = crop_app(); + draw_crop(&mut app); + // Space's Hand held over the Crop tool keeps its own right-click. + assert!(!open_crop(&mut app, &ctx, Tool::Hand, [10.0, 10.0])); + let reopen = |app: &mut PhotocraftApp| { + assert!(open_crop(app, &Context::default(), Tool::Crop, [10.0, 10.0])); + app.ui.canvas_tool_menu.clone().unwrap() + }; + // Nothing to save with a free ratio, nothing to delete without saved presets. + let menu = reopen(&mut app); + assert!(!entry_enabled(&app, &menu, CROP_NEW) && !entry_enabled(&app, &menu, CROP_DELETE)); + assert!(mode_checked(&app, &menu, "crop.ratio."), "free Ratio is checked, as in the dropdown"); + // A size preset fills W x H x Resolution, which the menu checks, as the dropdown does. + choose(&mut app, &ctx, "crop.ratio.preset:4x5in"); + let menu = reopen(&mut app); + assert!(mode_checked(&app, &menu, "crop.ratio.whr") && !mode_checked(&app, &menu, "crop.ratio.preset:4x5in")); + assert!((aspect(app.ui.crop_rect.unwrap()) - 0.8).abs() < 1e-9); + assert!(entry_enabled(&app, &menu, CROP_NEW)); + // Clear empties W x H x Resolution, as the bar's Clear. + choose(&mut app, &ctx, CROP_CLEAR); + assert_eq!(app.ui.tool_options.crop_width, ""); + // Overlays: another overlay starts at its first orientation; when it shows. + app.ui.tool_options.crop_overlay = CropOverlay::GoldenSpiral; + app.ui.tool_options.crop_overlay_orientation = 2; + reopen(&mut app); + choose(&mut app, &ctx, "crop.overlay.triangle"); + assert_eq!((app.ui.tool_options.crop_overlay, app.ui.tool_options.crop_overlay_orientation), (CropOverlay::Triangle, 0)); + reopen(&mut app); + choose(&mut app, &ctx, "crop.overlayShow.never"); + assert_eq!(app.ui.tool_options.crop_overlay_show, OverlayShow::Never); + let menu = reopen(&mut app); + assert!(mode_checked(&app, &menu, "crop.overlay.triangle") && mode_checked(&app, &menu, "crop.overlayShow.never")); + // A saved preset is listed by name; picking it refits the frame to its W x H, though the + // ratio key is "whr" before and after. + app.ui.canvas_tool_menu = None; + app.ui.tool_options.crop_ratio = crate::crop_size::WHR.into(); + let saved = json!({"crop_ratio": "whr", "crop_width": "300 px", "crop_height": "100 px", "crop_resolution": "72", "crop_resolution_unit": "px/in"}); + app.run("tool.presets.new", json!({"name": "Banner", "tool": "crop", "options": {"toolOptions": saved}})).unwrap(); + let menu = reopen(&mut app); + let banner = crop_rows(&menu).into_iter().flatten().find(|(l, _)| l == "Banner").expect("the saved preset is a row").1; + assert!(entry_enabled(&app, &menu, CROP_DELETE)); + choose(&mut app, &ctx, &banner); + assert_eq!(app.ui.tool_options.crop_width, "300 px"); + assert!((aspect(app.ui.crop_rect.unwrap()) - 3.0).abs() < 1e-9, "the frame follows the preset: {:?}", app.ui.crop_rect); + let menu = reopen(&mut app); + assert!(mode_checked(&app, &menu, &banner)); + // Crop commits as ↵ does: the preset's size. + choose(&mut app, &ctx, CROP_COMMIT); + let size = app.session.active().unwrap().doc.size; + assert_eq!((size.width, size.height), (300, 100)); + // Cancel drops a pending crop. + draw_crop(&mut app); + reopen(&mut app); + choose(&mut app, &ctx, CROP_CANCEL); + assert!(!crate::crop_ui::pending(&app)); + } } diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index 46f17357d1..14fd82c522 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -372,12 +372,16 @@ pub fn handle(app: &mut PhotocraftApp, ctx: &egui::Context, req: &ControlRequest /// The open canvas context menu's rows for `ui.state`: the spelling suggestions first (type edit /// menu over a misspelled word), then the menu's own rows. fn context_entries(app: &PhotocraftApp, menu: &crate::canvas_tool_menu::CanvasToolMenu) -> Vec { - use crate::canvas_tool_menu::{entry_enabled, rows, spelling_rows}; + use crate::canvas_tool_menu::{crop_rows, entry_enabled, rows, spelling_rows}; let spelling = spelling_rows(menu); let mut entries: Vec = spelling.iter().map(|(label, id)| json!({"label": label, "id": id, "enabled": entry_enabled(app, menu, id)})).collect(); if !spelling.is_empty() { entries.push(json!({"separator": true})); } + entries.extend(crop_rows(menu).iter().map(|row| match row { + Some((label, id)) => json!({"label": label, "id": id, "enabled": entry_enabled(app, menu, id)}), + None => json!({"separator": true}), + })); entries.extend(rows(menu).iter().map(|row| match row { Some((label, id)) => json!({"label": label, "id": id, "enabled": entry_enabled(app, menu, id)}), None => json!({"separator": true}), @@ -1088,6 +1092,12 @@ fn dispatch(app: &mut PhotocraftApp, ctx: &egui::Context, req: &ControlRequest) } continue; } + if app.ui.tool == crate::state::Tool::Crop && crate::crop_ui::pending(app) { + if down { + crate::canvas_tool_menu::open_crop(app, ctx, app.ui.tool, screen_point(app, x, y)); + } + continue; + } if crate::canvas_tool_menu::pasteboard_at(app, app.ui.tool, [x, y]) { if down { crate::canvas_tool_menu::open_pasteboard(app, ctx, app.ui.tool, screen_point(app, x, y)); @@ -1339,6 +1349,7 @@ pub fn inspect(app: &PhotocraftApp, ctx: &egui::Context) -> Value { "tool": menu.tool, "pasteboard": menu.pasteboard, "guide": menu.guide, + "crop": menu.crop.is_some(), "entries": context_entries(app, menu) }) }), @@ -1871,6 +1882,39 @@ mod tests { assert!(app.ui.canvas_tool_menu.is_none()); } + /// #6561: an agent's right-click on a pending crop opens the crop menu, as on the canvas. + #[test] + fn agent_right_click_on_a_pending_crop_opens_and_runs_the_crop_menu() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + let ctx = egui::Context::default(); + app.run("file.new", json!({"width": 32, "height": 32})).unwrap(); + app.sync_views(); + app.ui.tool = crate::state::Tool::Crop; + app.ui.tool_options.crop_shield.classic_mode = true; + app.ui.extras.snap = false; + crate::crop_ui::ensure_frame(&mut app); + tool_event(&mut app, ToolEvent::Down { x: 4.0, y: 4.0, pressure: 1.0 }, egui::Modifiers::NONE); + tool_event(&mut app, ToolEvent::Move { x: 16.0, y: 12.0, pressure: 1.0 }, egui::Modifiers::NONE); + tool_event(&mut app, ToolEvent::Move { x: 28.0, y: 20.0, pressure: 1.0 }, egui::Modifiers::NONE); + tool_event(&mut app, ToolEvent::Up { x: 28.0, y: 20.0 }, egui::Modifiers::NONE); + let frame = app.ui.crop_rect.unwrap(); + let result = call( + &mut app, + &ctx, + "ui.pointer", + json!({"tool": "Crop", "button": "secondary", "events": [{"kind":"down","x":16,"y":12},{"kind":"up","x":16,"y":12}]}), + ); + assert_eq!(result["ok"], true); + let inspected = call(&mut app, &ctx, "ui.inspect", json!({})); + assert_eq!(inspected.pointer("/result/canvasToolMenu/crop"), Some(&json!(true))); + let entries = inspected.pointer("/result/canvasToolMenu/entries").and_then(Value::as_array).unwrap(); + assert!(entries.iter().any(|row| row.get("id") == Some(&json!("crop.commit")) && row.get("enabled") == Some(&json!(true)))); + assert_eq!(app.ui.crop_rect, Some(frame), "the right-click leaves the frame alone"); + assert_eq!(call(&mut app, &ctx, "ui.context.choose", json!({"id":"crop.commit"}))["ok"], true); + let size = app.session.active().unwrap().doc.size; + assert_eq!([f64::from(size.width), f64::from(size.height)], [frame[2] - frame[0], frame[3] - frame[1]], "cropped to the frame"); + } + #[test] fn agent_can_inspect_and_choose_pen_make_selection_from_full_context_menu() { let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); diff --git a/crates/ui-egui/src/crop_overlay.rs b/crates/ui-egui/src/crop_overlay.rs index b0be59f2b1..c93f5e12e1 100644 --- a/crates/ui-egui/src/crop_overlay.rs +++ b/crates/ui-egui/src/crop_overlay.rs @@ -249,6 +249,14 @@ pub fn cycle(o: &mut ToolOptions) { o.crop_overlay_orientation = 0; } +/// Picks overlay `k`; another overlay starts at its first orientation. +pub fn set_overlay(o: &mut ToolOptions, k: CropOverlay) { + if o.crop_overlay != k { + o.crop_overlay_orientation = 0; + } + o.crop_overlay = k; +} + /// ⇧O: the overlay's next orientation (nothing for a symmetric one). pub fn cycle_orientation(o: &mut ToolOptions) { let n = o.crop_overlay.orientations().max(1); @@ -288,10 +296,7 @@ pub fn options_button(o: &mut ToolOptions, ui: &mut egui::Ui) { }; for k in CropOverlay::ALL { if item(ui, o.crop_overlay == k, tl!(k.label()), None) { - if o.crop_overlay != k { - o.crop_overlay_orientation = 0; - } - o.crop_overlay = k; + set_overlay(o, k); ui.close(); } } diff --git a/crates/ui-egui/src/crop_presets.rs b/crates/ui-egui/src/crop_presets.rs index e30b0d1cfc..b0986f9e1e 100644 --- a/crates/ui-egui/src/crop_presets.rs +++ b/crates/ui-egui/src/crop_presets.rs @@ -34,9 +34,9 @@ pub const MAX_NAME: usize = 255; /// The `ToolOptions` fields a crop preset saves. const KEYS: [&str; 5] = ["crop_ratio", "crop_width", "crop_height", "crop_resolution", "crop_resolution_unit"]; -/// One entry of the preset dropdown. +/// One entry of the preset dropdown (and of the Crop tool's canvas menu). #[derive(Clone, Debug, PartialEq)] -enum Choice { +pub(crate) enum Choice { /// A built-in key (`crop_ratio` value, size preset or Front Image), see [`crop_size::chosen`]. Builtin(String), /// A saved crop preset, by name. @@ -139,7 +139,7 @@ pub fn dropdown(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let users = user_presets(app); let o = &app.ui.tool_options; let label = button_label(o, &builtin, &users); - let current_user = users.iter().rev().find(|(_, f)| matches(o, f)).map(|(n, _)| n.clone()); + let current_user = current_user(app); let can_new = savable(o).is_some(); let mut chosen: Option = None; egui::ComboBox::from_id_salt("crop-ratio").selected_text(label).width(140.0).height(420.0).icon(crate::widgets::chevron_icon).show_ui(ui, |ui| { @@ -167,27 +167,40 @@ pub fn dropdown(app: &mut PhotocraftApp, ui: &mut egui::Ui) { chosen = Some(Choice::Delete); } }); - match chosen { - Some(Choice::Builtin(k)) => { + if let Some(c) = chosen { + apply_choice(app, c); + } +} + +/// What picking a dropdown entry does; the Crop tool's canvas menu picks through it too. +pub(crate) fn apply_choice(app: &mut PhotocraftApp, choice: Choice) { + match choice { + Choice::Builtin(k) => { app.ui.tool_options.crop_ratio = k; // A size preset or Front Image fills W x H x Resolution (#2443). crop_size::chosen(app); sync_custom_ratio_fields(app); } - Some(Choice::User(name)) => { + Choice::User(name) => { select(app, &name); sync_custom_ratio_fields(app); } - Some(Choice::New) => { + Choice::New => { open_new(app); } - Some(Choice::Delete) => { + Choice::Delete => { open_delete(app); } - None => {} } } +/// The saved crop preset whose values the fields hold (the latest saved one first), as the +/// dropdown shows it. +pub(crate) fn current_user(app: &PhotocraftApp) -> Option { + let o = &app.ui.tool_options; + user_presets(app).into_iter().rev().find(|(_, f)| matches(o, f)).map(|(n, _)| n) +} + /// A newly chosen ratio fills the editable custom W/H fields (free Ratio clears them, #3188). fn sync_custom_ratio_fields(app: &mut PhotocraftApp) { if app.ui.tool_options.crop_ratio != crop_size::WHR { diff --git a/crates/ui-egui/src/crop_size.rs b/crates/ui-egui/src/crop_size.rs index b30cdd8c4a..194760e6de 100644 --- a/crates/ui-egui/src/crop_size.rs +++ b/crates/ui-egui/src/crop_size.rs @@ -223,6 +223,15 @@ pub fn clear(o: &mut ToolOptions) { o.crop_resolution.clear(); } +/// The options bar's Clear: W, H and the resolution in W x H x Resolution mode, else the ratio. +pub fn clear_ratio(o: &mut ToolOptions) { + if o.crop_ratio == WHR { + clear(o); + } else { + o.crop_ratio.clear(); + } +} + /// Swaps W and H (the ⇄ button, X). False outside W x H x Resolution mode. pub fn swap(o: &mut ToolOptions) -> bool { if o.crop_ratio != WHR { diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 18cef34c98..d15914828c 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -1350,11 +1350,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { } widgets::vline(ui, 22.0); if widgets::secondary_button(ui, tl!("Clear"), 0.0).clicked() { - if o.crop_ratio == crate::crop_size::WHR { - crate::crop_size::clear(o); - } else { - o.crop_ratio.clear(); - } + crate::crop_size::clear_ratio(o); } crate::crop_straighten::options_button(&mut app.crop.straighten, ui); crate::crop_overlay::options_button(o, ui); diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rs index 1ad8d6d92a..94787c8193 100644 --- a/crates/ui-egui/src/shortcuts.rs +++ b/crates/ui-egui/src/shortcuts.rs @@ -391,8 +391,9 @@ pub fn handle(app: &mut PhotocraftApp, ctx: &egui::Context) { return; } // So does the right-click menu of text being edited: Esc closes only it, and keys typed while - // it is open don't reach the text beneath. - if app.ui.canvas_tool_menu.as_ref().is_some_and(|m| m.text) { + // it is open don't reach the text beneath. The crop menu's likewise: Esc and ↵ don't cancel or + // commit the crop under it (#6561). + if app.ui.canvas_tool_menu.as_ref().is_some_and(|m| m.text || m.crop.is_some()) { return; } let symmetry_editing = app.ui.symmetry_transform.is_some(); diff --git a/crates/ui-egui/src/transform_type_tests.rs b/crates/ui-egui/src/transform_type_tests.rs index 457c03c1cb..eeb91f44b9 100644 --- a/crates/ui-egui/src/transform_type_tests.rs +++ b/crates/ui-egui/src/transform_type_tests.rs @@ -55,6 +55,7 @@ fn type_layers_offer_free_transform_but_not_distort_or_perspective() { type_layer: false, guide: false, spelling: None, + crop: None, }; assert!(crate::canvas_tool_menu::available(&app, &menu, "edit.freeTransform")); assert!(!crate::canvas_tool_menu::available(&app, &menu, "edit.transform.distort")); diff --git a/docs/context-menu-parity.md b/docs/context-menu-parity.md index 53b6d99bd9..d6ec330909 100644 --- a/docs/context-menu-parity.md +++ b/docs/context-menu-parity.md @@ -1,6 +1,6 @@ # Context-menu parity contract -> **Last reviewed:** 2026-10-18 · **Last updated:** 2026-10-18 · **Change:** minor (Type tool menu over committed type, #7324) · **Target:** Adobe Photoshop 2026 +> **Last reviewed:** 2026-10-18 · **Last updated:** 2026-10-21 · **Change:** minor (Crop tool menu on a pending crop, #6561; Type tool menu over committed type, #7324) · **Target:** Adobe Photoshop 2026 Status: implementation contract, updated 2026-10-09. Scope: canvas, document tabs, and panels. “Right-click” means a secondary pointer click; macOS Control-click should also open the same menu where the platform sends a context-menu gesture. Photoshop changes a context menu with the active tool, selection, and panel item. Adobe documents that principle but does not publish a complete current menu catalog. **Documented** means an Adobe source explicitly names the gesture or action. **Inferred** means a PhotoCraft design target or an item known from a main menu whose presence in a Photoshop context menu still needs a current-product capture. Do not present inferred rows as exact Photoshop menus. [Adobe: panels and menus](https://helpx.adobe.com/photoshop/using/panels-menus.html), [Adobe: shortcuts and context menus](https://helpx.adobe.com/sa_en/photoshop/using/customizing-keyboard-shortcuts.html). @@ -22,7 +22,7 @@ The “PhotoCraft at branch point” column records behavior before this PR. Pic |---|---|---|---| | Move | Choose a layer at the point; an auto-select choice also exists in the options bar | Layers | P0; [Adobe layer movement](https://helpx.adobe.com/photoshop/using/moving-stacking-locking-layers.html); exact pop-up layout requires capture | | Rectangular/Elliptical Marquee, Lasso, Polygonal Lasso, Magnetic Lasso, Magic Wand, Quick Selection, Object Selection | Active selection: the 2026 selection menu (see *Selection canvas reference* below); no selection: making a selection | Quick Selection: Picker (a brush tool, as in Photoshop); the other six: the selection menu below (#614, #738) | P1; no-selection variant still needs a dated capture | -| Crop | During crop: ratio/preset, overlay, clear/reset, commit/cancel **(inferred context placement)** | No tool menu | P1; pending crop target | +| Crop | During crop: ratio/preset, overlay, clear/reset, commit/cancel **(inferred context placement)** | On a pending crop (canvas_tool_menu.rs `crop_rows`, #6561): the options bar's preset dropdown in its order (Ratio, W x H x Resolution, the ratios, the size presets, saved crop presets, Front Image), Clear, New/Delete Crop Preset…, the six overlays and Auto/Always/Never Show Overlay (checked as in the bar), Cancel and Crop; also outside the image while a crop is pending. The untouched default frame has no menu. Esc closes only the menu. Reset remains open (no reset of frame, rotation and ratio yet, nor the options bar's ↺) | P1; pending crop target; item list still needs a dated Photoshop capture | | Eyedropper | Sample-size/source choices **(inferred)** | No tool menu | P2; [Adobe illustration uses Eyedropper](https://helpx.adobe.com/photoshop/using/panels-menus.html), but does not publish item text | | Ruler, Note, Count | Unit / measurement, note edit/delete, count-group operations **(inferred)** | No tool menu | P2 | | Brush, Pencil, Eraser, Background Eraser, Spot Healing, Healing, Clone Stamp, History Brush, Blur, Sharpen, Smudge, Dodge, Burn, Sponge | Brush preset, size and hardness where applicable | Picker | P0; [Adobe Brush Settings](https://helpx.adobe.com/photoshop/desktop/apply-painting-techniques/brushes-presets/create-brush-set-painting-options.html). Alt+secondary-drag on Windows and Control+Option-drag on macOS adjust size/hardness ([Adobe cursor shortcuts](https://helpx.adobe.com/in/photoshop/desktop/get-started/settings-and-preferences/change-tool-pointers.html)) | @@ -100,6 +100,7 @@ Each slice needs pure model tests (including every item dispatching a known comm | Date | Change | Summary | |---|---|---| +| 2026-10-21 | minor | Crop tool menu on a pending crop (#6561) | | 2026-10-18 | minor | Type tool menu over committed type (#7324) | | 2026-10-13 | minor | Layer-mask thumbnail menu (#4575) | | 2026-10-10 | trivial | Status line, revision history | diff --git a/docs/gaps.md b/docs/gaps.md index ab42d0f8ef..894370c42f 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where PhotoCraft falls short of Photoshop -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-18 · **Change:** minor (G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-21 · **Change:** minor (G9: Crop tool canvas menu, #6561; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 @@ -204,7 +204,8 @@ what an agent can't finish alone. - **Missing:** 27 of 156 preferences do nothing (scorecard prefs audit); panel groups can't float or tear off into OS windows (UI-217-5, #1828, #1213, #2305); Color panel lacks wheel and slider modes (UI-217-17, #2569); more themes (UI-217-11, #2661); a single pixel layer - copies without its mask and styles (UI-217-23; fill and adjustment layers copy whole, #2344); tool-specific context menus beyond brushes, selections and Pen + copies without its mask and styles (UI-217-23; fill and adjustment layers copy whole, #2344); tool-specific context menus beyond brushes, selections, Pen and + Crop ([context-menu-parity.md](context-menu-parity.md)); Libraries, Comments, Contextual Task Bar panels. - **Estimate:** 150–250 h. @@ -274,6 +275,7 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| +| 2026-10-21 | minor | G9: right-click on a pending crop opens the Crop tool menu (presets, Clear, overlays, Cancel, Crop; #6561); Reset still open | | 2026-10-15 | minor | G1 / #5972 A1: render only provably constant-RGB `GdFl` noise fills; variable noise synthesis remains open | | 2026-10-18 | minor | G9: with no selection, Copy takes fill and adjustment layers whole and Paste recreates them (#2344); UI-217-23 stays partial (a single pixel layer copies its pixels only); estimate unchanged | | 2026-10-14 | minor | G1: a PSD smart object's filter mask shows when the file opens (Photoshop stores the filtered pixels unmasked); export stores them that way too; Photoshop-oracle floor 185 → 188 of 258 | From 48d8668584d895308382b093a2a8661bc23444c9 Mon Sep 17 00:00:00 2001 From: David Mann Date: Wed, 21 Oct 2026 13:57:13 +0200 Subject: [PATCH 180/649] Integration: Invert's hasoptions and the Wave seed as rendered (#5249) Photoshop saves an Invert smart filter with `hasoptions` false (checked on a file saved from Photoshop with Invert, Twirl and Wave smart filters on a smart object); the PR wrote true. Twirl and Wave from that file write back byte for byte. A Wave seed stored as -1 or 7.4 (layer.smartFilter.setParams keeps params as given) renders with 0xFFFFFFFF / 7 (engine `filters::seed`) but was written as `RndS` 0, so the reopened file drew a different wave. It is now decoded the same way. `wave_export_writes_the_seed_the_renderer_draws` and the corrected `invert_smart_filter_reads_and_writes_like_photoshop` fail without this change. Co-authored-by: abc2cb <271337822+abc2cb@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/io/src/smart_map.rs | 44 +++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/crates/io/src/smart_map.rs b/crates/io/src/smart_map.rs index 730d25cfca..182054f202 100644 --- a/crates/io/src/smart_map.rs +++ b/crates/io/src/smart_map.rs @@ -170,7 +170,7 @@ const KNOWN: [Known; 22] = [ Known { class: "Twrl", filter_id: code(b"Twrl"), name: "Twirl...", command: "filter.distort.twirl" }, Known { class: "Wave", filter_id: code(b"Wave"), name: "Wave...", command: "filter.distort.wave" }, Known { class: "ZgZg", filter_id: code(b"ZgZg"), name: "ZigZag...", command: "filter.distort.zigZag" }, - // Image › Adjustments › Invert on a smart object: no settings, so no `Fltr` (yet `hasoptions`). + // Image › Adjustments › Invert on a smart object: no settings, so no `Fltr` (`hasoptions` false). Known { class: "Invr", filter_id: code(b"Invr"), name: "Invert", command: "image.adjustments.invert" }, ]; @@ -676,7 +676,12 @@ fn fltr_for(k: &Known, p: &J) -> Result, String> { d.with("Amnt", pi(p, "amount", 10.0)).with("NmbR", pi(p, "ridges", 5.0)).with("ZZTy", enum_value(p, "style", "pondRipples", "ZZTy", &ZIGZAG_STYLE)?) } "Wave" => { - let seed = p.get("seed").and_then(J::as_u64).and_then(|s| u32::try_from(s).ok()).unwrap_or(0); + // The seed the renderer draws with (engine `filters::seed`): a u32, else a legacy signed + // or fractional seed, rounded and saturated, as its bit pattern. + let seed = match p.get("seed").and_then(J::as_u64).and_then(|s| u32::try_from(s).ok()) { + Some(s) => Value::Integer(s as i32), + None => pi(p, "seed", 0.0), + }; // The renderer draws at most MAX_WAVE_GENERATORS: write what PhotoCraft rendered, so // Photoshop doesn't draw more generators than the user saw. let generators = pf(p, "generators", 5.0).round().clamp(1.0, f64::from(photocraft_algo::MAX_WAVE_GENERATORS)) as i32; @@ -689,7 +694,7 @@ fn fltr_for(k: &Known, p: &J) -> Result, String> { .with("SclH", Value::Integer(100)) .with("SclV", Value::Integer(100)) .with("UndA", enum_value(p, "undefinedAreas", "wrap", "UndA", &UNDEFINED_AREAS)?) - .with("RndS", Value::Integer(seed as i32)) + .with("RndS", seed) } "Invr" => return Ok(None), _ => return Err("not a recognized filter".into()), @@ -726,8 +731,7 @@ pub fn item_for_filter(f: &SmartFilter) -> Result { .with("Nm ", Value::Text(UnicodeString::new_nul(k.name))) .with("blendOptions", blend_options(f)) .with("enab", Value::Boolean(f.visible)) - // Photoshop marks Invert as having options although it stores none. - .with("hasoptions", Value::Boolean(fltr.is_some() || k.class == "Invr")) + .with("hasoptions", Value::Boolean(fltr.is_some())) .with("FrgC", rgbc(0.0)) .with("BckC", rgbc(255.0)); if let Some(x) = fltr { @@ -1308,14 +1312,38 @@ mod tests { } } - /// Invert on a smart object: Photoshop stores no `Fltr`, but `hasoptions` and its filter id. + /// `RndS` is the seed the renderer draws with, also for a legacy signed or fractional seed + /// (stored as is by `layer.smartFilter.setParams`), not 0. + #[test] + fn wave_export_writes_the_seed_the_renderer_draws() { + for (stored, written) in [ + (json!(77), 77), + (json!(4_000_000_000u32), -294_967_296), + (json!(-1), -1), + (json!(7.4), 7), + (json!(-2.6), -3), + (json!(1e12), i32::MAX), + (json!("x"), 0), + ] { + let wave = sf("filter.distort.wave", json!({"generators": 3, "seed": stored})); + let fltr = match item_for_filter(&wave).unwrap().get("Fltr") { + Some(Value::Descriptor(d)) => d.clone(), + other => panic!("wave: no Fltr ({other:?})"), + }; + assert_eq!(int(&fltr, "RndS"), Some(written), "seed {stored}"); + // And it reads back as that bit pattern. + assert_eq!(known_params("Wave", Some(&fltr)).unwrap().1["seed"], json!(written as u32), "seed {stored}"); + } + } + + /// Invert on a smart object: Photoshop stores no `Fltr`, `hasoptions` false and its filter id. #[test] fn invert_smart_filter_reads_and_writes_like_photoshop() { let item = Descriptor::new("filterFX") .with("Nm ", Value::Text(UnicodeString::new_nul("Invert"))) .with("blendOptions", Value::Descriptor(Descriptor::new("blendOptions").with("Opct", unit(b"#Prc", 100.0)).with("Md ", enumv("BlnM", "normal")))) .with("enab", Value::Boolean(true)) - .with("hasoptions", Value::Boolean(true)) + .with("hasoptions", Value::Boolean(false)) .with("FrgC", rgbc(255.0)) .with("BckC", rgbc(0.0)) .with("filterID", Value::Integer(code(b"Invr"))); @@ -1323,7 +1351,7 @@ mod tests { assert_eq!((f.command.as_str(), &f.params), ("image.adjustments.invert", &json!({}))); let back = item_for_filter(&f).unwrap(); assert_eq!(back.get("Fltr"), None); - assert_eq!(back.get("hasoptions"), Some(&Value::Boolean(true))); + assert_eq!(back.get("hasoptions"), Some(&Value::Boolean(false))); assert_eq!(back.get("filterID"), Some(&Value::Integer(code(b"Invr")))); assert_eq!(back.get("Nm "), Some(&Value::Text(UnicodeString::new_nul("Invert")))); } From 6d92b12691bd3257ac9421bf7a38bda1d8de2356 Mon Sep 17 00:00:00 2001 From: Michael Higgins <55243596+Higgs32584@users.noreply.github.com> Date: Wed, 21 Oct 2026 08:51:55 -0400 Subject: [PATCH 181/649] Update crates/text/src/psd_path.rs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- crates/text/src/psd_path.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/text/src/psd_path.rs b/crates/text/src/psd_path.rs index f01807d21e..793b24dc7b 100644 --- a/crates/text/src/psd_path.rs +++ b/crates/text/src/psd_path.rs @@ -286,7 +286,8 @@ pub(crate) fn update_frame(entry: &mut E, shape: &TextShape) { frame.set("2", data); *entry = E::Dict(vec![("0".into(), frame)]); } - _ if kind != PATH_FRAME => {} + // Leave unreadable path frames unchanged. They were not imported as detached paths. + _ if kind != PATH_FRAME || frame.is_none_or(|f| read(f).is_err()) => {} TextShape::Box { x, y, width, height } => *entry = box_frame(f64::from(*x), f64::from(*y), f64::from(*width), f64::from(*height)), TextShape::Point => *entry = point_frame(), } From 68577e42e1e5bbcbff9fa6fc340bd4339a2f2a20 Mon Sep 17 00:00:00 2001 From: IbrahimOezhan Date: Wed, 21 Oct 2026 15:18:48 +0200 Subject: [PATCH 182/649] Image Assets: optionally keep a transparent artboard's full size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit File › Generate › Image Assets trims every asset to its visible pixels, artboards included. An opaque board background hides this, but a transparent artboard whose contents don't fill it came out cropped to the contents, losing their placement and padding on the board. Export Preferences › Image Assets: Keep Full Artboard Size (export.imageAssetsFullArtboards, off by default so existing asset sizes don't change) exports such an artboard at the board's size, transparent edges included, as File › Export › Artboards to Files does. Layers on the board are still trimmed. file.export.exportPreferences takes the new key; the label is translated in every complete catalog; docs/scorecard.md regenerated (171 preferences). Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/prefs.rs | 4 ++ crates/engine/src/web_cmds.rs | 19 ++++++--- crates/engine/src/web_cmds/tests.rs | 62 +++++++++++++++++++++++++---- crates/ui-egui/src/i18n/cs.tsv | 3 ++ crates/ui-egui/src/i18n/de.tsv | 3 ++ crates/ui-egui/src/i18n/el.tsv | 3 ++ crates/ui-egui/src/i18n/es.tsv | 3 ++ crates/ui-egui/src/i18n/fr.tsv | 3 ++ crates/ui-egui/src/i18n/hu.tsv | 3 ++ crates/ui-egui/src/i18n/id.tsv | 3 ++ crates/ui-egui/src/i18n/it.tsv | 3 ++ crates/ui-egui/src/i18n/ja.tsv | 3 ++ crates/ui-egui/src/i18n/ko.tsv | 3 ++ crates/ui-egui/src/i18n/nl.tsv | 3 ++ crates/ui-egui/src/i18n/pl.tsv | 3 ++ crates/ui-egui/src/i18n/pt-br.tsv | 3 ++ crates/ui-egui/src/i18n/ru.tsv | 3 ++ crates/ui-egui/src/i18n/sr.tsv | 3 ++ crates/ui-egui/src/i18n/tr.tsv | 3 ++ crates/ui-egui/src/i18n/uk.tsv | 3 ++ crates/ui-egui/src/i18n/vi.tsv | 3 ++ crates/ui-egui/src/i18n/zh-hans.tsv | 3 ++ crates/ui-egui/src/i18n/zh-hant.tsv | 3 ++ crates/ui-egui/src/prefs_ui.rs | 5 +++ docs/scorecard.md | 4 +- 25 files changed, 140 insertions(+), 14 deletions(-) diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index ed8b7f148f..d9437a9c2b 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -496,6 +496,9 @@ pub struct Export { pub webp_quality: u32, pub metadata: ExportMetadata, pub convert_to_srgb: bool, + /// File › Generate › Image Assets exports an artboard named like an asset at the board's + /// size, transparent edges included, instead of trimming it to its visible pixels. + pub image_assets_full_artboards: bool, } impl Default for Export { @@ -508,6 +511,7 @@ impl Default for Export { webp_quality: 85, metadata: ExportMetadata::Copyright, convert_to_srgb: true, + image_assets_full_artboards: false, } } } diff --git a/crates/engine/src/web_cmds.rs b/crates/engine/src/web_cmds.rs index 755ba07320..d2734d5d24 100644 --- a/crates/engine/src/web_cmds.rs +++ b/crates/engine/src/web_cmds.rs @@ -1046,6 +1046,7 @@ fn export_preferences(s: &mut Session, p: &Value) -> Result { ("webpQuality", "export.webpQuality"), ("metadata", "export.metadata"), ("convertToSrgb", "export.convertToSrgb"), + ("imageAssetsFullArtboards", "export.imageAssetsFullArtboards"), ] { if let Some(v) = p.get(k) { values.insert(key.into(), v.clone()); @@ -1402,7 +1403,11 @@ fn asset_output_path(dir: &str, relative: &str) -> Result<(String, String)> { /// same file, the one higher in the Layers panel keeps it and the other is reported in `errors`. /// Names are compared ignoring case, as `Logo.png` and `logo.png` are one file on Windows and /// macOS. -pub fn generate_assets(doc: &Document, dir: &str) -> (Vec, Vec) { +/// +/// A layer is trimmed to its visible pixels. With `full_artboards` (Export Preferences › Image +/// Assets: Keep Full Artboard Size) an artboard keeps its board, transparent edges included, as +/// File › Export › Artboards to Files writes it. +pub fn generate_assets(doc: &Document, dir: &str, full_artboards: bool) -> (Vec, Vec) { let dpi = f64::from(doc.resolution_dpi.max(1.0)); let mut defaults: Option> = None; let mut by_layer: Vec> = Vec::new(); @@ -1434,7 +1439,11 @@ pub fn generate_assets(doc: &Document, dir: &str) -> (Vec, Vec) { if written.contains(&key) { return Err(other(format!("{rel}: another layer already writes this file; rename one of the layers"))); } - let mut one = crate::layer_menu_cmds::layer_document(doc, *id)?; + let board = if full_artboards { crate::artboard_cmds::artboard_document(doc, *id)? } else { None }; + let mut one = match board { + Some(board) => board, + None => crate::layer_menu_cmds::layer_document(doc, *id)?, + }; one.metadata = Default::default(); let (w0, h0) = (f64::from(one.size.width), f64::from(one.size.height)); // The layer's own size spec wins; default variants scale on top of it. @@ -1506,7 +1515,7 @@ fn image_assets(s: &mut Session, p: &Value) -> Result { } match dir { Some(dir) if !cfg!(target_arch = "wasm32") => { - let (files, errors) = generate_assets(&d.doc, &dir); + let (files, errors) = generate_assets(&d.doc, &dir, s.prefs().export.image_assets_full_artboards); Ok(json!({"enabled": true, "dir": dir, "files": files, "errors": errors})) } _ => Ok(json!({"enabled": true, "dir": null, "files": [], "note": "assets are written when the document is saved"})), @@ -1520,7 +1529,7 @@ pub fn on_saved(s: &Session, index: usize) -> Option { return None; } let dir = assets_dir(d.path.as_deref()?); - let (files, errors) = generate_assets(&d.doc, &dir); + let (files, errors) = generate_assets(&d.doc, &dir, s.prefs().export.image_assets_full_artboards); Some(json!({"dir": dir, "files": files, "errors": errors})) } @@ -1548,7 +1557,7 @@ pub fn specs() -> Vec { "Export Preferences…", &["File", "Export"], None, - r##"{"quickExportFormat":"png|jpg|gif|webp"?,"quickExportLocation":"ask|sameFolder"?,"jpegQuality":1..100?,"webpLossless":bool?,"webpQuality":1..100?,"metadata":"none|copyright|all"?,"convertToSrgb":bool?} → {values}"##, + r##"{"quickExportFormat":"png|jpg|gif|webp"?,"quickExportLocation":"ask|sameFolder"?,"jpegQuality":1..100?,"webpLossless":bool?,"webpQuality":1..100?,"metadata":"none|copyright|all"?,"convertToSrgb":bool?,"imageAssetsFullArtboards":bool? (Image Assets export artboards at the board's size instead of trimming transparent edges)} → {values}"##, |_| Ok(()), export_preferences ), diff --git a/crates/engine/src/web_cmds/tests.rs b/crates/engine/src/web_cmds/tests.rs index 5791e5f27c..22a66723a2 100644 --- a/crates/engine/src/web_cmds/tests.rs +++ b/crates/engine/src/web_cmds/tests.rs @@ -599,12 +599,60 @@ fn image_assets_are_generated_now_and_on_save() { d.layers.push(Layer::new("default 200% @2x", LayerContent::Group(photocraft_doc::Group { children: vec![], expanded: false, artboard: None }))); let lid = d.layers[1].id; d.layer_mut(lid).unwrap().name = "icon.png".into(); - let (files, errors) = generate_assets(&d, &dir); + let (files, errors) = generate_assets(&d, &dir, false); assert!(errors.is_empty(), "{errors:?}"); assert_eq!(files.iter().map(|p| std::path::PathBuf::from(p.as_str())).collect::>(), vec![std::path::Path::new(&dir).join("icon@2x.png")]); assert_eq!(decode(&files[0]).dimensions(), (128, 80)); } +/// Export Preferences › Image Assets: Keep Full Artboard Size. A transparent artboard whose +/// contents don't fill it is trimmed to its pixels by default; with the preference on it keeps +/// the board's size, transparent edges included. Layers inside the board are still trimmed. +#[test] +fn image_assets_keep_full_artboards_when_asked() { + let dir = tmp("asset-artboards"); + let mut s = Session::new(); + s.execute("file.new", json!({"width": 64, "height": 48, "name": "boards.psd", "background": "transparent"})).unwrap(); + s.edit("board", |doc, _| { + let fmt = doc.pixel_format(); + let mut logo = Layer::raster("logo.png", fmt); + logo.surface_mut().unwrap().fill_rect(Rect::new(12, 10, 20, 16), &photocraft_raster::from_rgba(&fmt, [1.0, 0.0, 0.0, 1.0])); + let board = + photocraft_doc::Artboard { rect: Rect::new(4, 6, 44, 36), background: photocraft_doc::ArtboardBackground::Transparent, preset: String::new() }; + let group = photocraft_doc::Group { children: vec![logo], expanded: true, artboard: Some(board) }; + doc.layers = vec![Layer::new("board.png", LayerContent::Group(group))]; + Ok(()) + }) + .unwrap(); + assert!(!s.prefs().export.image_assets_full_artboards, "trimming stays the default"); + + let r = s.execute("file.generate.imageAssets", json!({"on": true, "dir": dir})).unwrap(); + assert!(r["errors"].as_array().unwrap().is_empty(), "{r}"); + assert_eq!(decode(&format!("{dir}/board.png")).dimensions(), (8, 6), "off: trimmed to the board's pixels"); + assert_eq!(decode(&format!("{dir}/logo.png")).dimensions(), (8, 6)); + + let r = s.execute("file.export.exportPreferences", json!({"imageAssetsFullArtboards": true})).unwrap(); + assert_eq!(r["values"]["imageAssetsFullArtboards"], true); + let r = s.execute("file.generate.imageAssets", json!({"on": true, "dir": dir})).unwrap(); + assert!(r["errors"].as_array().unwrap().is_empty(), "{r}"); + let board = decode(&format!("{dir}/board.png")); + assert_eq!(board.dimensions(), (40, 30), "on: the whole board"); + let px = board.to_rgba8(); + let at = |x: usize, y: usize| &px[(y * 40 + x) * 4..(y * 40 + x) * 4 + 4]; + assert_eq!(at(0, 0)[3], 0, "the board's empty corner stays transparent"); + assert_eq!(at(39, 29)[3], 0); + // The logo keeps its place on the board: document (12, 10) is board (8, 4). + assert!(at(8, 4)[0] > 250 && at(8, 4)[3] == 255, "{:?}", at(8, 4)); + assert_eq!(at(7, 4)[3], 0); + assert_eq!(decode(&format!("{dir}/logo.png")).dimensions(), (8, 6), "a layer on the board is still trimmed"); + + // Preferences saved before this setting existed load with it off. + let mut old = s.prefs().to_json(); + old["export"].as_object_mut().unwrap().remove("imageAssetsFullArtboards"); + let restored: crate::prefs::Preferences = serde_json::from_value(old).unwrap(); + assert!(!restored.export.image_assets_full_artboards); +} + /// #6614: two layers, or two default variants, naming one file never overwrite each other: the /// layer higher in the Layers panel keeps the file, whatever the case of its name, and the /// others are reported. @@ -626,7 +674,7 @@ fn image_assets_never_write_one_file_twice() { let (top, logo) = (id(&d, "Top"), id(&d, "Logo")); d.layer_mut(top).unwrap().name = "Logo.PNG".into(); d.layer_mut(logo).unwrap().name = "logo.png, logo.png".into(); - let (files, errors) = generate_assets(&d, &dir); + let (files, errors) = generate_assets(&d, &dir, false); assert_eq!(files.iter().map(|p| std::path::PathBuf::from(p.as_str())).collect::>(), vec![std::path::Path::new(&dir).join("Logo.png")]); assert_eq!(decode(&files[0]).dimensions(), (4, 4), "the top layer keeps the file"); assert_eq!(errors.len(), 2, "{errors:?}"); @@ -639,7 +687,7 @@ fn image_assets_never_write_one_file_twice() { d.layer_mut(logo).unwrap().name = "Logo".into(); d.layers .push(Layer::new("default 50% + 200% + 200% @2x", LayerContent::Group(photocraft_doc::Group { children: vec![], expanded: false, artboard: None }))); - let (files, errors) = generate_assets(&d, &dir); + let (files, errors) = generate_assets(&d, &dir, false); let names: Vec<_> = files.iter().map(|p| std::path::Path::new(p).file_name().unwrap().to_string_lossy().into_owned()).collect(); assert_eq!(names, ["icon.png", "icon@2x.png"]); assert_eq!(decode(&files[0]).dimensions(), (2, 2), "the 50% variant keeps icon.png"); @@ -656,7 +704,7 @@ fn image_assets_reject_traversal_from_names_and_defaults() { let id = d.layers[1].id; d.layer_mut(id).unwrap().name = format!("nested/ok.png, ../escaped.png, ..\\backslash.png, {outside}/absolute.png, C:\\drive\\escape.png, CON.png, aux/escape.png, foo./trailing.png"); - let (files, errors) = generate_assets(&d, &dir); + let (files, errors) = generate_assets(&d, &dir, false); assert_eq!(files.iter().map(|p| std::path::PathBuf::from(p.as_str())).collect::>(), vec![std::path::Path::new(&dir).join("nested").join("ok.png")]); assert_eq!(errors.len(), 7, "{errors:?}"); assert!(errors.iter().all(|e| e["error"].as_str().unwrap().contains("unsafe component")), "{errors:?}"); @@ -668,7 +716,7 @@ fn image_assets_reject_traversal_from_names_and_defaults() { "default ../ + /outside/ + ..\\bad/ + C:\\drive/ + 50% nested/", LayerContent::Group(photocraft_doc::Group { children: vec![], expanded: false, artboard: None }), )); - let (files, errors) = generate_assets(&d, &dir); + let (files, errors) = generate_assets(&d, &dir, false); assert_eq!( files.iter().map(|p| std::path::PathBuf::from(p.as_str())).collect::>(), vec![std::path::Path::new(&dir).join("nested").join("safe.png")] @@ -692,7 +740,7 @@ fn image_assets_reject_existing_symlinks_in_folders_and_files() { let mut d = (*session(8).active().unwrap().doc).clone(); let id = d.layers[1].id; d.layer_mut(id).unwrap().name = "linked/new/sub.png, leaf.png, leaf.webp, good/safe.png".into(); - let (files, errors) = generate_assets(&d, &dir); + let (files, errors) = generate_assets(&d, &dir, false); assert_eq!(files, vec![format!("{dir}/good/safe.png")]); assert_eq!(errors.len(), 3, "{errors:?}"); assert!(errors.iter().all(|e| e["error"].as_str().unwrap().contains("symlink")), "{errors:?}"); @@ -703,7 +751,7 @@ fn image_assets_reject_existing_symlinks_in_folders_and_files() { let linked_root = format!("{dir}/rootlink"); std::os::unix::fs::symlink(&outside, &linked_root).unwrap(); d.layer_mut(id).unwrap().name = "root.png".into(); - let (files, errors) = generate_assets(&d, &format!("{linked_root}/")); + let (files, errors) = generate_assets(&d, &format!("{linked_root}/"), false); assert!(errors.is_empty(), "{errors:?}"); assert_eq!(files, vec![format!("{linked_root}/root.png")]); assert!(std::path::Path::new(&format!("{outside}/root.png")).is_file()); diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 15879f60d2..cfaadeb1be 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -3864,3 +3864,6 @@ navigator Zoom Zvětšení # Graphics Adapter preference (#1885) GPU adapter Adaptér GPU + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Obrazové podklady: zachovat celou velikost kreslicí plochy diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index eb3ca77944..cde6b1147c 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -3259,3 +3259,6 @@ curves Smooth Glätten # Graphics Adapter preference (#1885) GPU adapter GPU-Adapter + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Bild-Assets: Volle Zeichenbereichsgröße beibehalten diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index bac53b53d6..16b237b3f3 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3956,3 +3956,6 @@ curves Smooth Εξομάλυνση # Graphics Adapter preference (#1885) GPU adapter Προσαρμογέας GPU + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Πόροι εικόνας: διατήρηση πλήρους μεγέθους πίνακα σχεδίασης diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 8629fc3fda..bd9733ccf5 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -4218,3 +4218,6 @@ navigator Zoom Zoom # Graphics Adapter preference (#1885) GPU adapter Adaptador de GPU + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Recursos de imagen: mantener el tamaño completo de la mesa de trabajo diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index fad669a4b2..c877fdf7f6 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -3265,3 +3265,6 @@ curves Smooth Lisser # Graphics Adapter preference (#1885) GPU adapter Adaptateur GPU + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Ressources d'image : conserver la taille complète du plan de travail diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index c066f42711..f5751e7f8d 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -4175,3 +4175,6 @@ cameraRaw Yellow Sárga # Graphics Adapter preference (#1885) GPU adapter GPU-adapter + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Képelemek: a rajztábla teljes méretének megtartása diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 9e0012bd64..3c94d62990 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -3252,3 +3252,6 @@ curves Smooth Haluskan # Graphics Adapter preference (#1885) GPU adapter Adaptor GPU + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Aset Gambar: Pertahankan Ukuran Penuh Artboard diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index fe8d4cf8dd..076de24647 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -4373,3 +4373,6 @@ shape Appearance Aspetto # Graphics Adapter preference (#1885) GPU adapter Adattatore GPU + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Risorse immagine: mantieni la dimensione intera della tavola da disegno diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 9b121c4c90..5d1e57a25a 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3934,3 +3934,6 @@ curves Smooth スムーズ # Graphics Adapter preference (#1885) GPU adapter GPU アダプター + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size 画像アセット: アートボード全体のサイズを保持 diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index dc4bf58c95..7dffb72407 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3440,3 +3440,6 @@ curves Smooth 매끄럽게 # Graphics Adapter preference (#1885) GPU adapter GPU 어댑터 + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size 이미지 에셋: 전체 아트보드 크기 유지 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 7104d69eda..f49f873d9e 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -4016,3 +4016,6 @@ curves Smooth Vloeiend maken # Graphics Adapter preference (#1885) GPU adapter GPU-adapter + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Afbeeldingsmiddelen: volledige tekengebiedgrootte behouden diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 8abed62baa..95a9ab3e12 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3856,3 +3856,6 @@ curves Smooth Wygładź # Graphics Adapter preference (#1885) GPU adapter Karta GPU + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Zasoby obrazów: zachowaj pełny rozmiar obszaru roboczego diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index b21564e683..d2d75c8a21 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -4046,3 +4046,6 @@ layerLabel No Color Sem cor # Graphics Adapter preference (#1885) GPU adapter Adaptador de GPU + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Recursos de imagem: manter o tamanho completo da prancheta diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index ff6fc08de8..8ff569aafb 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -3231,3 +3231,6 @@ curves Smooth Сгладить # Graphics Adapter preference (#1885) GPU adapter Адаптер GPU + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Ресурсы изображений: сохранять полный размер монтажной области diff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsv index 9a1ceff635..957b7bdbbe 100644 --- a/crates/ui-egui/src/i18n/sr.tsv +++ b/crates/ui-egui/src/i18n/sr.tsv @@ -4329,3 +4329,6 @@ shape Appearance Izgled # Graphics Adapter preference (#1885) GPU adapter GPU adapter + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Slikovni resursi: zadrži punu veličinu radne table diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index def688abcd..ad4881300d 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -3986,3 +3986,6 @@ cameraData Lens Lens # Graphics Adapter preference (#1885) GPU adapter GPU bağdaştırıcısı + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Resim Varlıkları: Tam çalışma yüzeyi boyutunu koru diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index e28ea0008c..878f2543e3 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3965,3 +3965,6 @@ curves Smooth Згладити # Graphics Adapter preference (#1885) GPU adapter Адаптер GPU + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Ресурси зображення: зберігати повний розмір монтажної області diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 503cc1006f..63855349d0 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3744,3 +3744,6 @@ curves Smooth Làm mượt # Graphics Adapter preference (#1885) GPU adapter Bộ điều hợp GPU + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size Tài nguyên ảnh: Giữ nguyên kích thước bảng vẽ diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index a030a8885f..484ac48da0 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2882,3 +2882,6 @@ curves Smooth 平滑 # Graphics Adapter preference (#1885) GPU adapter GPU 适配器 + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size 图像资源:保留完整画板大小 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 25a05a1826..a7738bdbea 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2867,3 +2867,6 @@ curves Smooth 平滑 # Graphics Adapter preference (#1885) GPU adapter GPU 介面卡 + +# Export Preferences › Image Assets: Keep Full Artboard Size + Image Assets: Keep Full Artboard Size 影像資產:保留完整工作區域大小 diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs index 5cd2e547d8..8388210bc9 100644 --- a/crates/ui-egui/src/prefs_ui.rs +++ b/crates/ui-egui/src/prefs_ui.rs @@ -1141,6 +1141,10 @@ fn humanize(key: &str) -> String { if key == "webpQuality" { return "Quality".into(); } + // File › Generate › Image Assets keeps a transparent artboard's full board instead of trimming it. + if key == "imageAssetsFullArtboards" { + return "Image Assets: Keep Full Artboard Size".into(); + } // The auto-hide notice settings read best with their own labels (Interface › Notification, #2022). if key == "notificationAutoHide" { return "Auto Hide Notifications".into(); @@ -2640,6 +2644,7 @@ mod tests { assert!(export_field_visible(&obj, "webpQuality")); assert_eq!(humanize("webpLossless"), "Lossless"); assert_eq!(humanize("webpQuality"), "Quality"); + assert_eq!(humanize("imageAssetsFullArtboards"), "Image Assets: Keep Full Artboard Size"); } #[test] diff --git a/docs/scorecard.md b/docs/scorecard.md index 42ae824b4d..dd46004711 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -9,7 +9,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js | [Performance](#performance) | 3 | 22 | 25 | 59 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 20 not run, 5 not measurable yet (baseline 2026-10-05) | | [File compatibility](#file-compatibility) | 7 | 14 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | | [Tools](#tools) | 33 | 11 | 0 | | -| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 170 (target 0) | +| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 171 (target 0) | | [Type](#type) | 4 | 3 | 2 | | | [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) | | [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 30 of 30 crates; panic_hunt present | @@ -180,7 +180,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t ## Workspace and UI -**Settings that do nothing: 26 of 170** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. +**Settings that do nothing: 26 of 171** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `file_handling.save_in_background`, `performance.cache_levels`, `performance.gpu_adapter`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`. From 962539607d427139f59085b204e28471fb46a796 Mon Sep 17 00:00:00 2001 From: David Mann Date: Wed, 21 Oct 2026 15:33:42 +0200 Subject: [PATCH 183/649] Integration: keep a strokeless shape strokeless on a 0 px width step (#6472) The width field reports a change for an arrow-key step that clamps at 0 px. With the stroke now kept at width 0, Down in the options-bar or Properties width field of a shape without a stroke added an invisible 0 px stroke (bg colour in the options bar, black in Properties), which enabled Copy Stroke and exported strokeEnabled to PSD. Skip the edit when the shape has no stroke and the width is still 0. Test: arrow_down_at_zero_width_keeps_a_strokeless_shape_strokeless. Co-authored-by: denstu473 <63150090+denstu473@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/vector_paint_tests.rs | 22 ++++++++++++++++++++++ crates/ui-egui/src/vector_ui.rs | 13 ++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/vector_paint_tests.rs b/crates/ui-egui/src/vector_paint_tests.rs index 321a106cb0..f050b9fac3 100644 --- a/crates/ui-egui/src/vector_paint_tests.rs +++ b/crates/ui-egui/src/vector_paint_tests.rs @@ -411,3 +411,25 @@ fn options_bar_fill_swatch_recolours_the_shape_just_drawn() { h.state_mut().run("edit.undo", json!({})).unwrap(); assert_eq!(shape(h.state()).fill, original.fill); } + +/// An arrow-key step at 0 px on a strokeless shape must not add an invisible stroke. +#[test] +fn arrow_down_at_zero_width_keeps_a_strokeless_shape_strokeless() { + for properties in [true, false] { + let mut app = app("rgb", 8); + app.run("shape.create", json!({"rect": [20, 20, 80, 60], "fill": "#336699", "stroke": null})).unwrap(); + assert!(shape(&app).stroke.is_none()); + let history = app.session.active().unwrap().history.past_len(); + let mut h = harness(app, properties); + h.get_all_by_role(egui::accesskit::Role::SpinButton).next().expect("the stroke width").click(); + h.run(); + h.key_press(Key::ArrowDown); + h.run_steps(3); + assert!(shape(h.state()).stroke.is_none(), "Properties={properties}: Down at 0 px added a stroke"); + assert_eq!(h.state().session.active().unwrap().history.past_len(), history, "Properties={properties}: no history step"); + // The field has the keys: Up still enables a 1 px stroke. + h.key_press(Key::ArrowUp); + h.run_steps(3); + assert_eq!(shape(h.state()).stroke.as_ref().map(|s| s.width), Some(1.0), "Properties={properties}"); + } +} diff --git a/crates/ui-egui/src/vector_ui.rs b/crates/ui-egui/src/vector_ui.rs index 1375f63b1a..3aee5cf8fc 100644 --- a/crates/ui-egui/src/vector_ui.rs +++ b/crates/ui-egui/src/vector_ui.rs @@ -1199,11 +1199,14 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo let stroke_color = swatch(ui, stroke.as_ref().map(|s| &s.paint), bg, tl!("Stroke color")); if crate::widgets::value_field(ui, &mut width, 0.0..=288.0, "px", 58.0).changed() { o.stroke_width = width; - let mut p = json!({"width": width}); - if stroke.is_none() { - p["color"] = json!(bg); + // A 0 px "change" (an arrow step clamped at the minimum) must not add a stroke. + if stroke.is_some() || width > 0.0 { + let mut p = json!({"width": width}); + if stroke.is_none() { + p["color"] = json!(bg); + } + edit = Some(json!({"stroke": p, "coalesce": key("stroke-w")})); } - edit = Some(json!({"stroke": p, "coalesce": key("stroke-w")})); } let preview = target.as_ref().filter(|s| s.stroke.is_some()).map(|s| (s.doc, s.layer)); if let Some(change) = @@ -1529,7 +1532,7 @@ pub fn shape_properties(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: photocra edit = Some(json!({"stroke": stroke, "coalesce": coalesce("stroke")})); } let mut w = sh.stroke.as_ref().map_or(0.0, |s| s.width); - if crate::widgets::value_field(ui, &mut w, 0.0..=288.0, "px", 60.0).changed() { + if crate::widgets::value_field(ui, &mut w, 0.0..=288.0, "px", 60.0).changed() && (sh.stroke.is_some() || w > 0.0) { edit = Some(json!({"stroke": {"width": w}, "coalesce": coalesce("stroke-w")})); } }); From f18e6189c72d05415f9a8f7e1d2354b084dbc9e9 Mon Sep 17 00:00:00 2001 From: David Mann Date: Wed, 21 Oct 2026 15:31:09 +0200 Subject: [PATCH 184/649] Integration: History follows the history, not every revision, and never moves a visible row (#5940) The panel scrolled with `scroll_to_rect(current, Some(Align::BOTTOM))` on every revision change. In egui an explicit alignment always realigns, and the revision also changes when nothing in the history does (selecting a layer, a channel eye). So clicking a visible older state slid it to the bottom under the pointer, Undo hid the greyed redo states, a layer click threw a user who had scrolled up back to the bottom, and selecting a snapshot scrolled it out of view. Now the panel follows the history position (document, past/redo counts, current name, and the newest past state, which also changes at the state limit), skips it while a snapshot is selected, and scrolls without alignment, so only a hidden current row moves into view. New tests: a clicked visible state stays put, Undo keeps the redo state in view, a layer click keeps the scroll, a selected snapshot stays in view, a new state at the limit is revealed; the first three fail on the PR head, the others without the snapshot guard / the newest-state key. Co-authored-by: nrq6993-a11y <342501791+nrq6993-a11y@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- .../ui-egui/src/history_panel_select_tests.rs | 142 ++++++++++++++++++ crates/ui-egui/src/panels.rs | 21 ++- 2 files changed, 158 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/history_panel_select_tests.rs b/crates/ui-egui/src/history_panel_select_tests.rs index 5e744794f3..14bfb344ca 100644 --- a/crates/ui-egui/src/history_panel_select_tests.rs +++ b/crates/ui-egui/src/history_panel_select_tests.rs @@ -83,3 +83,145 @@ fn new_history_steps_scroll_the_current_state_into_view() { let view = h.ctx.input(|i| i.viewport_rect()); assert!(view.contains_rect(row), "the current history row must scroll into view: row {row:?} view {view:?}",); } + +/// Open plus 18 New Layer states in a dock that shows only a few rows. +fn long_harness() -> Harness<'static, PhotocraftApp> { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 64, "height": 48})).unwrap(); + for n in 0..18 { + app.run("layer.new.layer", json!({"name": format!("Layer {n}")})).unwrap(); + } + let mut ready = false; + let mut h = Harness::builder().with_size(vec2(280.0, 220.0)).build_ui_state( + move |ui, app: &mut PhotocraftApp| { + if !ready { + PhotocraftApp::setup_context(ui.ctx(), theme::ThemeKind::ProMedium); + ready = true; + return; + } + history(app, ui); + }, + app, + ); + h.run_steps(4); + h +} + +/// Top of the `n`th New Layer row from the end (0 = the last). +fn row_top(h: &Harness<'_, PhotocraftApp>, n: usize) -> f32 { + let rows: Vec<_> = h.get_all_by_label("New Layer").map(|r| r.rect()).collect(); + rows[rows.len() - 1 - n].top() +} + +/// The rows' visible band: below the window top, above the footer. +fn shown(h: &Harness<'_, PhotocraftApp>, n: usize) -> bool { + let footer = h.get_by_label("Delete current state").rect().top(); + let top = row_top(h, n); + top >= h.ctx.input(|i| i.viewport_rect()).top() && top + 24.0 <= footer + 0.5 +} + +#[test] +fn clicking_a_visible_state_leaves_the_list_still() { + let mut h = long_harness(); + assert!(shown(&h, 0) && shown(&h, 1), "the newest states are in view"); + let before = row_top(&h, 1); + // A click on the state above the current one goes back one step; the row stays under the pointer. + let rows: Vec<_> = h.get_all_by_label("New Layer").collect(); + rows[rows.len() - 2].click(); + h.run_steps(4); + assert_eq!(h.state().session.active().unwrap().history.redo_labels().count(), 1); + assert_eq!(row_top(&h, 1), before, "the clicked row must not move"); +} + +#[test] +fn undo_and_a_layer_click_keep_the_redo_state_in_view() { + let mut h = long_harness(); + h.state_mut().run("edit.undo", json!({})).unwrap(); + h.run_steps(4); + assert!(shown(&h, 0), "the greyed redo state stays in view after Undo"); + let before = row_top(&h, 0); + // Selecting a layer bumps the revision but adds no state: the list stays where it is. + let id = h.state().session.active().unwrap().doc.layers[0].id; + h.state_mut().session.select_layer(id).unwrap(); + h.run_steps(4); + assert_eq!(row_top(&h, 0), before, "a layer click must not scroll History"); +} + +#[test] +fn scrolling_away_survives_a_change_that_adds_no_state() { + let mut h = long_harness(); + let view = h.ctx.input(|i| i.viewport_rect()); + h.event(egui::Event::PointerMoved(view.center())); + for _ in 0..3 { + h.event(egui::Event::MouseWheel { + unit: egui::MouseWheelUnit::Line, + delta: vec2(0.0, 3.0), + phase: egui::TouchPhase::Move, + modifiers: Default::default(), + }); + h.run_steps(1); + } + h.run_steps(4); + let scrolled = row_top(&h, 0); + assert!(!shown(&h, 0), "the wheel scrolled the current state out of view"); + let id = h.state().session.active().unwrap().doc.layers[0].id; + h.state_mut().session.select_layer(id).unwrap(); + h.run_steps(4); + assert_eq!(row_top(&h, 0), scrolled, "the user's scroll position is kept"); + // A new state brings the current row back into view. + h.state_mut().run("layer.new.layer", json!({})).unwrap(); + h.run_steps(4); + assert!(shown(&h, 0), "a new state scrolls into view"); +} + +#[test] +fn clicking_a_snapshot_keeps_it_in_view() { + let mut h = long_harness(); + h.state_mut().run("history.newSnapshot", json!({})).unwrap(); + h.run_steps(2); + // Scroll to the top, where the snapshots are. + let view = h.ctx.input(|i| i.viewport_rect()); + h.event(egui::Event::PointerMoved(view.center())); + for _ in 0..10 { + h.event(egui::Event::MouseWheel { + unit: egui::MouseWheelUnit::Line, + delta: vec2(0.0, 5.0), + phase: egui::TouchPhase::Move, + modifiers: Default::default(), + }); + h.run_steps(1); + } + h.run_steps(4); + let before = h.get_all_by_label("Snapshot 1").next().expect("the snapshot row").rect().top(); + // Selecting it adds a "Snapshot 1" state at the bottom; the selected snapshot row must not scroll away. + h.get_all_by_label("Snapshot 1").next().expect("the snapshot row").click(); + h.run_steps(4); + assert_eq!(h.state().session.active().unwrap().history.entries().last().map(String::as_str), Some("Snapshot 1")); + assert_eq!(h.get_all_by_label("Snapshot 1").next().expect("the snapshot row").rect().top(), before, "the clicked snapshot stays put"); +} + +#[test] +fn a_new_state_at_the_history_limit_still_scrolls_into_view() { + let mut h = long_harness(); + // At the limit a new step drops the oldest: the count and the (same) name stay as they were. + let st = h.state_mut().session.active_mut().unwrap(); + st.history.max_states = st.history.past_len(); + let view = h.ctx.input(|i| i.viewport_rect()); + h.event(egui::Event::PointerMoved(view.center())); + for _ in 0..3 { + h.event(egui::Event::MouseWheel { + unit: egui::MouseWheelUnit::Line, + delta: vec2(0.0, 3.0), + phase: egui::TouchPhase::Move, + modifiers: Default::default(), + }); + h.run_steps(1); + } + h.run_steps(4); + assert!(!shown(&h, 0), "the wheel scrolled the current state out of view"); + let past = h.state().session.active().unwrap().history.past_len(); + h.state_mut().run("layer.new.layer", json!({})).unwrap(); + assert_eq!(h.state().session.active().unwrap().history.past_len(), past, "the oldest state was dropped"); + h.run_steps(4); + assert!(shown(&h, 0), "a new state at the limit scrolls into view"); +} diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 46a0d4a66b..6a22b41f8e 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -3088,11 +3088,14 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) { return; }; let doc = st.doc.clone(); - let revision = st.revision; let entries = st.history.entries(); let current = entries.len() - 1; let redo: Vec = st.history.redo_labels().map(str::to_string).collect(); let selected_snap = selected_snapshot(ui.ctx(), st); + // The newest past state is a new document on every step, Undo and Redo, also at the state + // limit, where the counts and a repeated name stay the same. + let newest = st.history.past_len().checked_sub(1).and_then(|i| st.history.state(i)).map(|d| std::sync::Arc::as_ptr(&d) as usize); + let spot = (doc.id, history_spot(st), newest); let ctx = ui.ctx().clone(); // A row dragged onto the trash (#5324); a drag that never saw its release must not outlive it. if !ctx.input(|i| i.pointer.primary_down() || i.pointer.any_released()) { @@ -3119,8 +3122,16 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) { // The dock gives History a fixed height: the rows scroll above the footer. let footer = if t.pro { widgets::footer_height(ui) + ui.spacing().item_spacing.y } else { 0.0 }; let max_h = (ui.available_height() - footer).max(40.0); - let follow_id = ui.id().with(("history-follow-rev", doc.id)); - let follow = ui.ctx().data(|d| d.get_temp::(follow_id)) != Some(revision); + // Follow the current state when the history moves (a new step, Undo, a state row) or another + // document comes up (`spot`), scrolling only if its row is hidden (#5909). Other changes (a + // layer click, a channel eye) and a selected snapshot leave the list where the user put it. + let follow_id = egui::Id::new("history-follow"); + let moved = ui.ctx().data_mut(|d| { + let moved = d.get_temp::<(photocraft_doc::DocId, HistorySpot, Option)>(follow_id).as_ref() != Some(&spot); + d.insert_temp(follow_id, spot); + moved + }); + let follow = moved && selected_snap.is_none(); egui::ScrollArea::vertical().id_salt("history-rows").max_height(max_h).auto_shrink([false, false]).show(ui, |ui| { // Snapshots head the list and scroll with the states, so many of them never push the // footer out of a short dock. @@ -3169,9 +3180,9 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) { } } if follow && let Some(rect) = current_rect { - ui.scroll_to_rect(rect, Some(egui::Align::BOTTOM)); + // No alignment: a row already in view stays put. No animation, as the Layers panel reveal. + ui.scroll_to_rect_animation(rect, None, egui::style::ScrollAnimation::none()); } - ui.ctx().data_mut(|d| d.insert_temp(follow_id, revision)); }); if let Some(drag) = drag && let Some(p) = ctx.input(|i| i.pointer.interact_pos()) From 71df947c27f5c13e94c9009db927fb189716a937 Mon Sep 17 00:00:00 2001 From: SBaksa Date: Thu, 22 Oct 2026 00:39:42 +1100 Subject: [PATCH 185/649] Raw: a DNG whose raw data isn't supported opens its JPEG XL preview, not the small JPEG thumbnail (#8125) A DNG 1.7 converter that writes its raw data as JPEG XL writes the larger previews that way too, keeping only a small thumbnail as a JPEG stream. When the raw data couldn't be decoded, the fallback took the largest JPEG preview, so such a file opened as its thumbnail (256x171 for a full-size photo). photocraft-raw gains embedded_jxl_preview: the largest JPEG XL RGB preview IFD of a DNG, decoded with the raw strip and tile reader, with its PreviewColorSpace (PreviewColorSpace gains ProPhoto). The import fallback opens it when it is larger than the JPEG preview, in its stated colour space and turned upright by the raw's orientation, and the warning names the preview's format and depth. The browser build has no JPEG XL decoder, so it keeps the JPEG preview. --- Cargo.lock | 2 ++ crates/io/Cargo.toml | 3 ++ crates/io/src/raw.rs | 57 ++++++++++++++++++++++-------- crates/io/tests/raw.rs | 73 +++++++++++++++++++++++++++++++++++++++ crates/raw/src/lib.rs | 2 +- crates/raw/src/preview.rs | 47 +++++++++++++++++++++++++ crates/raw/src/sensor.rs | 2 +- 7 files changed, 169 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b0ff196c55..b30044383b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4924,6 +4924,8 @@ dependencies = [ "roxmltree 0.20.0", "serde_json", "thiserror 2.0.21", + "zune-core 0.5.3", + "zune-jpegxl", ] [[package]] diff --git a/crates/io/Cargo.toml b/crates/io/Cargo.toml index eb8c0b00d7..8e096aceb5 100644 --- a/crates/io/Cargo.toml +++ b/crates/io/Cargo.toml @@ -55,3 +55,6 @@ flate2 = { workspace = true } photocraft-psd = { workspace = true, features = ["testgen"] } photocraft-raw = { workspace = true, features = ["testgen"] } proptest = { workspace = true } +# Lossless JPEG XL encoder for the JPEG XL DNG preview test (tests only), as in photocraft-raw. +zune-jpegxl = { version = "=0.5.2", default-features = false, features = ["std"] } +zune-core = { workspace = true } diff --git a/crates/io/src/raw.rs b/crates/io/src/raw.rs index aba70c21e7..5e5c264a20 100644 --- a/crates/io/src/raw.rs +++ b/crates/io/src/raw.rs @@ -255,25 +255,52 @@ pub fn import_raw_with(name: &str, bytes: &[u8], opts: &DevelopOptions) -> Resul let summary = format!("{DEVELOPED_NOTE} ({} demosaic, as-shot white balance)", opts.demosaic.id()); developed_document(name, format, dev, &summary) } - Err(RawError::Unsupported(reason)) => match photocraft_raw::embedded_preview(bytes) { - Some(p) => { - let img = upright_preview(bytes, p.jpeg)?; - let mut r = image_to_document(name, &img)?; - r.warnings.insert( - 0, - format!( - "{format}: {reason} is not supported yet; opened the camera's embedded {}x{} JPEG preview instead (8-bit, not the raw sensor data)", - p.width, p.height - ), - ); - Ok(r) - } - None => Err(IoError::Raw(RawError::Unsupported(reason))), - }, + Err(RawError::Unsupported(reason)) => { + let jpeg = photocraft_raw::embedded_preview(bytes); + // A DNG 1.7 converter keeps only its small thumbnail as JPEG and writes the larger + // previews as JPEG XL, like the raw data (#8125): open the largest of either kind. + let jpeg_area = jpeg.map_or(0, |p| u64::from(p.width) * u64::from(p.height)); + let jxl = photocraft_raw::embedded_jxl_preview(bytes, &opts.limits).filter(|p| u64::from(p.width) * u64::from(p.height) > jpeg_area); + let (img, kind, (w, h)) = match (jxl, jpeg) { + (Some(p), _) => { + let size = (p.width, p.height); + (jxl_preview_image(bytes, p)?, "JPEG XL", size) + } + (None, Some(p)) => (upright_preview(bytes, p.jpeg)?, "JPEG", (p.width, p.height)), + (None, None) => return Err(IoError::Raw(RawError::Unsupported(reason))), + }; + let mut r = image_to_document(name, &img)?; + let depth = if img.sample_type() == SampleType::U8 { "8-bit" } else { "16-bit" }; + r.warnings.insert( + 0, + format!( + "{format}: {reason} is not supported yet; opened the camera's embedded {w}x{h} {kind} preview instead ({depth}, not the raw sensor data)" + ), + ); + Ok(r) + } Err(e) => Err(IoError::Raw(e)), } } +/// A decoded JPEG XL preview as an image: in its stated colour space (sRGB when it states +/// none), turned upright by the raw's orientation (DNG previews are stored as the raw is). +fn jxl_preview_image(raw: &[u8], p: photocraft_raw::DecodedPreview) -> Result { + let img = if p.bits == 8 { + Image::from_u8(p.width, p.height, ChannelLayout::Rgb, p.rgb.iter().map(|&v| v.min(255) as u8).collect())? + } else { + let max = f64::from((1u32 << p.bits.clamp(1, 16)) - 1); + let rgb: Vec = p.rgb.iter().map(|&v| (f64::from(v).min(max) * 65535.0 / max).round() as u16).collect(); + Image::from_u16(p.width, p.height, ChannelLayout::Rgb, &rgb)? + }; + let icc = match p.color_space { + Some(PreviewColorSpace::AdobeRgb) => Some(Builtin::AdobeRgbCompat.profile().to_bytes().to_vec()), + Some(PreviewColorSpace::ProPhoto) => Some(Builtin::ProPhotoCompat.profile().to_bytes().to_vec()), + Some(PreviewColorSpace::Srgb) | None => None, + }; + Ok(img.with_icc(icc).oriented(photocraft_raw::orientation(raw).unwrap_or(1))?) +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/io/tests/raw.rs b/crates/io/tests/raw.rs index d9e31a87c1..9a8a0798ca 100644 --- a/crates/io/tests/raw.rs +++ b/crates/io/tests/raw.rs @@ -82,6 +82,79 @@ fn unsupported_raw_falls_back_to_the_embedded_preview() { assert!(r.warnings.first().is_some_and(|w| w.contains("Nikon compressed NEF") && w.contains("embedded")), "{:?}", r.warnings); } +/// A DNG 1.7 laid out as converters write one with JPEG XL raw data: an 8×6 JPEG thumbnail in +/// IFD0, raw data this reader refuses (here floating-point LinearRaw), and a 40×30 preview +/// compressed with JPEG XL, stored as the raw is (IFD0 Orientation 6). +fn dng_with_jxl_preview() -> Vec { + use zune_core::{bit_depth::BitDepth, colorspace::ColorSpace, options::EncoderOptions}; + let thumb = Image::from_u8(8, 6, ChannelLayout::Rgb, vec![90; 8 * 6 * 3]).unwrap(); + let thumb = photocraft_codecs::encode(&thumb, Format::Jpeg, &EncodeOptions::default()).unwrap(); + let (w, h) = (40usize, 30usize); + let rgb: Vec = (0..w * h).flat_map(|i| [(i % w * 6) as u8, (i / w * 8) as u8, 120]).collect(); + let mut preview = Vec::new(); + zune_jpegxl::JxlSimpleEncoder::new(&rgb, EncoderOptions::new(w, h, ColorSpace::RGB, BitDepth::Eight)).encode(&mut preview).unwrap(); + let mut t = TiffBuilder::default(); + let raw_strip = t.blob(vec![0; 4 * 4 * 3 * 2]); + let raw = t.ifd(vec![ + (254, Val::Long(vec![0])), + (256, Val::Long(vec![4])), + (257, Val::Long(vec![4])), + (258, Val::Short(vec![16, 16, 16])), + (259, Val::Short(vec![1])), + (262, Val::Short(vec![34892])), + (273, Val::Blobs(vec![raw_strip])), + (277, Val::Short(vec![3])), + (278, Val::Long(vec![4])), + (279, Val::Long(vec![4 * 4 * 3 * 2])), + (339, Val::Short(vec![3, 3, 3])), + ]); + let preview_len = preview.len() as u32; + let preview_strip = t.blob(preview); + let preview = t.ifd(vec![ + (254, Val::Long(vec![1])), + (256, Val::Long(vec![w as u32])), + (257, Val::Long(vec![h as u32])), + (258, Val::Short(vec![8, 8, 8])), + (259, Val::Short(vec![52546])), + (262, Val::Short(vec![2])), + (273, Val::Blobs(vec![preview_strip])), + (277, Val::Short(vec![3])), + (278, Val::Long(vec![h as u32])), + (279, Val::Long(vec![preview_len])), + (50970, Val::Long(vec![2])), + ]); + let thumb_len = thumb.len() as u32; + let thumb_strip = t.blob(thumb); + let ifd0 = t.ifd(vec![ + (254, Val::Long(vec![1])), + (256, Val::Long(vec![8])), + (257, Val::Long(vec![6])), + (258, Val::Short(vec![8, 8, 8])), + (259, Val::Short(vec![7])), + (262, Val::Short(vec![6])), + (271, Val::Ascii("Synthetic".into())), + (273, Val::Blobs(vec![thumb_strip])), + (274, Val::Short(vec![6])), + (277, Val::Short(vec![3])), + (278, Val::Long(vec![6])), + (279, Val::Long(vec![thumb_len])), + (330, Val::Ifds(vec![raw, preview])), + (50706, Val::Byte(vec![1, 7, 0, 0])), + ]); + t.chain = vec![ifd0]; + t.build() +} + +/// #8125: a DNG whose raw data isn't supported opens its full JPEG XL preview, upright, not +/// the small JPEG thumbnail. +#[test] +fn unsupported_dng_falls_back_to_its_jpeg_xl_preview() { + let r = import("photo.dng", &dng_with_jxl_preview()).unwrap(); + assert_eq!((r.document.size.width, r.document.size.height), (30, 40), "the 40×30 preview, turned upright: {:?}", r.warnings); + let w = r.warnings.first().map_or("", String::as_str); + assert!(w.contains("floating-point") && w.contains("40x30 JPEG XL preview"), "{:?}", r.warnings); +} + #[test] fn unsupported_raw_without_preview_is_a_clear_error() { let mut cr3 = vec![0, 0, 0, 24]; diff --git a/crates/raw/src/lib.rs b/crates/raw/src/lib.rs index 0d1a99e796..f2d26ed68e 100644 --- a/crates/raw/src/lib.rs +++ b/crates/raw/src/lib.rs @@ -77,7 +77,7 @@ pub use crate::develop::{DevelopOptions, Developed, RawInfo, WhiteBalance, devel pub use crate::error::RawError; pub use crate::look::{CameraLook, LookRejected, PROXY_EDGE, Reference, ToneCurve, fit_look}; pub use crate::opcodes::GainMap; -pub use crate::preview::{Preview, PreviewColorSpace, embedded_preview, embedded_preview_color_space, embedded_previews}; +pub use crate::preview::{DecodedPreview, Preview, PreviewColorSpace, embedded_jxl_preview, embedded_preview, embedded_preview_color_space, embedded_previews}; pub use crate::sensor::{BlackLevels, Cfa, Rect, Sensor}; pub use crate::tone::{Tone, retone}; diff --git a/crates/raw/src/preview.rs b/crates/raw/src/preview.rs index d5dd013310..489eea3b9e 100644 --- a/crates/raw/src/preview.rs +++ b/crates/raw/src/preview.rs @@ -1,5 +1,7 @@ //! Finding the camera-rendered JPEG preview embedded in a raw file. +use crate::Limits; +use crate::sensor::{JPEG_XL, JpegLayout, read_plane}; use crate::tiff::{Tiff, tag}; /// An embedded baseline-JPEG preview. @@ -100,11 +102,56 @@ pub fn embedded_previews(bytes: &[u8]) -> Vec> { found } +/// A DNG 1.7 preview compressed with JPEG XL (Compression 52546), decoded. Converters that +/// write their raw data as JPEG XL store the larger previews that way too, leaving only a small +/// thumbnail as a JPEG stream for [`embedded_previews`] (#8125). +#[derive(Debug, Clone, PartialEq)] +pub struct DecodedPreview { + pub width: u32, + pub height: u32, + /// BitsPerSample: `rgb` holds `0..=2^bits - 1`. + pub bits: u32, + /// Interleaved RGB, `width * height * 3` samples. + pub rgb: Vec, + /// The DNG PreviewColorSpace (tag 50970); `None` when it's unknown or grey. + pub color_space: Option, +} + +/// DNG PreviewColorSpace (DNG Specification 1.7). +const PREVIEW_COLOR_SPACE: u16 = 50970; + +/// The largest JPEG XL-compressed RGB preview of a DNG, decoded within `limits`. `None` when the +/// file has none, or it doesn't decode (always in the browser build, which has no JPEG XL decoder). +pub fn embedded_jxl_preview(bytes: &[u8], limits: &Limits) -> Option { + let t = Tiff::new(bytes)?; + let ifd0 = t.ifd_at(t.first_ifd, 0)?; + if !ifd0.has(tag::DNG_VERSION) { + return None; + } + let area = |i: &crate::tiff::Ifd| u64::from(t.tag_uint(i, tag::IMAGE_WIDTH).unwrap_or(0)) * u64::from(t.tag_uint(i, tag::IMAGE_LENGTH).unwrap_or(0)); + let ifd = t + .all_ifds() + .into_iter() + .filter(|i| t.tag_uint(i, tag::NEW_SUBFILE_TYPE) == Some(1)) + .filter(|i| t.tag_uint(i, tag::COMPRESSION) == Some(JPEG_XL) && t.tag_uint(i, tag::SAMPLES_PER_PIXEL) == Some(3)) + .max_by_key(area)?; + let plane = read_plane(&t, &ifd, limits, JpegLayout::Flat).ok()?; + let color_space = match t.tag_uint(&ifd, PREVIEW_COLOR_SPACE).or_else(|| t.tag_uint(&ifd0, PREVIEW_COLOR_SPACE)) { + Some(2) => Some(PreviewColorSpace::Srgb), + Some(3) => Some(PreviewColorSpace::AdobeRgb), + Some(4) => Some(PreviewColorSpace::ProPhoto), + _ => None, + }; + Some(DecodedPreview { width: u32::try_from(plane.width).ok()?, height: u32::try_from(plane.height).ok()?, bits: plane.bits, rgb: plane.data, color_space }) +} + /// The colour space a raw file states for its embedded previews, which carry no ICC profile of their own. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum PreviewColorSpace { Srgb, AdobeRgb, + /// ProPhoto RGB, which a DNG can state for its previews (PreviewColorSpace 4). + ProPhoto, } /// The colour space the raw's EXIF gives for the camera's JPEG rendering, for a preview that declares none itself: diff --git a/crates/raw/src/sensor.rs b/crates/raw/src/sensor.rs index f2cffdb808..8defea86ca 100644 --- a/crates/raw/src/sensor.rs +++ b/crates/raw/src/sensor.rs @@ -212,7 +212,7 @@ pub(crate) enum JpegLayout { } /// DNG 1.7 JPEG XL compression. -const JPEG_XL: u32 = 52546; +pub(crate) const JPEG_XL: u32 = 52546; /// Inflates one zlib tile into at most `need` bytes. The stream must run to its end: a truncated /// stream, or one that holds more than `need` bytes, is an error rather than a silent cut-off. From c0492f2303c31cfb9e108e5dc8b2cee4fd88053c Mon Sep 17 00:00:00 2001 From: IbrahimOezhan Date: Wed, 21 Oct 2026 15:53:54 +0200 Subject: [PATCH 186/649] Document the Export Preferences, Image Assets and preference-label helpers export_preferences, image_assets and humanize had no doc comments; the review's docstring check counts them as functions this change touches. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/web_cmds.rs | 4 ++++ crates/ui-egui/src/prefs_ui.rs | 2 ++ 2 files changed, 6 insertions(+) diff --git a/crates/engine/src/web_cmds.rs b/crates/engine/src/web_cmds.rs index d2734d5d24..ff0a29df9d 100644 --- a/crates/engine/src/web_cmds.rs +++ b/crates/engine/src/web_cmds.rs @@ -1035,6 +1035,8 @@ fn save_for_web_impl(s: &mut Session, p: &Value, write: &mut dyn FnMut(&str, &[u // ---------- Export Preferences / Quick Export ---------- +/// File › Export › Export Preferences…: sets the given `export.*` preferences through `prefs.set` +/// (validated like any other preference) and returns the whole section. fn export_preferences(s: &mut Session, p: &Value) -> Result { let cmd = "file.export.exportPreferences"; let mut values = serde_json::Map::new(); @@ -1496,6 +1498,8 @@ pub fn assets_dir(doc_path: &str) -> String { join(&dir, &format!("{}-assets", stem(doc_path))) } +/// File › Generate › Image Assets: toggles generation for the active document (or sets it with +/// `on`) and, when it is on and the output folder is known, writes the assets now. fn image_assets(s: &mut Session, p: &Value) -> Result { let d = s.active().ok_or(EngineError::NoDocument)?; let id: DocId = d.doc.id; diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs index 8388210bc9..3c3f6307a4 100644 --- a/crates/ui-egui/src/prefs_ui.rs +++ b/crates/ui-egui/src/prefs_ui.rs @@ -1126,6 +1126,8 @@ fn gpu_memory_lines(app: &PhotocraftApp) -> Vec { v } +/// The label a preference key shows in the dialog: a few keys have their own wording, the rest +/// split camelCase into words (`convertToSrgb` → "Convert to srgb"). fn humanize(key: &str) -> String { match key { "appearanceMode" => return "Appearance Mode".into(), From 27c525c0790c7aad0b66faf96994b8eb3ca330eb Mon Sep 17 00:00:00 2001 From: David Mann Date: Wed, 21 Oct 2026 16:04:29 +0200 Subject: [PATCH 187/649] Integration: a unit per field, no Percent, not remembered, as in Photoshop (#7922) Photoshop's Create Rectangle switches only the right-clicked field (Width 35.28 mm, Height still 100 px), lists the six length units without Percent, and opens in pixels again after OK. The PR shared one unit between both fields, offered Percent, and saved the unit on every OK, so after one use with the rulers in px the dialog stayed in px even after the rulers changed to cm, though no unit was ever picked. Now each field has its own widthUnit / heightUnit (set only by the menu, never remembered), and the menu is rulers::unit_menu_of with LENGTH_UNITS. The new test right-clicks the real field and clicks the menu item through egui input. Co-authored-by: Korg1ch <57859048+Korg1ch@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/rulers.rs | 21 ++++-- crates/ui-egui/src/shape_dialog.rs | 25 +++---- crates/ui-egui/src/shape_dialog_tests.rs | 94 +++++++++++++++--------- 3 files changed, 87 insertions(+), 53 deletions(-) diff --git a/crates/ui-egui/src/rulers.rs b/crates/ui-egui/src/rulers.rs index a5f4bb0fd1..40c20a9814 100644 --- a/crates/ui-egui/src/rulers.rs +++ b/crates/ui-egui/src/rulers.rs @@ -64,19 +64,28 @@ fn unit_label(u: Unit) -> &'static str { /// Every length unit, in the Preferences › Units & Rulers order. const UNITS: [Unit; 7] = [Unit::Pixels, Unit::Inches, Unit::Centimeters, Unit::Millimeters, Unit::Points, Unit::Picas, Unit::Percent]; -/// The ruler right-click menu: every length unit with its (translated) label and whether it's the -/// one in effect. Picking one changes the ruler unit exactly as the preference pane does. -fn unit_menu_items(current: Unit) -> Vec<(String, &'static str, bool)> { - UNITS.iter().map(|&u| (tl!(unit_label(u)).to_string(), u.name(), u == current)).collect() +/// The units Photoshop's Create Rectangle (and the other shape dialogs) offer on a right-click of +/// Width or Height: the lengths, without Percent. +pub(crate) const LENGTH_UNITS: [Unit; 6] = [Unit::Pixels, Unit::Inches, Unit::Centimeters, Unit::Millimeters, Unit::Points, Unit::Picas]; + +/// The ruler right-click menu: every unit of `units` with its (translated) label and whether it's +/// the one in effect. Picking one changes the ruler unit exactly as the preference pane does. +fn unit_menu_items(current: Unit, units: &[Unit]) -> Vec<(String, &'static str, bool)> { + units.iter().map(|&u| (tl!(unit_label(u)).to_string(), u.name(), u == current)).collect() } /// The length units menu that right-clicking a ruler (or Free Transform's W and H fields) opens; /// the chosen unit's name is returned (`None` if the menu is dismissed without a pick). pub(crate) fn unit_menu(ui: &mut egui::Ui, current: Unit) -> Option<&'static str> { + unit_menu_of(ui, current, &UNITS) +} + +/// [`unit_menu`] with only `units` in it. +pub(crate) fn unit_menu_of(ui: &mut egui::Ui, current: Unit, units: &[Unit]) -> Option<&'static str> { crate::widgets::menu_scroll(ui, |ui| { ui.set_min_width(150.0); let mut chosen = None; - for (label, name, checked) in unit_menu_items(current) { + for (label, name, checked) in unit_menu_items(current, units) { let label = if checked { format!("✓ {label}") } else { label }; if ui.button(label).clicked() { ui.close(); @@ -806,7 +815,7 @@ mod tests { #[test] fn unit_menu_lists_every_unit_with_the_current_one_checked() { - let items = unit_menu_items(Unit::Inches); + let items = unit_menu_items(Unit::Inches, &UNITS); assert_eq!(items.len(), Unit::NAMES.len()); // Every unit is offered, labelled, and in the preference's order. assert_eq!(items[0], ("Pixels".to_string(), "pixels", false)); diff --git a/crates/ui-egui/src/shape_dialog.rs b/crates/ui-egui/src/shape_dialog.rs index 517fa90248..ca68e87015 100644 --- a/crates/ui-egui/src/shape_dialog.rs +++ b/crates/ui-egui/src/shape_dialog.rs @@ -2,8 +2,8 @@ //! opens Photoshop's creation dialog instead of drawing. OK runs the same `shape.create` command as //! a drag, with the options bar's fill and stroke, at the clicked point (or centred on it). //! Width and height are stored in document pixels (so automation can set them with -//! `ui.dialog.set`) and shown in the ruler unit, or in one picked from the Width and Height -//! fields' right-click menu (remembered with the other values). +//! `ui.dialog.set`) and shown in the ruler unit, or each in one picked from its right-click menu +//! (`widthUnit`, `heightUnit`; not remembered, as in Photoshop). use egui::{Align2, Sense, pos2, vec2}; use serde_json::{Map, Value, json}; @@ -18,7 +18,7 @@ const MARK: &str = "__createShape"; /// Largest side the dialog accepts, in pixels (Photoshop's document limit). const MAX_PX: f64 = 300_000.0; /// Remembered values (document pixels; sides and radii come from the options bar). -const KEYS: [&str; 5] = ["width", "height", "fromCenter", "starRatio", "unit"]; +const KEYS: [&str; 4] = ["width", "height", "fromCenter", "starRatio"]; pub fn owns(fields: &Map) -> bool { fields.contains_key(MARK) @@ -43,7 +43,6 @@ fn valid(key: &str, v: &Value) -> bool { match key { "width" | "height" => v.as_f64().is_some_and(|x| x.is_finite() && (1.0..=MAX_PX).contains(&x)), "starRatio" => v.as_f64().is_some_and(|x| x.is_finite() && (1.0..=100.0).contains(&x)), - "unit" => v.as_str().is_some_and(|u| Unit::parse(u).is_some()), _ => v.is_boolean(), } } @@ -72,8 +71,6 @@ pub fn open(app: &mut PhotocraftApp, tool: Tool, at: [f64; 2]) -> Option { f.insert("width".into(), json!(100.0)); f.insert("height".into(), json!(100.0)); f.insert("fromCenter".into(), json!(false)); - // The unit Width and Height show (the ruler unit until one is picked with a right-click). - f.insert("unit".into(), json!(app.session.prefs().units_and_rulers.rulers.name())); match kind { "rectangle" => { f.insert("radii".into(), json!([r, r, r, r])); @@ -166,16 +163,16 @@ fn label(ui: &mut egui::Ui, text: &str) { pub fn body(app: &PhotocraftApp, ui: &mut egui::Ui, f: &mut Map) { ui.spacing_mut().item_spacing.y = 6.0; let kind = f.get(MARK).and_then(Value::as_str).unwrap_or("").to_string(); - // Width and height in the dialog's unit (percent of the document's side): the ruler unit, or - // the one picked from the fields' right-click menu, as in Photoshop (#7786). + // Width and height each in its own unit (percent of the document's side): the ruler unit, or + // the one picked from that field's right-click menu, as in Photoshop (#7786). let ur = &app.session.prefs().units_and_rulers; - let unit = f.get("unit").and_then(Value::as_str).and_then(Unit::parse).unwrap_or(ur.rulers); - let ppi = ur.point_size.per_inch(); + let (rulers, ppi) = (ur.rulers, ur.point_size.per_inch()); let (dpi, size) = app .session .active() .map_or((72.0, [1.0, 1.0]), |d| (f64::from(d.doc.resolution_dpi.max(1.0)), [f64::from(d.doc.size.width), f64::from(d.doc.size.height)])); - for (key, text, extent) in [("width", tl!("Width:"), size[0]), ("height", tl!("Height:"), size[1])] { + for (key, unit_key, text, extent) in [("width", "widthUnit", tl!("Width:"), size[0]), ("height", "heightUnit", tl!("Height:"), size[1])] { + let unit = f.get(unit_key).and_then(Value::as_str).and_then(Unit::parse).unwrap_or(rulers); ui.horizontal(|ui| { label(ui, text); let px = num(f, key).unwrap_or(100.0); @@ -187,10 +184,10 @@ pub fn body(app: &PhotocraftApp, ui: &mut egui::Ui, f: &mut Map) let px = unit.to_px(f64::from(v), dpi, extent, ppi).clamp(1.0, MAX_PX); f.insert(key.into(), json!((px * 1000.0).round() / 1000.0)); } - // Right-click: the length units, for both fields (the sizes stay in pixels). + // Right-click: the length units for this field (the sizes stay in pixels). resp.context_menu(|ui| { - if let Some(name) = crate::rulers::unit_menu(ui, unit) { - f.insert("unit".into(), json!(name)); + if let Some(name) = crate::rulers::unit_menu_of(ui, unit, &crate::rulers::LENGTH_UNITS) { + f.insert(unit_key.into(), json!(name)); } }); }); diff --git a/crates/ui-egui/src/shape_dialog_tests.rs b/crates/ui-egui/src/shape_dialog_tests.rs index db45a004a7..fdb6085d04 100644 --- a/crates/ui-egui/src/shape_dialog_tests.rs +++ b/crates/ui-egui/src/shape_dialog_tests.rs @@ -249,56 +249,84 @@ fn the_dialog_body_renders_for_every_tool_and_unit() { } } -/// The texts a dialog body draws. -fn body_texts(app: &PhotocraftApp, fields: &mut serde_json::Map) -> Vec { - let ctx = egui::Context::default(); - let mut out = ctx.run_ui(egui::RawInput::default(), |ui| body(app, ui, fields)); +/// One frame of a dialog body with `events`: the texts it draws, each with its screen rect. +fn frame(ctx: &egui::Context, app: &PhotocraftApp, fields: &mut serde_json::Map, events: Vec) -> Vec<(String, egui::Rect)> { + let input = egui::RawInput { events, ..Default::default() }; + let mut out = ctx.run_ui(input, |ui| body(app, ui, fields)); out.textures_delta.clear(); let mut texts = Vec::new(); for clip in &out.shapes { if let egui::Shape::Text(t) = &clip.shape { - texts.push(t.galley.text().to_string()); + texts.push((t.galley.text().to_string(), t.galley.rect.translate(t.pos.to_vec2()))); } } texts } -/// #7786: Width and Height show in the unit picked from their right-click menu (the ruler unit -/// until then), the sizes stay in pixels, and OK remembers the unit with the other values. +/// A click of `button` at `pos`, as frames: move there, press, release. +fn click(ctx: &egui::Context, app: &PhotocraftApp, f: &mut serde_json::Map, pos: egui::Pos2, button: egui::PointerButton) { + let press = |pressed| egui::Event::PointerButton { pos, button, pressed, modifiers: egui::Modifiers::NONE }; + frame(ctx, app, f, vec![egui::Event::PointerMoved(pos)]); + frame(ctx, app, f, vec![press(true)]); + frame(ctx, app, f, vec![press(false)]); +} + +/// Each of Width and Height: its value and unit, and the value's screen rect. +fn sides(texts: &[(String, egui::Rect)]) -> Vec<(String, String, egui::Rect)> { + ["Width:", "Height:"] + .iter() + .filter_map(|l| texts.iter().position(|(t, _)| t == l)) + .filter_map(|i| { + let (v, r) = texts.get(i + 1)?.clone(); + Some((v, texts.get(i + 2)?.0.clone(), r)) + }) + .collect() +} + +/// #7786: right-clicking Width or Height offers the length units (no Percent, as in Photoshop's +/// Create Rectangle) and switches only that field; the sizes stay in pixels and the unit isn't +/// remembered, so the next dialog follows the ruler unit again. #[test] -fn width_and_height_show_in_the_picked_unit_and_remember_it() { +fn right_click_picks_the_unit_of_that_field_only_and_it_is_not_remembered() { let mut app = app(); press(&mut app, Tool::Rectangle, [10.0, 10.0], [10.0, 10.0]); let id = only_dialog(&app); let mut f = app.ui.dialog_mut(id).unwrap().fields.clone(); - assert_eq!(f["unit"], json!("pixels"), "the ruler unit at first"); - // Each of Width and Height: its label, its value, its unit. - let sides = |texts: &[String]| -> Vec<(String, String)> { - ["Width:", "Height:"] - .iter() - .filter_map(|l| texts.iter().position(|t| t == l)) - .filter_map(|i| Some((texts.get(i + 1)?.clone(), texts.get(i + 2)?.clone()))) - .collect() - }; + let ctx = egui::Context::default(); + let shown = |s: &[(String, String, egui::Rect)]| s.iter().map(|(v, u, _)| (v.clone(), u.clone())).collect::>(); let px = ("100".to_string(), "px".to_string()); - assert_eq!(sides(&body_texts(&app, &mut f)), [px.clone(), px], "shown in pixels"); - // What the menu's Millimeters sets: 100 px at the document's 72 ppi is 35.28 mm. - f.insert("unit".into(), json!("mm")); - let mm = ("35.28".to_string(), "mm".to_string()); - assert_eq!(sides(&body_texts(&app, &mut f)), [mm.clone(), mm]); + let texts = frame(&ctx, &app, &mut f, vec![]); + let s = sides(&texts); + assert_eq!(shown(&s), [px.clone(), px.clone()], "shown in the ruler unit, pixels"); + // Right-click Width: its menu lists the lengths and no Percent. + click(&ctx, &app, &mut f, s[0].2.center(), egui::PointerButton::Secondary); + let menu = frame(&ctx, &app, &mut f, vec![]); + let has = |label: &str| menu.iter().any(|(t, _)| t.ends_with(label)); + assert!(["Pixels", "Inches", "Centimeters", "Millimeters", "Points", "Picas"].iter().all(|l| has(l)), "{menu:?}"); + assert!(!has("Percent"), "Photoshop's menu here has no Percent"); + let mm_item = menu.iter().find(|(t, _)| t == "Millimeters").unwrap().1.center(); + click(&ctx, &app, &mut f, mm_item, egui::PointerButton::Primary); + // Only Width changes: 100 px at the document's 72 ppi is 35.28 mm; the size stays in pixels. + let s = sides(&frame(&ctx, &app, &mut f, vec![])); + assert_eq!(shown(&s), [("35.28".to_string(), "mm".to_string()), px.clone()]); + assert_eq!((f["widthUnit"].as_str(), f.get("heightUnit")), (Some("mm"), None)); assert_eq!(f["width"].as_f64(), Some(100.0), "the size stays in pixels"); - set(&mut app, id, json!({"unit": "mm", "width": 50})); + // Height has its own menu, with its own unit checked: Inches switches Height alone. + click(&ctx, &app, &mut f, s[1].2.center(), egui::PointerButton::Secondary); + let menu = frame(&ctx, &app, &mut f, vec![]); + assert!(menu.iter().any(|(t, _)| t == "✓ Pixels"), "{menu:?}"); + let in_item = menu.iter().find(|(t, _)| t == "Inches").unwrap().1.center(); + click(&ctx, &app, &mut f, in_item, egui::PointerButton::Primary); + let s = sides(&frame(&ctx, &app, &mut f, vec![])); + assert_eq!(shown(&s), [("35.28".to_string(), "mm".to_string()), ("1.389".to_string(), "in".to_string())]); + // OK, then the rulers change: the next dialog shows the new ruler unit, not the pick. + set(&mut app, id, json!({"widthUnit": "mm", "width": 50})); crate::dialogs::confirm(&mut app, id).unwrap(); - // The next Create Rectangle opens in millimetres, with the remembered size. + app.run("prefs.set", json!({"path": "unitsAndRulers.rulers", "value": "cm"})).unwrap(); press(&mut app, Tool::Rectangle, [40.0, 40.0], [40.0, 40.0]); let id = only_dialog(&app); - let f = &app.ui.dialog_mut(id).unwrap().fields; - assert_eq!((f["unit"].as_str(), f["width"].as_f64()), (Some("mm"), Some(50.0))); - // A remembered unit that isn't one falls back to the ruler unit. - app.ui.close_dialog(id); - app.session.prefs.edit(|p| { - p.dialogs.insert("shape.create.rectangle".into(), json!({"unit": "furlongs"})); - }); - press(&mut app, Tool::Rectangle, [40.0, 40.0], [40.0, 40.0]); - assert_eq!(app.ui.dialogs[0].fields["unit"], json!("pixels")); + let mut f = app.ui.dialog_mut(id).unwrap().fields.clone(); + assert_eq!((f.get("widthUnit"), f["width"].as_f64()), (None, Some(50.0)), "the size is remembered, the unit isn't"); + let s = sides(&frame(&egui::Context::default(), &app, &mut f, vec![])); + assert_eq!(shown(&s), [("1.76".to_string(), "cm".to_string()), ("3.53".to_string(), "cm".to_string())]); } From 52c1e211d1c8bb7fe3e8d006aa24e8c41cc01797 Mon Sep 17 00:00:00 2001 From: David Mann Date: Wed, 21 Oct 2026 15:47:56 +0200 Subject: [PATCH 188/649] Integration: one undo step per Color panel gesture, no Move tool recolouring (#5842) A drag in the Color panel's field or sliders only reaches the panel after its press frame (egui decides click vs drag on a later frame), so `continuing()` was always true on a drag's first pick and the drag reused the previous pick's history key: a swatch, click or earlier drag followed by a drag became one undo step. The key is now the pointer's press time, as `type_tool::drag_key` does; swatches, the Color Picker and clicks get a fresh key. The kittest `color_panel_gestures_recolour_the_selected_shape_in_separate_steps` drives real clicks and drags (the first drag joined the click's step before). CodeRabbit flagged this on the PR. The R, G, B, HSB and hex fields apply every keystroke, so typing "128" into G with a shape selected left three undo steps (1, 12, 128). While no button is held, picks now share the focused field's step; a focus counter (`track_focus`, run by the panel each frame) makes a value typed after refocusing a field a new step, and a click (a release frame) is always its own; a sum (`2*64`) committed by Enter, after the field let go of the focus, keeps the step of the field focused last frame. Pinned by `typing_an_rgb_value_recolours_the_selected_shape_in_one_step` (5 steps instead of 3 for "128" before). With the Move tool (the default tool), Photoshop only changes the foreground when a colour is picked; the PR recoloured the selected type and shapes too, so a colour picked to paint with later rewrote them. The Move tool now joins `other_tools_only_change_the_foreground`. Co-authored-by: baz <57290335+bazmarth@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/apply_color.rs | 61 +++++++++---- crates/ui-egui/src/apply_color_tests.rs | 69 ++++----------- crates/ui-egui/src/color_picker_ui.rs | 2 +- crates/ui-egui/src/panels.rs | 110 +++++++++++++++++++++++- crates/ui-egui/src/state.rs | 4 - crates/ui-egui/src/swatches_ui.rs | 2 +- docs/ui-parity.md | 4 +- 7 files changed, 170 insertions(+), 82 deletions(-) diff --git a/crates/ui-egui/src/apply_color.rs b/crates/ui-egui/src/apply_color.rs index ed40823a04..a2b2fcbb2e 100644 --- a/crates/ui-egui/src/apply_color.rs +++ b/crates/ui-egui/src/apply_color.rs @@ -6,14 +6,13 @@ //! * a Type tool, not editing: the colour of every selected type layer (`type.setStyle`); //! * a shape tool, a Pen or a path selection tool: the fill of every selected shape layer //! (`shape.edit` with `fill`); -//! * the Move tool (layers picked by a click, ⇧-click or its marquee): both, every selected type -//! layer and shape; -//! * any other tool (the brushes, the pixel selection tools…): nothing, only the foreground. +//! * any other tool (the Move tool, the brushes, the pixel selection tools…): nothing, only the +//! foreground. //! //! One pick is one history step for all the layers it recolours; a drag in the Color panel's field //! or sliders is one step too. -use egui::Context; +use egui::{Context, Id}; use photocraft_doc::LayerContent; use serde_json::json; @@ -41,25 +40,53 @@ fn recolours_shapes(tool: Tool) -> bool { ) } -/// Is the pointer still held from an earlier frame (a drag in the Color panel), so this pick -/// joins the previous one's history step? -pub fn continuing(ctx: &Context) -> bool { - ctx.input(|i| i.pointer.any_down() && !i.pointer.any_pressed()) +/// The gesture a Color panel pick belongs to: the press while the pointer is held (a drag in its +/// field or sliders), else the field being typed into (its value changes with every keystroke); +/// `None` for a click. Every pick of one gesture joins one history step, and the next press or +/// focused field starts another. +pub fn gesture(ctx: &Context) -> Option { + if let Some(t) = ctx.input(|i| if i.pointer.any_down() { i.pointer.press_start_time() } else { None }) { + return Some(format!("press-{}", t.to_bits())); + } + // A click (reported on its release) is a step of its own, even while a field keeps the focus. + if ctx.input(|i| i.pointer.any_released()) { + return None; + } + // The focused field; on the frame Enter commits a typed sum (`2*64`) it has just let go, so + // the field focused last frame. + let (last, n) = ctx.data(|d| d.get_temp::<(Option, u64)>(focus_key())).unwrap_or_default(); + ctx.memory(|m| m.focused()).or(last).map(|id| format!("field-{}-{n}", id.value())) +} + +fn focus_key() -> Id { + Id::new("apply-color-focus") +} + +/// Counts the changes of keyboard focus, so two values typed into one field, each after +/// focusing it, are two history steps (see [`gesture`]). Called every frame by the Color panel. +pub fn track_focus(ctx: &Context) { + let focused = ctx.memory(|m| m.focused()); + ctx.data_mut(|d| { + let (last, n) = d.get_temp::<(Option, u64)>(focus_key()).unwrap_or_default(); + if last != focused { + d.insert_temp(focus_key(), (focused, n.wrapping_add(1))); + } + }); } /// The foreground colour just changed through the Color panel, the Swatches panel or the Color /// Picker: recolour what is selected, as the tool in hand says (see the module docs). -/// `continuing` (a drag still in progress) joins the previous pick's history step. -pub fn foreground_changed(app: &mut PhotocraftApp, continuing: bool) { +/// Picks of one `gesture` (a Color panel drag or typed value, see [`gesture`]) share one history +/// step; `None` (a swatch, the Color Picker, a click) is a step of its own. +pub fn foreground_changed(app: &mut PhotocraftApp, gesture: Option) { // Editing type: the selected characters, in the editing session's step; nothing else. if app.ui.text_edit.is_some() { crate::type_tool::foreground_changed(app); return; } let tool = app.ui.tool; - // What the tool in hand recolours: type layers, shape layers, or both (the Move tool). + // What the tool in hand recolours: type layers or shape layers. let (do_texts, do_shapes) = match tool { - Tool::Move => (true, true), t if t.is_type() && !t.is_type_mask() => (true, false), t if recolours_shapes(t) => (false, true), _ => return, @@ -75,13 +102,9 @@ pub fn foreground_changed(app: &mut PhotocraftApp, continuing: bool) { if texts.is_empty() && shapes.is_empty() { return; } - let key = match app.ui.apply_color_key.clone().filter(|_| continuing) { - Some(k) => k, - None => { - let k = format!("apply-color-{}", app.ui.alloc_id()); - app.ui.apply_color_key = Some(k.clone()); - k - } + let key = match gesture { + Some(g) => format!("apply-color-{g}"), + None => format!("apply-color-{}", app.ui.alloc_id()), }; let color = hex(app.session.tools.foreground); let result = (|| { diff --git a/crates/ui-egui/src/apply_color_tests.rs b/crates/ui-egui/src/apply_color_tests.rs index a007eb9845..b07d731775 100644 --- a/crates/ui-egui/src/apply_color_tests.rs +++ b/crates/ui-egui/src/apply_color_tests.rs @@ -58,9 +58,9 @@ fn steps(app: &PhotocraftApp) -> usize { app.session.active().unwrap().history.entries().len() } -fn pick(app: &mut PhotocraftApp, c: [f32; 4], continuing: bool) { +fn pick(app: &mut PhotocraftApp, c: [f32; 4], gesture: Option<&str>) { app.session.tools.foreground = c; - super::foreground_changed(app, continuing); + super::foreground_changed(app, gesture.map(str::to_string)); } #[test] @@ -68,7 +68,7 @@ fn a_type_tool_recolours_every_selected_type_layer_in_one_step() { for tool in [Tool::Type, Tool::VerticalType] { let (mut app, texts, shapes) = app(tool); let n = steps(&app); - pick(&mut app, RED, false); + pick(&mut app, RED, None); assert!(texts.iter().all(|id| red(text_rgb(&app, *id))), "{tool:?}"); assert!(shapes.iter().all(|id| !red(fill_rgb(&app, *id).unwrap())), "{tool:?}: shapes keep their fill"); assert_eq!(steps(&app), n + 1, "one history step"); @@ -82,7 +82,7 @@ fn shape_and_path_tools_recolour_every_selected_shape_fill_in_one_step() { for tool in [Tool::Rectangle, Tool::Polygon, Tool::PathSelection, Tool::DirectSelection, Tool::Pen, Tool::CurvaturePen] { let (mut app, texts, shapes) = app(tool); let n = steps(&app); - pick(&mut app, RED, false); + pick(&mut app, RED, None); assert!(shapes.iter().all(|id| fill_rgb(&app, *id).is_some_and(red)), "{tool:?}"); assert!(texts.iter().all(|id| !red(text_rgb(&app, *id))), "{tool:?}: type keeps its colour"); assert_eq!(steps(&app), n + 1, "{tool:?}: one history step for both layers"); @@ -91,10 +91,10 @@ fn shape_and_path_tools_recolour_every_selected_shape_fill_in_one_step() { #[test] fn other_tools_only_change_the_foreground() { - for tool in [Tool::Brush, Tool::RectMarquee, Tool::Eyedropper, Tool::HorizontalTypeMask] { + for tool in [Tool::Move, Tool::Brush, Tool::RectMarquee, Tool::Eyedropper, Tool::HorizontalTypeMask] { let (mut app, texts, shapes) = app(tool); let n = steps(&app); - pick(&mut app, RED, false); + pick(&mut app, RED, None); assert_eq!(app.session.tools.foreground, RED); assert!(texts.iter().all(|id| !red(text_rgb(&app, *id))) && shapes.iter().all(|id| !red(fill_rgb(&app, *id).unwrap())), "{tool:?}"); assert_eq!(steps(&app), n, "{tool:?}: nothing recorded"); @@ -105,13 +105,18 @@ fn other_tools_only_change_the_foreground() { fn a_color_panel_drag_is_one_history_step_and_a_new_pick_another() { let (mut app, _, shapes) = app(Tool::Rectangle); let n = steps(&app); - pick(&mut app, [0.2, 0.0, 0.0, 1.0], false); - pick(&mut app, [0.6, 0.0, 0.0, 1.0], true); - pick(&mut app, RED, true); + pick(&mut app, [0.2, 0.0, 0.0, 1.0], None); + assert_eq!(steps(&app), n + 1, "a click or a swatch is one step"); + // One drag: every pick of one press. + pick(&mut app, [0.4, 0.0, 0.0, 1.0], Some("press-1")); + pick(&mut app, [0.6, 0.0, 0.0, 1.0], Some("press-1")); + pick(&mut app, RED, Some("press-1")); assert!(fill_rgb(&app, shapes[0]).is_some_and(red)); - assert_eq!(steps(&app), n + 1, "the drag is one step"); - pick(&mut app, [0.0, 0.0, 1.0, 1.0], false); - assert_eq!(steps(&app), n + 2, "a new pick is another"); + assert_eq!(steps(&app), n + 2, "the drag is one step, not joined to the click before it"); + pick(&mut app, [0.0, 0.0, 1.0, 1.0], Some("press-2")); + assert_eq!(steps(&app), n + 3, "the next drag is another"); + pick(&mut app, [0.0, 1.0, 0.0, 1.0], None); + assert_eq!(steps(&app), n + 4, "a new pick is another"); } #[test] @@ -142,43 +147,3 @@ fn a_swatch_and_the_color_picker_go_through_it() { assert_eq!(app.session.tools.foreground, [0.0, 0.0, 1.0, 1.0]); assert!(shapes.iter().all(|id| same(&app, *id)), "the picker recoloured the shapes"); } - -#[test] -fn the_move_tool_recolours_the_selected_type_and_shapes_together_in_one_step() { - // Layers picked with the Move tool (a click, ⇧-click or its marquee) take the colour, type and - // shapes alike. - let (mut app, texts, shapes) = app(Tool::Move); - let n = steps(&app); - pick(&mut app, RED, false); - assert!(texts.iter().all(|id| red(text_rgb(&app, *id))), "the type is red"); - assert!(shapes.iter().all(|id| fill_rgb(&app, *id).is_some_and(red)), "the shapes are red"); - assert_eq!(steps(&app), n + 1, "one history step for all four layers"); - assert!(app.session.undo()); - assert!(texts.iter().all(|id| !red(text_rgb(&app, *id))) && shapes.iter().all(|id| !red(fill_rgb(&app, *id).unwrap()))); - // Only the selected ones: with one shape selected, the rest keep their colour. - app.run("layer.select", json!({"layer": shapes[0].0})).unwrap(); - pick(&mut app, RED, false); - assert!(fill_rgb(&app, shapes[0]).is_some_and(red)); - assert!(!red(fill_rgb(&app, shapes[1]).unwrap()) && texts.iter().all(|id| !red(text_rgb(&app, *id)))); -} - -#[test] -fn a_move_tool_marquee_selection_takes_the_colour() { - // The video case: shapes box-selected with the Move tool's marquee, then a swatch. - let (mut app, _, shapes) = app(Tool::Move); - app.run("layer.select", json!({"layer": shapes[0].0})).unwrap(); - // The marquee from an empty spot across both shapes. - for (kind, x, y) in [("down", 140.0, 10.0), ("move", 200.0, 50.0), ("move", 290.0, 90.0), ("up", 290.0, 90.0)] { - let ev = match kind { - "down" => crate::canvas::ToolEvent::Down { x, y, pressure: 1.0 }, - "move" => crate::canvas::ToolEvent::Move { x, y, pressure: 1.0 }, - _ => crate::canvas::ToolEvent::Up { x, y }, - }; - crate::canvas::tool_event(&mut app, ev, egui::Modifiers::NONE); - } - let mut sel = app.session.active().unwrap().selected_layers(); - sel.sort_by_key(|l| l.0); - assert_eq!(sel, shapes, "the marquee selected both shapes"); - pick(&mut app, RED, false); - assert!(shapes.iter().all(|id| fill_rgb(&app, *id).is_some_and(red))); -} diff --git a/crates/ui-egui/src/color_picker_ui.rs b/crates/ui-egui/src/color_picker_ui.rs index 319413aaf9..d37deec36f 100644 --- a/crates/ui-egui/src/color_picker_ui.rs +++ b/crates/ui-egui/src/color_picker_ui.rs @@ -828,7 +828,7 @@ pub fn confirm(app: &mut PhotocraftApp, f: &Map) -> Result match &sh.fill { + Some(Fill::Solid(c)) => srgb_bytes([c.c[0], c.c[1], c.c[2], 1.0]), + _ => panic!("a solid fill"), + }, + _ => panic!("not a shape layer"), + }; + let steps = |app: &PhotocraftApp| app.session.active().unwrap().history.entries().len(); + let before = steps(h.state()); + // The only spin buttons are R, G and B, in that order. + for (field, text, steps_after, want) in [(1, "128", 1, [0x00, 0x80, 0x00]), (2, "64", 2, [0x00, 0x80, 0x40])] { + h.query_all_by_role(egui::accesskit::Role::SpinButton).nth(field).unwrap().click(); + h.run_steps(1); + h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A); + h.run_steps(1); + for ch in text.chars() { + h.event(egui::Event::Text(ch.to_string())); + h.run_steps(1); + } + h.key_press(egui::Key::Tab); + h.run_steps(2); + assert_eq!(fill(h.state()), want, "{text}"); + assert_eq!(steps(h.state()), before + steps_after, "{text}: one step for the typed value"); + } + // Typing into B again and clicking the field while B still has the focus: two steps, the + // click is not part of the typed value. + h.query_all_by_role(egui::accesskit::Role::SpinButton).nth(2).unwrap().click(); + h.run_steps(1); + h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A); + h.run_steps(1); + h.event(egui::Event::Text("9".into())); + h.run_steps(1); + assert_eq!(fill(h.state()), [0x00, 0x80, 0x09]); + assert_eq!(steps(h.state()), before + 3, "the typed 9"); + let min = h.ctx.input(|i| i.viewport_rect()).min; + click(&mut h, min + vec2(60.0, 10.0)); + assert_eq!(steps(h.state()), before + 4, "the click after typing"); + // A sum applies when Enter commits it, after the field let go of the focus: still the + // step of the "2" typed before it. + h.query_all_by_role(egui::accesskit::Role::SpinButton).next().unwrap().click(); + h.run_steps(1); + h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A); + h.run_steps(1); + for ch in "2*64".chars() { + h.event(egui::Event::Text(ch.to_string())); + h.run_steps(1); + } + h.key_press(egui::Key::Enter); + h.run_steps(2); + assert_eq!(fill(h.state())[0], 0x80, "2*64"); + assert_eq!(steps(h.state()), before + 5, "2*64 is one step"); + } + /// The pro Color panel's hex readout edits the foreground too. #[test] fn color_field_hex_field_takes_a_typed_hex() { @@ -4864,6 +4931,43 @@ mod color_tests { } } + /// With a shape tool and a shape layer selected, the field recolours its fill, and each + /// gesture is its own undo step: a click, every drag, and a swatch followed by a drag. A drag + /// only reaches the field after its press frame, so it must not join the step before it. + #[test] + fn color_panel_gestures_recolour_the_selected_shape_in_separate_steps() { + use photocraft_doc::{Fill, LayerContent, LayerId}; + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.session.execute("file.new", json!({"width": 64, "height": 48})).unwrap(); + let id = LayerId(app.run("shape.create", json!({"rect": [8, 8, 40, 30], "fill": "#000000"})).unwrap()["layer"].as_u64().unwrap()); + app.ui.tool = crate::state::Tool::Rectangle; + let mut h = field_harness(app); + let is_foreground = |app: &PhotocraftApp| { + let fg = app.session.tools.foreground; + match &app.session.active().unwrap().doc.layer(id).unwrap().content { + LayerContent::Shape(sh) => matches!(&sh.fill, Some(Fill::Solid(c)) if (0..3).all(|i| (c.c[i] - fg[i]).abs() < 0.01)), + _ => panic!("not a shape layer"), + } + }; + let steps = |app: &PhotocraftApp| app.session.active().unwrap().history.entries().len(); + let before = steps(h.state()); + let min = h.ctx.input(|i| i.viewport_rect()).min; + click(&mut h, min + vec2(60.0, 10.0)); + assert!(is_foreground(h.state())); + assert_eq!(steps(h.state()), before + 1, "the click"); + drag(&mut h, min + vec2(120.0, 40.0), min + vec2(250.0, 120.0)); + assert!(is_foreground(h.state())); + assert_eq!(steps(h.state()), before + 2, "the drag is one more step"); + drag(&mut h, min + vec2(200.0, 60.0), min + vec2(100.0, 150.0)); + assert_eq!(steps(h.state()), before + 3, "the next drag another"); + let name = h.state_mut().run("swatches.list", json!({})).unwrap()["groups"][0]["swatches"][0]["name"].as_str().unwrap().to_string(); + crate::swatches_ui::use_swatch(h.state_mut(), &name, false); + assert_eq!(steps(h.state()), before + 4, "the swatch"); + drag(&mut h, min + vec2(150.0, 30.0), min + vec2(220.0, 100.0)); + assert!(is_foreground(h.state())); + assert_eq!(steps(h.state()), before + 5, "a drag after a swatch is a step of its own"); + } + /// Press at `from`, move to `to` in six steps and release, as egui sees a drag. fn drag(h: &mut egui_kittest::Harness<'_, PhotocraftApp>, from: egui::Pos2, to: egui::Pos2) { h.hover_at(from); diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 333f345574..974d3fde35 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -1210,9 +1210,6 @@ pub struct UiState { /// Direct Selection tool: selected anchors and the drag in progress (#790). #[serde(default)] pub direct_selection: crate::direct_select::DirectSelection, - /// The history step a Color panel drag recolouring the selection joins (`apply_color`). - #[serde(skip)] - pub apply_color_key: Option, /// A live rectangle's corner radius widget being dragged (TOOL-214-12). #[serde(skip)] pub corner_radius: Option, @@ -1407,7 +1404,6 @@ impl Default for UiState { pen: None, stroke_editor: None, direct_selection: Default::default(), - apply_color_key: None, corner_radius: None, selected_path: None, panels: Panels::default(), diff --git a/crates/ui-egui/src/swatches_ui.rs b/crates/ui-egui/src/swatches_ui.rs index 6013ec779d..bc900c8c38 100644 --- a/crates/ui-egui/src/swatches_ui.rs +++ b/crates/ui-egui/src/swatches_ui.rs @@ -53,7 +53,7 @@ pub fn use_swatch(app: &mut PhotocraftApp, name: &str, background: bool) { if run(app, "swatches.use", json!({"swatch": name, "target": target})).is_some() && !background { // Clicking a swatch recolours the selected characters (#364), or the selected type or // shape layers with a Type, shape or Pen tool, as in Photoshop. - crate::apply_color::foreground_changed(app, false); + crate::apply_color::foreground_changed(app, None); } } diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 239af4d994..418f1e7f86 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -209,7 +209,7 @@ Paragraph; the rest open as in-app floating windows. | Drag panels to reorder and regroup | partial | #2272, #2305 | | Docked resize pushes the neighbour | partial | #2573 | | Color panel wheel and RGB/HSB/CMYK/Lab sliders | missing | UI-217-17, #2569 | -| A colour picked in the Color or Swatches panel or the Color Picker recolours the selection: selected characters while editing; every selected type layer with a Type tool; every selected shape's fill with a shape, Pen or path selection tool; both with the Move tool (layers picked by click, ⇧-click or its marquee); only the foreground with other tools; one history step (a Color panel drag too) | done: `apply_color.rs`, `apply_color_tests.rs` | | +| A colour picked in the Color or Swatches panel or the Color Picker recolours the selection: selected characters while editing; every selected type layer with a Type tool; every selected shape's fill with a shape, Pen or path selection tool; only the foreground with other tools, the Move tool too; one history step (a Color panel drag too) | done: `apply_color.rs`, `apply_color_tests.rs` | | | Window size and dock width remembered | done | UI-217-2 | | Command palette with recents | done | UI-217-7 | | Menu bar from the keyboard: Alt / F10 focus the bar, ← → ↓ ↩ drive it, Alt+letter opens a menu, underlined mnemonics run items | done | `menu_keys.rs`, #4988; macOS uses the native bar | @@ -258,4 +258,4 @@ Paragraph; the rest open as in-app floating windows. | 2026-10-14 | minor | Last selected tool restored across launches; temporary overrides excluded, explicit Eraser choices retained, and final selection flushed on normal exit | | 2026-10-13 | minor | Free Transform with a selection: the box is the selection's rectangle, and the marching ants follow it while it is transformed (#5297) | | 2026-10-14 | minor | Move › Show Transform Controls frames every selected layer and outlines the selected shapes | -| 2026-10-14 | minor | A colour picked in the Color or Swatches panel or the Color Picker recolours the selected type layers (Type tool), shape fills (shape, Pen and path selection tools), or both (Move tool) | +| 2026-10-14 | minor | A colour picked in the Color or Swatches panel or the Color Picker recolours the selected type layers (Type tool) or shape fills (shape, Pen and path selection tools) | From 49df3fb921af93615bb46f5d6c192e076a22dc0b Mon Sep 17 00:00:00 2001 From: fjamesprice Date: Sat, 17 Oct 2026 01:20:07 -0400 Subject: [PATCH 189/649] perf(camera-raw): develop the preview's per-pixel stages on the GPU (#6916) Step 1 of #6916: one wgpu fragment pass for develop's per-pixel stages (white balance and exposure, Contrast without Texture or Clarity, Whites and Blacks, Vibrance and Saturation, tone curves, Color Mixer, Color Grading, vignette, grain in full-resolution coordinates). - algo: camera_raw::per_pixel resolves those stages' constants and tables; the CPU develop builds its own from the same functions, so its output is unchanged bit for bit. - gpu: CameraRawDevelop (camera_raw.rs, camera_raw.wgsl), curves and Whites/Blacks rows in one R32Float table texture, readback for the histogram and scopes. Built on demand, not with the compositor (#6419). - ui-egui: the proxy worker develops on the GPU when the settings have no spatial stage; Rendering Mode CPU, no GPU canvas, a software adapter, a fault or a failed develop use the CPU develop. The pipeline builds on a thread at the first open. describe() reports developMs and developBackend. GPU vs CPU at 8, 16 and 32 bits: at most 2.7e-5 (RTX 5060 Ti, Vulkan and DX12), 6.7e-6 (WARP); tests hold 1/4096. 858x572 proxy, release: CPU 20.7-28.1 ms, GPU 2.7 ms. Part of #6916. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 3 + crates/algo/src/camera_raw.rs | 124 +++--- crates/algo/src/camera_raw/per_pixel.rs | 239 +++++++++++ crates/algo/src/camera_raw/whites_blacks.rs | 21 +- crates/gpu/Cargo.toml | 4 + crates/gpu/examples/bench_camera_raw.rs | 109 +++++ crates/gpu/src/camera_raw.rs | 418 ++++++++++++++++++++ crates/gpu/src/camera_raw.wgsl | 416 +++++++++++++++++++ crates/gpu/src/lib.rs | 5 + crates/gpu/tests/camera_raw.rs | 343 ++++++++++++++++ crates/ui-egui/src/camera_raw_gpu.rs | 277 +++++++++++++ crates/ui-egui/src/camera_raw_ui.rs | 58 ++- crates/ui-egui/src/gpu_canvas.rs | 41 +- crates/ui-egui/src/lib.rs | 1 + docs/hardware-parity.md | 5 +- 15 files changed, 1986 insertions(+), 78 deletions(-) create mode 100644 crates/algo/src/camera_raw/per_pixel.rs create mode 100644 crates/gpu/examples/bench_camera_raw.rs create mode 100644 crates/gpu/src/camera_raw.rs create mode 100644 crates/gpu/src/camera_raw.wgsl create mode 100644 crates/gpu/tests/camera_raw.rs create mode 100644 crates/ui-egui/src/camera_raw_gpu.rs diff --git a/Cargo.lock b/Cargo.lock index 90330fd4a5..e039ea036e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4876,14 +4876,17 @@ dependencies = [ name = "photocraft-gpu" version = "0.11.1" dependencies = [ + "bytemuck", "half", "log", + "photocraft-algo", "photocraft-cms", "photocraft-color", "photocraft-compose", "photocraft-doc", "photocraft-geom", "photocraft-raster", + "photocraft-testkit", "photocraft-vector", "pollster 1.0.1", "rayon", diff --git a/crates/algo/src/camera_raw.rs b/crates/algo/src/camera_raw.rs index 3cadd1d20c..053a0e1180 100644 --- a/crates/algo/src/camera_raw.rs +++ b/crates/algo/src/camera_raw.rs @@ -56,8 +56,11 @@ pub fn validate_curve(points: &[[f32; 2]]) -> Result<(), String> { use crate::photo_util::{hash01, linear_to_srgb, par_rows, srgb_to_linear}; mod local_tone; +mod per_pixel; mod whites_blacks; +pub use per_pixel::{CURVE_LUT, Grade, Grain, PerPixel, Vignette, VignetteStyle, WB_STEPS, WhitesBlacks, per_pixel, white_black_points}; + /// How the pixels encode light: the sRGB curve (gamma 0) or a pure power law (ProPhoto's 1.8, /// Adobe RGB's 2.2). The tone controls work on light, so the document's own curve decodes it. #[derive(Clone, Copy, Debug, PartialEq)] @@ -580,15 +583,10 @@ pub fn develop(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw, float: bo let ps = p.pixel_scale.clamp(0.01, 1.0); let long = w.max(h) as f32; // 1. White balance + exposure in linear light. - if !p.wb_neutral() { - let mut g = white_balance_gains(p.temperature, p.tint); - let norm = luma(g); - g = g.map(|v| v / norm * 2f32.powf(p.exposure)); + if let Some(g) = per_pixel::gains(p) { par_rows(px, w, 1, |_, row| { for q in row.iter_mut() { - for c in 0..3 { - q[c] = linear_to_srgb((srgb_to_linear(q[c]) * g[c]).max(0.0)); - } + *q = balance(*q, g); } }); } @@ -606,7 +604,6 @@ pub fn develop(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw, float: bo let clar = (p.clarity != 0.0).then(|| guided_fast(&lc, &lc, w, h, ((long * 0.02) as usize).max(3), 0.005)); let tex = (p.texture != 0.0).then(|| gauss(&lc, w, h, (long * 0.002).max(1.5 * ps))); let k_con = p.contrast / 100.0 * 0.6; - let tau = std::f32::consts::TAU; par_rows(px, w, 1, |y, row| { for (x, q) in row.iter_mut().enumerate() { let i = y * w + x; @@ -619,22 +616,14 @@ pub fn develop(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw, float: bo if let Some(t) = &tex { lv += p.texture / 100.0 * 0.9 * (lc[i] - t[i]).clamp(-0.1, 0.1); } - if k_con != 0.0 { - let xx = lv.clamp(0.0, 1.0); - lv += -k_con * (tau * xx).sin() / tau; - } - let lv = lv.max(0.0) + (l0 - lc[i]); - let ratio = if l0 > 1e-5 { lv / l0 } else { 1.0 }; - for c in 0..3 { - q[c] = if l0 > 1e-5 { q[c] * ratio } else { q[c] + (lv - l0) }; - } + *q = tone(*q, l0, lc[i], lv, k_con); } }); } // 3b. Whites and Blacks: global curves adapted to the image's black and white points. if p.whites != 0.0 || p.blacks != 0.0 { let enc = Encoding::of(p.encoding_gamma); - let (bp, wp) = luminance_points(px, w, h, enc); + let (bp, wp) = luminance_points(px, w, h, enc, |q| q); let (xw, xb) = whites_blacks::amounts(p.whites.clamp(-100.0, 100.0), p.blacks.clamp(-100.0, 100.0), bp, wp); whites_blacks::apply(px, w, xw, xb, enc); } @@ -646,14 +635,7 @@ pub fn develop(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw, float: bo let (master, cr, cg, cb) = (pts(&p.point_curve), pts(&p.point_curve_red), pts(&p.point_curve_green), pts(&p.point_curve_blue)); let hsl = !p.hsl_neutral(); let grade = !p.grade_neutral(); - let wheel_tint = |wh: &Wheel| -> [f32; 3] { - let c = hsv_to_rgb(wh.hue, 1.0, 1.0); - let l = luma(c); - [c[0] - l, c[1] - l, c[2] - l].map(|v| v * wh.sat / 100.0 * 0.3) - }; - let tints = [wheel_tint(&p.grade_shadows), wheel_tint(&p.grade_midtones), wheel_tint(&p.grade_highlights), wheel_tint(&p.grade_global)]; - let blend = 0.15 + p.grade_blending.clamp(0.0, 100.0) / 100.0 * 0.35; - let bal = p.grade_balance.clamp(-100.0, 100.0) / 100.0 * 0.25; + let Grade { tints, lums, blend, balance: bal } = Grade::new(p); par_rows(px, w, 1, |_, row| { for q in row.iter_mut() { let mut c = [q[0], q[1], q[2]]; @@ -706,7 +688,6 @@ pub fn develop(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw, float: bo let hi = smoothstep(0.5 + bal - blend, 1.0, l); let mid = (1.0 - sh - hi).max(0.0); let masks = [sh, mid, hi, 1.0]; - let lums = [p.grade_shadows.lum, p.grade_midtones.lum, p.grade_highlights.lum, p.grade_global.lum]; for k in 0..4 { for ch in 0..3 { c[ch] += masks[k] * tints[k][ch]; @@ -732,11 +713,7 @@ pub fn develop(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw, float: bo vignette(px, w, h, p); } if p.grain_amount > 0.0 { - let cell = 1.0 + p.grain_size / 25.0; - let rough = p.grain_roughness / 100.0; - let amt = p.grain_amount / 100.0 * 0.12; - let seed = p.seed as u64; - let pscale = 1.0 / ps; + let Grain { cell, roughness: rough, amount: amt, seed, scale: pscale } = Grain::new(p); par_rows(px, w, 1, |y, row| { for (x, q) in row.iter_mut().enumerate() { // Sample in full-resolution coordinates so previews match the result. @@ -759,24 +736,60 @@ pub fn develop(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw, float: bo } } +/// The end of stage 3 on one pixel: Contrast (strength `k_con`) on the luminance `lv` that +/// Clarity and Texture left, then the pixel rescaled to it. `l0` is its luminance, `lc` that +/// clipped to 1. +fn tone(mut q: [f32; 4], l0: f32, lc: f32, mut lv: f32, k_con: f32) -> [f32; 4] { + if k_con != 0.0 { + let tau = std::f32::consts::TAU; + let xx = lv.clamp(0.0, 1.0); + lv += -k_con * (tau * xx).sin() / tau; + } + let lv = lv.max(0.0) + (l0 - lc); + let ratio = if l0 > 1e-5 { lv / l0 } else { 1.0 }; + for c in 0..3 { + q[c] = if l0 > 1e-5 { q[c] * ratio } else { q[c] + (lv - l0) }; + } + q +} + +/// Stage 3 on one pixel when Contrast is its only control. +fn contrast(q: [f32; 4], k_con: f32) -> [f32; 4] { + let l0 = luma([q[0], q[1], q[2]]).max(0.0); + let lc = l0.min(1.0); + tone(q, l0, lc, lc, k_con) +} + +/// Stage 1 on one pixel: white balance and exposure `gains` in linear light. +fn balance(mut q: [f32; 4], g: [f32; 3]) -> [f32; 4] { + for c in 0..3 { + q[c] = linear_to_srgb((srgb_to_linear(q[c]) * g[c]).max(0.0)); + } + q +} + /// The image's black and white points as sRGB-encoded grey levels: the 3rd percentile of the /// luminance and the 99.5th of the brightest channel, on a copy at most 256 pixels across (so a -/// preview proxy and the full image agree). -fn luminance_points(px: &[[f32; 4]], w: usize, h: usize, enc: Encoding) -> (f32, f32) { +/// preview proxy and the full image agree). `map` is applied to each pixel first. +fn luminance_points(px: &[[f32; 4]], w: usize, h: usize, enc: Encoding, map: impl Fn([f32; 4]) -> [f32; 4] + Sync) -> (f32, f32) { let f = w.max(h).div_ceil(256).max(1); let (sw, sh) = (w.div_ceil(f), h.div_ceil(f)); - let mut sum = vec![[0.0f64; 4]; sw * sh]; - for y in 0..h { - for x in 0..w { - let q = px[y * w + x]; - let s = &mut sum[(y / f) * sw + x / f]; - for c in 0..3 { - s[c] += f64::from(enc.decode(q[c]).clamp(0.0, 1.0)); + // Each band of `f` rows sums into its own row of cells, in the same order as one pass would. + let bands = crate::photo_util::par_map(sh, |sy| { + let mut sum = vec![[0.0f64; 4]; sw]; + for y in sy * f..((sy + 1) * f).min(h) { + for x in 0..w { + let q = map(px[y * w + x]); + let s = &mut sum[x / f]; + for c in 0..3 { + s[c] += f64::from(enc.decode(q[c]).clamp(0.0, 1.0)); + } + s[3] += 1.0; } - s[3] += 1.0; } - } - let cells: Vec<[f32; 3]> = sum.iter().filter(|s| s[3] > 0.0).map(|s| [0, 1, 2].map(|c| (s[c] / s[3]) as f32)).collect(); + sum + }); + let cells: Vec<[f32; 3]> = bands.iter().flatten().filter(|s| s[3] > 0.0).map(|s| [0, 1, 2].map(|c| (s[c] / s[3]) as f32)).collect(); if cells.is_empty() { return (0.0, 1.0); } @@ -923,24 +936,7 @@ fn detail(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw, ps: f32) { } fn vignette(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw) { - let amt = p.vignette_amount / 100.0; - let mid = p.vignette_midpoint.clamp(0.0, 100.0) / 100.0; - let feather = p.vignette_feather.clamp(0.0, 100.0) / 100.0; - let round = p.vignette_roundness.clamp(-100.0, 100.0) / 100.0; - let hl = p.vignette_highlights.clamp(0.0, 100.0) / 100.0; - let style = p.vignette_style.as_str(); - let (cx, cy) = (w as f32 / 2.0, h as f32 / 2.0); - // Roundness: 0 follows the frame's aspect, +1 a circle, −1 a rounded rectangle. - let (ax, ay) = if round >= 0.0 { - let r = cx.min(cy) + (cx.max(cy) - cx.min(cy)) * (1.0 - round); - (if cx >= cy { r } else { cx }, if cy > cx { r } else { cy }) - } else { - (cx, cy) - }; - let pw = 2.0 + (-round).max(0.0) * 6.0; - let inner = 1.0 - mid * 0.8; - let edge0 = inner - feather * 0.5 * inner; - let edge1 = inner + feather * 0.5 * (1.4 - inner) + 0.02; + let Vignette { amount: amt, highlights: hl, style, centre: [cx, cy], axes: [ax, ay], power: pw, edges: [edge0, edge1] } = Vignette::new(w, h, p); par_rows(px, w, 1, |y, row| { for (x, q) in row.iter_mut().enumerate() { let (dx, dy) = (((x as f32 + 0.5 - cx) / ax).abs(), ((y as f32 + 0.5 - cy) / ay).abs()); @@ -951,7 +947,7 @@ fn vignette(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw) { } let l = luma([q[0], q[1], q[2]]).clamp(0.0, 1.0); match style { - "paintOverlay" => { + VignetteStyle::PaintOverlay => { let target = if amt < 0.0 { 0.0 } else { 1.0 }; let k = m * amt.abs(); for c in 0..3 { @@ -965,7 +961,7 @@ fn vignette(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw) { let protect = smoothstep(0.6, 1.0, l) * hl; k += (1.0 - k) * protect; } - if style == "colorPriority" { + if style == VignetteStyle::ColorPriority { let nl = l * k; for c in 0..3 { q[c] += nl - l; diff --git a/crates/algo/src/camera_raw/per_pixel.rs b/crates/algo/src/camera_raw/per_pixel.rs new file mode 100644 index 0000000000..88bfc9a006 --- /dev/null +++ b/crates/algo/src/camera_raw/per_pixel.rs @@ -0,0 +1,239 @@ +//! Develop's per-pixel stages resolved for one image: every constant and table they use, so +//! another implementation of them (the GPU preview, `photocraft_gpu::CameraRawDevelop`) runs the +//! same maths. [`develop`](super::develop) builds its own constants with the same functions. + +use super::{CameraRaw, Encoding, Wheel, curve_lut, hsv_to_rgb, is_linear, luma, parametric_lut, white_balance_gains, whites_blacks}; + +/// Entries of the tone curve tables (parametric and point curves). +pub const CURVE_LUT: usize = 1024; +/// Samples of a Whites or Blacks curve row: grey levels 0, 1/32, …, 1. +pub const WB_STEPS: usize = whites_blacks::STEPS; + +/// White balance and exposure: channel gains in linear light, when the stage is on. +pub(crate) fn gains(p: &CameraRaw) -> Option<[f32; 3]> { + if p.wb_neutral() { + return None; + } + let g = white_balance_gains(p.temperature, p.tint); + let norm = luma(g); + Some(g.map(|v| v / norm * 2f32.powf(p.exposure))) +} + +/// Contrast's strength, when Contrast is set. +fn contrast(p: &CameraRaw) -> Option { + (p.contrast != 0.0).then_some(p.contrast / 100.0 * 0.6) +} + +/// Whites and Blacks as two curve rows for the image's amounts. +#[derive(Clone, Debug, PartialEq)] +pub struct WhitesBlacks { + /// The Whites curve over grey levels 0, 1/32, …, 1, when Whites is set. + pub whites: Option<[f32; WB_STEPS]>, + /// The Blacks curve, applied after Whites. + pub blacks: Option<[f32; WB_STEPS]>, + /// The clipping directions (Whites up, Blacks down) curve each channel; the others scale the + /// pixel by the change of its luminance. + pub per_channel: bool, +} + +/// Color Grading's wheels resolved. +#[derive(Clone, Debug, PartialEq)] +pub struct Grade { + /// Colour offsets of the shadows, midtones, highlights and global wheels. + pub tints: [[f32; 3]; 4], + /// Luminance of the same wheels (slider units). + pub lums: [f32; 4], + pub blend: f32, + pub balance: f32, +} + +impl Grade { + pub(crate) fn new(p: &CameraRaw) -> Self { + let tint = |wh: &Wheel| -> [f32; 3] { + let c = hsv_to_rgb(wh.hue, 1.0, 1.0); + let l = luma(c); + [c[0] - l, c[1] - l, c[2] - l].map(|v| v * wh.sat / 100.0 * 0.3) + }; + Grade { + tints: [tint(&p.grade_shadows), tint(&p.grade_midtones), tint(&p.grade_highlights), tint(&p.grade_global)], + lums: [p.grade_shadows.lum, p.grade_midtones.lum, p.grade_highlights.lum, p.grade_global.lum], + blend: 0.15 + p.grade_blending.clamp(0.0, 100.0) / 100.0 * 0.35, + balance: p.grade_balance.clamp(-100.0, 100.0) / 100.0 * 0.25, + } + } +} + +/// The vignette's `vignette_style`. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum VignetteStyle { + HighlightPriority, + ColorPriority, + PaintOverlay, +} + +/// The post-crop vignette's shape on a `w × h` frame. +#[derive(Clone, Debug, PartialEq)] +pub struct Vignette { + /// −1 … 1. + pub amount: f32, + /// 0 … 1. + pub highlights: f32, + pub style: VignetteStyle, + /// Frame centre (pixels). + pub centre: [f32; 2], + /// Half axes of the shape (pixels). + pub axes: [f32; 2], + /// Exponent of the superellipse. + pub power: f32, + /// The mask's smoothstep edges in normalised radius. + pub edges: [f32; 2], +} + +impl Vignette { + pub(crate) fn new(w: usize, h: usize, p: &CameraRaw) -> Self { + let mid = p.vignette_midpoint.clamp(0.0, 100.0) / 100.0; + let feather = p.vignette_feather.clamp(0.0, 100.0) / 100.0; + let round = p.vignette_roundness.clamp(-100.0, 100.0) / 100.0; + let (cx, cy) = (w as f32 / 2.0, h as f32 / 2.0); + // Roundness: 0 follows the frame's aspect, +1 a circle, −1 a rounded rectangle. + let (ax, ay) = if round >= 0.0 { + let r = cx.min(cy) + (cx.max(cy) - cx.min(cy)) * (1.0 - round); + (if cx >= cy { r } else { cx }, if cy > cx { r } else { cy }) + } else { + (cx, cy) + }; + let inner = 1.0 - mid * 0.8; + Vignette { + amount: p.vignette_amount / 100.0, + highlights: p.vignette_highlights.clamp(0.0, 100.0) / 100.0, + style: match p.vignette_style.as_str() { + "paintOverlay" => VignetteStyle::PaintOverlay, + "colorPriority" => VignetteStyle::ColorPriority, + _ => VignetteStyle::HighlightPriority, + }, + centre: [cx, cy], + axes: [ax, ay], + power: 2.0 + (-round).max(0.0) * 6.0, + edges: [inner - feather * 0.5 * inner, inner + feather * 0.5 * (1.4 - inner) + 0.02], + } + } +} + +/// Grain: value noise sampled in full-resolution coordinates. +#[derive(Clone, Debug, PartialEq)] +pub struct Grain { + /// Noise cell size (full-resolution pixels). + pub cell: f32, + /// Weight of the finer octave. + pub roughness: f32, + pub amount: f32, + pub seed: u64, + /// Full-resolution pixels per pixel (`1 / pixel_scale`). + pub scale: f32, +} + +impl Grain { + pub(crate) fn new(p: &CameraRaw) -> Self { + Grain { + cell: 1.0 + p.grain_size / 25.0, + roughness: p.grain_roughness / 100.0, + amount: p.grain_amount / 100.0 * 0.12, + seed: u64::from(p.seed), + scale: 1.0 / p.pixel_scale.clamp(0.01, 1.0), + } + } +} + +/// Develop's per-pixel stages for one image and settings, in order. `None` stages are off. +#[derive(Clone, Debug, PartialEq)] +pub struct PerPixel { + /// 1. White balance and exposure gains in linear light (sRGB-decoded values). + pub gains: Option<[f32; 3]>, + /// 3. Contrast's strength (Contrast without Texture or Clarity is per pixel). + pub contrast: Option, + /// 3b. Whites and Blacks, in the document's encoding. + pub whites_blacks: Option, + /// The document's transfer curve: 0 for sRGB's, else a power-law gamma. + pub encoding: f32, + /// 4. Vibrance and Saturation (slider / 100). + pub presence: Option<[f32; 2]>, + /// 5. The parametric tone curve, [`CURVE_LUT`] entries over 0 … 1. + pub parametric: Option>, + /// 5. Point curves: master, red, green, blue. + pub point: [Option>; 4], + /// 6. Color Mixer hue, saturation and luminance per band. + pub hsl: Option<[[f32; 8]; 3]>, + /// 7. Color Grading. + pub grade: Option, + /// 9. Vignette. + pub vignette: Option, + /// 9. Grain. + pub grain: Option, + /// Clip RGB to 0 … 1 at the end (all but 32-bit documents). + pub clamp: bool, +} + +impl CameraRaw { + /// Whether developing needs a stage that reads neighbouring pixels: Dehaze, Shadows and + /// Highlights, Texture, Clarity, sharpening or noise reduction. + pub fn spatial(&self) -> bool { + self.dehaze != 0.0 + || [self.highlights, self.shadows, self.texture, self.clarity].iter().any(|v| *v != 0.0) + || self.sharpen_amount > 0.0 + || self.noise_luminance > 0.0 + || self.noise_color > 0.0 + } +} + +/// The image's black and white points that Whites and Blacks adapt to, for `px` (`w × h`, +/// display-encoded) developed per pixel with `p`: what [`develop`](super::develop) measures +/// after white balance and Contrast. `None` when Whites and Blacks are 0 or `p` needs a +/// spatial stage. +pub fn white_black_points(px: &[[f32; 4]], w: usize, h: usize, p: &CameraRaw) -> Option<(f32, f32)> { + if (p.whites == 0.0 && p.blacks == 0.0) || p.spatial() || px.len() != w.saturating_mul(h) { + return None; + } + let enc = Encoding::of(p.encoding_gamma); + let (g, k_con) = (gains(p), contrast(p)); + Some(super::luminance_points(px, w, h, enc, |q| { + let q = g.map_or(q, |g| super::balance(q, g)); + k_con.map_or(q, |k| super::contrast(q, k)) + })) +} + +/// Develop's stages for settings without spatial stages, on a `w × h` image; `points` are the +/// image's [`white_black_points`]. `None` when `p` needs a spatial stage, or Whites or Blacks is +/// set without `points`. +pub fn per_pixel(p: &CameraRaw, w: usize, h: usize, float: bool, points: Option<(f32, f32)>) -> Option { + if p.spatial() { + return None; + } + let identity = p.is_identity(); + let whites_blacks = if p.whites != 0.0 || p.blacks != 0.0 { + let (bp, wp) = points?; + let (xw, xb) = whites_blacks::amounts(p.whites.clamp(-100.0, 100.0), p.blacks.clamp(-100.0, 100.0), bp, wp); + (xw != 0.0 || xb != 0.0).then(|| WhitesBlacks { + whites: (xw != 0.0).then(|| whites_blacks::whites_row(xw)), + blacks: (xb != 0.0).then(|| whites_blacks::blacks_row(xb)), + per_channel: xw > 0.0 || xb < 0.0, + }) + } else { + None + }; + let parametric_on = !(p.curve_highlights == 0.0 && p.curve_lights == 0.0 && p.curve_darks == 0.0 && p.curve_shadows == 0.0); + let pts = |c: &Vec<[f32; 2]>| (!is_linear(c)).then(|| curve_lut(c, CURVE_LUT)); + Some(PerPixel { + gains: gains(p), + contrast: contrast(p), + whites_blacks, + encoding: Encoding::of(p.encoding_gamma).0, + presence: (p.vibrance != 0.0 || p.saturation != 0.0).then_some([p.vibrance / 100.0, p.saturation / 100.0]), + parametric: parametric_on.then(|| parametric_lut(p, CURVE_LUT)), + point: [pts(&p.point_curve), pts(&p.point_curve_red), pts(&p.point_curve_green), pts(&p.point_curve_blue)], + hsl: (!p.hsl_neutral()).then_some([p.hsl_hue, p.hsl_sat, p.hsl_lum]), + grade: (!p.grade_neutral()).then(|| Grade::new(p)), + vignette: (p.vignette_amount != 0.0).then(|| Vignette::new(w, h, p)), + grain: (p.grain_amount > 0.0).then(|| Grain::new(p)), + clamp: !float && !identity, + }) +} diff --git a/crates/algo/src/camera_raw/whites_blacks.rs b/crates/algo/src/camera_raw/whites_blacks.rs index 93bb9cff31..cfce5378b4 100644 --- a/crates/algo/src/camera_raw/whites_blacks.rs +++ b/crates/algo/src/camera_raw/whites_blacks.rs @@ -24,7 +24,7 @@ use super::Encoding; use crate::photo_util::par_rows; /// Grey levels the curves are sampled at: 0, 1/32, …, 1 (sRGB-encoded). -const STEPS: usize = 33; +pub(crate) const STEPS: usize = 33; /// The first row's internal amount; rows are 10 apart. const WHITES_FROM: f32 = -100.0; const BLACKS_FROM: f32 = -100.0; @@ -315,6 +315,25 @@ fn curve(rows: &[[f32; STEPS]], from: f32, x: f32, v: f32) -> f32 { at(&rows[i]) * (1.0 - t) + at(&rows[i + 1]) * t } +/// The curve at a fractional internal amount `x` as one row: `curve(rows, from, x, v)` is this +/// row interpolated at `v`, because both interpolations are linear. +fn row_at(rows: &[[f32; STEPS]], from: f32, x: f32) -> [f32; STEPS] { + let r = ((x - from) / 10.0).clamp(0.0, (rows.len() - 1) as f32); + let i = (r as usize).min(rows.len() - 2); + let t = r - i as f32; + std::array::from_fn(|j| rows[i][j] * (1.0 - t) + rows[i + 1][j] * t) +} + +/// The Whites curve at internal amount `x` as a row over grey levels 0, 1/32, …, 1. +pub(crate) fn whites_row(x: f32) -> [f32; STEPS] { + row_at(&WHITES, WHITES_FROM, x) +} + +/// The Blacks curve at internal amount `x` as a row over grey levels 0, 1/32, …, 1. +pub(crate) fn blacks_row(x: f32) -> [f32; STEPS] { + row_at(&BLACKS, BLACKS_FROM, x) +} + /// Whites at internal amount `x` (−100 … 270) of grey level `v`. pub(crate) fn whites(v: f32, x: f32) -> f32 { curve(&WHITES, WHITES_FROM, x, v) diff --git a/crates/gpu/Cargo.toml b/crates/gpu/Cargo.toml index 81b51f4c35..ecc9fdc392 100644 --- a/crates/gpu/Cargo.toml +++ b/crates/gpu/Cargo.toml @@ -14,6 +14,9 @@ photocraft-color = { workspace = true } photocraft-raster = { workspace = true } photocraft-doc = { workspace = true } photocraft-compose = { workspace = true } +# Camera Raw's per-pixel stages (`camera_raw.rs`) take their constants from the CPU develop. +photocraft-algo = { workspace = true } +bytemuck = { workspace = true } # Same major version as eframe's wgpu so the app's device can be shared. wgpu = { version = "30", default-features = false, features = ["std", "wgsl"] } log = { workspace = true } @@ -29,3 +32,4 @@ pollster = "1" photocraft-vector = { workspace = true } # A document-tagged CMYK profile in the tile conversion test. photocraft-cms = { workspace = true } +photocraft-testkit = { workspace = true } diff --git a/crates/gpu/examples/bench_camera_raw.rs b/crates/gpu/examples/bench_camera_raw.rs new file mode 100644 index 0000000000..8f31be5e8f --- /dev/null +++ b/crates/gpu/examples/bench_camera_raw.rs @@ -0,0 +1,109 @@ +//! Camera Raw's preview develop on the 858×572 proxy of a 6000×4000 image: the CPU develop +//! against the GPU pass (upload, render, readback), for per-pixel settings. +//! `cargo run --release -p photocraft-gpu --example bench_camera_raw [-- --quick]` +use std::time::Instant; + +use photocraft_algo::camera_raw::{CameraRaw, Wheel, develop, per_pixel, white_black_points}; +use photocraft_gpu::CameraRawDevelop; + +fn median(mut v: Vec) -> f64 { + v.sort_by(f64::total_cmp); + v[v.len() / 2] +} + +fn time(runs: usize, mut f: impl FnMut()) -> f64 { + f(); + median( + (0..runs) + .map(|_| { + let t = Instant::now(); + f(); + t.elapsed().as_secs_f64() * 1e3 + }) + .collect(), + ) +} + +fn main() -> Result<(), Box> { + let runs = if std::env::args().any(|a| a == "--quick") { 5 } else { 40 }; + let (w, h) = (858usize, 572usize); + let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::new_without_display_handle_from_env()); + let options = wgpu::RequestAdapterOptions { power_preference: wgpu::PowerPreference::HighPerformance, ..Default::default() }; + let adapter = pollster::block_on(instance.request_adapter(&options))?; + let (device, queue) = pollster::block_on(adapter.request_device(&Default::default()))?; + let info = adapter.get_info(); + println!("adapter: {} ({:?}), proxy {w}x{h}, median of {runs}", info.name, info.backend); + let built = Instant::now(); + let mut pass = CameraRawDevelop::new(&device)?; + println!("pipeline build: {:.1} ms", built.elapsed().as_secs_f64() * 1e3); + let src: Vec<[f32; 4]> = (0..w * h) + .map(|i| { + let (x, y) = ((i % w) as f32 / w as f32, (i / w) as f32 / h as f32); + [0.1 + 0.8 * x, 0.2 + 0.6 * y, 0.6 - 0.5 * x * y, 1.0] + }) + .collect(); + let scale = w as f32 / 6000.0; + let mut hsl = [0.0; 8]; + hsl[1] = 30.0; + hsl[5] = -40.0; + let sets = [ + ( + "Basic (WB, Exposure, Contrast, Whites, Blacks)", + CameraRaw { temperature: 20.0, exposure: 0.4, contrast: 25.0, whites: 30.0, blacks: -20.0, pixel_scale: scale, ..Default::default() }, + ), + ( + "every per-pixel stage", + CameraRaw { + temperature: 20.0, + tint: 5.0, + exposure: 0.4, + contrast: 25.0, + whites: 30.0, + blacks: -20.0, + vibrance: 30.0, + saturation: 10.0, + curve_lights: 20.0, + point_curve: vec![[0.0, 8.0], [128.0, 140.0], [255.0, 250.0]], + hsl_hue: hsl, + hsl_sat: hsl, + hsl_lum: hsl, + grade_shadows: Wheel { hue: 210.0, sat: 30.0, lum: 0.0 }, + grade_highlights: Wheel { hue: 40.0, sat: 20.0, lum: 5.0 }, + vignette_amount: -30.0, + grain_amount: 25.0, + pixel_scale: scale, + ..Default::default() + }, + ), + ]; + for (name, p) in &sets { + let cpu = time(runs, || { + let mut px = src.clone(); + develop(&mut px, w, h, p, false); + }); + let points_ms = time(runs, || { + std::hint::black_box(white_black_points(&src, w, h, p)); + }); + let points = white_black_points(&src, w, h, p); + let stages = per_pixel(p, w, h, false, points).ok_or("not per pixel")?; + let size = [w as u32, h as u32]; + let upload = time(runs, || { + pass.develop(&device, &queue, None, &src, None, size, &stages).ok(); + }); + let cached = time(runs, || { + pass.develop(&device, &queue, None, &src, Some(1), size, &stages).ok(); + }); + println!("{name}:"); + println!(" CPU develop {cpu:7.2} ms"); + println!(" GPU, source uploaded every time {upload:7.2} ms"); + println!(" GPU, source cached (slider drag) {cached:7.2} ms"); + println!(" Whites/Blacks points on the CPU {points_ms:7.2} ms (cached per WB/Exposure/Contrast in the dialog)"); + } + let shadows = CameraRaw { shadows: 50.0, pixel_scale: scale, ..Default::default() }; + let cpu = time(runs.min(10), || { + let mut px = src.clone(); + develop(&mut px, w, h, &shadows, false); + }); + println!("for reference, Shadows +50 (CPU only): {cpu:.2} ms"); + Ok(()) +} diff --git a/crates/gpu/src/camera_raw.rs b/crates/gpu/src/camera_raw.rs new file mode 100644 index 0000000000..3f1833a54b --- /dev/null +++ b/crates/gpu/src/camera_raw.rs @@ -0,0 +1,418 @@ +//! Camera Raw's per-pixel develop on the GPU, for the dialog's interactive preview (#6916). +//! +//! One fragment pass (`camera_raw.wgsl`) runs the stages that read only their own pixel: white +//! balance and exposure, Contrast without Texture or Clarity, Whites and Blacks, Vibrance and +//! Saturation, the tone curves, the Color Mixer, Color Grading, the vignette and grain. Their +//! constants and tables come from [`photocraft_algo::camera_raw::per_pixel`], which the CPU +//! develop builds its own from, so both evaluate the same maths; the curves and the Whites and +//! Blacks rows are rows of one `R32Float` texture. Settings with a spatial stage (Dehaze, Shadows +//! and Highlights, Texture, Clarity, Detail) have no [`PerPixel`] and stay on the CPU. +//! +//! The pipeline is built on demand ([`CameraRawDevelop::new`]), not with the compositor (#6419). +//! It renders into `Rgba32Float`; [`CameraRawDevelop::supported`] says whether the adapter can. + +use photocraft_algo::camera_raw::{CURVE_LUT, PerPixel, VignetteStyle, WB_STEPS}; + +use crate::Unsupported; + +/// The pass's WGSL source. +pub const CAMERA_RAW_SHADER: &str = include_str!("camera_raw.wgsl"); + +const FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba32Float; +/// `Params` in the shader: 19 rows of 16 bytes. +const PARAMS_SIZE: u64 = 19 * 16; +/// Rows of the table texture: parametric, master, red, green, blue curves; Whites, Blacks. +const LUT_ROWS: u32 = 7; +const LUT_WIDTH: u32 = CURVE_LUT as u32; +const BYTES_PER_PIXEL: u32 = 16; + +struct Image { + key: Option, + size: [u32; 2], + texture: wgpu::Texture, + view: wgpu::TextureView, +} + +impl Image { + fn new(device: &wgpu::Device, label: &str, size: [u32; 2], usage: wgpu::TextureUsages) -> Self { + let texture = device.create_texture(&wgpu::TextureDescriptor { + label: Some(label), + size: wgpu::Extent3d { width: size[0], height: size[1], depth_or_array_layers: 1 }, + mip_level_count: 1, + sample_count: 1, + dimension: wgpu::TextureDimension::D2, + format: FORMAT, + usage, + view_formats: &[], + }); + let view = texture.create_view(&Default::default()); + Image { key: None, size, texture, view } + } +} + +/// The Camera Raw preview pass and its textures (reused while the size stays). +pub struct CameraRawDevelop { + pipeline: wgpu::RenderPipeline, + layout: wgpu::BindGroupLayout, + params: wgpu::Buffer, + luts: wgpu::Texture, + luts_view: wgpu::TextureView, + source: Option, + target: Option, + #[cfg(not(target_arch = "wasm32"))] + readback: Option, +} + +impl CameraRawDevelop { + /// Whether `adapter` can render the pass's `Rgba32Float` output. + pub fn supported(adapter: &wgpu::Adapter) -> bool { + adapter.get_texture_format_features(FORMAT).allowed_usages.contains(wgpu::TextureUsages::RENDER_ATTACHMENT) + } + + /// Builds the pipeline. A shader or pipeline the driver can't build is an `Err`, so the + /// caller keeps the CPU develop (where errors only arrive asynchronously, on WebGPU, creation + /// is assumed to have worked). + pub fn new(device: &wgpu::Device) -> Result { + match crate::first_error(device, || Self::build(device)) { + (dev, None) => Ok(dev), + (_, Some(e)) => Err(Unsupported(format!("couldn't build the Camera Raw pipeline: {e}"))), + } + } + + fn build(device: &wgpu::Device) -> Self { + let module = device + .create_shader_module(wgpu::ShaderModuleDescriptor { label: Some("pc_camera_raw"), source: wgpu::ShaderSource::Wgsl(CAMERA_RAW_SHADER.into()) }); + let layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { + label: Some("pc_camera_raw"), + entries: &[ + wgpu::BindGroupLayoutEntry { + binding: 0, + visibility: wgpu::ShaderStages::FRAGMENT, + ty: wgpu::BindingType::Buffer { + ty: wgpu::BufferBindingType::Uniform, + has_dynamic_offset: false, + min_binding_size: wgpu::BufferSize::new(PARAMS_SIZE), + }, + count: None, + }, + crate::tex_entry(1), + crate::tex_entry(2), + ], + }); + let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { + label: Some("pc_camera_raw"), + bind_group_layouts: &[Some(&layout)], + immediate_size: 0, + }); + let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { + label: Some("pc_camera_raw"), + layout: Some(&pipeline_layout), + vertex: wgpu::VertexState { module: &module, entry_point: Some("vs"), buffers: &[], compilation_options: Default::default() }, + primitive: wgpu::PrimitiveState::default(), + depth_stencil: None, + multisample: wgpu::MultisampleState::default(), + fragment: Some(wgpu::FragmentState { + module: &module, + entry_point: Some("fs"), + targets: &[Some(wgpu::ColorTargetState { format: FORMAT, blend: None, write_mask: wgpu::ColorWrites::ALL })], + compilation_options: Default::default(), + }), + multiview_mask: None, + cache: None, + }); + let params = device.create_buffer(&wgpu::BufferDescriptor { + label: Some("pc_camera_raw_params"), + size: PARAMS_SIZE, + usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST, + mapped_at_creation: false, + }); + let luts = device.create_texture(&wgpu::TextureDescriptor { + label: Some("pc_camera_raw_luts"), + size: wgpu::Extent3d { width: LUT_WIDTH, height: LUT_ROWS, depth_or_array_layers: 1 }, + mip_level_count: 1, + sample_count: 1, + dimension: wgpu::TextureDimension::D2, + format: wgpu::TextureFormat::R32Float, + usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST, + view_formats: &[], + }); + let luts_view = luts.create_view(&Default::default()); + CameraRawDevelop { + pipeline, + layout, + params, + luts, + luts_view, + source: None, + target: None, + #[cfg(not(target_arch = "wasm32"))] + readback: None, + } + } + + /// Records the develop of `source` (`w × h` straight RGBA, display-encoded) with `stages` + /// into `encoder` and returns the `Rgba32Float` texture it renders. The source is uploaded + /// unless the last one had the same `key` and size (`None` always uploads). + #[allow(clippy::too_many_arguments)] + pub fn encode( + &mut self, + device: &wgpu::Device, + queue: &wgpu::Queue, + encoder: &mut wgpu::CommandEncoder, + source: &[[f32; 4]], + key: Option, + size: [u32; 2], + stages: &PerPixel, + ) -> Result<&wgpu::Texture, Unsupported> { + check_size(device, source, size)?; + let [w, h] = size; + let usage = wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST; + let src = match self.source.take() { + Some(s) if s.size == size => s, + _ => Image::new(device, "pc_camera_raw_source", size, usage), + }; + let src = self.source.insert(src); + if key.is_none() || src.key != key { + queue.write_texture( + wgpu::TexelCopyTextureInfo { texture: &src.texture, mip_level: 0, origin: wgpu::Origin3d::ZERO, aspect: wgpu::TextureAspect::All }, + bytemuck::cast_slice(source), + wgpu::TexelCopyBufferLayout { offset: 0, bytes_per_row: Some(w * BYTES_PER_PIXEL), rows_per_image: Some(h) }, + wgpu::Extent3d { width: w, height: h, depth_or_array_layers: 1 }, + ); + src.key = key; + } + queue.write_buffer(&self.params, 0, ¶ms(size, stages)); + queue.write_texture( + wgpu::TexelCopyTextureInfo { texture: &self.luts, mip_level: 0, origin: wgpu::Origin3d::ZERO, aspect: wgpu::TextureAspect::All }, + bytemuck::cast_slice(&tables(stages)), + wgpu::TexelCopyBufferLayout { offset: 0, bytes_per_row: Some(LUT_WIDTH * 4), rows_per_image: Some(LUT_ROWS) }, + wgpu::Extent3d { width: LUT_WIDTH, height: LUT_ROWS, depth_or_array_layers: 1 }, + ); + let target = match self.target.take() { + Some(t) if t.size == size => t, + _ => Image::new(device, "pc_camera_raw_target", size, wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC), + }; + let target = self.target.insert(target); + let group = device.create_bind_group(&wgpu::BindGroupDescriptor { + label: Some("pc_camera_raw"), + layout: &self.layout, + entries: &[ + wgpu::BindGroupEntry { binding: 0, resource: self.params.as_entire_binding() }, + wgpu::BindGroupEntry { binding: 1, resource: wgpu::BindingResource::TextureView(&src.view) }, + wgpu::BindGroupEntry { binding: 2, resource: wgpu::BindingResource::TextureView(&self.luts_view) }, + ], + }); + { + let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: Some("pc_camera_raw"), + color_attachments: &[Some(wgpu::RenderPassColorAttachment { + view: &target.view, + depth_slice: None, + resolve_target: None, + ops: wgpu::Operations { load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT), store: wgpu::StoreOp::Store }, + })], + depth_stencil_attachment: None, + timestamp_writes: None, + occlusion_query_set: None, + multiview_mask: None, + }); + pass.set_pipeline(&self.pipeline); + pass.set_bind_group(0, &group, &[]); + pass.draw(0..3, 0..1); + } + Ok(&target.texture) + } + + /// Develops `source` and reads the result back (blocking; native only, the web has no + /// blocking wait). GPU errors and a lost device are `Err`; `health`, when the device is + /// watched, records a loss. + #[cfg(not(target_arch = "wasm32"))] + #[allow(clippy::too_many_arguments)] + pub fn develop( + &mut self, + device: &wgpu::Device, + queue: &wgpu::Queue, + health: Option<&crate::DeviceHealth>, + source: &[[f32; 4]], + key: Option, + size: [u32; 2], + stages: &PerPixel, + ) -> Result, Unsupported> { + if let Some(f) = health.and_then(crate::DeviceHealth::fault) { + return Err(Unsupported(f.to_string())); + } + let (result, error) = crate::first_error(device, || self.develop_inner(device, queue, health, source, key, size, stages)); + match error { + Some(e) => { + // A half-done upload must not be taken for the cached source next time. + self.source = None; + Err(Unsupported(format!("GPU Camera Raw develop failed: {e}"))) + } + None => result, + } + } + + #[cfg(not(target_arch = "wasm32"))] + #[allow(clippy::too_many_arguments)] + fn develop_inner( + &mut self, + device: &wgpu::Device, + queue: &wgpu::Queue, + health: Option<&crate::DeviceHealth>, + source: &[[f32; 4]], + key: Option, + size: [u32; 2], + stages: &PerPixel, + ) -> Result, Unsupported> { + check_size(device, source, size)?; + let [w, h] = size; + let row = (w * BYTES_PER_PIXEL).div_ceil(wgpu::COPY_BYTES_PER_ROW_ALIGNMENT) * wgpu::COPY_BYTES_PER_ROW_ALIGNMENT; + let bytes = u64::from(row) * u64::from(h); + let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: Some("pc_camera_raw") }); + self.encode(device, queue, &mut encoder, source, key, size, stages)?; + let Some(target) = self.target.as_ref().map(|t| &t.texture) else { return Err(Unsupported("no Camera Raw target".into())) }; + let buffer = match self.readback.take() { + Some(b) if b.size() == bytes => b, + _ => device.create_buffer(&wgpu::BufferDescriptor { + label: Some("pc_camera_raw_readback"), + size: bytes, + usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ, + mapped_at_creation: false, + }), + }; + encoder.copy_texture_to_buffer( + wgpu::TexelCopyTextureInfo { texture: target, mip_level: 0, origin: wgpu::Origin3d::ZERO, aspect: wgpu::TextureAspect::All }, + wgpu::TexelCopyBufferInfo { buffer: &buffer, layout: wgpu::TexelCopyBufferLayout { offset: 0, bytes_per_row: Some(row), rows_per_image: Some(h) } }, + wgpu::Extent3d { width: w, height: h, depth_or_array_layers: 1 }, + ); + let index = queue.submit([encoder.finish()]); + buffer.slice(..).map_async(wgpu::MapMode::Read, |_| {}); + match health { + Some(hl) => { + if !hl.wait(device, Some(index)) { + return Err(Unsupported(hl.fault().map_or_else(|| "GPU device lost".into(), |f| f.to_string()))); + } + } + None => { + device.poll(wgpu::PollType::Wait { submission_index: Some(index), timeout: None }).map_err(|e| Unsupported(format!("GPU wait failed: {e}")))?; + } + } + let mut out = Vec::with_capacity(source.len()); + { + let data = buffer.slice(..).get_mapped_range().map_err(|e| Unsupported(format!("GPU readback failed: {e:?}")))?; + let width = w as usize * BYTES_PER_PIXEL as usize; + for y in 0..h as usize { + let start = y * row as usize; + let line = data.get(start..start + width).ok_or_else(|| Unsupported("short GPU readback".into()))?; + out.extend(bytemuck::pod_collect_to_vec::(line)); + } + } + buffer.unmap(); + self.readback = Some(buffer); + Ok(out) + } +} + +fn check_size(device: &wgpu::Device, source: &[[f32; 4]], [w, h]: [u32; 2]) -> Result<(), Unsupported> { + let max = device.limits().max_texture_dimension_2d; + if w == 0 || h == 0 || w > max || h > max { + return Err(Unsupported(format!("a {w}×{h} Camera Raw preview doesn't fit the GPU's {max} px textures"))); + } + if source.len() as u64 != u64::from(w) * u64::from(h) { + return Err(Unsupported(format!("{} Camera Raw preview pixels for {w}×{h}", source.len()))); + } + Ok(()) +} + +/// Flags of `Params.flags`, in the shader's bit order. +fn flags(s: &PerPixel) -> u32 { + let wb = s.whites_blacks.as_ref(); + let on = [ + s.gains.is_some(), + s.contrast.is_some(), + wb.is_some_and(|w| w.whites.is_some()), + wb.is_some_and(|w| w.blacks.is_some()), + wb.is_some_and(|w| w.per_channel), + s.presence.is_some(), + s.parametric.is_some(), + s.point[0].is_some(), + s.point[1].is_some(), + s.point[2].is_some(), + s.point[3].is_some(), + s.hsl.is_some(), + s.grade.is_some(), + s.vignette.is_some(), + s.grain.is_some(), + s.clamp, + ]; + on.iter().enumerate().fold(0, |f, (bit, on)| if *on { f | 1 << bit } else { f }) +} + +/// The shader's `Params` for a `size` image. +fn params(size: [u32; 2], s: &PerPixel) -> Vec { + let g = s.gains.unwrap_or([1.0; 3]); + let presence = s.presence.unwrap_or_default(); + let hsl = s.hsl.unwrap_or_default(); + let grade = s.grade.as_ref(); + let vig = s.vignette.as_ref(); + let grain = s.grain.as_ref(); + let mut out: Vec = Vec::with_capacity(PARAMS_SIZE as usize); + out.extend([size[0], size[1], flags(s)].iter().flat_map(|v| v.to_le_bytes()).chain(s.encoding.to_le_bytes())); + let mut f = |v: [f32; 4]| out.extend(v.iter().flat_map(|x| x.to_le_bytes())); + f([g[0], g[1], g[2], s.contrast.unwrap_or(0.0)]); + f([presence[0], presence[1], 0.0, 0.0]); + for row in hsl { + f([row[0], row[1], row[2], row[3]]); + f([row[4], row[5], row[6], row[7]]); + } + for k in 0..4 { + let (t, l) = grade.map_or(([0.0; 3], 0.0), |gr| (gr.tints[k], gr.lums[k])); + f([t[0], t[1], t[2], l]); + } + f(grade.map_or([0.0; 4], |gr| [gr.blend, gr.balance, 0.0, 0.0])); + let style = |v: VignetteStyle| match v { + VignetteStyle::HighlightPriority => 0.0, + VignetteStyle::ColorPriority => 1.0, + VignetteStyle::PaintOverlay => 2.0, + }; + f(vig.map_or([0.0, 0.0, 0.0, 2.0], |v| [v.amount, v.highlights, style(v.style), v.power])); + f(vig.map_or([0.0, 0.0, 1.0, 1.0], |v| [v.centre[0], v.centre[1], v.axes[0], v.axes[1]])); + f(vig.map_or([0.0; 4], |v| [v.edges[0], v.edges[1], 0.0, 0.0])); + f(grain.map_or([1.0, 0.0, 0.0, 1.0], |gr| [gr.cell, gr.roughness, gr.amount, gr.scale])); + let seed = grain.map_or(0, |gr| gr.seed); + let fine = seed.wrapping_add(7); + out.extend([seed as u32, (seed >> 32) as u32, fine as u32, (fine >> 32) as u32].iter().flat_map(|v| v.to_le_bytes())); + out +} + +/// The table texture's rows (see [`LUT_ROWS`]); rows of stages that are off stay zero. +fn tables(s: &PerPixel) -> Vec { + let mut t = vec![0.0f32; (LUT_WIDTH * LUT_ROWS) as usize]; + let mut put = |row: usize, v: &[f32]| { + let start = row * LUT_WIDTH as usize; + let n = v.len().min(LUT_WIDTH as usize); + if let (Some(dst), Some(src)) = (t.get_mut(start..start + n), v.get(..n)) { + dst.copy_from_slice(src); + } + }; + if let Some(l) = &s.parametric { + put(0, l); + } + for (k, l) in s.point.iter().enumerate() { + if let Some(l) = l { + put(1 + k, l); + } + } + if let Some(wb) = &s.whites_blacks { + if let Some(r) = &wb.whites { + put(5, r); + } + if let Some(r) = &wb.blacks { + put(6, r); + } + } + t +} + +// The Whites and Blacks rows fit a table row. +const _: () = assert!(WB_STEPS <= CURVE_LUT); diff --git a/crates/gpu/src/camera_raw.wgsl b/crates/gpu/src/camera_raw.wgsl new file mode 100644 index 0000000000..abad7cbbc1 --- /dev/null +++ b/crates/gpu/src/camera_raw.wgsl @@ -0,0 +1,416 @@ +// Camera Raw's per-pixel develop stages (`photocraft_algo::camera_raw::develop`, constants from +// `camera_raw::per_pixel`), one fragment per pixel. Each function mirrors the CPU code it is +// named after, in the same order of operations; `camera_raw.rs` holds the bindings. + +struct Params { + size: vec2, + flags: u32, + // The document's transfer curve: 0 for sRGB's, else a power-law gamma. + encoding: f32, + // White balance gains (rgb), Contrast's strength (w). + gains: vec4, + // Vibrance, Saturation. + presence: vec4, + // Color Mixer bands 0-3 and 4-7: hue, saturation, luminance. + hsl: array, 6>, + // Color Grading wheels: tint (rgb), luminance (w). + tints: array, 4>, + // Blending, Balance. + grade: vec4, + // [amount, highlights, style, power], [centre, axes], [edges]. + vignette: array, 3>, + // Cell, roughness, amount, full-resolution pixels per pixel. + grain: vec4, + // The two octaves' seeds as (low, high) words. + seeds: vec4, +} + +@group(0) @binding(0) var P: Params; +@group(0) @binding(1) var src: texture_2d; +// R32Float rows of `LUT_WIDTH`: parametric, master, red, green, blue curves; Whites, Blacks rows. +@group(0) @binding(2) var luts: texture_2d; + +const GAINS: u32 = 0u; +const CONTRAST: u32 = 1u; +const WHITES: u32 = 2u; +const BLACKS: u32 = 3u; +const PER_CHANNEL: u32 = 4u; +const PRESENCE: u32 = 5u; +const PARAMETRIC: u32 = 6u; +const MASTER: u32 = 7u; +const RED: u32 = 8u; +const HSL: u32 = 11u; +const GRADE: u32 = 12u; +const VIGNETTE: u32 = 13u; +const GRAIN: u32 = 14u; +const CLAMP: u32 = 15u; + +const CURVE_LUT: i32 = 1024; +const WB_STEPS: i32 = 33; +const TAU: f32 = 6.2831855; + +struct VOut { + @builtin(position) pos: vec4, +} + +@vertex +fn vs(@builtin(vertex_index) vi: u32) -> VOut { + let uv = vec2(f32((vi << 1u) & 2u), f32(vi & 2u)); + return VOut(vec4(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0, 0.0, 1.0)); +} + +fn on(flag: u32) -> bool { + return (P.flags & (1u << flag)) != 0u; +} + +fn luma(c: vec3) -> f32 { + return 0.2126 * c.x + 0.7152 * c.y + 0.0722 * c.z; +} + +fn smoothstep_(e0: f32, e1: f32, x: f32) -> f32 { + let t = clamp((x - e0) / (e1 - e0), 0.0, 1.0); + return t * t * (3.0 - 2.0 * t); +} + +fn rem_euclid(x: f32, m: f32) -> f32 { + let r = x % m; + return select(r, r + m, r < 0.0); +} + +fn srgb_to_linear(v: f32) -> f32 { + if v <= 0.04045 { + return v / 12.92; + } + return pow((v + 0.055) / 1.055, 2.4); +} + +fn linear_to_srgb(v: f32) -> f32 { + if v <= 0.0031308 { + return v * 12.92; + } + return 1.055 * pow(v, 1.0 / 2.4) - 0.055; +} + +fn decode(v: f32) -> f32 { + if P.encoding > 0.0 { + return pow(max(v, 0.0), P.encoding); + } + return srgb_to_linear(v); +} + +fn encode(v: f32) -> f32 { + if P.encoding > 0.0 { + return pow(max(v, 0.0), 1.0 / P.encoding); + } + return linear_to_srgb(v); +} + +fn lut_at(row: i32, i: i32) -> f32 { + return textureLoad(luts, vec2(i, row), 0).r; +} + +// `lut_eval`: linear inside 0..1, extended linearly outside (float documents). +fn lut_eval(row: i32, v: f32) -> f32 { + if v < 0.0 { + return v + lut_at(row, 0); + } + if v > 1.0 { + return lut_at(row, CURVE_LUT - 1) + (v - 1.0); + } + let x = v * f32(CURVE_LUT - 1); + let i = min(i32(x), CURVE_LUT - 2); + let t = x - f32(i); + let a = lut_at(row, i); + return a + (lut_at(row, i + 1) - a) * t; +} + +// `whites_blacks::curve` on one row. +fn wb_curve(row: i32, v: f32) -> f32 { + if v >= 1.0 { + return 1.0; + } + let p = max(v, 0.0) * f32(WB_STEPS - 1); + let j = min(i32(p), WB_STEPS - 2); + let s = p - f32(j); + let a = lut_at(row, j); + return a + (lut_at(row, j + 1) - a) * s; +} + +fn grey(v: f32) -> f32 { + var g = v; + if on(WHITES) { + g = wb_curve(5, g); + } + if on(BLACKS) { + g = wb_curve(6, g); + } + return g; +} + +// `whites_blacks::apply`. +fn whites_blacks(q: vec3) -> vec3 { + let lin = vec3(decode(q.x), decode(q.y), decode(q.z)); + var out = q; + if on(PER_CHANNEL) { + for (var c = 0; c < 3; c++) { + let over = max(lin[c] - 1.0, 0.0); + out[c] = encode(srgb_to_linear(grey(linear_to_srgb(min(lin[c], 1.0)))) + over); + } + return out; + } + let y = max(luma(lin), 0.0); + if y <= 1e-7 { + return q; + } + let y2 = srgb_to_linear(grey(linear_to_srgb(min(y, 1.0)))) + max(y - 1.0, 0.0); + let k = y2 / y; + for (var c = 0; c < 3; c++) { + out[c] = encode(lin[c] * k); + } + return out; +} + +fn rgb_to_hsv(c: vec3) -> vec3 { + let mx = max(max(c.x, c.y), c.z); + let mn = min(min(c.x, c.y), c.z); + let d = mx - mn; + var h = 0.0; + if d <= 1e-9 { + h = 0.0; + } else if mx == c.x { + h = 60.0 * rem_euclid((c.y - c.z) / d, 6.0); + } else if mx == c.y { + h = 60.0 * ((c.z - c.x) / d + 2.0); + } else { + h = 60.0 * ((c.x - c.y) / d + 4.0); + } + return vec3(h, select(0.0, d / mx, mx > 1e-9), mx); +} + +fn hsv_to_rgb(hue: f32, s: f32, v: f32) -> vec3 { + let h = rem_euclid(hue, 360.0) / 60.0; + let c = v * s; + let x = c * (1.0 - abs((h % 2.0) - 1.0)); + var rgb: vec3; + switch u32(h) { + case 0u: { rgb = vec3(c, x, 0.0); } + case 1u: { rgb = vec3(x, c, 0.0); } + case 2u: { rgb = vec3(0.0, c, x); } + case 3u: { rgb = vec3(0.0, x, c); } + case 4u: { rgb = vec3(x, 0.0, c); } + default: { rgb = vec3(c, 0.0, x); } + } + let m = v - c; + return rgb + vec3(m); +} + +const HSL_BANDS = array(0.0, 30.0, 60.0, 120.0, 180.0, 240.0, 270.0, 300.0); + +fn band(k: i32, row: i32) -> f32 { + return P.hsl[row * 2 + k / 4][k % 4]; +} + +// `band_weights` folded into the three sums. +fn hsl_shift(h: f32) -> vec3 { + var bands = HSL_BANDS; + var d = vec3(0.0); + for (var k = 0; k < 8; k++) { + let c = bands[k]; + let prev = bands[(k + 7) % 8]; + let next = bands[(k + 1) % 8]; + let diff = ((h - c + 540.0) % 360.0) - 180.0; + let span = select(rem_euclid(c - prev, 360.0), rem_euclid(next - c, 360.0), diff >= 0.0); + let w = max(1.0 - abs(diff) / max(span, 1e-3), 0.0); + d += w * vec3(band(k, 0), band(k, 1), band(k, 2)); + } + return d; +} + +// `photo_util::hash01`: 64-bit words as (low, high). +fn mul_wide(a: u32, b: u32) -> vec2 { + let a0 = a & 0xffffu; + let a1 = a >> 16u; + let b0 = b & 0xffffu; + let b1 = b >> 16u; + let p00 = a0 * b0; + let p01 = a0 * b1; + let p10 = a1 * b0; + let p11 = a1 * b1; + let mid = (p00 >> 16u) + (p01 & 0xffffu) + (p10 & 0xffffu); + return vec2((p00 & 0xffffu) | (mid << 16u), p11 + (p01 >> 16u) + (p10 >> 16u) + (mid >> 16u)); +} + +fn mul64(a: vec2, b: vec2) -> vec2 { + let w = mul_wide(a.x, b.x); + return vec2(w.x, w.y + a.x * b.y + a.y * b.x); +} + +fn shr64(z: vec2, n: u32) -> vec2 { + return vec2((z.x >> n) | (z.y << (32u - n)), z.y >> n); +} + +fn i64_(v: i32) -> vec2 { + return vec2(bitcast(v), select(0u, 0xffffffffu, v < 0)); +} + +fn hash01(x: i32, y: i32, seed: vec2) -> f32 { + var z = mul64(i64_(x), vec2(0x7f4a7c15u, 0x9e3779b9u)) ^ mul64(i64_(y), vec2(0x27d4eb4fu, 0xc2b2ae3du)) ^ mul64(seed, vec2(0x9e3779f9u, 0x165667b1u)); + z = mul64(z ^ shr64(z, 30u), vec2(0x1ce4e5b9u, 0xbf58476du)); + z = mul64(z ^ shr64(z, 27u), vec2(0x133111ebu, 0x94d049bbu)); + z = z ^ shr64(z, 31u); + return f32(z.y >> 8u) / 16777216.0; +} + +fn value_noise(x: f32, y: f32, seed: vec2) -> f32 { + let xi = floor(x); + let yi = floor(y); + let tx = x - xi; + let ty = y - yi; + let sx = tx * tx * (3.0 - 2.0 * tx); + let sy = ty * ty * (3.0 - 2.0 * ty); + let ix = i32(xi); + let iy = i32(yi); + let h00 = hash01(ix, iy, seed); + let h10 = hash01(ix + 1, iy, seed); + let h01 = hash01(ix, iy + 1, seed); + let h11 = hash01(ix + 1, iy + 1, seed); + let top = h00 + (h10 - h00) * sx; + let bot = h01 + (h11 - h01) * sx; + return top + (bot - top) * sy; +} + +@fragment +fn fs(@builtin(position) pos: vec4) -> @location(0) vec4 { + let p = vec2(floor(pos.xy)); + let q = textureLoad(src, p, 0); + var c = q.rgb; + // 1. White balance and exposure. + if on(GAINS) { + for (var i = 0; i < 3; i++) { + c[i] = linear_to_srgb(max(srgb_to_linear(c[i]) * P.gains[i], 0.0)); + } + } + // 3. Contrast (without Texture and Clarity). + if on(CONTRAST) { + let l0 = max(luma(c), 0.0); + let lc = min(l0, 1.0); + var lv = lc; + let xx = clamp(lv, 0.0, 1.0); + lv += -P.gains.w * sin(TAU * xx) / TAU; + lv = max(lv, 0.0) + (l0 - lc); + if l0 > 1e-5 { + c = c * (lv / l0); + } else { + c = c + vec3(lv - l0); + } + } + // 3b. Whites and Blacks. + if on(WHITES) || on(BLACKS) { + c = whites_blacks(c); + } + // 4. Vibrance and Saturation. + if on(PRESENCE) { + let l = luma(c); + let mx = max(max(c.x, c.y), c.z); + let mn = min(min(c.x, c.y), c.z); + let sat = select(0.0, (mx - mn) / mx, mx > 1e-6); + let hue = rgb_to_hsv(c).x; + let skin = clamp(1.0 - (abs(hue - 25.0) / 25.0), 0.0, 1.0) * 0.5; + let k = 1.0 + P.presence.y + P.presence.x * (1.0 - sat) * (1.0 - skin); + c = vec3(l) + (c - vec3(l)) * max(k, 0.0); + } + // 5. Tone curves. + if on(PARAMETRIC) { + c = vec3(lut_eval(0, c.x), lut_eval(0, c.y), lut_eval(0, c.z)); + } + if on(MASTER) { + c = vec3(lut_eval(1, c.x), lut_eval(1, c.y), lut_eval(1, c.z)); + } + for (var i = 0; i < 3; i++) { + if on(RED + u32(i)) { + c[i] = lut_eval(2 + i, c[i]); + } + } + // 6. Color Mixer. + if on(HSL) { + let hsv = rgb_to_hsv(max(c, vec3(0.0))); + let s = hsv.y; + if s > 1e-4 { + let d = hsl_shift(hsv.x); + let nh = hsv.x + d.x / 100.0 * 30.0; + let ns = clamp(s * (1.0 + d.y / 100.0), 0.0, 1.0); + var out = hsv_to_rgb(nh, ns, hsv.z); + let l0 = luma(c); + let l1 = luma(out); + if l1 > 1e-6 { + out = out * l0 / l1; + } + let k = exp2(d.z / 100.0 * 1.0 * s); + c = out * k; + } + } + // 7. Color Grading. + if on(GRADE) { + let l = clamp(luma(c), 0.0, 1.0); + let blend = P.grade.x; + let bal = P.grade.y; + let sh = 1.0 - smoothstep_(0.0, 0.5 + bal + blend, l); + let hi = smoothstep_(0.5 + bal - blend, 1.0, l); + let mid = max(1.0 - sh - hi, 0.0); + let masks = vec4(sh, mid, hi, 1.0); + for (var k = 0; k < 4; k++) { + c += masks[k] * P.tints[k].xyz; + if P.tints[k].w != 0.0 { + c = c * exp2(masks[k] * P.tints[k].w / 100.0 * 0.6); + } + } + } + // 9. Vignette. + if on(VIGNETTE) { + let amt = P.vignette[0].x; + let hl = P.vignette[0].y; + let style = u32(P.vignette[0].z); + let pw = P.vignette[0].w; + let centre = P.vignette[1].xy; + let axes = P.vignette[1].zw; + let dx = abs((f32(p.x) + 0.5 - centre.x) / axes.x); + let dy = abs((f32(p.y) + 0.5 - centre.y) / axes.y); + let r = pow(pow(dx, pw) + pow(dy, pw), 1.0 / pw); + let m = smoothstep_(P.vignette[2].x, P.vignette[2].y, r); + if m > 0.0 { + let l = clamp(luma(c), 0.0, 1.0); + if style == 2u { + let goal = select(1.0, 0.0, amt < 0.0); + let k = m * abs(amt); + c += (vec3(goal) - c) * k; + } else { + var k = exp2(amt * 2.0 * m); + if amt < 0.0 && hl > 0.0 { + let protect = smoothstep_(0.6, 1.0, l) * hl; + k += (1.0 - k) * protect; + } + if style == 1u { + let nl = l * k; + c += vec3(nl - l); + } else { + c = c * k; + } + } + } + } + // 9. Grain, in full-resolution coordinates. + if on(GRAIN) { + let cell = P.grain.x; + let rough = P.grain.y; + let fx = f32(p.x) * P.grain.w / cell; + let fy = f32(p.y) * P.grain.w / cell; + let n = value_noise(fx, fy, P.seeds.xy) * (1.0 - rough) + (value_noise(fx * 2.3, fy * 2.3, P.seeds.zw) - 0.0) * rough; + let l = clamp(luma(c), 0.0, 1.0); + let g = (n - 0.5) * 2.0 * P.grain.z * (0.4 + 2.4 * l * (1.0 - l)); + c += vec3(g); + } + if on(CLAMP) { + c = clamp(c, vec3(0.0), vec3(1.0)); + } + return vec4(c, q.a); +} diff --git a/crates/gpu/src/lib.rs b/crates/gpu/src/lib.rs index fbc43f9d8d..230ba2a065 100644 --- a/crates/gpu/src/lib.rs +++ b/crates/gpu/src/lib.rs @@ -34,10 +34,14 @@ //! (Multichannel documents, patterns larger than the texture limit, uncached gradients with //! coincident colour or opacity stops) returns [`Unsupported`]; //! callers fall back to the CPU compositor. +//! +//! [`CameraRawDevelop`] (`camera_raw.rs`) is a separate pass, not part of the compositor: Camera +//! Raw's per-pixel develop stages for the dialog's preview, built the first time the dialog opens. #![forbid(unsafe_code)] #![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] pub mod bounds; +mod camera_raw; mod fx; pub mod health; pub mod plan; @@ -54,6 +58,7 @@ use photocraft_doc::{DocId, Document, LayerContent, LayerId, Pattern}; use photocraft_geom::{Rect, TILE_SIZE, TileCoord}; use photocraft_raster::{Surface, Tile}; +pub use camera_raw::{CAMERA_RAW_SHADER, CameraRawDevelop}; pub use health::{DeviceHealth, Fault}; pub use plan::{Kernel, Plan, Role, Unsupported, plan}; pub use timing::{GpuTimer, GpuTiming}; diff --git a/crates/gpu/tests/camera_raw.rs b/crates/gpu/tests/camera_raw.rs new file mode 100644 index 0000000000..f6bce1c55a --- /dev/null +++ b/crates/gpu/tests/camera_raw.rs @@ -0,0 +1,343 @@ +//! Camera Raw's GPU preview pass against the CPU develop (the oracle), stage by stage, at 8, 16 +//! and 32 bits. Skips when there is no adapter or it can't render `Rgba32Float`. + +use photocraft_algo::camera_raw::{CameraRaw, Wheel, develop, per_pixel, white_black_points}; +use photocraft_gpu::{CameraRawDevelop, DeviceHealth, Fault}; + +/// Largest difference from the CPU develop, per channel. The pass evaluates the same +/// expressions in f32, so what remains is the GPU's own `pow`, `exp2` and `sin` (a few ulps) and +/// how they move a value across a table entry; measured at most about 1e-5 on NVIDIA (Vulkan, +/// DX12) and WARP. 1/4096 keeps a margin and stays well under one 8-bit step (the compositor's +/// tolerance is 1/255). +const TOL: f32 = 1.0 / 4096.0; + +struct Gpu { + device: wgpu::Device, + queue: wgpu::Queue, + dev: CameraRawDevelop, + _lock: std::sync::MutexGuard<'static, ()>, +} + +fn gpu() -> Option { + let lock = photocraft_testkit::gpu_lock(); + // `WGPU_BACKEND` picks the backend; `PHOTOCRAFT_TEST_FALLBACK_ADAPTER=1` the software one (WARP). + let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::new_without_display_handle_from_env()); + let fallback = std::env::var_os("PHOTOCRAFT_TEST_FALLBACK_ADAPTER").is_some(); + let options = wgpu::RequestAdapterOptions { force_fallback_adapter: fallback, ..Default::default() }; + let adapter = match pollster::block_on(instance.request_adapter(&options)) { + Ok(a) => a, + Err(e) => { + eprintln!("skipping Camera Raw GPU tests: no adapter ({e})"); + return None; + } + }; + if !CameraRawDevelop::supported(&adapter) { + eprintln!("skipping Camera Raw GPU tests: adapter can't render Rgba32Float"); + return None; + } + let (device, queue) = pollster::block_on(adapter.request_device(&wgpu::DeviceDescriptor::default())).ok()?; + eprintln!("Camera Raw GPU tests on {:?} ({})", adapter.get_info().backend, adapter.get_info().name); + let dev = CameraRawDevelop::new(&device).ok()?; + Some(Gpu { device, queue, dev, _lock: lock }) +} + +#[derive(Clone, Copy, Debug)] +enum Depth { + Eight, + Sixteen, + Float, +} + +const DEPTHS: [Depth; 3] = [Depth::Eight, Depth::Sixteen, Depth::Float]; + +fn hash(i: usize, c: u64) -> f32 { + let mut z = (i as u64).wrapping_mul(0x9E37_79B9_7F4A_7C15) ^ c.wrapping_mul(0xC2B2_AE3D_27D4_EB4F); + z = (z ^ (z >> 29)).wrapping_mul(0xBF58_476D_1CE4_E5B9); + (z >> 40) as f32 / (1u64 << 24) as f32 +} + +/// Gradients, noise and saturated patches (every Color Mixer band), quantized to `depth`. The +/// 32-bit image also has values above 1 and a few below 0. +fn image(w: usize, h: usize, depth: Depth) -> Vec<[f32; 4]> { + (0..w * h) + .map(|i| { + let (x, y) = ((i % w) as f32 / w as f32, (i / w) as f32 / h as f32); + let mut c = if (i / w).is_multiple_of(4) { + // A hue sweep at full and half saturation. + let hue = x * 6.0; + let f = |n: f32| (((hue + n) % 6.0 - 3.0).abs() - 1.0).clamp(0.0, 1.0); + let s = if (i / w).is_multiple_of(8) { 1.0 } else { 0.5 }; + [f(0.0), f(4.0), f(2.0)].map(|v| (1.0 - s) * 0.6 + s * v) + } else { + [0.1 + 0.8 * x, 0.2 + 0.6 * y, 0.5 - 0.4 * x * y].map(|v| v + (hash(i, 1) - 0.5) * 0.15) + }; + if let Depth::Float = depth { + c = c.map(|v| v * (1.0 + 1.5 * y) - 0.02 * hash(i, 2)); + } + let q = |v: f32| match depth { + Depth::Eight => (v.clamp(0.0, 1.0) * 255.0).round() / 255.0, + Depth::Sixteen => (v.clamp(0.0, 1.0) * 32768.0).round() / 32768.0, + Depth::Float => v, + }; + [q(c[0]), q(c[1]), q(c[2]), 1.0] + }) + .collect() +} + +/// Develops `p` both ways and returns the largest channel difference. +fn compare(g: &mut Gpu, p: &CameraRaw, depth: Depth) -> f32 { + let (w, h) = (171, 113); + let float = matches!(depth, Depth::Float); + let src = image(w, h, depth); + let mut cpu = src.clone(); + develop(&mut cpu, w, h, p, float); + let points = white_black_points(&src, w, h, p); + let stages = per_pixel(p, w, h, float, points).unwrap_or_else(|| panic!("{p:?} has a spatial stage")); + let out = g.dev.develop(&g.device, &g.queue, None, &src, None, [w as u32, h as u32], &stages).unwrap(); + assert_eq!(out.len(), cpu.len()); + let mut worst = (0.0f32, 0usize); + for (i, (a, b)) in out.iter().zip(&cpu).enumerate() { + assert!(a.iter().all(|v| v.is_finite()), "{p:?} {depth:?}: non-finite GPU pixel {i}: {a:?}"); + assert_eq!(a[3], b[3], "alpha is kept"); + for c in 0..3 { + let d = (a[c] - b[c]).abs(); + if d > worst.0 { + worst = (d, i); + } + } + } + let (d, i) = worst; + assert!(d <= TOL, "{p:?} {depth:?}: GPU {:?} vs CPU {:?} at pixel {i} (source {:?}), off by {d}", out[i], cpu[i], src[i]); + if !float { + assert!(out.iter().all(|q| q[..3].iter().all(|v| (0.0..=1.0).contains(v))), "{p:?} {depth:?}: clipped like the CPU"); + } + d +} + +fn check(name: &str, sets: &[CameraRaw]) { + let Some(mut g) = gpu() else { return }; + for p in sets { + for depth in DEPTHS { + let d = compare(&mut g, p, depth); + eprintln!("{name} {depth:?}: max |GPU - CPU| = {d:.2e}"); + } + } +} + +#[test] +fn white_balance_and_exposure() { + check( + "white balance", + &[ + CameraRaw { temperature: 40.0, tint: -25.0, ..Default::default() }, + CameraRaw { temperature: -70.0, tint: 60.0, exposure: -1.2, ..Default::default() }, + CameraRaw { exposure: 1.5, ..Default::default() }, + ], + ); +} + +#[test] +fn contrast_without_texture_or_clarity() { + check("contrast", &[CameraRaw { contrast: 60.0, ..Default::default() }, CameraRaw { contrast: -80.0, exposure: 0.4, ..Default::default() }]); +} + +#[test] +fn whites_and_blacks() { + check( + "whites/blacks", + &[ + CameraRaw { whites: 70.0, blacks: -45.0, ..Default::default() }, + CameraRaw { whites: -60.0, blacks: 50.0, temperature: 20.0, ..Default::default() }, + CameraRaw { whites: 30.0, ..Default::default() }, + CameraRaw { blacks: -100.0, exposure: -0.5, ..Default::default() }, + // ProPhoto's power-law encoding. + CameraRaw { whites: 50.0, blacks: -30.0, encoding_gamma: 1.8, ..Default::default() }, + ], + ); +} + +#[test] +fn tone_curves() { + check( + "tone curves", + &[ + CameraRaw { + curve_highlights: -60.0, + curve_lights: 30.0, + curve_darks: 40.0, + curve_shadows: -20.0, + curve_splits: [20.0, 45.0, 80.0], + ..Default::default() + }, + CameraRaw { point_curve: vec![[0.0, 20.0], [64.0, 50.0], [192.0, 220.0], [255.0, 245.0]], ..Default::default() }, + CameraRaw { + point_curve_red: vec![[0.0, 0.0], [128.0, 160.0], [255.0, 255.0]], + point_curve_green: vec![[0.0, 10.0], [255.0, 230.0]], + point_curve_blue: vec![[0.0, 0.0], [100.0, 70.0], [255.0, 255.0]], + ..Default::default() + }, + ], + ); +} + +#[test] +fn vibrance_and_saturation() { + check( + "presence", + &[ + CameraRaw { vibrance: 70.0, ..Default::default() }, + CameraRaw { saturation: -60.0, ..Default::default() }, + CameraRaw { vibrance: -40.0, saturation: 50.0, ..Default::default() }, + ], + ); +} + +#[test] +fn color_mixer() { + let ramp = |k: f32| std::array::from_fn(|i| ((i as f32 * 37.0 + k) % 200.0) - 100.0); + check( + "color mixer", + &[ + CameraRaw { hsl_hue: ramp(0.0), ..Default::default() }, + CameraRaw { hsl_sat: ramp(50.0), ..Default::default() }, + CameraRaw { hsl_lum: ramp(120.0), ..Default::default() }, + CameraRaw { hsl_hue: ramp(10.0), hsl_sat: ramp(80.0), hsl_lum: ramp(150.0), ..Default::default() }, + ], + ); +} + +#[test] +fn color_grading() { + check( + "color grading", + &[ + CameraRaw { grade_shadows: Wheel { hue: 220.0, sat: 70.0, lum: 20.0 }, ..Default::default() }, + CameraRaw { + grade_midtones: Wheel { hue: 120.0, sat: 30.0, lum: -15.0 }, + grade_highlights: Wheel { hue: 40.0, sat: 50.0, lum: 10.0 }, + grade_global: Wheel { hue: 300.0, sat: 15.0, lum: 5.0 }, + grade_blending: 80.0, + grade_balance: -40.0, + ..Default::default() + }, + ], + ); +} + +#[test] +fn vignette() { + check( + "vignette", + &[ + CameraRaw { vignette_amount: -70.0, ..Default::default() }, + CameraRaw { vignette_amount: -50.0, vignette_roundness: -60.0, vignette_feather: 20.0, vignette_highlights: 70.0, ..Default::default() }, + CameraRaw { + vignette_amount: 60.0, + vignette_roundness: 80.0, + vignette_midpoint: 20.0, + vignette_style: "colorPriority".into(), + ..Default::default() + }, + CameraRaw { vignette_amount: -40.0, vignette_style: "paintOverlay".into(), ..Default::default() }, + CameraRaw { vignette_amount: 40.0, vignette_style: "paintOverlay".into(), ..Default::default() }, + ], + ); +} + +#[test] +fn grain_in_full_resolution_coordinates() { + check( + "grain", + &[ + CameraRaw { grain_amount: 60.0, seed: 3, ..Default::default() }, + // A preview proxy: the noise lattice is sampled at full-resolution positions. + CameraRaw { grain_amount: 80.0, grain_size: 60.0, grain_roughness: 90.0, seed: u32::MAX, pixel_scale: 0.143, ..Default::default() }, + CameraRaw { grain_amount: 25.0, grain_size: 0.0, grain_roughness: 0.0, seed: 77, pixel_scale: 0.5, ..Default::default() }, + ], + ); +} + +#[test] +fn every_per_pixel_stage_at_once() { + let mut hsl = [0.0; 8]; + hsl[1] = 35.0; + hsl[5] = -50.0; + check( + "all stages", + &[CameraRaw { + temperature: 25.0, + tint: 10.0, + exposure: 0.3, + contrast: 25.0, + whites: 20.0, + blacks: -15.0, + vibrance: 30.0, + saturation: 10.0, + curve_darks: 20.0, + point_curve: vec![[0.0, 8.0], [255.0, 250.0]], + hsl_hue: hsl, + hsl_sat: hsl, + hsl_lum: hsl, + grade_shadows: Wheel { hue: 210.0, sat: 25.0, lum: 0.0 }, + vignette_amount: -30.0, + grain_amount: 20.0, + pixel_scale: 0.2, + ..Default::default() + }], + ); +} + +#[test] +fn identity_leaves_pixels_alone_and_spatial_settings_have_no_pass() { + let Some(mut g) = gpu() else { return }; + let p = CameraRaw::default(); + let src = image(64, 32, Depth::Float); + let stages = per_pixel(&p, 64, 32, false, None).unwrap(); + let out = g.dev.develop(&g.device, &g.queue, None, &src, Some(1), [64, 32], &stages).unwrap(); + assert_eq!(out, src, "the CPU develop returns early, unclipped"); + for spatial in [ + CameraRaw { dehaze: 10.0, ..Default::default() }, + CameraRaw { shadows: 10.0, ..Default::default() }, + CameraRaw { highlights: -10.0, ..Default::default() }, + CameraRaw { texture: 10.0, ..Default::default() }, + CameraRaw { clarity: 10.0, ..Default::default() }, + CameraRaw { sharpen_amount: 10.0, ..Default::default() }, + CameraRaw { noise_luminance: 10.0, ..Default::default() }, + CameraRaw { noise_color: 10.0, ..Default::default() }, + ] { + assert!(spatial.spatial() && per_pixel(&spatial, 64, 32, false, Some((0.0, 1.0))).is_none(), "{spatial:?}"); + } + // Whites and Blacks need the image's points. + assert!(per_pixel(&CameraRaw { whites: 10.0, ..Default::default() }, 64, 32, false, None).is_none()); +} + +#[test] +fn a_cached_source_is_reused_and_a_new_key_uploads() { + let Some(mut g) = gpu() else { return }; + let p = CameraRaw { exposure: 0.5, ..Default::default() }; + let stages = per_pixel(&p, 64, 32, false, None).unwrap(); + let a = image(64, 32, Depth::Eight); + let b: Vec<[f32; 4]> = a.iter().map(|q| [q[2], q[0], q[1], 1.0]).collect(); + let first = g.dev.develop(&g.device, &g.queue, None, &a, Some(7), [64, 32], &stages).unwrap(); + // Same key: the uploaded source stays (callers key by the proxy's identity). + assert_eq!(g.dev.develop(&g.device, &g.queue, None, &b, Some(7), [64, 32], &stages).unwrap(), first); + let mut cpu = b.clone(); + develop(&mut cpu, 64, 32, &p, false); + let other = g.dev.develop(&g.device, &g.queue, None, &b, Some(8), [64, 32], &stages).unwrap(); + assert!(other.iter().zip(&cpu).all(|(x, y)| (0..3).all(|c| (x[c] - y[c]).abs() <= TOL))); +} + +#[test] +fn bad_sizes_and_faulted_devices_are_errors() { + let Some(mut g) = gpu() else { return }; + let stages = per_pixel(&CameraRaw { exposure: 0.5, ..Default::default() }, 4, 4, false, None).unwrap(); + let px = vec![[0.5f32; 4]; 16]; + for size in [[0, 4], [4, 0], [5, 4], [3, 3], [u32::MAX, 1]] { + assert!(g.dev.develop(&g.device, &g.queue, None, &px, None, size, &stages).is_err(), "{size:?}"); + } + let health = DeviceHealth::new(); + health.mark(Fault::Lost("test".into())); + assert!(g.dev.develop(&g.device, &g.queue, Some(&health), &px, None, [4, 4], &stages).is_err()); + // And the pass still works afterwards. + assert!(g.dev.develop(&g.device, &g.queue, Some(&DeviceHealth::new()), &px, None, [4, 4], &stages).is_ok()); +} diff --git a/crates/ui-egui/src/camera_raw_gpu.rs b/crates/ui-egui/src/camera_raw_gpu.rs new file mode 100644 index 0000000000..d017063048 --- /dev/null +++ b/crates/ui-egui/src/camera_raw_gpu.rs @@ -0,0 +1,277 @@ +//! Camera Raw's preview develop on the GPU (#6916). When every stage the settings use reads +//! only its own pixel, the proxy develops in one wgpu pass (`photocraft_gpu::CameraRawDevelop`) +//! on the canvas's device and is read back for the histogram, scopes and display conversion. +//! Spatial stages, Rendering Mode CPU, `PHOTOCRAFT_CPU_CAMERA_RAW`, no GPU canvas, a software +//! adapter, a device fault or a failed develop all keep the CPU develop on the worker. +//! +//! The pipeline builds on a thread the first time a dialog opens (DX12's shader compiler takes +//! about 0.35 s, #6419); frames develop on the CPU until it is ready. + +use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; +use std::sync::{Arc, Mutex, OnceLock}; + +use eframe::wgpu; +use photocraft_algo::camera_raw::CameraRaw; +use photocraft_gpu::{CameraRawDevelop, DeviceHealth}; + +use crate::PhotocraftApp; + +/// The built pass, shared by every Camera Raw dialog on the device (never built on the web). +#[derive(Clone)] +#[cfg_attr(target_arch = "wasm32", allow(dead_code))] +pub(crate) struct Pass(Arc>); + +/// A device's pass: unset while it builds, `None` when the device can't run it. +pub(crate) type Slot = Arc>>; + +impl Pass { + /// Whether `adapter` may run the pass: not a software adapter (the CPU develop is faster + /// there), one that renders `Rgba32Float`, and not on the web (no blocking readback yet). + fn usable(adapter: &wgpu::Adapter) -> bool { + if cfg!(target_arch = "wasm32") { + return false; + } + if adapter.get_info().device_type == wgpu::DeviceType::Cpu { + log::info!("Camera Raw develops on the CPU: software graphics adapter"); + return false; + } + if !CameraRawDevelop::supported(adapter) { + log::info!("Camera Raw develops on the CPU: the adapter can't render Rgba32Float"); + return false; + } + true + } + + /// Builds the pass into `slot`, on a thread where there are threads. + pub(crate) fn start(adapter: &wgpu::Adapter, device: &wgpu::Device, slot: &Slot) { + if !Self::usable(adapter) { + let _ = (slot.set(None), device); + return; + } + #[cfg(not(target_arch = "wasm32"))] + { + let (on, out) = (device.clone(), slot.clone()); + let spawned = std::thread::Builder::new().name("camera-raw-pipeline".into()).spawn(move || { + let pass = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| Self::build_on(&on))).unwrap_or_else(|_| { + log::warn!("building the Camera Raw pipeline panicked; Camera Raw develops on the CPU"); + None + }); + let _ = out.set(pass); + }); + if spawned.is_err() { + let _ = slot.set(Self::build_on(device)); + } + } + } + + /// The pass on `device`, whatever its adapter. + #[cfg_attr(target_arch = "wasm32", allow(dead_code))] + pub(crate) fn build_on(device: &wgpu::Device) -> Option { + match CameraRawDevelop::new(device) { + Ok(pass) => Some(Pass(Arc::new(Mutex::new(pass)))), + Err(e) => { + log::warn!("{e}; Camera Raw develops on the CPU"); + None + } + } + } +} + +/// The dialog's GPU develop, if the app may use one. +pub(crate) fn for_app(app: &PhotocraftApp) -> Option { + let cpu = app.session.prefs().performance.effective_rendering_mode() == photocraft_engine::prefs::RenderingMode::Cpu; + if cpu || std::env::var_os("PHOTOCRAFT_CPU_CAMERA_RAW").is_some() { + return None; + } + app.gpu.as_ref()?.camera_raw() +} + +/// A key for a dialog's proxy pixels, unique in the process: the pass keeps the last source it +/// uploaded, and a new dialog's proxy may reuse a closed one's memory. +pub(crate) fn source_key() -> u64 { + static NEXT: AtomicU64 = AtomicU64::new(1); + NEXT.fetch_add(1, Ordering::Relaxed) +} + +/// The source key and the settings the black and white points depend on. +type PointsKey = (u64, [u32; 5]); +/// The last [`PointsKey`] and its points. +type Points = Option<(PointsKey, Option<(f32, f32)>)>; + +/// One dialog's handle on the pass (cheap to clone into each proxy job). +#[derive(Clone)] +#[cfg_attr(target_arch = "wasm32", allow(dead_code))] +pub(crate) struct CameraRawGpu { + device: wgpu::Device, + queue: wgpu::Queue, + health: DeviceHealth, + pass: Slot, + /// Set after a develop failed: the dialog stays on the CPU. + failed: Arc, + /// Whites and Blacks adapt to the image; its points change only with these settings. + points: Arc>, +} + +impl CameraRawGpu { + pub(crate) fn new(device: wgpu::Device, queue: wgpu::Queue, health: DeviceHealth, pass: Slot) -> Self { + CameraRawGpu { device, queue, health, pass, failed: Arc::default(), points: Arc::default() } + } + + /// Develops `px` (`w × h`) with `p`, or `None` when the CPU must: a spatial stage, the pass + /// still building, a fault, or a GPU error (logged; the dialog then stays on the CPU). `key` names the pixels when they + /// are the dialog's unchanged proxy ([`source_key`]), so they upload once. + pub(crate) fn develop(&self, px: &[[f32; 4]], key: Option, w: usize, h: usize, p: &CameraRaw, float: bool) -> Option> { + if p.spatial() || self.failed.load(Ordering::Relaxed) || !self.health.is_ok() { + return None; + } + #[cfg(target_arch = "wasm32")] + { + let _ = (px, key, w, h, float); + None + } + #[cfg(not(target_arch = "wasm32"))] + { + let Some(Some(pass)) = self.pass.get() else { return None }; + let points = self.points(px, key, w, h, p); + let stages = photocraft_algo::camera_raw::per_pixel(p, w, h, float, points)?; + let size = [u32::try_from(w).ok()?, u32::try_from(h).ok()?]; + let mut pass = pass.0.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + match pass.develop(&self.device, &self.queue, Some(&self.health), px, key, size, &stages) { + Ok(out) => Some(out), + Err(e) => { + log::warn!("{}; Camera Raw develops on the CPU", e.0); + self.failed.store(true, Ordering::Relaxed); + None + } + } + } + } + + #[cfg(not(target_arch = "wasm32"))] + fn points(&self, px: &[[f32; 4]], key: Option, w: usize, h: usize, p: &CameraRaw) -> Option<(f32, f32)> { + if p.whites == 0.0 && p.blacks == 0.0 { + return None; + } + let Some(key) = key else { return photocraft_algo::camera_raw::white_black_points(px, w, h, p) }; + let key = (key, [p.temperature, p.tint, p.exposure, p.contrast, p.encoding_gamma].map(f32::to_bits)); + let mut cache = self.points.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + if let Some((k, points)) = *cache + && k == key + { + return points; + } + let points = photocraft_algo::camera_raw::white_black_points(px, w, h, p); + *cache = Some((key, points)); + points + } +} + +#[cfg(test)] +mod tests { + use super::*; + use photocraft_algo::camera_raw::develop; + use serde_json::json; + + /// The pass evaluates develop's expressions in f32 (see `photocraft-gpu`'s Camera Raw tests). + const TOL: f32 = 1.0 / 4096.0; + + /// The app on egui_kittest's device (a software adapter where there is one), or `None`. + fn gpu_app(depth: u32) -> Option<(PhotocraftApp, egui::Context)> { + let Ok(rs) = std::panic::catch_unwind(|| egui_kittest::wgpu::create_render_state(crate::gpu_canvas::wgpu_setup(), Default::default())) else { + eprintln!("skipping: no GPU adapter"); + return None; + }; + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + app.set_wgpu(rs); + app.gpu.as_ref()?; + app.run("file.new", json!({"width": 300, "height": 200, "depth": depth})).unwrap(); + app.run("layer.new.layer", json!({})).unwrap(); + app.run("filter.render.clouds", json!({"seed": 5})).unwrap(); + app.run("select.rect", json!({"x": 40, "y": 30, "width": 120, "height": 90})).unwrap(); + app.run("edit.fill", json!({"color": "#cc4422"})).unwrap(); + app.run("select.deselect", json!({})).unwrap(); + Some((app, egui::Context::default())) + } + + /// The canvas's pass, built even on a software adapter (which the app leaves on the CPU). + fn force_pass(app: &PhotocraftApp) { + app.gpu.as_ref().expect("GPU canvas").force_camera_raw_pass(); + } + + fn developed(app: &mut PhotocraftApp, ctx: &egui::Context, p: CameraRaw) -> (&'static str, Vec<[f32; 4]>, Vec<[f32; 4]>) { + let d = app.camera_raw.as_mut().expect("dialog"); + d.params = p; + d.render(ctx); + let mut cpu = d.proxy.to_vec(); + let mut q = d.params.clone(); + q.pixel_scale = (d.pw as f32 / d.full_w.max(1) as f32).min(1.0); + develop(&mut cpu, d.pw, d.ph, &q, d.float); + (d.develop_backend, d.processed.clone(), cpu) + } + + #[test] + fn the_pass_is_built_when_camera_raw_first_opens_not_with_the_canvas() { + let _gpu = photocraft_testkit::gpu_lock(); + let Some((mut app, ctx)) = gpu_app(8) else { return }; + let canvas = app.gpu.clone().expect("GPU canvas"); + assert!(!canvas.camera_raw_started(), "no Camera Raw pipeline at launch (#6419)"); + crate::camera_raw_ui::open(&mut app, &ctx).unwrap(); + assert!(canvas.camera_raw_started(), "built (or refused) from the first open"); + assert_eq!(app.camera_raw.as_ref().map(|d| d.develop_backend), Some("cpu"), "the first frame doesn't wait for the pipeline"); + canvas.wait_camera_raw_pass(); + let software = canvas.adapter_info().device_type == wgpu::DeviceType::Cpu; + let d = app.camera_raw.as_ref().expect("dialog"); + assert_eq!(d.gpu.is_none(), software, "a software adapter keeps the CPU develop"); + } + + #[test] + fn per_pixel_settings_develop_on_the_gpu_like_the_cpu_and_the_rest_stays_on_the_cpu() { + let _gpu = photocraft_testkit::gpu_lock(); + for depth in [8, 16, 32] { + let Some((mut app, ctx)) = gpu_app(depth) else { return }; + force_pass(&app); + crate::camera_raw_ui::open(&mut app, &ctx).unwrap(); + if app.camera_raw.as_ref().is_some_and(|d| d.gpu.is_none()) { + eprintln!("skipping: the device can't run the Camera Raw pass"); + return; + } + let per_pixel = CameraRaw { + temperature: 20.0, + exposure: 0.4, + contrast: 30.0, + whites: 25.0, + blacks: -20.0, + vibrance: 40.0, + curve_lights: 25.0, + grade_shadows: photocraft_algo::camera_raw::Wheel { hue: 220.0, sat: 40.0, lum: 0.0 }, + vignette_amount: -40.0, + grain_amount: 30.0, + ..Default::default() + }; + let (backend, gpu, cpu) = developed(&mut app, &ctx, per_pixel.clone()); + assert_eq!(backend, "gpu", "{depth}-bit"); + let worst = gpu.iter().zip(&cpu).flat_map(|(a, b)| (0..4).map(move |c| (a[c] - b[c]).abs())).fold(0.0f32, f32::max); + assert!(worst <= TOL, "{depth}-bit: off by {worst}"); + let described = app.camera_raw.as_ref().map(|d| d.describe(&app.ui.camera_raw_scope, &app.ui.camera_raw_preview)).unwrap(); + assert_eq!(described["developBackend"], "gpu"); + // A spatial stage develops the whole frame on the CPU. + let (backend, shown, cpu) = developed(&mut app, &ctx, CameraRaw { shadows: 40.0, ..per_pixel.clone() }); + assert_eq!((backend, shown == cpu), ("cpu", true), "{depth}-bit"); + // A device fault: the CPU, from the next frame on. + app.gpu.as_ref().unwrap().health().mark(photocraft_gpu::Fault::Lost("test".into())); + let (backend, shown, cpu) = developed(&mut app, &ctx, per_pixel); + assert_eq!((backend, shown == cpu), ("cpu", true), "{depth}-bit after a fault"); + } + } + + #[test] + fn rendering_mode_cpu_keeps_the_cpu_develop() { + let _gpu = photocraft_testkit::gpu_lock(); + let Some((mut app, ctx)) = gpu_app(8) else { return }; + force_pass(&app); + app.run("prefs.set", json!({"path": "performance.renderingMode", "value": "cpu"})).unwrap(); + crate::camera_raw_ui::open(&mut app, &ctx).unwrap(); + let (backend, shown, cpu) = developed(&mut app, &ctx, CameraRaw { exposure: 0.5, ..Default::default() }); + assert_eq!((backend, shown == cpu), ("cpu", true)); + } +} diff --git a/crates/ui-egui/src/camera_raw_ui.rs b/crates/ui-egui/src/camera_raw_ui.rs index 8766b8efc6..61cbd64117 100644 --- a/crates/ui-egui/src/camera_raw_ui.rs +++ b/crates/ui-egui/src/camera_raw_ui.rs @@ -4,8 +4,10 @@ //! The preview runs [`photocraft_algo::camera_raw::develop`] on a CPU proxy of the layer //! (≤ 900 px, `pixel_scale` keeps pixel radii true to the full image), recomputed when a //! control changes: on a worker for the dialog's own controls, so a drag never waits for it, and -//! on the UI thread for the control channel, so a reply describes its own settings. OK runs `filter.cameraRaw` with the non-default settings, so the result is -//! one history step (or a smart filter on a smart object) and exactly replayable. +//! on the UI thread for the control channel, so a reply describes its own settings. Settings +//! whose stages are all per pixel develop on the GPU instead where it can (`camera_raw_gpu`). +//! OK runs `filter.cameraRaw` with the non-default settings, so the result is one history step +//! (or a smart filter on a smart object) and exactly replayable. //! //! Control channel: `ui.menu.invoke {"id":"filter.cameraRaw","params":{"ui":{"set":{…}, //! "commit":true | "cancel":true}}}`; the reply describes the dialog. `{"ui":{"saveSettings":true}}` @@ -43,7 +45,7 @@ pub struct CameraRawDialog { pub(crate) selection: Option>>, pub(crate) pw: usize, pub(crate) ph: usize, - full_w: usize, + pub(crate) full_w: usize, full_h: usize, preview_ppp: f32, pub(crate) detail: super::camera_raw_detail_ui::DetailPreview, @@ -74,6 +76,13 @@ pub struct CameraRawDialog { pending: Option>>, /// The last worker failure the status bar shows, with the preview revision it failed on. preview_error: Option<(String, u64)>, + /// The GPU develop, when the app may use one. + pub(crate) gpu: Option, + /// Names [`Self::proxy`] for the GPU pass's upload cache. + source_key: u64, + /// The last frame's develop alone, and where it ran ("gpu" or "cpu"). + develop_ms: f64, + pub(crate) develop_backend: &'static str, /// Settings before each finished edit, so Ctrl+Z works inside the dialog (#4100). undo: Vec, redo: Vec, @@ -85,7 +94,7 @@ impl CameraRawDialog { pub fn describe(&self, view: &crate::state::CameraRawScopeState, navigation: &crate::state::CameraRawPreviewState) -> Value { let h = self.histogram(); let mut result = json!({"layer": self.layer.0, "params": serde_json::to_value(&self.params).unwrap_or(Value::Null), "proxy": [self.pw, self.ph], - "renderMs": self.render_ms, "histogramMs": self.histogram_ms, "previewRevision": self.preview_revision, "before": self.show_before, + "renderMs": self.render_ms, "developMs": self.develop_ms, "developBackend": self.develop_backend, "histogramMs": self.histogram_ms, "previewRevision": self.preview_revision, "before": self.show_before, "histogram": {"source": if self.show_before { "before" } else { "after" }, "approximate": true, "size": [self.pw, self.ph], "sampleDomain": "preview-rgb", "range": [0, 1], "red": h.channels[0].as_slice(), "green": h.channels[1].as_slice(), "blue": h.channels[2].as_slice(), "samples": h.samples, "transparent": h.transparent, "invalid": h.invalid, "underflow": h.underflow, "overflow": h.overflow, "shadows": h.shadows, "highlights": h.highlights}}); @@ -166,6 +175,8 @@ impl CameraRawDialog { size: (self.pw, self.ph), full_w: self.full_w, display: self.display.clone(), + gpu: self.gpu.clone(), + source_key: self.source_key, } } @@ -187,6 +198,8 @@ impl CameraRawDialog { self.processed = frame.px; self.scope.cache = None; self.render_ms = frame.ms; + self.develop_ms = frame.develop_ms; + self.develop_backend = frame.backend; self.preview_revision = self.preview_revision.saturating_add(1); } @@ -266,6 +279,8 @@ struct ProxyJob { size: (usize, usize), full_w: usize, display: std::sync::Arc, + gpu: Option, + source_key: u64, } /// A developed proxy, ready to show. @@ -276,21 +291,38 @@ struct ProxyFrame { image: egui::ColorImage, display: std::sync::Arc, ms: f64, + develop_ms: f64, + backend: &'static str, } impl ProxyJob { fn run(self) -> ProxyFrame { let t0 = crate::gpu_canvas::now_ms(); let (pw, ph) = self.size; - let mut px = self.proxy.to_vec(); let mut p = self.params; p.pixel_scale = (pw as f32 / self.full_w.max(1) as f32).min(1.0); - if let Some(curve) = &self.raw_curve { - let tone = raw_stage(&p); - photocraft_io::raw::retone(&mut px, pw, ph, curve, tone); + // The open-time dialog re-tones the proxy for each job; otherwise the GPU reads the + // proxy as it is and uploads it once. + let retoned = self.raw_curve.as_ref().map(|curve| { + let mut px = self.proxy.to_vec(); + photocraft_io::raw::retone(&mut px, pw, ph, curve, raw_stage(&p)); + px + }); + if retoned.is_some() { (p.shadows, p.highlights, p.clarity, p.texture, p.dehaze) = (0.0, 0.0, 0.0, 0.0, 0.0); } - photocraft_algo::camera_raw::develop(&mut px, pw, ph, &p, self.float); + let develop_start = crate::gpu_canvas::now_ms(); + let key = retoned.is_none().then_some(self.source_key); + let input = retoned.as_deref().unwrap_or(&self.proxy); + let (mut px, backend) = match self.gpu.as_ref().and_then(|g| g.develop(input, key, pw, ph, &p, self.float)) { + Some(out) => (out, "gpu"), + None => { + let mut px = retoned.unwrap_or_else(|| self.proxy.to_vec()); + photocraft_algo::camera_raw::develop(&mut px, pw, ph, &p, self.float); + (px, "cpu") + } + }; + let develop_ms = crate::gpu_canvas::now_ms() - develop_start; if let Some(mask) = &self.selection { for ((out, original), coverage) in px.iter_mut().zip(self.proxy.iter()).zip(mask.iter()) { for (out, original) in out.iter_mut().zip(original) { @@ -302,7 +334,7 @@ impl ProxyJob { let histogram = RgbHistogram::from_rgba(&px); let histogram_ms = crate::gpu_canvas::now_ms() - histogram_start; let image = CameraRawDialog::image(&px, pw, ph, &self.display); - ProxyFrame { px, histogram, histogram_ms, image, display: self.display, ms: crate::gpu_canvas::now_ms() - t0 } + ProxyFrame { px, histogram, histogram_ms, image, display: self.display, ms: crate::gpu_canvas::now_ms() - t0, develop_ms, backend } } } @@ -722,6 +754,8 @@ fn open_pixels( app.ui.camera_raw_scope.selected_region = false; } let float = surf.format().sample == photocraft_color::SampleType::F32; + // Builds the GPU pass the first time any Camera Raw dialog opens. + let gpu = crate::camera_raw_gpu::for_app(app); let mut d = CameraRawDialog { layer, layer_name: name, @@ -770,6 +804,10 @@ fn open_pixels( raw_curve: None, pending: None, preview_error: None, + gpu, + source_key: crate::camera_raw_gpu::source_key(), + develop_ms: 0.0, + develop_backend: "cpu", undo: Vec::new(), redo: Vec::new(), edit_origin: None, diff --git a/crates/ui-egui/src/gpu_canvas.rs b/crates/ui-egui/src/gpu_canvas.rs index 76eb7a652d..7029fb1dac 100644 --- a/crates/ui-egui/src/gpu_canvas.rs +++ b/crates/ui-egui/src/gpu_canvas.rs @@ -120,6 +120,9 @@ pub struct GpuCanvas { /// [`canvas_budget`], shared with the paint callback's resources: [`GpuCanvas::format_for`] /// reads it while the renderer is locked. canvas_budget: std::sync::Arc, + /// Camera Raw's preview pass, built the first time the dialog asks (#6419). + camera_raw: crate::camera_raw_gpu::Slot, + camera_raw_started: std::sync::Arc, } /// Whether `regenerate_mips` builds each level in a scratch texture and copies it back: on @@ -177,7 +180,7 @@ impl GpuCanvas { rs.target_format, vram.map_or_else(|| "unknown".to_owned(), |b| format!("{} MB", b >> 20)) ); - Self { rs: rs.clone(), tile, high, health, vram, canvas_budget: budget } + Self { rs: rs.clone(), tile, high, health, vram, canvas_budget: budget, camera_raw: Default::default(), camera_raw_started: Default::default() } } /// The device's health flag (shared with the wgpu compositor and the paint callback). @@ -185,6 +188,42 @@ impl GpuCanvas { &self.health } + /// Camera Raw's GPU preview develop on this device; the first call starts building its + /// pipeline. `None` on a software adapter, without `Rgba32Float` render targets, after a + /// fault, or when the driver couldn't build the pipeline; the dialog then develops on the CPU. + pub(crate) fn camera_raw(&self) -> Option { + if self.fault().is_some() { + return None; + } + if !self.camera_raw_started.swap(true, Ordering::AcqRel) { + crate::camera_raw_gpu::Pass::start(&self.rs.adapter, &self.rs.device, &self.camera_raw); + } + if matches!(self.camera_raw.get(), Some(None)) { + return None; + } + Some(crate::camera_raw_gpu::CameraRawGpu::new(self.rs.device.clone(), self.rs.queue.clone(), self.health.clone(), self.camera_raw.clone())) + } + + /// Whether [`Self::camera_raw`] started building the pass. + #[cfg(test)] + pub(crate) fn camera_raw_started(&self) -> bool { + self.camera_raw_started.load(Ordering::Acquire) + } + + /// Waits until the pass is built or refused. + #[cfg(test)] + pub(crate) fn wait_camera_raw_pass(&self) { + let _ = self.camera_raw.wait(); + } + + /// Builds Camera Raw's pass even where [`Self::camera_raw`] wouldn't (egui_kittest's software + /// adapter), so tests drive the GPU develop. + #[cfg(test)] + pub(crate) fn force_camera_raw_pass(&self) { + self.camera_raw_started.store(true, Ordering::Release); + let _ = self.camera_raw.set(crate::camera_raw_gpu::Pass::build_on(&self.rs.device)); + } + /// Why the GPU can't be used any more (`None` while it can). pub fn fault(&self) -> Option { self.health.fault() diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 8784800ddd..660099bff1 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -43,6 +43,7 @@ pub mod caf_ui; pub(crate) mod cam_preview; mod cam_transform; mod camera_raw_detail_ui; +mod camera_raw_gpu; mod camera_raw_preview_ui; mod camera_raw_scope_ui; pub mod camera_raw_ui; diff --git a/docs/hardware-parity.md b/docs/hardware-parity.md index 391c92f0ce..e73fcd7290 100644 --- a/docs/hardware-parity.md +++ b/docs/hardware-parity.md @@ -1,6 +1,6 @@ # Hardware parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-10 · **Change:** major (first version: GPU, pen tablets, displays, gestures per platform against Photoshop 2026) · **Target:** Adobe Photoshop 2026 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-17 · **Change:** minor (Camera Raw's preview develops its per-pixel stages on the GPU) · **Target:** Adobe Photoshop 2026 Each hardware feature Photoshop 2026 (27.11.0) uses, per platform, against PhotoCraft. Photoshop side: its bundle (Metal and OpenCL paths, "Precise Color Management for HDR Display" and EDR @@ -19,7 +19,7 @@ HDR display to verify. |---|---|---|---| | GPU canvas, zoom/pan, rotate view | Metal (macOS), DirectX/OpenCL (Windows) | wgpu 30: Metal, Vulkan, DX12, GL; backend selectable | done | | GPU compositing of layers, blend modes, effects | partial (Photoshop composites mostly on CPU) | wgpu compositor, ≤ 1/255 vs CPU oracle; Multichannel and > texture-limit regions fall back to CPU | done (ahead in places) | -| GPU filters (Blur Gallery, Liquify, Smart Sharpen, Camera Raw) | yes | CPU (rayon) for filters; GPU for compose and effects | partial | +| GPU filters (Blur Gallery, Liquify, Smart Sharpen, Camera Raw) | yes | CPU (rayon) for filters; GPU for compose and effects. Camera Raw's preview runs its per-pixel stages (white balance to grain) in one wgpu pass, 2.7 ms vs 21-28 ms on the CPU for the 858×572 proxy; spatial stages and OK still develop on the CPU (#6916) | partial | | Documents larger than the GPU texture limit | yes (tiled) | CPU fallback; tiling in progress (#49) | partial | | CPU-only fallback when no GPU | yes, reduced | `cpu` canvas preference; fails to start without an adapter on some Linux systems (#2519, #2412) | partial | | Choosing the GPU on a multi-GPU machine | Preferences › Performance › Use Graphics Processor | Linux only: Preferences › Performance › Advanced › GPU adapter and `PHOTOCRAFT_GPU_ADAPTER` (#1885); ignored on Windows and macOS | partial | @@ -63,4 +63,5 @@ HDR display to verify. | Date | Change | Summary | |---|---|---| | 2026-10-10 | major | First version | +| 2026-10-17 | minor | GPU filters: Camera Raw's preview, per-pixel stages (#6916 step 1) | | 2026-10-19 | minor | Graphics Adapter choice on Linux (#1885) | From 4830c326d8789365c2b76533a11bc885780ac936 Mon Sep 17 00:00:00 2001 From: fjamesprice Date: Sun, 18 Oct 2026 22:15:01 -0400 Subject: [PATCH 190/649] fix(camera-raw): the GPU benchmark stops on a failed develop bench_camera_raw dropped each GPU develop's Result with .ok(), so a device fault or a refused size would have been timed and printed as a GPU figure. try_time returns the first error instead, and main propagates it. Co-Authored-By: Claude Opus 5.5 --- crates/gpu/examples/bench_camera_raw.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/gpu/examples/bench_camera_raw.rs b/crates/gpu/examples/bench_camera_raw.rs index 8f31be5e8f..be206fe382 100644 --- a/crates/gpu/examples/bench_camera_raw.rs +++ b/crates/gpu/examples/bench_camera_raw.rs @@ -24,6 +24,17 @@ fn time(runs: usize, mut f: impl FnMut()) -> f64 { ) } +/// [`time`] for a call that can fail: its first error ends the benchmark instead of being timed. +fn try_time(runs: usize, mut f: impl FnMut() -> Result<(), E>) -> Result { + let mut failed = None; + let ms = time(runs, || { + if failed.is_none() { + failed = f().err(); + } + }); + failed.map_or(Ok(ms), Err) +} + fn main() -> Result<(), Box> { let runs = if std::env::args().any(|a| a == "--quick") { 5 } else { 40 }; let (w, h) = (858usize, 572usize); @@ -87,12 +98,8 @@ fn main() -> Result<(), Box> { let points = white_black_points(&src, w, h, p); let stages = per_pixel(p, w, h, false, points).ok_or("not per pixel")?; let size = [w as u32, h as u32]; - let upload = time(runs, || { - pass.develop(&device, &queue, None, &src, None, size, &stages).ok(); - }); - let cached = time(runs, || { - pass.develop(&device, &queue, None, &src, Some(1), size, &stages).ok(); - }); + let upload = try_time(runs, || pass.develop(&device, &queue, None, &src, None, size, &stages).map(drop))?; + let cached = try_time(runs, || pass.develop(&device, &queue, None, &src, Some(1), size, &stages).map(drop))?; println!("{name}:"); println!(" CPU develop {cpu:7.2} ms"); println!(" GPU, source uploaded every time {upload:7.2} ms"); From 0cc7bba44cae7c858453bebe55498f78a708ca8d Mon Sep 17 00:00:00 2001 From: Jason White Date: Sat, 17 Oct 2026 19:48:57 +0100 Subject: [PATCH 191/649] fix(atn): import a recorded Save As with its destination (#7102) The save event was mapped with no fields, so every Save As in an .atn came in as a plain File > Save. Playing it wrote over the file the action was played on and never wrote the recorded output. Save now reads As, In and Cpy. A destination that's a file of the recorded format imports as file.saveAs, or file.saveACopy for As a Copy. A folder destination, an unknown format or an extension that doesn't match stays a kept Photoshop step, so playback stops before writing anything. Folder saves can map once the {folder, extension} step from Save As steps now export to .atn too instead of being skipped. --- crates/engine/src/atn_cmds.rs | 56 +++++++++++++++++- crates/engine/src/atn_cmds/tests.rs | 88 +++++++++++++++++++++++++++++ crates/ui-egui/src/actions.rs | 68 ++++++++++++++++++++++ docs/file-format-parity.md | 5 +- docs/gaps.md | 8 ++- 5 files changed, 221 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/atn_cmds.rs b/crates/engine/src/atn_cmds.rs index 343a5920a0..d6f04fce86 100644 --- a/crates/engine/src/atn_cmds.rs +++ b/crates/engine/src/atn_cmds.rs @@ -1549,6 +1549,60 @@ fn open_to(_: &str, p: &Value) -> Option { Some(desc("null").with("null", path_value(jstr(p, "path")?))) } +/// Save As format classes (`As`) and the extensions PhotoCraft saves them under. The first +/// extension of a class is the one exported; WebP comes from Google's WebPShop plug-in. +const SAVE_FORMATS: &[(&str, &[&str])] = &[ + ("Pht3", &["psd"]), + ("PNGF", &["png"]), + ("JPEG", &["jpg", "jpeg"]), + ("TIFF", &["tif", "tiff"]), + ("BMPF", &["bmp"]), + ("Google WebPShop", &["webp"]), + ("Google WebP", &["webp"]), +]; + +fn path_extension(path: &str) -> Option { + let name = path.rsplit(['/', '\\']).next()?; + let (stem, ext) = name.rsplit_once('.')?; + (!stem.is_empty() && !ext.is_empty()).then(|| ext.to_ascii_lowercase()) +} + +/// `save`: a plain Save, or a Save As (`As` format, `In` destination, `Cpy` As a Copy). +/// Only a destination that is a file of the recorded format imports: a folder (#5430), an +/// unknown format or a mismatched extension stays a kept Photoshop step, so playback stops +/// before writing rather than saving over the played file (#7102). +fn save_from(d: &Descriptor) -> Mapped { + let unsupported = Mapped::Unsupported { harmless: false }; + let (format, dest) = (get_obj(d, "As "), d.get("In ")); + if format.is_none() && dest.is_none() { + return step("file.save", json!({})); + } + let Some(path) = dest.and_then(path_text) else { return unsupported }; + if get_bool(d, "DIDr") == Some(true) { + return unsupported; + } + let Some(ext) = path_extension(&path) else { return unsupported }; + if let Some(f) = format { + let class = trimmed(&f.class_id); + let Some((_, exts)) = SAVE_FORMATS.iter().find(|(c, _)| *c == class) else { return unsupported }; + if !exts.contains(&ext.as_str()) { + return unsupported; + } + } + step(if get_bool(d, "Cpy ") == Some(true) { "file.saveACopy" } else { "file.saveAs" }, json!({"path": path})) +} + +fn save_to(id: &str, p: &Value) -> Option { + if id == "file.save" { + return Some(desc("null")); + } + let path = jstr(p, "path")?; + let ext = path_extension(path)?; + let (class, _) = SAVE_FORMATS.iter().find(|(_, exts)| exts.contains(&ext.as_str()))?; + let d = desc("null").with("As ", D::Descriptor(desc(class))).with("In ", path_value(path)); + Some(if id == "file.saveACopy" { d.with("Cpy ", D::Boolean(true)) } else { d }) +} + /// Photoshop's four-character condition codes that differ from the string ids. const CONDITION_CODES: &[(&str, &str)] = &[("Lyrs", "hasLayers")]; @@ -3046,7 +3100,7 @@ const EVENTS: &[Event] = &[ Event { code: "Plc ", name: "placeEvent", label: "Place", ids: &["file.placeEmbedded", "file.placeLinked"], from: place_from, to: place_to }, Event { code: "Opn ", name: "open", label: "Open", ids: &["file.openAs"], from: open_from, to: open_to }, Event { code: "", name: "conditional", label: "If", ids: &["actions.conditional"], from: conditional_from, to: conditional_to }, - ev!("save", "save", "Save", "file.save", &[]), + Event { code: "save", name: "save", label: "Save", ids: &["file.save", "file.saveAs", "file.saveACopy"], from: save_from, to: save_to }, ev!("Rvrt", "revert", "Revert", "file.revert", &[]), Event { code: "Ply ", name: "play", label: "Play", ids: &["actions.play"], from: play_from, to: play_to }, Event { code: "Stop", name: "stop", label: "Stop", ids: &[STOP_MESSAGE], from: stop_from, to: stop_to }, diff --git a/crates/engine/src/atn_cmds/tests.rs b/crates/engine/src/atn_cmds/tests.rs index 638fc45cb5..c85fdabb91 100644 --- a/crates/engine/src/atn_cmds/tests.rs +++ b/crates/engine/src/atn_cmds/tests.rs @@ -335,6 +335,8 @@ fn every_mapped_command_exports_and_imports_back() { ("file.placeEmbedded", json!({"path": "/tmp/logo.png", "scale": 50})), ("file.placeLinked", json!({"path": "/tmp/logo.png"})), ("file.openAs", json!({"path": "/tmp/a.psd"})), + ("file.saveAs", json!({"path": "/tmp/out/a.png"})), + ("file.saveACopy", json!({"path": "/tmp/out/a.tif"})), ("actions.conditional", json!({"if": "hasLayers", "then": "FS8-Layers", "else": "FS8-No-Layers", "set": "S"})), ("actions.conditional", json!({"if": "landscape", "then": "Wide", "else": null, "set": "S"})), ("actions.play", json!({"action": "Other", "set": "S"})), @@ -1401,3 +1403,89 @@ fn function_keys_keep_shift_and_command() { } assert_eq!(super::function_key_name(7, false, false), "F7"); } + +fn one_action(items: Vec) -> AtnFile { + AtnFile { + name: UnicodeString::new_nul("Saves"), + expanded: false, + actions: vec![AtnAction { name: UnicodeString::new_nul("A"), items, ..Default::default() }], + warnings: vec![], + } +} + +fn save_as(format: &str, path: &str) -> Descriptor { + desc("null").with("As ", D::Descriptor(desc(format))).with("In ", path_value(path)).with("DocI", long(53.0)) +} + +#[test] +fn save_as_to_a_file_imports_with_its_destination() { + let file = one_action(vec![ + item("save", "Save", Some(save_as("PNGF", "/out/result.png"))), + item("save", "Save", Some(save_as("Google WebPShop", "C:\\out\\result.webp").with("Cpy ", D::Boolean(true)))), + item("save", "Save", Some(save_as("JPEG", "/out/result.jpeg"))), + item("save", "Save", None), + item("save", "Save", Some(desc("null").with("DocI", long(53.0)))), + ]); + let imp = import(&atn::write(&file).unwrap()).unwrap(); + assert_eq!( + imp.actions[0].steps, + [ + ("file.saveAs".to_string(), json!({"path": "/out/result.png"})), + ("file.saveACopy".to_string(), json!({"path": "C:\\out\\result.webp"})), + ("file.saveAs".to_string(), json!({"path": "/out/result.jpeg"})), + ("file.save".to_string(), json!({})), + ("file.save".to_string(), json!({})), + ] + ); + assert!(imp.unsupported.is_empty()); +} + +#[test] +fn save_as_that_cannot_be_mapped_stops_playback_instead_of_saving_over_the_file() { + // Before #7102 each of these imported as a plain File › Save, which overwrote the file the + // action was played on. + let file = one_action(vec![ + item("save", "Save", Some(save_as("PNGF", "/out/folder"))), + item("save", "Save", Some(save_as("PNGF", "/out/v1.png").with("DIDr", D::Boolean(true)))), + item("save", "Save", Some(save_as("PNGF", "/out/result.webp"))), + item("save", "Save", Some(save_as("GIFf", "/out/result.gif"))), + item("save", "Save", Some(desc("null").with("As ", D::Descriptor(desc("PNGF"))))), + ]); + let imp = import(&atn::write(&file).unwrap()).unwrap(); + let ids: Vec<&str> = imp.actions[0].steps.iter().map(|(id, _)| id.as_str()).collect(); + assert_eq!(ids, [PHOTOSHOP_STEP; 5]); + assert!(imp.actions[0].disabled.is_empty(), "kept saves stay on, so playback stops on them"); + // The kept steps are written back byte for byte. + let a = &imp.actions[0]; + let (bytes, skipped) = export("Saves", &[a], &[], false).unwrap(); + assert!(skipped.is_empty()); + let back = atn::parse(&bytes).unwrap(); + for (out, orig) in back.actions[0].items.iter().zip(&file.actions[0].items) { + assert_eq!(out.descriptor, orig.descriptor); + } +} + +#[test] +fn saves_round_trip_through_photoshop_events() { + let steps = vec![ + ("file.saveAs".to_string(), json!({"path": "/out/result.psd"})), + ("file.saveACopy".to_string(), json!({"path": "/out/copy.webp"})), + ("file.save".to_string(), json!({})), + ]; + let a = Action::new("A", steps.clone()); + let (bytes, skipped) = export("Saves", &[&a], &[], false).unwrap(); + assert!(skipped.is_empty()); + let file = atn::parse(&bytes).unwrap(); + let items = &file.actions[0].items; + assert!(items.iter().all(|i| i.event.id() == "save")); + let first = items[0].descriptor.as_ref().unwrap(); + assert_eq!(get_obj(first, "As ").map(|f| trimmed(&f.class_id)).as_deref(), Some("Pht3")); + assert_eq!(first.get("In ").and_then(path_text).as_deref(), Some("/out/result.psd")); + assert_eq!(get_bool(items[1].descriptor.as_ref().unwrap(), "Cpy "), Some(true)); + assert_eq!(import(&bytes).unwrap().actions[0].steps, steps); + + // A Save As PhotoCraft can't express in Photoshop's terms is skipped, never exported as a + // plain Save. + let odd = Action::new("B", vec![("file.saveAs".to_string(), json!({"path": "/out/result.xcf"}))]); + assert!(export("Saves", &[&odd], &[], false).is_err()); +} diff --git a/crates/ui-egui/src/actions.rs b/crates/ui-egui/src/actions.rs index 8b52ba88c5..b8f6a65623 100644 --- a/crates/ui-egui/src/actions.rs +++ b/crates/ui-egui/src/actions.rs @@ -1520,6 +1520,74 @@ mod tests { assert!(!b_changed && !a_changed); } + /// Loads a Photoshop set holding Invert + a Save As into `dest` and plays it on a PSD. + /// Returns the played result, whether the PSD changed on disk and the files in `out`. + fn play_imported_save_as(dest: &str) -> (Value, bool, Vec) { + use photocraft_psd::atn::{AtnAction, AtnEvent, AtnFile, AtnItem}; + use photocraft_psd::descriptor::{Descriptor, UnicodeString, Value as D}; + let dir = std::env::temp_dir().join(format!("photocraft-atn-save-as-{}-{}", dest.len(), std::process::id())); + let out = dir.join("out"); + std::fs::create_dir_all(&out).unwrap(); + let src = dir.join("src.psd").to_string_lossy().into_owned(); + let path = |text: &str| { + let units: Vec = text.encode_utf16().chain(std::iter::once(0)).collect(); + let mut b = b"txtu".to_vec(); + b.extend_from_slice(&((12 + units.len() * 2) as u32).to_le_bytes()); + b.extend_from_slice(&(units.len() as u32).to_le_bytes()); + units.iter().for_each(|u| b.extend_from_slice(&u.to_le_bytes())); + D::Path(b) + }; + let save = Descriptor::new("null") + .with("As ", D::Descriptor(Descriptor::new("PNGF"))) + .with("In ", path(&out.join(dest).to_string_lossy())) + .with("DocI", D::Integer(53)); + let item = |code: &[u8; 4], label: &str, d: Option| AtnItem { + event: AtnEvent::Code(*code), + dictionary: label.into(), + descriptor: d, + ..Default::default() + }; + let set = AtnFile { + name: UnicodeString::new_nul("Export"), + actions: vec![AtnAction { + name: UnicodeString::new_nul("Invert and save"), + items: vec![item(b"Invr", "Invert", None), item(b"save", "Save", Some(save))], + ..Default::default() + }], + ..Default::default() + }; + let mut app = disk_app(vec![]); + app.run("file.new", json!({"width": 16, "height": 16})).unwrap(); + app.save_as(Some(src.clone())).unwrap(); + let before = std::fs::read(&src).unwrap(); + app.run("actions.load", json!({"data": photocraft_engine::paint::tile::b64_encode(&photocraft_psd::atn::write(&set).unwrap())})).unwrap(); + app.open_path(&src).unwrap(); + let played = app.run("actions.play", json!({"action": 0})).unwrap(); + let mut written: Vec = std::fs::read_dir(&out).unwrap().map(|e| e.unwrap().file_name().to_string_lossy().into_owned()).collect(); + written.sort(); + let r = (played, std::fs::read(&src).unwrap() != before, written); + let _ = std::fs::remove_dir_all(&dir); + r + } + + #[test] + fn imported_save_as_writes_the_recorded_file_not_the_played_one() { + // #7102: the Save As imported as File › Save, which wrote over src.psd. + let (played, src_changed, written) = play_imported_save_as("result.png"); + assert!(played.get("failed").is_none(), "{played}"); + assert!(!src_changed, "the Save As wrote over the file the action was played on"); + assert_eq!(written, ["result.png"]); + } + + #[test] + fn imported_save_as_into_a_folder_stops_before_writing() { + // A folder destination isn't mapped yet (#5430): playback stops on it, nothing is saved. + let (played, src_changed, written) = play_imported_save_as("folder"); + assert!(played.get("failed").is_some(), "{played}"); + assert!(!src_changed); + assert!(written.is_empty(), "{written:?}"); + } + #[test] fn set_folders_group_actions_and_collapse() { use egui_kittest::{Harness, kittest::Queryable}; diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 0a80894db1..af2eda436f 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File-format parity -> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-15 · **Change:** minor (DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); PSD smart filters: 41 filters (27 more: Blur, Surface Blur, Smart Sharpen, Diffuse, Wind, Offset, Mezzotint and others) plus Hue/Saturation and Perspective Warp mapped both ways, #6296, #6298, #6300, #6302, #6304, #6314, #6316, #6267, #6268, FILE-215-2; large-file fixtures: a 20 MP layered PSD, a 150-layer layout, a 2 GB PSD and a 4.4 GB PSB generated at test time and round-tripped, FILE-216-2 done, #5107; earlier: PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-17 · **Change:** minor (`.atn`: a recorded Save As imports with its format and file (`file.saveAs`, `file.saveACopy` for As a Copy) instead of as a plain Save that wrote over the played file, #7102; folder destinations stop playback until #5430; DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); PSD smart filters: 41 filters (27 more: Blur, Surface Blur, Smart Sharpen, Diffuse, Wind, Offset, Mezzotint and others) plus Hue/Saturation and Perspective Warp mapped both ways, #6296, #6298, #6300, #6302, #6304, #6314, #6316, #6267, #6268, FILE-215-2; large-file fixtures: a 20 MP layered PSD, a 150-layer layout, a 2 GB PSD and a 4.4 GB PSB generated at test time and round-tripped, FILE-216-2 done, #5107; earlier: PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; 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 @@ -131,7 +131,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings. | LUTs `.cube` / `.3dl` / `.look` | R/W (Export Color Lookup) | R/W / R / R | `cms/src/lutfile.rs` | | Keyboard shortcuts `.kys` | R/W | R/W | `engine/src/kys.rs` (`write`: Edit › Keyboard Shortcuts › Export…, rows carry our id; Photoshop reading our files is unverified) | | ICC profiles | R | R | Own CMS | -| Actions `.atn` | R/W | R/W | `psd/src/atn.rs` (version 16 sets, exact round trip), `engine/src/atn_cmds.rs` (112 Photoshop events ↔ commands; other steps kept verbatim). Panel menu, CLI `batch --actions set.atn`, `actions.load`/`actions.save`. Photoshop 5-era version 12 files unsupported (AUTO-219-2) | +| Actions `.atn` | R/W | R/W | `psd/src/atn.rs` (version 16 sets, exact round trip), `engine/src/atn_cmds.rs` (112 Photoshop events ↔ commands; other steps kept verbatim; Save As maps to `file.saveAs`/`file.saveACopy` when its destination is a file, #7102). Panel menu, CLI `batch --actions set.atn`, `actions.load`/`actions.save`. Photoshop 5-era version 12 files unsupported (AUTO-219-2) | | Styles `.asl` | R/W | no | #1693 | | Contours `.shc` | R/W | R/W | `psd/src/shc.rs`; Contour Editor Load…/Save… (FILE-215-15). No user contour library; not yet checked against a Photoshop-written file | | Custom shapes `.csh`, tool presets `.tpl` | R/W | no | | @@ -142,6 +142,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings. | Date | Change | Summary | |---|---|---| +| 2026-10-17 | minor | `.atn`: a recorded Save As imports with its format and file (`file.saveAs`, `file.saveACopy` for As a Copy) instead of as a plain Save that wrote over the played file, #7102; folder destinations stop playback until #5430 | | 2026-10-15 | minor | DDS textures save (#1327): uncompressed or BC1/BC2/BC3 (DXT1/3/5) from a clean-room block encoder, optional box-filtered mip chain, legacy header; DDS Options in Save As and Save a Copy, `ddsCompression`/`ddsMipmaps` for scripts, the CLI and MCP | | 2026-10-16 | minor | PSD smart filters: Perspective Warp (`perspectiveWarpTransform`: `vertices`, `warpedVertices`, `quads` of vertex indices, document pixels) opens as `layer.smartObjects.perspectiveWarp`, one plane per quad, and re-renders warped; save writes the original item with only the geometry rewritten, or a new one in Photoshop's layout; inconsistent descriptors stay verbatim (FILE-215-2, #6268) | | 2026-10-16 | minor | PSD smart filters: Hue/Saturation (`HStr`: `Clrz`, `Adjs` = master `Hst2` plus one per edited range with `LclR` and its four range sliders, all longs, measured on a Photoshop-saved file) opens as `image.adjustments.hueSaturation`, re-renders with the smart object and saves in Photoshop's layout; layouts outside it stay verbatim (FILE-215-2, #6267) | diff --git a/docs/gaps.md b/docs/gaps.md index 3c56d6d35a..13196b1323 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where PhotoCraft falls short of Photoshop -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-18 · **Change:** minor (G9: Preferences › File Handling › Save in Background takes effect, #6207, 24 of 169 preferences do nothing; G7: Content-Aware Move previews every selection the command takes, coarse then exact, TOOL-213-4 done, #6680; G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7; G9: Animated Zoom pref read: holding the Zoom tool zooms continuously, #6210, prefs that do nothing 25 of 166; G2: a cancelled 24 MP Gaussian Blur job stops in at most 44 ms, P25 under its 200 ms budget, #6205; G1: generated large-file fixtures, a 4.38 GB PSB opens on Windows through io, FILE-216-2 done, #5107; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-19 · **Change:** minor (G11: a recorded Save As imports with its format and file (`file.saveAs`, `file.saveACopy` for As a Copy) instead of as a plain Save that wrote over the played file, #7102; folder destinations stop playback until #5430; G9: Preferences › File Handling › Save in Background takes effect, #6207, 24 of 169 preferences do nothing; G7: Content-Aware Move previews every selection the command takes, coarse then exact, TOOL-213-4 done, #6680; G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7; G9: Animated Zoom pref read: holding the Zoom tool zooms continuously, #6210, prefs that do nothing 25 of 166; G2: a cancelled 24 MP Gaussian Blur job stops in at most 44 ms, P25 under its 200 ms budget, #6205; G1: generated large-file fixtures, a 4.38 GB PSB opens on Windows through io, FILE-216-2 done, #5107; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 @@ -106,6 +106,11 @@ what an agent can't finish alone. mapped events (paths, scripts, Generative Fill, Filter Gallery effects other than Spatter, Duplicate Layers into a new document, Bitmap halftone screens…) load as kept Photoshop steps that fail at playback by name. +- **Done 2026-10-17:** a recorded Save As imports with its format and destination file + (`file.saveAs`, or `file.saveACopy` for As a Copy) instead of as a plain Save, which wrote + over the file the action was played on (#7102). A folder destination, an unmapped format or a + mismatched extension stays a kept Photoshop step, so playback stops before writing; folder + saves wait for #5430. - **Done 2026-10-12:** Load/Save Actions `.atn` in the panel menu, `batch --actions set.atn` and `actions.load`/`actions.save`; 112 Photoshop events map to commands both ways (Transform, Apply Image, Save for Web, smart-object edits, Gradient Map, Quick Mask, polygon selections, @@ -287,6 +292,7 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| +| 2026-10-19 | minor | G11: a recorded Save As imports with its format and file (`file.saveAs`, `file.saveACopy` for As a Copy) instead of as a plain Save that wrote over the played file, #7102; folder destinations stop playback until #5430 | | 2026-10-15 | minor | G1 / #5972 A1: render only provably constant-RGB `GdFl` noise fills; variable noise synthesis remains open | | 2026-10-18 | minor | G9: with no selection, Copy takes fill and adjustment layers whole and Paste recreates them (#2344); UI-217-23 stays partial (a single pixel layer copies its pixels only); estimate unchanged | | 2026-10-15 | minor | G2: a cancelled 24 MP Gaussian Blur job stops within 44 ms max (P25, budget 200 ms; was about 400 ms), the uncancelled job about 40% faster; #6205 | From 5f0b8cb51ce0e8223ee444455da802c4b5678968 Mon Sep 17 00:00:00 2001 From: Jason White Date: Sat, 17 Oct 2026 22:22:47 +0100 Subject: [PATCH 192/649] fix(atn): write WebP saves with Photoshop's built-in WebP class Photoshop 2026 rejects the old WebPShop plug-in class and saves a PSD instead. WebPFormat is what it uses now, the plug-in classes still import. --- crates/engine/src/atn_cmds.rs | 5 ++++- crates/engine/src/atn_cmds/tests.rs | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/atn_cmds.rs b/crates/engine/src/atn_cmds.rs index d6f04fce86..bb1cfe075e 100644 --- a/crates/engine/src/atn_cmds.rs +++ b/crates/engine/src/atn_cmds.rs @@ -1550,13 +1550,16 @@ fn open_to(_: &str, p: &Value) -> Option { } /// Save As format classes (`As`) and the extensions PhotoCraft saves them under. The first -/// extension of a class is the one exported; WebP comes from Google's WebPShop plug-in. +/// extension of a class is the one exported, and the first class of an extension is the one +/// written back. `WebPFormat` is Photoshop's built-in WebP (checked against Photoshop 2026); the +/// Google classes come from the older WebPShop plug-in and are only read. const SAVE_FORMATS: &[(&str, &[&str])] = &[ ("Pht3", &["psd"]), ("PNGF", &["png"]), ("JPEG", &["jpg", "jpeg"]), ("TIFF", &["tif", "tiff"]), ("BMPF", &["bmp"]), + ("WebPFormat", &["webp"]), ("Google WebPShop", &["webp"]), ("Google WebP", &["webp"]), ]; diff --git a/crates/engine/src/atn_cmds/tests.rs b/crates/engine/src/atn_cmds/tests.rs index c85fdabb91..3148dadc64 100644 --- a/crates/engine/src/atn_cmds/tests.rs +++ b/crates/engine/src/atn_cmds/tests.rs @@ -1423,6 +1423,7 @@ fn save_as_to_a_file_imports_with_its_destination() { item("save", "Save", Some(save_as("PNGF", "/out/result.png"))), item("save", "Save", Some(save_as("Google WebPShop", "C:\\out\\result.webp").with("Cpy ", D::Boolean(true)))), item("save", "Save", Some(save_as("JPEG", "/out/result.jpeg"))), + item("save", "Save", Some(save_as("WebPFormat", "/out/result.webp"))), item("save", "Save", None), item("save", "Save", Some(desc("null").with("DocI", long(53.0)))), ]); @@ -1433,6 +1434,7 @@ fn save_as_to_a_file_imports_with_its_destination() { ("file.saveAs".to_string(), json!({"path": "/out/result.png"})), ("file.saveACopy".to_string(), json!({"path": "C:\\out\\result.webp"})), ("file.saveAs".to_string(), json!({"path": "/out/result.jpeg"})), + ("file.saveAs".to_string(), json!({"path": "/out/result.webp"})), ("file.save".to_string(), json!({})), ("file.save".to_string(), json!({})), ] @@ -1482,6 +1484,8 @@ fn saves_round_trip_through_photoshop_events() { assert_eq!(get_obj(first, "As ").map(|f| trimmed(&f.class_id)).as_deref(), Some("Pht3")); assert_eq!(first.get("In ").and_then(path_text).as_deref(), Some("/out/result.psd")); assert_eq!(get_bool(items[1].descriptor.as_ref().unwrap(), "Cpy "), Some(true)); + // Photoshop's own WebP class, not the plug-in's: Photoshop 2026 rejects `Google WebPShop`. + assert_eq!(get_obj(items[1].descriptor.as_ref().unwrap(), "As ").map(|f| trimmed(&f.class_id)).as_deref(), Some("WebPFormat")); assert_eq!(import(&bytes).unwrap().actions[0].steps, steps); // A Save As PhotoCraft can't express in Photoshop's terms is skipped, never exported as a From 81b917a6b8952e6cd5adac74931b9057f996edcb Mon Sep 17 00:00:00 2001 From: Jason White Date: Sun, 18 Oct 2026 21:05:00 +0100 Subject: [PATCH 193/649] fix(atn): don't read an odd Save As format as a plain Save If a recorded Save had an As field that wasn't a descriptor, it got treated like no format at all. With no destination that imported as a plain File > Save, which saves over the open file, and with one it went through as a Save As without checking the format. Both stay kept steps now so playback stops there. --- crates/engine/src/atn_cmds.rs | 14 ++++++++++---- crates/engine/src/atn_cmds/tests.rs | 5 ++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/atn_cmds.rs b/crates/engine/src/atn_cmds.rs index bb1cfe075e..66cc99a71d 100644 --- a/crates/engine/src/atn_cmds.rs +++ b/crates/engine/src/atn_cmds.rs @@ -1576,10 +1576,16 @@ fn path_extension(path: &str) -> Option { /// before writing rather than saving over the played file (#7102). fn save_from(d: &Descriptor) -> Mapped { let unsupported = Mapped::Unsupported { harmless: false }; - let (format, dest) = (get_obj(d, "As "), d.get("In ")); - if format.is_none() && dest.is_none() { - return step("file.save", json!({})); - } + let dest = d.get("In "); + let format = match d.get("As ") { + None if dest.is_none() => return step("file.save", json!({})), + None => None, + // A format that isn't a descriptor can't be checked against the destination. + Some(_) => match get_obj(d, "As ") { + Some(f) => Some(f), + None => return unsupported, + }, + }; let Some(path) = dest.and_then(path_text) else { return unsupported }; if get_bool(d, "DIDr") == Some(true) { return unsupported; diff --git a/crates/engine/src/atn_cmds/tests.rs b/crates/engine/src/atn_cmds/tests.rs index 3148dadc64..ff42da5e38 100644 --- a/crates/engine/src/atn_cmds/tests.rs +++ b/crates/engine/src/atn_cmds/tests.rs @@ -1452,10 +1452,13 @@ fn save_as_that_cannot_be_mapped_stops_playback_instead_of_saving_over_the_file( item("save", "Save", Some(save_as("PNGF", "/out/result.webp"))), item("save", "Save", Some(save_as("GIFf", "/out/result.gif"))), item("save", "Save", Some(desc("null").with("As ", D::Descriptor(desc("PNGF"))))), + // A format that isn't a descriptor, with and without a destination. + item("save", "Save", Some(desc("null").with("As ", long(1.0)))), + item("save", "Save", Some(desc("null").with("As ", long(1.0)).with("In ", path_value("/out/result.png")))), ]); let imp = import(&atn::write(&file).unwrap()).unwrap(); let ids: Vec<&str> = imp.actions[0].steps.iter().map(|(id, _)| id.as_str()).collect(); - assert_eq!(ids, [PHOTOSHOP_STEP; 5]); + assert_eq!(ids, [PHOTOSHOP_STEP; 7]); assert!(imp.actions[0].disabled.is_empty(), "kept saves stay on, so playback stops on them"); // The kept steps are written back byte for byte. let a = &imp.actions[0]; From 6fdbed2348b875840fd41e52aa1b10a3bf94d6a6 Mon Sep 17 00:00:00 2001 From: Jason White Date: Mon, 19 Oct 2026 10:48:31 +0100 Subject: [PATCH 194/649] fix(atn): keep a Save with a destination but no format A recorded Save with an In path and no As format was still imported as a Save As going by the file extension alone. Without the format there's nothing to check the destination against, so keep it as a Photoshop step and let playback stop there. --- crates/engine/src/atn_cmds.rs | 32 ++++++++++++----------------- crates/engine/src/atn_cmds/tests.rs | 4 +++- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/crates/engine/src/atn_cmds.rs b/crates/engine/src/atn_cmds.rs index 66cc99a71d..726aa93bf5 100644 --- a/crates/engine/src/atn_cmds.rs +++ b/crates/engine/src/atn_cmds.rs @@ -1571,32 +1571,26 @@ fn path_extension(path: &str) -> Option { } /// `save`: a plain Save, or a Save As (`As` format, `In` destination, `Cpy` As a Copy). -/// Only a destination that is a file of the recorded format imports: a folder (#5430), an -/// unknown format or a mismatched extension stays a kept Photoshop step, so playback stops +/// Only a destination that is a file of the recorded format imports: a folder (#5430), a missing +/// or unknown format or a mismatched extension stays a kept Photoshop step, so playback stops /// before writing rather than saving over the played file (#7102). fn save_from(d: &Descriptor) -> Mapped { let unsupported = Mapped::Unsupported { harmless: false }; - let dest = d.get("In "); - let format = match d.get("As ") { - None if dest.is_none() => return step("file.save", json!({})), - None => None, - // A format that isn't a descriptor can't be checked against the destination. - Some(_) => match get_obj(d, "As ") { - Some(f) => Some(f), - None => return unsupported, - }, - }; - let Some(path) = dest.and_then(path_text) else { return unsupported }; + if d.get("As ").is_none() && d.get("In ").is_none() { + return step("file.save", json!({})); + } + // A Save As needs a format descriptor to check the destination against: without one (or + // with a format that isn't a descriptor) the step is kept. + let Some(format) = get_obj(d, "As ") else { return unsupported }; + let Some(path) = d.get("In ").and_then(path_text) else { return unsupported }; if get_bool(d, "DIDr") == Some(true) { return unsupported; } let Some(ext) = path_extension(&path) else { return unsupported }; - if let Some(f) = format { - let class = trimmed(&f.class_id); - let Some((_, exts)) = SAVE_FORMATS.iter().find(|(c, _)| *c == class) else { return unsupported }; - if !exts.contains(&ext.as_str()) { - return unsupported; - } + let class = trimmed(&format.class_id); + let Some((_, exts)) = SAVE_FORMATS.iter().find(|(c, _)| *c == class) else { return unsupported }; + if !exts.contains(&ext.as_str()) { + return unsupported; } step(if get_bool(d, "Cpy ") == Some(true) { "file.saveACopy" } else { "file.saveAs" }, json!({"path": path})) } diff --git a/crates/engine/src/atn_cmds/tests.rs b/crates/engine/src/atn_cmds/tests.rs index ff42da5e38..a9a9076d4c 100644 --- a/crates/engine/src/atn_cmds/tests.rs +++ b/crates/engine/src/atn_cmds/tests.rs @@ -1455,10 +1455,12 @@ fn save_as_that_cannot_be_mapped_stops_playback_instead_of_saving_over_the_file( // A format that isn't a descriptor, with and without a destination. item("save", "Save", Some(desc("null").with("As ", long(1.0)))), item("save", "Save", Some(desc("null").with("As ", long(1.0)).with("In ", path_value("/out/result.png")))), + // A destination with no format at all. + item("save", "Save", Some(desc("null").with("In ", path_value("/out/result.png")))), ]); let imp = import(&atn::write(&file).unwrap()).unwrap(); let ids: Vec<&str> = imp.actions[0].steps.iter().map(|(id, _)| id.as_str()).collect(); - assert_eq!(ids, [PHOTOSHOP_STEP; 7]); + assert_eq!(ids, [PHOTOSHOP_STEP; 8]); assert!(imp.actions[0].disabled.is_empty(), "kept saves stay on, so playback stops on them"); // The kept steps are written back byte for byte. let a = &imp.actions[0]; From bf7dd539f5cb323cdae972000cedf8fae966f964 Mon Sep 17 00:00:00 2001 From: Jason D Date: Wed, 21 Oct 2026 11:25:23 -0400 Subject: [PATCH 195/649] codecs: read and write TIFF extra samples (spot and alpha channels) A TIFF's extra samples other than the image alpha (spot colours and further alpha channels, ExtraSamples 0) were dropped on decode, and the encoder could write only one alpha sample. They now travel through `Metadata::extra_samples`, one plane per sample with its ExtraSamples value as `kind`. - Decode: chunky and planar, strips and tiles, every depth, Gray, RGB, CMYK and Lab. At most 16 (`MAX_EXTRA_SAMPLES`) are kept; the planes count against `Limits::max_alloc` and are allocated fallibly. Layout and pixel data are unchanged: the first alpha sample (1 or 2) is still the image alpha. - Encode: extra samples follow the colour and alpha samples, with their kinds in the ExtraSamples tag; Lab as CIELab (float Lab at 16 bits). More than 16, or a plane of the wrong size, is an error. - `Image::convert` converts the planes with the sample type, and `Image::oriented` turns them with the image. - main's `extra_samples_that_are_not_alpha_are_dropped` becomes `extra_samples_that_are_not_alpha_are_kept_apart`: same inputs, same layout and data, and it now checks the extra planes. From #3121 (split out of #7415). Co-authored-by: Zer0C00L01 <12090083+Zer0C00L01@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/codecs/README.md | 11 +- crates/codecs/src/codecs/tiff.rs | 528 ++++++++++++++++++++++++-- crates/codecs/src/image.rs | 32 +- crates/codecs/src/lib.rs | 3 +- crates/codecs/src/orientation.rs | 6 + crates/codecs/tests/orientation.rs | 19 + crates/codecs/tests/tiff_lab.rs | 33 ++ crates/codecs/tests/tiff_pages.rs | 16 +- crates/codecs/tests/tiff_photoshop.rs | 181 +++++++++ 9 files changed, 790 insertions(+), 39 deletions(-) diff --git a/crates/codecs/README.md b/crates/codecs/README.md index 539365c95b..e3799d357b 100644 --- a/crates/codecs/README.md +++ b/crates/codecs/README.md @@ -187,8 +187,12 @@ embedded table (and a PNG's transparent entry) so `photocraft-io` can open them planar configuration 1 or 2. * Supports 1, 2 and 4-bit gray, 8/16/32/64-bit integers (32 and 64-bit are reduced to U16), F16, F32 and F64 (converted to F32), WhiteIsZero (#691: the tones are no longer inverted), - palette images (opened as RGB), associated alpha (made straight) and extra samples (dropped - unless the first is alpha). + palette images (opened as RGB) and associated alpha (made straight). + * Extra samples: the first alpha sample (ExtraSamples 1 or 2, wherever it sits) is the image's + alpha. Every other extra sample, such as a spot colour or a further alpha channel + (ExtraSamples 0), comes back in `Metadata::extra_samples`: one plane per sample in the + image's sample type, with its ExtraSamples value as `kind`. At most `MAX_EXTRA_SAMPLES` (16) + are kept, and they count against `Limits::max_alloc` with the image. * Every directory is reachable: `tiff_info` lists the main IFD chain and its SubIFDs (tag 330) with each page's size, kind (page, reduced-resolution copy, mask) and storage, walked with a seen-set, a depth limit and a 10 000-directory cap; `decode_tiff_page` opens any of them. @@ -202,7 +206,8 @@ embedded table (and a PNG's transparent entry) so `photocraft-io` can open them * YCbCr, CIE Lab, signed integers and compressions that the `tiff` crate lacks (CCITT, JPEG-in-TIFF) return `Unsupported`. * **TIFF encode** writes classic TIFF, or BigTIFF when `EncodeOptions::tiff_bigtiff` is set or - the file could pass 4 GiB. + the file could pass 4 GiB. `Metadata::extra_samples` (up to 16) are written after the colour + and alpha samples, with their `kind` in the ExtraSamples tag; more than 16 is an error. * **EXR** * Multi-part files (a Maya/Arnold render writes one part per AOV) open the part that looks most like a colour image — RGBA beats RGB beats YA beats a single channel, so a diff --git a/crates/codecs/src/codecs/tiff.rs b/crates/codecs/src/codecs/tiff.rs index 9528fec9c8..1cfa38bc10 100644 --- a/crates/codecs/src/codecs/tiff.rs +++ b/crates/codecs/src/codecs/tiff.rs @@ -249,7 +249,9 @@ pub(crate) fn decode_page(bytes: &[u8], page: Option, limits: &Limits) -> .ok_or_else(|| CodecError::InvalidImage(format!("TIFF page {index} does not exist (the file has {} directories)", info.pages.len())))?; let dir = file.ifd(p.ifd_offset).ok_or_else(|| err("image directory cut off"))?; let mut img = decode_ifd(&file, &dir, limits)?; + let extra_samples = std::mem::take(&mut img.meta.extra_samples); img.meta = metadata(&file, &dir, &mut img.icc); + img.meta.extra_samples = extra_samples; let pages = info.page_count(); if pages > 1 { img.warnings.push(DecodeWarning::MorePages { total: info.complete.then_some(u32::try_from(pages).unwrap_or(u32::MAX)) }); @@ -423,6 +425,8 @@ struct Layout { palette: Option>, /// Upper bound for one chunk's scratch buffer. scratch_cap: usize, + /// File sample indices that are neither colour nor the chosen alpha (spot / extra alpha). + extra_at: Vec, } impl Layout { @@ -436,6 +440,9 @@ impl Layout { fn out_row(&self) -> usize { self.w * self.out_channels() * self.out.bytes() } + fn extra_row(&self) -> usize { + self.w.saturating_mul(self.extra_at.len()).saturating_mul(self.out.bytes()) + } /// A chunky strip already in the output's layout: decoded in place. fn direct(&self) -> bool { self.copyable() && self.across == 1 @@ -543,13 +550,16 @@ fn decode_ifd(f: &File<'_>, dir: &Ifd, limits: &Limits) -> Result 3, 5 => 4, _ => 1, }; - let alpha_at = extra.iter().position(|&e| e == 1 || e == 2).filter(|&a| (color + a as u64) < spp); - let all_samples = palette.is_none() && matches!(photometric, 2 | 5 | 8 | 9) && alpha_at.is_some_and(|a| a > 0); + let alpha_at = extra.iter().position(|&e| e == 1 || e == 2).filter(|&a| (color as u64).saturating_add(a as u64) < spp); + // Samples the colour model does not keep. RGB, CMYK and Lab only hand back every sample when + // asked (photometric patched to black-is-zero below); gray already comes back as multiband. + let unused = !extra.is_empty() && (spp as usize) > color.saturating_add(usize::from(alpha_at.is_some())); + let all_samples = palette.is_none() && matches!(photometric, 2 | 5 | 8 | 9) && (alpha_at.is_some_and(|a| a > 0) || (!planar && unused)); let mut patches: Vec<(u64, Vec)> = Vec::new(); let encode_u = |v: u64, len: usize| -> Vec { let b = if f.le { v.to_le_bytes() } else { v.to_be_bytes() }; @@ -592,7 +602,31 @@ fn decode_ifd(f: &File<'_>, dir: &Ifd, limits: &Limits) -> Result (ChannelLayout::Rgb, 1), tiff::ColorType::Gray(_) => (ChannelLayout::Gray, 1), tiff::ColorType::Multiband { num_samples, .. } if all_samples => { - (if photometric == 5 { ChannelLayout::CmykA } else { ChannelLayout::Rgba }, usize::from(num_samples)) + // Lab reads as RGB here and is relabelled below. + let layout = match photometric { + 2 | 8 | 9 => { + if alpha_at.is_some() { + ChannelLayout::Rgba + } else { + ChannelLayout::Rgb + } + } + 5 => { + if alpha_at.is_some() { + ChannelLayout::CmykA + } else { + ChannelLayout::Cmyk + } + } + _ => { + if gray_alpha { + ChannelLayout::GrayA + } else { + ChannelLayout::Gray + } + } + }; + (layout, usize::from(num_samples)) } tiff::ColorType::Multiband { num_samples, .. } if photometric <= 1 => { (if gray_alpha { ChannelLayout::GrayA } else { ChannelLayout::Gray }, usize::from(num_samples)) @@ -661,6 +695,7 @@ fn decode_ifd(f: &File<'_>, dir: &Ifd, limits: &Limits) -> Result, dir: &Ifd, limits: &Limits) -> Result, dir: &Ifd, limits: &Limits) -> Result 0 { return Err(err("the image data is missing (cut off or past the end of the file)")); } @@ -693,6 +739,10 @@ fn decode_ifd(f: &File<'_>, dir: &Ifd, limits: &Limits) -> Result 0 { img.warnings.push(DecodeWarning::Truncated { format: F }); } @@ -728,6 +778,52 @@ fn convert_ab(data: &mut [u8], channels: usize, sample: SampleType, signed: bool } } +/// File sample indices that are not a colour channel and not the one alpha sample, capped at +/// [`crate::MAX_EXTRA_SAMPLES`]. +fn extra_sample_indices(spp: usize, color: usize, alpha_at: Option, has_alpha: bool) -> Vec { + let mut used = vec![false; spp]; + for i in 0..color.min(spp) { + if let Some(slot) = used.get_mut(i) { + *slot = true; + } + } + if has_alpha { + let a = alpha_at.map(|k| color.saturating_add(k)).unwrap_or(color); + if let Some(slot) = used.get_mut(a) { + *slot = true; + } + } + used.into_iter().enumerate().filter(|(_, on)| !*on).map(|(i, _)| i).take(crate::MAX_EXTRA_SAMPLES).collect() +} + +/// Interleaved extra samples (`extra_at.len()` per pixel) → one plane per sample. Each plane is +/// allocated fallibly (the caller has checked their total against the limits). +fn split_extra_samples( + buf: &[u8], + w: usize, + h: usize, + at: &[usize], + sample: SampleType, + mut kind_of: impl FnMut(usize) -> u16, +) -> Result, CodecError> { + let b = sample.bytes(); + let n = w.saturating_mul(h); + let spp = at.len(); + let mut out = Vec::with_capacity(spp); + for (ei, &si) in at.iter().enumerate() { + let mut data = zeroed(n.saturating_mul(b))?; + for i in 0..n { + let src = (i.saturating_mul(spp).saturating_add(ei)).saturating_mul(b); + let dst = i.saturating_mul(b); + if let (Some(s), Some(d)) = (buf.get(src..src.saturating_add(b)), data.get_mut(dst..dst.saturating_add(b))) { + d.copy_from_slice(s); + } + } + out.push(crate::ExtraSample { kind: kind_of(si), data }); + } + Ok(out) +} + /// A zero-filled buffer, allocated fallibly. On native targets the zeroing (and the first /// touch of every page, which dominates on a fresh multi-hundred-megabyte buffer) is spread over /// all cores. @@ -760,20 +856,43 @@ impl std::ops::Add for Tally { } /// Decodes every band into `data`, in parallel on native targets (one decoder and scratch -/// buffer per worker). +/// buffer per worker). `extra` receives samples that are not part of the colour image, one +/// band of rows at a time, when it is non-empty. #[cfg(not(target_arch = "wasm32"))] -fn decode_bands<'a, O>(lay: &Layout, data: &mut [u8], band_bytes: usize, _first: &mut Decoder>, open: &O) -> Result +fn decode_bands<'a, O>( + lay: &Layout, + data: &mut [u8], + band_bytes: usize, + extra: &mut [u8], + extra_band: usize, + _first: &mut Decoder>, + open: &O, +) -> Result where O: Fn() -> Result>, CodecError> + Sync, { use rayon::prelude::*; + if extra.is_empty() { + return data + .par_chunks_mut(band_bytes.max(1)) + .enumerate() + .map_init( + || open().map(|d| (d, Vec::new())).map_err(|e| e.to_string()), + |worker, (b, band)| { + let (dec, scratch) = worker.as_mut().map_err(|e| err(e.clone()))?; + decode_band(lay, dec, scratch, b, band, None) + }, + ) + .try_reduce(Tally::default, |a, b| Ok(a + b)); + } data.par_chunks_mut(band_bytes.max(1)) + .zip(extra.par_chunks_mut(extra_band.max(1))) .enumerate() .map_init( || open().map(|d| (d, Vec::new())).map_err(|e| e.to_string()), - |worker, (b, band)| { + |worker, (b, (band, extra_band))| { let (dec, scratch) = worker.as_mut().map_err(|e| err(e.clone()))?; - decode_band(lay, dec, scratch, b, band) + decode_band(lay, dec, scratch, b, band, Some(extra_band)) }, ) .try_reduce(Tally::default, |a, b| Ok(a + b)) @@ -781,20 +900,41 @@ where /// Decodes every band into `data`, one after the other. #[cfg(target_arch = "wasm32")] -fn decode_bands<'a, O>(lay: &Layout, data: &mut [u8], band_bytes: usize, first: &mut Decoder>, _open: &O) -> Result +fn decode_bands<'a, O>( + lay: &Layout, + data: &mut [u8], + band_bytes: usize, + extra: &mut [u8], + extra_band: usize, + first: &mut Decoder>, + _open: &O, +) -> Result where O: Fn() -> Result>, CodecError> + Sync, { let mut scratch = Vec::new(); let mut tally = Tally::default(); - for (b, band) in data.chunks_mut(band_bytes.max(1)).enumerate() { - tally = tally + decode_band(lay, first, &mut scratch, b, band)?; + if extra.is_empty() { + for (b, band) in data.chunks_mut(band_bytes.max(1)).enumerate() { + tally = tally + decode_band(lay, first, &mut scratch, b, band, None)?; + } + return Ok(tally); + } + for (b, (band, extra_band)) in data.chunks_mut(band_bytes.max(1)).zip(extra.chunks_mut(extra_band.max(1))).enumerate() { + tally = tally + decode_band(lay, first, &mut scratch, b, band, Some(extra_band))?; } Ok(tally) } /// Decodes band `b` (one strip, or one row of tiles, in every plane) into its output rows. -fn decode_band(lay: &Layout, dec: &mut Decoder>, scratch: &mut Vec, b: usize, band: &mut [u8]) -> Result { +fn decode_band( + lay: &Layout, + dec: &mut Decoder>, + scratch: &mut Vec, + b: usize, + band: &mut [u8], + mut extra: Option<&mut [u8]>, +) -> Result { let out_row = lay.out_row(); let rows = band.len() / out_row.max(1); let px = lay.out_channels() * lay.out.bytes(); @@ -836,16 +976,95 @@ fn decode_band(lay: &Layout, dec: &mut Decoder>, scratch: &mut Vec>, + scratch: &mut Vec, + b: usize, + rows: usize, + extra: Option<&mut [u8]>, + tally: &mut Tally, +) -> Result<(), CodecError> { + let Some(extra) = extra else { return Ok(()) }; + let ech = lay.extra_at.len(); + let erow = lay.extra_row(); + if ech == 0 || erow == 0 { + return Ok(()); + } + for (ei, &file_plane) in lay.extra_at.iter().enumerate() { + for col in 0..lay.across { + let chunk = file_plane + .checked_mul(lay.chunks_per_plane) + .and_then(|c| c.checked_add(b.checked_mul(lay.across)?)) + .and_then(|c| c.checked_add(col)) + .and_then(|c| u32::try_from(c).ok()) + .ok_or_else(|| err("chunk index out of range"))?; + let pref = dec.image_chunk_buffer_layout(chunk).map_err(map_err)?; + let stride = pref.row_stride.map(|s| s.get()).ok_or_else(|| err("empty chunk row"))?; + if pref.len > lay.scratch_cap { + return Err(CodecError::LimitExceeded(format!("a {} byte strip or tile", pref.len))); + } + if scratch.len() < pref.len { + scratch.resize(pref.len, 0); + } + let buf = scratch.get_mut(..pref.len).ok_or_else(|| err("scratch buffer"))?; + match dec.read_chunk_bytes(chunk, buf) { + Ok(()) => tally.decoded += 1, + Err(e) if is_eof(&e) => { + tally.missing += 1; + continue; + } + Err(e) => return Err(map_err(e)), + } + let x0 = col * lay.cw; + let n = lay.cw.min(lay.w.saturating_sub(x0)); + for (ri, src_row) in buf.chunks_exact(stride).take(rows).enumerate() { + let start = ri.saturating_mul(erow); + let Some(er) = extra.get_mut(start..start.saturating_add(erow)) else { continue }; + let px = ech * lay.out.bytes(); + let Some(dst) = er.get_mut(x0.saturating_mul(px)..(x0.saturating_add(n)).saturating_mul(px)) else { continue }; + transfer(lay.src, src_row, 1, 0, dst, lay.out, ech, ei, n); + } + } + } + Ok(()) +} + /// Converts `n` pixels of one decoded chunk row into output pixels (`plane` for planar data). fn convert_row(lay: &Layout, src: &[u8], dst: &mut [u8], n: usize, plane: usize) { let och = lay.out_channels(); @@ -1072,6 +1291,214 @@ custom_colortype!(Lab16, u16, PI::CIELab, &[16; 3], &[SampleFormat::Uint; 3], in custom_colortype!(LabA8, u8, PI::CIELab, &[8; 4], &[SampleFormat::Uint; 4], int); custom_colortype!(LabA16, u16, PI::CIELab, &[16; 4], &[SampleFormat::Uint; 4], int); +// Colour types with 1..=MAX_EXTRA_SAMPLES trailing extra samples (spot channels, extra alpha). +// One generic type per (sample, photometric, bit depth, total sample count) instead of a +// hand-written type for every layout. `N` is the total sample count, not the extra count. +const fn extra_photo(v: u16) -> PhotometricInterpretation { + match v { + 1 => PhotometricInterpretation::BlackIsZero, + 2 => PhotometricInterpretation::RGB, + 5 => PhotometricInterpretation::CMYK, + 8 => PhotometricInterpretation::CIELab, + _ => PhotometricInterpretation::RGB, + } +} + +trait ExtraKind: Copy + TiffValue + 'static { + const FORMAT: SampleFormat; + fn predict(row: &[Self], out: &mut Vec, samples: usize); +} + +impl ExtraKind for u8 { + const FORMAT: SampleFormat = SampleFormat::Uint; + fn predict(row: &[Self], out: &mut Vec, samples: usize) { + let n = samples.min(row.len()); + out.extend_from_slice(&row[..n]); + out.extend(row.iter().zip(&row[n..]).map(|(prev, current)| current.wrapping_sub(*prev))); + } +} + +impl ExtraKind for u16 { + const FORMAT: SampleFormat = SampleFormat::Uint; + fn predict(row: &[Self], out: &mut Vec, samples: usize) { + let n = samples.min(row.len()); + out.extend_from_slice(&row[..n]); + out.extend(row.iter().zip(&row[n..]).map(|(prev, current)| current.wrapping_sub(*prev))); + } +} + +impl ExtraKind for f32 { + const FORMAT: SampleFormat = SampleFormat::IEEEFP; + fn predict(row: &[Self], out: &mut Vec, _samples: usize) { + out.extend_from_slice(row); + } +} + +struct Extras(std::marker::PhantomData); + +impl TiffColorType for Extras +where + T: ExtraKind, +{ + type Inner = T; + const TIFF_VALUE: PhotometricInterpretation = extra_photo(PHOTO); + const BITS_PER_SAMPLE: &'static [u16] = &[BITS; N]; + const SAMPLE_FORMAT: &'static [SampleFormat] = &[T::FORMAT; N]; + fn horizontal_predict(row: &[Self::Inner], result: &mut Vec) { + T::predict(row, result, N); + } +} + +macro_rules! write_extras { + ($n:expr, $enc:expr, $w:expr, $h:expr, $data:expr, $tags:expr, $sample:ty, $photo:literal, $bits:literal, $base:literal) => { + match $n { + 1 => write_one::, K>($enc, $w, $h, $data, $tags), + 2 => write_one::, K>($enc, $w, $h, $data, $tags), + 3 => write_one::, K>($enc, $w, $h, $data, $tags), + 4 => write_one::, K>($enc, $w, $h, $data, $tags), + 5 => write_one::, K>($enc, $w, $h, $data, $tags), + 6 => write_one::, K>($enc, $w, $h, $data, $tags), + 7 => write_one::, K>($enc, $w, $h, $data, $tags), + 8 => write_one::, K>($enc, $w, $h, $data, $tags), + 9 => write_one::, K>($enc, $w, $h, $data, $tags), + 10 => write_one::, K>($enc, $w, $h, $data, $tags), + 11 => write_one::, K>($enc, $w, $h, $data, $tags), + 12 => write_one::, K>($enc, $w, $h, $data, $tags), + 13 => write_one::, K>($enc, $w, $h, $data, $tags), + 14 => write_one::, K>($enc, $w, $h, $data, $tags), + 15 => write_one::, K>($enc, $w, $h, $data, $tags), + 16 => write_one::, K>($enc, $w, $h, $data, $tags), + other => Err(io::Error::new(io::ErrorKind::InvalidInput, format!("unsupported extra samples ({other})")).into()), + } + }; +} + +fn bytes_as_u16(b: &[u8]) -> Vec { + b.as_chunks::<2>().0.iter().map(|c| u16::from_ne_bytes(*c)).collect() +} + +fn bytes_as_f32(b: &[u8]) -> Vec { + b.as_chunks::<4>().0.iter().map(|c| f32::from_ne_bytes(*c)).collect() +} + +/// Interleaves colour (and alpha) samples with [`Metadata::extra_samples`]. +fn interleave_extras(img: &Image) -> Result, String> { + let (w, h) = img.dimensions(); + let n = (w as usize).checked_mul(h as usize).ok_or_else(|| "image size overflows".to_string())?; + let sb = img.sample_type().bytes(); + let ch = img.layout().channels(); + let extras = &img.meta.extra_samples; + let total = ch.checked_add(extras.len()).ok_or_else(|| "too many samples".to_string())?; + let px = total.checked_mul(sb).ok_or_else(|| "sample size overflows".to_string())?; + let mut out = vec![0u8; n.checked_mul(px).ok_or_else(|| "image size overflows".to_string())?]; + let base = img.data(); + let base_px = ch.saturating_mul(sb); + for i in 0..n { + let src = i.saturating_mul(base_px); + let dst = i.saturating_mul(px); + let Some(s) = base.get(src..src.saturating_add(base_px)) else { + return Err("image buffer is shorter than its dimensions".into()); + }; + let Some(d) = out.get_mut(dst..dst.saturating_add(base_px)) else { + return Err("extra-sample buffer is short".into()); + }; + d.copy_from_slice(s); + for (k, e) in extras.iter().enumerate() { + let es = i.saturating_mul(sb); + let ed = dst.saturating_add(base_px).saturating_add(k.saturating_mul(sb)); + let Some(s) = e.data.get(es..es.saturating_add(sb)) else { + return Err(format!("extra sample {k} is shorter than the image")); + }; + let Some(d) = out.get_mut(ed..ed.saturating_add(sb)) else { + return Err("extra-sample buffer is short".into()); + }; + d.copy_from_slice(s); + } + } + Ok(out) +} + +fn write_with_extras(enc: &mut TiffEncoder<&mut Cursor>, K>, img: &Image, tags: &TagSet<'_>) -> tiff::TiffResult<()> { + use ChannelLayout as L; + use SampleType as S; + let (w, h) = img.dimensions(); + let n = img.meta.extra_samples.len(); + if img.layout().is_lab() { + let file = lab_file(img); + let bytes = interleave_extras(&file).map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?; + return match (file.layout(), file.sample_type()) { + (L::Lab, S::U8) => write_extras!(n, enc, w, h, &bytes, tags, u8, 8, 8, 3), + (L::Lab, _) => { + let v = bytes_as_u16(&bytes); + write_extras!(n, enc, w, h, &v, tags, u16, 8, 16, 3) + } + (_, S::U8) => write_extras!(n, enc, w, h, &bytes, tags, u8, 8, 8, 4), + _ => { + let v = bytes_as_u16(&bytes); + write_extras!(n, enc, w, h, &v, tags, u16, 8, 16, 4) + } + }; + } + let bytes = interleave_extras(img).map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?; + match (img.layout(), img.sample_type()) { + (L::Gray, S::U8) => write_extras!(n, enc, w, h, &bytes, tags, u8, 1, 8, 1), + (L::Gray, S::U16) => { + let v = bytes_as_u16(&bytes); + write_extras!(n, enc, w, h, &v, tags, u16, 1, 16, 1) + } + (L::Gray, S::F32) => { + let v = bytes_as_f32(&bytes); + write_extras!(n, enc, w, h, &v, tags, f32, 1, 32, 1) + } + (L::GrayA, S::U8) => write_extras!(n, enc, w, h, &bytes, tags, u8, 1, 8, 2), + (L::GrayA, S::U16) => { + let v = bytes_as_u16(&bytes); + write_extras!(n, enc, w, h, &v, tags, u16, 1, 16, 2) + } + (L::GrayA, S::F32) => { + let v = bytes_as_f32(&bytes); + write_extras!(n, enc, w, h, &v, tags, f32, 1, 32, 2) + } + (L::Rgb, S::U8) => write_extras!(n, enc, w, h, &bytes, tags, u8, 2, 8, 3), + (L::Rgb, S::U16) => { + let v = bytes_as_u16(&bytes); + write_extras!(n, enc, w, h, &v, tags, u16, 2, 16, 3) + } + (L::Rgb, S::F32) => { + let v = bytes_as_f32(&bytes); + write_extras!(n, enc, w, h, &v, tags, f32, 2, 32, 3) + } + (L::Rgba, S::U8) => write_extras!(n, enc, w, h, &bytes, tags, u8, 2, 8, 4), + (L::Rgba, S::U16) => { + let v = bytes_as_u16(&bytes); + write_extras!(n, enc, w, h, &v, tags, u16, 2, 16, 4) + } + (L::Rgba, S::F32) => { + let v = bytes_as_f32(&bytes); + write_extras!(n, enc, w, h, &v, tags, f32, 2, 32, 4) + } + (L::Cmyk, S::U8) => write_extras!(n, enc, w, h, &bytes, tags, u8, 5, 8, 4), + (L::Cmyk, S::U16) => { + let v = bytes_as_u16(&bytes); + write_extras!(n, enc, w, h, &v, tags, u16, 5, 16, 4) + } + (L::Cmyk, S::F32) => { + let v = bytes_as_f32(&bytes); + write_extras!(n, enc, w, h, &v, tags, f32, 5, 32, 4) + } + (L::CmykA, S::U8) => write_extras!(n, enc, w, h, &bytes, tags, u8, 5, 8, 5), + (L::CmykA, S::U16) => { + let v = bytes_as_u16(&bytes); + write_extras!(n, enc, w, h, &v, tags, u16, 5, 16, 5) + } + (L::CmykA, S::F32) => { + let v = bytes_as_f32(&bytes); + write_extras!(n, enc, w, h, &v, tags, f32, 5, 32, 5) + } + _ => Err(io::Error::new(io::ErrorKind::InvalidInput, format!("unsupported extra samples ({n})")).into()), + } +} + struct TagSet<'a> { icc: Option<&'a [u8]>, /// The EXIF block's directories and IFD0 tags, written as the TIFF's own. @@ -1079,7 +1506,8 @@ struct TagSet<'a> { xmp: Option<&'a [u8]>, dpi: Option<(f32, f32)>, text: Vec<(Tag, &'a str)>, - alpha: bool, + /// ExtraSamples tag, including the unassociated-alpha marker when the image has alpha. + extra_samples: &'a [u16], photoshop_resources: Option<&'a [u8]>, photoshop_layers: Option<&'a [u8]>, } @@ -1109,9 +1537,8 @@ where im.y_resolution(Rational { n: (y * 1000.0).round() as u32, d: 1000 }); } let d = im.encoder(); - if tags.alpha { - // 2 = unassociated alpha - d.write_tag(Tag::ExtraSamples, &[2u16][..])?; + if !tags.extra_samples.is_empty() { + d.write_tag(Tag::ExtraSamples, tags.extra_samples)?; } if let Some(icc) = tags.icc { d.write_tag(Tag::IccProfile, Undefined(icc))?; @@ -1142,10 +1569,24 @@ where im.write_data(data) } +/// A Lab image as CIELab stores it: a* and b* signed, 8 or 16 bits (CIELab has no float form: +/// 32-bit Lab is written with 16 bits). Extra samples follow the new sample type. +fn lab_file(img: &Image) -> Image { + let sample = if img.sample_type() == SampleType::U8 { SampleType::U8 } else { SampleType::U16 }; + // `convert` brings the extra samples to the new sample type with the image. + let mut file = img.convert(img.layout(), sample); + let channels = file.layout().channels(); + convert_ab(file.data_mut(), channels, sample, true, true); + file +} + /// Writes the image with the colour type matching its layout and sample type. fn write_image(enc: &mut TiffEncoder<&mut Cursor>, K>, img: &Image, tags: &TagSet<'_>) -> tiff::TiffResult<()> { use ChannelLayout as L; use SampleType as S; + if !img.meta.extra_samples.is_empty() { + return write_with_extras::(enc, img, tags); + } let (w, h) = img.dimensions(); let u16s = || img.to_u16_samples().unwrap_or_default(); let f32s = || img.to_f32_samples().unwrap_or_default(); @@ -1170,13 +1611,9 @@ fn write_image(enc: &mut TiffEncoder<&mut Cursor>, K>, img: (L::CmykA, S::U16) => write_one::(enc, w, h, &u16s(), tags), (L::CmykA, S::F32) => write_one::(enc, w, h, &f32s(), tags), (L::Lab | L::LabA, _) => { - // CIELab has no float form: 32-bit Lab is written with 16 bits. - let sample = if img.sample_type() == S::U8 { S::U8 } else { S::U16 }; - let mut file = img.convert(img.layout(), sample); - let channels = file.layout().channels(); - convert_ab(file.data_mut(), channels, sample, true, true); + let file = lab_file(img); let u16s = || file.to_u16_samples().unwrap_or_default(); - match (file.layout(), sample) { + match (file.layout(), file.sample_type()) { (L::Lab, S::U8) => write_one::(enc, w, h, file.data(), tags), (L::Lab, _) => write_one::(enc, w, h, &u16s(), tags), (_, S::U8) => write_one::(enc, w, h, file.data(), tags), @@ -1198,11 +1635,16 @@ fn estimated_size(img: &Image, tags: &TagSet<'_>) -> u64 { + tags.exif.iter().flat_map(|e| e.ifd0.iter().chain(&e.exif).chain(&e.gps)).map(|f| f.value.len() as u64 + 12).sum::(); // Strip tables: one offset and one count per strip of about 1 MB. let tables = (img.data().len() as u64 / (1 << 20) + 1) * 16; - (img.data().len() as u64).saturating_add(payloads).saturating_add(text).saturating_add(tables).saturating_add(1 << 20) + let extras: u64 = img.meta.extra_samples.iter().map(|e| e.data.len() as u64).sum(); + (img.data().len() as u64).saturating_add(extras).saturating_add(payloads).saturating_add(text).saturating_add(tables).saturating_add(1 << 20) } pub(crate) fn encode(src: &Image, plan: Plan, opts: &EncodeOptions) -> Result, CodecError> { - let img = src.converted(plan.layout, plan.sample); + // `converted` brings the extra samples to the plan's sample type with the image. + encode_ready(&src.converted(plan.layout, plan.sample), opts) +} + +fn encode_ready(img: &Image, opts: &EncodeOptions) -> Result, CodecError> { let compression = match opts.tiff_compression { TiffCompression::None => tiff::encoder::Compression::Uncompressed, TiffCompression::Lzw => tiff::encoder::Compression::Lzw, @@ -1226,13 +1668,23 @@ pub(crate) fn encode(src: &Image, plan: Plan, opts: &EncodeOptions) -> Result crate::MAX_EXTRA_SAMPLES { + return Err(CodecError::encode(F, format!("TIFF stores at most {} extra samples", crate::MAX_EXTRA_SAMPLES))); + } + let mut kinds = Vec::with_capacity(img.meta.extra_samples.len().saturating_add(1)); + if img.layout().has_alpha() { + kinds.push(2); + } + for e in &img.meta.extra_samples { + kinds.push(e.kind); + } let tags = TagSet { icc: if opts.embed_icc { img.icc.as_deref() } else { None }, exif: if opts.embed_metadata { img.meta.exif.as_deref().and_then(|e| tiff_exif::read(crate::orientation::tiff_body(e))) } else { None }, xmp: xmp.as_deref().map(str::as_bytes), dpi: if opts.embed_metadata { img.meta.dpi.filter(|d| d.0 > 0.0 && d.1 > 0.0) } else { None }, text, - alpha: img.layout().has_alpha(), + extra_samples: &kinds, // Document content, not metadata: written whenever present. photoshop_resources: img.meta.photoshop_resources.as_deref().filter(|r| !r.is_empty()), photoshop_layers: img.meta.photoshop_layers.as_deref().filter(|l| !l.is_empty()), @@ -1245,17 +1697,33 @@ pub(crate) fn encode(src: &Image, plan: Plan, opts: &EncodeOptions) -> Result(&mut enc, &img, &tags)?; + write_image::(&mut enc, img, &tags)?; } else { let mut enc = TiffEncoder::new(&mut cursor)?.with_compression(compression).with_predictor(predictor); - write_image::(&mut enc, &img, &tags)?; + write_image::(&mut enc, img, &tags)?; } Ok(cursor.into_inner()) }; - let big = opts.tiff_bigtiff || estimated_size(&img, &tags) > CLASSIC_LIMIT; + let big = opts.tiff_bigtiff || estimated_size(img, &tags) > CLASSIC_LIMIT; match write(big) { Ok(v) => Ok(v), Err(tiff::TiffError::IntSizeError) if !big => write(true).map_err(|e| CodecError::encode(F, e)), Err(e) => Err(CodecError::encode(F, e)), } } + +#[cfg(test)] +mod bits_len { + use super::Extras; + use tiff::encoder::colortype::ColorType as TiffColorType; + + #[test] + fn const_generic_sample_tables_have_one_entry_per_sample() { + // A repeat expression in an associated const (`&[BITS; N]`) has, on some compilers, + // promoted to a slice shorter than `N`. The encoder sizes every strip from that length. + assert_eq!( as TiffColorType>::BITS_PER_SAMPLE.len(), 4, "{:?}", as TiffColorType>::BITS_PER_SAMPLE); + assert_eq!( as TiffColorType>::BITS_PER_SAMPLE.len(), 5); + assert_eq!( as TiffColorType>::BITS_PER_SAMPLE.len(), 19); + assert_eq!( as TiffColorType>::SAMPLE_FORMAT.len(), 6); + } +} diff --git a/crates/codecs/src/image.rs b/crates/codecs/src/image.rs index 5a03e7d283..a15ab72779 100644 --- a/crates/codecs/src/image.rs +++ b/crates/codecs/src/image.rs @@ -145,6 +145,24 @@ pub struct Metadata { /// Photoshop layer data (TIFF tag 37724 `ImageSourceData`): a layered TIFF's layers. Kept /// opaque here; `photocraft-io` reads and writes it through `photocraft-psd`. pub photoshop_layers: Option>, + /// Samples per pixel beyond the colour channels and the one alpha sample. TIFF extra + /// samples (spot colours, extra alpha channels) the pixel layout does not hold. Each entry + /// is one sample per pixel, native endian, in the image's [`SampleType`], row-major. + pub extra_samples: Vec, +} + +/// How many extra TIFF samples an encoded file may carry. Decoders keep at most this many. +/// Sixteen covers a UV-DTF stack (white, varnish, gloss, primer, and further spots) without +/// approaching the PSD 56-channel limit. +pub const MAX_EXTRA_SAMPLES: usize = 16; + +/// One TIFF extra sample (a spot channel or an alpha channel that is not the image alpha). +#[derive(Debug, Clone, PartialEq)] +pub struct ExtraSample { + /// TIFF ExtraSamples value: 0 unspecified, 1 associated alpha, 2 unassociated alpha. + pub kind: u16, + /// One sample per pixel, native endian, same sample type as the image. + pub data: Vec, } impl Metadata { @@ -155,6 +173,7 @@ impl Metadata { && self.text.is_empty() && self.photoshop_resources.is_none() && self.photoshop_layers.is_none() + && self.extra_samples.is_empty() } } @@ -639,6 +658,17 @@ impl Image { let values = convert_layout(&src, self.layout, layout); quantize(&values, sample) }; + let mut meta = self.meta.clone(); + if sample != self.sample { + // Extra samples are stored in the image's sample type, so they convert with it. A + // plane of the wrong size is left as it is: importers drop it with a warning. + let plane_len = (self.width as usize).saturating_mul(self.height as usize).saturating_mul(self.sample.bytes()); + for e in meta.extra_samples.iter_mut().filter(|e| e.data.len() == plane_len) { + if let Ok(plane) = Image::from_raw(self.width, self.height, ChannelLayout::Gray, self.sample, std::mem::take(&mut e.data)) { + e.data = plane.convert(ChannelLayout::Gray, sample).data; + } + } + } Image { width: self.width, height: self.height, @@ -646,7 +676,7 @@ impl Image { sample, data, icc: if layout.same_model(self.layout) { self.icc.clone() } else { None }, - meta: self.meta.clone(), + meta, warnings: self.warnings.clone(), } } diff --git a/crates/codecs/src/lib.rs b/crates/codecs/src/lib.rs index 8c06694b9a..5c0e37b0db 100644 --- a/crates/codecs/src/lib.rs +++ b/crates/codecs/src/lib.rs @@ -36,7 +36,8 @@ pub use crate::exif_color::{EXIF_COLOR_SPACE_SRGB, exif_color_space}; pub use crate::fidelity::{FidelityWarning, fidelity_warnings, fidelity_warnings_with}; pub use crate::format::{ASYMMETRIC_EXCEPTIONS, Format, FormatCaps, caps, detect, from_extension}; pub use crate::image::{ - ChannelLayout, CryptomatteBuffer, CryptomatteLayer, DecodeWarning, DeepChannel, DeepImage, ExrChannelInfo, ExrPartInfo, Image, Metadata, SampleType, + ChannelLayout, CryptomatteBuffer, CryptomatteLayer, DecodeWarning, DeepChannel, DeepImage, ExrChannelInfo, ExrPartInfo, ExtraSample, Image, + MAX_EXTRA_SAMPLES, Metadata, SampleType, }; pub use crate::options::{ DdsCompression, DdsOptions, DecodeOptions, DpxBits, EncodeOptions, ExrCompression, Limits, PngCompression, PngStereo, TiffCompression, diff --git a/crates/codecs/src/orientation.rs b/crates/codecs/src/orientation.rs index 3d10d5ddea..7f31a6b271 100644 --- a/crates/codecs/src/orientation.rs +++ b/crates/codecs/src/orientation.rs @@ -331,6 +331,12 @@ impl Image { } let data = orient_bytes(self.data(), bpp, o, (w, h), ow)?; let mut meta = self.meta.clone(); + // Extra samples (a TIFF's alpha and spot planes, one sample a pixel) turn with the image. + // A plane of the wrong size is left as it is: importers drop it with a warning. + let plane_len = w.saturating_mul(h).saturating_mul(sample.bytes()); + for e in meta.extra_samples.iter_mut().filter(|e| e.data.len() == plane_len) { + e.data = orient_bytes(&e.data, sample.bytes(), o, (w, h), ow)?; + } if let Some(e) = &mut meta.exif && let Cow::Owned(fixed) = upright_exif(e) { diff --git a/crates/codecs/tests/orientation.rs b/crates/codecs/tests/orientation.rs index c1f176b87c..0532b44066 100644 --- a/crates/codecs/tests/orientation.rs +++ b/crates/codecs/tests/orientation.rs @@ -211,6 +211,25 @@ fn png_opens_upright_for_every_orientation() { } } +/// Extra samples (a TIFF's alpha and spot planes) turn with the image, so a channel stays +/// aligned with the pixels for every orientation. +#[test] +fn extra_samples_turn_with_the_image() { + let (w, h) = (4, 7); + let up = exact_scene(w, h); + let up_extra: Vec = up.iter().map(|v| 255 - v).collect(); + for o in 1..=8u16 { + let (s, sw, sh) = stored(&up, w, h, o); + let (s_extra, _, _) = stored(&up_extra, w, h, o); + let mut img = gray(sw, sh, s); + img.meta.extra_samples = vec![ExtraSample { kind: 0, data: s_extra }]; + let turned = img.oriented(o).unwrap(); + assert_eq!(turned.data(), &up[..], "o={o}"); + assert_eq!(turned.meta.extra_samples.len(), 1, "o={o}"); + assert_eq!(turned.meta.extra_samples[0].data, up_extra, "o={o}"); + } +} + #[test] fn tiff_opens_upright_for_every_orientation() { let (w, h) = (4, 7); diff --git a/crates/codecs/tests/tiff_lab.rs b/crates/codecs/tests/tiff_lab.rs index 7076633ef5..9e41ef80b2 100644 --- a/crates/codecs/tests/tiff_lab.rs +++ b/crates/codecs/tests/tiff_lab.rs @@ -74,3 +74,36 @@ fn lab_converts_to_rgb_for_other_formats() { assert_eq!(&p[4..7], &[255, 255, 255], "white"); assert!(p[0] > 180 && p[1] < 120 && p[2] > 140, "L 50, a 50, b −30 is a magenta-ish purple: {:?}", &p[..3]); } + +#[test] +fn lab_keeps_extra_samples() { + // A spot plate next to Lab: written as CIELab plus one unspecified extra sample, and read + // back as Lab with the spot (not as LabA). + for (layout, sample) in [(ChannelLayout::Lab, SampleType::U8), (ChannelLayout::LabA, SampleType::U16)] { + let px: Vec = + [lab(50.0, 50.0, -30.0), lab(100.0, 0.0, 0.0)].iter().flat_map(|p| p.iter().copied().chain(layout.has_alpha().then_some(0.5))).collect(); + let mut img = Image::from_normalized(2, 1, layout, sample, &px).unwrap(); + let spot: Vec = (0..2 * sample.bytes()).map(|i| (i * 37 + 5) as u8).collect(); + img.meta.extra_samples = vec![ExtraSample { kind: 0, data: spot.clone() }]; + let file = uncompressed(&img); + if layout == ChannelLayout::Lab { + assert!(find(&file, &[128, 50, (-30i8) as u8, spot[0], 255, 0, 0, spot[1]]).is_some(), "CIELab samples with the spot"); + } + let back = decode(&file).unwrap(); + assert_eq!((back.layout(), back.sample_type()), (layout, sample)); + let (a, b) = (img.to_normalized(), back.to_normalized()); + assert!(a.iter().zip(&b).all(|(x, y)| (x - y).abs() <= 1.5 / 65535.0), "{layout:?}: {a:?} {b:?}"); + assert_eq!(back.meta.extra_samples, vec![ExtraSample { kind: 0, data: spot }], "{layout:?}"); + } +} + +#[test] +fn float_lab_writes_its_extra_samples_with_16_bits() { + let px: Vec = [lab(50.0, 50.0, -30.0), lab(100.0, 0.0, 0.0)].concat(); + let mut img = Image::from_normalized(2, 1, ChannelLayout::Lab, SampleType::F32, &px).unwrap(); + img.meta.extra_samples = vec![ExtraSample { kind: 0, data: [0.25f32, 1.0].iter().flat_map(|v| v.to_ne_bytes()).collect() }]; + let back = decode(&uncompressed(&img)).unwrap(); + assert_eq!((back.layout(), back.sample_type()), (ChannelLayout::Lab, SampleType::U16)); + let spot: Vec = [16384u16, 65535].iter().flat_map(|v| v.to_ne_bytes()).collect(); + assert_eq!(back.meta.extra_samples, vec![ExtraSample { kind: 0, data: spot }]); +} diff --git a/crates/codecs/tests/tiff_pages.rs b/crates/codecs/tests/tiff_pages.rs index 60885e527d..dce4317a8c 100644 --- a/crates/codecs/tests/tiff_pages.rs +++ b/crates/codecs/tests/tiff_pages.rs @@ -128,13 +128,16 @@ fn planar_strips_at_every_depth() { } } +/// Extra samples that are not the alpha (ExtraSamples 0: a spot colour or an extra channel) are +/// not part of the image: they come back in `meta.extra_samples`, one plane each. #[test] -fn extra_samples_that_are_not_alpha_are_dropped() { +fn extra_samples_that_are_not_alpha_are_kept_apart() { let (w, h) = (5usize, 3usize); let t = truth(w * h * 5, 4); let rgb_of = |spp: usize, keep: usize| -> Vec { t.u8s[..w * h * spp].chunks(spp).flat_map(|p| p[..keep].to_vec()).collect() }; + let extra = |spp: usize, at: usize| vec![ExtraSample { kind: 0, data: t.u8s[..w * h * spp].chunks(spp).map(|p| p[at]).collect() }]; for planar in [false, true] { - // RGB + one unspecified extra sample: RGB. + // RGB + one unspecified extra sample: RGB, and the sample as an extra plane. let px = &t.u8s[..w * h * 4]; let chunks = if planar { planar_strips(px, w, h, 4, 1, 2) } else { px.chunks(w * 4 * 2).map(<[u8]>::to_vec).collect() }; let mut d = Dir { entries: base(w as u32, h as u32, 8, 4, 2), chunks, tiled: false }.tag(278, LONG, &[2]).tag(338, SHORT, &[0]); @@ -144,7 +147,8 @@ fn extra_samples_that_are_not_alpha_are_dropped() { let img = decode_ok(&build(true, false, &[d], &[0]).bytes); assert_eq!(img.layout(), ChannelLayout::Rgb); assert_eq!(img.data(), &rgb_of(4, 3)[..], "planar {planar}"); - // RGB + alpha + an unspecified extra sample: RGBA. + assert_eq!(img.meta.extra_samples, extra(4, 3), "planar {planar}"); + // RGB + alpha + an unspecified extra sample: RGBA and one extra plane. let px = &t.u8s[..w * h * 5]; let chunks = if planar { planar_strips(px, w, h, 5, 1, 2) } else { px.chunks(w * 5 * 2).map(<[u8]>::to_vec).collect() }; let mut d = Dir { entries: base(w as u32, h as u32, 8, 5, 2), chunks, tiled: false }.tag(278, LONG, &[2]).tag(338, SHORT, &[2, 0]); @@ -154,18 +158,22 @@ fn extra_samples_that_are_not_alpha_are_dropped() { let img = decode_ok(&build(false, true, &[d], &[0]).bytes); assert_eq!(img.layout(), ChannelLayout::Rgba); assert_eq!(img.data(), &rgb_of(5, 4)[..], "planar {planar}"); + assert_eq!(img.meta.extra_samples, extra(5, 4), "planar {planar}"); } - // Gray + alpha + extra: gray and alpha; gray + an unspecified extra: gray. + // Gray + alpha + extra: gray and alpha; gray + an unspecified extra: gray. Each keeps the + // extra sample as a plane. let px = &t.u8s[..w * h * 3]; let d = strips(w as u32, h as u32, 8, 3, 1, 3, px).tag(338, SHORT, &[2, 0]); let img = decode_ok(&build(true, false, &[d], &[0]).bytes); assert_eq!(img.layout(), ChannelLayout::GrayA); assert_eq!(img.data(), &rgb_of(3, 2)[..]); + assert_eq!(img.meta.extra_samples, extra(3, 2)); let px = &t.u8s[..w * h * 2]; let d = strips(w as u32, h as u32, 8, 2, 1, 3, px).tag(338, SHORT, &[0]); let img = decode_ok(&build(true, false, &[d], &[0]).bytes); assert_eq!(img.layout(), ChannelLayout::Gray); assert_eq!(img.data(), &rgb_of(2, 1)[..]); + assert_eq!(img.meta.extra_samples, extra(2, 1)); } #[test] diff --git a/crates/codecs/tests/tiff_photoshop.rs b/crates/codecs/tests/tiff_photoshop.rs index 400b72eb0c..82f4b74e7d 100644 --- a/crates/codecs/tests/tiff_photoshop.rs +++ b/crates/codecs/tests/tiff_photoshop.rs @@ -41,6 +41,187 @@ fn tags_round_trip_through_the_encoder() { } } +#[test] +fn extra_samples_round_trip() { + for (layout, sample) in [ + (ChannelLayout::Rgb, SampleType::U8), + (ChannelLayout::Rgba, SampleType::U8), + (ChannelLayout::Gray, SampleType::U16), + (ChannelLayout::Cmyk, SampleType::F32), + ] { + let mut img = synth(4, 3, layout, sample, 2, 0.4); + let n = 4 * 3; + let b = sample.bytes(); + let data: Vec = (0..n * b).map(|i| (i * 17) as u8).collect(); + img.meta.extra_samples = vec![ExtraSample { kind: 0, data: data.clone() }]; + let bytes = encode(&img, Format::Tiff, &EncodeOptions::default()).unwrap(); + let back = decode(&bytes).unwrap(); + assert_eq!(back.layout(), layout, "{layout:?} {sample:?}"); + assert_eq!(back.data(), img.data(), "{layout:?} {sample:?}"); + assert_eq!(back.meta.extra_samples.len(), 1, "{layout:?} {sample:?}"); + assert_eq!(back.meta.extra_samples[0].kind, 0, "{layout:?} {sample:?}"); + assert_eq!(back.meta.extra_samples[0].data, data, "{layout:?} {sample:?}"); + } +} + +/// Tall enough that the default strip size (about 1 MB) cannot hold every row, so a writer +/// that only fills the first strip, or predicts across the wrong sample count, cannot hide. +/// The spot plane is checked with the `tiff` crate, not PhotoCraft's decoder. +#[test] +fn multi_strip_spot_round_trip_and_dump() { + let w = 800u32; + let h = 400u32; + let n = (w as usize) * (h as usize); + for (layout, channels) in [(ChannelLayout::Rgb, 3usize), (ChannelLayout::Rgba, 4usize)] { + let mut px = vec![0u8; n * channels]; + let mut spot = vec![0u8; n]; + for y in 0..h as usize { + for x in 0..w as usize { + let i = y * w as usize + x; + px[i * channels] = (x % 251) as u8; + px[i * channels + 1] = (y % 251) as u8; + px[i * channels + 2] = 40; + if channels == 4 { + px[i * channels + 3] = if x > 20 && x < 780 && y > 10 && y + 10 < h as usize { 255 } else { 0 }; + } + spot[i] = ((x * 3 + y * 17) % 251) as u8; + } + } + let mut img = Image::from_u8(w, h, layout, px).unwrap(); + img.meta.extra_samples = vec![ExtraSample { kind: 0, data: spot.clone() }]; + for compression in [TiffCompression::None, TiffCompression::Deflate, TiffCompression::Lzw, TiffCompression::PackBits] { + let bytes = encode(&img, Format::Tiff, &EncodeOptions { tiff_compression: compression, ..Default::default() }).unwrap(); + let label = format!("{layout:?} {compression:?}"); + let back = decode(&bytes).unwrap(); + assert_eq!(back.meta.extra_samples.len(), 1, "{label}"); + assert_eq!(back.meta.extra_samples[0].data, spot, "own decoder {label}"); + assert_eq!(back.data(), img.data(), "own decoder rgb {label}"); + let mut dec = tiff::decoder::Decoder::new(std::io::Cursor::new(bytes.as_slice())).unwrap(); + let spp: u16 = dec.get_tag_unsigned(tiff::tags::Tag::SamplesPerPixel).unwrap(); + let bps = dec.get_tag_u16_vec(tiff::tags::Tag::BitsPerSample).unwrap(); + let extra = dec.get_tag_u16_vec(tiff::tags::Tag::ExtraSamples).unwrap(); + let rows = dec.find_tag_unsigned::(tiff::tags::Tag::RowsPerStrip).unwrap(); + assert_eq!(bps.len(), spp as usize, "{label}"); + assert_eq!(spp as usize, channels + 1, "{label}"); + assert_eq!(*extra.last().unwrap(), 0, "{label} spot ExtraSamples {extra:?}"); + assert!(rows.is_some_and(|r| r < h) || compression == TiffCompression::PackBits, "{label} rows {rows:?}"); + let patched = min_is_black(&bytes); + let mut indep = tiff::decoder::Decoder::new(std::io::Cursor::new(patched.as_slice())).unwrap(); + let tiff::decoder::DecodingResult::U8(samples) = indep.read_image().unwrap() else { panic!("{label} not u8") }; + let spp = spp as usize; + assert_eq!(samples.len(), n * spp, "{label}"); + let mut bad = 0usize; + let mut first = None; + for (i, want) in spot.iter().enumerate() { + let got = samples.get(i * spp + spp - 1).copied(); + if got != Some(*want) { + bad += 1; + first.get_or_insert((i, got)); + } + } + assert_eq!(bad, 0, "{label} independent reader, first {first:?}"); + } + } +} + +/// Retag photometric interpretation 262 as MinIsBlack so `tiff`'s decoder returns every sample. +fn min_is_black(src: &[u8]) -> Vec { + let mut bytes = src.to_vec(); + let le = bytes.first().copied() == Some(b'I'); + let ru16 = |b: &[u8], i: usize| -> Option { + let s = b.get(i..i + 2)?; + Some(if le { u16::from_le_bytes([s[0], s[1]]) } else { u16::from_be_bytes([s[0], s[1]]) }) + }; + let ru32 = |b: &[u8], i: usize| -> Option { + let s = b.get(i..i + 4)?; + Some(if le { u32::from_le_bytes(s.try_into().ok()?) } else { u32::from_be_bytes(s.try_into().ok()?) }) + }; + let Some(ifd) = ru32(&bytes, 4) else { return bytes }; + let Some(n) = ru16(&bytes, ifd as usize) else { return bytes }; + for e in 0..n as usize { + let at = ifd as usize + 2 + e * 12; + if ru16(&bytes, at) == Some(262) { + let value = if le { 1u16.to_le_bytes() } else { 1u16.to_be_bytes() }; + if let Some(slot) = bytes.get_mut(at + 8..at + 10) { + slot.copy_from_slice(&value); + } + break; + } + } + bytes +} + +#[test] +fn more_than_sixteen_extra_samples_is_refused() { + let mut img = synth(2, 2, ChannelLayout::Rgb, SampleType::U8, 1, 0.0); + img.meta.extra_samples = (0..MAX_EXTRA_SAMPLES + 1).map(|_| ExtraSample { kind: 0, data: vec![0; 4] }).collect(); + assert!(encode(&img, Format::Tiff, &EncodeOptions::default()).is_err()); +} + +#[test] +fn sixteen_extra_samples_round_trip() { + for (layout, sample, base) in [ + (ChannelLayout::Rgb, SampleType::U8, 3usize), + (ChannelLayout::Rgba, SampleType::U8, 4), + (ChannelLayout::Gray, SampleType::U16, 1), + (ChannelLayout::Cmyk, SampleType::F32, 4), + ] { + let mut img = synth(2, 2, layout, sample, 1, 0.0); + let n = 2 * 2 * sample.bytes(); + img.meta.extra_samples = (0..MAX_EXTRA_SAMPLES).map(|k| ExtraSample { kind: 0, data: vec![k as u8; n] }).collect(); + let bytes = encode(&img, Format::Tiff, &EncodeOptions::default()).unwrap(); + let back = decode(&bytes).unwrap(); + assert_eq!(back.layout(), layout, "{layout:?} {sample:?} base {base}"); + assert_eq!(back.data(), img.data(), "{layout:?}"); + assert_eq!(back.meta.extra_samples.len(), MAX_EXTRA_SAMPLES, "{layout:?}"); + assert_eq!(back.meta.extra_samples[7].kind, 0, "{layout:?}"); + assert_eq!(back.meta.extra_samples[15].data, vec![15; n], "{layout:?}"); + } +} + +/// Extra samples count against `max_alloc` with the image (their interleaved buffer and the +/// planes split from it): a budget that holds the RGB image but not sixteen extra planes refuses +/// the file instead of allocating past it. +#[test] +fn extra_samples_count_against_the_allocation_limit() { + let (w, h) = (64u32, 64u32); + let n = (w * h) as usize; + let mut img = synth(w, h, ChannelLayout::Rgb, SampleType::U8, 1, 0.0); + img.meta.extra_samples = (0..MAX_EXTRA_SAMPLES).map(|k| ExtraSample { kind: 0, data: vec![k as u8; n] }).collect(); + let bytes = encode(&img, Format::Tiff, &EncodeOptions::default()).unwrap(); + let with = |max_alloc: u64| decode_with(&bytes, &DecodeOptions { limits: Limits { max_alloc, ..Limits::default() }, ..DecodeOptions::default() }); + // RGB is 3 bytes a pixel; the extra samples add 2 x 16 more. + let image_only = 3 * n as u64; + let with_extras = (3 + 2 * MAX_EXTRA_SAMPLES as u64) * n as u64; + assert!(matches!(with(image_only), Err(CodecError::LimitExceeded(_))), "the image fits, the extra samples don't"); + assert!(matches!(with(with_extras - 1), Err(CodecError::LimitExceeded(_)))); + let back = with(with_extras).expect("everything fits"); + assert_eq!(back.meta.extra_samples.len(), MAX_EXTRA_SAMPLES); +} + +/// Converting an image's sample type converts its extra samples with it, so they keep matching +/// the image: a 16-bit float TIFF's spot planes survive the 32-bit float a layered import uses. +#[test] +fn extra_samples_follow_a_sample_type_conversion() { + let (w, h) = (3u32, 2u32); + let n = (w * h) as usize; + let values = [0.0f32, 0.25, 0.5, 0.75, 1.0, 0.125]; + let half = |v: f32| f16::from_f32(v).to_bits().to_ne_bytes(); + let rgb: Vec = (0..n * 3).flat_map(|_| half(0.5)).collect(); + let mut img = Image::from_raw(w, h, ChannelLayout::Rgb, SampleType::F16, rgb).unwrap(); + img.meta.extra_samples = vec![ExtraSample { kind: 0, data: values.iter().flat_map(|v| half(*v)).collect() }]; + + let wide = img.convert(ChannelLayout::Rgb, SampleType::F32); + let plane: Vec = wide.meta.extra_samples[0].data.as_chunks::<4>().0.iter().map(|c| f32::from_ne_bytes(*c)).collect(); + assert_eq!(plane, values); + + // To 8 bits, the plane quantizes exactly as a gray image of the same values does. + let narrow = wide.convert(ChannelLayout::Rgb, SampleType::U8); + let gray = Image::from_raw(w, h, ChannelLayout::Gray, SampleType::F32, wide.meta.extra_samples[0].data.clone()).unwrap(); + assert_eq!(narrow.meta.extra_samples[0].data, gray.convert(ChannelLayout::Gray, SampleType::U8).data()); + assert_eq!(narrow.meta.extra_samples[0].data.len(), n); +} + #[test] fn absent_and_empty_tags_are_not_written() { let mut img = synth(4, 4, ChannelLayout::Rgb, SampleType::U8, 1, 0.0); From ef754074b504b6194234f2947fd30e3c985e1628 Mon Sep 17 00:00:00 2001 From: Jason D Date: Wed, 21 Oct 2026 11:25:52 -0400 Subject: [PATCH 196/649] contributors: credit jasallen Co-Authored-By: Claude Opus 5.5 --- contributors/people.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contributors/people.toml b/contributors/people.toml index b3cab8e04f..2526e9c96c 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -191,3 +191,8 @@ sync_github_name = true [people.ha1des] sync_github_name = true + +[people.jasallen] +real_name = "Jason DeBoever" +display_name = "jasallen" +sync_github_name = true From 7b7b6c930d4b5c193af5638e177845c0662578ec Mon Sep 17 00:00:00 2001 From: Jason D Date: Wed, 21 Oct 2026 10:28:54 -0400 Subject: [PATCH 197/649] PSD: recognise Photoshop's MTrn merged-transparency marker Photoshop 27.11 saves a layered TIFF with Save Transparency as an RGBA composite whose layer data has a positive layer count and an `MTrn` block (`nrTM` in an II file). The specification's key is `Mtrn`, so the composite's transparency opened as an extra alpha channel and a PSD save wrote it twice. TaggedBlock::is_merged_transparency_marker lists Mtrn, MTrn, Mt16 and Mt32; PsdFile::merged_has_alpha and the PSD exporter's layer-block placement use it. Split from #7415; the work started in #3121. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Zer0C00L01 <12090083+Zer0C00L01@users.noreply.github.com> --- crates/io/src/psd_export.rs | 15 ++++--- crates/io/tests/psd16_merged_transparency.rs | 2 +- crates/io/tests/tiff_layers.rs | 41 ++++++++++++++++++++ crates/psd/src/file.rs | 37 ++++++++++++++---- crates/psd/src/tagged.rs | 8 ++++ docs/file-format-parity.md | 3 +- 6 files changed, 92 insertions(+), 14 deletions(-) diff --git a/crates/io/src/psd_export.rs b/crates/io/src/psd_export.rs index 9ad93bdf66..f8605331c8 100644 --- a/crates/io/src/psd_export.rs +++ b/crates/io/src/psd_export.rs @@ -1826,10 +1826,10 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c resources.push(version_info_resource(real_merged)); let has_layers = !ex.records.is_empty(); - // Photoshop writes a merged-transparency marker (`Mtrn`, `Mt16`, `Mt32`) before the layer - // block, and won't open a file whose `Lr32` comes first (#5068): the layer block goes right - // after the last kept marker, else first. - let index = global_blocks.iter().rposition(|b| matches!(&b.key, b"Mtrn" | b"Mt16" | b"Mt32")).map_or(0, |i| i + 1); + // Photoshop writes a merged-transparency marker (`Mtrn`, `Mt16`, `Mt32`; `MTrn` in a TIFF) + // before the layer block, and won't open a file whose `Lr32` comes first (#5068): the layer + // block goes right after the last kept marker, else first. + let index = global_blocks.iter().rposition(TaggedBlock::is_merged_transparency_marker).map_or(0, |i| i + 1); let placement = match (has_layers, sample) { (true, SampleType::U16) => LayerInfoPlacement::GlobalBlock { index, signature: *b"8BIM", key: *b"Lr16", padding: None }, (true, SampleType::F32) => LayerInfoPlacement::GlobalBlock { index, signature: *b"8BIM", key: *b"Lr32", padding: None }, @@ -1963,7 +1963,12 @@ mod tests { /// `transparentbg.psd` re-saved both ways). The layer block follows a kept marker. #[test] fn layer_block_follows_a_kept_merged_transparency_marker() { - for (depth, key, marker) in [(SampleType::F32, *b"Lr32", *b"Mt32"), (SampleType::U16, *b"Lr16", *b"Mt16"), (SampleType::F32, *b"Lr32", *b"Mtrn")] { + for (depth, key, marker) in [ + (SampleType::F32, *b"Lr32", *b"Mt32"), + (SampleType::U16, *b"Lr16", *b"Mt16"), + (SampleType::F32, *b"Lr32", *b"Mtrn"), + (SampleType::F32, *b"Lr32", *b"MTrn"), + ] { let mut doc = Document::new("t", photocraft_geom::Size::new(8, 6), ColorMode::Rgb, depth); let mut s = Surface::new(doc.pixel_format()); s.fill_rect(photocraft_geom::Rect::new(1, 1, 5, 4), &[0.5, 0.2, 0.9, 1.0]); diff --git a/crates/io/tests/psd16_merged_transparency.rs b/crates/io/tests/psd16_merged_transparency.rs index 02d6c0e6b3..3cbdd4b460 100644 --- a/crates/io/tests/psd16_merged_transparency.rs +++ b/crates/io/tests/psd16_merged_transparency.rs @@ -43,7 +43,7 @@ fn resave_keeps_a_name_marked_merged_transparency() { // transparency named in the alpha channel names. let mut ps = ours.clone(); ps.layer_info.as_mut().expect("layers").merged_alpha = false; - ps.global_blocks.retain(|b| !matches!(&b.key, b"Mtrn" | b"Mt16" | b"Mt32")); + ps.global_blocks.retain(|b| !b.is_merged_transparency_marker()); assert!(!ps.merged_has_alpha(), "{case}: nothing marks it yet"); let name: Vec = [0u8, 0, 0, 13].into_iter().chain("Transparency\0".encode_utf16().flat_map(u16::to_be_bytes)).collect(); ps.resources.retain(|r| !matches!(r.id, 1006 | 1045)); diff --git a/crates/io/tests/tiff_layers.rs b/crates/io/tests/tiff_layers.rs index 56e51bf9f9..4cf78aca68 100644 --- a/crates/io/tests/tiff_layers.rs +++ b/crates/io/tests/tiff_layers.rs @@ -202,6 +202,47 @@ fn transparency_is_straight_in_the_composite() { assert_docs_eq(&d, &back); } +/// Photoshop (27.11) saves a layered TIFF with Save Transparency as a composite with a +/// transparency sample, a positive layer count and an `MTrn` block first in the layer data +/// (the specification's key is `Mtrn`; `nrTM` in an `II` file). That sample is the merged +/// transparency: it opens as no alpha channel, and a PSD save doesn't write it twice. +#[test] +fn photoshop_mtrn_marks_the_merged_transparency_of_a_layered_tiff() { + use photocraft_psd::{PsdFile, TaggedBlock}; + for depth in [SampleType::U8, SampleType::U16] { + let mut d = Document::new("t", photocraft_geom::Size::new(8, 6), ColorMode::Rgb, depth); + let fmt = d.pixel_format(); + d.layers.push(raster("shape", fmt, photocraft_geom::Rect::new(1, 1, 5, 4), 3, true)); + let r = tiff(&d, true); + let mut img = photocraft_codecs::decode(&r.bytes).expect("decode"); + assert!(img.layout().has_alpha(), "{depth:?}: the composite has a transparency sample"); + let (isd, _) = ImageSourceData::from_bytes(&tags(&r.bytes).1.expect("layer data")).expect("parse"); + for order in [ByteOrder::Little, ByteOrder::Big] { + let case = format!("{depth:?} {order:?}"); + // Photoshop's form of the same layer data. + let mut ps = isd.clone(); + ps.layer_info.as_mut().expect("layers").merged_alpha = false; + ps.global_blocks.insert(0, TaggedBlock::new(*b"MTrn", Vec::new())); + let layers = ps.to_bytes(order).expect("layer data").0; + if order == ByteOrder::Little { + assert!(layers.windows(12).any(|w| w == b"MIB8nrTM\0\0\0\0"), "{case}: stored as Photoshop stores it"); + } + img.meta.photoshop_layers = Some(layers); + let bytes = photocraft_codecs::encode(&img, photocraft_codecs::Format::Tiff, &photocraft_codecs::EncodeOptions::default()).expect("encode"); + + let opened = import("x.tif", &bytes).expect("import").document; + let names: Vec<&str> = opened.channels.iter().map(|c| c.name.as_str()).collect(); + assert!(names.is_empty(), "{case}: no alpha channel from the merged transparency: {names:?}"); + // The marker is kept for the next save. + let mut want = d.clone(); + want.metadata.psd_global_blocks = vec![(*b"8BIM", *b"MTrn", std::sync::Arc::new(Vec::new()))]; + assert_docs_eq(&want, &opened); + let psd = PsdFile::from_bytes(&export(&opened, "x.psd", &ExportOptions::default()).expect("PSD save").bytes).expect("parse"); + assert_eq!(psd.header.channels, 4, "{case}: colour + merged transparency"); + } + } +} + #[test] fn big_documents_use_the_psb_signature() { // Forcing PSB stands in for a > 30000 px document. diff --git a/crates/psd/src/file.rs b/crates/psd/src/file.rs index fab262732b..740d44f8bf 100644 --- a/crates/psd/src/file.rs +++ b/crates/psd/src/file.rs @@ -352,12 +352,12 @@ impl PsdFile { } /// `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). Photoshop also names the merged transparency - /// "Transparency" and lists it first among the alpha channel names, and some of its 16-bit - /// PSBs carry no other mark (#4654): when the layers sit in a global `Lr16`/`Lr32` block, that - /// name with one name per extra channel marks it too. + /// the layer count was stored negative or a "Saving Merged Transparency" global block (see + /// [`TaggedBlock::is_merged_transparency_marker`]) is present. Photoshop marks 32-bit documents + /// with `Mt32` and a positive layer count (psd-tools transparentbg.psd). Photoshop also names + /// the merged transparency "Transparency" and lists it first among the alpha channel names, + /// and some of its 16-bit PSBs carry no other mark (#4654): when the layers sit in a global + /// `Lr16`/`Lr32` block, that name with one name per extra channel marks it too. pub fn merged_has_alpha(&self) -> bool { let Some(color) = self.header.color_mode.color_channels() else { return false; @@ -365,7 +365,7 @@ 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")); + let marked = self.global_blocks.iter().any(TaggedBlock::is_merged_transparency_marker); match &self.layer_info { Some(li) => { let in_block = matches!(self.layer_info_placement, LayerInfoPlacement::GlobalBlock { .. }); @@ -583,4 +583,27 @@ mod write_tests { } } } + + /// A positive layer count plus a merged-transparency marker still makes the first extra + /// channel the transparency, for the specification's keys and for the `MTrn` Photoshop + /// writes in a layered TIFF. + #[test] + fn merged_transparency_markers_mark_the_first_extra_channel() { + let mut file = testgen::small(Version::Psd, Compression::Raw); + if let Some(li) = &mut file.layer_info { + li.merged_alpha = false; + } + assert!(!file.merged_has_alpha()); + for key in [*b"Mtrn", *b"MTrn", *b"Mt16", *b"Mt32"] { + let mut marked = file.clone(); + marked.global_blocks.push(TaggedBlock::new(key, Vec::new())); + assert!(marked.merged_has_alpha(), "{}", String::from_utf8_lossy(&key)); + } + // Other keys, and the marker's letters in another case, do not. + for key in [*b"MTRN", *b"mtrn", *b"Lr16"] { + let mut other = file.clone(); + other.global_blocks.push(TaggedBlock::new(key, Vec::new())); + assert!(!other.merged_has_alpha(), "{}", String::from_utf8_lossy(&key)); + } + } } diff --git a/crates/psd/src/tagged.rs b/crates/psd/src/tagged.rs index 7728d53fd1..b16e158565 100644 --- a/crates/psd/src/tagged.rs +++ b/crates/psd/src/tagged.rs @@ -155,6 +155,14 @@ impl TaggedBlock { Self::is_foreign_order_signature(&self.signature) } + /// `true` for a "Saving Merged Transparency" marker: the merged image's first extra channel + /// is its transparency. The specification's keys are `Mtrn`, `Mt16` and `Mt32`; Photoshop + /// (27.11) writes `MTrn`, with a positive layer count, in a layered TIFF saved with Save + /// Transparency next to spot and alpha channels. + pub fn is_merged_transparency_marker(&self) -> bool { + matches!(&self.key, b"Mtrn" | b"MTrn" | b"Mt16" | b"Mt32") + } + /// Key as a string (lossy). pub fn key_str(&self) -> String { String::from_utf8_lossy(&self.key).into_owned() diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 938a723b69..3e4cca8330 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File-format parity -> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-15 · **Change:** minor (DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); earlier: PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-21 · **Change:** patch (Photoshop's `MTrn` merged-transparency marker, from a layered TIFF saved with Save Transparency, marks the merged transparency; earlier: DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; 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 @@ -142,6 +142,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings. | Date | Change | Summary | |---|---|---| +| 2026-10-21 | patch | PSD and layered TIFF: the `MTrn` block Photoshop writes in a layered TIFF saved with Save Transparency (a positive layer count, `nrTM` in an `II` file) marks the merged image's first extra channel as its transparency, like `Mtrn`/`Mt16`/`Mt32`: such a file no longer opens with its transparency also as an alpha channel (named "Transparency" in Photoshop 27.11's file), and a PSD save no longer writes it twice (split from #7415; credit #3121) | | 2026-10-15 | minor | DDS textures save (#1327): uncompressed or BC1/BC2/BC3 (DXT1/3/5) from a clean-room block encoder, optional box-filtered mip chain, legacy header; DDS Options in Save As and Save a Copy, `ddsCompression`/`ddsMipmaps` for scripts, the CLI and MCP | | 2026-10-15 | minor | PNG: a stereo PNG's `sTER` pairing (PNG Extensions 1.4.0 §3.6) is read on open and written back on save, so the file still says it is a stereo pair (#6063) | | 2026-10-15 | minor | PSD guides: image resource 1092 (guides v2) gives guides their own colours on import; 1092 and 1097 (guide GUIDs) are written back only while they still describe the document's guides, so an edit no longer leaves Photoshop a stale second guide list (#5966) | From a8e5cb3e8e79bad623f9177ee21614f4dca7a4ad Mon Sep 17 00:00:00 2001 From: Jason D Date: Wed, 21 Oct 2026 10:36:14 -0400 Subject: [PATCH 198/649] PSD: drop a kept merged-transparency marker when the composite is opaque A marker kept from the opened file (Photoshop's Mtrn/Mt16/Mt32 PSDs, or the MTrn of its layered TIFFs) was written back verbatim. Saved with an opaque composite and an alpha channel, the file has a positive layer count and the marker, so it reopened with that alpha channel taken as the merged transparency, and the channel was gone. Co-Authored-By: Claude Opus 5.5 --- crates/io/src/psd_export.rs | 30 +++++++++++++++++++++++++++++- docs/file-format-parity.md | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/crates/io/src/psd_export.rs b/crates/io/src/psd_export.rs index f8605331c8..454f1c5dd8 100644 --- a/crates/io/src/psd_export.rs +++ b/crates/io/src/psd_export.rs @@ -1785,7 +1785,13 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c if !ex.records.is_empty() && matches!(&key, b"Lr16" | b"Lr32" | b"Layr") { continue; } - global_blocks.push(global_block(block_signature(sig, key, version), key, &data)); + let block = global_block(block_signature(sig, key, version), key, &data); + // A kept merged-transparency marker describes the opened file's composite. Over an opaque + // one it would make the first alpha channel read back as the transparency, and vanish. + if !has_alpha && block.is_merged_transparency_marker() { + continue; + } + global_blocks.push(block); } if let Some(txt2) = txt2 { let mut tb = TaggedBlock::new(*b"Txt2", txt2.clone()); @@ -1988,6 +1994,28 @@ mod tests { assert!(matches!(saved.layer_info_placement, LayerInfoPlacement::GlobalBlock { index: 0, .. })); } + /// A merged-transparency marker kept from the opened file describes that file's composite. + /// Saved with an opaque composite, it would make the first alpha channel read back as the + /// merged transparency, and the channel would be gone: the save drops it. + #[test] + fn an_opaque_save_drops_a_kept_merged_transparency_marker() { + for (depth, marker) in [(SampleType::U8, *b"MTrn"), (SampleType::U8, *b"Mtrn"), (SampleType::U16, *b"Mt16"), (SampleType::F32, *b"Mt32")] { + let case = format!("{depth:?} {}", String::from_utf8_lossy(&marker)); + let mut doc = Document::new("t", photocraft_geom::Size::new(8, 6), ColorMode::Rgb, depth); + let mut s = Surface::new(doc.pixel_format()); + s.fill_rect(photocraft_geom::Rect::new(0, 0, 8, 6), &[0.5, 0.2, 0.9, 1.0]); + doc.layers.push(Layer::new("Layer 1", LayerContent::Raster(s))); + doc.channels.push(photocraft_doc::AlphaChannel::new("Alpha 1", Surface::new(PixelFormat::GRAY8))); + doc.metadata.psd_global_blocks = vec![(*b"8BIM", marker, std::sync::Arc::new(Vec::new()))]; + let file = document_to_psd(&doc); + assert!(!file.global_blocks.iter().any(TaggedBlock::is_merged_transparency_marker), "{case}"); + assert!(!file.merged_has_alpha(), "{case}"); + let back = crate::import("a.psd", &file.to_bytes().unwrap()).unwrap().document; + let names: Vec<&str> = back.channels.iter().map(|c| c.name.as_str()).collect(); + assert_eq!(names, ["Alpha 1"], "{case}"); + } + } + #[test] fn unreadable_lr16_warns_on_import_and_is_not_saved_twice() { // #2700: a 16-bit file whose Lr16 block claims five layers but holds none. diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 3e4cca8330..63fef83486 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -142,7 +142,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings. | Date | Change | Summary | |---|---|---| -| 2026-10-21 | patch | PSD and layered TIFF: the `MTrn` block Photoshop writes in a layered TIFF saved with Save Transparency (a positive layer count, `nrTM` in an `II` file) marks the merged image's first extra channel as its transparency, like `Mtrn`/`Mt16`/`Mt32`: such a file no longer opens with its transparency also as an alpha channel (named "Transparency" in Photoshop 27.11's file), and a PSD save no longer writes it twice (split from #7415; credit #3121) | +| 2026-10-21 | patch | PSD and layered TIFF: the `MTrn` block Photoshop writes in a layered TIFF saved with Save Transparency (a positive layer count, `nrTM` in an `II` file) marks the merged image's first extra channel as its transparency, like `Mtrn`/`Mt16`/`Mt32`: such a file no longer opens with its transparency also as an alpha channel (named "Transparency" in Photoshop 27.11's file), and a PSD save no longer writes it twice. A PSD save with an opaque composite drops any of these markers kept from the opened file, so its first alpha channel no longer reopens as transparency and vanishes (split from #7415; credit #3121) | | 2026-10-15 | minor | DDS textures save (#1327): uncompressed or BC1/BC2/BC3 (DXT1/3/5) from a clean-room block encoder, optional box-filtered mip chain, legacy header; DDS Options in Save As and Save a Copy, `ddsCompression`/`ddsMipmaps` for scripts, the CLI and MCP | | 2026-10-15 | minor | PNG: a stereo PNG's `sTER` pairing (PNG Extensions 1.4.0 §3.6) is read on open and written back on save, so the file still says it is a stereo pair (#6063) | | 2026-10-15 | minor | PSD guides: image resource 1092 (guides v2) gives guides their own colours on import; 1092 and 1097 (guide GUIDs) are written back only while they still describe the document's guides, so an edit no longer leaves Photoshop a stale second guide list (#5966) | From 8c5ec444dbeea93b5f0a2533c18baba71e2626e2 Mon Sep 17 00:00:00 2001 From: Unemars <62496697+Unemars@users.noreply.github.com> Date: Wed, 21 Oct 2026 19:43:02 +0200 Subject: [PATCH 199/649] Brush test: the parallel threshold goes back to its default however the test ends MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The parallel-vs-serial test moved the process-wide threshold and restored a hard-coded 256² only on success. A drop guard now restores it on every exit path, a panic inside a render included, from the renderer's own `DEFAULT_PARALLEL_MIN_PIXELS` instead of a copy of the literal. Co-Authored-By: Claude Opus 5.5 --- crates/paint/src/brush_tests.rs | 10 +++++++++- crates/paint/src/render.rs | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/paint/src/brush_tests.rs b/crates/paint/src/brush_tests.rs index 4c90586b78..8edf99350a 100644 --- a/crates/paint/src/brush_tests.rs +++ b/crates/paint/src/brush_tests.rs @@ -1641,9 +1641,17 @@ fn large_tips_render_the_same_in_parallel_and_serially() { }) .collect() }; + // The threshold is process-wide: put the default back however the test ends, a panic + // inside a render included. + struct Restore; + impl Drop for Restore { + fn drop(&mut self) { + crate::render::set_parallel_min_pixels(crate::render::DEFAULT_PARALLEL_MIN_PIXELS); + } + } + let _restore = Restore; let parallel = render(0); let serial = render(usize::MAX); - crate::render::set_parallel_min_pixels(256 * 256); for (i, (p, s)) in parallel.iter().zip(&serial).enumerate() { assert_eq!(p.len(), s.len()); let diff = p.iter().zip(s).filter(|(a, b)| a != b).count(); diff --git a/crates/paint/src/render.rs b/crates/paint/src/render.rs index 9afd83c6d1..ab38249bd9 100644 --- a/crates/paint/src/render.rs +++ b/crates/paint/src/render.rs @@ -44,7 +44,11 @@ pub const COV_TILE: i32 = 64; /// it the threads cost more than they save. A large soft tip is tens of megapixels per dab, and /// every stage of it is independent per row or tile, so the pixels come out the same. #[cfg(not(target_arch = "wasm32"))] -static PARALLEL_MIN_PIXELS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(256 * 256); +pub(crate) const DEFAULT_PARALLEL_MIN_PIXELS: usize = 256 * 256; + +/// The threshold in use: [`DEFAULT_PARALLEL_MIN_PIXELS`] (tests move it). +#[cfg(not(target_arch = "wasm32"))] +static PARALLEL_MIN_PIXELS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(DEFAULT_PARALLEL_MIN_PIXELS); /// Whether `pixels` of independent work are worth the thread pool (the web has none: there every /// stage takes its serial path). From 1017babd354f257adcb303c91dfd1084735ec7ba Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 21 Oct 2026 20:27:49 +0200 Subject: [PATCH 200/649] Fix filter-mask copy, named targets and mask-view switching --- crates/engine/src/edit_cmds.rs | 15 +++--- crates/engine/src/lib.rs | 2 +- .../src/smart_cmds/tests/filter_mask_paint.rs | 51 +++++++++++++++++++ crates/ui-egui/src/control.rs | 8 +-- crates/ui-egui/src/lib.rs | 21 ++++++++ crates/ui-egui/src/panels.rs | 5 +- crates/ui-egui/src/smart_ui.rs | 29 +++++++++++ 7 files changed, 114 insertions(+), 17 deletions(-) diff --git a/crates/engine/src/edit_cmds.rs b/crates/engine/src/edit_cmds.rs index aa2ce627f7..76330c8088 100644 --- a/crates/engine/src/edit_cmds.rs +++ b/crates/engine/src/edit_cmds.rs @@ -304,15 +304,18 @@ fn copy(s: &mut Session, merged: bool) -> Result { Ok(json!({"bounds": [b.x0, b.y0, b.width(), b.height()]})) } -/// Copy with the layer mask targeted (`"target":"mask"`, #2928): the mask's values as a +/// Copy the targeted layer mask (`"target":"mask"`, #2928) or smart-filter mask +/// (`"target":"filterMask"`): the mask's values as a /// grayscale clip, inside the selection or the whole canvas — an untouched mask copies at its /// default value, so a plain Reveal All / Hide All mask transfers too. Paste then writes into /// another layer's mask (targeted, #1035), in this or another document. -fn copy_mask(s: &mut Session) -> Result { +fn copy_mask(s: &mut Session, filter: bool) -> Result { let d = s.active().ok_or(EngineError::NoDocument)?; let canvas = d.doc.bounds(); let id = d.active_layer.ok_or_else(|| EngineError::Other("no active layer".into()))?; - let mask = d.doc.layer(id).ok_or(EngineError::NoLayer(id))?.mask.as_ref().ok_or_else(|| EngineError::Other("the active layer has no layer mask".into()))?; + let layer = d.doc.layer(id).ok_or(EngineError::NoLayer(id))?; + let mask = crate::mask_view_cmds::viewed_mask(layer, filter) + .ok_or_else(|| EngineError::Other(if filter { "the active layer has no filter mask" } else { "the active layer has no layer mask" }.into()))?; let sel = d.doc.selection.as_ref(); let area = sel.map_or(canvas, |m| m.content_bounds().intersect(&canvas)); if area.is_empty() { @@ -344,7 +347,7 @@ fn copy_mask(s: &mut Session) -> Result { let b = bounds; let resolution = Some(d.doc.resolution_dpi); s.clipboard = Some(Clip { surface, bounds: b, layers: None, resolution }); - Ok(json!({"bounds": [b.x0, b.y0, b.width(), b.height()], "target": "mask"})) + Ok(json!({"bounds": [b.x0, b.y0, b.width(), b.height()], "target": if filter { "filterMask" } else { "mask" }})) } fn clear_selected(doc: &mut Document, id: LayerId, background: [f32; 4]) -> Result<()> { @@ -975,11 +978,11 @@ pub fn specs() -> Vec { "Copy", &["Edit"], Some("Cmd+C"), - r##"{"target":"mask"? = the targeted mask, copied as grayscale (#2928)} (a targeted colour or alpha channel copies that channel, as grayscale)"##, + r##"{"target":"mask|filterMask"? = the targeted mask, copied as grayscale (#2928)} (a targeted colour or alpha channel copies that channel, as grayscale)"##, can_copy, |s, p| { if crate::commands::is_mask_target(p) { - return copy_mask(s); + return copy_mask(s, crate::channel_cmds::target_of(p) == crate::channel_cmds::Target::FilterMask); } match crate::channel_clip::copy(s)? { Some(r) => Ok(r), diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 160d40e5d8..984aa8ccda 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -799,7 +799,7 @@ impl Session { let d = self.active_mut()?; d.doc.layer(target)?; let active = d.active_layer.replace(target); - let r = (spec.enabled)(self); + let r = self.precondition(spec, params); if let Some(d) = self.active_mut() { d.active_layer = active; } diff --git a/crates/engine/src/smart_cmds/tests/filter_mask_paint.rs b/crates/engine/src/smart_cmds/tests/filter_mask_paint.rs index b0061e7da9..1db1fc5793 100644 --- a/crates/engine/src/smart_cmds/tests/filter_mask_paint.rs +++ b/crates/engine/src/smart_cmds/tests/filter_mask_paint.rs @@ -20,7 +20,11 @@ fn painting_the_filter_mask_hides_the_filters_there_in_one_undo_step() { let original = flat(&s); convert(&mut s); // Without smart filters there is no filter mask to paint. + let before = s.active().unwrap().doc.clone(); + let steps = s.active().unwrap().history.past_len(); assert!(matches!(stroke(&mut s, Some("filterMask")), Err(EngineError::Disabled(..))), "depth {depth}"); + assert!(std::sync::Arc::ptr_eq(&s.active().unwrap().doc, &before)); + assert_eq!(s.active().unwrap().history.past_len(), steps); s.execute("filter.blur.gaussianBlur", json!({"radius": 3})).unwrap(); let blurred = flat(&s); assert!(active_smart(&s).filter_mask.is_none()); @@ -64,7 +68,9 @@ fn a_shown_filter_mask_takes_the_paint() { paint(&mut s); convert(&mut s); s.execute("filter.blur.gaussianBlur", json!({"radius": 3})).unwrap(); + let before = s.active().unwrap().channel_view.clone(); assert!(s.execute("view.layerMask", json!({"mode": "gray", "mask": "filter"})).is_err(), "no filter mask yet"); + assert_eq!(s.active().unwrap().channel_view, before); stroke(&mut s, Some("filterMask")).unwrap(); let v = s.execute("view.layerMask", json!({"mode": "gray", "mask": "filter"})).unwrap(); assert_eq!(v["mode"], "gray"); @@ -75,5 +81,50 @@ fn a_shown_filter_mask_takes_the_paint() { let d = s.active().unwrap(); assert!(matches!(d.doc.layer(d.active_layer.unwrap()).unwrap().content, LayerContent::Smart(_)), "still a smart object"); // Bad params are refused, not a panic. + let before = s.active().unwrap().channel_view.clone(); assert!(s.execute("view.layerMask", json!({"mask": 3})).is_err()); + assert_eq!(s.active().unwrap().channel_view, before); +} + +#[test] +fn copying_the_filter_mask_never_copies_the_layer_mask() { + for depth in DEPTHS { + let mut s = session(depth); + paint(&mut s); + convert(&mut s); + s.execute("filter.blur.gaussianBlur", json!({"radius": 3})).unwrap(); + stroke(&mut s, Some("filterMask")).unwrap(); + for layer_mask in [false, true] { + if layer_mask { + s.execute("layer.layerMask.revealAll", json!({})).unwrap(); + } + let before = s.active().unwrap().doc.clone(); + let steps = s.active().unwrap().history.past_len(); + let result = s.execute("edit.copy", json!({"target": "filterMask"})).unwrap(); + assert_eq!(result["target"], "filterMask"); + let clip = s.clipboard.as_ref().unwrap(); + assert_eq!(clip.surface.rgba(8, 20), [0.0, 0.0, 0.0, 1.0]); + assert_eq!(clip.surface.rgba(30, 20), [1.0; 4]); + assert!(std::sync::Arc::ptr_eq(&s.active().unwrap().doc, &before)); + assert_eq!(s.active().unwrap().history.past_len(), steps); + } + } +} + +#[test] +fn an_explicit_layer_checks_filter_mask_eligibility() { + let mut s = session(8); + paint(&mut s); + let id = convert(&mut s); + s.execute("filter.blur.gaussianBlur", json!({"radius": 3})).unwrap(); + s.execute("shape.create", json!({"kind": "rect", "rect": [1, 1, 20, 20], "fill": "#ff0000"})).unwrap(); + let active = s.active().unwrap().active_layer; + s.execute("paint.cloneStamp", json!({"layer": id, "target": "filterMask", "source": [8, 8], "points": [[20, 20]], "size": 4})).unwrap(); + assert_eq!(s.active().unwrap().active_layer, active); + // A shape has no filter mask: rejection must precede recoloring its fill. + let before = s.active().unwrap().doc.clone(); + let steps = s.active().unwrap().history.past_len(); + assert!(s.execute("edit.fillForeground", json!({"layer": active.unwrap().0, "target": "filterMask"})).is_err()); + assert!(std::sync::Arc::ptr_eq(&s.active().unwrap().doc, &before)); + assert_eq!(s.active().unwrap().history.past_len(), steps); } diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index 43b02be1a6..d73c24f080 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -754,12 +754,8 @@ fn dispatch(app: &mut PhotocraftApp, ctx: &egui::Context, req: &ControlRequest) app.sync_mask_targets(); } if let Some(m) = filter_mask_target { - app.ui.filter_mask_target = if m { app.session.active().and_then(|st| st.active_layer).map(|id| id.0) } else { None }; - if m { - app.ui.mask_target = false; - app.ui.vector_mask_target = false; - } - app.sync_mask_targets(); + let layer = if m { app.session.active().and_then(|st| st.active_layer).map(|id| id.0) } else { None }; + app.select_filter_mask_target(layer); } // Selection tools' options-bar mode: 0 New, 1 Add, 2 Subtract, 3 Intersect. if let Some(m) = selection_mode { diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 376e7d0e0e..040eb1c9d2 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -2349,6 +2349,27 @@ impl PhotocraftApp { colors_off && !alpha_on } + /// Explicitly targeting a filter mask ends any conflicting mask view. + pub(crate) fn select_filter_mask_target(&mut self, layer: Option) { + if layer.is_some() { + if let Some(st) = self.session.active_mut() { + if st.channel_view.layer_mask.is_some_and(|v| !v.filter || Some(v.layer.0) != layer) { + st.channel_view.layer_mask = None; + } + if matches!( + st.channel_view.target, + photocraft_engine::channel_cmds::ChannelTarget::LayerMask | photocraft_engine::channel_cmds::ChannelTarget::VectorMask + ) { + st.channel_view.target = photocraft_engine::channel_cmds::ChannelTarget::Composite; + } + } + self.ui.mask_target = false; + self.ui.vector_mask_target = false; + } + self.ui.filter_mask_target = layer; + self.sync_mask_targets(); + } + /// Viewing a layer mask (#196) targets it; a vector-mask target needs a vector mask on the /// active layer (a shape layer's path is its content, not a mask). Targeting a mask or the /// pixels brings back that target's foreground/background pair, as in Photoshop (#2166). diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 281a2a0448..e389c5605f 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -2839,10 +2839,7 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) { continue; } if id == "ui.filterMaskTarget" { - app.ui.filter_mask_target = p.as_u64(); - app.ui.mask_target = false; - app.ui.vector_mask_target = false; - app.sync_mask_targets(); + app.select_filter_mask_target(p.as_u64()); continue; } // Double-clicking a mask thumbnail opens its settings: show Properties. diff --git a/crates/ui-egui/src/smart_ui.rs b/crates/ui-egui/src/smart_ui.rs index d1776fd7f4..b35bf0bdb7 100644 --- a/crates/ui-egui/src/smart_ui.rs +++ b/crates/ui-egui/src/smart_ui.rs @@ -457,6 +457,35 @@ mod tests { assert_eq!(app.ui.filter_mask_target, None, "a layer mask target replaces it"); } + #[test] + fn selecting_the_filter_mask_replaces_a_layer_mask_view() { + let mut app = PhotocraftApp::new(Session::new(), Services::default()); + app.run("file.new", json!({"width": 32, "height": 32})).unwrap(); + app.run("layer.new.layer", json!({})).unwrap(); + app.run("edit.fill", json!({"contents": "color", "color": "#ff0000"})).unwrap(); + app.run("layer.smartObjects.convertToSmartObject", json!({})).unwrap(); + app.run("filter.blur.gaussianBlur", json!({"radius": 2})).unwrap(); + app.run("layer.layerMask.revealAll", json!({})).unwrap(); + app.run("view.layerMask", json!({"mode": "gray"})).unwrap(); + app.sync_mask_targets(); + assert!(app.layer_mask_targeted()); + let id = app.session.active().unwrap().active_layer.unwrap(); + app.select_filter_mask_target(Some(id.0)); + app.sync_views(); + assert!(app.filter_mask_targeted()); + assert!(!app.layer_mask_targeted()); + assert!(photocraft_engine::mask_view_cmds::current(app.session.active().unwrap()).is_none()); + app.run("paint.stroke", json!({"points": [[8, 8]], "size": 6, "hardness": 1, "color": "#000000"})).unwrap(); + let st = app.session.active().unwrap(); + let layer = st.doc.layer(id).unwrap(); + assert_eq!(layer.mask.as_ref().unwrap().value(8, 8), 1.0); + let LayerContent::Smart(sm) = &layer.content else { panic!("smart object") }; + assert_eq!(sm.filter_mask.as_ref().unwrap().value(8, 8), 0.0); + app.run("view.layerMask", json!({"mode": "gray", "mask": "filter"})).unwrap(); + app.select_filter_mask_target(Some(id.0)); + assert!(photocraft_engine::mask_view_cmds::current(app.session.active().unwrap()).unwrap().filter, "a matching filter-mask view stays open"); + } + /// A pixel layer, a shape layer and a smart object, in that order. fn layers() -> [Layer; 3] { let mut s = photocraft_engine::Session::new(); From 9484e9e412d90cff79533fb6b99952677e305598 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 21 Oct 2026 20:27:51 +0200 Subject: [PATCH 201/649] Keep one clone source snapshot across Vanishing Point preview batches --- crates/algo/src/vanishing.rs | 47 +++++++++++++++++++++++++++++++++--- crates/engine/src/vp_cmds.rs | 10 +++++++- crates/ui-egui/src/vp_ui.rs | 44 ++++++++++++++++++++++++++++++--- 3 files changed, 92 insertions(+), 9 deletions(-) diff --git a/crates/algo/src/vanishing.rs b/crates/algo/src/vanishing.rs index 2ac85badb4..461c43a881 100644 --- a/crates/algo/src/vanishing.rs +++ b/crates/algo/src/vanishing.rs @@ -382,8 +382,9 @@ pub fn clone_source(scene: &Scene, source: [f64; 2], anchor: [f64; 2], p: [f64; } /// [`clone_stroke`]'s dabs at `points` for a stroke anchored at `anchor` (its first dab, which -/// fixes the offset and the brush's metric size), so a stroke can be painted in pieces exactly -/// as one. Returns the dabs painted and the area they changed. +/// fixes the offset and the brush's metric size). Samples a snapshot taken at this call. +/// For incremental painting use [`clone_dabs_from`] with one snapshot per stroke. +/// Returns the dabs painted and the area they changed. #[allow(clippy::too_many_arguments)] pub fn clone_dabs( scene: &Scene, @@ -395,9 +396,29 @@ pub fn clone_dabs( hardness: f64, opacity: f32, ) -> (usize, Rect) { + let src_copy = surf.clone(); + clone_dabs_from(scene, surf, &src_copy, source, anchor, points, size, hardness, opacity) +} + +/// Paint a batch of one stroke using the same immutable source snapshot for every batch. +/// Source and destination must have the same pixel format; otherwise no dabs are painted. +#[allow(clippy::too_many_arguments)] +pub fn clone_dabs_from( + scene: &Scene, + surf: &mut Surface, + src_copy: &Surface, + source: [f64; 2], + anchor: [f64; 2], + points: &[[f64; 2]], + size: f64, + hardness: f64, + opacity: f32, +) -> (usize, Rect) { + if surf.format() != src_copy.format() { + return (0, Rect::EMPTY); + } let Some(f) = CloneFrame::new(scene, source, anchor, size) else { return (0, Rect::EMPTY) }; let (lud, lvd) = f.ld; - let src_copy = surf.clone(); let fmt = surf.format(); let n = fmt.channels(); let mut dabs = 0; @@ -434,7 +455,7 @@ pub fn clone_dabs( let k = (fall * fall * (3.0 - 2.0 * fall)) as f32 * opacity; // Source pixel at the same metric offset. let (sx, sy) = f.hs.apply((m[0] + f.offset[0]) / f.ls.0, (m[1] + f.offset[1]) / f.ls.1); - let s = sample(&src_copy, sx - 0.5, sy - 0.5, n); + let s = sample(src_copy, sx - 0.5, sy - 0.5, n); for c in 0..n { px[c] += (s[c] - px[c]) * k; } @@ -555,4 +576,22 @@ mod tests { let back = clone_source(&sc, [sx, sy], [dx, dy], [dx, dy]).unwrap(); assert!((back[0] - sx).abs() < 1e-6 && (back[1] - sy).abs() < 1e-6, "{back:?}"); } + #[test] + fn incremental_clone_uses_one_source_snapshot_per_stroke() { + let sc = Scene::new(VpPlane { corners: [[0.0, 0.0], [100.0, 0.0], [100.0, 100.0], [0.0, 100.0]] }, [50.0, 50.0], None, 800.0); + for fmt in [PixelFormat::RGBA8, PixelFormat::RGBA16, PixelFormat::RGBA32F] { + let mut original = Surface::new(fmt); + for x in 0..100 { + original.fill_rect(Rect::new(x, 0, x + 1, 100), &[x as f32 / 100.0, (x % 7) as f32 / 6.0, 0.3, 1.0]); + } + let points = [[40.0, 50.0], [44.0, 50.0], [48.0, 50.0], [52.0, 50.0]]; + let mut whole = original.clone(); + assert_eq!(clone_stroke(&sc, &mut whole, [36.0, 50.0], &points, 12.0, 0.8, 1.0), 4); + let mut pieces = original.clone(); + for part in points.chunks(2) { + clone_dabs_from(&sc, &mut pieces, &original, [36.0, 50.0], points[0], part, 12.0, 0.8, 1.0); + } + assert_eq!(whole.read_region(Rect::new(0, 0, 100, 100)), pieces.read_region(Rect::new(0, 0, 100, 100))); + } + } } diff --git a/crates/engine/src/vp_cmds.rs b/crates/engine/src/vp_cmds.rs index e1e342a10a..ee9a4c6d7f 100644 --- a/crates/engine/src/vp_cmds.rs +++ b/crates/engine/src/vp_cmds.rs @@ -361,9 +361,13 @@ mod tests { s.execute("file.new", json!({"width": 200, "height": 200, "depth": 32})).unwrap(); s.execute("layer.new.layer", json!({})).unwrap(); let floor = json!({"corners": [[60, 60], [140, 60], [190, 190], [10, 190]]}); + let before = s.active().unwrap().doc.clone(); + let steps = s.active().unwrap().history.past_len(); for torn in [json!({"from": 0, "angle": 1e9}), json!({"from": 0, "depth": -1}), json!({"from": 0, "depth": 1e300})] { let e = s.execute(VP, json!({"planes": [floor, torn]})).unwrap_err().to_string(); assert!(e.contains("plane 1"), "{e}"); + assert!(std::sync::Arc::ptr_eq(&s.active().unwrap().doc, &before)); + assert_eq!(s.active().unwrap().history.past_len(), steps); } let many: Vec<[f64; 2]> = vec![[100.0, 150.0]; MAX_CLONE_DABS + 1]; for clone in [ @@ -374,10 +378,14 @@ mod tests { json!({"source": [100, 180]}), ] { let label: String = clone.to_string().chars().take(80).collect(); - assert!(s.execute(VP, json!({"planes": [floor], "clone": clone})).is_err(), "{label}"); + assert!(s.execute(VP, json!({"planes": [floor], "clone": clone, "newLayer": true})).is_err(), "{label}"); + assert!(std::sync::Arc::ptr_eq(&s.active().unwrap().doc, &before)); + assert_eq!(s.active().unwrap().history.past_len(), steps); } let planes: Vec = std::iter::repeat_n(floor.clone(), MAX_PLANES + 1).collect(); assert!(s.execute(VP, json!({"planes": planes})).is_err()); + assert!(std::sync::Arc::ptr_eq(&s.active().unwrap().doc, &before)); + assert_eq!(s.active().unwrap().history.past_len(), steps); // A clone on a torn-off wall, at 32 bits, sampling the floor. let r = s .execute(VP, json!({"planes": [floor, {"from": 0, "edge": "top", "angle": 90, "depth": 0.5}], "clone": [{"source": [100, 150], "points": [[100, 50], [104, 50]], "size": 8}]})) diff --git a/crates/ui-egui/src/vp_ui.rs b/crates/ui-egui/src/vp_ui.rs index c3dc645dd9..418b9516e0 100644 --- a/crates/ui-egui/src/vp_ui.rs +++ b/crates/ui-egui/src/vp_ui.rs @@ -18,7 +18,7 @@ use std::sync::Arc; use egui::{Color32, Pos2, Stroke, TextureHandle, pos2}; use photocraft_algo::transform::Homography; -use photocraft_algo::vanishing::{Edge, PlaneCheck, Scene, VpPlane, clone_dabs, clone_source}; +use photocraft_algo::vanishing::{Edge, PlaneCheck, Scene, VpPlane, clone_dabs_from, clone_source}; use photocraft_doc::{DocId, Document, Layer, LayerContent, LayerId}; use photocraft_engine::vp_cmds::{CloneSpec, MAX_CLONE_DABS, MAX_CLONE_STROKES, VP, copy_changed, visible_image}; use photocraft_geom::Rect; @@ -97,6 +97,8 @@ struct StampPreview { new_layer: bool, /// On a new layer: the visible image the strokes sample, with the strokes so far. work: Option, + /// The sampled image before the current stroke, retained across frame batches. + source: Option<(usize, Surface)>, /// The target layer's pixels as painted so far. out: Surface, /// Strokes painted: those before `.0`, and the first `.1` points of stroke `.0`. @@ -497,7 +499,8 @@ impl VpSession { // The old preview's area changes back too. let keys = self.preview.take().map(|p| p.keys).unwrap_or_default(); area = keys.iter().fold(Rect::EMPTY, |a, k| union(a, k.1)); - self.preview = Some(StampPreview { rev: self.rev, new_layer: self.new_layer, work, out, done: (0, 0), keys, shown: self.base.clone() }); + self.preview = + Some(StampPreview { rev: self.rev, new_layer: self.new_layer, work, source: None, out, done: (0, 0), keys, shown: self.base.clone() }); } let Some(pv) = self.preview.as_mut() else { return false }; let (from_stroke, from_point) = pv.done; @@ -507,15 +510,19 @@ impl VpSession { if points.is_empty() { continue; } + if pv.source.as_ref().is_none_or(|(stroke, _)| *stroke != si) { + pv.source = Some((si, pv.work.as_ref().unwrap_or(&pv.out).clone())); + } + let Some((_, source)) = pv.source.as_ref() else { continue }; let (hard, opacity) = (c.hardness, c.opacity as f32); let changed = match pv.work.as_mut() { Some(work) => { let before = work.clone(); - let (_, a) = clone_dabs(&sc, work, c.source, *anchor, points, c.size, hard, opacity); + let (_, a) = clone_dabs_from(&sc, work, source, c.source, *anchor, points, c.size, hard, opacity); copy_changed(&mut pv.out, &before, work, a); a } - None => clone_dabs(&sc, &mut pv.out, c.source, *anchor, points, c.size, hard, opacity).1, + None => clone_dabs_from(&sc, &mut pv.out, source, c.source, *anchor, points, c.size, hard, opacity).1, }; area = union(area, changed); } @@ -1329,4 +1336,33 @@ mod tests { assert!(s.torn[1].is_some()); assert!(crate::distort_ui::display_doc(&app, 0).is_some(), "the stroke shows again"); } + #[test] + fn overlapping_stamp_preview_matches_commit_across_batches() { + for new_layer in [false, true] { + let (ctx, mut app) = app_with_layer(); + app.session + .edit("pattern", |doc, active| { + let surf = doc.layer_mut(active.unwrap()).unwrap().surface_mut().unwrap(); + for x in 0..240 { + surf.fill_rect(Rect::new(x, 0, x + 1, 160), &[x as f32 / 240.0, (x % 7) as f32 / 6.0, 0.3, 1.0]); + } + Ok(()) + }) + .unwrap(); + crate::distort_ui::menu(&mut app, &ctx, VP, &json!({})).unwrap().unwrap(); + control(&mut app, &json!({"planes": [{"corners": [[10, 10], [230, 10], [230, 150], [10, 150]]}]})).unwrap(); + let points = [[80.0, 80.0], [84.0, 80.0], [88.0, 80.0], [92.0, 80.0]]; + let s = app.distort.vanishing.as_mut().unwrap(); + s.new_layer = new_layer; + s.strokes.push(CloneSpec { source: [76.0, 80.0], points: points[..2].to_vec(), size: 12.0, hardness: 0.8, opacity: 1.0 }); + assert!(s.paint_preview(|| 1)); + s.strokes[0].points.extend_from_slice(&points[2..]); + assert!(s.paint_preview(|| 2)); + let (shown, _) = s.shown().unwrap(); + let expected = photocraft_compose::flatten(&shown).px; + assert_ne!(expected, photocraft_compose::flatten(&app.session.active().unwrap().doc).px); + commit(&mut app).unwrap(); + assert_eq!(photocraft_compose::flatten(&app.session.active().unwrap().doc).px, expected, "newLayer={new_layer}"); + } + } } From ffc05c3760455c3aecfc8a490057f3df653de77e Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 21 Oct 2026 20:30:17 +0200 Subject: [PATCH 202/649] Regenerate filter-mask scorecard after merging main --- docs/scorecard.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/scorecard.md b/docs/scorecard.md index 5a59aad2a4..a04ae80f04 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -7,7 +7,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js | Area | Done | Partial | Missing | Key numbers | |---|---:|---:|---:|---| | [Performance](#performance) | 3 | 22 | 26 | 60 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 22 not run, 4 not measurable yet (baseline 2026-10-05) | -| [File compatibility](#file-compatibility) | 9 | 12 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | +| [File compatibility](#file-compatibility) | 10 | 12 | 5 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | | [Tools](#tools) | 36 | 8 | 0 | | | [Workspace and UI](#workspace-and-ui) | 13 | 7 | 3 | settings that do nothing: 24 of 171 (target 0) | | [Type](#type) | 5 | 3 | 1 | | @@ -104,7 +104,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t |---|---|---|---|---| | FILE-215-1 | Smart Objects export as embedded Smart Objects (SoLd + lnk2), not flat pixels | done | [#215](https://github.com/storytold/photocraft/issues/215) | psd_export.rs smart_blocks: PlLd + SoLd, source in lnk2 (.pcraft -> PSB); engine tests/smart_psd.rs; Photoshop 2026 opens 8/16-bit exports as live smart objects. Linked files are embedded | | FILE-215-2 | Smart Filters survive PSD save and re-open (filterFX descriptor read and written) | partial | [#215](https://github.com/storytold/photocraft/issues/215) | smart_map.rs: 41 filters plus Hue/Saturation, Perspective Warp, Filter Gallery (Chrome) and a verified Camera Raw subset mapped both ways, others kept verbatim, mask in FEid; io tests/smart_corpus.rs. PhotoCraft-only filters (Twirl, Liquify…) and unmapped Camera Raw settings are left out of filterFX with a warning | -| FILE-215-3 | Filter mask can be painted directly, with undo | missing | [#215](https://github.com/storytold/photocraft/issues/215) | smart_cmds.rs:382 mask only from the selection | +| FILE-215-3 | Filter mask can be painted directly, with undo | done | [#215](https://github.com/storytold/photocraft/issues/215) | Clicking the filter mask thumbnail on the Smart Filters row targets it (ui.filterMaskTarget, smart_ui.rs). Painting, fills, filters and adjustments with "target":"filterMask" then edit it (a white mask starts on the first stroke) and re-render the smart object, one undo step per stroke (channel_cmds Target::FilterMask, Session::edit). ⌥-click shows it (view.layerMask "mask":"filter"), ⇧-click disables it. Kept through .pcraft and PSD FEid (smart_cmds/tests/filter_mask_paint.rs) | | FILE-215-4 | Adjustments (Hue/Sat + Colorize, Curves, Levels, Shadows/Highlights) apply as Smart Filters | done | [#215](https://github.com/storytold/photocraft/issues/215) | Image › Adjustments on a smart object records image.adjustments. as a smart filter (adjust_cmds.rs adjust_as_smart_filter; the selection becomes the filter mask), re-rendered from the source by adjust_as_filter and re-editable with layer.smartFilter.setParams; PSD maps Levels/Curves/Shadows-Highlights both ways (smart_map.rs). Opening the editor from the smart-filter row is FILE-215-5's row work | | FILE-215-5 | Smart Filter rows: collapse, mask thumb, blend icon, drag reorder, context menu, live preview | partial | [#215](https://github.com/storytold/photocraft/issues/215) | smart_ui.rs:31 rows + visibility + editor; no collapse, drag or context menu | | FILE-215-6 | Smart Object corner skew and perspective (quad or homography transform) | done | [#215](https://github.com/storytold/photocraft/issues/215) | #426: SmartObject.perspective holds the projective map (transform keeps its affine approximation); Distort / Perspective on a smart object set it (transform_cmds.rs, smart_cmds::set_placement), it re-renders from the source through the homography, Warp composes with it, and the PSD placement reads and writes nonAffineTransform / Trnf (io/blocks.rs placed_projective, smart_map.rs); tests distort_survives_edit_contents, warp_on_a_distorted_smart_object_follows_the_corners, placement survives the save | From 07cfd9b219f0ebd41d5781d6d7d6e019f7573f33 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 21 Oct 2026 20:34:12 +0200 Subject: [PATCH 203/649] Regenerate Vanishing Point scorecard after merging main --- docs/scorecard.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/scorecard.md b/docs/scorecard.md index 5a59aad2a4..c8ee0c28aa 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -8,7 +8,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js |---|---:|---:|---:|---| | [Performance](#performance) | 3 | 22 | 26 | 60 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 22 not run, 4 not measurable yet (baseline 2026-10-05) | | [File compatibility](#file-compatibility) | 9 | 12 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | -| [Tools](#tools) | 36 | 8 | 0 | | +| [Tools](#tools) | 37 | 7 | 0 | | | [Workspace and UI](#workspace-and-ui) | 13 | 7 | 3 | settings that do nothing: 24 of 171 (target 0) | | [Type](#type) | 5 | 3 | 1 | | | [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) | @@ -162,7 +162,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t | TOOL-214-11 | Stroke Path dialog: pick any brush-based tool, Simulate Pressure | done | [#214](https://github.com/storytold/photocraft/issues/214) | path.stroke tool: Brush, Pencil, Eraser and every other brush-based tool (Background Eraser, Clone/Pattern Stamp, Healing/Spot Healing Brush, History Brush, Blur, Sharpen, Smudge, Dodge, Burn, Sponge, Color Replacement, Mixer Brush: their paint.* command along the path, one step) plus simulatePressure (taper both ends); Stroke Path dialog from the Pen menu, the Paths panel menu and Alt-click on its Stroke button (#2978) | | TOOL-214-12 | Shapes: on-canvas corner radius handles, shape feather, selection to shape with tolerance | done | [#214](https://github.com/storytold/photocraft/issues/214) | On-canvas corner radius widgets on every selected live rectangle with Path Selection, the Rectangle tool and Move + Show Transform Controls: drag rounds every corner of every selected rectangle alike, Alt that corner on each, corner radius cursor and R: readout, one history step (corner_radius.rs, 2026-10-13); select.convertToShape with tolerance (vector_cmds.rs:1256); shape Density and Feather (Properties, layer.vectorMask.edit on a shape layer; the path as the fill's soft vector mask, Photoshop's 10 px feather ramp within 1 level; PSD mask parameters and .pcraft, #5846, 2026-10-15) | | TOOL-214-13 | Mask Properties: Density and Feather controls | done | [#214](https://github.com/storytold/photocraft/issues/214) | Properties panel shows Density (%) and Feather (px) sliders for a targeted pixel mask (layer.layerMask.edit) and a targeted vector mask (layer.vectorMask.edit), non-destructive and one undo step per drag, with Photoshop's Refine row (mask_props_ui.rs; mask_props_ui_tests.rs pixel_mask_properties_follow_target_for_raster_and_adjustment_in_both_themes, mask_slider_drags_preview_live_and_undo_as_separate_gestures, vector_mask_properties_edit_density_and_feather) | -| TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | partial | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15); on-canvas plane editor (vp_ui.rs: Create/Edit Plane, edge nodes, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane on OK); clone stamp, marquee and tear-off planes in the window still missing | +| TOOL-214-14 | Vanishing Point window: draw and edit planes, paste, clone in perspective | done | [#214](https://github.com/storytold/photocraft/issues/214) | filter.vanishingPoint (vp_cmds.rs:15); on-canvas window (vp_ui.rs: Create/Edit Plane, edge nodes, Ctrl/Cmd-drag tear-off planes with depth and Alt-drag angle, valid/doubtful/invalid grid colours, Grid Size, clipboard pasted onto the plane, Stamp tool cloning in perspective with live preview, all applied on OK as one step); the window's Marquee tool and the Stamp's Heal modes are still missing | | TOOL-214-15 | Content-Aware Fill workspace: paint the sampling area, preview, rotate/scale/mirror, new layer | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Engine sampling auto, rect, custom (edit_menu_cmds.rs:324); generic dialog | | TOOL-214-16 | Liquify: redo (Cmd+Shift+Z) | done | [#214](https://github.com/storytold/photocraft/issues/214) | liquify_ui.rs supports bounded redo through Cmd+Shift+Z and the control channel; new strokes clear redo | | TOOL-213-17 | Red Eye tool: click a pupil to neutralize the red reflection | done | [#213](https://github.com/storytold/photocraft/issues/213) | paint.redEye (redeye_cmds.rs) + Tool::RedEye in the J flyout; Pupil Size and Darken Amount; catchlights kept; a miss is an error | From c7ef3676afab57250c5d7254b89160f36c5efb97 Mon Sep 17 00:00:00 2001 From: David Mann Date: Wed, 21 Oct 2026 22:05:27 +0200 Subject: [PATCH 204/649] Integration: snapshot selection and History follow share one history identity (#5940) At the history limit a new state can keep the count and the name, so a selected snapshot stayed selected after it. The newest past state now belongs to HistorySpot, used by both checks. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../ui-egui/src/history_panel_select_tests.rs | 22 +++++++++++++++++++ crates/ui-egui/src/panels.rs | 16 +++++++------- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/history_panel_select_tests.rs b/crates/ui-egui/src/history_panel_select_tests.rs index 14bfb344ca..8a591a739a 100644 --- a/crates/ui-egui/src/history_panel_select_tests.rs +++ b/crates/ui-egui/src/history_panel_select_tests.rs @@ -225,3 +225,25 @@ fn a_new_state_at_the_history_limit_still_scrolls_into_view() { h.run_steps(4); assert!(shown(&h, 0), "a new state at the limit scrolls into view"); } + +#[test] +fn a_new_state_at_the_history_limit_deselects_the_snapshot() { + let mut h = long_harness(); + h.state_mut().run("history.newSnapshot", json!({})).unwrap(); + h.run_steps(2); + // What a click on the snapshot row does: the command, then the selection at the state it made. + let id = h.state().session.active().unwrap().snapshots[0].id; + h.state_mut().run("history.selectSnapshot", json!({"snapshot": id})).unwrap(); + select_snapshot(&h.ctx, h.state().session.active().unwrap(), id); + h.run_steps(4); + assert_eq!(selected_snapshot(&h.ctx, h.state().session.active().unwrap()), Some(id), "the snapshot is selected"); + // At the limit, selecting the snapshot again by command adds a state with the same name and + // drops the oldest: only the newest state tells the two apart. + let st = h.state_mut().session.active_mut().unwrap(); + st.history.max_states = st.history.past_len(); + let past = st.history.past_len(); + h.state_mut().run("history.selectSnapshot", json!({"snapshot": id})).unwrap(); + assert_eq!(h.state().session.active().unwrap().history.past_len(), past, "the oldest state was dropped"); + h.run_steps(4); + assert_eq!(selected_snapshot(&h.ctx, h.state().session.active().unwrap()), None, "a new state deselects the snapshot"); +} diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 5a430205c8..33dc5185cb 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -3360,10 +3360,7 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let redo: Vec = st.history.redo_labels().map(str::to_string).collect(); let source = photocraft_engine::history_source_cmds::source(st); let selected_snap = selected_snapshot(ui.ctx(), st); - // The newest past state is a new document on every step, Undo and Redo, also at the state - // limit, where the counts and a repeated name stay the same. - let newest = st.history.past_len().checked_sub(1).and_then(|i| st.history.state(i)).map(|d| std::sync::Arc::as_ptr(&d) as usize); - let spot = (doc.id, history_spot(st), newest); + let spot = (doc.id, history_spot(st)); let ctx = ui.ctx().clone(); // A row dragged onto the trash (#5324); a drag that never saw its release must not outlive it. if !ctx.input(|i| i.pointer.primary_down() || i.pointer.any_released()) { @@ -3396,7 +3393,7 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) { // layer click, a channel eye) and a selected snapshot leave the list where the user put it. let follow_id = egui::Id::new("history-follow"); let moved = ui.ctx().data_mut(|d| { - let moved = d.get_temp::<(photocraft_doc::DocId, HistorySpot, Option)>(follow_id).as_ref() != Some(&spot); + let moved = d.get_temp::<(photocraft_doc::DocId, HistorySpot)>(follow_id).as_ref() != Some(&spot); d.insert_temp(follow_id, spot); moved }); @@ -3563,12 +3560,15 @@ fn history_drag_key() -> egui::Id { } /// The snapshot the History panel shows selected (#5324), and where the history stood after its -/// click: the number of past states, the current state's name and the number of redo states. +/// click: the number of past states, the current state's name, the number of redo states and the +/// newest past state. That last one is a new document on every step, also at the state limit, +/// where the counts and a repeated name stay the same. type SelectedSnapshot = (u64, HistorySpot); -type HistorySpot = (usize, Option, usize); +type HistorySpot = (usize, Option, usize, Option); fn history_spot(st: &photocraft_engine::DocState) -> HistorySpot { - (st.history.past_len(), st.history.entries().pop(), st.history.redo_labels().count()) + let newest = st.history.past_len().checked_sub(1).and_then(|i| st.history.state(i)).map(|d| std::sync::Arc::as_ptr(&d) as usize); + (st.history.past_len(), st.history.entries().pop(), st.history.redo_labels().count(), newest) } fn selected_snapshot_key(doc: photocraft_doc::DocId) -> egui::Id { From 76c514cdf5e26ce58d661151aa3e0db00bf0dad1 Mon Sep 17 00:00:00 2001 From: bommerts <44821497+bommerts@users.noreply.github.com> Date: Wed, 21 Oct 2026 16:15:23 -0400 Subject: [PATCH 205/649] Keep the CPU canvas sharp at 100% zoom (#8321) --- ATTRIBUTION.md | 1 + crates/ui-egui/src/canvas.rs | 62 ++++-- .../src/canvas/pixel_alignment_tests.rs | 126 +++++++++++++ .../images/cpu-pixel-alignment/LICENSE-APACHE | 177 ++++++++++++++++++ docs/images/cpu-pixel-alignment/LICENSE-MIT | 21 +++ docs/images/cpu-pixel-alignment/README.md | 7 + docs/images/cpu-pixel-alignment/after.png | Bin 0 -> 35275 bytes docs/images/cpu-pixel-alignment/before.png | Bin 0 -> 42454 bytes 8 files changed, 381 insertions(+), 13 deletions(-) create mode 100644 crates/ui-egui/src/canvas/pixel_alignment_tests.rs create mode 100644 docs/images/cpu-pixel-alignment/LICENSE-APACHE create mode 100644 docs/images/cpu-pixel-alignment/LICENSE-MIT create mode 100644 docs/images/cpu-pixel-alignment/README.md create mode 100644 docs/images/cpu-pixel-alignment/after.png create mode 100644 docs/images/cpu-pixel-alignment/before.png diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index cbbbe069a5..a5fe5ba9e3 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -84,6 +84,7 @@ The other built-in ICC profiles and the generated LUT looks are produced by code | `docs/brand/` (all files) | ArtCraft name, wordmark and mark | ArtCraft Team | getartcraft.com | Not open source; trademarks of the ArtCraft Team, [`docs/brand/LICENSE-brand.txt`](docs/brand/LICENSE-brand.txt) | | `docs/images/photocraft-*.jpg` | PhotoCraft screenshots | PhotoCraft contributors (UI) | Rendered offscreen with the `snapshot` example | MIT OR Apache-2.0 (UI); the artwork in each is public domain, listed below | | `docs/images/preferences-apply-*.png` | Preferences before and after adding Apply (no artwork) | PhotoCraft contributors | PhotoCraft control-channel capture and offscreen `snapshot` example | MIT OR Apache-2.0 | +| `docs/images/cpu-pixel-alignment/*.png` | CPU canvas pixel alignment, before and after #8321 | PhotoCraft contributors | Original synthetic noise rendered with the offscreen `snapshot` example; see the adjacent README | MIT OR Apache-2.0, adjacent `LICENSE-MIT` and `LICENSE-APACHE` | Artwork shown in the screenshots (all public domain, via Wikimedia Commons; details in [`docs/images/SOURCES.md`](docs/images/SOURCES.md)): diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 7b05bffce8..135db88dce 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -938,14 +938,46 @@ impl ViewXform { /// The main canvas's mapping for the active document as last laid out (inside the rulers). pub fn active(app: &PhotocraftApp) -> Option { let v = app.ui.views.get(app.session.active_index()?)?; - Some(Self { - rect: crate::rulers::content_rect(app, app.last_canvas_rect), - zoom: v.zoom / app.canvas_ppp(), - center: v.center, - flip: app.ui.view.flip_horizontal, - rotation: v.rotation, - aspect: app.ui.view.display_aspect(), - }) + Some( + Self { + rect: crate::rulers::content_rect(app, app.last_canvas_rect), + zoom: v.zoom / app.canvas_ppp(), + center: v.center, + flip: app.ui.view.flip_horizontal, + rotation: v.rotation, + aspect: app.ui.view.display_aspect(), + } + .pixel_aligned(app.canvas_ppp()), + ) + } + + /// At integer physical magnifications, texel edges must land on display pixel edges. + /// Keep this derived camera shared by images, overlays and input without changing the saved pan. + fn pixel_aligned(mut self, ppp: f32) -> Self { + if !ppp.is_finite() || ppp <= 0.0 || !self.zoom.is_finite() || self.zoom <= 0.0 || !self.rotation.is_finite() || self.rotation.abs() >= 1e-8 { + return self; + } + let scale = vec2(self.zoom_x(), self.zoom) * ppp; + if !scale.is_finite() + || scale.x.round() < 1.0 + || scale.y.round() < 1.0 + || (scale.x - scale.x.round()).abs() > 1e-5 + || (scale.y - scale.y.round()).abs() > 1e-5 + { + return self; + } + let origin = self.to_screen(0.0, 0.0); + let physical = origin * ppp; + if !physical.is_finite() { + return self; + } + let aligned = pos2(physical.x.round(), physical.y.round()) / ppp; + let offset = self.unmap_vec((aligned - origin) / self.zoom); + let center = [self.center[0] - offset.x, self.center[1] - offset.y]; + if center.iter().all(|v| v.is_finite()) { + self.center = center; + } + self } fn sincos(self) -> (f32, f32) { @@ -3144,7 +3176,7 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: let flip = app.ui.view.flip_horizontal; // Canvas geometry (ViewXform, ViewParams, painter rects) is in egui points. let point_zoom = view.zoom / ppp; - let xf = ViewXform { rect, zoom: point_zoom, center: view.center, flip, rotation: view.rotation, aspect }; + let xf = ViewXform { rect, zoom: point_zoom, center: view.center, flip, rotation: view.rotation, aspect }.pixel_aligned(ppp); let pixel_grid = app.ui.view.shows(app.ui.view.show.pixel_grid); let response = ui.allocate_rect(rect, Sense::click_and_drag()); let stroke_dismissal = primary && crate::shape_stroke_ui::dismiss_from_canvas(app, &response); @@ -3197,8 +3229,8 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: zoom: view.zoom * k as f32 / ppp, // A size-changing preview grows around the old image center; keep the view's pan. center: [ - view.center[0] / k as f32 + (preview_size[0] as f32 - original_size[0] as f32) / 2.0, - view.center[1] / k as f32 + (preview_size[1] as f32 - original_size[1] as f32) / 2.0, + xf.center[0] / k as f32 + (preview_size[0] as f32 - original_size[0] as f32) / 2.0, + xf.center[1] / k as f32 + (preview_size[1] as f32 - original_size[1] as f32) / 2.0, ], rotation: if view.rotation.is_finite() { view.rotation.to_radians() } else { 0.0 }, shadow: { @@ -3221,7 +3253,7 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: doc: doc.id.0, doc_size: [doc.size.width, doc.size.height], zoom: point_zoom, - center: view.center, + center: xf.center, rotation: if view.rotation.is_finite() { view.rotation.to_radians() } else { 0.0 }, shadow: { let t = crate::theme::Tokens::get(&ctx); @@ -4007,7 +4039,7 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: ctx.request_repaint(); } } - let xf = if crop_camera { ViewXform { center: view.center, rotation: view.rotation, ..xf } } else { xf }; + let xf = if crop_camera { ViewXform { center: view.center, rotation: view.rotation, ..xf }.pixel_aligned(ppp) } else { xf }; let (img_rect, beyond, layer_edges) = painted.unwrap_or_else(|| paint_canvas(app, ui, &view, xf)); if primary && !(hand_pan && response.dragged()) { // The transform preview is image content: it goes under the grid and guides, which @@ -9045,3 +9077,7 @@ mod display_memo_tests; #[cfg(test)] #[path = "canvas/blend_viewport_tests.rs"] mod blend_viewport_regression; + +#[cfg(test)] +#[path = "canvas/pixel_alignment_tests.rs"] +mod pixel_alignment_tests; diff --git a/crates/ui-egui/src/canvas/pixel_alignment_tests.rs b/crates/ui-egui/src/canvas/pixel_alignment_tests.rs new file mode 100644 index 0000000000..1f6859f8b1 --- /dev/null +++ b/crates/ui-egui/src/canvas/pixel_alignment_tests.rs @@ -0,0 +1,126 @@ +use super::*; + +fn xform(ppp: f32, physical_size: [f32; 2]) -> ViewXform { + ViewXform { + rect: Rect::from_min_size(pos2(40.0 / ppp, 100.0 / ppp), vec2(physical_size[0] / ppp, physical_size[1] / ppp)), + zoom: 1.0 / ppp, + center: [1500.0, 1000.0], + flip: false, + rotation: 0.0, + aspect: 1.0, + } +} + +fn assert_pixel_edges(xf: ViewXform, ppp: f32) { + for [x, y] in [[0.0, 0.0], [1.0, 1.0], [17.0, 29.0], [1500.0, 1000.0]] { + let p = xf.to_screen(x, y) * ppp; + assert!((p.x - p.x.round()).abs() < 0.001, "x edge: {p:?}, ppp {ppp}"); + assert!((p.y - p.y.round()).abs() < 0.001, "y edge: {p:?}, ppp {ppp}"); + } +} + +#[test] +fn actual_pixels_align_texel_edges_in_odd_viewports_at_every_display_scale() { + for ppp in [1.0, 1.25, 1.5, 2.0] { + for size in [[523.0, 470.0], [524.0, 471.0], [523.0, 471.0]] { + let before = xform(ppp, size); + let aligned = before.pixel_aligned(ppp); + assert_pixel_edges(aligned, ppp); + let delta = (aligned.to_screen(0.0, 0.0) - before.to_screen(0.0, 0.0)) * ppp; + assert!(delta.x.abs() <= 0.501 && delta.y.abs() <= 0.501); + let again = aligned.pixel_aligned(ppp); + assert!((again.to_screen(0.0, 0.0) - aligned.to_screen(0.0, 0.0)).length() < 0.001); + let back = aligned.to_doc(aligned.to_screen(123.25, 45.75)); + assert!((back[0] - 123.25).abs() < 0.001 && (back[1] - 45.75).abs() < 0.001); + } + } +} + +#[test] +fn integer_magnification_aligns_flipped_and_aspect_corrected_views() { + for flip in [false, true] { + let before = ViewXform { + rect: Rect::from_min_size(pos2(-20.25, 30.25), vec2(523.0, 471.0)), + zoom: 2.0, + center: [1500.125, 999.75], + flip, + aspect: 1.5, + ..xform(1.0, [523.0, 471.0]) + }; + assert_pixel_edges(before.pixel_aligned(1.0), 1.0); + } + let even = xform(1.0, [524.0, 470.0]); + assert_eq!(even.pixel_aligned(1.0).center, even.center); +} + +#[test] +fn fractional_zoom_rotation_and_invalid_scales_preserve_the_camera() { + let original = xform(1.0, [523.0, 471.0]); + for zoom in [0.25, 0.5, 0.75, 1.25, 1.5, 2.5, 0.0, -1.0, f32::NAN, f32::INFINITY] { + let xf = ViewXform { zoom, ..original }; + assert_eq!(xf.pixel_aligned(1.0).center, xf.center); + } + for rotation in [0.2, 30.0, 90.0, f32::NAN] { + let xf = ViewXform { rotation, ..original }; + assert_eq!(xf.pixel_aligned(1.0).center, xf.center); + } + for ppp in [0.0, -1.0, f32::NAN, f32::INFINITY] { + assert_eq!(original.pixel_aligned(ppp).center, original.center); + } + let aspect = ViewXform { aspect: 1.2, ..original }; + assert_eq!(aspect.pixel_aligned(1.0).center, aspect.center); +} + +#[test] +fn active_transform_uses_the_same_alignment_without_changing_saved_pan() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", serde_json::json!({"width": 3000, "height": 2000})).unwrap(); + app.sync_views(); + for ppp in [1.0, 1.25, 1.5, 2.0] { + app.ppp = ppp; + app.last_canvas_rect = xform(ppp, [523.0, 471.0]).rect; + app.ui.views[0].center = [1500.0, 1000.0]; + app.ui.views[0].zoom = 1.0; + let before = app.ui.views[0].center; + let active = ViewXform::active(&app).unwrap(); + assert_pixel_edges(active, ppp); + assert_eq!(app.ui.views[0].center, before); + } +} + +#[test] +fn cpu_canvas_paints_its_image_on_physical_pixel_edges() { + for ppp in [1.0, 1.25, 2.0] { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", serde_json::json!({"width": 64, "height": 64, "background": "white"})).unwrap(); + app.sync_views(); + app.ppp = ppp; + app.ui.views[0].zoom = 1.0; + app.ui.views[0].center = [32.0, 32.0]; + app.ui.views[0].fit_pending = false; + app.ui.views[0].doc_size = [64, 64]; + let ctx = egui::Context::default(); + ctx.set_pixels_per_point(ppp); + let tex = ensure_texture(&mut app, &ctx, 0, None).unwrap().0; + let view = app.ui.views[0].clone(); + let saved_center = view.center; + let mut out = ctx.run_ui(egui::RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(900.0, 600.0))), ..Default::default() }, |ui| { + canvas_view(&mut app, ui, 0, xform(ppp, [523.0, 471.0]).rect, view.clone(), false); + }); + out.textures_delta.clear(); + let mesh = out + .shapes + .iter() + .find_map(|s| match &s.shape { + egui::Shape::Mesh(mesh) if mesh.texture_id == tex => Some(mesh), + _ => None, + }) + .expect("CPU document image quad"); + assert_eq!(mesh.vertices.len(), 4); + for vertex in &mesh.vertices { + let p = vertex.pos * ppp; + assert!((p.x - p.x.round()).abs() < 0.001 && (p.y - p.y.round()).abs() < 0.001, "ppp {ppp}: {p:?}"); + } + assert_eq!(app.ui.views[0].center, saved_center); + } +} diff --git a/docs/images/cpu-pixel-alignment/LICENSE-APACHE b/docs/images/cpu-pixel-alignment/LICENSE-APACHE new file mode 100644 index 0000000000..f433b1a53f --- /dev/null +++ b/docs/images/cpu-pixel-alignment/LICENSE-APACHE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/docs/images/cpu-pixel-alignment/LICENSE-MIT b/docs/images/cpu-pixel-alignment/LICENSE-MIT new file mode 100644 index 0000000000..68facca4cf --- /dev/null +++ b/docs/images/cpu-pixel-alignment/LICENSE-MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 ArtCraft Team and the PhotoCraft contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/docs/images/cpu-pixel-alignment/README.md b/docs/images/cpu-pixel-alignment/README.md new file mode 100644 index 0000000000..30c3edd40e --- /dev/null +++ b/docs/images/cpu-pixel-alignment/README.md @@ -0,0 +1,7 @@ +# CPU canvas pixel alignment (#8321) + +Original 200 × 200 pixel crops at screen coordinates (200, 250)–(400, 450) from 900 × 600 offscreen renders at display scale 1. The scene is a white 1024 × 768 RGB document with 60% monochromatic Add Noise, viewed at Actual Pixels through the CPU canvas (`--safe-gpu`). No external artwork is used. + +`before.png` shows the half-pixel horizontal offset. `after.png` shows the aligned canvas and is byte-for-byte equal to the GPU canvas crop. Their grayscale standard deviations are 17.4105 and 24.6821 respectively. The 901-pixel-wide control stays sharp. + +The source document fits the offscreen WARP adapter texture limit, so reduced-texture sampling does not mask the pixel-alignment comparison. These captures are original PhotoCraft assets, licensed MIT OR Apache-2.0 (the license files are alongside them). diff --git a/docs/images/cpu-pixel-alignment/after.png b/docs/images/cpu-pixel-alignment/after.png new file mode 100644 index 0000000000000000000000000000000000000000..43b407fce316597c83a0b52658838481364accb4 GIT binary patch literal 35275 zcmV)QK(xP!P)AN=44@4oSkZ@m1>_mHoB z?Q8EnZ#n<{zyJ65e*cGm_=k7D@f*MK_IKrf{Ez?f?zevHw_bk!zyJ6DzWo2wpZ@gS zFMs*VcYprpfBy3OzyJHczdg@;fBn~g{oSvA^{bcf@&893ef0J@_4~s={KI#D^;duO z?tlHS|Ml{|e*T-k`J3;(|L_0)@8A8m|MuTr+SxXI=}TXF_h0_Ye|h^Gb@}5z{^OUQ z)yIGQ$A7$it{y)9^wYP${qToBd@F;$^X_kc^P4Zf|MqYH_Ivf9jy%JA|K(r)<>ha` z^EyFZFB;`>4Nq8UNp)4JUc42gsi~{**TWd5$vN+Y{t6%-< z+wTAv`PYB_*UuRQ5K@~Cj`@jGD@Ba7y{@?HZ&;R*9@0E$vb_lw}h6uz{uu?Cb4%?ha0{OeY z`@5HR`Knt)ay0O~;7Zi3!)W^_u~I{#O`@|Bm*!Tm!6%8ms=y-&r|$b!;J z`@N3eQrO&PMqd>?AiZqX^oL@%tQx0XWN$ zE3^S8gUM*;|NNi-^Uaz2y}$k2zkT^%$Jc3=Ir+KHRe+%n>O?fN%>V)CArdbGBm7+f z@J4B+`YjpYa6kCL58nOP|N39wiyDo_kR5=>cG{Nzc@Iv7PAn5F@iUICjudpw_fGY% zh_C8LtWa0T5G+wgu!PXwC4O|z-*`@f!9gSsv4A{a7E_s%(5RCVDXiX&x5K!Ug$D`% zSxM0ui~;}$AW>nIxM0*-0X`|jNdVm{!N{Sa7HlZNwoqsE0K@J3VW(|_qBD^a0a!sx zBt>VNx*-4rU?BiWU;)HNYToI0As|`VDBXJU?8%97jz+vjUO;b}j9@eL%im#M-uIKA z{Nx3+{EQx{BjsTWoDyQ8{wS1b+P$%ll@2f9t*D@hEF!Z2tD4=;hVkHqigRLo4rSc*gOn$7VHowO^`3&H} zMus~SEHfi@J}b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7%>{%CH*}W0ca>_U5 zq^dz?R_lPZ#K70d=C9hi%~iRzO^Yy{AX}+%A64jFw?(F%9w(m~&@Wu)O zSo`CYA-oM;Bi#a7UfM*5Rev^*h(SC<moxQKhRS>t{7#eUE z_pUZba6Ru}YMO_4(v@=Rv{&t2@CjeoJxCYA2^czMkUVSGh&`&&GzQD&-{+0l9AE4= zX|Y0frPauu0j7r=xXn~pWw}EwD(tg$sZf9=LTDjTa09N}h8AMEkU{)y?f`warxip} zDQWAc1At6{wcWUY$}-Ip*69|9X&qaARheRpe3x?OFC?D*%FFO@Dhb9CMqZJzdqv4sf$ldU+e9iE!)hQ5J7`^ zIMMgv0*%ua8|u9fT2a^Lv$Y^2tSvj2c)iI%PKCl*P<0y>b+F-PPs~-Ywsx^IWs994 zEq2Qu*Myjo?=&i0$)}s#KmOxCzG%02vqI1&&7B}%g`Ddyz{Vgh-X+c@(4|X++u#5F z-~U1(n255C>^=3dsb0m0gydq&|I2^*FE6nmoYtBP(FY)LCIw8};5Jc#87HTD?>3BT z7KgT0Y5w`4MaXi?5@)!2^KxCkCfpNjloG2!URox~i?!!$nTMXkC}fK4?~gwE=p{`j zhIxu|XDMt5T&vIehp>F6qg(=Zmwl qrARm!PW{c_{LM?wY2tBn`u_kbmb*#X$+Ii~0000 Date: Wed, 21 Oct 2026 16:19:24 -0400 Subject: [PATCH 206/649] Preserve continuous camera movement in default Crop --- crates/ui-egui/src/canvas.rs | 12 +++++++++--- crates/ui-egui/src/canvas/pixel_alignment_tests.rs | 10 ++++++++++ docs/images/cpu-pixel-alignment/README.md | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 135db88dce..db8a44bccf 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -947,10 +947,16 @@ impl ViewXform { rotation: v.rotation, aspect: app.ui.view.display_aspect(), } - .pixel_aligned(app.canvas_ppp()), + .pixel_aligned_for(app, app.canvas_ppp()), ) } + fn pixel_aligned_for(self, app: &PhotocraftApp, ppp: f32) -> Self { + // Default Crop counter-moves the frame and camera with fractional pointer deltas. + // Preserve that continuous mapping so its fixed frame does not wobble during a drag. + if crate::crop_mode::moves_image(app) { self } else { self.pixel_aligned(ppp) } + } + /// At integer physical magnifications, texel edges must land on display pixel edges. /// Keep this derived camera shared by images, overlays and input without changing the saved pan. fn pixel_aligned(mut self, ppp: f32) -> Self { @@ -3176,7 +3182,7 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: let flip = app.ui.view.flip_horizontal; // Canvas geometry (ViewXform, ViewParams, painter rects) is in egui points. let point_zoom = view.zoom / ppp; - let xf = ViewXform { rect, zoom: point_zoom, center: view.center, flip, rotation: view.rotation, aspect }.pixel_aligned(ppp); + let xf = ViewXform { rect, zoom: point_zoom, center: view.center, flip, rotation: view.rotation, aspect }.pixel_aligned_for(app, ppp); let pixel_grid = app.ui.view.shows(app.ui.view.show.pixel_grid); let response = ui.allocate_rect(rect, Sense::click_and_drag()); let stroke_dismissal = primary && crate::shape_stroke_ui::dismiss_from_canvas(app, &response); @@ -4039,7 +4045,7 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: ctx.request_repaint(); } } - let xf = if crop_camera { ViewXform { center: view.center, rotation: view.rotation, ..xf }.pixel_aligned(ppp) } else { xf }; + let xf = if crop_camera { ViewXform { center: view.center, rotation: view.rotation, ..xf }.pixel_aligned_for(app, ppp) } else { xf }; let (img_rect, beyond, layer_edges) = painted.unwrap_or_else(|| paint_canvas(app, ui, &view, xf)); if primary && !(hand_pan && response.dragged()) { // The transform preview is image content: it goes under the grid and guides, which diff --git a/crates/ui-egui/src/canvas/pixel_alignment_tests.rs b/crates/ui-egui/src/canvas/pixel_alignment_tests.rs index 1f6859f8b1..1e6126da3e 100644 --- a/crates/ui-egui/src/canvas/pixel_alignment_tests.rs +++ b/crates/ui-egui/src/canvas/pixel_alignment_tests.rs @@ -124,3 +124,13 @@ fn cpu_canvas_paints_its_image_on_physical_pixel_edges() { assert_eq!(app.ui.views[0].center, saved_center); } } + +#[test] +fn crop_image_movement_keeps_its_continuous_camera_mapping() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.ui.tool = Tool::Crop; + let xf = xform(1.0, [523.0, 471.0]); + assert_eq!(xf.pixel_aligned_for(&app, 1.0).center, xf.center); + app.ui.tool_options.crop_shield.classic_mode = true; + assert_pixel_edges(xf.pixel_aligned_for(&app, 1.0), 1.0); +} diff --git a/docs/images/cpu-pixel-alignment/README.md b/docs/images/cpu-pixel-alignment/README.md index 30c3edd40e..d1993a7d12 100644 --- a/docs/images/cpu-pixel-alignment/README.md +++ b/docs/images/cpu-pixel-alignment/README.md @@ -5,3 +5,5 @@ Original 200 × 200 pixel crops at screen coordinates (200, 250)–(400, 450) fr `before.png` shows the half-pixel horizontal offset. `after.png` shows the aligned canvas and is byte-for-byte equal to the GPU canvas crop. Their grayscale standard deviations are 17.4105 and 24.6821 respectively. The 901-pixel-wide control stays sharp. The source document fits the offscreen WARP adapter texture limit, so reduced-texture sampling does not mask the pixel-alignment comparison. These captures are original PhotoCraft assets, licensed MIT OR Apache-2.0 (the license files are alongside them). + +Default Crop keeps its continuous camera positioning so the crop frame stays fixed during fractional pointer drags. Normal canvas views and Classic Crop use pixel alignment at integral physical magnifications. From aa1a77b9dac07b3846f43f39ae3d22c0168026d1 Mon Sep 17 00:00:00 2001 From: David Bonnier Date: Fri, 16 Oct 2026 15:14:37 +0200 Subject: [PATCH 207/649] fix(io/ui): allow explicit PSD recovery with non-overwriting Save a Copy --- apps/photocraft/src/services.rs | 17 ++ crates/engine/src/file_cmds.rs | 49 +++++- crates/engine/src/jobs.rs | 25 ++- crates/engine/src/lib.rs | 4 + crates/io/src/lib.rs | 186 ++++++++++++++++++++- crates/io/src/psd_import.rs | 68 +++++++- crates/io/src/recovery.rs | 108 ++++++++++++ crates/io/tests/psd_recovery_generated.rs | 64 ++++++++ crates/io/tests/support/recovery_psd.rs | 191 ++++++++++++++++++++++ crates/ui-egui/src/file_ui.rs | 3 + crates/ui-egui/src/jobs_ui.rs | 11 +- crates/ui-egui/src/lib.rs | 74 +++++++-- crates/ui-egui/src/menus.rs | 3 +- crates/ui-egui/src/open_prompt.rs | 60 ++++++- crates/ui-egui/src/save_identity_tests.rs | 62 +++++++ crates/ui-egui/src/view_cmds.rs | 32 +++- 16 files changed, 916 insertions(+), 41 deletions(-) create mode 100644 crates/io/src/recovery.rs create mode 100644 crates/io/tests/psd_recovery_generated.rs create mode 100644 crates/io/tests/support/recovery_psd.rs diff --git a/apps/photocraft/src/services.rs b/apps/photocraft/src/services.rs index 082506e92c..1b26a3bcdf 100644 --- a/apps/photocraft/src/services.rs +++ b/apps/photocraft/src/services.rs @@ -363,6 +363,19 @@ fn save_through( Ok(r.warnings) } +fn recovery_save_file( + doc: &Document, + path: &str, + settings: &photocraft_ui_egui::ExportSettings, + ctl: &photocraft_ui_egui::jobs_ui::SaveCtl, +) -> Result, String> { + save_through(doc, path, settings, ctl, |p, b, progress| { + photocraft_io::write_recovery_copy_bytes(Path::new(p), b).map_err(|e| e.to_string())?; + progress(1.0); + Ok(()) + }) +} + fn save_file( doc: &Document, path: &str, @@ -537,6 +550,10 @@ pub fn native(automation: Option) -> crate::crash_guard::guard("Export", || photocraft_io::export(doc, path, &opts).map(|r| (r.bytes, r.warnings)).map_err(|e| e.to_string())) })), save_file: Some(Arc::new(save_file)), + recovery_save_file: Some(Arc::new(recovery_save_file)), + recovery_write: Some(Box::new(|path: &str, bytes: &[u8]| { + photocraft_io::write_recovery_copy_bytes(Path::new(path), bytes).map_err(|e| e.to_string()) + })), file_dialog: Some(Box::new(show_file_dialog)), write: Some(Box::new(|path: &str, bytes: &[u8]| write_atomic(Path::new(path), bytes))), file_stamp: Some(Box::new(|path: &str| { diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index 5f3a5edec0..45c298d005 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -540,6 +540,9 @@ fn save_a_copy(s: &mut Session, p: &Value) -> Result { msg: "`path` is the document's own file, so the copy would replace it: choose another path, or pass \"overwrite\": true".into(), }); } + // Engine commands can be replayed from scripts. Recovery mode is never + // allowed to use the ordinary replacement writer, even for Save a Copy. + let recovery = d.recovery_mode; let mut doc = (*d.doc).clone(); if p.get("layers").and_then(Value::as_bool) == Some(false) { // "Layers" unchecked in Save a Copy: write the flattened image. @@ -547,7 +550,14 @@ fn save_a_copy(s: &mut Session, p: &Value) -> Result { let px = flattened(&doc, fmt); doc.layers = vec![Layer::new("Background", LayerContent::Raster(px))]; } - let warnings = save_doc(&doc, &path, SaveOpts::from_params(s, p, "file.saveACopy")?)?; + let opts = SaveOpts::from_params(s, p, "file.saveACopy")?; + let warnings = if recovery { + let (bytes, warnings) = encode(&doc, &path, opts)?; + photocraft_io::write_recovery_copy_bytes(std::path::Path::new(&path), &bytes).map_err(|e| EngineError::Other(e.to_string()))?; + warnings + } else { + save_doc(&doc, &path, opts)? + }; Ok(json!({"path": path, "warnings": warnings})) } @@ -1451,7 +1461,15 @@ fn flatten_all_masks(s: &mut Session) -> Result { fn layers_to_files(s: &mut Session, p: &Value) -> Result { let cmd = "file.export.layersToFiles"; let dir = str_param(p, "dir", cmd).or_else(|_| str_param(p, "output", cmd))?.to_string(); - let names = export_layers_with(s, p, |name, bytes| write_file(&join(&dir, name), bytes))?; + let recovery = s.active().is_some_and(|d| d.recovery_mode); + let names = export_layers_with(s, p, |name, bytes| { + let path = join(&dir, name); + if recovery { + photocraft_io::write_recovery_copy_bytes(std::path::Path::new(&path), bytes).map_err(|e| EngineError::Other(e.to_string())) + } else { + write_file(&path, bytes) + } + })?; let files: Vec = names.iter().map(|name| join(&dir, name)).collect(); Ok(json!({"files": files})) } @@ -1623,7 +1641,11 @@ fn color_lookup_tables(s: &mut Session, p: &Value) -> Result { let cube = bake_cube_layers(size as usize, &title, &layers); match p.get("path").and_then(Value::as_str) { Some(path) => { - write_file(path, cube.as_bytes())?; + if d.recovery_mode { + photocraft_io::write_recovery_copy_bytes(std::path::Path::new(path), cube.as_bytes()).map_err(|e| EngineError::Other(e.to_string()))?; + } else { + write_file(path, cube.as_bytes())?; + } Ok(json!({"path": path, "size": size, "layerCount": count})) } None => Ok(json!({"cube": cube, "size": size, "layerCount": count})), @@ -1925,3 +1947,24 @@ mod aces_exr_tests { } } } + +#[cfg(test)] +mod psd_recovery_tests { + use super::*; + #[cfg(not(target_arch = "wasm32"))] + #[test] + fn an_engine_action_does_not_replace_an_existing_file_in_recovery_mode() { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 2, "height": 2})).unwrap(); + s.active_mut().unwrap().recovery_mode = true; + let path = std::env::temp_dir().join(format!( + "photocraft-engine-recovery-{}-{}", + std::process::id(), + std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos() + )); + std::fs::write(&path, b"original").unwrap(); + assert!(s.execute("file.saveACopy", json!({"path": path})).is_err()); + assert_eq!(std::fs::read(&path).unwrap(), b"original"); + std::fs::remove_file(path).unwrap(); + } +} diff --git a/crates/engine/src/jobs.rs b/crates/engine/src/jobs.rs index 0ee0573170..c97cab6b06 100644 --- a/crates/engine/src/jobs.rs +++ b/crates/engine/src/jobs.rs @@ -507,6 +507,17 @@ impl Session { /// result is `{held, name, warnings, color}` (`color` the question): take it with /// [`Session::take_held_open`] once answered. pub fn start_open(&mut self, name: &str, source: OpenSource) -> Result { + self.start_open_inner(name, source, false) + } + + /// GUI opening: PSDs are decoded with the opt-in recovery path, but a + /// damaged result is held back until the user accepts the recovery prompt. + /// Headless/automation opening keeps the strict default above. + pub fn start_open_for_user(&mut self, name: &str, source: OpenSource) -> Result { + self.start_open_inner(name, source, true) + } + + fn start_open_inner(&mut self, name: &str, source: OpenSource, offer_recovery: bool) -> Result { let label = format!("Opening {name}"); let name_w = name.to_string(); let name_a = name.to_string(); @@ -525,7 +536,13 @@ impl Session { ctx.check()?; ctx.progress(0.02, "Decoding"); let imported = ctx - .stage(0.02, 0.95, "Decoding", |ctl| photocraft_io::import_with_svg_group_depth_and_interrupt(&name_w, &bytes, max_svg_group_depth, ctl)) + .stage(0.02, 0.95, "Decoding", |ctl| { + if offer_recovery && photocraft_io::is_psd(&bytes) { + photocraft_io::import_psd_for_recovery_with(&name_w, &bytes, ctl) + } else { + photocraft_io::import_with_svg_group_depth_and_interrupt(&name_w, &bytes, max_svg_group_depth, ctl) + } + }) .map_err(|e| match e { photocraft_io::IoError::Cancelled => EngineError::Cancelled, e => EngineError::Other(e.to_string()), @@ -540,9 +557,11 @@ impl Session { // Ask When Opening: held back until the prompt is answered (`take_held_open`). A // developed raw has no embedded profile to ask about. let raw = r.warnings.iter().any(|w| w.contains(photocraft_io::raw::DEVELOPED_NOTE)); - if let Some(question) = s.color.open_question(&r.document).filter(|_| !raw) { + let recovery = offer_recovery && r.source_read_only && r.warnings.iter().any(|w| w.starts_with("PSD/PSB RECOVERY:")); + let question = s.color.open_question(&r.document).filter(|_| !raw); + if recovery || question.is_some() { let held = s.hold_open(r.document, r.source_read_only); - return Ok(json!({"held": held, "name": name_a, "warnings": r.warnings, "color": question})); + return Ok(json!({"held": held, "name": name_a, "warnings": r.warnings, "color": question, "recovery": recovery})); } let (index, color) = s.open_document(r.document, None); if let Some(st) = s.active_mut() { diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 5a7aa83dfb..87d79cf466 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -208,6 +208,9 @@ pub struct DocState { pub path: Option, /// An Affinity document (or its preview) must not acquire the native source as its Save path. pub source_read_only: bool, + /// This session came from a damaged PSD: every save is a new, no-overwrite copy. + /// Kept outside history so Undo and Save a Copy cannot remove the restriction. + pub recovery_mode: bool, /// Increments on every change; UIs re-render when it moves. pub revision: u64, pub saved_revision: u64, @@ -273,6 +276,7 @@ impl DocState { layer_anchor: active_layer, path, source_read_only: false, + recovery_mode: false, revision: 1, saved_revision: 1, view_revision: 0, diff --git a/crates/io/src/lib.rs b/crates/io/src/lib.rs index fdf7831181..5184dc0613 100644 --- a/crates/io/src/lib.rs +++ b/crates/io/src/lib.rs @@ -61,6 +61,8 @@ mod pdn; pub mod pixels; mod psd_export; mod psd_import; +mod recovery; +pub use recovery::write_recovery_copy_bytes; pub mod psd_thumbnail; pub mod raw; pub mod slices_map; @@ -309,7 +311,87 @@ pub fn import_with_svg_group_depth_and_interrupt( Ok(r) } +/// Import a damaged PSD/PSB for explicit recovery. Unlike [`import`], this +/// permits partially decoded layers, but marks the result source-read-only. +/// +/// Front ends must show `warnings`, require user consent before editing, +/// keep a session-level recovery flag, and use [`write_recovery_copy_bytes`] +/// for every write: it publishes only NEW file names and never replaces the +/// damaged original (or any existing file). Do not use this API as a drop-in +/// replacement for [`import`]. +pub fn import_psd_for_recovery(name: &str, bytes: &[u8]) -> Result { + import_psd_for_recovery_with(name, bytes, &photocraft_raster::Interrupt::NONE) +} + +/// Cancelable version of [`import_psd_for_recovery`]. +pub fn import_psd_for_recovery_with(name: &str, bytes: &[u8], ctl: &photocraft_raster::Interrupt) -> Result { + if !is_psd(bytes) { + return Err(IoError::Unsupported("recovery import accepts only PSD/PSB files".into())); + } + ctl.check().map_err(|_| IoError::Cancelled)?; + let result = import_stages_with_psd_recovery(name, bytes, ctl, photocraft_doc::MAX_GROUP_DEPTH, true)?; + ctl.check().map_err(|_| IoError::Cancelled)?; + ctl.progress(1.0); + Ok(result) +} + +/// Refuse a recovered document's copy destination if it names its source. +/// Canonical paths catch lexical aliases, `..`, relative paths, and symlinks; +/// on Unix, inode/device identity also catches hardlinks. The source must +/// exist, otherwise the check fails closed. +/// +/// This validates a destination at one instant; front ends must call it +/// immediately before their atomic write/rename. Callers also need to prevent +/// concurrent destination replacement (TOCTOU), or use a platform-specific +/// no-overwrite file operation. +pub fn validate_recovery_copy_destination(source: &std::path::Path, destination: &std::path::Path) -> Result<(), IoError> { + use std::io::ErrorKind; + use std::path::Path; + + let denied = || IoError::Unsupported("recovery copy must not overwrite the original PSD/PSB file".into()); + let source_path = std::fs::canonicalize(source).map_err(|e| IoError::Unsupported(format!("cannot verify original PSD/PSB path: {e}")))?; + let source_metadata = std::fs::metadata(source).map_err(|e| IoError::Unsupported(format!("cannot stat original PSD/PSB file: {e}")))?; + + let (candidate, exists) = match std::fs::symlink_metadata(destination) { + Ok(_) => (std::fs::canonicalize(destination).map_err(|e| IoError::Unsupported(format!("cannot resolve recovery destination: {e}")))?, true), + Err(e) if e.kind() == ErrorKind::NotFound => { + let parent = destination.parent().filter(|p| !p.as_os_str().is_empty()).unwrap_or(Path::new(".")); + let directory = std::fs::canonicalize(parent).map_err(|e| IoError::Unsupported(format!("cannot resolve recovery destination folder: {e}")))?; + let filename = destination.file_name().ok_or_else(|| IoError::Unsupported("recovery copy needs a filename".into()))?; + (directory.join(filename), false) + } + Err(e) => return Err(IoError::Unsupported(format!("cannot inspect recovery destination: {e}"))), + }; + if candidate == source_path { + return Err(denied()); + } + + // A hard link has a different path but the same inode. + #[cfg(unix)] + if exists { + use std::os::unix::fs::MetadataExt; + let metadata = std::fs::metadata(destination).map_err(|e| IoError::Unsupported(format!("cannot stat recovery destination: {e}")))?; + if metadata.dev() == source_metadata.dev() && metadata.ino() == source_metadata.ino() { + return Err(denied()); + } + } + #[cfg(not(unix))] + let _ = (source_metadata, exists); + + Ok(()) +} + fn import_stages(name: &str, bytes: &[u8], ctl: &photocraft_raster::Interrupt, max_group_depth: usize) -> Result { + import_stages_with_psd_recovery(name, bytes, ctl, max_group_depth, false) +} + +fn import_stages_with_psd_recovery( + name: &str, + bytes: &[u8], + ctl: &photocraft_raster::Interrupt, + max_group_depth: usize, + recovery_requested: bool, +) -> Result { // A declared native extension must reach its loader so malformed bundles retain format errors. if has_extension(name, photocraft_format::EXTENSION) || photocraft_format::is_pcraft(bytes) { let document = photocraft_format::load_from_bytes(bytes)?; @@ -327,10 +409,27 @@ fn import_stages(name: &str, bytes: &[u8], ctl: &photocraft_raster::Interrupt, m psd_import::check_group_depth(&file)?; ctl.check().map_err(|_| IoError::Cancelled)?; ctl.progress(0.05); - let (mut document, warnings) = psd_import::psd_to_document_decoded(&file, ctl, merged).ok_or(IoError::Cancelled)?; + let (mut document, mut warnings, unsafe_for_editing) = psd_import::psd_to_document_decoded_integrity(&file, ctl, merged).ok_or(IoError::Cancelled)?; + // An imported document cannot be trusted when channels or layer blocks failed to decode: + // allowing a normal Save or a Save As targeting the original would destroy the raw data. + // The normal importer remains fail-closed. Only an explicit recovery request can open + // partial content, and its caller must enforce validate_recovery_copy_destination(). + if unsafe_for_editing && !recovery_requested { + return Err(IoError::Unsupported(format!( + "PSD/PSB contains unreadable image, layer or mask data; editing was refused to protect the source file ({})", + warnings + .iter() + .find(|w| w.contains("could not be decoded") || w.contains("could not be read") || w.contains("not imported")) + .map(String::as_str) + .unwrap_or("incomplete import"), + ))); + } + if unsafe_for_editing { + warnings.insert(0, "PSD/PSB RECOVERY: the document is incomplete. The original must never be overwritten. Use Save a Copy to a different file; some layers, masks or channels are missing.".into()); + } document.name = name.to_string(); text_import::prepare(&mut document); - return Ok(ImportResult { document, warnings, source_read_only: false, preview_only: false }); + return Ok(ImportResult { document, warnings, source_read_only: unsafe_for_editing, preview_only: false }); } if affinity::is_affinity(bytes) || affinity::has_extension(name) { return affinity::import(name, bytes); @@ -585,7 +684,88 @@ pub fn merged_composite(file: &PsdFile) -> Result, IoError> { #[cfg(test)] mod tests { - use super::is_svg_input; + use super::{IoError, import, is_svg_input}; + use photocraft_psd::{Compression, Version, testgen}; + + #[test] + fn valid_psd_can_still_be_edited() { + let bytes = testgen::small(Version::Psd, Compression::Raw).to_bytes().unwrap(); + let imported = import("valid.psd", &bytes).unwrap(); + assert!(!imported.source_read_only); + } + + #[test] + fn unreadable_psd_channel_is_rejected_before_editing() { + let mut file = testgen::small(Version::Psd, Compression::Raw); + let channel = file.layers_mut()[0].channels.iter_mut().find(|c| c.id == 0).unwrap(); + channel.data.clear(); + let bytes = file.to_bytes().unwrap(); + assert!(matches!( + import("damaged.psd", &bytes), + Err(IoError::Unsupported(reason)) if reason.contains("unreadable") + )); + } + + #[test] + fn explicit_recovery_opens_unreadable_psd_read_only() { + let mut file = testgen::small(Version::Psd, Compression::Raw); + let channel = file.layers_mut()[0].channels.iter_mut().find(|c| c.id == 0).unwrap(); + channel.data.clear(); + let bytes = file.to_bytes().unwrap(); + // Existing P0 behaviour: ordinary open is refused. + assert!(import("damaged.psd", &bytes).is_err()); + // Explicit recovery: a partial document, but never normal source save. + let recovered = super::import_psd_for_recovery("damaged.psd", &bytes).unwrap(); + assert!(recovered.source_read_only); + assert!(!recovered.preview_only); + assert!(recovered.warnings.iter().any(|w| w.contains("RECOVERY"))); + assert!(recovered.warnings.iter().any(|w| w.contains("could not be decoded"))); + } + + #[test] + fn recovery_import_of_valid_psd_remains_editable() { + let bytes = testgen::small(Version::Psd, Compression::Raw).to_bytes().unwrap(); + let result = super::import_psd_for_recovery("valid.psd", &bytes).unwrap(); + assert!(!result.source_read_only); + } + + #[test] + fn recovery_import_rejects_other_formats() { + assert!(super::import_psd_for_recovery("image.png", b"not a PSD").is_err()); + } + + #[test] + fn recovery_copy_guard_rejects_original_and_aliases() { + use std::fs; + use std::time::{SystemTime, UNIX_EPOCH}; + + let nonce = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos(); + let root = std::env::temp_dir().join(format!("photocraft-recovery-{nonce}-{}", std::process::id())); + fs::create_dir_all(root.join("subdir")).unwrap(); + let source = root.join("original.psd"); + fs::write(&source, b"original unchanged").unwrap(); + + assert!(super::validate_recovery_copy_destination(&source, &source).is_err()); + assert!(super::validate_recovery_copy_destination(&source, &root.join("subdir/../original.psd")).is_err()); + assert!(super::validate_recovery_copy_destination(&source, &root.join("recovered.psd")).is_ok()); + assert!(super::validate_recovery_copy_destination(&source, &root.join("subdir/recovered.psd")).is_ok()); + + #[cfg(unix)] + { + use std::os::unix::fs::symlink; + let link = root.join("alias.psd"); + symlink(&source, &link).unwrap(); + assert!(super::validate_recovery_copy_destination(&source, &link).is_err()); + let hardlink = root.join("hardlink.psd"); + fs::hard_link(&source, &hardlink).unwrap(); + assert!(super::validate_recovery_copy_destination(&source, &hardlink).is_err()); + let directory_link = root.join("alias_dir"); + symlink(&root, &directory_link).unwrap(); + assert!(super::validate_recovery_copy_destination(&source, &directory_link.join("original.psd")).is_err()); + } + assert_eq!(fs::read(&source).unwrap(), b"original unchanged"); + fs::remove_dir_all(root).unwrap(); + } #[test] fn svg_extension_does_not_override_another_format_signature() { diff --git a/crates/io/src/psd_import.rs b/crates/io/src/psd_import.rs index 8a948aa6e2..2acfab577d 100644 --- a/crates/io/src/psd_import.rs +++ b/crates/io/src/psd_import.rs @@ -51,6 +51,8 @@ pub(crate) struct Ctx<'a> { pub cc: usize, pub cmyk: bool, pub warnings: Vec, + /// The import lost source data that cannot be safely written back to PSD/PSB. + pub unsafe_for_editing: bool, /// Document resolution (type sizes are converted to points with it). pub dpi: f32, /// The parsed `Txt2` block (type settings EngineData lacks, e.g. optical kerning). @@ -132,6 +134,11 @@ impl Ctx<'_> { self.warnings.push(s.into()); } + fn warn_unreadable_data(&mut self, s: impl Into) { + self.unsafe_for_editing = true; + self.warn(s); + } + /// Source id, transform, (Distort/Perspective) projective placement and warp of a placed /// layer that has only a `PlLd` block, as Photoshop CS2 and older write it (#2465). `PlLd` /// stores the placed corners but not the source size, which comes from the embedded file. @@ -167,7 +174,7 @@ impl Ctx<'_> { match rec.decode_channel(id, self.file.header.depth, self.file.header.version) { Ok(p) => Some(p), Err(e) => { - self.warn(format!("layer \"{name}\": channel {id} could not be decoded ({e}); treated as empty")); + self.warn_unreadable_data(format!("layer \"{name}\": channel {id} could not be decoded ({e}); treated as empty")); None } } @@ -200,7 +207,7 @@ impl Ctx<'_> { let mut planes: Vec>> = Vec::with_capacity(decoded.len()); for (&id, p) in ids.iter().zip(decoded) { if p.is_none() && rec.channel(id).is_some() { - self.warn(format!("layer \"{name}\": channel {id} could not be decoded; treated as empty")); + self.warn_unreadable_data(format!("layer \"{name}\": channel {id} could not be decoded; treated as empty")); } planes.push(p); } @@ -826,6 +833,17 @@ pub(crate) fn psd_to_document_decoded( ctl: &photocraft_raster::Interrupt, decoded: Option>>, ) -> Option<(Document, Vec)> { + psd_to_document_decoded_integrity(file, ctl, decoded).map(|(document, warnings, _)| (document, warnings)) +} + +/// Also reports whether unrecoverable channel, layer or merged-image data was discarded. +/// Normal imports reject that result before exposing the document for editing; callers using +/// the low-level conversion API retain its existing best-effort behaviour. +pub(crate) fn psd_to_document_decoded_integrity( + file: &PsdFile, + ctl: &photocraft_raster::Interrupt, + decoded: Option>>, +) -> Option<(Document, Vec, bool)> { let h = &file.header; let mut warnings = Vec::new(); let mode = doc_mode(h.color_mode).unwrap_or_else(|| { @@ -892,7 +910,9 @@ pub(crate) fn psd_to_document_decoded( // A 16/32-bit file whose layer block can't be parsed would otherwise open as a flattened // file without a word (#2700). The raw block is kept, but a PSD save writes the document's // own layers in its place (see `psd_export`). + let mut unsafe_for_editing = false; if let Some((b, e)) = file.unreadable_layer_block() { + unsafe_for_editing = true; warnings.push(format!( "the layers ({} block) could not be read ({e}); only the merged image was opened. Saving as PSD replaces the unreadable layer data", b.key_str() @@ -917,6 +937,7 @@ pub(crate) fn psd_to_document_decoded( cc, cmyk: fmt.mode == ColorMode::Cmyk, warnings, + unsafe_for_editing, dpi: doc.resolution_dpi, txt2: file.global_blocks.iter().find(|b| &b.key == b"Txt2").and_then(|b| photocraft_text::psd::parse_txt2(&b.data)), filter_effects: Vec::new(), @@ -956,9 +977,9 @@ pub(crate) fn psd_to_document_decoded( } ctl.progress(0.1); if let Err(e) = &m { - cx.warn(format!("merged image could not be decoded: {e}")); + cx.warn_unreadable_data(format!("merged image could not be decoded: {e}")); if can_recover_layers(file) { - cx.warn("extra alpha/spot channels in the merged image could not be recovered"); + cx.warn_unreadable_data("extra alpha/spot channels in the merged image could not be recovered"); } } Some(m) @@ -1086,7 +1107,7 @@ pub(crate) fn psd_to_document_decoded( } // A merged image that failed to decode was reported above. Err(_) if matches!(merged, Some(Err(_))) => {} - Err(e) => cx.warn(format!("the image could not be read: {e}")), + Err(e) => cx.warn_unreadable_data(format!("the image could not be read: {e}")), } } @@ -1101,7 +1122,10 @@ pub(crate) fn psd_to_document_decoded( let skip = usize::from(file.merged_has_alpha() && names.len() == usize::from(h.channels).saturating_sub(cc)); let names = names.get(skip..).unwrap_or_default(); for (k, idx) in (first..usize::from(h.channels)).enumerate() { - let Some(p) = merged_plane(all, idx, plane) else { break }; + let Some(p) = merged_plane(all, idx, plane) else { + cx.warn_unreadable_data(format!("merged extra channel {idx} is incomplete and was not imported")); + break; + }; let mut s = Surface::new(cx.mask_fmt); s.write_interleaved(canvas, &be_to_ne_plane(p, depth, n)); s.prune(); @@ -1139,7 +1163,7 @@ pub(crate) fn psd_to_document_decoded( return None; } ctl.progress(1.0); - Some((doc, cx.warnings)) + Some((doc, cx.warnings, cx.unsafe_for_editing)) } #[cfg(test)] @@ -1184,6 +1208,36 @@ mod tests { assert_eq!(unicode_names(&data), ["A"]); } + #[test] + fn unreadable_layer_channel_marks_conversion_unsafe_for_editing() { + let mut file = testgen::small(Version::Psd, Compression::Raw); + let channel = file.layers_mut()[0].channels.iter_mut().find(|c| c.id == 0).unwrap(); + channel.data.clear(); + assert!(file.layers()[0].decode_channel(0, file.header.depth, file.header.version).is_err()); + + let (_, warnings, unsafe_for_editing) = psd_to_document_decoded_integrity(&file, &photocraft_raster::Interrupt::NONE, None).unwrap(); + assert!(unsafe_for_editing); + assert!(warnings.iter().any(|w| w.contains("could not be decoded"))); + } + + #[test] + fn unreadable_mask_channel_marks_conversion_unsafe_for_editing() { + let mut file = testgen::small(Version::Psd, Compression::Raw); + let channel = file.layers_mut()[0].channels.iter_mut().find(|c| c.id == CHANNEL_USER_MASK).unwrap(); + channel.data.clear(); + + let (_, warnings, unsafe_for_editing) = psd_to_document_decoded_integrity(&file, &photocraft_raster::Interrupt::NONE, None).unwrap(); + assert!(unsafe_for_editing); + assert!(warnings.iter().any(|w| w.contains("could not be decoded"))); + } + + #[test] + fn valid_layer_channels_keep_conversion_editable() { + let file = testgen::small(Version::Psd, Compression::Raw); + let (_, warnings, unsafe_for_editing) = psd_to_document_decoded_integrity(&file, &photocraft_raster::Interrupt::NONE, None).unwrap(); + assert!(!unsafe_for_editing, "unexpectedly marked good PSD unsafe: {warnings:?}"); + } + #[test] fn merged_plane_checks_offsets() { let all = [1u8, 2, 3, 4]; diff --git a/crates/io/src/recovery.rs b/crates/io/src/recovery.rs new file mode 100644 index 0000000000..214ae6e10b --- /dev/null +++ b/crates/io/src/recovery.rs @@ -0,0 +1,108 @@ +//! A recovered PSD may be exported only to a new file. Publishing a completely +//! written temporary inode with `hard_link` gives an atomic, no-replace commit: +//! replacing the original file (including through an alias) is impossible. +//! +//! There is deliberately no fallback to `rename`, which can replace files. + +use std::path::Path; +use crate::IoError; + +#[cfg(not(target_arch = "wasm32"))] +struct Temporary(std::path::PathBuf); + +#[cfg(not(target_arch = "wasm32"))] +impl Drop for Temporary { + fn drop(&mut self) { let _ = std::fs::remove_file(&self.0); } +} + +/// Atomically publish an encoded recovery copy at a **previously unused** name. +/// Unlike a conventional Save As, this NEVER replaces an existing destination. +/// This includes aliases of the original (symlinks/hardlinks) and defeats a +/// race where a destination appears after an earlier `exists()` check. +/// A filesystem that cannot hard-link a same-directory temporary file fails +/// closed rather than falling back to a destructive operation. +#[cfg(not(target_arch = "wasm32"))] +pub fn write_recovery_copy_bytes(destination: &Path, bytes: &[u8]) -> Result<(), IoError> { + use std::fs::OpenOptions; + use std::io::Write; + use std::sync::atomic::{AtomicU64, Ordering}; + + static NEXT: AtomicU64 = AtomicU64::new(0); + let err = |e: std::io::Error| IoError::Unsupported(format!("recovery copy: {e}")); + let parent = destination.parent().filter(|p| !p.as_os_str().is_empty()).unwrap_or(Path::new(".")); + let name = destination.file_name().filter(|n| !n.is_empty()).ok_or_else(|| + IoError::Unsupported("recovery copy needs a valid file name".into()))?; + let mut temporary = None; + for _ in 0..64 { + let next = NEXT.fetch_add(1, Ordering::Relaxed); + let mut filename = std::ffi::OsString::from(".photocraft-recovery-"); + filename.push(std::process::id().to_string()); + filename.push(format!("-{next}-")); + filename.push(name); + filename.push(".tmp"); + let candidate = parent.join(filename); + let mut opts = OpenOptions::new(); + opts.write(true).create_new(true); + #[cfg(unix)] + { + use std::os::unix::fs::OpenOptionsExt; + opts.mode(0o600); + } + match opts.open(&candidate) { + Ok(file) => { temporary = Some((Temporary(candidate), file)); break; } + Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => continue, + Err(e) => return Err(err(e)), + } + } + let (temp, mut file) = temporary.ok_or_else(|| IoError::Unsupported("cannot reserve a temporary recovery file".into()))?; + file.write_all(bytes).map_err(err)?; + file.sync_all().map_err(err)?; + drop(file); + // The link operation is atomic: EEXIST if ANY file was placed at the + // destination, even after a previous validation or through a symlink. + std::fs::hard_link(&temp.0, destination).map_err(|e| { + if e.kind() == std::io::ErrorKind::AlreadyExists { + IoError::Unsupported("recovery copy must use a NEW file name; an existing file will never be overwritten".into()) + } else { + err(e) + } + })?; + // The copy now has its own name and stays intact when the temp name is removed. + Ok(()) +} + +#[cfg(target_arch = "wasm32")] +pub fn write_recovery_copy_bytes(_destination: &Path, _bytes: &[u8]) -> Result<(), IoError> { + Err(IoError::Unsupported("native recovery copy is unavailable on the web".into())) +} + +#[cfg(all(test, not(target_arch = "wasm32")))] +mod tests { + use super::*; + + #[test] + fn recovered_copy_never_replaces_an_existing_file() { + let dir = std::env::temp_dir().join(format!("photocraft-copy-{}-{}", std::process::id(), std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos())); + std::fs::create_dir(&dir).unwrap(); + let source = dir.join("original.psd"); + let copy = dir.join("copy.psd"); + std::fs::write(&source, b"valuable original").unwrap(); + assert!(write_recovery_copy_bytes(&source, b"damaged").is_err()); + assert_eq!(std::fs::read(&source).unwrap(), b"valuable original"); + write_recovery_copy_bytes(©, b"recovered").unwrap(); + assert_eq!(std::fs::read(©).unwrap(), b"recovered"); + assert!(write_recovery_copy_bytes(©, b"overwritten").is_err()); + assert_eq!(std::fs::read(©).unwrap(), b"recovered"); + #[cfg(unix)] { + use std::os::unix::fs::symlink; + let link = dir.join("symlink.psd"); + symlink(&source, &link).unwrap(); + assert!(write_recovery_copy_bytes(&link, b"symlink overwrite").is_err()); + let hardlink = dir.join("hardlink.psd"); + std::fs::hard_link(&source, &hardlink).unwrap(); + assert!(write_recovery_copy_bytes(&hardlink, b"hardlink overwrite").is_err()); + } + assert_eq!(std::fs::read(&source).unwrap(), b"valuable original"); + std::fs::remove_dir_all(dir).unwrap(); + } +} diff --git a/crates/io/tests/psd_recovery_generated.rs b/crates/io/tests/psd_recovery_generated.rs new file mode 100644 index 0000000000..2eaa62de0d --- /dev/null +++ b/crates/io/tests/psd_recovery_generated.rs @@ -0,0 +1,64 @@ +//! PSD/PSB recovery regression tests using in-memory Rust-generated fixtures. +//! +//! No `.psd` file is checked into the repository and no Python generator runs. +//! Fixtures are created at the beginning of each test, so parallel test order +//! does not matter. See the ignored test for GUI-ready temporary files. + +#[path = "support/recovery_psd.rs"] +mod recovery_psd; + +use photocraft_io::{IoError, import, import_psd_for_recovery}; +use photocraft_psd::PsdFile; + +#[test] +fn valid_generated_psd_opens_normally() { + let bytes = recovery_psd::make_psd(false); + assert_eq!(bytes.len(), 74_986, "the fixture should retain the reference PSD layout"); + let result = import("valid-two-layers.psd", &bytes).expect("generated healthy PSD must import"); + assert!(!result.source_read_only); + assert!(!result.preview_only); + assert_eq!(result.document.layers.len(), 2); +} + +#[test] +fn corrupt_generated_rle_channel_requires_opt_in_recovery() { + let bytes = recovery_psd::make_psd(true); + assert_eq!(bytes.len(), 74_986, "the fixture should retain the reference PSD layout"); + let (parsed, _) = PsdFile::from_bytes_and_merged(&bytes, |_| false).expect("the PSD container must stay valid"); + let layer = parsed.layers().iter().find(|layer| layer.name() == "BROKEN orange RLE").expect("generated upper layer exists"); + + assert!(layer.decode_channel(0, parsed.header.depth, parsed.header.version).is_ok()); + assert!(layer.decode_channel(1, parsed.header.depth, parsed.header.version).is_err()); + assert!(layer.decode_channel(2, parsed.header.depth, parsed.header.version).is_ok()); + assert!(parsed.decode_merged().is_ok(), "the composite must remain recoverable"); + + let error = import("corrupt-green-rle.psd", &bytes).unwrap_err(); + assert!(matches!(error, IoError::Unsupported(_)), "unexpected error: {error}"); + + let recovered = import_psd_for_recovery("corrupt-green-rle.psd", &bytes).expect("explicit recovery must return readable layers"); + assert!(recovered.source_read_only, "recovery must not save over the source"); + assert!(!recovered.preview_only); + assert!(!recovered.document.layers.is_empty()); + assert!(recovered.warnings.iter().any(|w| w.starts_with("PSD/PSB RECOVERY:"))); + assert!(recovered.warnings.iter().any(|w| w.contains("could not be decoded"))); +} + +/// Generate the same two PSDs on demand for manual testing in the GUI. +/// +/// Run with: +/// cargo test -p photocraft-io --test psd_recovery_generated \ +/// write_psds_for_manual_gui_test -- --ignored --nocapture +/// +/// The files go to the system's temp folder, not into the repository. +#[test] +#[ignore = "writes temporary PSD fixtures only when manual GUI testing is requested"] +fn write_psds_for_manual_gui_test() { + let output = std::env::temp_dir().join(format!("photocraft-psd-recovery-{}", std::process::id())); + std::fs::create_dir_all(&output).expect("create temporary fixture directory"); + + for (name, corrupt) in [("valid-two-layers.psd", false), ("corrupt-green-rle.psd", true)] { + let path = output.join(name); + std::fs::write(&path, recovery_psd::make_psd(corrupt)).expect("write generated temporary PSD"); + println!("{}", path.display()); + } +} diff --git a/crates/io/tests/support/recovery_psd.rs b/crates/io/tests/support/recovery_psd.rs new file mode 100644 index 0000000000..aff1632e2b --- /dev/null +++ b/crates/io/tests/support/recovery_psd.rs @@ -0,0 +1,191 @@ +//! Minimal, deterministic PSD fixtures for the PSD recovery tests. +//! +//! Pure Rust / std: no binary fixtures, external assets, Python, or build script. +//! The damaged fixture has valid layer records and a valid merged composite; +//! only the green channel of the orange layer contains a truncated PackBits run. + +const WIDTH: usize = 128; +const HEIGHT: usize = 96; +const PANEL: (usize, usize, usize, usize) = (20, 16, 108, 80); +const PANEL_RGB: [u8; 3] = [244, 156, 28]; +const PANEL_ALPHA: u8 = 220; + +struct Channel { + id: i16, + data: Vec, +} + +struct Layer { + record: Vec, + pixels: Vec, +} + +fn put_len(out: &mut Vec, len: usize) { + out.extend_from_slice(&u32::try_from(len).expect("test PSD section fits u32").to_be_bytes()); +} + +fn background_rgb() -> [Vec; 3] { + let mut planes: [Vec; 3] = std::array::from_fn(|_| Vec::with_capacity(WIDTH * HEIGHT)); + for y in 0..HEIGHT { + for x in 0..WIDTH { + let checker = u8::try_from((x / 16 + y / 16) % 2).expect("checker value is 0 or 1"); + planes[0].push(34 + checker * 12); + planes[1].push(102 + checker * 15); + planes[2].push(184 + checker * 12); + } + } + planes +} + +fn raw_channel(id: i16, pixels: &[u8]) -> Channel { + let mut data = Vec::with_capacity(2 + pixels.len()); + data.extend_from_slice(&0u16.to_be_bytes()); // 0 = uncompressed + data.extend_from_slice(pixels); + Channel { id, data } +} + +fn rle_channel(id: i16, sample: u8, width: usize, height: usize, corrupt: bool) -> Channel { + let mut rows: Vec> = Vec::with_capacity(height); + for y in 0..height { + if corrupt && y == height / 2 { + // 0 declares one literal byte, but that byte is missing. + // Its row-length entry remains valid: this tests the decoder. + rows.push(vec![0]); + continue; + } + let mut row = Vec::new(); + let mut remaining = width; + while remaining != 0 { + let count = remaining.min(128); + // PackBits negative repeat count -(count - 1), modulo 256. + let header = u8::try_from(257 - count).expect("PackBits repeat header fits u8"); + row.extend_from_slice(&[header, sample]); + remaining -= count; + } + rows.push(row); + } + let mut data = Vec::new(); + data.extend_from_slice(&1u16.to_be_bytes()); // 1 = PackBits/RLE + for row in &rows { + data.extend_from_slice(&u16::try_from(row.len()).expect("row fits PSD u16 length").to_be_bytes()); + } + for row in rows { + data.extend_from_slice(&row); + } + Channel { id, data } +} + +fn layer(name: &str, rect: (i32, i32, i32, i32), channels: Vec) -> Layer { + let (left, top, right, bottom) = rect; + let name_bytes = name.as_bytes(); + let name_len = u8::try_from(name_bytes.len()).expect("layer name fits Pascal string"); + + let mut extra = Vec::new(); + extra.extend_from_slice(&0u32.to_be_bytes()); // no layer mask + extra.extend_from_slice(&0u32.to_be_bytes()); // no blending ranges + extra.push(name_len); + extra.extend_from_slice(name_bytes); + while extra.len() % 4 != 0 { + extra.push(0); + } + + let mut record = Vec::new(); + for coordinate in [top, left, bottom, right] { + record.extend_from_slice(&coordinate.to_be_bytes()); + } + record.extend_from_slice(&u16::try_from(channels.len()).expect("channel count fits u16").to_be_bytes()); + for channel in &channels { + record.extend_from_slice(&channel.id.to_be_bytes()); + put_len(&mut record, channel.data.len()); + } + record.extend_from_slice(b"8BIMnorm"); + record.extend_from_slice(&[255, 0, 0, 0]); // opacity, clipping, flags, filler + put_len(&mut record, extra.len()); + record.extend_from_slice(&extra); + + let mut pixels = Vec::new(); + for channel in channels { + pixels.extend_from_slice(&channel.data); + } + Layer { record, pixels } +} + +fn merged_rgb(background: &[Vec; 3]) -> Vec { + let mut planes = background.clone(); + for y in PANEL.1..PANEL.3 { + for x in PANEL.0..PANEL.2 { + let pixel = y * WIDTH + x; + for channel in 0..3 { + let fg = u32::from(PANEL_RGB[channel]); + let bg = u32::from(background[channel][pixel]); + let alpha = u32::from(PANEL_ALPHA); + let mixed = (fg * alpha + bg * (255 - alpha) + 127) / 255; + planes[channel][pixel] = u8::try_from(mixed).expect("composite pixel fits u8"); + } + } + } + let mut data = Vec::new(); + data.extend_from_slice(&0u16.to_be_bytes()); // merged composite: uncompressed + for plane in &planes { + data.extend_from_slice(plane); + } + data +} + +/// Returns a complete PSD file in memory. `corrupt` changes *only* one RLE row +/// in the green channel of the upper layer; the file is otherwise well framed. +pub fn make_psd(corrupt: bool) -> Vec { + let background = background_rgb(); + let background_layer = layer( + "SAFE blue background", + (0, 0, WIDTH as i32, HEIGHT as i32), + (0..3).map(|ch| raw_channel(ch, &background[ch as usize])).collect(), + ); + + let panel_width = PANEL.2 - PANEL.0; + let panel_height = PANEL.3 - PANEL.1; + let top_layer = layer( + "BROKEN orange RLE", + (PANEL.0 as i32, PANEL.1 as i32, PANEL.2 as i32, PANEL.3 as i32), + vec![ + rle_channel(0, PANEL_RGB[0], panel_width, panel_height, false), + rle_channel(1, PANEL_RGB[1], panel_width, panel_height, corrupt), + rle_channel(2, PANEL_RGB[2], panel_width, panel_height, false), + rle_channel(-1, PANEL_ALPHA, panel_width, panel_height, false), + ], + ); + // Photoshop stores the top layer's record first. + let layers = [top_layer, background_layer]; + let mut layer_info = Vec::new(); + layer_info.extend_from_slice(&2i16.to_be_bytes()); + for layer in &layers { + layer_info.extend_from_slice(&layer.record); + } + for layer in &layers { + layer_info.extend_from_slice(&layer.pixels); + } + if layer_info.len() % 2 != 0 { + layer_info.push(0); // layer info is padded to an even size + } + + let mut layer_and_mask = Vec::new(); + put_len(&mut layer_and_mask, layer_info.len()); + layer_and_mask.extend_from_slice(&layer_info); + layer_and_mask.extend_from_slice(&0u32.to_be_bytes()); // empty global layer mask + + let mut out = Vec::new(); + out.extend_from_slice(b"8BPS"); + out.extend_from_slice(&1u16.to_be_bytes()); // PSD (not PSB) + out.extend_from_slice(&[0u8; 6]); + out.extend_from_slice(&3u16.to_be_bytes()); // RGB channels + out.extend_from_slice(&(HEIGHT as u32).to_be_bytes()); + out.extend_from_slice(&(WIDTH as u32).to_be_bytes()); + out.extend_from_slice(&8u16.to_be_bytes()); // 8 bits per channel + out.extend_from_slice(&3u16.to_be_bytes()); // RGB colour mode + out.extend_from_slice(&0u32.to_be_bytes()); // no colour-mode data + out.extend_from_slice(&0u32.to_be_bytes()); // no image resources + put_len(&mut out, layer_and_mask.len()); + out.extend_from_slice(&layer_and_mask); + out.extend_from_slice(&merged_rgb(&background)); + out +} diff --git a/crates/ui-egui/src/file_ui.rs b/crates/ui-egui/src/file_ui.rs index 32f97bc4e8..4e5745adef 100644 --- a/crates/ui-egui/src/file_ui.rs +++ b/crates/ui-egui/src/file_ui.rs @@ -696,6 +696,9 @@ fn web_confirm(app: &mut PhotocraftApp, f: &Map) -> Result Result { + if app.session.active().is_some_and(|st| st.recovery_mode) { + return Err("PSD recovery: Save for Web is disabled for this document; first save a new recovery copy and reopen it".into()); + } #[cfg(target_arch = "wasm32")] let result = download_for_web(app, p); #[cfg(not(target_arch = "wasm32"))] diff --git a/crates/ui-egui/src/jobs_ui.rs b/crates/ui-egui/src/jobs_ui.rs index 45fa60d8a3..e836692fdb 100644 --- a/crates/ui-egui/src/jobs_ui.rs +++ b/crates/ui-egui/src/jobs_ui.rs @@ -200,7 +200,7 @@ pub fn run(app: &mut PhotocraftApp, id: &str, params: Value) -> Result, source: OpenSource) -> Result<(), String> { let name = &app.open_name(name); - match app.session.start_open(name, source).map_err(|e| e.to_string())? { + match app.session.start_open_for_user(name, source).map_err(|e| e.to_string())? { // Inline (wasm): finish now, like a background open that ended at once. Started::Done(v) => finish_open(app, name, path.as_deref(), &v, None), Started::Job(job) => { @@ -552,6 +552,8 @@ fn finish_open(app: &mut PhotocraftApp, name: &str, path: Option<&str>, v: &Valu let held = |doc, read_only, question, policy_applied| crate::open_prompt::Held { doc, read_only, + recovery_mode: v.get("recovery").and_then(Value::as_bool).unwrap_or(false), + recovery_pending: v.get("recovery").and_then(Value::as_bool).unwrap_or(false), name: name.to_string(), path: path.map(str::to_string), warnings: warnings.clone(), @@ -607,8 +609,11 @@ pub(crate) fn after_open(app: &mut PhotocraftApp, name: &str, path: Option<&str> } else { notices::io_warnings(app, &opened, warnings); } - // Script events bound to "Open Document". - photocraft_engine::automate_cmds::document_opened(&mut app.session); + // Script event hooks can save a file or run other I/O commands. Do not + // dispatch them automatically for a recovered, partially decoded PSD. + if !app.session.active().is_some_and(|st| st.recovery_mode) { + photocraft_engine::automate_cmds::document_opened(&mut app.session); + } app.sync_views(); } diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 8784800ddd..0bc7b47c1b 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -526,6 +526,10 @@ pub struct Services { /// Encode and write in one step on a worker thread, so a large save doesn't freeze the /// window (#2017). With background jobs on, saves use it instead of `export` and `write`. pub save_file: Option, + /// Recovery-mode writes publish ONLY new files (no replace, even via aliases). + pub recovery_write: Option, + /// The worker version of `recovery_write`, to keep large PSD copies responsive. + pub recovery_save_file: Option, /// File access used only by control/MCP requests. Interactive dialogs keep /// using `file_dialog` and `write` with the user's authority. pub automation_read: Option, @@ -1455,7 +1459,14 @@ impl PhotocraftApp { } let import = self.services.import.as_ref().ok_or("no importer configured")?; let max_svg_group_depth = self.session.prefs().file_handling.rasterize_svg_groups_deeper_than as usize; - let (doc, warnings) = import(name, bytes, max_svg_group_depth)?; + let (doc, warnings, recovery_mode) = match import(name, bytes, max_svg_group_depth) { + Ok((doc, warnings)) => (doc, warnings, false), + Err(error) if photocraft_io::is_psd(bytes) => match photocraft_io::import_psd_for_recovery(name, bytes) { + Ok(r) if r.source_read_only && r.warnings.iter().any(|w| w.starts_with("PSD/PSB RECOVERY:")) => (r.document, r.warnings, true), + _ => return Err(error), + }, + Err(error) => return Err(error), + }; // Edit › Color Settings policies apply on open; Ask When Opening holds the file back // until its prompt is answered, and later files wait behind it (`open_prompt`). // Missing fonts are read from the document itself: it may not be open yet (#4559). @@ -1468,7 +1479,9 @@ impl PhotocraftApp { self, open_prompt::Held { doc, - read_only: photocraft_io::affinity::is_affinity(bytes), + read_only: recovery_mode || photocraft_io::affinity::is_affinity(bytes), + recovery_mode, + recovery_pending: recovery_mode, name: name.to_string(), path: path.map(str::to_string), warnings: warnings.clone(), @@ -1540,7 +1553,7 @@ impl PhotocraftApp { return Err("Answer the TIFF, Targa or DDS Options before starting another save".into()); } // Edit Contents documents save back into their smart object. - if path.is_none() && self.session.is_enabled("layer.smartObjects.saveContents") { + if path.is_none() && !self.session.active().is_some_and(|st| st.recovery_mode) && self.session.is_enabled("layer.smartObjects.saveContents") { self.run("layer.smartObjects.saveContents", serde_json::json!({}))?; return Ok(serde_json::json!({"path": "smart object", "warnings": []})); } @@ -1562,16 +1575,21 @@ impl PhotocraftApp { || (e == "ora" && holds_ora) || (flat && photocraft_codecs::from_extension(&e).is_some_and(|f| f.caps().write)) }); - let suggested = match &st.path { - Some(p) if writable => p.clone(), - p => { - let source = p.as_deref().unwrap_or(&st.doc.name); - let ext = match photocraft_engine::file_cmds::extension(source).as_deref() { - Some("pdn") => "pcraft", - Some("kra" | "krz") => "ora", - _ => "psd", - }; - std::path::Path::new(source).with_extension(ext).to_string_lossy().into_owned() + let suggested = if st.recovery_mode { + let name = st.doc.name.rsplit_once('.').map(|(stem, _)| stem).unwrap_or(&st.doc.name); + format!("{name} recovered.psd") + } else { + match &st.path { + Some(p) if writable => p.clone(), + p => { + let source = p.as_deref().unwrap_or(&st.doc.name); + let ext = match photocraft_engine::file_cmds::extension(source).as_deref() { + Some("pdn") => "pcraft", + Some("kra" | "krz") => "ora", + _ => "psd", + }; + std::path::Path::new(source).with_extension(ext).to_string_lossy().into_owned() + } } }; let doc = st.doc.id; @@ -1753,6 +1771,23 @@ impl PhotocraftApp { /// `None` when the save went to a background job (#2017), which finishes it in /// [`jobs_ui::tick`]. pub(crate) fn write_document(&mut self, path: String, settings: &ExportSettings, copy: bool) -> Result)>, String> { + if self.session.active().is_some_and(|st| st.recovery_mode) { + // Keep the recovery restriction for the entire session, even after + // successfully writing a copy. Neither Save nor Save As can replace + // ANY existing file; only a new copy is possible. + if self.background_jobs { + let writer = self.services.recovery_save_file.clone().ok_or("safe recovery-copy writer not available")?; + return jobs_ui::start_save(self, path, settings.clone(), true, writer, false); + } + let st = self.session.active().ok_or("no document")?; + let (doc, revision) = (st.doc.id, st.revision); + let export = self.services.export.as_ref().ok_or("no exporter configured")?; + let (bytes, warnings) = export(&st.doc, &path, settings)?; + let write = self.services.recovery_write.as_mut().ok_or("safe recovery-copy writer not available")?; + write(&path, &bytes)?; + self.saved(doc, revision, &path, &warnings, true); + return Ok(Some((path, warnings))); + } if self.background_jobs && let Some(save) = self.services.save_file.clone() { @@ -1790,7 +1825,12 @@ impl PhotocraftApp { (false, holds) } }; - self.ui.status = crate::i18n::fmt(tl!("Saved {name}"), &[("name", path)]); + let recovery_copy = copy && self.session.documents().iter().any(|st| st.doc.id == doc && st.recovery_mode); + self.ui.status = if recovery_copy { + crate::i18n::fmt(tl!("Saved recovered copy as {name}"), &[("name", path)]) + } else { + crate::i18n::fmt(tl!("Saved {name}"), &[("name", path)]) + }; if !copy { // A background save may finish while another document is active (or after its // document was closed, when there is nothing left to record). @@ -1872,6 +1912,11 @@ impl PhotocraftApp { /// Targa's `None`: 32 with an alpha channel or transparency, else 24; a DDS texture's: /// uncompressed without mipmaps). Automation saves never prompt. pub fn save_automation_with(&mut self, path: Option, choices: FormatChoices) -> Result { + // Automation writes use a capability-scoped writer which may replace a + // destination. Do not silently downgrade the recovery no-overwrite rule. + if self.session.active().is_some_and(|st| st.recovery_mode) { + return Err("PSD recovery: automated saving is disabled for this document; choose File > Save a Copy with a new filename".into()); + } let target = { let state = self.session.active().ok_or("no document")?; // As File › Save: without `path` only a layered file is written back (#416). @@ -2189,6 +2234,7 @@ impl eframe::App for PhotocraftApp { workspace_ui::windows(self, &ctx); palette::show(self, &ctx); dialogs::show(self, &ctx); + open_prompt::recovery_dialog(self, &ctx); rasterize_prompt::run_pending(self, &ctx); jobs_ui::dialog(self, &ctx); discard_ui::show(self, &ctx); diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 63b46f4429..77373d6b0d 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -13,7 +13,8 @@ pub(crate) fn modal_allows(app: &PhotocraftApp, id: &str) -> bool { if app.camera_raw.is_some() || crate::crop_ui::blocks(app, id) { return false; } - (app.ui.dialogs.is_empty() && app.discard.is_none()) || crate::shortcuts::NAV_COMMANDS.contains(&id) + (app.ui.dialogs.is_empty() && app.discard.is_none() && !app.held_opens.front().is_some_and(|h| h.recovery_pending)) + || crate::shortcuts::NAV_COMMANDS.contains(&id) } /// Top-level menus in Photoshop order. diff --git a/crates/ui-egui/src/open_prompt.rs b/crates/ui-egui/src/open_prompt.rs index a4d93ca057..5234297c85 100644 --- a/crates/ui-egui/src/open_prompt.rs +++ b/crates/ui-egui/src/open_prompt.rs @@ -19,6 +19,10 @@ pub struct Held { pub doc: Document, /// The source is read-only (an Affinity file): Save doesn't write back to it. pub read_only: bool, + /// True for damaged PSDs admitted only through the explicit recovery path. + pub recovery_mode: bool, + /// Consent must be obtained before the document is opened or a profile prompt appears. + pub recovery_pending: bool, pub name: String, pub path: Option, pub warnings: Vec, @@ -48,6 +52,9 @@ pub fn arrive(app: &mut PhotocraftApp, held: Held) { /// Opens queued files in order until one needs its prompt, which is shown if it isn't yet. fn advance(app: &mut PhotocraftApp) { while let Some(front) = app.held_opens.front() { + if front.recovery_pending { + return; // The recovery consent window is drawn by recovery_dialog(). + } if front.question.is_some() { if !app.ui.dialogs.iter().any(|d| d.fields.contains_key(FIELD)) { show(app); @@ -112,6 +119,9 @@ pub fn owns(fields: &serde_json::Map) -> bool { /// The prompt's answer: `Some(action)` (OK) opens the first queued file with it and moves on to /// the next; `None` (Cancel) drops every queued file and stops the reads still running. pub fn answer(app: &mut PhotocraftApp, action: Option<&str>) -> Result { + if app.held_opens.front().is_some_and(|h| h.recovery_pending) { + return Err("answer the PSD recovery confirmation first".into()); + } let Some(action) = action else { let dropped = app.held_opens.len(); let name = app.held_opens.front().map(|h| h.name.clone()).unwrap_or_default(); @@ -134,6 +144,9 @@ pub fn answer(app: &mut PhotocraftApp, action: Option<&str>) -> Result Result { + if app.held_opens.front().is_some_and(|h| h.recovery_pending) { + return Err("answer the PSD recovery confirmation first".into()); + } let Some(key) = app.held_opens.front().and_then(|h| policy_key(h.doc.mode)) else { return answer(app, Some(action)) }; let policy = match action { "convert" => "convert", @@ -141,7 +154,7 @@ pub fn answer_remembering(app: &mut PhotocraftApp, action: &str) -> Result "preserve", }; app.run("edit.colorSettings", json!({key: policy, "askOnMismatch": false}))?; - let same = |h: &Held| policy_key(h.doc.mode) == Some(key) && h.question.as_ref().is_some_and(|q| q.get("missing").and_then(Value::as_bool) != Some(true)); + let same = |h: &Held| !h.recovery_pending && policy_key(h.doc.mode) == Some(key) && h.question.as_ref().is_some_and(|q| q.get("missing").and_then(Value::as_bool) != Some(true)); let Some(held) = app.held_opens.pop_front() else { return Err("no file is waiting to open".into()) }; let r = open(app, held, Some(action)); while app.held_opens.front().is_some_and(same) { @@ -154,10 +167,52 @@ pub fn answer_remembering(app: &mut PhotocraftApp, action: &str) -> Result) -> Result { - let Held { mut doc, read_only, name, path, warnings, bytes, slot, question, policy_applied } = held; + if held.recovery_pending { + return Err("damaged PSD cannot be opened before recovery consent".into()); + } + let Held { mut doc, read_only, recovery_mode, recovery_pending: _, name, path, warnings, bytes, slot, question, policy_applied } = held; let index = if question.is_some() || policy_applied { if let Some(action) = action && let Err(e) = app.session.color.resolve_open(&mut doc, action) @@ -171,6 +226,7 @@ fn open(app: &mut PhotocraftApp, held: Held, action: Option<&str>) -> Result app diff --git a/crates/ui-egui/src/save_identity_tests.rs b/crates/ui-egui/src/save_identity_tests.rs index 3396dfcdd5..166de4c8aa 100644 --- a/crates/ui-egui/src/save_identity_tests.rs +++ b/crates/ui-egui/src/save_identity_tests.rs @@ -272,3 +272,65 @@ fn unconfirmed_download_names_the_document_but_keeps_it_unsaved() { app.save_as(Some("download.psd".into())).unwrap(); assert!(!app.has_unsaved_work()); } + +#[cfg(not(target_arch = "wasm32"))] +#[test] +fn recovery_session_remains_protected_after_saving_a_copy() { + let mut app = app(); + let dir = std::env::temp_dir().join(format!( + "photocraft-recovery-ui-{}-{}", + std::process::id(), + std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos() + )); + std::fs::create_dir(&dir).unwrap(); + let original = dir.join("original.psd"); + let copy = dir.join("copy.psd"); + std::fs::write(&original, b"valuable original bytes").unwrap(); + app.session.active_mut().unwrap().recovery_mode = true; + app.session.active_mut().unwrap().source_read_only = true; + app.services.recovery_write = + Some(Box::new(|path, bytes| photocraft_io::write_recovery_copy_bytes(std::path::Path::new(path), bytes).map_err(|e| e.to_string()))); + let own = identity(&app); + assert!(app.save_as(Some(original.to_string_lossy().into_owned())).is_err()); + app.save_as(Some(copy.to_string_lossy().into_owned())).unwrap(); + assert!(copy.is_file()); + assert_eq!(identity(&app), own, "Save a Copy must not retarget the recovered session"); + assert!(app.session.active().unwrap().recovery_mode); + assert!(app.save_as(Some(copy.to_string_lossy().into_owned())).is_err()); + assert!(app.save_automation(Some(original.to_string_lossy().into_owned())).is_err()); + assert_eq!(std::fs::read(original).unwrap(), b"valuable original bytes"); + std::fs::remove_dir_all(dir).unwrap(); +} + +#[test] +fn recovery_consent_is_required_before_opening() { + let mut session = Session::new(); + session.execute("file.new", json!({"width": 2, "height": 2})).unwrap(); + let doc = (*session.active().unwrap().doc).clone(); + session.close(0); + let mut app = PhotocraftApp::new(session, Services::default()); + let make_held = |doc: photocraft_doc::Document| crate::open_prompt::Held { + doc, + read_only: true, + recovery_mode: true, + recovery_pending: true, + name: "damaged.psd".into(), + path: Some("/tmp/damaged.psd".into()), + warnings: vec!["PSD/PSB RECOVERY: partial import".into()], + bytes: None, + slot: None, + question: None, + policy_applied: false, + }; + crate::open_prompt::arrive(&mut app, make_held(doc.clone())); + assert_eq!(app.session.documents().len(), 0); + crate::open_prompt::answer_recovery(&mut app, false); + assert_eq!(app.session.documents().len(), 0); + crate::open_prompt::arrive(&mut app, make_held(doc)); + crate::open_prompt::answer_recovery(&mut app, true); + assert_eq!(app.session.documents().len(), 1); + let st = app.session.active().unwrap(); + assert!(st.recovery_mode); + assert!(st.source_read_only); + assert_eq!(st.path, None); +} diff --git a/crates/ui-egui/src/view_cmds.rs b/crates/ui-egui/src/view_cmds.rs index 7fffcf784a..bfab75a502 100644 --- a/crates/ui-egui/src/view_cmds.rs +++ b/crates/ui-egui/src/view_cmds.rs @@ -1469,9 +1469,11 @@ fn front(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str, params: &Value) /// and saved state are untouched. An action being recorded keeps it as a `file.saveACopy` step /// with its path (#4373). fn save_a_copy(app: &mut PhotocraftApp) -> Result { - let doc = app.session.active().ok_or("no document")?.doc.clone(); + let st = app.session.active().ok_or("no document")?; + let recovered = st.recovery_mode; + let doc = st.doc.clone(); let stem = doc.name.rsplit_once('.').map_or(doc.name.as_str(), |(a, _)| a); - let suggested = format!("{stem} copy.psd"); + let suggested = if recovered { format!("{stem} recovered.psd") } else { format!("{stem} copy.psd") }; // The copy is of the document as it was when asked. app.pick_save(&suggested, move |app, path| { // An RGB Targa asks for its bits per pixel first, and a DDS texture for its compression; @@ -1490,7 +1492,7 @@ fn save_a_copy(app: &mut PhotocraftApp) -> Result { if parked { return Ok(json!({"path": path, "warnings": []})); } - let r = write_copy(app, &doc, &path, crate::FormatChoices::default())?; + let r = write_copy_with_mode(app, &doc, &path, crate::FormatChoices::default(), recovered)?; app.session.journal.push(("file.saveACopy".into(), json!({"path": path}))); Ok(r) }) @@ -1499,10 +1501,25 @@ fn save_a_copy(app: &mut PhotocraftApp) -> Result { /// Writes `doc` to `path` as a copy (Save a Copy, and its replayed action step): the document's /// path and saved state are untouched. `choices` are the Targa and DDS answers, when there are any. pub(crate) fn write_copy(app: &mut PhotocraftApp, doc: &photocraft_doc::Document, path: &str, choices: crate::FormatChoices) -> Result { + let recovered = app.session.documents().iter().any(|st| st.doc.id == doc.id && st.recovery_mode); + write_copy_with_mode(app, doc, path, choices, recovered) +} + +fn write_copy_with_mode( + app: &mut PhotocraftApp, + doc: &photocraft_doc::Document, + path: &str, + choices: crate::FormatChoices, + recovered: bool, +) -> Result { let settings = choices.apply(app.save_settings()); let export = app.services.export.as_ref().ok_or("no exporter configured")?; let (bytes, warnings) = export(doc, path, &settings)?; - let write = app.services.write.as_mut().ok_or("no writer configured")?; + let write = if recovered { + app.services.recovery_write.as_mut().ok_or("safe recovery-copy writer not available")? + } else { + app.services.write.as_mut().ok_or("no writer configured")? + }; write(path, &bytes)?; let template = "Saved a copy as {path}"; app.ui.status = crate::i18n::fmt(tl!(template), &[("path", path)]); @@ -1515,11 +1532,16 @@ pub(crate) fn write_copy(app: &mut PhotocraftApp, doc: &photocraft_doc::Document /// Layer › Smart Objects › Export Contents: saves the contents file under its own name by default. fn export_contents(app: &mut PhotocraftApp) -> Result { let st = app.session.active().ok_or("no document")?; + let recovered = st.recovery_mode; let layer = st.active_layer.ok_or("no layer selected")?; // The contents as they were when asked, like Save a Copy. let (name, bytes) = photocraft_engine::smart_cmds::contents_of(&st.doc, layer).map_err(|e| e.to_string())?; app.pick_save(&name.clone(), move |app, path| { - let write = app.services.write.as_mut().ok_or("no writer configured")?; + let write = if recovered { + app.services.recovery_write.as_mut().ok_or("safe recovery-copy writer not available")? + } else { + app.services.write.as_mut().ok_or("no writer configured")? + }; write(&path, &bytes)?; let template = "Exported contents to {path}"; app.ui.status = crate::i18n::fmt(tl!(template), &[("path", &path)]); From d5d709f701e4af4bf1abb020fa4914b6202bbf76 Mon Sep 17 00:00:00 2001 From: David Bonnier Date: Fri, 16 Oct 2026 18:52:30 +0200 Subject: [PATCH 208/649] style: apply missing cargo fmt formatting --- apps/photocraft/src/services.rs | 4 +- crates/io/src/recovery.rs | 23 ++++++++---- crates/io/tests/support/recovery_psd.rs | 7 +--- crates/ui-egui/src/open_prompt.rs | 50 +++++++++++++++---------- 4 files changed, 49 insertions(+), 35 deletions(-) diff --git a/apps/photocraft/src/services.rs b/apps/photocraft/src/services.rs index 1b26a3bcdf..9a1a6c1384 100644 --- a/apps/photocraft/src/services.rs +++ b/apps/photocraft/src/services.rs @@ -551,9 +551,7 @@ pub fn native(automation: Option) -> })), save_file: Some(Arc::new(save_file)), recovery_save_file: Some(Arc::new(recovery_save_file)), - recovery_write: Some(Box::new(|path: &str, bytes: &[u8]| { - photocraft_io::write_recovery_copy_bytes(Path::new(path), bytes).map_err(|e| e.to_string()) - })), + recovery_write: Some(Box::new(|path: &str, bytes: &[u8]| photocraft_io::write_recovery_copy_bytes(Path::new(path), bytes).map_err(|e| e.to_string()))), file_dialog: Some(Box::new(show_file_dialog)), write: Some(Box::new(|path: &str, bytes: &[u8]| write_atomic(Path::new(path), bytes))), file_stamp: Some(Box::new(|path: &str| { diff --git a/crates/io/src/recovery.rs b/crates/io/src/recovery.rs index 214ae6e10b..bc3c5c55e2 100644 --- a/crates/io/src/recovery.rs +++ b/crates/io/src/recovery.rs @@ -4,15 +4,17 @@ //! //! There is deliberately no fallback to `rename`, which can replace files. -use std::path::Path; use crate::IoError; +use std::path::Path; #[cfg(not(target_arch = "wasm32"))] struct Temporary(std::path::PathBuf); #[cfg(not(target_arch = "wasm32"))] impl Drop for Temporary { - fn drop(&mut self) { let _ = std::fs::remove_file(&self.0); } + fn drop(&mut self) { + let _ = std::fs::remove_file(&self.0); + } } /// Atomically publish an encoded recovery copy at a **previously unused** name. @@ -30,8 +32,7 @@ pub fn write_recovery_copy_bytes(destination: &Path, bytes: &[u8]) -> Result<(), static NEXT: AtomicU64 = AtomicU64::new(0); let err = |e: std::io::Error| IoError::Unsupported(format!("recovery copy: {e}")); let parent = destination.parent().filter(|p| !p.as_os_str().is_empty()).unwrap_or(Path::new(".")); - let name = destination.file_name().filter(|n| !n.is_empty()).ok_or_else(|| - IoError::Unsupported("recovery copy needs a valid file name".into()))?; + let name = destination.file_name().filter(|n| !n.is_empty()).ok_or_else(|| IoError::Unsupported("recovery copy needs a valid file name".into()))?; let mut temporary = None; for _ in 0..64 { let next = NEXT.fetch_add(1, Ordering::Relaxed); @@ -49,7 +50,10 @@ pub fn write_recovery_copy_bytes(destination: &Path, bytes: &[u8]) -> Result<(), opts.mode(0o600); } match opts.open(&candidate) { - Ok(file) => { temporary = Some((Temporary(candidate), file)); break; } + Ok(file) => { + temporary = Some((Temporary(candidate), file)); + break; + } Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => continue, Err(e) => return Err(err(e)), } @@ -82,7 +86,11 @@ mod tests { #[test] fn recovered_copy_never_replaces_an_existing_file() { - let dir = std::env::temp_dir().join(format!("photocraft-copy-{}-{}", std::process::id(), std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos())); + let dir = std::env::temp_dir().join(format!( + "photocraft-copy-{}-{}", + std::process::id(), + std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos() + )); std::fs::create_dir(&dir).unwrap(); let source = dir.join("original.psd"); let copy = dir.join("copy.psd"); @@ -93,7 +101,8 @@ mod tests { assert_eq!(std::fs::read(©).unwrap(), b"recovered"); assert!(write_recovery_copy_bytes(©, b"overwritten").is_err()); assert_eq!(std::fs::read(©).unwrap(), b"recovered"); - #[cfg(unix)] { + #[cfg(unix)] + { use std::os::unix::fs::symlink; let link = dir.join("symlink.psd"); symlink(&source, &link).unwrap(); diff --git a/crates/io/tests/support/recovery_psd.rs b/crates/io/tests/support/recovery_psd.rs index aff1632e2b..7febfd94be 100644 --- a/crates/io/tests/support/recovery_psd.rs +++ b/crates/io/tests/support/recovery_psd.rs @@ -136,11 +136,8 @@ fn merged_rgb(background: &[Vec; 3]) -> Vec { /// in the green channel of the upper layer; the file is otherwise well framed. pub fn make_psd(corrupt: bool) -> Vec { let background = background_rgb(); - let background_layer = layer( - "SAFE blue background", - (0, 0, WIDTH as i32, HEIGHT as i32), - (0..3).map(|ch| raw_channel(ch, &background[ch as usize])).collect(), - ); + let background_layer = + layer("SAFE blue background", (0, 0, WIDTH as i32, HEIGHT as i32), (0..3).map(|ch| raw_channel(ch, &background[ch as usize])).collect()); let panel_width = PANEL.2 - PANEL.0; let panel_height = PANEL.3 - PANEL.1; diff --git a/crates/ui-egui/src/open_prompt.rs b/crates/ui-egui/src/open_prompt.rs index 5234297c85..3a86e2019f 100644 --- a/crates/ui-egui/src/open_prompt.rs +++ b/crates/ui-egui/src/open_prompt.rs @@ -154,7 +154,11 @@ pub fn answer_remembering(app: &mut PhotocraftApp, action: &str) -> Result "preserve", }; app.run("edit.colorSettings", json!({key: policy, "askOnMismatch": false}))?; - let same = |h: &Held| !h.recovery_pending && policy_key(h.doc.mode) == Some(key) && h.question.as_ref().is_some_and(|q| q.get("missing").and_then(Value::as_bool) != Some(true)); + let same = |h: &Held| { + !h.recovery_pending + && policy_key(h.doc.mode) == Some(key) + && h.question.as_ref().is_some_and(|q| q.get("missing").and_then(Value::as_bool) != Some(true)) + }; let Some(held) = app.held_opens.pop_front() else { return Err("no file is waiting to open".into()) }; let r = open(app, held, Some(action)); while app.held_opens.front().is_some_and(same) { @@ -173,33 +177,39 @@ pub(crate) fn recovery_dialog(app: &mut PhotocraftApp, ctx: &egui::Context) { let Some(front) = app.held_opens.front().filter(|h| h.recovery_pending) else { return }; let (name, warnings) = (front.name.clone(), front.warnings.clone()); let mut choice = None; - egui::Window::new(tl!("Damaged Photoshop document")) - .anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0]) - .collapsible(false) - .resizable(false) - .show(ctx, |ui| { - ui.set_max_width(500.0); - ui.label(format!("{name} contains unreadable layers or image data.")); - ui.label("You can open the recoverable parts, but some pixels or masks may be missing."); - ui.strong("The original file cannot be overwritten. Save a Copy must use a new file name."); - for warning in warnings.iter().filter(|w| !w.starts_with("PSD/PSB RECOVERY:")).take(5) { - ui.label(format!("- {warning}")); + egui::Window::new(tl!("Damaged Photoshop document")).anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0]).collapsible(false).resizable(false).show(ctx, |ui| { + ui.set_max_width(500.0); + ui.label(format!("{name} contains unreadable layers or image data.")); + ui.label("You can open the recoverable parts, but some pixels or masks may be missing."); + ui.strong("The original file cannot be overwritten. Save a Copy must use a new file name."); + for warning in warnings.iter().filter(|w| !w.starts_with("PSD/PSB RECOVERY:")).take(5) { + ui.label(format!("- {warning}")); + } + ui.separator(); + ui.horizontal(|ui| { + if ui.button(tl!("Cancel")).clicked() { + choice = Some(false); + } + if ui.button(tl!("Open in Recovery Mode")).clicked() { + choice = Some(true); } - ui.separator(); - ui.horizontal(|ui| { - if ui.button(tl!("Cancel")).clicked() { choice = Some(false); } - if ui.button(tl!("Open in Recovery Mode")).clicked() { choice = Some(true); } - }); }); - if let Some(accept) = choice { answer_recovery(app, accept); } + }); + if let Some(accept) = choice { + answer_recovery(app, accept); + } } /// Accept or discard the first pending damaged PSD. This is also the modal's testable /// transition: no document is opened before `accept` is explicitly true. pub(crate) fn answer_recovery(app: &mut PhotocraftApp, accept: bool) { - if !app.held_opens.front().is_some_and(|h| h.recovery_pending) { return; } + if !app.held_opens.front().is_some_and(|h| h.recovery_pending) { + return; + } if accept { - if let Some(front) = app.held_opens.front_mut() { front.recovery_pending = false; } + if let Some(front) = app.held_opens.front_mut() { + front.recovery_pending = false; + } } else { app.held_opens.pop_front(); } From d1c1d8819f759a5d4d350fe57dcc6ba32400df79 Mon Sep 17 00:00:00 2001 From: David Bonnier Date: Wed, 21 Oct 2026 19:05:08 +0200 Subject: [PATCH 209/649] refactor: confirm damaged PSD opens without restricting saves --- apps/photocraft/src/services.rs | 15 -- crates/engine/src/file_cmds.rs | 49 +----- crates/engine/src/jobs.rs | 73 ++++++-- crates/engine/src/lib.rs | 4 - crates/io/src/lib.rs | 204 ++++------------------ crates/io/src/psd_import.rs | 36 ++-- crates/io/src/recovery.rs | 117 ------------- crates/io/tests/psd_recovery_generated.rs | 56 ++++-- crates/ui-egui/src/dialogs.rs | 8 +- crates/ui-egui/src/file_ui.rs | 3 - crates/ui-egui/src/jobs_ui.rs | 12 +- crates/ui-egui/src/lib.rs | 83 +++------ crates/ui-egui/src/menus.rs | 3 +- crates/ui-egui/src/open_prompt.rs | 123 +++++++------ crates/ui-egui/src/psd_open_tests.rs | 187 ++++++++++++++++++++ crates/ui-egui/src/save_identity_tests.rs | 62 ------- crates/ui-egui/src/view_cmds.rs | 32 +--- 17 files changed, 458 insertions(+), 609 deletions(-) delete mode 100644 crates/io/src/recovery.rs create mode 100644 crates/ui-egui/src/psd_open_tests.rs diff --git a/apps/photocraft/src/services.rs b/apps/photocraft/src/services.rs index 9a1a6c1384..082506e92c 100644 --- a/apps/photocraft/src/services.rs +++ b/apps/photocraft/src/services.rs @@ -363,19 +363,6 @@ fn save_through( Ok(r.warnings) } -fn recovery_save_file( - doc: &Document, - path: &str, - settings: &photocraft_ui_egui::ExportSettings, - ctl: &photocraft_ui_egui::jobs_ui::SaveCtl, -) -> Result, String> { - save_through(doc, path, settings, ctl, |p, b, progress| { - photocraft_io::write_recovery_copy_bytes(Path::new(p), b).map_err(|e| e.to_string())?; - progress(1.0); - Ok(()) - }) -} - fn save_file( doc: &Document, path: &str, @@ -550,8 +537,6 @@ pub fn native(automation: Option) -> crate::crash_guard::guard("Export", || photocraft_io::export(doc, path, &opts).map(|r| (r.bytes, r.warnings)).map_err(|e| e.to_string())) })), save_file: Some(Arc::new(save_file)), - recovery_save_file: Some(Arc::new(recovery_save_file)), - recovery_write: Some(Box::new(|path: &str, bytes: &[u8]| photocraft_io::write_recovery_copy_bytes(Path::new(path), bytes).map_err(|e| e.to_string()))), file_dialog: Some(Box::new(show_file_dialog)), write: Some(Box::new(|path: &str, bytes: &[u8]| write_atomic(Path::new(path), bytes))), file_stamp: Some(Box::new(|path: &str| { diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index 45c298d005..5f3a5edec0 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -540,9 +540,6 @@ fn save_a_copy(s: &mut Session, p: &Value) -> Result { msg: "`path` is the document's own file, so the copy would replace it: choose another path, or pass \"overwrite\": true".into(), }); } - // Engine commands can be replayed from scripts. Recovery mode is never - // allowed to use the ordinary replacement writer, even for Save a Copy. - let recovery = d.recovery_mode; let mut doc = (*d.doc).clone(); if p.get("layers").and_then(Value::as_bool) == Some(false) { // "Layers" unchecked in Save a Copy: write the flattened image. @@ -550,14 +547,7 @@ fn save_a_copy(s: &mut Session, p: &Value) -> Result { let px = flattened(&doc, fmt); doc.layers = vec![Layer::new("Background", LayerContent::Raster(px))]; } - let opts = SaveOpts::from_params(s, p, "file.saveACopy")?; - let warnings = if recovery { - let (bytes, warnings) = encode(&doc, &path, opts)?; - photocraft_io::write_recovery_copy_bytes(std::path::Path::new(&path), &bytes).map_err(|e| EngineError::Other(e.to_string()))?; - warnings - } else { - save_doc(&doc, &path, opts)? - }; + let warnings = save_doc(&doc, &path, SaveOpts::from_params(s, p, "file.saveACopy")?)?; Ok(json!({"path": path, "warnings": warnings})) } @@ -1461,15 +1451,7 @@ fn flatten_all_masks(s: &mut Session) -> Result { fn layers_to_files(s: &mut Session, p: &Value) -> Result { let cmd = "file.export.layersToFiles"; let dir = str_param(p, "dir", cmd).or_else(|_| str_param(p, "output", cmd))?.to_string(); - let recovery = s.active().is_some_and(|d| d.recovery_mode); - let names = export_layers_with(s, p, |name, bytes| { - let path = join(&dir, name); - if recovery { - photocraft_io::write_recovery_copy_bytes(std::path::Path::new(&path), bytes).map_err(|e| EngineError::Other(e.to_string())) - } else { - write_file(&path, bytes) - } - })?; + let names = export_layers_with(s, p, |name, bytes| write_file(&join(&dir, name), bytes))?; let files: Vec = names.iter().map(|name| join(&dir, name)).collect(); Ok(json!({"files": files})) } @@ -1641,11 +1623,7 @@ fn color_lookup_tables(s: &mut Session, p: &Value) -> Result { let cube = bake_cube_layers(size as usize, &title, &layers); match p.get("path").and_then(Value::as_str) { Some(path) => { - if d.recovery_mode { - photocraft_io::write_recovery_copy_bytes(std::path::Path::new(path), cube.as_bytes()).map_err(|e| EngineError::Other(e.to_string()))?; - } else { - write_file(path, cube.as_bytes())?; - } + write_file(path, cube.as_bytes())?; Ok(json!({"path": path, "size": size, "layerCount": count})) } None => Ok(json!({"cube": cube, "size": size, "layerCount": count})), @@ -1947,24 +1925,3 @@ mod aces_exr_tests { } } } - -#[cfg(test)] -mod psd_recovery_tests { - use super::*; - #[cfg(not(target_arch = "wasm32"))] - #[test] - fn an_engine_action_does_not_replace_an_existing_file_in_recovery_mode() { - let mut s = Session::new(); - s.execute("file.new", json!({"width": 2, "height": 2})).unwrap(); - s.active_mut().unwrap().recovery_mode = true; - let path = std::env::temp_dir().join(format!( - "photocraft-engine-recovery-{}-{}", - std::process::id(), - std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos() - )); - std::fs::write(&path, b"original").unwrap(); - assert!(s.execute("file.saveACopy", json!({"path": path})).is_err()); - assert_eq!(std::fs::read(&path).unwrap(), b"original"); - std::fs::remove_file(path).unwrap(); - } -} diff --git a/crates/engine/src/jobs.rs b/crates/engine/src/jobs.rs index c97cab6b06..02f3c2c265 100644 --- a/crates/engine/src/jobs.rs +++ b/crates/engine/src/jobs.rs @@ -510,14 +510,14 @@ impl Session { self.start_open_inner(name, source, false) } - /// GUI opening: PSDs are decoded with the opt-in recovery path, but a - /// damaged result is held back until the user accepts the recovery prompt. - /// Headless/automation opening keeps the strict default above. + /// Interactive opening: hold a damaged PSD until the user answers a damage + /// confirmation, without changing import or subsequent save behaviour. + /// Headless callers keep using [`Self::start_open`]. pub fn start_open_for_user(&mut self, name: &str, source: OpenSource) -> Result { self.start_open_inner(name, source, true) } - fn start_open_inner(&mut self, name: &str, source: OpenSource, offer_recovery: bool) -> Result { + fn start_open_inner(&mut self, name: &str, source: OpenSource, confirm_damage: bool) -> Result { let label = format!("Opening {name}"); let name_w = name.to_string(); let name_a = name.to_string(); @@ -536,32 +536,26 @@ impl Session { ctx.check()?; ctx.progress(0.02, "Decoding"); let imported = ctx - .stage(0.02, 0.95, "Decoding", |ctl| { - if offer_recovery && photocraft_io::is_psd(&bytes) { - photocraft_io::import_psd_for_recovery_with(&name_w, &bytes, ctl) - } else { - photocraft_io::import_with_svg_group_depth_and_interrupt(&name_w, &bytes, max_svg_group_depth, ctl) - } - }) + .stage(0.02, 0.95, "Decoding", |ctl| photocraft_io::import_for_open_with(&name_w, &bytes, max_svg_group_depth, ctl)) .map_err(|e| match e { photocraft_io::IoError::Cancelled => EngineError::Cancelled, e => EngineError::Other(e.to_string()), })?; ctx.progress(0.95, "Preparing layers"); - warm_layer_bounds(&imported.document, || ctx.check())?; + warm_layer_bounds(&imported.0.document, || ctx.check())?; Ok(imported) }, - move |s, mut r: photocraft_io::ImportResult| { + move |s, (mut r, damaged): (photocraft_io::ImportResult, bool)| { // File Handling's ACEScg option, before the colour prompt looks at the profile. crate::file_cmds::tag_exr_colorspace(s, &name_a, &mut r.document); // Ask When Opening: held back until the prompt is answered (`take_held_open`). A // developed raw has no embedded profile to ask about. let raw = r.warnings.iter().any(|w| w.contains(photocraft_io::raw::DEVELOPED_NOTE)); - let recovery = offer_recovery && r.source_read_only && r.warnings.iter().any(|w| w.starts_with("PSD/PSB RECOVERY:")); + let damaged = confirm_damage && damaged; let question = s.color.open_question(&r.document).filter(|_| !raw); - if recovery || question.is_some() { + if damaged || question.is_some() { let held = s.hold_open(r.document, r.source_read_only); - return Ok(json!({"held": held, "name": name_a, "warnings": r.warnings, "color": question, "recovery": recovery})); + return Ok(json!({"held": held, "name": name_a, "warnings": r.warnings, "color": question, "damaged": damaged})); } let (index, color) = s.open_document(r.document, None); if let Some(st) = s.active_mut() { @@ -1022,3 +1016,50 @@ pub fn specs() -> Vec { #[cfg(test)] #[path = "jobs_tests.rs"] mod tests; + +#[cfg(test)] +#[path = "../../io/tests/support/recovery_psd.rs"] +mod psd_open_fixture; + +#[cfg(test)] +mod psd_open_confirmation_tests { + use super::*; + + fn result(s: &mut Session, started: Started) -> Value { + match started { + Started::Done(v) => v, + Started::Job(id) => s.wait_job(id).unwrap(), + } + } + + #[test] + fn headless_open_keeps_best_effort_psd_import() { + let mut s = Session::new(); + let started = s.start_open("damaged.psd", OpenSource::Bytes(Arc::new(super::psd_open_fixture::make_psd(true)))).unwrap(); + let v = result(&mut s, started); + assert!(v.get("document").is_some(), "{v}"); + assert!(v.get("held").is_none(), "no new prompt for a headless caller"); + assert!(!s.active().unwrap().source_read_only); + assert!(v["warnings"].as_array().unwrap().iter().any(|w| w.as_str().unwrap().contains("could not be decoded"))); + } + + #[test] + fn interactive_open_holds_only_a_damaged_psd() { + for corrupt in [false, true] { + let mut s = Session::new(); + let started = s.start_open_for_user("file.psd", OpenSource::Bytes(Arc::new(super::psd_open_fixture::make_psd(corrupt)))).unwrap(); + let v = result(&mut s, started); + if corrupt { + assert_eq!(v["damaged"], true); + assert!(s.documents().is_empty()); + let held = v["held"].as_u64().unwrap(); + let (doc, read_only) = s.take_held_open(held).unwrap(); + assert_eq!(doc.layers.len(), 2); + assert!(!read_only); + } else { + assert!(v.get("document").is_some(), "{v}"); + assert!(!s.active().unwrap().source_read_only); + } + } + } +} diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 87d79cf466..5a7aa83dfb 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -208,9 +208,6 @@ pub struct DocState { pub path: Option, /// An Affinity document (or its preview) must not acquire the native source as its Save path. pub source_read_only: bool, - /// This session came from a damaged PSD: every save is a new, no-overwrite copy. - /// Kept outside history so Undo and Save a Copy cannot remove the restriction. - pub recovery_mode: bool, /// Increments on every change; UIs re-render when it moves. pub revision: u64, pub saved_revision: u64, @@ -276,7 +273,6 @@ impl DocState { layer_anchor: active_layer, path, source_read_only: false, - recovery_mode: false, revision: 1, saved_revision: 1, view_revision: 0, diff --git a/crates/io/src/lib.rs b/crates/io/src/lib.rs index 5184dc0613..37227fff87 100644 --- a/crates/io/src/lib.rs +++ b/crates/io/src/lib.rs @@ -61,8 +61,6 @@ mod pdn; pub mod pixels; mod psd_export; mod psd_import; -mod recovery; -pub use recovery::write_recovery_copy_bytes; pub mod psd_thumbnail; pub mod raw; pub mod slices_map; @@ -304,94 +302,32 @@ pub fn import_with_svg_group_depth_and_interrupt( max_group_depth: usize, ctl: &photocraft_raster::Interrupt, ) -> Result { + import_for_open_with(name, bytes, max_group_depth, ctl).map(|(result, _)| result) +} + +/// The ordinary import result plus whether PSD/PSB decoding encountered damaged data. +/// Interactive callers can ask whether to continue before adding the document. This is +/// information, not a save policy: accepting it opens an ordinary, writable document. +/// Non-interactive callers keep using [`import`], which still returns readable content +/// and warnings without requiring confirmation. +/// +/// The flag is independent of the wording of `warnings`. An ordinary compatibility +/// warning does not set it. No file is decoded a second time to obtain this information. +pub fn import_for_open(name: &str, bytes: &[u8], max_group_depth: usize) -> Result<(ImportResult, bool), IoError> { + import_for_open_with(name, bytes, max_group_depth, &photocraft_raster::Interrupt::NONE) +} + +/// [`import_for_open`] with cancellation and progress, shared with [`import_with`]. +pub fn import_for_open_with(name: &str, bytes: &[u8], max_group_depth: usize, ctl: &photocraft_raster::Interrupt) -> Result<(ImportResult, bool), IoError> { ctl.check().map_err(|_| IoError::Cancelled)?; - let r = import_stages(name, bytes, ctl, max_group_depth)?; + let mut damaged = false; + let result = import_stages(name, bytes, ctl, max_group_depth, &mut damaged)?; ctl.check().map_err(|_| IoError::Cancelled)?; ctl.progress(1.0); - Ok(r) + Ok((result, damaged)) } -/// Import a damaged PSD/PSB for explicit recovery. Unlike [`import`], this -/// permits partially decoded layers, but marks the result source-read-only. -/// -/// Front ends must show `warnings`, require user consent before editing, -/// keep a session-level recovery flag, and use [`write_recovery_copy_bytes`] -/// for every write: it publishes only NEW file names and never replaces the -/// damaged original (or any existing file). Do not use this API as a drop-in -/// replacement for [`import`]. -pub fn import_psd_for_recovery(name: &str, bytes: &[u8]) -> Result { - import_psd_for_recovery_with(name, bytes, &photocraft_raster::Interrupt::NONE) -} - -/// Cancelable version of [`import_psd_for_recovery`]. -pub fn import_psd_for_recovery_with(name: &str, bytes: &[u8], ctl: &photocraft_raster::Interrupt) -> Result { - if !is_psd(bytes) { - return Err(IoError::Unsupported("recovery import accepts only PSD/PSB files".into())); - } - ctl.check().map_err(|_| IoError::Cancelled)?; - let result = import_stages_with_psd_recovery(name, bytes, ctl, photocraft_doc::MAX_GROUP_DEPTH, true)?; - ctl.check().map_err(|_| IoError::Cancelled)?; - ctl.progress(1.0); - Ok(result) -} - -/// Refuse a recovered document's copy destination if it names its source. -/// Canonical paths catch lexical aliases, `..`, relative paths, and symlinks; -/// on Unix, inode/device identity also catches hardlinks. The source must -/// exist, otherwise the check fails closed. -/// -/// This validates a destination at one instant; front ends must call it -/// immediately before their atomic write/rename. Callers also need to prevent -/// concurrent destination replacement (TOCTOU), or use a platform-specific -/// no-overwrite file operation. -pub fn validate_recovery_copy_destination(source: &std::path::Path, destination: &std::path::Path) -> Result<(), IoError> { - use std::io::ErrorKind; - use std::path::Path; - - let denied = || IoError::Unsupported("recovery copy must not overwrite the original PSD/PSB file".into()); - let source_path = std::fs::canonicalize(source).map_err(|e| IoError::Unsupported(format!("cannot verify original PSD/PSB path: {e}")))?; - let source_metadata = std::fs::metadata(source).map_err(|e| IoError::Unsupported(format!("cannot stat original PSD/PSB file: {e}")))?; - - let (candidate, exists) = match std::fs::symlink_metadata(destination) { - Ok(_) => (std::fs::canonicalize(destination).map_err(|e| IoError::Unsupported(format!("cannot resolve recovery destination: {e}")))?, true), - Err(e) if e.kind() == ErrorKind::NotFound => { - let parent = destination.parent().filter(|p| !p.as_os_str().is_empty()).unwrap_or(Path::new(".")); - let directory = std::fs::canonicalize(parent).map_err(|e| IoError::Unsupported(format!("cannot resolve recovery destination folder: {e}")))?; - let filename = destination.file_name().ok_or_else(|| IoError::Unsupported("recovery copy needs a filename".into()))?; - (directory.join(filename), false) - } - Err(e) => return Err(IoError::Unsupported(format!("cannot inspect recovery destination: {e}"))), - }; - if candidate == source_path { - return Err(denied()); - } - - // A hard link has a different path but the same inode. - #[cfg(unix)] - if exists { - use std::os::unix::fs::MetadataExt; - let metadata = std::fs::metadata(destination).map_err(|e| IoError::Unsupported(format!("cannot stat recovery destination: {e}")))?; - if metadata.dev() == source_metadata.dev() && metadata.ino() == source_metadata.ino() { - return Err(denied()); - } - } - #[cfg(not(unix))] - let _ = (source_metadata, exists); - - Ok(()) -} - -fn import_stages(name: &str, bytes: &[u8], ctl: &photocraft_raster::Interrupt, max_group_depth: usize) -> Result { - import_stages_with_psd_recovery(name, bytes, ctl, max_group_depth, false) -} - -fn import_stages_with_psd_recovery( - name: &str, - bytes: &[u8], - ctl: &photocraft_raster::Interrupt, - max_group_depth: usize, - recovery_requested: bool, -) -> Result { +fn import_stages(name: &str, bytes: &[u8], ctl: &photocraft_raster::Interrupt, max_group_depth: usize, damaged: &mut bool) -> Result { // A declared native extension must reach its loader so malformed bundles retain format errors. if has_extension(name, photocraft_format::EXTENSION) || photocraft_format::is_pcraft(bytes) { let document = photocraft_format::load_from_bytes(bytes)?; @@ -409,27 +345,11 @@ fn import_stages_with_psd_recovery( psd_import::check_group_depth(&file)?; ctl.check().map_err(|_| IoError::Cancelled)?; ctl.progress(0.05); - let (mut document, mut warnings, unsafe_for_editing) = psd_import::psd_to_document_decoded_integrity(&file, ctl, merged).ok_or(IoError::Cancelled)?; - // An imported document cannot be trusted when channels or layer blocks failed to decode: - // allowing a normal Save or a Save As targeting the original would destroy the raw data. - // The normal importer remains fail-closed. Only an explicit recovery request can open - // partial content, and its caller must enforce validate_recovery_copy_destination(). - if unsafe_for_editing && !recovery_requested { - return Err(IoError::Unsupported(format!( - "PSD/PSB contains unreadable image, layer or mask data; editing was refused to protect the source file ({})", - warnings - .iter() - .find(|w| w.contains("could not be decoded") || w.contains("could not be read") || w.contains("not imported")) - .map(String::as_str) - .unwrap_or("incomplete import"), - ))); - } - if unsafe_for_editing { - warnings.insert(0, "PSD/PSB RECOVERY: the document is incomplete. The original must never be overwritten. Use Save a Copy to a different file; some layers, masks or channels are missing.".into()); - } + let (mut document, warnings, psd_damaged) = psd_import::psd_to_document_decoded_integrity(&file, ctl, merged).ok_or(IoError::Cancelled)?; + *damaged = psd_damaged; document.name = name.to_string(); text_import::prepare(&mut document); - return Ok(ImportResult { document, warnings, source_read_only: unsafe_for_editing, preview_only: false }); + return Ok(ImportResult { document, warnings, source_read_only: false, preview_only: false }); } if affinity::is_affinity(bytes) || affinity::has_extension(name) { return affinity::import(name, bytes); @@ -684,7 +604,7 @@ pub fn merged_composite(file: &PsdFile) -> Result, IoError> { #[cfg(test)] mod tests { - use super::{IoError, import, is_svg_input}; + use super::{import, import_for_open, is_svg_input}; use photocraft_psd::{Compression, Version, testgen}; #[test] @@ -695,78 +615,30 @@ mod tests { } #[test] - fn unreadable_psd_channel_is_rejected_before_editing() { + fn unreadable_psd_channel_keeps_best_effort_import_and_reports_damage() { let mut file = testgen::small(Version::Psd, Compression::Raw); let channel = file.layers_mut()[0].channels.iter_mut().find(|c| c.id == 0).unwrap(); channel.data.clear(); let bytes = file.to_bytes().unwrap(); - assert!(matches!( - import("damaged.psd", &bytes), - Err(IoError::Unsupported(reason)) if reason.contains("unreadable") - )); + let imported = import("damaged.psd", &bytes).unwrap(); + assert!(!imported.source_read_only); + assert!(imported.warnings.iter().any(|w| w.contains("could not be decoded"))); + let (opened, damaged) = import_for_open("damaged.psd", &bytes, photocraft_doc::MAX_GROUP_DEPTH).unwrap(); + assert!(damaged); + assert!(!opened.source_read_only); + assert!(!opened.preview_only); + assert_eq!(opened.warnings, imported.warnings); + assert_eq!(opened.document.layers.len(), imported.document.layers.len()); } #[test] - fn explicit_recovery_opens_unreadable_psd_read_only() { - let mut file = testgen::small(Version::Psd, Compression::Raw); - let channel = file.layers_mut()[0].channels.iter_mut().find(|c| c.id == 0).unwrap(); - channel.data.clear(); - let bytes = file.to_bytes().unwrap(); - // Existing P0 behaviour: ordinary open is refused. - assert!(import("damaged.psd", &bytes).is_err()); - // Explicit recovery: a partial document, but never normal source save. - let recovered = super::import_psd_for_recovery("damaged.psd", &bytes).unwrap(); - assert!(recovered.source_read_only); - assert!(!recovered.preview_only); - assert!(recovered.warnings.iter().any(|w| w.contains("RECOVERY"))); - assert!(recovered.warnings.iter().any(|w| w.contains("could not be decoded"))); - } - - #[test] - fn recovery_import_of_valid_psd_remains_editable() { + fn valid_psd_does_not_request_damage_confirmation() { let bytes = testgen::small(Version::Psd, Compression::Raw).to_bytes().unwrap(); - let result = super::import_psd_for_recovery("valid.psd", &bytes).unwrap(); + let (result, damaged) = import_for_open("valid.psd", &bytes, photocraft_doc::MAX_GROUP_DEPTH).unwrap(); + assert!(!damaged); assert!(!result.source_read_only); } - #[test] - fn recovery_import_rejects_other_formats() { - assert!(super::import_psd_for_recovery("image.png", b"not a PSD").is_err()); - } - - #[test] - fn recovery_copy_guard_rejects_original_and_aliases() { - use std::fs; - use std::time::{SystemTime, UNIX_EPOCH}; - - let nonce = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos(); - let root = std::env::temp_dir().join(format!("photocraft-recovery-{nonce}-{}", std::process::id())); - fs::create_dir_all(root.join("subdir")).unwrap(); - let source = root.join("original.psd"); - fs::write(&source, b"original unchanged").unwrap(); - - assert!(super::validate_recovery_copy_destination(&source, &source).is_err()); - assert!(super::validate_recovery_copy_destination(&source, &root.join("subdir/../original.psd")).is_err()); - assert!(super::validate_recovery_copy_destination(&source, &root.join("recovered.psd")).is_ok()); - assert!(super::validate_recovery_copy_destination(&source, &root.join("subdir/recovered.psd")).is_ok()); - - #[cfg(unix)] - { - use std::os::unix::fs::symlink; - let link = root.join("alias.psd"); - symlink(&source, &link).unwrap(); - assert!(super::validate_recovery_copy_destination(&source, &link).is_err()); - let hardlink = root.join("hardlink.psd"); - fs::hard_link(&source, &hardlink).unwrap(); - assert!(super::validate_recovery_copy_destination(&source, &hardlink).is_err()); - let directory_link = root.join("alias_dir"); - symlink(&root, &directory_link).unwrap(); - assert!(super::validate_recovery_copy_destination(&source, &directory_link.join("original.psd")).is_err()); - } - assert_eq!(fs::read(&source).unwrap(), b"original unchanged"); - fs::remove_dir_all(root).unwrap(); - } - #[test] fn svg_extension_does_not_override_another_format_signature() { let webp_header = b"RIFF\x04\0\0\0WEBP"; diff --git a/crates/io/src/psd_import.rs b/crates/io/src/psd_import.rs index 2acfab577d..6e8bebe678 100644 --- a/crates/io/src/psd_import.rs +++ b/crates/io/src/psd_import.rs @@ -51,8 +51,8 @@ pub(crate) struct Ctx<'a> { pub cc: usize, pub cmyk: bool, pub warnings: Vec, - /// The import lost source data that cannot be safely written back to PSD/PSB. - pub unsafe_for_editing: bool, + /// Decoding encountered damaged PSD data; interactive opens ask whether to continue. + pub damaged: bool, /// Document resolution (type sizes are converted to points with it). pub dpi: f32, /// The parsed `Txt2` block (type settings EngineData lacks, e.g. optical kerning). @@ -135,7 +135,7 @@ impl Ctx<'_> { } fn warn_unreadable_data(&mut self, s: impl Into) { - self.unsafe_for_editing = true; + self.damaged = true; self.warn(s); } @@ -837,8 +837,8 @@ pub(crate) fn psd_to_document_decoded( } /// Also reports whether unrecoverable channel, layer or merged-image data was discarded. -/// Normal imports reject that result before exposing the document for editing; callers using -/// the low-level conversion API retain its existing best-effort behaviour. +/// Interactive opens use this to ask whether to continue. Both ordinary imports and +/// the low-level conversion API retain their existing best-effort behaviour. pub(crate) fn psd_to_document_decoded_integrity( file: &PsdFile, ctl: &photocraft_raster::Interrupt, @@ -910,9 +910,9 @@ pub(crate) fn psd_to_document_decoded_integrity( // A 16/32-bit file whose layer block can't be parsed would otherwise open as a flattened // file without a word (#2700). The raw block is kept, but a PSD save writes the document's // own layers in its place (see `psd_export`). - let mut unsafe_for_editing = false; + let mut damaged = false; if let Some((b, e)) = file.unreadable_layer_block() { - unsafe_for_editing = true; + damaged = true; warnings.push(format!( "the layers ({} block) could not be read ({e}); only the merged image was opened. Saving as PSD replaces the unreadable layer data", b.key_str() @@ -937,7 +937,7 @@ pub(crate) fn psd_to_document_decoded_integrity( cc, cmyk: fmt.mode == ColorMode::Cmyk, warnings, - unsafe_for_editing, + damaged, dpi: doc.resolution_dpi, txt2: file.global_blocks.iter().find(|b| &b.key == b"Txt2").and_then(|b| photocraft_text::psd::parse_txt2(&b.data)), filter_effects: Vec::new(), @@ -985,7 +985,7 @@ pub(crate) fn psd_to_document_decoded_integrity( Some(m) } else { if let Some(Err(e)) = decoded { - cx.warn(format!("merged image could not be decoded; opened the available layers instead: {e}")); + cx.warn_unreadable_data(format!("merged image could not be decoded; opened the available layers instead: {e}")); } None }; @@ -1163,7 +1163,7 @@ pub(crate) fn psd_to_document_decoded_integrity( return None; } ctl.progress(1.0); - Some((doc, cx.warnings, cx.unsafe_for_editing)) + Some((doc, cx.warnings, cx.damaged)) } #[cfg(test)] @@ -1209,33 +1209,33 @@ mod tests { } #[test] - fn unreadable_layer_channel_marks_conversion_unsafe_for_editing() { + fn unreadable_layer_channel_marks_conversion_damaged() { let mut file = testgen::small(Version::Psd, Compression::Raw); let channel = file.layers_mut()[0].channels.iter_mut().find(|c| c.id == 0).unwrap(); channel.data.clear(); assert!(file.layers()[0].decode_channel(0, file.header.depth, file.header.version).is_err()); - let (_, warnings, unsafe_for_editing) = psd_to_document_decoded_integrity(&file, &photocraft_raster::Interrupt::NONE, None).unwrap(); - assert!(unsafe_for_editing); + let (_, warnings, damaged) = psd_to_document_decoded_integrity(&file, &photocraft_raster::Interrupt::NONE, None).unwrap(); + assert!(damaged); assert!(warnings.iter().any(|w| w.contains("could not be decoded"))); } #[test] - fn unreadable_mask_channel_marks_conversion_unsafe_for_editing() { + fn unreadable_mask_channel_marks_conversion_damaged() { let mut file = testgen::small(Version::Psd, Compression::Raw); let channel = file.layers_mut()[0].channels.iter_mut().find(|c| c.id == CHANNEL_USER_MASK).unwrap(); channel.data.clear(); - let (_, warnings, unsafe_for_editing) = psd_to_document_decoded_integrity(&file, &photocraft_raster::Interrupt::NONE, None).unwrap(); - assert!(unsafe_for_editing); + let (_, warnings, damaged) = psd_to_document_decoded_integrity(&file, &photocraft_raster::Interrupt::NONE, None).unwrap(); + assert!(damaged); assert!(warnings.iter().any(|w| w.contains("could not be decoded"))); } #[test] fn valid_layer_channels_keep_conversion_editable() { let file = testgen::small(Version::Psd, Compression::Raw); - let (_, warnings, unsafe_for_editing) = psd_to_document_decoded_integrity(&file, &photocraft_raster::Interrupt::NONE, None).unwrap(); - assert!(!unsafe_for_editing, "unexpectedly marked good PSD unsafe: {warnings:?}"); + let (_, warnings, damaged) = psd_to_document_decoded_integrity(&file, &photocraft_raster::Interrupt::NONE, None).unwrap(); + assert!(!damaged, "unexpectedly marked good PSD damaged: {warnings:?}"); } #[test] diff --git a/crates/io/src/recovery.rs b/crates/io/src/recovery.rs deleted file mode 100644 index bc3c5c55e2..0000000000 --- a/crates/io/src/recovery.rs +++ /dev/null @@ -1,117 +0,0 @@ -//! A recovered PSD may be exported only to a new file. Publishing a completely -//! written temporary inode with `hard_link` gives an atomic, no-replace commit: -//! replacing the original file (including through an alias) is impossible. -//! -//! There is deliberately no fallback to `rename`, which can replace files. - -use crate::IoError; -use std::path::Path; - -#[cfg(not(target_arch = "wasm32"))] -struct Temporary(std::path::PathBuf); - -#[cfg(not(target_arch = "wasm32"))] -impl Drop for Temporary { - fn drop(&mut self) { - let _ = std::fs::remove_file(&self.0); - } -} - -/// Atomically publish an encoded recovery copy at a **previously unused** name. -/// Unlike a conventional Save As, this NEVER replaces an existing destination. -/// This includes aliases of the original (symlinks/hardlinks) and defeats a -/// race where a destination appears after an earlier `exists()` check. -/// A filesystem that cannot hard-link a same-directory temporary file fails -/// closed rather than falling back to a destructive operation. -#[cfg(not(target_arch = "wasm32"))] -pub fn write_recovery_copy_bytes(destination: &Path, bytes: &[u8]) -> Result<(), IoError> { - use std::fs::OpenOptions; - use std::io::Write; - use std::sync::atomic::{AtomicU64, Ordering}; - - static NEXT: AtomicU64 = AtomicU64::new(0); - let err = |e: std::io::Error| IoError::Unsupported(format!("recovery copy: {e}")); - let parent = destination.parent().filter(|p| !p.as_os_str().is_empty()).unwrap_or(Path::new(".")); - let name = destination.file_name().filter(|n| !n.is_empty()).ok_or_else(|| IoError::Unsupported("recovery copy needs a valid file name".into()))?; - let mut temporary = None; - for _ in 0..64 { - let next = NEXT.fetch_add(1, Ordering::Relaxed); - let mut filename = std::ffi::OsString::from(".photocraft-recovery-"); - filename.push(std::process::id().to_string()); - filename.push(format!("-{next}-")); - filename.push(name); - filename.push(".tmp"); - let candidate = parent.join(filename); - let mut opts = OpenOptions::new(); - opts.write(true).create_new(true); - #[cfg(unix)] - { - use std::os::unix::fs::OpenOptionsExt; - opts.mode(0o600); - } - match opts.open(&candidate) { - Ok(file) => { - temporary = Some((Temporary(candidate), file)); - break; - } - Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => continue, - Err(e) => return Err(err(e)), - } - } - let (temp, mut file) = temporary.ok_or_else(|| IoError::Unsupported("cannot reserve a temporary recovery file".into()))?; - file.write_all(bytes).map_err(err)?; - file.sync_all().map_err(err)?; - drop(file); - // The link operation is atomic: EEXIST if ANY file was placed at the - // destination, even after a previous validation or through a symlink. - std::fs::hard_link(&temp.0, destination).map_err(|e| { - if e.kind() == std::io::ErrorKind::AlreadyExists { - IoError::Unsupported("recovery copy must use a NEW file name; an existing file will never be overwritten".into()) - } else { - err(e) - } - })?; - // The copy now has its own name and stays intact when the temp name is removed. - Ok(()) -} - -#[cfg(target_arch = "wasm32")] -pub fn write_recovery_copy_bytes(_destination: &Path, _bytes: &[u8]) -> Result<(), IoError> { - Err(IoError::Unsupported("native recovery copy is unavailable on the web".into())) -} - -#[cfg(all(test, not(target_arch = "wasm32")))] -mod tests { - use super::*; - - #[test] - fn recovered_copy_never_replaces_an_existing_file() { - let dir = std::env::temp_dir().join(format!( - "photocraft-copy-{}-{}", - std::process::id(), - std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos() - )); - std::fs::create_dir(&dir).unwrap(); - let source = dir.join("original.psd"); - let copy = dir.join("copy.psd"); - std::fs::write(&source, b"valuable original").unwrap(); - assert!(write_recovery_copy_bytes(&source, b"damaged").is_err()); - assert_eq!(std::fs::read(&source).unwrap(), b"valuable original"); - write_recovery_copy_bytes(©, b"recovered").unwrap(); - assert_eq!(std::fs::read(©).unwrap(), b"recovered"); - assert!(write_recovery_copy_bytes(©, b"overwritten").is_err()); - assert_eq!(std::fs::read(©).unwrap(), b"recovered"); - #[cfg(unix)] - { - use std::os::unix::fs::symlink; - let link = dir.join("symlink.psd"); - symlink(&source, &link).unwrap(); - assert!(write_recovery_copy_bytes(&link, b"symlink overwrite").is_err()); - let hardlink = dir.join("hardlink.psd"); - std::fs::hard_link(&source, &hardlink).unwrap(); - assert!(write_recovery_copy_bytes(&hardlink, b"hardlink overwrite").is_err()); - } - assert_eq!(std::fs::read(&source).unwrap(), b"valuable original"); - std::fs::remove_dir_all(dir).unwrap(); - } -} diff --git a/crates/io/tests/psd_recovery_generated.rs b/crates/io/tests/psd_recovery_generated.rs index 2eaa62de0d..13479a843a 100644 --- a/crates/io/tests/psd_recovery_generated.rs +++ b/crates/io/tests/psd_recovery_generated.rs @@ -7,7 +7,7 @@ #[path = "support/recovery_psd.rs"] mod recovery_psd; -use photocraft_io::{IoError, import, import_psd_for_recovery}; +use photocraft_io::{import, import_for_open}; use photocraft_psd::PsdFile; #[test] @@ -18,10 +18,12 @@ fn valid_generated_psd_opens_normally() { assert!(!result.source_read_only); assert!(!result.preview_only); assert_eq!(result.document.layers.len(), 2); + let (_, damaged) = import_for_open("valid-two-layers.psd", &bytes, photocraft_doc::MAX_GROUP_DEPTH).unwrap(); + assert!(!damaged); } #[test] -fn corrupt_generated_rle_channel_requires_opt_in_recovery() { +fn corrupt_generated_rle_channel_keeps_best_effort_import_and_reports_damage() { let bytes = recovery_psd::make_psd(true); assert_eq!(bytes.len(), 74_986, "the fixture should retain the reference PSD layout"); let (parsed, _) = PsdFile::from_bytes_and_merged(&bytes, |_| false).expect("the PSD container must stay valid"); @@ -32,15 +34,49 @@ fn corrupt_generated_rle_channel_requires_opt_in_recovery() { assert!(layer.decode_channel(2, parsed.header.depth, parsed.header.version).is_ok()); assert!(parsed.decode_merged().is_ok(), "the composite must remain recoverable"); - let error = import("corrupt-green-rle.psd", &bytes).unwrap_err(); - assert!(matches!(error, IoError::Unsupported(_)), "unexpected error: {error}"); + let imported = import("corrupt-green-rle.psd", &bytes).expect("headless imports keep readable content"); + assert!(!imported.source_read_only); + assert!(!imported.preview_only); + assert_eq!(imported.document.layers.len(), 2); + assert!(imported.warnings.iter().any(|w| w.contains("could not be decoded"))); - let recovered = import_psd_for_recovery("corrupt-green-rle.psd", &bytes).expect("explicit recovery must return readable layers"); - assert!(recovered.source_read_only, "recovery must not save over the source"); - assert!(!recovered.preview_only); - assert!(!recovered.document.layers.is_empty()); - assert!(recovered.warnings.iter().any(|w| w.starts_with("PSD/PSB RECOVERY:"))); - assert!(recovered.warnings.iter().any(|w| w.contains("could not be decoded"))); + let (opened, damaged) = import_for_open("corrupt-green-rle.psd", &bytes, photocraft_doc::MAX_GROUP_DEPTH).unwrap(); + assert!(damaged, "interactive opening must ask whether to continue"); + assert!(!opened.source_read_only, "the flag does not introduce a save restriction"); + assert_eq!(opened.warnings, imported.warnings); + assert_eq!(opened.document.layers.len(), imported.document.layers.len()); +} + +#[test] +fn damaged_composite_keeps_layers_and_requests_interactive_confirmation() { + let mut file = PsdFile::from_bytes(&recovery_psd::make_psd(false)).unwrap(); + file.image_data.data.truncate(file.image_data.data.len() / 2); + let bytes = file.to_bytes().unwrap(); + let imported = import("damaged-preview.psd", &bytes).expect("intact layers are still usable"); + assert_eq!(imported.document.layers.len(), 2); + assert!(!imported.source_read_only); + let (opened, damaged) = import_for_open("damaged-preview.psd", &bytes, photocraft_doc::MAX_GROUP_DEPTH).unwrap(); + assert!(damaged); + assert_eq!(opened.warnings, imported.warnings); + assert!(opened.warnings.iter().any(|w| w.contains("merged image"))); +} + +#[test] +fn ordinary_compatibility_warning_does_not_mean_damaged() { + use photocraft_psd::{ImageResource, ResolutionInfo, resources::ids}; + let mut file = PsdFile::from_bytes(&recovery_psd::make_psd(false)).unwrap(); + let resolution = ResolutionInfo { v_res_fixed: ResolutionInfo::from_dpi(150.0).v_res_fixed, ..ResolutionInfo::from_dpi(300.0) }; + file.resources.push(ImageResource::new(ids::RESOLUTION_INFO, resolution.to_bytes())); + let (opened, damaged) = import_for_open("resolution.psd", &file.to_bytes().unwrap(), photocraft_doc::MAX_GROUP_DEPTH).unwrap(); + assert!(!damaged); + assert!(opened.warnings.iter().any(|w| w.contains("vertical resolution"))); +} + +#[test] +fn fatal_parse_errors_are_not_turned_into_confirmation_requests() { + let bytes = b"8BPS\0"; + assert!(import("truncated.psd", bytes).is_err()); + assert!(import_for_open("truncated.psd", bytes, photocraft_doc::MAX_GROUP_DEPTH).is_err()); } /// Generate the same two PSDs on demand for manual testing in the GUI. diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index 182930232e..52a4cfc49a 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -315,6 +315,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) { ui.add_space(8.0); about_tab_body(app, ui, chosen); } + DialogKind::Command if crate::open_prompt::owns_damage(&fields) => crate::open_prompt::damage_body(ui, &fields), DialogKind::Command if crate::guide_layout_ui::owns(&fields) => outcome = crate::guide_layout_ui::body(app, ui, &mut fields, interactive), DialogKind::Command if crate::brush_preset_dialog::owns(&fields) => { outcome = crate::brush_preset_dialog::body(app, ui, &mut fields, interactive) @@ -414,6 +415,8 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) { } else { let ok_label = if d.kind == DialogKind::NewDocument { tl!("Create") + } else if crate::open_prompt::owns_damage(&d.fields) { + tl!("Continue") } else if crate::delete_layer_prompt::owns(&d.fields) { tl!("Delete") } else if crate::disk_change_prompt::owns(&d.fields) { @@ -622,6 +625,7 @@ pub fn confirm(app: &mut PhotocraftApp, id: u64) -> Result { } r } + DialogKind::Command if crate::open_prompt::owns_damage(&d.fields) => crate::open_prompt::answer_damage(app, true), DialogKind::Command if crate::guide_layout_ui::owns(&d.fields) => crate::guide_layout_ui::confirm(app, &d.fields), DialogKind::Command if crate::brush_preset_dialog::owns(&d.fields) => crate::brush_preset_dialog::confirm(app, &d.fields), DialogKind::Command if crate::fill_ui::owns(&d.fields) => crate::fill_ui::confirm(app, &d.fields), @@ -687,7 +691,9 @@ pub fn cancel(app: &mut PhotocraftApp, id: u64) -> Result { app.ui.dialogs.retain(|child| child.fields.get("__dialog").and_then(Value::as_u64) != Some(id)); } // Cancel on a profile prompt opens neither its file nor the ones still to come. - if crate::open_prompt::owns(&closed.fields) { + if crate::open_prompt::owns_damage(&closed.fields) { + crate::open_prompt::answer_damage(app, false)?; + } else if crate::open_prompt::owns(&closed.fields) { crate::open_prompt::answer(app, None)?; } app.ui.dialogs.retain(|d| !crate::layer_style::color_picker::child_of(&d.fields, id)); diff --git a/crates/ui-egui/src/file_ui.rs b/crates/ui-egui/src/file_ui.rs index 4e5745adef..32f97bc4e8 100644 --- a/crates/ui-egui/src/file_ui.rs +++ b/crates/ui-egui/src/file_ui.rs @@ -696,9 +696,6 @@ fn web_confirm(app: &mut PhotocraftApp, f: &Map) -> Result Result { - if app.session.active().is_some_and(|st| st.recovery_mode) { - return Err("PSD recovery: Save for Web is disabled for this document; first save a new recovery copy and reopen it".into()); - } #[cfg(target_arch = "wasm32")] let result = download_for_web(app, p); #[cfg(not(target_arch = "wasm32"))] diff --git a/crates/ui-egui/src/jobs_ui.rs b/crates/ui-egui/src/jobs_ui.rs index e836692fdb..bd7c16ace9 100644 --- a/crates/ui-egui/src/jobs_ui.rs +++ b/crates/ui-egui/src/jobs_ui.rs @@ -552,8 +552,7 @@ fn finish_open(app: &mut PhotocraftApp, name: &str, path: Option<&str>, v: &Valu let held = |doc, read_only, question, policy_applied| crate::open_prompt::Held { doc, read_only, - recovery_mode: v.get("recovery").and_then(Value::as_bool).unwrap_or(false), - recovery_pending: v.get("recovery").and_then(Value::as_bool).unwrap_or(false), + damage_pending: v.get("damaged").and_then(Value::as_bool).unwrap_or(false), name: name.to_string(), path: path.map(str::to_string), warnings: warnings.clone(), @@ -565,7 +564,7 @@ fn finish_open(app: &mut PhotocraftApp, name: &str, path: Option<&str>, v: &Valu // Held back for the profile prompt (Ask When Opening). if let Some(id) = v.get("held").and_then(Value::as_u64) { let (doc, read_only) = app.session.take_held_open(id).ok_or("the open job's document is gone")?; - crate::open_prompt::arrive(app, held(doc, read_only, v.get("color").cloned(), false)); + crate::open_prompt::arrive(app, held(doc, read_only, v.get("color").filter(|q| !q.is_null()).cloned(), false)); return Ok(()); } let mut index = v.get("document").and_then(Value::as_u64).ok_or("the open job returned no document")? as usize; @@ -609,11 +608,8 @@ pub(crate) fn after_open(app: &mut PhotocraftApp, name: &str, path: Option<&str> } else { notices::io_warnings(app, &opened, warnings); } - // Script event hooks can save a file or run other I/O commands. Do not - // dispatch them automatically for a recovered, partially decoded PSD. - if !app.session.active().is_some_and(|st| st.recovery_mode) { - photocraft_engine::automate_cmds::document_opened(&mut app.session); - } + // Script events bound to "Open Document". + photocraft_engine::automate_cmds::document_opened(&mut app.session); app.sync_views(); } diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 0bc7b47c1b..f108ef8bd1 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -526,10 +526,6 @@ pub struct Services { /// Encode and write in one step on a worker thread, so a large save doesn't freeze the /// window (#2017). With background jobs on, saves use it instead of `export` and `write`. pub save_file: Option, - /// Recovery-mode writes publish ONLY new files (no replace, even via aliases). - pub recovery_write: Option, - /// The worker version of `recovery_write`, to keep large PSD copies responsive. - pub recovery_save_file: Option, /// File access used only by control/MCP requests. Interactive dialogs keep /// using `file_dialog` and `write` with the user's authority. pub automation_read: Option, @@ -1459,13 +1455,14 @@ impl PhotocraftApp { } let import = self.services.import.as_ref().ok_or("no importer configured")?; let max_svg_group_depth = self.session.prefs().file_handling.rasterize_svg_groups_deeper_than as usize; - let (doc, warnings, recovery_mode) = match import(name, bytes, max_svg_group_depth) { - Ok((doc, warnings)) => (doc, warnings, false), - Err(error) if photocraft_io::is_psd(bytes) => match photocraft_io::import_psd_for_recovery(name, bytes) { - Ok(r) if r.source_read_only && r.warnings.iter().any(|w| w.starts_with("PSD/PSB RECOVERY:")) => (r.document, r.warnings, true), - _ => return Err(error), - }, - Err(error) => return Err(error), + let (doc, warnings, damaged) = if photocraft_io::is_psd(bytes) { + // Read PSD damage as structured information in the same decode, not by + // retrying an error or matching the text of a compatibility warning. + let (r, damaged) = photocraft_io::import_for_open(name, bytes, max_svg_group_depth).map_err(|e| e.to_string())?; + (r.document, r.warnings, damaged) + } else { + let (doc, warnings) = import(name, bytes, max_svg_group_depth)?; + (doc, warnings, false) }; // Edit › Color Settings policies apply on open; Ask When Opening holds the file back // until its prompt is answered, and later files wait behind it (`open_prompt`). @@ -1479,9 +1476,8 @@ impl PhotocraftApp { self, open_prompt::Held { doc, - read_only: recovery_mode || photocraft_io::affinity::is_affinity(bytes), - recovery_mode, - recovery_pending: recovery_mode, + read_only: photocraft_io::affinity::is_affinity(bytes), + damage_pending: damaged, name: name.to_string(), path: path.map(str::to_string), warnings: warnings.clone(), @@ -1553,7 +1549,7 @@ impl PhotocraftApp { return Err("Answer the TIFF, Targa or DDS Options before starting another save".into()); } // Edit Contents documents save back into their smart object. - if path.is_none() && !self.session.active().is_some_and(|st| st.recovery_mode) && self.session.is_enabled("layer.smartObjects.saveContents") { + if path.is_none() && self.session.is_enabled("layer.smartObjects.saveContents") { self.run("layer.smartObjects.saveContents", serde_json::json!({}))?; return Ok(serde_json::json!({"path": "smart object", "warnings": []})); } @@ -1575,21 +1571,16 @@ impl PhotocraftApp { || (e == "ora" && holds_ora) || (flat && photocraft_codecs::from_extension(&e).is_some_and(|f| f.caps().write)) }); - let suggested = if st.recovery_mode { - let name = st.doc.name.rsplit_once('.').map(|(stem, _)| stem).unwrap_or(&st.doc.name); - format!("{name} recovered.psd") - } else { - match &st.path { - Some(p) if writable => p.clone(), - p => { - let source = p.as_deref().unwrap_or(&st.doc.name); - let ext = match photocraft_engine::file_cmds::extension(source).as_deref() { - Some("pdn") => "pcraft", - Some("kra" | "krz") => "ora", - _ => "psd", - }; - std::path::Path::new(source).with_extension(ext).to_string_lossy().into_owned() - } + let suggested = match &st.path { + Some(p) if writable => p.clone(), + p => { + let source = p.as_deref().unwrap_or(&st.doc.name); + let ext = match photocraft_engine::file_cmds::extension(source).as_deref() { + Some("pdn") => "pcraft", + Some("kra" | "krz") => "ora", + _ => "psd", + }; + std::path::Path::new(source).with_extension(ext).to_string_lossy().into_owned() } }; let doc = st.doc.id; @@ -1771,23 +1762,6 @@ impl PhotocraftApp { /// `None` when the save went to a background job (#2017), which finishes it in /// [`jobs_ui::tick`]. pub(crate) fn write_document(&mut self, path: String, settings: &ExportSettings, copy: bool) -> Result)>, String> { - if self.session.active().is_some_and(|st| st.recovery_mode) { - // Keep the recovery restriction for the entire session, even after - // successfully writing a copy. Neither Save nor Save As can replace - // ANY existing file; only a new copy is possible. - if self.background_jobs { - let writer = self.services.recovery_save_file.clone().ok_or("safe recovery-copy writer not available")?; - return jobs_ui::start_save(self, path, settings.clone(), true, writer, false); - } - let st = self.session.active().ok_or("no document")?; - let (doc, revision) = (st.doc.id, st.revision); - let export = self.services.export.as_ref().ok_or("no exporter configured")?; - let (bytes, warnings) = export(&st.doc, &path, settings)?; - let write = self.services.recovery_write.as_mut().ok_or("safe recovery-copy writer not available")?; - write(&path, &bytes)?; - self.saved(doc, revision, &path, &warnings, true); - return Ok(Some((path, warnings))); - } if self.background_jobs && let Some(save) = self.services.save_file.clone() { @@ -1825,12 +1799,7 @@ impl PhotocraftApp { (false, holds) } }; - let recovery_copy = copy && self.session.documents().iter().any(|st| st.doc.id == doc && st.recovery_mode); - self.ui.status = if recovery_copy { - crate::i18n::fmt(tl!("Saved recovered copy as {name}"), &[("name", path)]) - } else { - crate::i18n::fmt(tl!("Saved {name}"), &[("name", path)]) - }; + self.ui.status = crate::i18n::fmt(tl!("Saved {name}"), &[("name", path)]); if !copy { // A background save may finish while another document is active (or after its // document was closed, when there is nothing left to record). @@ -1912,11 +1881,6 @@ impl PhotocraftApp { /// Targa's `None`: 32 with an alpha channel or transparency, else 24; a DDS texture's: /// uncompressed without mipmaps). Automation saves never prompt. pub fn save_automation_with(&mut self, path: Option, choices: FormatChoices) -> Result { - // Automation writes use a capability-scoped writer which may replace a - // destination. Do not silently downgrade the recovery no-overwrite rule. - if self.session.active().is_some_and(|st| st.recovery_mode) { - return Err("PSD recovery: automated saving is disabled for this document; choose File > Save a Copy with a new filename".into()); - } let target = { let state = self.session.active().ok_or("no document")?; // As File › Save: without `path` only a layered file is written back (#416). @@ -2234,7 +2198,6 @@ impl eframe::App for PhotocraftApp { workspace_ui::windows(self, &ctx); palette::show(self, &ctx); dialogs::show(self, &ctx); - open_prompt::recovery_dialog(self, &ctx); rasterize_prompt::run_pending(self, &ctx); jobs_ui::dialog(self, &ctx); discard_ui::show(self, &ctx); @@ -2979,6 +2942,8 @@ mod transform_undo_tests; #[cfg(test)] mod transform_type_tests; +#[cfg(test)] +mod psd_open_tests; #[cfg(test)] mod save_identity_tests; diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 77373d6b0d..63b46f4429 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -13,8 +13,7 @@ pub(crate) fn modal_allows(app: &PhotocraftApp, id: &str) -> bool { if app.camera_raw.is_some() || crate::crop_ui::blocks(app, id) { return false; } - (app.ui.dialogs.is_empty() && app.discard.is_none() && !app.held_opens.front().is_some_and(|h| h.recovery_pending)) - || crate::shortcuts::NAV_COMMANDS.contains(&id) + (app.ui.dialogs.is_empty() && app.discard.is_none()) || crate::shortcuts::NAV_COMMANDS.contains(&id) } /// Top-level menus in Photoshop order. diff --git a/crates/ui-egui/src/open_prompt.rs b/crates/ui-egui/src/open_prompt.rs index 3a86e2019f..39f4dee8a8 100644 --- a/crates/ui-egui/src/open_prompt.rs +++ b/crates/ui-egui/src/open_prompt.rs @@ -1,8 +1,9 @@ -//! Ask When Opening (Edit › Color Settings): a file whose embedded profile doesn't match the -//! working space (or that has none) is held back while a prompt asks what to do, as Photoshop -//! does: one prompt at a time, naming its file, before that file opens. OK applies the answer to -//! that file and opens it, then asks about the next; Cancel opens neither it nor the files still -//! to come. Files that finish reading while a prompt is up wait their turn, so they open in order. +//! Interactive opening confirmations: damaged PSD data and Color Settings questions. +//! A decoded file is held back while its standard, agent-accessible dialog asks what to do. +//! Damage confirmation comes first; Continue admits the file normally once any profile question +//! is answered, with no persistent save restriction. Cancelling damage discards just that file; +//! cancelling a profile question retains its existing behaviour of cancelling the whole queue. +//! Files that finish reading while a prompt is up wait their turn. use std::sync::Arc; @@ -13,16 +14,18 @@ use crate::PhotocraftApp; /// The field that marks a prompt as this module's. const FIELD: &str = "__heldOpen"; +/// A regular dialog: agents see it in `ui.inspect` and answer through +/// `ui.dialog.confirm` / `ui.dialog.cancel`, just like the profile prompt. +const DAMAGE_FIELD: &str = "__psdDamagedOpen"; /// A file read and decoded, waiting to open. pub struct Held { pub doc: Document, /// The source is read-only (an Affinity file): Save doesn't write back to it. pub read_only: bool, - /// True for damaged PSDs admitted only through the explicit recovery path. - pub recovery_mode: bool, - /// Consent must be obtained before the document is opened or a profile prompt appears. - pub recovery_pending: bool, + /// Ask whether to continue before adding a damaged PSD or showing its profile prompt. + /// Discarded after the answer: it does not become a document or save restriction. + pub damage_pending: bool, pub name: String, pub path: Option, pub warnings: Vec, @@ -52,8 +55,11 @@ pub fn arrive(app: &mut PhotocraftApp, held: Held) { /// Opens queued files in order until one needs its prompt, which is shown if it isn't yet. fn advance(app: &mut PhotocraftApp) { while let Some(front) = app.held_opens.front() { - if front.recovery_pending { - return; // The recovery consent window is drawn by recovery_dialog(). + if front.damage_pending { + if !app.ui.dialogs.iter().any(|d| owns_damage(&d.fields)) { + show_damage(app); + } + return; } if front.question.is_some() { if !app.ui.dialogs.iter().any(|d| d.fields.contains_key(FIELD)) { @@ -119,8 +125,8 @@ pub fn owns(fields: &serde_json::Map) -> bool { /// The prompt's answer: `Some(action)` (OK) opens the first queued file with it and moves on to /// the next; `None` (Cancel) drops every queued file and stops the reads still running. pub fn answer(app: &mut PhotocraftApp, action: Option<&str>) -> Result { - if app.held_opens.front().is_some_and(|h| h.recovery_pending) { - return Err("answer the PSD recovery confirmation first".into()); + if app.held_opens.front().is_some_and(|h| h.damage_pending) { + return Err("answer the damaged PSD confirmation first".into()); } let Some(action) = action else { let dropped = app.held_opens.len(); @@ -144,8 +150,8 @@ pub fn answer(app: &mut PhotocraftApp, action: Option<&str>) -> Result Result { - if app.held_opens.front().is_some_and(|h| h.recovery_pending) { - return Err("answer the PSD recovery confirmation first".into()); + if app.held_opens.front().is_some_and(|h| h.damage_pending) { + return Err("answer the damaged PSD confirmation first".into()); } let Some(key) = app.held_opens.front().and_then(|h| policy_key(h.doc.mode)) else { return answer(app, Some(action)) }; let policy = match action { @@ -155,9 +161,7 @@ pub fn answer_remembering(app: &mut PhotocraftApp, action: &str) -> Result Result) -> bool { + fields.contains_key(DAMAGE_FIELD) +} + +fn show_damage(app: &mut PhotocraftApp) { + let Some(front) = app.held_opens.front().filter(|h| h.damage_pending) else { return }; + let message = format!( + "{}\n\n{}\n\n{}", + crate::i18n::fmt(tl!("The document “{name}” may be damaged."), &[("name", &front.name)]), + tl!("Some layers, pixels or masks could not be read. Do you want to continue opening it?"), + tl!("If you continue, saving over the original may permanently discard unreadable data. Save a copy to keep the original."), + ); + let fields = [ + (DAMAGE_FIELD.into(), json!(true)), + ("__label".into(), json!("Damaged Photoshop document")), + ("name".into(), json!(front.name)), + ("message".into(), json!(message)), + ("warnings".into(), json!(front.warnings)), + ] + .into_iter() + .collect(); + app.ui.open_dialog(crate::state::DialogKind::Command, fields); +} + +/// Body of the standard modal; the same fields are visible to automation. +pub(crate) fn damage_body(ui: &mut egui::Ui, fields: &serde_json::Map) { + ui.label(fields.get("message").and_then(Value::as_str).unwrap_or_default()); + if let Some(warnings) = fields.get("warnings").and_then(Value::as_array) { + egui::ScrollArea::vertical().max_height(140.0).show(ui, |ui| { + for warning in warnings.iter().filter_map(Value::as_str) { + ui.label(warning); } }); - }); - if let Some(accept) = choice { - answer_recovery(app, accept); } } -/// Accept or discard the first pending damaged PSD. This is also the modal's testable -/// transition: no document is opened before `accept` is explicitly true. -pub(crate) fn answer_recovery(app: &mut PhotocraftApp, accept: bool) { - if !app.held_opens.front().is_some_and(|h| h.recovery_pending) { - return; - } +/// Continue or discard this file only, then move the queue forward. Accepting does not +/// mark the document read-only: Save, Export, scripts and web downloads work normally. +pub(crate) fn answer_damage(app: &mut PhotocraftApp, accept: bool) -> Result { + let Some(front) = app.held_opens.front_mut().filter(|h| h.damage_pending) else { + return Err("no damaged PSD is waiting for confirmation".into()); + }; + let name = front.name.clone(); if accept { - if let Some(front) = app.held_opens.front_mut() { - front.recovery_pending = false; - } + front.damage_pending = false; } else { app.held_opens.pop_front(); + app.ui.status = crate::i18n::fmt(tl!("Cancelled opening {name}"), &[("name", &name)]); + app.ui.status_error = false; } advance(app); + Ok(json!({"name": name, "continued": accept})) } /// Opens a queued file, applying `action` (the prompt's answer) or else the Color Settings /// policy, then does what any open does afterwards. fn open(app: &mut PhotocraftApp, held: Held, action: Option<&str>) -> Result { - if held.recovery_pending { - return Err("damaged PSD cannot be opened before recovery consent".into()); + if held.damage_pending { + return Err("damaged PSD cannot be opened before confirmation".into()); } - let Held { mut doc, read_only, recovery_mode, recovery_pending: _, name, path, warnings, bytes, slot, question, policy_applied } = held; + let Held { mut doc, read_only, damage_pending: _, name, path, warnings, bytes, slot, question, policy_applied } = held; let index = if question.is_some() || policy_applied { if let Some(action) = action && let Err(e) = app.session.color.resolve_open(&mut doc, action) @@ -236,7 +250,6 @@ fn open(app: &mut PhotocraftApp, held: Held, action: Option<&str>) -> Result app diff --git a/crates/ui-egui/src/psd_open_tests.rs b/crates/ui-egui/src/psd_open_tests.rs new file mode 100644 index 0000000000..4a5149de48 --- /dev/null +++ b/crates/ui-egui/src/psd_open_tests.rs @@ -0,0 +1,187 @@ +//! Damaged PSD confirmation is an opening decision, not a persistent save policy. +//! The exact same generated files exercise IO, the synchronous web-style path, +//! background opening and the agent-visible dialog commands. + +#[path = "../../io/tests/support/recovery_psd.rs"] +mod recovery_psd; + +use crate::{PhotocraftApp, Services, control}; +use photocraft_engine::Session; +use serde_json::{Value, json}; +use std::{cell::RefCell, rc::Rc}; + +fn app() -> PhotocraftApp { + let mut app = PhotocraftApp::new( + Session::new(), + Services { + import: Some(Box::new(|name, bytes, depth| { + photocraft_io::import_with_svg_group_depth(name, bytes, depth).map(|r| (r.document, r.warnings)).map_err(|e| e.to_string()) + })), + export: Some(Box::new(|doc, path, _| { + photocraft_io::export(doc, path, &Default::default()).map(|r| (r.bytes, r.warnings)).map_err(|e| e.to_string()) + })), + write: Some(Box::new(|_, _| Ok(()))), + automation_write: Some(Box::new(|_, _| Ok(()))), + ..Default::default() + }, + ); + app.background_jobs = false; + app +} + +fn call(app: &mut PhotocraftApp, method: &str, params: Value) -> Value { + let (req, _rx) = control::ControlRequest::new(method, params); + match control::handle(app, &egui::Context::default(), &req) { + control::Outcome::Done(v) => v, + _ => panic!("{method}: expected an immediate reply"), + } +} + +fn damage_dialog(app: &mut PhotocraftApp) -> u64 { + let inspected = call(app, "ui.inspect", json!({})); + assert_eq!(inspected["ok"], true); + let dialogs = inspected["result"]["dialogs"].as_array().unwrap(); + assert_eq!(dialogs.len(), 1, "only the damage confirmation: {dialogs:?}"); + assert_eq!(dialogs[0]["fields"]["__psdDamagedOpen"], true); + assert!(dialogs[0]["fields"]["message"].as_str().unwrap().contains("saving over the original")); + dialogs[0]["id"].as_u64().unwrap() +} + +#[test] +fn healthy_psd_opens_without_a_damage_prompt() { + let mut app = app(); + app.open_bytes("valid-two-layers.psd", &recovery_psd::make_psd(false)).unwrap(); + assert_eq!(app.session.documents().len(), 1); + assert!(app.ui.dialogs.is_empty()); + assert!(!app.session.active().unwrap().source_read_only); +} + +#[test] +fn damaged_psd_can_be_cancelled_or_accepted_through_agent_dialog_commands() { + let mut app = app(); + let bytes = recovery_psd::make_psd(true); + app.open_bytes("corrupt-green-rle.psd", &bytes).unwrap(); + assert!(app.session.documents().is_empty()); + let id = damage_dialog(&mut app); + assert_eq!(call(&mut app, "ui.dialog.cancel", json!({"dialog": id}))["ok"], true); + assert!(app.session.documents().is_empty()); + assert!(app.ui.dialogs.is_empty()); + + app.open_bytes("corrupt-green-rle.psd", &bytes).unwrap(); + let id = damage_dialog(&mut app); + assert_eq!(call(&mut app, "ui.dialog.confirm", json!({"dialog": id}))["ok"], true); + assert_eq!(app.session.documents().len(), 1); + assert!(!app.session.active().unwrap().source_read_only); + assert!(app.ui.dialogs.is_empty()); +} + +#[test] +fn accepted_psd_keeps_its_source_path_and_uses_the_normal_save_writer() { + let mut app = app(); + let path = "original.psd"; + let stored = Rc::new(RefCell::new(recovery_psd::make_psd(true))); + let original = stored.borrow().clone(); + let destination = stored.clone(); + app.services.write = Some(Box::new(move |p, bytes| { + assert_eq!(p, path); + *destination.borrow_mut() = bytes.to_vec(); + Ok(()) + })); + app.open_bytes_from(path, &original, Some(path)).unwrap(); + assert_eq!(*stored.borrow(), original, "nothing written while waiting for consent"); + let id = damage_dialog(&mut app); + assert_eq!(call(&mut app, "ui.dialog.confirm", json!({"dialog": id}))["ok"], true); + assert_eq!(app.session.active().unwrap().path.as_deref(), Some(path)); + assert_eq!(*stored.borrow(), original, "accepting the open is not a save"); + + for _ in 0..2 { + app.run("layer.new.layer", json!({})).unwrap(); + crate::menus::invoke(&mut app, &egui::Context::default(), "file.save", json!({})).unwrap(); + assert_eq!(app.session.active().unwrap().path.as_deref(), Some(path)); + assert!(!app.session.active().unwrap().is_dirty()); + assert!(photocraft_io::import(path, &stored.borrow()).is_ok()); + } + assert_ne!(*stored.borrow(), original, "ordinary Save can replace the source after consent"); + assert!(app.save_automation(Some("automated-copy.psd".into())).is_ok()); +} + +#[test] +fn accepted_psd_uses_web_download_semantics_without_a_special_writer() { + let mut app = app(); + app.services.write_unconfirmed = true; + app.open_bytes("corrupt-green-rle.psd", &recovery_psd::make_psd(true)).unwrap(); + let id = damage_dialog(&mut app); + assert_eq!(call(&mut app, "ui.dialog.confirm", json!({"dialog": id}))["ok"], true); + app.run("layer.new.layer", json!({})).unwrap(); + app.save_as(Some("download.psd".into())).unwrap(); + assert_eq!(app.session.active().unwrap().path.as_deref(), Some("download.psd")); + assert!(app.session.active().unwrap().is_dirty(), "an unconfirmed browser download is not a confirmed save"); +} + +#[test] +fn damaged_psd_automation_import_does_not_require_interactive_confirmation() { + let mut app = app(); + let warnings = app.open_automation_bytes("corrupt-green-rle.psd", &recovery_psd::make_psd(true)).unwrap(); + assert_eq!(app.session.documents().len(), 1); + assert!(!app.session.active().unwrap().source_read_only); + assert!(app.ui.dialogs.is_empty()); + assert!(warnings.iter().any(|w| w.contains("could not be decoded"))); +} + +#[test] +fn cancelling_one_damaged_open_does_not_open_the_next_damaged_file_without_consent() { + let mut app = app(); + let bytes = recovery_psd::make_psd(true); + for name in ["first.psd", "second.psd"] { + app.open_bytes(name, &bytes).unwrap(); + } + let first = damage_dialog(&mut app); + assert_eq!(call(&mut app, "ui.dialog.cancel", json!({"dialog": first}))["ok"], true); + assert!(app.session.documents().is_empty()); + let second = damage_dialog(&mut app); + assert_ne!(first, second); + assert_eq!(app.ui.dialogs[0].fields["name"], "second.psd"); + assert_eq!(call(&mut app, "ui.dialog.confirm", json!({"dialog": second}))["ok"], true); + assert_eq!(app.session.documents().len(), 1); + assert_eq!(app.session.active().unwrap().doc.name, "second.psd"); +} + +#[test] +fn damage_confirmation_precedes_the_profile_question() { + let mut app = app(); + app.run("edit.colorSettings", json!({"askOnMismatch": true, "policyRgb": "preserve"})).unwrap(); + let (mut file, _) = photocraft_psd::PsdFile::from_bytes_and_merged(&recovery_psd::make_psd(true), |_| false).unwrap(); + file.resources.push(photocraft_psd::ImageResource::new( + photocraft_psd::resources::ids::ICC_PROFILE, + photocraft_cms::Builtin::from_id("adobe-rgb-compat").unwrap().profile().to_bytes().to_vec(), + )); + app.open_bytes("profile.psd", &file.to_bytes().unwrap()).unwrap(); + let id = damage_dialog(&mut app); + assert!(crate::open_prompt::answer(&mut app, Some("preserve")).is_err(), "a profile answer cannot bypass the damage confirmation"); + assert_eq!(call(&mut app, "ui.dialog.confirm", json!({"dialog": id}))["ok"], true); + assert!(app.session.documents().is_empty(), "the profile question still needs its own answer"); + assert_eq!(app.ui.dialogs.len(), 1); + assert!(!crate::open_prompt::owns_damage(&app.ui.dialogs[0].fields)); + let profile = app.ui.dialogs[0].id; + assert_eq!(call(&mut app, "ui.dialog.confirm", json!({"dialog": profile}))["ok"], true); + assert_eq!(app.session.documents().len(), 1); +} + +#[cfg(not(target_arch = "wasm32"))] +#[test] +fn background_damage_only_open_does_not_create_a_spurious_profile_question() { + let mut app = app(); + app.background_jobs = true; + app.open_bytes("corrupt-green-rle.psd", &recovery_psd::make_psd(true)).unwrap(); + // Wait deterministically for the worker, then let the normal UI completion path run. + let jobs: Vec<_> = app.session.jobs().iter().map(|j| j.id).collect(); + for id in jobs { + app.session.wait_job(id).unwrap(); + } + crate::jobs_ui::tick(&mut app, &egui::Context::default()); + assert!(app.session.documents().is_empty()); + let id = damage_dialog(&mut app); + assert_eq!(call(&mut app, "ui.dialog.confirm", json!({"dialog": id}))["ok"], true); + assert_eq!(app.session.documents().len(), 1); + assert!(app.ui.dialogs.is_empty(), "color:null is not a profile question"); +} diff --git a/crates/ui-egui/src/save_identity_tests.rs b/crates/ui-egui/src/save_identity_tests.rs index 166de4c8aa..3396dfcdd5 100644 --- a/crates/ui-egui/src/save_identity_tests.rs +++ b/crates/ui-egui/src/save_identity_tests.rs @@ -272,65 +272,3 @@ fn unconfirmed_download_names_the_document_but_keeps_it_unsaved() { app.save_as(Some("download.psd".into())).unwrap(); assert!(!app.has_unsaved_work()); } - -#[cfg(not(target_arch = "wasm32"))] -#[test] -fn recovery_session_remains_protected_after_saving_a_copy() { - let mut app = app(); - let dir = std::env::temp_dir().join(format!( - "photocraft-recovery-ui-{}-{}", - std::process::id(), - std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos() - )); - std::fs::create_dir(&dir).unwrap(); - let original = dir.join("original.psd"); - let copy = dir.join("copy.psd"); - std::fs::write(&original, b"valuable original bytes").unwrap(); - app.session.active_mut().unwrap().recovery_mode = true; - app.session.active_mut().unwrap().source_read_only = true; - app.services.recovery_write = - Some(Box::new(|path, bytes| photocraft_io::write_recovery_copy_bytes(std::path::Path::new(path), bytes).map_err(|e| e.to_string()))); - let own = identity(&app); - assert!(app.save_as(Some(original.to_string_lossy().into_owned())).is_err()); - app.save_as(Some(copy.to_string_lossy().into_owned())).unwrap(); - assert!(copy.is_file()); - assert_eq!(identity(&app), own, "Save a Copy must not retarget the recovered session"); - assert!(app.session.active().unwrap().recovery_mode); - assert!(app.save_as(Some(copy.to_string_lossy().into_owned())).is_err()); - assert!(app.save_automation(Some(original.to_string_lossy().into_owned())).is_err()); - assert_eq!(std::fs::read(original).unwrap(), b"valuable original bytes"); - std::fs::remove_dir_all(dir).unwrap(); -} - -#[test] -fn recovery_consent_is_required_before_opening() { - let mut session = Session::new(); - session.execute("file.new", json!({"width": 2, "height": 2})).unwrap(); - let doc = (*session.active().unwrap().doc).clone(); - session.close(0); - let mut app = PhotocraftApp::new(session, Services::default()); - let make_held = |doc: photocraft_doc::Document| crate::open_prompt::Held { - doc, - read_only: true, - recovery_mode: true, - recovery_pending: true, - name: "damaged.psd".into(), - path: Some("/tmp/damaged.psd".into()), - warnings: vec!["PSD/PSB RECOVERY: partial import".into()], - bytes: None, - slot: None, - question: None, - policy_applied: false, - }; - crate::open_prompt::arrive(&mut app, make_held(doc.clone())); - assert_eq!(app.session.documents().len(), 0); - crate::open_prompt::answer_recovery(&mut app, false); - assert_eq!(app.session.documents().len(), 0); - crate::open_prompt::arrive(&mut app, make_held(doc)); - crate::open_prompt::answer_recovery(&mut app, true); - assert_eq!(app.session.documents().len(), 1); - let st = app.session.active().unwrap(); - assert!(st.recovery_mode); - assert!(st.source_read_only); - assert_eq!(st.path, None); -} diff --git a/crates/ui-egui/src/view_cmds.rs b/crates/ui-egui/src/view_cmds.rs index bfab75a502..7fffcf784a 100644 --- a/crates/ui-egui/src/view_cmds.rs +++ b/crates/ui-egui/src/view_cmds.rs @@ -1469,11 +1469,9 @@ fn front(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str, params: &Value) /// and saved state are untouched. An action being recorded keeps it as a `file.saveACopy` step /// with its path (#4373). fn save_a_copy(app: &mut PhotocraftApp) -> Result { - let st = app.session.active().ok_or("no document")?; - let recovered = st.recovery_mode; - let doc = st.doc.clone(); + let doc = app.session.active().ok_or("no document")?.doc.clone(); let stem = doc.name.rsplit_once('.').map_or(doc.name.as_str(), |(a, _)| a); - let suggested = if recovered { format!("{stem} recovered.psd") } else { format!("{stem} copy.psd") }; + let suggested = format!("{stem} copy.psd"); // The copy is of the document as it was when asked. app.pick_save(&suggested, move |app, path| { // An RGB Targa asks for its bits per pixel first, and a DDS texture for its compression; @@ -1492,7 +1490,7 @@ fn save_a_copy(app: &mut PhotocraftApp) -> Result { if parked { return Ok(json!({"path": path, "warnings": []})); } - let r = write_copy_with_mode(app, &doc, &path, crate::FormatChoices::default(), recovered)?; + let r = write_copy(app, &doc, &path, crate::FormatChoices::default())?; app.session.journal.push(("file.saveACopy".into(), json!({"path": path}))); Ok(r) }) @@ -1501,25 +1499,10 @@ fn save_a_copy(app: &mut PhotocraftApp) -> Result { /// Writes `doc` to `path` as a copy (Save a Copy, and its replayed action step): the document's /// path and saved state are untouched. `choices` are the Targa and DDS answers, when there are any. pub(crate) fn write_copy(app: &mut PhotocraftApp, doc: &photocraft_doc::Document, path: &str, choices: crate::FormatChoices) -> Result { - let recovered = app.session.documents().iter().any(|st| st.doc.id == doc.id && st.recovery_mode); - write_copy_with_mode(app, doc, path, choices, recovered) -} - -fn write_copy_with_mode( - app: &mut PhotocraftApp, - doc: &photocraft_doc::Document, - path: &str, - choices: crate::FormatChoices, - recovered: bool, -) -> Result { let settings = choices.apply(app.save_settings()); let export = app.services.export.as_ref().ok_or("no exporter configured")?; let (bytes, warnings) = export(doc, path, &settings)?; - let write = if recovered { - app.services.recovery_write.as_mut().ok_or("safe recovery-copy writer not available")? - } else { - app.services.write.as_mut().ok_or("no writer configured")? - }; + let write = app.services.write.as_mut().ok_or("no writer configured")?; write(path, &bytes)?; let template = "Saved a copy as {path}"; app.ui.status = crate::i18n::fmt(tl!(template), &[("path", path)]); @@ -1532,16 +1515,11 @@ fn write_copy_with_mode( /// Layer › Smart Objects › Export Contents: saves the contents file under its own name by default. fn export_contents(app: &mut PhotocraftApp) -> Result { let st = app.session.active().ok_or("no document")?; - let recovered = st.recovery_mode; let layer = st.active_layer.ok_or("no layer selected")?; // The contents as they were when asked, like Save a Copy. let (name, bytes) = photocraft_engine::smart_cmds::contents_of(&st.doc, layer).map_err(|e| e.to_string())?; app.pick_save(&name.clone(), move |app, path| { - let write = if recovered { - app.services.recovery_write.as_mut().ok_or("safe recovery-copy writer not available")? - } else { - app.services.write.as_mut().ok_or("no writer configured")? - }; + let write = app.services.write.as_mut().ok_or("no writer configured")?; write(&path, &bytes)?; let template = "Exported contents to {path}"; app.ui.status = crate::i18n::fmt(tl!(template), &[("path", &path)]); From da58af974a405d52db31d09ac72b6399e55e143d Mon Sep 17 00:00:00 2001 From: Jason D Date: Wed, 21 Oct 2026 11:19:55 -0400 Subject: [PATCH 210/649] io: port TIFF alpha and spot channels from #7415 Flat and layered TIFFs write and read alpha channels, spot channels and a Quick Mask as extra samples, with Photoshop's channel resources. This is the io part of #7415 as it stands, on current main; the next commit keeps PSD output as it is on main. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Zer0C00L01 <12090083+Zer0C00L01@users.noreply.github.com> --- Cargo.lock | 1 + book/src/formats/raster-formats.md | 2 +- crates/io/Cargo.toml | 1 + crates/io/src/channel_map.rs | 93 ++++- crates/io/src/flat.rs | 4 + crates/io/src/pixels.rs | 27 ++ crates/io/src/psd_export.rs | 23 +- crates/io/src/psd_import.rs | 28 +- crates/io/src/tiff_layers.rs | 632 ++++++++++++++++++++++++++++- crates/io/tests/tiff_layers.rs | 606 ++++++++++++++++++++++++++- crates/psd/src/file.rs | 8 + crates/psd/tests/roundtrip.rs | 1 + docs/file-format-parity.md | 5 +- docs/gaps.md | 8 +- docs/target-app-parity.md | 5 +- scorecard/file_compat.toml | 8 +- 16 files changed, 1396 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b0ff196c55..6743a397de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4924,6 +4924,7 @@ dependencies = [ "roxmltree 0.20.0", "serde_json", "thiserror 2.0.21", + "tiff", ] [[package]] diff --git a/book/src/formats/raster-formats.md b/book/src/formats/raster-formats.md index c333cbc737..2173feccad 100644 --- a/book/src/formats/raster-formats.md +++ b/book/src/formats/raster-formats.md @@ -4,7 +4,7 @@ ## Layered TIFF -A TIFF saved by Photoshop with its layers carries them in two private tags: 37724 (`ImageSourceData`, the same layer section a PSD has, preceded by the string `Adobe Photoshop Document Data Block`) and 34377 (the PSD image resources). `photocraft-codecs` passes both through as opaque bytes on `Metadata`; `photocraft-io` rebuilds a PSD model from them plus the TIFF's pixels and hands it to the PSD importer, so groups, masks, layer styles, type, shapes, smart objects and adjustment layers open from a TIFF exactly as from a PSD, and are written back the same way. In Intel-order (`II`) files Photoshop stores the whole block structure byte-swapped (reversed keys such as `MIB8` and `ryaL`, little-endian integers and doubles) while pixel samples stay big-endian; `photocraft-psd`'s `tiff` module converts between the two orders field by field, and drops, with a warning, any block whose layout it does not know rather than pass byte-swapped data to other readers. Limits: a TIFF holds one transparency sample, so extra alpha channels are not written; Lab documents are saved flat. Save As asks "Including layers will increase file size" (with "Discard Layers and Save a Copy") while *Ask Before Saving Layered TIFF Files* is on in Preferences › File Handling. Scripted and agent saves write a flat TIFF unless they ask for layers: `--tiff-layers` for `photocraft-cli convert`, `run` and `batch`, and `"tiffLayers": true` in the save, batch and export commands and MCP `doc_save`. +A TIFF saved by Photoshop with its layers carries them in two private tags: 37724 (`ImageSourceData`, the same layer section a PSD has, preceded by the string `Adobe Photoshop Document Data Block`) and 34377 (the PSD image resources). `photocraft-codecs` passes both through as opaque bytes on `Metadata`; `photocraft-io` rebuilds a PSD model from them plus the TIFF's pixels and hands it to the PSD importer, so groups, masks, layer styles, type, shapes, smart objects and adjustment layers open from a TIFF exactly as from a PSD, and are written back the same way. In Intel-order (`II`) files Photoshop stores the whole block structure byte-swapped (reversed keys such as `MIB8` and `ryaL`, little-endian integers and doubles) while pixel samples stay big-endian; `photocraft-psd`'s `tiff` module converts between the two orders field by field, and drops, with a warning, any block whose layout it does not know rather than pass byte-swapped data to other readers. Limits: up to sixteen extra samples (spot colours and alpha channels, plus a Quick Mask) are written in the IFD and round-trip, with Photoshop image resources for the channel name, ink colour and solidity; Lab documents are saved flat, with their extra samples. Save As asks "Including layers will increase file size" (with "Discard Layers and Save a Copy") while *Ask Before Saving Layered TIFF Files* is on in Preferences › File Handling. Scripted and agent saves write a flat TIFF unless they ask for layers: `--tiff-layers` for `photocraft-cli convert`, `run` and `batch`, and `"tiffLayers": true` in the save, batch and export commands and MCP `doc_save`. ## WebP diff --git a/crates/io/Cargo.toml b/crates/io/Cargo.toml index eb8c0b00d7..37ac195d7c 100644 --- a/crates/io/Cargo.toml +++ b/crates/io/Cargo.toml @@ -55,3 +55,4 @@ flate2 = { workspace = true } photocraft-psd = { workspace = true, features = ["testgen"] } photocraft-raw = { workspace = true, features = ["testgen"] } proptest = { workspace = true } +tiff = { version = "0.11", default-features = false, features = ["deflate", "lzw"] } diff --git a/crates/io/src/channel_map.rs b/crates/io/src/channel_map.rs index bafde26f30..60b671101a 100644 --- a/crates/io/src/channel_map.rs +++ b/crates/io/src/channel_map.rs @@ -1,10 +1,12 @@ //! Alpha / spot channel options <-> PSD `DisplayInfo` image resources (1077, and the older 1007). //! -//! Layout (Adobe PSD spec, "DisplayInfo"): resource 1077 starts with a 4-byte version (1), then -//! one 13-byte record per extra channel: colour space (u16), four u16 colour components, opacity -//! (u16, 0..100) and kind (u8: 0 = colour indicates selected areas, 1 = masked ("protected") -//! areas, 2 = spot channel). Resource 1007 has the same records without the version and the spot -//! kind, each followed by a padding byte (14 bytes). +//! Layout (Adobe PSD spec, "DisplayInfo", and a Photoshop 27 layered TIFF): resource 1077 +//! starts with a 4-byte version (1), then one record per extra channel: colour space (u16), +//! four u16 colour components, opacity (u16, 0..100) and kind (u8: 0 = colour indicates +//! selected areas, 1 = masked ("protected") areas, 2 = spot channel). Photoshop writes that +//! 13-byte record with no pad. Older files pad each record to 14 bytes; both are read. +//! Resource 1007 has the same records without the version, each followed by a padding byte. +//! When the merged image has transparency, Photoshop writes that channel's record first. use photocraft_color::{Color, ColorMode}; use photocraft_doc::{AlphaChannel, ColorIndicates}; @@ -13,6 +15,8 @@ pub(crate) const DISPLAY_INFO: u16 = 1077; pub(crate) const DISPLAY_INFO_OLD: u16 = 1007; /// Quick Mask information: channel id (u16) and an "initially empty" flag (u8). pub(crate) const QUICK_MASK_INFO: u16 = 1022; +/// Alpha channel identifiers (Photoshop 6): one big-endian u32 per extra channel, no count prefix. +pub(crate) const ALPHA_IDENTIFIERS: u16 = 1053; const SPACE_RGB: u16 = 0; const SPACE_HSB: u16 = 1; @@ -20,6 +24,23 @@ const SPACE_CMYK: u16 = 2; const SPACE_LAB: u16 = 7; const SPACE_GRAY: u16 = 8; +/// Resource 1053: channel ids `1..=count`, one big-endian u32 each, with no length prefix. +/// Photoshop, ag-psd and psd-tools read u32s until the resource ends. +pub(crate) fn alpha_identifiers(count: usize) -> Vec { + alpha_identifiers_from(1, count) +} + +/// Resource 1053 starting at `first` (a layered TIFF uses the sample's index in the IFD: +/// 3 for the spot after RGB, not 1). +pub(crate) fn alpha_identifiers_from(first: u32, count: usize) -> Vec { + let mut out = Vec::with_capacity(count.saturating_mul(4)); + for i in 0..count { + let id = first.saturating_add(u32::try_from(i).unwrap_or(u32::MAX)); + out.extend_from_slice(&id.to_be_bytes()); + } + out +} + /// Resource 1077 for `channels` (in file order): a version, then 13 bytes per channel (colour /// space, four components, opacity, kind). Every corpus file, Photoshop's included, uses 13; /// 14-byte records (the older 1007 layout) shift every channel after the first. @@ -46,12 +67,41 @@ pub(crate) fn display_info(channels: &[&AlphaChannel], transparency: bool) -> Ve out } -/// Applies a DisplayInfo resource (`versioned` = 1077: 13-byte records after a version; else the -/// older 1007 with 14-byte records) to the imported channels in order, after skipping `skip` -/// records (the merged transparency channel's). +/// 13 when every record is Photoshop's unpadded form, otherwise the 14-byte padded form. +/// +/// Lengths divisible by both (14, 28, … unpadded records, or 13, 26, … padded ones) take +/// the unpadded stride for resource 1077, which is what Photoshop 27 writes, and the padded +/// stride for the older 1007 resource, whose record includes the pad byte. +fn display_stride(body: &[u8], versioned: bool) -> usize { + let unpadded = !body.is_empty() && body.len().is_multiple_of(13); + let padded = !body.is_empty() && body.len().is_multiple_of(14); + if unpadded && (!padded || versioned) { 13 } else { 14 } +} + +/// Which of the first `count` DisplayInfo records are spot channels (kind 2). +/// Missing records are not spots. Alpha channels (kind 0 or 1) stay false: their samples +/// are stored straight, while a spot's samples are stored inverted. +pub(crate) fn spot_flags(data: &[u8], versioned: bool, count: usize) -> Vec { + let body = if versioned { data.get(4..).unwrap_or(&[]) } else { data }; + let stride = display_stride(body, versioned); + let mut out = vec![false; count]; + for (i, rec) in body.chunks(stride).take(count).enumerate() { + if rec.len() >= 13 { + out[i] = rec[12] == 2; + } + } + out +} + +/// Applies a DisplayInfo resource (`versioned` = 1077: records after a version; else the older +/// 1007) to the imported channels in order, after skipping `skip` records (the merged +/// transparency channel's). Both the 13-byte records Photoshop writes and the 14-byte padded +/// form are read. pub(crate) fn apply_display_info(data: &[u8], versioned: bool, skip: usize, channels: &mut [AlphaChannel]) { - let (body, size) = if versioned { (data.get(4..).unwrap_or(&[]), 13) } else { (data, 14) }; - for (c, rec) in channels.iter_mut().zip(body.chunks_exact(size).skip(skip)) { + let body = if versioned { data.get(4..).unwrap_or(&[]) } else { data }; + let stride = display_stride(body, versioned); + for (c, rec) in channels.iter_mut().zip(body.chunks(stride).skip(skip)) { + let Some(rec) = rec.get(..13) else { break }; let u = |i: usize| u16::from_be_bytes([rec[i], rec[i + 1]]); let comps = [u(2), u(4), u(6), u(8)]; let color = decode_color(u(0), comps); @@ -149,6 +199,14 @@ mod tests { assert!((back[0].opacity - 0.3).abs() < 1e-6); assert_eq!(back[0].indicates, ColorIndicates::SelectedAreas); assert_eq!(back[1].spot, s.spot); + assert_eq!(alpha_identifiers(2), [0, 0, 0, 1, 0, 0, 0, 2]); + assert!(alpha_identifiers(0).is_empty()); + assert_eq!(alpha_identifiers_from(3, 1), [0, 0, 0, 3]); + // Photoshop 27 writes a 13-byte record (no pad): red spot, solidity 60. + let ps = [0, 0, 0, 1, 0, 0, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0x3c, 2]; + let mut spot = vec![AlphaChannel::new("S", Surface::new(PixelFormat::GRAY8))]; + apply_display_info(&ps, true, 0, &mut spot); + assert_eq!(spot[0].spot.map(|(c, s)| (c.to_rgb(), (s * 100.0).round() as u16)), Some(([1.0, 0.0, 0.0], 60))); // With the merged transparency's record first, the channels still get their own. let with_t = display_info(&[&a, &s], true); assert_eq!(with_t.len(), 4 + 3 * 13); @@ -160,6 +218,21 @@ mod tests { let mut c = vec![AlphaChannel::new("x", Surface::new(PixelFormat::GRAY8))]; apply_display_info(&bytes[..10], true, 0, &mut c); assert_eq!(c[0].opacity, 0.5); + + // 14 unpadded records are a multiple of 14 as well (14×13 = 13×14). Resource 1077 + // still reads them as 13-byte records; the last spot's solidity must survive. + let mut many = Vec::new(); + for i in 0..14 { + let mut ch = AlphaChannel::new(format!("{i}"), Surface::new(PixelFormat::GRAY8)); + ch.spot = Some((Color::rgb(1.0, 0.0, 0.0), (i as f32) / 14.0)); + many.push(ch); + } + let refs: Vec<&AlphaChannel> = many.iter().collect(); + let packed = display_info(&refs, false); + assert_eq!(packed.len(), 4 + 14 * 13); + let mut got: Vec = (0..14).map(|i| AlphaChannel::new(format!("{i}"), Surface::new(PixelFormat::GRAY8))).collect(); + apply_display_info(&packed, true, 0, &mut got); + assert_eq!(got[13].spot.map(|(_, s)| (s * 100.0).round() as u16), many[13].spot.map(|(_, s)| (s * 100.0).round() as u16)); } #[test] diff --git a/crates/io/src/flat.rs b/crates/io/src/flat.rs index c9e3a410ae..8139a36a4c 100644 --- a/crates/io/src/flat.rs +++ b/crates/io/src/flat.rs @@ -237,6 +237,7 @@ pub(crate) fn image_to_document(name: &str, img: &Image) -> Result SampleType { } } +/// Complements every sample in `bytes`. Photoshop stores a spot channel as ink density +/// inverted: 0 is solid ink and the maximum sample is bare paper (the same convention as a +/// CMYK plate and as Multichannel). An alpha channel is not stored this way: 0 is empty and +/// the maximum sample is selected. `big_endian` is the PSD merged-image order; TIFF extra +/// samples are native-endian. +pub fn invert_plane(bytes: &mut [u8], s: SampleType, big_endian: bool) { + let bps = s.bytes(); + if bps == 0 { + return; + } + for c in bytes.chunks_exact_mut(bps) { + match s { + SampleType::U8 => c[0] = 255 - c[0], + SampleType::U16 => { + let v = if big_endian { u16::from_be_bytes([c[0], c[1]]) } else { u16::from_ne_bytes([c[0], c[1]]) }; + let w = 65535 - v; + c.copy_from_slice(&(if big_endian { w.to_be_bytes() } else { w.to_ne_bytes() })); + } + SampleType::F32 => { + let v = if big_endian { f32::from_be_bytes([c[0], c[1], c[2], c[3]]) } else { f32::from_ne_bytes([c[0], c[1], c[2], c[3]]) }; + let w = 1.0 - v; + c.copy_from_slice(&(if big_endian { w.to_be_bytes() } else { w.to_ne_bytes() })); + } + } + } +} + fn invert_sample(bytes: &mut [u8], s: SampleType) { match s { SampleType::U8 => bytes[0] = 255 - bytes[0], diff --git a/crates/io/src/psd_export.rs b/crates/io/src/psd_export.rs index 454f1c5dd8..81d3ebe5a4 100644 --- a/crates/io/src/psd_export.rs +++ b/crates/io/src/psd_export.rs @@ -484,6 +484,8 @@ impl Ex { } flags.set_hidden(!l.visible); flags.set_transparency_protected(l.locks.transparency); + // Bit 3 (with bit 4 clear) is the flag Photoshop sets on every layer it writes. + flags.0 |= LayerFlags::BIT4_USEFUL; let mut blocks = vec![TaggedBlock::unicode_name(&l.name), TaggedBlock::layer_id(id)]; let lspf = blocks::lspf_from_locks(&l.locks); if lspf != 0 { @@ -1075,6 +1077,8 @@ impl Ex { match &l.content { LayerContent::Group(g) => { let id = self.fresh_id(); + let mut divider_flags = LayerFlags(0); + divider_flags.0 |= LayerFlags::BIT4_USEFUL; self.records.push(LayerRecord { channels: self.empty_channels(), blending_ranges: BlendingRanges::full(self.cc), @@ -1084,6 +1088,7 @@ impl Ex { TaggedBlock::layer_id(id), TaggedBlock::section_divider(SectionType::BoundingDivider, None, None), ], + flags: divider_flags, ..Default::default() }); self.emit(&g.children, tick); @@ -1205,9 +1210,12 @@ pub(crate) fn pascal_names_resource(names: &[&str]) -> Vec { let mut v = Vec::new(); for n in names { let b = legacy_name(n); - v.push(b.len() as u8); - v.extend_from_slice(&b); + let n = b.len().min(255); + v.push(n as u8); + v.extend_from_slice(&b[..n]); } + // No per-string pad: Photoshop's resource 1006 for "Spot Color 1" is 13 bytes + // (length byte + 12 characters). The 8BIM container pads an odd resource separately. v } @@ -1703,7 +1711,9 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c for a in &extra { let s = if a.surface.format() != ex.mask_fmt { a.surface.convert(ex.mask_fmt) } else { a.surface.clone() }; let bytes = s.to_interleaved(canvas); - planes.extend(deinterleave(&bytes, 1, sample, &[false]).remove(0)); + // Spot ink is stored inverted (0 = solid, max = paper), the same way Multichannel + // and a Photoshop TIFF do. An alpha channel stays straight (max = selected). + planes.extend(deinterleave(&bytes, 1, sample, &[a.spot.is_some()]).remove(0)); } let channels = (cc + usize::from(has_alpha) + extra.len()) as u16; let mode = if duotone_inks.is_some() { PsdMode::Duotone } else { psd_mode(fmt.mode) }; @@ -1734,6 +1744,7 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c resources.push(ImageResource::new(1006, pascal_names_resource(&names))); resources.push(ImageResource::new(1045, unicode_names_resource(&names))); resources.push(ImageResource::new(crate::channel_map::DISPLAY_INFO, crate::channel_map::display_info(&extra, has_alpha))); + resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers(extra.len()))); } if let Some(id) = quick_mask_id { let mut data = id.to_be_bytes().to_vec(); @@ -1816,6 +1827,10 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c if !keep_imported_resource(doc, *id, data) { continue; } + // A fresh 1053 was written with the extra channels. A preserved copy would be a second one. + if *id == crate::channel_map::ALPHA_IDENTIFIERS && !extra.is_empty() { + continue; + } let mut r = ImageResource::new(*id, data.to_vec()); r.name = legacy_name(name); resources.push(r); @@ -1866,7 +1881,7 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c resources, layer_info, layer_info_placement: placement, - global_layer_mask: (has_layers || !global_blocks.is_empty()).then(GlobalLayerMask::default), + global_layer_mask: (has_layers || !global_blocks.is_empty()).then(GlobalLayerMask::photoshop_default), global_blocks, layer_mask_trailing: Vec::new(), image_data, diff --git a/crates/io/src/psd_import.rs b/crates/io/src/psd_import.rs index 0eca6d704f..82f998143b 100644 --- a/crates/io/src/psd_import.rs +++ b/crates/io/src/psd_import.rs @@ -603,7 +603,7 @@ fn be_to_ne_plane(plane: &[u8], s: SampleType, n: usize) -> Vec { interleave(&[Some(plane)], &[zero_sample(s)], n, s, &[false]) } -fn unicode_names(data: &[u8]) -> Vec { +pub(crate) fn unicode_names(data: &[u8]) -> Vec { let mut out = Vec::new(); let mut at = 0; while at + 4 <= data.len() { @@ -832,6 +832,10 @@ pub(crate) fn psd_to_document_decoded( doc.clipping_path = Some(photocraft_doc::ClippingPath { name, flatness: 0.0 }); doc.metadata.psd_resources.push((r.id, String::from_utf8_lossy(&r.name).into_owned(), Arc::new(r.data.clone()))); } + // Resource 1053 is rewritten from the extra channels on a layered save, so keeping + // the copy just written would show up as new metadata. Multichannel has no such + // rewrite: the imported bytes are the channel ids, copied back when they still match. + crate::channel_map::ALPHA_IDENTIFIERS if !multichannel => {} id if MAPPED_RESOURCES.contains(&id) => {} id => doc.metadata.psd_resources.push((id, String::from_utf8_lossy(&r.name).into_owned(), Arc::new(r.data.clone()))), } @@ -1048,13 +1052,31 @@ pub(crate) fn psd_to_document_decoded( { let first = cc + usize::from(file.merged_has_alpha()); let names = file.resource(1045).map(|r| unicode_names(&r.data)).unwrap_or_default(); + let extra_n = usize::from(h.channels).saturating_sub(first); // Photoshop lists every extra channel, the merged transparency first when there is one. let skip = usize::from(file.merged_has_alpha() && names.len() == usize::from(h.channels).saturating_sub(cc)); - let names = names.get(skip..).unwrap_or_default(); + let names = names.get(skip..).unwrap_or(&[]); + // Spot planes are ink-inverted in the file (0 = solid). Alpha planes are not. + // DisplayInfo lists the transparency record first when `skip` is 1. + let spots = { + let n = extra_n.saturating_add(skip); + let all = if let Some(r) = file.resource(crate::channel_map::DISPLAY_INFO) { + crate::channel_map::spot_flags(&r.data, true, n) + } else if let Some(r) = file.resource(crate::channel_map::DISPLAY_INFO_OLD) { + crate::channel_map::spot_flags(&r.data, false, n) + } else { + vec![false; n] + }; + all.into_iter().skip(skip).collect::>() + }; for (k, idx) in (first..usize::from(h.channels)).enumerate() { let Some(p) = merged_plane(all, idx, plane) else { break }; + let mut raw = be_to_ne_plane(p, depth, n); + if spots.get(k).copied().unwrap_or(false) { + crate::pixels::invert_plane(&mut raw, depth, false); + } let mut s = Surface::new(cx.mask_fmt); - s.write_interleaved(canvas, &be_to_ne_plane(p, depth, n)); + s.write_interleaved(canvas, &raw); s.prune(); let name = names.get(k).cloned().unwrap_or_else(|| format!("Alpha {}", k + 1)); doc.channels.push(AlphaChannel::new(name, s)); diff --git a/crates/io/src/tiff_layers.rs b/crates/io/src/tiff_layers.rs index 91011c6eb1..826c1557f7 100644 --- a/crates/io/src/tiff_layers.rs +++ b/crates/io/src/tiff_layers.rs @@ -11,11 +11,13 @@ use std::sync::Arc; use photocraft_codecs::{self as codecs, ChannelLayout, Format, Image, SampleType as CSample}; -use photocraft_color::ColorMode; -use photocraft_doc::Document; +use photocraft_color::{ColorMode, PixelFormat, SampleType}; +use photocraft_doc::{AlphaChannel, Document}; +use photocraft_geom::Rect; use photocraft_psd::resources::ids; use photocraft_psd::tiff::{ByteOrder, ImageSourceData, resources_from_bytes, resources_to_bytes}; use photocraft_psd::{ColorMode as PsdMode, Compression, Header, ImageData, ImageResource, ResolutionInfo}; +use photocraft_raster::Surface; use crate::flat::{csample, encode_image, image_to_document, layout_for, single_layer, try_buffer}; use crate::psd_export::PsdExportOptions; @@ -101,11 +103,31 @@ pub(crate) fn import_layered(name: &str, img: &Image, layers: &[u8]) -> Result 32, }; let (w, h) = img.dimensions(); - let channels = u16::try_from(img.layout().channels()).map_err(|_| IoError::Unsupported("too many channels".into()))?; + let mut data = planar_big_endian(&img, color_channels, mode == PsdMode::Cmyk)?; + let bps = img.sample_type().bytes(); + let plane_len = (w as usize).saturating_mul(h as usize).saturating_mul(bps); + let mut added = 0usize; + for e in img.meta.extra_samples.iter().take(codecs::MAX_EXTRA_SAMPLES) { + match native_plane_to_be(&e.data, bps) { + Ok(be) if be.len() == plane_len => { + data.extend(be); + added += 1; + } + _ => warnings.push("an extra TIFF sample did not match the image and was dropped".into()), + } + } + let channels = u16::try_from(img.layout().channels().saturating_add(added)).map_err(|_| IoError::Unsupported("too many channels".into()))?; let header = Header::new(isd.version, w, h, channels, depth, mode); - let data = planar_big_endian(&img, color_channels, mode == PsdMode::Cmyk)?; let image_data = ImageData { compression: Compression::Raw, data }; - let file = isd.into_psd(header, resources, image_data); + let mut file = isd.into_psd(header, resources, image_data); + // Empty `Patt` and the default filter mask are written so Photoshop's block list matches + // a file it saved. They carry nothing the document stores, so they are not kept: a + // round trip would otherwise grow `metadata.psd_global_blocks` on every open. + file.global_blocks.retain(|b| { + let empty_pattern = matches!(&b.key, b"Patt" | b"Pat2" | b"Pat3") && b.data.is_empty(); + let default_filter_mask = &b.key == b"FMsk" && b.data.as_slice() == FILTER_MASK_DEFAULT; + !empty_pattern && !default_filter_mask + }); // The same nesting limit as opening a PSD (#2940). crate::psd_import::check_group_depth(&file)?; let (mut doc, w) = psd_to_document(&file); @@ -200,19 +222,24 @@ pub(crate) fn export_layered(doc: &Document, opts: &ExportOptions, ctl: &photocr } let mut warnings = Vec::new(); let big = doc.size.width > 30_000 || doc.size.height > 30_000; - // The PSD exporter renders the composite we need for the TIFF itself: unmatted (the TIFF - // keeps straight alpha) and uncompressed (its planes are interleaved below). + // The PSD exporter renders the composite we need for the TIFF itself, uncompressed (its + // planes are interleaved below). A spot (or any user channel) is saved the way Photoshop's + // TIFF dialog does with "Save Transparency" off: the composite is colour plus those + // channels, matted on white, and each layer keeps its own transparency. With no user + // channel the composite stays unmatted, straight RGBA, which is what a plain transparent + // TIFF already round-trips as. // Layer data is written PSD-style ("Adobe Photoshop Document Data Block", 4-byte lengths), as // Photoshop writes it: Photoshop does not read the PSB-style header ("... Data V0002") in a // TIFF and opens only the composite, as one locked Background. The exporter's size estimate // counts layer planes uncompressed, so a document with many canvas-sized layers passes 2 GB // while its real layer data is a small fraction of that; it is not used here. PSB-style data // is written only past 30000 px, when asked for, or when a length really overflows 32 bits. + let user_channels = !doc.channels.is_empty() || doc.quick_mask.is_some(); let force_psb = opts.force_psb || big; let psd_opts = PsdExportOptions { force_psb, size_limit_psb: false, - merged_matte: false, + merged_matte: user_channels, merged_compression: Compression::Raw, maximize_compatibility: true, document_path: opts.document_path.clone(), @@ -232,7 +259,7 @@ pub(crate) fn export_layered(doc: &Document, opts: &ExportOptions, ctl: &photocr ctl.check().map_err(|_| IoError::Cancelled)?; warnings.extend(w); let order = if codecs::tiff_writes_little_endian() { ByteOrder::Little } else { ByteOrder::Big }; - let (layers, w) = match ImageSourceData::from_psd(&file).to_bytes(order) { + let (layers, w) = match tiff_image_source(doc, &file).to_bytes(order) { Err(photocraft_psd::PsdError::LimitExceeded(_)) if !force_psb => { let psb_opts = PsdExportOptions { force_psb: true, ..psd_opts }; let (psb, w) = crate::with_span(ctl, 0.0, TIFF_MODEL_DONE, |ctl| crate::psd_export::document_to_psd_interruptible(doc, &psb_opts, ctl)); @@ -240,7 +267,7 @@ pub(crate) fn export_layered(doc: &Document, opts: &ExportOptions, ctl: &photocr warnings.extend(w); warnings.push("layer data exceeds 4 GB; written with PSB-sized lengths, which some readers do not open".into()); file = psb; - ImageSourceData::from_psd(&file).to_bytes(order)? + tiff_image_source(doc, &file).to_bytes(order)? } r => r?, }; @@ -250,24 +277,58 @@ pub(crate) fn export_layered(doc: &Document, opts: &ExportOptions, ctl: &photocr // The profile and XMP are written as TIFF tags, not as resources. EXIF stays a resource // (1058), which the PSD importer reads back unchanged; a block rebuilt from the TIFF's own // Exif directory keeps only the Exif, GPS and descriptive tags. - let resources: Vec = file.resources.iter().filter(|r| !matches!(r.id, ids::ICC_PROFILE | ids::XMP)).cloned().collect(); - let resources = resources_to_bytes(&resources)?; + let mut resources: Vec = file.resources.iter().filter(|r| !matches!(r.id, ids::ICC_PROFILE | ids::XMP)).cloned().collect(); let fmt = doc.pixel_format(); let cc = fmt.mode.color_channels(); let has_alpha = file.layer_info.as_ref().is_some_and(|l| l.merged_alpha); let channels = cc + usize::from(has_alpha); - let extra = usize::from(file.header.channels).saturating_sub(channels); - if extra > 0 { - warnings.push(format!("{extra} alpha channel(s) are not written to TIFF (one transparency channel only)")); + let extra_n = usize::from(file.header.channels).saturating_sub(channels); + let kept = extra_n.min(codecs::MAX_EXTRA_SAMPLES); + if extra_n > kept { + warnings.push(format!("{extra_n} extra channels; TIFF keeps the first {kept}")); } + // With spot or alpha channels, the IFD image is colour + those channels. The merged + // transparency plane stays out of the IFD (see above); a file with no extra channels keeps + // it, so a plain transparent TIFF still opens with alpha. + let write_alpha = has_alpha && kept == 0; + // One identifier per extra sample actually stored, replacing any preserved 1053 whose count + // described the PSD merged image (which still included transparency). + if kept > 0 { + resources.retain(|r| r.id != crate::channel_map::ALPHA_IDENTIFIERS); + // Photoshop's spot TIFF (RGB, Save Transparency off) stores identifier 3: the spot's + // index among the IFD samples, not a 1-based count of user channels. + let first = u32::try_from(cc.saturating_add(usize::from(write_alpha))).unwrap_or(u32::MAX); + resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers_from(first, kept))); + } + // Resource 1022 names a channel of the PSD merged image, which counts the transparency plane. + // The IFD below does not, so the id moves back by one. + if has_alpha + && kept > 0 + && let Some(r) = resources.iter_mut().find(|r| r.id == crate::channel_map::QUICK_MASK_INFO) + && r.data.len() >= 2 + { + let id = u16::from_be_bytes([r.data[0], r.data[1]]).saturating_sub(1); + let be = id.to_be_bytes(); + r.data[0] = be[0]; + r.data[1] = be[1]; + } + // The name and DisplayInfo resources list the merged transparency plane first. The IFD + // leaves that plane out, so the resources must too: Photoshop pairs each name with the + // next sample past the colour channels. + if has_alpha && !write_alpha { + drop_merged_transparency(&mut resources); + } + let resources = resources_to_bytes(&resources)?; + let ifd_channels = cc + usize::from(write_alpha); let sample = csample(fmt.sample); let (w, h) = (doc.size.width, doc.size.height); let cmyk = fmt.mode == ColorMode::Cmyk; - let data = interleave(&file.image_data.data, w, h, channels, cc, sample, cmyk)?; + let data = interleave(&file.image_data.data, w, h, ifd_channels, cc, sample, cmyk)?; + let extras = native_extra_planes(&file.image_data.data, w, h, channels, kept, sample)?; ctl.check().map_err(|_| IoError::Cancelled)?; ctl.progress(TIFF_COMPOSITE_DONE); - let layout = layout_for(fmt.mode, has_alpha); + let layout = layout_for(fmt.mode, write_alpha); let mut img = Image::from_raw(w, h, layout, sample, data)?; img.icc = doc.icc_profile.as_ref().map(|i| i.to_vec()); img.meta = codecs::Metadata { @@ -280,11 +341,133 @@ pub(crate) fn export_layered(doc: &Document, opts: &ExportOptions, ctl: &photocr dpi: Some((doc.resolution_dpi, doc.resolution_dpi)), photoshop_resources: Some(resources), photoshop_layers: Some(layers), + extra_samples: extras, ..Default::default() }; encode_image(&img, Format::Tiff, opts, warnings) } +/// The layer data (`ImageSourceData`) of a layered TIFF saved from `file`, adjusted the way +/// Photoshop writes it. +fn tiff_image_source(doc: &Document, file: &photocraft_psd::PsdFile) -> ImageSourceData { + // Photoshop pairs alpha-name resources with samples past the colour channels and ignores + // the ExtraSamples kind. The merged transparency must not occupy that first slot when a + // spot is also stored. Layer transparency stays in each layer's channel −1. + let mut isd = ImageSourceData::from_psd(file); + let spot_extras = file.header.channels as usize > { + let cc = doc.pixel_format().mode.color_channels(); + let alpha = file.layer_info.as_ref().is_some_and(|l| l.merged_alpha); + cc + usize::from(alpha) + }; + // Positive layer count: the merged image's first extra sample is not transparency + // (Photoshop's own spot TIFF does this; a negative count would claim the spot plane is alpha). + if spot_extras && let Some(info) = &mut isd.layer_info { + info.merged_alpha = false; + } + // A merged-transparency marker kept from an opened file (Photoshop's `MTrn`) would make the + // first spot read back as transparency: keep it only while the composite keeps that sample. + if spot_extras || !file.layer_info.as_ref().is_some_and(|l| l.merged_alpha) { + isd.global_blocks.retain(|b| !b.is_merged_transparency_marker()); + } + if let Some(info) = &mut isd.layer_info { + for layer in &mut info.layers { + photoshop_layer_blocks(&mut layer.blocks); + } + } + // Photoshop reads a fixed 14-byte user-mask record from `LMsk` and an empty `Patt` + // before the filter mask. A zero-length `LMsk` is what makes it report that the + // layer data could not be read. + if let Some(mask) = &mut isd.global_layer_mask + && mask.data.len() < 14 + { + *mask = photocraft_psd::GlobalLayerMask::photoshop_default(); + } + if !isd.global_blocks.iter().any(|b| matches!(&b.key, b"Patt" | b"Pat2" | b"Pat3")) { + isd.global_blocks.insert(0, photocraft_psd::TaggedBlock::new(*b"Patt", Vec::new())); + } + if !isd.global_blocks.iter().any(|b| &b.key == b"FMsk") { + isd.global_blocks.push(photocraft_psd::TaggedBlock::new(*b"FMsk", FILTER_MASK_DEFAULT.to_vec())); + } + isd +} + +/// Removes the leading transparency entry from the channel-name resources (1006, 1045) and +/// from DisplayInfo (1077). Each is left unchanged when it is too short to hold that entry. +fn drop_merged_transparency(resources: &mut [ImageResource]) { + for r in resources { + r.data = match r.id { + 1006 => drop_first_pascal(&r.data), + 1045 => drop_first_unicode(&r.data), + id if id == crate::channel_map::DISPLAY_INFO => drop_first_display_record(&r.data), + _ => continue, + }; + } +} + +fn drop_first_pascal(data: &[u8]) -> Vec { + let Some(&n) = data.first() else { return data.to_vec() }; + let end = 1usize.saturating_add(usize::from(n)); + data.get(end..).unwrap_or(data).to_vec() +} + +fn drop_first_unicode(data: &[u8]) -> Vec { + let Some(nbe) = data.get(..4) else { return data.to_vec() }; + let n = u32::from_be_bytes([nbe[0], nbe[1], nbe[2], nbe[3]]) as usize; + let end = 4usize.saturating_add(n.saturating_mul(2)); + data.get(end..).unwrap_or(data).to_vec() +} + +/// Resource 1077: a 4-byte version, then 13-byte records. Drops the first record. +fn drop_first_display_record(data: &[u8]) -> Vec { + const RECORD: usize = 13; + if data.len() < 4 + RECORD { + return data.to_vec(); + } + let mut out = Vec::with_capacity(data.len() - RECORD); + out.extend_from_slice(&data[..4]); + out.extend_from_slice(&data[4 + RECORD..]); + out +} + +/// Filter-mask block (`FMsk`) Photoshop writes next to a layered TIFF: the same red 50% +/// overlay as [`photocraft_psd::GlobalLayerMask::photoshop_default`], without the kind byte. +const FILTER_MASK_DEFAULT: &[u8] = &[0, 0, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 50]; + +/// Blocks Photoshop writes on every layer of a layered TIFF, when the layer does not +/// already carry them. Defaults match a plain pixel layer (clipped-as-group on, nothing +/// locked, no label). +fn photoshop_layer_blocks(blocks: &mut Vec) { + let has = |k: &[u8; 4]| blocks.iter().any(|b| &b.key == k); + let mut add = Vec::new(); + if !has(b"lnsr") { + add.push(photocraft_psd::TaggedBlock::name_source(*b"layr")); + } + if !has(b"clbl") { + add.push(photocraft_psd::TaggedBlock::blend_clipped_as_group(true)); + } + if !has(b"infx") { + add.push(photocraft_psd::TaggedBlock::blend_interior_elements(false)); + } + if !has(b"knko") { + add.push(photocraft_psd::TaggedBlock::knockout(0)); + } + if !has(b"lspf") { + add.push(photocraft_psd::TaggedBlock::protection(0)); + } + if !has(b"lclr") { + add.push(photocraft_psd::TaggedBlock::sheet_color(0)); + } + let at = blocks + .iter() + .position(|b| &b.key == b"lyid") + .map(|i| i + 1) + .or_else(|| blocks.iter().position(|b| &b.key == b"luni").map(|i| i + 1)) + .unwrap_or(blocks.len()); + for (i, block) in add.into_iter().enumerate() { + blocks.insert(at.saturating_add(i), block); + } +} + /// Removes the blocks a document kept verbatim from a little-endian TIFF because their layout /// is unknown ([`photocraft_psd::TaggedBlock::is_foreign_order`]) before `file` is written as a /// PSD: their bytes are in the wrong order for a PSD and cannot be converted. Returns a warning @@ -314,6 +497,421 @@ pub fn strip_foreign_order_blocks(file: &mut photocraft_psd::PsdFile) -> Vec Result, IoError> { + if bps == 1 { + return Ok(src.to_vec()); + } + if !matches!(bps, 2 | 4) || !src.len().is_multiple_of(bps) { + return Err(IoError::Unsupported("an extra channel plane is incomplete".into())); + } + let mut out = Vec::with_capacity(src.len()); + for c in src.chunks_exact(bps) { + match (bps, to_be, c) { + (2, true, [a, b]) => { + let v = u16::from_ne_bytes([*a, *b]); + out.extend_from_slice(&v.to_be_bytes()); + } + (2, false, [a, b]) => { + let v = u16::from_be_bytes([*a, *b]); + out.extend_from_slice(&v.to_ne_bytes()); + } + (4, true, [a, b, c, d]) => { + let v = f32::from_ne_bytes([*a, *b, *c, *d]); + out.extend_from_slice(&v.to_be_bytes()); + } + (4, false, [a, b, c, d]) => { + let v = f32::from_be_bytes([*a, *b, *c, *d]); + out.extend_from_slice(&v.to_ne_bytes()); + } + _ => return Err(IoError::Unsupported("an extra channel plane is incomplete".into())), + } + } + Ok(out) +} + +/// Native-endian extra-sample plane → big-endian, for the PSD merged image a layered TIFF rebuilds. +fn native_plane_to_be(src: &[u8], bps: usize) -> Result, IoError> { + swap_plane(src, bps, true) +} + +/// Extra planes of a PSD merged image (`skip` colour-and-alpha planes already consumed), as +/// native-endian TIFF extra samples. A spot plane is already Photoshop ink (0 = solid, max = +/// paper); an alpha plane is already straight. Neither is inverted again here. +fn native_extra_planes(planes: &[u8], w: u32, h: u32, skip: usize, count: usize, sample: CSample) -> Result, IoError> { + let bps = sample.bytes(); + let n = (w as usize).checked_mul(h as usize).ok_or_else(|| IoError::Unsupported("image size overflows".into()))?; + let plane = n.checked_mul(bps).ok_or_else(|| IoError::Unsupported("image size overflows".into()))?; + let mut out = Vec::with_capacity(count); + for i in 0..count { + let at = skip.checked_add(i).and_then(|k| k.checked_mul(plane)).ok_or_else(|| IoError::Unsupported("image size overflows".into()))?; + let Some(src) = planes.get(at..at.saturating_add(plane)) else { + return Err(IoError::Unsupported("the merged image is missing an extra channel".into())); + }; + if src.len() != plane { + return Err(IoError::Unsupported("the merged image is missing an extra channel".into())); + } + out.push(codecs::ExtraSample { kind: 0, data: swap_plane(src, bps, false)? }); + } + Ok(out) +} + +/// One grayscale channel as native-endian samples in `img`'s sample type. +fn channel_plane(channel: &AlphaChannel, canvas: Rect, sample: CSample) -> Result, String> { + let depth = match sample { + CSample::U8 => SampleType::U8, + CSample::U16 => SampleType::U16, + CSample::F16 | CSample::F32 => SampleType::F32, + }; + let fmt = PixelFormat::new(ColorMode::Grayscale, depth, false); + let owned; + let surface = if channel.surface.format() == fmt { + &channel.surface + } else { + owned = channel.surface.convert(fmt); + &owned + }; + let mut bytes = surface.to_interleaved(canvas); + let n = (canvas.width() as usize).saturating_mul(canvas.height() as usize); + let expect = n.saturating_mul(depth.bytes()); + if bytes.len() != expect { + return Err(format!("channel \"{}\" does not cover the canvas", channel.name)); + } + // Document density is 1 = solid ink. Photoshop's TIFF stores the opposite for a spot. + if channel.spot.is_some() { + crate::pixels::invert_plane(&mut bytes, depth, false); + } + if sample == CSample::F16 { + let mut out = Vec::with_capacity(n.saturating_mul(2)); + for arr in bytes.as_chunks::<4>().0 { + let v = f32::from_ne_bytes(*arr); + out.extend_from_slice(&codecs::f16::from_f32(v).to_ne_bytes()); + } + return Ok(out); + } + Ok(bytes) +} + +/// Composites straight alpha over white and drops it. Photoshop's TIFF save with +/// "Save Transparency" off stores that matte in the colour samples and keeps transparency +/// only inside each layer. Fully opaque pixels are copied unchanged, so they stay identical +/// to a composite that was quantized before the matte. `false` when there is no alpha or +/// the buffer is not one sample per channel. +fn matte_and_drop_alpha(img: &mut Image) -> bool { + if !img.layout().has_alpha() { + return false; + } + let (w, h) = img.dimensions(); + let sample = img.sample_type(); + let dst = img.layout().without_alpha(); + let bps = sample.bytes(); + let keep = dst.channels().saturating_mul(bps); + let stride = img.layout().channels().saturating_mul(bps); + if stride == 0 || keep == 0 || bps == 0 || stride <= keep || !img.data().len().is_multiple_of(stride) { + return false; + } + let cmyk = img.layout().is_cmyk(); + let white_byte: u8 = if cmyk { 0 } else { 255 }; + let white_u16: u16 = if cmyk { 0 } else { u16::MAX }; + let white_f: f32 = if cmyk { 0.0 } else { 1.0 }; + // Lab's white is L* 100 with a* and b* 0, which PhotoCraft holds mid-range (`(0 + 128) / 255`). + let lab = img.layout().is_lab(); + let mut out = Vec::with_capacity(img.data().len() / stride * keep); + for px in img.data().chunks_exact(stride) { + let Some(color) = px.get(..keep) else { return false }; + let Some(alpha) = px.get(keep..keep.saturating_add(bps)) else { return false }; + let ok = if lab { + let (Some(l), Some(ab)) = (color.get(..bps), color.get(bps..)) else { return false }; + matte_pixel(sample, l, alpha, white_byte, white_u16, white_f, &mut out) && matte_pixel(sample, ab, alpha, 128, 128 * 257, 128.0 / 255.0, &mut out) + } else { + matte_pixel(sample, color, alpha, white_byte, white_u16, white_f, &mut out) + }; + if !ok { + return false; + } + } + let icc = img.icc.clone(); + let meta = img.meta.clone(); + let warnings = img.warnings.clone(); + let Ok(mut next) = Image::from_raw(w, h, dst, sample, out) else { return false }; + next.icc = icc; + next.meta = meta; + next.warnings = warnings; + *img = next; + true +} + +/// One pixel of [`matte_and_drop_alpha`]. Opaque samples are copied; a clear pixel becomes +/// `white`; anything in between is `c·a + white·(1−a)` in normalized space. +fn matte_pixel(sample: CSample, color: &[u8], alpha: &[u8], white_byte: u8, white_u16: u16, white_f: f32, out: &mut Vec) -> bool { + match sample { + CSample::U8 => { + let Some(&a) = alpha.first() else { return false }; + if a == 255 { + out.extend_from_slice(color); + } else if a == 0 { + out.resize(out.len().saturating_add(color.len()), white_byte); + } else { + let af = f32::from(a) / 255.0; + for &c in color { + let m = crate::pixels::matte(f32::from(c) / 255.0, af, white_f); + out.push((m.clamp(0.0, 1.0) * 255.0).round() as u8); + } + } + } + CSample::U16 => { + let Some(a) = ne_u16(alpha) else { return false }; + if a == u16::MAX { + out.extend_from_slice(color); + } else if a == 0 { + for _ in 0..color.len() / 2 { + out.extend_from_slice(&white_u16.to_ne_bytes()); + } + } else { + let af = f32::from(a) / 65535.0; + for pair in color.as_chunks::<2>().0 { + let c = u16::from_ne_bytes(*pair); + let m = crate::pixels::matte(f32::from(c) / 65535.0, af, white_f); + out.extend_from_slice(&((m.clamp(0.0, 1.0) * 65535.0).round() as u16).to_ne_bytes()); + } + } + } + CSample::F32 => { + let Some(a) = ne_f32(alpha) else { return false }; + if a == 1.0 { + out.extend_from_slice(color); + } else if a == 0.0 || !a.is_finite() { + for _ in 0..color.len() / 4 { + out.extend_from_slice(&white_f.to_ne_bytes()); + } + } else { + let af = a.clamp(0.0, 1.0); + for quad in color.as_chunks::<4>().0 { + let m = crate::pixels::matte(f32::from_ne_bytes(*quad), af, white_f); + out.extend_from_slice(&m.to_ne_bytes()); + } + } + } + CSample::F16 => { + let Some(bits) = ne_u16(alpha) else { return false }; + let a = codecs::f16::from_bits(bits).to_f32(); + if a == 1.0 { + out.extend_from_slice(color); + } else if a == 0.0 || !a.is_finite() { + let w = codecs::f16::from_f32(white_f).to_bits().to_ne_bytes(); + for _ in 0..color.len() / 2 { + out.extend_from_slice(&w); + } + } else { + let af = a.clamp(0.0, 1.0); + for pair in color.as_chunks::<2>().0 { + let c = codecs::f16::from_bits(u16::from_ne_bytes(*pair)).to_f32(); + let m = codecs::f16::from_f32(crate::pixels::matte(c, af, white_f)).to_bits(); + out.extend_from_slice(&m.to_ne_bytes()); + } + } + } + } + true +} + +fn ne_u16(b: &[u8]) -> Option { + let arr: [u8; 2] = b.get(..2)?.try_into().ok()?; + Some(u16::from_ne_bytes(arr)) +} + +fn ne_f32(b: &[u8]) -> Option { + let arr: [u8; 4] = b.get(..4)?.try_into().ok()?; + Some(f32::from_ne_bytes(arr)) +} + +/// Writes alpha and spot channels (and a Quick Mask) into a flat TIFF: extra samples in the +/// IFD, plus Photoshop resources for the name, ink colour and solidity. At most +/// [`codecs::MAX_EXTRA_SAMPLES`] are kept. A TIFF with no extra channels is left unchanged. +/// When any are written, the composite's own transparency is left out of the IFD: readers pair +/// the channel resources with every sample past the colour channels, in order. +pub(crate) fn stamp_flat_channels(doc: &Document, img: &mut Image) -> Vec { + let total = doc.channels.len().saturating_add(usize::from(doc.quick_mask.is_some())); + if total == 0 { + return Vec::new(); + } + let mut warnings = Vec::new(); + let (w, h) = img.dimensions(); + if w != doc.size.width || h != doc.size.height { + warnings.push("extra channels were not written: the image size differs from the document".into()); + return warnings; + } + let max = codecs::MAX_EXTRA_SAMPLES; + let mut picked: Vec<&AlphaChannel> = doc.channels.iter().take(max).collect(); + if let Some(q) = &doc.quick_mask + && picked.len() < max + { + picked.push(q); + } + if total > picked.len() { + warnings.push(format!("{total} extra channels; TIFF keeps the first {}", picked.len())); + } + let canvas = Rect::new(0, 0, w as i32, h as i32); + let mut planes = Vec::with_capacity(picked.len()); + for ch in &picked { + match channel_plane(ch, canvas, img.sample_type()) { + Ok(data) => planes.push(data), + Err(msg) => { + warnings.push(msg); + break; + } + } + } + picked.truncate(planes.len()); + if picked.is_empty() { + return warnings; + } + let names: Vec<&str> = picked.iter().map(|c| c.name.as_str()).collect(); + let quick_last = matches!((picked.last(), doc.quick_mask.as_ref()), (Some(p), Some(q)) if std::ptr::eq(*p, q)); + let color_channels = img.layout().color_channels(); + // Save Transparency off: the colour samples are the composite over white, and the + // alpha plane is not an extra sample (it would be named as the first spot). The + // composite transparency is gone after this; say so, because the user did not pick + // that option themselves. + if img.layout().has_alpha() { + if !matte_and_drop_alpha(img) { + warnings.push("extra channels were not written: the composite transparency could not be separated from them".into()); + return warnings; + } + warnings.push( + "transparency composited over white; a TIFF with alpha or spot channels stores them as extra samples and drops image transparency (Save Transparency off)" + .into(), + ); + } + let quick_id = if quick_last { u16::try_from(color_channels.saturating_add(picked.len()).saturating_sub(1)).ok() } else { None }; + let first_id = u32::try_from(color_channels).unwrap_or(u32::MAX); + match channel_resources(img.meta.photoshop_resources.as_deref(), &names, &picked, quick_id, first_id) { + Ok(bytes) => img.meta.photoshop_resources = Some(bytes), + Err(e) => warnings.push(format!("spot channel options were not written to the TIFF: {e}")), + } + img.meta.extra_samples = planes.into_iter().map(|data| codecs::ExtraSample { kind: 0, data }).collect(); + warnings +} + +/// Existing Photoshop resources with the channel-name, display-info and quick-mask blocks replaced. +fn channel_resources(existing: Option<&[u8]>, names: &[&str], channels: &[&AlphaChannel], quick_id: Option, first_id: u32) -> Result, IoError> { + let mut resources = match existing.filter(|b| !b.is_empty()) { + Some(b) => resources_from_bytes(b)?.0, + None => Vec::new(), + }; + resources.retain(|r| { + !matches!(r.id, 1006 | 1045 | crate::channel_map::DISPLAY_INFO | crate::channel_map::QUICK_MASK_INFO | crate::channel_map::ALPHA_IDENTIFIERS) + }); + resources.push(ImageResource::new(1006, crate::psd_export::pascal_names_resource(names))); + resources.push(ImageResource::new(1045, crate::psd_export::unicode_names_resource(names))); + resources.push(ImageResource::new(crate::channel_map::DISPLAY_INFO, crate::channel_map::display_info(channels, false))); + resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers_from(first_id, names.len()))); + if let Some(id) = quick_id { + let mut data = id.to_be_bytes().to_vec(); + data.push(0); + resources.push(ImageResource::new(crate::channel_map::QUICK_MASK_INFO, data)); + } + Ok(resources_to_bytes(&resources)?) +} + +/// Extra samples of a flat TIFF become alpha / spot channels. Layered TIFFs rebuild those +/// through the PSD importer instead, so this is only for a file with no layer tag. +pub(crate) fn channels_from_extras(doc: &mut Document, img: &Image) -> Vec { + if img.meta.extra_samples.is_empty() { + return Vec::new(); + } + let mut warnings = Vec::new(); + let (w, h) = img.dimensions(); + if w != doc.size.width || h != doc.size.height { + warnings.push("extra TIFF samples were dropped: their size differs from the image".into()); + return warnings; + } + let parsed = img.meta.photoshop_resources.as_deref().filter(|b| !b.is_empty()).and_then(|b| resources_from_bytes(b).ok()); + let none = Vec::new(); + let resources = parsed.as_ref().map(|(r, _)| r.as_slice()).unwrap_or(&none); + let all_names = resources.iter().find(|r| r.id == 1045).map(|r| crate::psd_import::unicode_names(&r.data)).unwrap_or_default(); + // As in the PSD importer: Photoshop lists the image transparency first ("Transparency", with + // its own display record), ahead of the channels the extra samples hold. + let skip = usize::from(img.layout().has_alpha() && all_names.len() == img.meta.extra_samples.len().saturating_add(1)); + let names = all_names.get(skip..).unwrap_or_default(); + let kept = img.meta.extra_samples.len().min(codecs::MAX_EXTRA_SAMPLES); + let spots = if let Some(r) = resources.iter().find(|r| r.id == crate::channel_map::DISPLAY_INFO) { + crate::channel_map::spot_flags(&r.data, true, kept.saturating_add(skip)).split_off(skip) + } else if let Some(r) = resources.iter().find(|r| r.id == crate::channel_map::DISPLAY_INFO_OLD) { + crate::channel_map::spot_flags(&r.data, false, kept.saturating_add(skip)).split_off(skip) + } else { + vec![false; kept] + }; + let start = doc.channels.len(); + let n_px = (w as usize).saturating_mul(h as usize); + for (k, e) in img.meta.extra_samples.iter().take(codecs::MAX_EXTRA_SAMPLES).enumerate() { + let invert = spots.get(k).copied().unwrap_or(false); + match mask_from_plane(&e.data, w, h, n_px, img.sample_type(), doc.depth, invert) { + Ok(surface) => { + let name = names.get(k).cloned().filter(|s| !s.is_empty()).unwrap_or_else(|| format!("Alpha {}", k + 1)); + doc.channels.push(AlphaChannel::new(name, surface)); + } + Err(msg) => warnings.push(msg), + } + } + if doc.channels.len() == start { + return warnings; + } + { + let slice = &mut doc.channels[start..]; + if let Some(r) = resources.iter().find(|r| r.id == crate::channel_map::DISPLAY_INFO) { + crate::channel_map::apply_display_info(&r.data, true, skip, slice); + } else if let Some(r) = resources.iter().find(|r| r.id == crate::channel_map::DISPLAY_INFO_OLD) { + crate::channel_map::apply_display_info(&r.data, false, skip, slice); + } + } + let first = img.layout().color_channels().saturating_add(usize::from(img.layout().has_alpha())); + if let Some(r) = resources.iter().find(|r| r.id == crate::channel_map::QUICK_MASK_INFO) + && r.data.len() >= 2 + && let Some(k) = usize::from(u16::from_be_bytes([r.data[0], r.data[1]])).checked_sub(first) + && start.saturating_add(k) < doc.channels.len() + { + doc.quick_mask = Some(doc.channels.remove(start + k)); + } + warnings +} + +/// Native-endian extra-sample bytes → a grayscale surface at the document depth. +/// `invert` turns Photoshop spot ink (0 = solid) into document density (1 = solid). +fn mask_from_plane(data: &[u8], w: u32, h: u32, n: usize, from: CSample, depth: SampleType, invert: bool) -> Result { + let rect = Rect::new(0, 0, w as i32, h as i32); + let mut bytes = match (from, depth) { + (CSample::U8, SampleType::U8) | (CSample::U16, SampleType::U16) | (CSample::F32, SampleType::F32) => { + if data.len() != n.saturating_mul(from.bytes()) { + return Err("an extra TIFF sample did not match the image and was dropped".into()); + } + data.to_vec() + } + (CSample::F16, SampleType::F32) => { + if data.len() != n.saturating_mul(2) { + return Err("an extra TIFF sample did not match the image and was dropped".into()); + } + let mut out = Vec::with_capacity(n.saturating_mul(4)); + for arr in data.as_chunks::<2>().0 { + let v = codecs::f16::from_bits(u16::from_ne_bytes(*arr)).to_f32(); + out.extend_from_slice(&v.to_ne_bytes()); + } + out + } + _ => return Err(format!("an extra TIFF sample ({from:?}) does not match the document depth and was dropped")), + }; + if invert { + crate::pixels::invert_plane(&mut bytes, depth, false); + } + if bytes.len() != n.saturating_mul(depth.bytes()) { + return Err("an extra TIFF sample did not match the image and was dropped".into()); + } + let mut s = Surface::new(PixelFormat::new(ColorMode::Grayscale, depth, false)); + s.write_interleaved(rect, &bytes); + s.prune(); + Ok(s) +} + #[cfg(test)] mod tests { use photocraft_doc::{Color, Document, Fill, FillCache, Layer, LayerContent}; diff --git a/crates/io/tests/tiff_layers.rs b/crates/io/tests/tiff_layers.rs index 4cf78aca68..f19ccff7dc 100644 --- a/crates/io/tests/tiff_layers.rs +++ b/crates/io/tests/tiff_layers.rs @@ -34,19 +34,18 @@ fn roundtrip(doc: &Document) -> Document { // The TIFF is a plain image to any other reader: the composite at the document's size. let flat = photocraft_codecs::decode(&r.bytes).expect("flat decode"); assert_eq!(flat.dimensions(), (doc.size.width, doc.size.height)); - // A TIFF holds one transparency channel: extra alpha channels (and a Quick Mask) are not - // kept, and the export says so. + // Extra alpha channels and a Quick Mask travel as TIFF extra samples (at most MAX_EXTRA_SAMPLES). let extra = doc.channels.len() + usize::from(doc.quick_mask.is_some()); - assert_eq!(r.warnings.iter().any(|w| w.contains("alpha channel(s) are not written")), extra > 0, "{:?}", r.warnings); + assert!(!r.warnings.iter().any(|w| w.contains("not written")), "{:?}", r.warnings); + if extra > 0 && extra <= photocraft_codecs::MAX_EXTRA_SAMPLES { + assert_eq!(flat.meta.extra_samples.len(), extra, "{:?}", r.warnings); + } import("x.tif", &r.bytes).expect("import").document } -/// `doc` as a layered TIFF round trip returns it: without extra alpha channels or a Quick Mask. +/// `doc` as a layered TIFF round trip returns it, including extra channels. fn expected(doc: &Document) -> Document { - let mut d = doc.clone(); - d.channels.clear(); - d.quick_mask = None; - d + doc.clone() } macro_rules! rt_case { @@ -302,12 +301,11 @@ fn psdtags_fixtures_open_with_their_layers() { // tifffile writes a Software tag; nothing else is worth a warning. assert!(r.warnings.iter().all(|w| w.contains("text metadata")), "{name}: {:?}", r.warnings); // psdtags wrote the composite's alpha sample without the transparency flag, so by the - // PSD rules it is an alpha channel (which a re-save cannot keep). Re-saving keeps - // everything else; the file is then in the encoder's byte order. + // PSD rules it is an alpha channel. A re-save keeps it as a TIFF extra sample. assert_eq!(d.channels.len(), 1, "{name}"); let out = tiff(d, true); let back = import(name, &out.bytes).unwrap().document; - assert_docs_eq(&expected(d), &back); + assert_docs_eq(d, &back); } } @@ -396,6 +394,592 @@ fn damaged_layer_data_opens_flattened() { } } +/// Every sample of a TIFF, read by the `tiff` crate rather than PhotoCraft's decoder. +/// +/// That decoder drops unspecified extra samples when the photometric interpretation is RGB, so +/// the file is retagged MinIsBlack first. The result is then a multiband image of every sample, +/// which is what libtiff's `TIFFReadScanline` returns and what a RIP walks. +fn independent_samples(bytes: &[u8]) -> (u16, Vec, Vec, u32, Vec) { + let mut tags = tiff::decoder::Decoder::new(std::io::Cursor::new(bytes)).expect("tiff tags"); + let spp: u16 = tags.get_tag_unsigned(tiff::tags::Tag::SamplesPerPixel).expect("spp"); + let bps = tags.get_tag_u16_vec(tiff::tags::Tag::BitsPerSample).expect("bps"); + let extra = tags.get_tag_u16_vec(tiff::tags::Tag::ExtraSamples).unwrap_or_default(); + let rows = tags.find_tag_unsigned::(tiff::tags::Tag::RowsPerStrip).ok().flatten().unwrap_or(0); + let patched = photometric_min_is_black(bytes); + let mut dec = tiff::decoder::Decoder::new(std::io::Cursor::new(patched.as_slice())).expect("tiff decode"); + let tiff::decoder::DecodingResult::U8(samples) = dec.read_image().expect("read image") else { + panic!("expected 8-bit samples"); + }; + (spp, bps, extra, rows, samples) +} + +/// Classic-TIFF photometric tag 262 → 1 (MinIsBlack), value stored inline in the IFD entry. +fn photometric_min_is_black(src: &[u8]) -> Vec { + let mut bytes = src.to_vec(); + let le = bytes.first().copied() == Some(b'I'); + let ru16 = |b: &[u8], i: usize| -> Option { + let s = b.get(i..i + 2)?; + Some(if le { u16::from_le_bytes([s[0], s[1]]) } else { u16::from_be_bytes([s[0], s[1]]) }) + }; + let ru32 = |b: &[u8], i: usize| -> Option { + let s = b.get(i..i + 4)?; + Some(if le { u32::from_le_bytes(s.try_into().ok()?) } else { u32::from_be_bytes(s.try_into().ok()?) }) + }; + let Some(ifd) = ru32(&bytes, 4) else { return bytes }; + let Some(n) = ru16(&bytes, ifd as usize) else { return bytes }; + for e in 0..n as usize { + let at = ifd as usize + 2 + e * 12; + if ru16(&bytes, at) == Some(262) { + let value = if le { 1u16.to_le_bytes() } else { 1u16.to_be_bytes() }; + if let Some(slot) = bytes.get_mut(at + 8..at + 10) { + slot.copy_from_slice(&value); + } + break; + } + } + bytes +} + +fn assert_plane(samples: &[u8], spp: usize, plane: usize, expected: &[u8]) { + assert_eq!(samples.len(), expected.len().saturating_mul(spp)); + let mut bad = 0usize; + let mut first = None; + for (i, want) in expected.iter().enumerate() { + let got = samples.get(i * spp + plane).copied(); + if got != Some(*want) { + bad += 1; + first.get_or_insert((i, got)); + } + } + assert_eq!(bad, 0, "{bad} mismatches, first {first:?}"); +} + +/// A multi-layer transparent document, large enough for several TIFF strips and several +/// raster tiles, with a spot whose every pixel is a known value. +#[test] +fn dtf_like_spot_is_written_in_full() { + use photocraft_color::{Color, PixelFormat}; + use photocraft_doc::{AlphaChannel, Layer}; + use photocraft_geom::{Rect, Size}; + use photocraft_psd::tiff::resources_from_bytes; + use photocraft_raster::Surface; + + let (w, h) = (900u32, 360u32); + let mut doc = Document::new("dtf", Size::new(w, h), ColorMode::Rgb, SampleType::U8); + let fmt = doc.pixel_format(); + let mut art = Surface::new(fmt); + let px = photocraft_raster::from_rgba(&fmt, [0.2, 0.5, 0.9, 1.0]); + art.fill_rect(Rect::new(30, 20, 870, 340), &px); + doc.layers.push(Layer::new("Art", LayerContent::Raster(art))); + let mut ink = Surface::new(fmt); + let px = photocraft_raster::from_rgba(&fmt, [0.9, 0.1, 0.2, 0.5]); + ink.fill_rect(Rect::new(80, 40, 700, 300), &px); + let mut layer = Layer::new("Ink", LayerContent::Raster(ink)); + layer.opacity = 0.8; + doc.layers.push(layer); + + let n = (w as usize) * (h as usize); + let mut spot_bytes = vec![0u8; n]; + for y in 0..h as usize { + for x in 0..w as usize { + spot_bytes[y * w as usize + x] = ((x * 3 + y * 17) % 251) as u8; + } + } + // Outside the artwork the composite is transparent, but the spot is not zero: a reader that + // binds "Spot Color 1" to the alpha plane fails here. + assert_eq!(spot_bytes[10 * w as usize + 10], 200); + let gray = PixelFormat::new(ColorMode::Grayscale, SampleType::U8, false); + let spot_surface = Surface::from_interleaved(gray, Rect::new(0, 0, w as i32, h as i32), &spot_bytes); + let mut channel = AlphaChannel::new("Spot Color 1", spot_surface); + channel.spot = Some((Color::rgb(1.0, 0.0, 0.0), 0.6)); + doc.channels.push(channel); + + let mut seen = Vec::new(); + for (name, layers) in [("flat", false), ("layered", true)] { + let opts = ExportOptions { tiff_layers: layers, ..ExportOptions::default() }; + let r = export(&doc, "dtf.tif", &opts).unwrap(); + assert!(!r.warnings.iter().any(|w| w.contains("not written")), "{name}: {:?}", r.warnings); + let img = photocraft_codecs::decode(&r.bytes).unwrap(); + assert!(!img.layout().has_alpha(), "{name}: {:?}", img.layout()); + assert_eq!(img.layout().color_channels(), 3, "{name}"); + assert_eq!(img.meta.extra_samples.len(), 1, "{name}"); + assert_eq!(img.meta.extra_samples[0].kind, 0, "{name}"); + // Photoshop stores spot ink inverted: document 255 (solid) is file 0. + let stored_spot: Vec = spot_bytes.iter().map(|b| 255 - b).collect(); + assert_eq!(img.meta.extra_samples[0].data, stored_spot, "{name} own decoder"); + + let (spp, bps, extra, rows, samples) = independent_samples(&r.bytes); + assert_eq!(spp, 4, "{name}"); + assert_eq!(bps, vec![8, 8, 8, 8], "{name}"); + assert_eq!(extra, vec![0], "{name} ExtraSamples"); + assert!(rows > 0 && rows < h, "{name} rows_per_strip {rows}"); + assert_plane(&samples, 4, 3, &stored_spot); + seen.push(samples.clone()); + + // Outside the artwork the composite is matted to white (Save Transparency off). The + // spot at that pixel is not zero, so a reader that binds the name to the alpha fails. + let at = (10 * w as usize + 10) * 4; + assert_eq!(&samples[at..at + 3], &[255, 255, 255], "{name} matted rgb"); + let (resources, layer_tag) = tags(&r.bytes); + let resources = resources.expect("photoshop resources"); + let (blocks, warnings) = resources_from_bytes(&resources).unwrap(); + assert!(warnings.is_empty(), "{name} {warnings:?}"); + let block = |id: u16| blocks.iter().find(|b| b.id == id).unwrap_or_else(|| panic!("{name} missing {id}")); + // "Spot Color 1" is 12 characters: Photoshop stores 13 bytes and pads the 8BIM block, not the string. + assert_eq!(block(1006).data, b"\x0cSpot Color 1", "{name}"); + assert_eq!(block(1045).data.len(), 30, "{name}"); + let info = &block(1077).data; + assert_eq!(info.len(), 17, "{name}"); + assert_eq!(u16::from_be_bytes([info[14], info[15]]), 60, "{name} solidity"); + assert_eq!(info[16], 2, "{name} spot kind"); + // RGB occupies samples 0..2, so the spot's identifier is 3. + assert_eq!(block(1053).data, 3u32.to_be_bytes(), "{name} channel id"); + + let back = import("dtf.tif", &r.bytes).unwrap().document; + assert_eq!(back.channels.len(), 1, "{name}"); + assert_eq!(back.channels[0].name, "Spot Color 1"); + let (ink, sol) = back.channels[0].spot.expect("spot"); + assert_eq!(ink.to_rgb(), [1.0, 0.0, 0.0], "{name}"); + assert!((sol - 0.6).abs() < 1e-4, "{name}"); + let area = Rect::new(0, 0, w as i32, h as i32); + assert_eq!(back.channels[0].surface.to_interleaved(area), spot_bytes, "{name} reimport"); + if layers { + let layer_tag = layer_tag.expect("layer tag"); + let (isd, w) = ImageSourceData::from_bytes(&layer_tag).unwrap(); + assert!(w.is_empty(), "{w:?}"); + let info = isd.layer_info.expect("layers"); + assert!(!info.merged_alpha, "{name}"); + assert!(info.layers.iter().all(|l| l.flags.0 & 0x08 != 0), "{name} photoshop flag"); + assert!(info.layers.iter().all(|l| l.blocks.iter().any(|b| &b.key == b"lnsr")), "{name} lnsr"); + let mask = isd.global_layer_mask.expect("LMsk"); + assert_eq!(mask.data.len(), 14, "{name}"); + assert_eq!(mask.opacity(), Some(50)); + assert_eq!(mask.kind(), Some(128)); + assert_photoshop_layered_tiff(&r.bytes, true); + assert_eq!(back.layers.len(), 2, "{name}"); + let ink = back.layers.iter().find(|l| l.name == "Ink").expect("ink layer"); + let px = ink.surface().expect("ink pixels").pixel(100, 100); + assert!((px[3] - 0.5).abs() < 0.02, "{name} layer alpha {px:?}"); + let outside = ink.surface().expect("ink pixels").pixel(0, 0); + assert!(outside[3] < 0.02, "{name} transparent pixel {outside:?}"); + } else { + assert!(layer_tag.is_none(), "{name}"); + } + } + assert_eq!(seen[0], seen[1], "flat and layered IFD samples differ"); +} + +/// A transparent document with no user channels still stores image alpha. +#[test] +fn transparent_tiff_without_channels_keeps_image_alpha() { + use photocraft_doc::Layer; + use photocraft_geom::{Rect, Size}; + use photocraft_raster::Surface; + + let mut doc = Document::new("t", Size::new(8, 8), ColorMode::Rgb, SampleType::U8); + let fmt = doc.pixel_format(); + let mut art = Surface::new(fmt); + art.fill_rect(Rect::new(1, 1, 6, 6), &photocraft_raster::from_rgba(&fmt, [1.0, 0.0, 0.0, 0.5])); + doc.layers.push(Layer::new("Art", LayerContent::Raster(art))); + for layers in [false, true] { + let r = export(&doc, "t.tif", &ExportOptions { tiff_layers: layers, ..ExportOptions::default() }).unwrap(); + let img = photocraft_codecs::decode(&r.bytes).unwrap(); + assert!(img.layout().has_alpha(), "{layers}"); + assert!(img.meta.extra_samples.is_empty(), "{layers}"); + let mut dec = tiff::decoder::Decoder::new(std::io::Cursor::new(r.bytes.as_slice())).unwrap(); + let extra = dec.get_tag_u16_vec(tiff::tags::Tag::ExtraSamples).unwrap(); + assert_eq!(extra, vec![2], "{layers}"); + assert!(!r.warnings.iter().any(|w| w.contains("Save Transparency")), "{layers}: {:?}", r.warnings); + if layers { + assert_photoshop_layered_tiff(&r.bytes, false); + } + } +} + +/// A flat TIFF that also stores an alpha or spot channel mattes the composite on white +/// and drops image transparency. The export says so. +#[test] +fn flat_tiff_warns_when_extra_channels_matte_transparency() { + use photocraft_color::{Color, PixelFormat}; + use photocraft_doc::{AlphaChannel, Layer}; + use photocraft_geom::{Rect, Size}; + use photocraft_raster::Surface; + + let mut doc = Document::new("t", Size::new(4, 4), ColorMode::Rgb, SampleType::U8); + let fmt = doc.pixel_format(); + let mut art = Surface::new(fmt); + // (0, 0) stays transparent. (1, 1) is half-red, so the matte is halfway to white. + art.fill_rect(Rect::new(1, 1, 2, 2), &photocraft_raster::from_rgba(&fmt, [1.0, 0.0, 0.0, 0.5])); + doc.layers.push(Layer::new("Art", LayerContent::Raster(art))); + let mut spot = AlphaChannel::new("Spot Color 1", Surface::new(PixelFormat::new(ColorMode::Grayscale, SampleType::U8, false))); + spot.spot = Some((Color::rgb(0.0, 1.0, 0.0), 1.0)); + doc.channels.push(spot); + + let r = export(&doc, "t.tif", &ExportOptions { tiff_layers: false, ..ExportOptions::default() }).unwrap(); + assert!(r.warnings.iter().any(|w| w.contains("composited over white") && w.contains("Save Transparency")), "{:?}", r.warnings); + let img = photocraft_codecs::decode(&r.bytes).unwrap(); + assert!(!img.layout().has_alpha(), "{:?}", img.layout()); + assert_eq!(img.meta.extra_samples.len(), 1); + let (_spp, _bps, extra, _rows, samples) = independent_samples(&r.bytes); + assert_eq!(extra, vec![0]); + // 4 samples per pixel: RGB + spot. (0, 0) was transparent and is now white. + assert_eq!(&samples[..3], &[255, 255, 255]); + // Half-red over white is about (255, 128, 128). Pixel (1, 1), 4 samples per pixel. + let (x, y, width, spp) = (1usize, 1usize, 4usize, 4usize); + let at = (y * width + x) * spp; + let rgb = &samples[at..at + 3]; + assert!(rgb[0] > 250 && (rgb[1] as i16 - 128).abs() <= 2 && (rgb[2] as i16 - 128).abs() <= 2, "{rgb:?}"); +} + +/// A 4×4 RGB document whose one layer is transparent outside its middle, plus a "White" spot +/// channel with solid ink in its left half: the shape of a UV print's underbase. +fn transparent_art_with_white_spot() -> Document { + use photocraft_color::{Color, PixelFormat}; + use photocraft_doc::{AlphaChannel, Layer}; + use photocraft_geom::{Rect, Size}; + use photocraft_raster::Surface; + + let mut doc = Document::new("t", Size::new(4, 4), ColorMode::Rgb, SampleType::U8); + let fmt = doc.pixel_format(); + let mut art = Surface::new(fmt); + art.fill_rect(Rect::new(1, 1, 3, 3), &photocraft_raster::from_rgba(&fmt, [1.0, 0.0, 0.0, 1.0])); + doc.layers.push(Layer::new("Layer 1", LayerContent::Raster(art))); + let gray = PixelFormat::new(ColorMode::Grayscale, SampleType::U8, false); + let mut plate = Surface::new(gray); + plate.fill_rect(Rect::new(0, 0, 2, 4), &photocraft_raster::from_rgba(&gray, [1.0, 1.0, 1.0, 1.0])); + let mut white = AlphaChannel::new("White", plate); + white.spot = Some((Color::rgb(0.8, 0.2, 0.2), 1.0)); + doc.channels.push(white); + doc +} + +/// The first channel's ink at (0, 0), inked, and at (3, 0), bare. +fn ink(d: &Document) -> (f32, f32) { + (d.channels[0].surface.pixel(0, 0)[0], d.channels[0].surface.pixel(3, 0)[0]) +} + +/// `doc` laid out as Photoshop 25.12 saves a TIFF with Save Transparency on: R, G, B, +/// transparency and spot samples, with "Transparency" first in the channel names and display +/// records. With `layers`, the layer data has a positive layer count and an `MTrn` block (the +/// specification's key is `Mtrn`); without, the file is flat. Built from the PSD model of `doc`. +fn photoshop_transparency_and_spot_tiff(doc: &Document, layers: bool) -> Vec { + use photocraft_psd::{Compression, TaggedBlock}; + + let opts = PsdExportOptions { merged_matte: false, merged_compression: Compression::Raw, ..Default::default() }; + let (file, _) = document_to_psd_with(doc, &opts); + let planes = file.decode_merged().unwrap(); + let n = 16; + assert_eq!(planes.len(), 5 * n); + let rgba: Vec = (0..n).flat_map(|i| (0..4).map(move |c| (i, c))).map(|(i, c)| planes[c * n + i]).collect(); + let mut img = photocraft_codecs::Image::from_raw(4, 4, photocraft_codecs::ChannelLayout::Rgba, photocraft_codecs::SampleType::U8, rgba).unwrap(); + img.meta.extra_samples = vec![photocraft_codecs::ExtraSample { kind: 0, data: planes[4 * n..].to_vec() }]; + img.meta.photoshop_resources = Some(photocraft_psd::tiff::resources_to_bytes(&file.resources).unwrap()); + if layers { + let mut isd = ImageSourceData::from_psd(&file); + if let Some(info) = &mut isd.layer_info { + info.merged_alpha = false; + } + isd.global_blocks.insert(0, TaggedBlock::new(*b"MTrn", Vec::new())); + let order = if photocraft_codecs::tiff_writes_little_endian() { ByteOrder::Little } else { ByteOrder::Big }; + img.meta.photoshop_layers = Some(isd.to_bytes(order).unwrap().0); + } + photocraft_codecs::encode(&img, photocraft_codecs::Format::Tiff, &photocraft_codecs::EncodeOptions::default()).unwrap() +} + +/// Photoshop's layered TIFF with transparency next to a spot channel opens with the spot as the +/// only channel. A layered re-save leaves the transparency sample out next to the spot, so it +/// must also drop the `MTrn` marker, or the spot would read back as transparency. +#[test] +fn photoshop_mtrn_tiff_opens_without_a_transparency_channel() { + use photocraft_psd::TaggedBlock; + + let bytes = photoshop_transparency_and_spot_tiff(&transparent_art_with_white_spot(), true); + let opened = import("t.tif", &bytes).unwrap().document; + let names: Vec<&str> = opened.channels.iter().map(|c| c.name.as_str()).collect(); + assert_eq!(names, ["White"]); + assert!(opened.channels[0].spot.is_some()); + assert_eq!(ink(&opened), (1.0, 0.0)); + + let r = tiff(&opened, true); + let (isd, _) = ImageSourceData::from_bytes(&tags(&r.bytes).1.unwrap()).unwrap(); + assert!(!isd.global_blocks.iter().any(TaggedBlock::is_merged_transparency_marker)); + let back = import("t.tif", &r.bytes).unwrap().document; + let names: Vec<&str> = back.channels.iter().map(|c| c.name.as_str()).collect(); + assert_eq!(names, ["White"]); + assert_eq!(ink(&back), (1.0, 0.0)); +} + +/// The same Photoshop layout in a flat TIFF (no layer data): the image keeps its transparency, +/// and the spot gets its own name and display record, not the leading "Transparency" ones, so +/// it opens as a spot with its ink the right way round. +#[test] +fn photoshop_flat_tiff_with_transparency_opens_its_spot_as_a_spot() { + let bytes = photoshop_transparency_and_spot_tiff(&transparent_art_with_white_spot(), false); + assert!(tags(&bytes).1.is_none(), "flat: no layer data"); + let opened = import("t.tif", &bytes).unwrap().document; + let names: Vec<&str> = opened.channels.iter().map(|c| c.name.as_str()).collect(); + assert_eq!(names, ["White"]); + assert!(opened.channels[0].spot.is_some(), "a spot, not an alpha channel"); + assert_eq!(ink(&opened), (1.0, 0.0)); + let LayerContent::Raster(s) = &opened.layers[0].content else { panic!("raster") }; + assert_eq!(s.pixel(0, 0)[3], 0.0, "the image keeps its transparency"); +} + +/// A Lab document with a spot channel keeps the spot as a CIELab extra sample, and its +/// transparency is matted on Lab white (L* 100, a* and b* 0), not on the maximum of every sample. +#[test] +fn lab_tiff_keeps_spot_and_mattes_on_lab_white() { + use photocraft_color::{Color, PixelFormat}; + use photocraft_doc::{AlphaChannel, Layer}; + use photocraft_geom::{Rect, Size}; + use photocraft_raster::Surface; + + for sample in [SampleType::U8, SampleType::U16] { + let mut doc = Document::new("t", Size::new(4, 4), ColorMode::Lab, sample); + let fmt = doc.pixel_format(); + let mut art = Surface::new(fmt); + // (0, 0) stays transparent. + art.fill_rect(Rect::new(1, 1, 2, 2), &photocraft_raster::from_rgba(&fmt, [1.0, 0.0, 0.0, 1.0])); + doc.layers.push(Layer::new("Art", LayerContent::Raster(art))); + let mut plate = Surface::new(PixelFormat::new(ColorMode::Grayscale, sample, false)); + plate.fill_rect(Rect::new(0, 0, 2, 4), &photocraft_raster::from_rgba(&plate.format(), [1.0, 1.0, 1.0, 1.0])); + let mut spot = AlphaChannel::new("Spot Color 1", plate); + spot.spot = Some((Color::rgb(0.0, 1.0, 0.0), 1.0)); + doc.channels.push(spot); + + // Lab is always saved flat, whether layers were asked for or not. + for layers in [false, true] { + let r = export(&doc, "t.tif", &ExportOptions { tiff_layers: layers, ..ExportOptions::default() }).unwrap(); + let img = photocraft_codecs::decode(&r.bytes).unwrap(); + assert_eq!(img.layout(), photocraft_codecs::ChannelLayout::Lab, "{sample:?} {layers}"); + assert_eq!(img.meta.extra_samples.len(), 1, "{sample:?} {layers}"); + let white = &img.to_normalized()[..3]; + assert!((white[0] - 1.0).abs() < 1e-3 && (white[1] - 128.0 / 255.0).abs() < 1e-3 && (white[2] - 128.0 / 255.0).abs() < 1e-3, "{white:?}"); + let back = import("t.tif", &r.bytes).unwrap().document; + assert_eq!(back.pixel_format().mode, ColorMode::Lab, "{sample:?} {layers}"); + assert_eq!(back.channels.len(), 1, "{sample:?} {layers}"); + assert_eq!(back.channels[0].name, "Spot Color 1"); + assert!(back.channels[0].spot.is_some(), "{sample:?} {layers}"); + let plate = |c: &AlphaChannel| c.surface.to_interleaved(Rect::new(0, 0, 4, 4)); + assert_eq!(plate(&back.channels[0]), plate(&doc.channels[0]), "{sample:?} {layers}"); + } + } +} + +/// Tag 37724 walked as raw bytes (not through [`ImageSourceData`]). +/// +/// Matches a Photoshop 27 layered TIFF: classic 4-byte block lengths, `Layr` then a 14-byte +/// `LMsk`, no `MTrn` (that block is only for a composite that keeps both transparency and a +/// spot). A 4320×4320 RGB spot plate is 74_649_600 bytes and still fits those u32 lengths; +/// this check uses the same layout on a smaller image. +fn assert_photoshop_layered_tiff(bytes: &[u8], with_spot: bool) { + assert!(bytes.starts_with(b"II"), "little-endian TIFF"); + let u16_at = |i: usize| u16::from_le_bytes([bytes[i], bytes[i + 1]]); + let u32_at = |i: usize| u32::from_le_bytes(bytes[i..i + 4].try_into().unwrap()); + let ifd = u32_at(4) as usize; + let n = u16_at(ifd) as usize; + let mut layers = None; + let mut spp = 0u16; + let mut extra = Vec::new(); + for e in 0..n { + let at = ifd + 2 + e * 12; + let tag = u16_at(at); + let typ = u16_at(at + 2); + let count = u32_at(at + 4) as usize; + let val = u32_at(at + 8) as usize; + let unit: usize = match typ { + 3 => 2, + 4 => 4, + _ => 1, + }; + let size = unit.saturating_mul(count); + let inline = at + 8; + let raw = if size <= 4 { &bytes[inline..inline + size] } else { &bytes[val..val + size] }; + match tag { + 277 => spp = u16::from_le_bytes([raw[0], raw[1]]), + 338 => extra = raw.as_chunks::<2>().0.iter().map(|c| u16::from_le_bytes(*c)).collect(), + 37724 => layers = Some(raw), + _ => {} + } + } + let isd = layers.expect("37724"); + let sig = b"Adobe Photoshop Document Data Block\0"; + assert!(isd.starts_with(sig), "PSB-sized lengths"); + let mut pos = sig.len(); + let mut keys = Vec::new(); + let mut layr: Option> = None; + while pos + 12 <= isd.len() { + assert_eq!(&isd[pos..pos + 4], b"MIB8", "block at {pos}"); + let key = [isd[pos + 7], isd[pos + 6], isd[pos + 5], isd[pos + 4]]; + let len = u32::from_le_bytes(isd[pos + 8..pos + 12].try_into().unwrap()) as usize; + let body = &isd[pos + 12..pos + 12 + len]; + if &key == b"Layr" { + layr = Some(body.to_vec()); + } + if &key == b"LMsk" { + assert_eq!(body, &[0, 0, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0x32, 0, 0x80, 0]); + } + keys.push(key); + pos += 12 + len; + let rest = &isd[pos..]; + let pad = (0..=3).find(|&k| k == rest.len() || rest.get(k..k + 4) == Some(b"MIB8")).unwrap_or(0); + pos += pad; + } + assert_eq!(pos, isd.len(), "trailing bytes after the last block"); + assert_eq!(keys.first(), Some(b"Layr")); + assert_eq!(keys.get(1), Some(b"LMsk")); + assert!(!keys.iter().any(|k| k == b"MTrn" || k == b"Mtrn")); + let layr = layr.expect("Layr"); + let count = i16::from_le_bytes([layr[0], layr[1]]); + if with_spot { + assert!(count > 0, "layer count {count}"); + assert_eq!((spp, extra.as_slice()), (4, [0u16].as_slice())); + } else { + assert!(count < 0, "layer count {count}"); + assert_eq!(extra, vec![2]); + } + let nch = u16::from_le_bytes([layr[18], layr[19]]) as usize; + let mut ids = Vec::new(); + let mut p = 20; + for _ in 0..nch { + ids.push(i16::from_le_bytes([layr[p], layr[p + 1]])); + p += 6; + } + assert!(ids.contains(&-1), "channel ids {ids:?}"); +} + +/// Photoshop 27's Kato-Karate TIFF stores spot ink inverted: every non-white artwork pixel +/// has spot 0, and the white background is spot 255. An alpha channel is the other way +/// around (255 = selected). Both polarities round-trip, in TIFF and in PSD. +#[test] +fn spot_ink_is_stored_as_zero_and_alpha_is_not() { + use photocraft_color::{Color, PixelFormat}; + use photocraft_doc::{AlphaChannel, Layer}; + use photocraft_geom::{Rect, Size}; + use photocraft_psd::PsdFile; + use photocraft_raster::Surface; + + for depth in [SampleType::U8, SampleType::U16, SampleType::F32] { + let (w, h) = (8u32, 8u32); + let mut doc = Document::new("pol", Size::new(w, h), ColorMode::Rgb, depth); + let fmt = doc.pixel_format(); + let mut art = Surface::new(fmt); + art.fill_rect(Rect::new(2, 2, 6, 6), &photocraft_raster::from_rgba(&fmt, [1.0, 0.2, 0.1, 1.0])); + doc.layers.push(Layer::new("Art", LayerContent::Raster(art))); + let gray = PixelFormat::new(ColorMode::Grayscale, depth, false); + let n = (w as usize) * (h as usize); + let mut ink = vec![0.0f32; n]; + for y in 2..6 { + for x in 2..6 { + ink[y * w as usize + x] = 1.0; + } + } + let mut spot = AlphaChannel::new("Spot Color 1", Surface::new(gray)); + spot.surface.write_region(Rect::new(0, 0, w as i32, h as i32), &ink); + spot.spot = Some((Color::rgb(1.0, 0.0, 0.0), 0.6)); + doc.channels.push(spot); + let mut alpha = AlphaChannel::new("Alpha 1", Surface::new(gray)); + alpha.surface.write_region(Rect::new(0, 0, w as i32, h as i32), &ink); + doc.channels.push(alpha); + + let psd = export(&doc, "pol.psd", &ExportOptions::default()).unwrap(); + let file = PsdFile::from_bytes(&psd.bytes).unwrap(); + let merged = file.decode_merged().unwrap(); + let bps = depth.bytes(); + let plane = n * bps; + let first = 3 + usize::from(file.merged_has_alpha()); + let spot_plane = &merged[first * plane..(first + 1) * plane]; + let alpha_plane = &merged[(first + 1) * plane..(first + 2) * plane]; + // Background (0,0) and artwork (3,3). Spot: 0 = solid ink, max = paper. + // Alpha: max = selected, 0 = empty. + assert_stored(spot_plane, 0, depth, false, "psd spot background"); + assert_stored(spot_plane, (3 * w as usize + 3) * bps, depth, true, "psd spot art"); + assert_stored(alpha_plane, 0, depth, true, "psd alpha background"); + assert_stored(alpha_plane, (3 * w as usize + 3) * bps, depth, false, "psd alpha art"); + let back = import("pol.psd", &psd.bytes).unwrap().document; + let area = Rect::new(0, 0, w as i32, h as i32); + assert_eq!(back.channels[0].surface.to_interleaved(area), doc.channels[0].surface.to_interleaved(area), "{depth:?} psd spot"); + assert_eq!(back.channels[1].surface.to_interleaved(area), doc.channels[1].surface.to_interleaved(area), "{depth:?} psd alpha"); + assert!(back.channels[0].spot.is_some(), "{depth:?}"); + assert!(back.channels[1].spot.is_none(), "{depth:?}"); + + if depth == SampleType::U8 { + for layers in [false, true] { + let r = export(&doc, "pol.tif", &ExportOptions { tiff_layers: layers, ..ExportOptions::default() }).unwrap(); + let (spp, _bps, extra, _rows, samples) = independent_samples(&r.bytes); + assert_eq!((spp, extra.as_slice()), (5, [0u16, 0].as_slice()), "{layers}"); + // Reference TIFF: artwork spot sample is 0, background spot sample is 255. + assert_eq!(samples[3], 255, "{layers} background spot"); + assert_eq!(samples[(3 * w as usize + 3) * 5 + 3], 0, "{layers} art spot"); + assert_eq!(samples[4], 0, "{layers} background alpha"); + assert_eq!(samples[(3 * w as usize + 3) * 5 + 4], 255, "{layers} art alpha"); + let back = import("pol.tif", &r.bytes).unwrap().document; + assert_eq!(back.channels[0].surface.to_interleaved(area), doc.channels[0].surface.to_interleaved(area), "{layers}"); + assert_eq!(back.channels[1].surface.to_interleaved(area), doc.channels[1].surface.to_interleaved(area), "{layers}"); + } + } + } +} + +/// `at` addresses one sample of a big-endian PSD plane. `zero` expects 0; otherwise the +/// maximum sample (255 / 65535 / 1.0). +fn assert_stored(plane: &[u8], at: usize, depth: SampleType, zero: bool, what: &str) { + match depth { + SampleType::U8 => { + let v = plane[at]; + assert_eq!(v, if zero { 0 } else { 255 }, "{what} {v}"); + } + SampleType::U16 => { + let v = u16::from_be_bytes([plane[at], plane[at + 1]]); + assert_eq!(v, if zero { 0 } else { 65535 }, "{what} {v}"); + } + SampleType::F32 => { + let v = f32::from_be_bytes([plane[at], plane[at + 1], plane[at + 2], plane[at + 3]]); + assert_eq!(v, if zero { 0.0 } else { 1.0 }, "{what} {v}"); + } + } +} + +/// Quick Mask stays the last channel after the merged transparency plane is omitted. +#[test] +fn spot_tiff_keeps_quick_mask_when_composite_alpha_is_omitted() { + use photocraft_color::{Color, PixelFormat}; + use photocraft_doc::{AlphaChannel, Layer}; + use photocraft_geom::{Rect, Size}; + use photocraft_raster::Surface; + + let mut doc = Document::new("q", Size::new(8, 8), ColorMode::Rgb, SampleType::U8); + let fmt = doc.pixel_format(); + let mut art = Surface::new(fmt); + art.fill_rect(Rect::new(1, 1, 6, 6), &photocraft_raster::from_rgba(&fmt, [1.0, 0.0, 0.0, 0.5])); + doc.layers.push(Layer::new("Art", LayerContent::Raster(art))); + let gray = PixelFormat::new(ColorMode::Grayscale, SampleType::U8, false); + let area = Rect::new(0, 0, 8, 8); + let mut spot_bytes = vec![9u8; 64]; + spot_bytes[0] = 3; + let mut channel = AlphaChannel::new("Spot Color 1", Surface::from_interleaved(gray, area, &spot_bytes)); + channel.spot = Some((Color::rgb(1.0, 0.0, 0.0), 0.6)); + doc.channels.push(channel); + let mut qbytes = vec![7u8; 64]; + qbytes[1] = 4; + doc.quick_mask = Some(AlphaChannel::new("Quick Mask", Surface::from_interleaved(gray, area, &qbytes))); + + for layers in [false, true] { + let r = export(&doc, "q.tif", &ExportOptions { tiff_layers: layers, ..ExportOptions::default() }).unwrap(); + let (spp, _bps, extra, _rows, samples) = independent_samples(&r.bytes); + assert_eq!((spp, extra.as_slice()), (5, [0, 0].as_slice()), "{layers}"); + let stored_spot: Vec = spot_bytes.iter().map(|b| 255 - b).collect(); + assert_plane(&samples, 5, 3, &stored_spot); + // A Quick Mask is an alpha channel: stored straight, not as spot ink. + assert_plane(&samples, 5, 4, &qbytes); + let back = import("q.tif", &r.bytes).unwrap().document; + assert_eq!(back.channels.len(), 1, "{layers}"); + assert_eq!(back.channels[0].surface.to_interleaved(area), spot_bytes, "{layers}"); + let qm = back.quick_mask.as_ref().unwrap_or_else(|| panic!("{layers}: no quick mask")); + assert_eq!(qm.surface.to_interleaved(area), qbytes, "{layers}"); + } +} + #[test] fn default_export_options_write_a_flat_tiff() { // Scripted and agent saves (CLI, batch, MCP) build on the defaults: layers only on request. diff --git a/crates/psd/src/file.rs b/crates/psd/src/file.rs index 740d44f8bf..eec73ed072 100644 --- a/crates/psd/src/file.rs +++ b/crates/psd/src/file.rs @@ -39,6 +39,14 @@ pub struct GlobalLayerMask { } impl GlobalLayerMask { + /// The mask Photoshop writes for a layered file that has no global mask of its own: + /// an RGB red overlay at 50% opacity, kind 128 (use the per-layer setting), plus the + /// filler byte. A zero-length `LMsk` block in a TIFF makes Photoshop give up on the + /// layer data (it reads this 14-byte record from the block). + pub fn photoshop_default() -> Self { + GlobalLayerMask { data: vec![0, 0, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 50, 128, 0] } + } + fn be16(&self, at: usize) -> Option { self.data.get(at..at + 2).map(|b| u16::from_be_bytes([b[0], b[1]])) } diff --git a/crates/psd/tests/roundtrip.rs b/crates/psd/tests/roundtrip.rs index 1f23ee6284..49ad412e7c 100644 --- a/crates/psd/tests/roundtrip.rs +++ b/crates/psd/tests/roundtrip.rs @@ -232,6 +232,7 @@ fn global_mask_accessors() { assert_eq!(gm.opacity(), Some(50)); assert_eq!(gm.kind(), Some(128)); assert_eq!(GlobalLayerMask::default().kind(), None); + assert_eq!(GlobalLayerMask::photoshop_default().data, gm.data); } #[test] diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 63fef83486..e2fc72c8ed 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File-format parity -> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-21 · **Change:** patch (Photoshop's `MTrn` merged-transparency marker, from a layered TIFF saved with Save Transparency, marks the merged transparency; earlier: DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-21 · **Change:** minor (TIFF writes and reads alpha and spot channels as extra samples with Photoshop's channel resources, PSD output unchanged, FILE-215-7, FILE-215-17's TIFF part, #7415; earlier the same day: Photoshop's `MTrn` merged-transparency marker, from a layered TIFF saved with Save Transparency, marks the merged transparency; earlier: DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; 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 @@ -24,7 +24,7 @@ XL are missing (gap G10). Remaining: 300–500 h including PSD fidelity. | PSD | R/W | yes | yes | 1/8/16/32-bit; Bitmap, Gray, Indexed, RGB, CMYK, Multichannel, Lab, Duotone; layers, groups, masks, vector masks, adjustment and fill layers, effects, text, shapes, smart objects (SoLd/lnk2; CS2 PlLd/lnkD read with their warp, kept as is or re-saved as SoLd once edited), smart filters (14 mapped plus Filter Gallery with Chrome, rest verbatim), slices, comps, Advanced Blending. Oracle floors: Photoshop-authored 188/258, io 148/170, psd-tools 249/309; round trip ≥ 169/170, 308/309, 258/256. Known failures: #1281, #2469 (#2374, text layers, closed 2026-10-10; #2465, CS2 `PlLd`-only smart objects, fixed 2026-10-12) | | PSB | R/W | yes | yes | Auto-switches above 2 GB (REL-212-2); 4–5 GB fixtures generated (FILE-216-2); > 4 GB fails on Windows (#375) | | Cloud PSD (.psdc) | R/W | no | no | Out of scope (Adobe cloud) | -| TIFF | R/W | yes | yes | 8/16/32f, Gray/RGB/CMYK, BigTIFF, every IFD, banded parallel decode; layered TIFF both byte orders (FILE-215-7: extra alpha channels not written) | +| TIFF | R/W | yes | yes | 8/16/32f, Gray/RGB/CMYK, BigTIFF, every IFD, banded parallel decode; layered TIFF both byte orders (FILE-215-7); alpha and spot channels as extra samples (at most 16) with Photoshop's names, ink colours and solidity, spot ink stored 0 = solid (#7415); no Save Transparency choice yet (channels are written as Photoshop does with it off) | | JPEG | R/W | yes | yes | 8-bit Gray/RGB/CMYK, ICC/EXIF/XMP; Save keeps the opened file's quality (estimated from its quantisation tables, #2399); no JPEG Options dialog (quality 0–12, baseline/progressive) (FILE-215-19) | | PNG | R/W | yes | yes | 8/16-bit, ICC/text; APNG first frame only; alpha channels on open (#2225); palette PNGs open in Indexed Color mode with their transparent entry (#4804); Save keeps a stereo PNG's `sTER` pairing (#6063) | | GIF | R/W | yes | yes | File › Open keeps the first frame; New Video Layer from File and Video Frames to Layers take every frame, with the timeline rate from the delays (#572). Per-frame delays and keeping the frames in `.pcraft` are not done | @@ -142,6 +142,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings. | Date | Change | Summary | |---|---|---| +| 2026-10-21 | minor | TIFF: alpha and spot channels are written and read as extra samples (at most 16) with Photoshop's channel resources (1006, 1045, 1077, 1053), spot ink stored 0 = solid as Photoshop 27.11's TIFFs store it; PSD output is unchanged. FILE-215-7 done, FILE-215-17 partial (its TIFF part) (#7415, supersedes #3121) | | 2026-10-21 | patch | PSD and layered TIFF: the `MTrn` block Photoshop writes in a layered TIFF saved with Save Transparency (a positive layer count, `nrTM` in an `II` file) marks the merged image's first extra channel as its transparency, like `Mtrn`/`Mt16`/`Mt32`: such a file no longer opens with its transparency also as an alpha channel (named "Transparency" in Photoshop 27.11's file), and a PSD save no longer writes it twice. A PSD save with an opaque composite drops any of these markers kept from the opened file, so its first alpha channel no longer reopens as transparency and vanishes (split from #7415; credit #3121) | | 2026-10-15 | minor | DDS textures save (#1327): uncompressed or BC1/BC2/BC3 (DXT1/3/5) from a clean-room block encoder, optional box-filtered mip chain, legacy header; DDS Options in Save As and Save a Copy, `ddsCompression`/`ddsMipmaps` for scripts, the CLI and MCP | | 2026-10-15 | minor | PNG: a stereo PNG's `sTER` pairing (PNG Extensions 1.4.0 §3.6) is read on open and written back on save, so the file still says it is a stereo pair (#6063) | diff --git a/docs/gaps.md b/docs/gaps.md index ab42d0f8ef..647c121998 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where PhotoCraft falls short of Photoshop -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-18 · **Change:** minor (G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-21 · **Change:** minor (G10: TIFF alpha and spot channels written and read as extra samples, FILE-215-7 done, FILE-215-17's TIFF part, #7415; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 @@ -230,9 +230,12 @@ what an agent can't finish alone. write (FILE-215-10, #2541; a single flattened page now saves via Save As / Save a Copy / CLI, 2026-10-11, #3401), AVIF read (#463) and default-build AVIF write, JPEG XL, JPEG 2000 (#1047), Cineon write (read landed), DICOM, EPS/DCS, Pixar, IFF, WBMP, MPO/JPS, PICT, Scitex CT, Photoshop - Raw; layered TIFF extra alpha channels (FILE-215-7); spot plates (FILE-215-17); .atn, .asl, + Raw; spot plates beyond TIFF: spot ink preview in RGB/CMYK documents and PDF Separation + (FILE-215-17); .atn, .asl, .shc, .csh presets (FILE-215-15); C2PA (#1050). - **Detail:** [`file-format-parity.md`](file-format-parity.md). +- **Progress (2026-10-21, #7415):** TIFF writes and reads alpha and spot channels as extra samples + with Photoshop's names, ink colours and solidity (FILE-215-7 done; FILE-215-17's TIFF part). - **Progress (2026-10-13):** Cineon (`.cin`) 10-bit gray/RGB frames open read-only, sharing the DPX header/unpacking (`crates/codecs/src/codecs/dpx.rs`); writing is still open. - **Estimate:** 120–220 h. @@ -274,6 +277,7 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| +| 2026-10-21 | minor | G10: TIFF alpha and spot channels written and read as extra samples with Photoshop's channel resources, PSD output unchanged (#7415); FILE-215-7 leaves the list, FILE-215-17 narrows to RGB/CMYK spot preview and PDF Separation | | 2026-10-15 | minor | G1 / #5972 A1: render only provably constant-RGB `GdFl` noise fills; variable noise synthesis remains open | | 2026-10-18 | minor | G9: with no selection, Copy takes fill and adjustment layers whole and Paste recreates them (#2344); UI-217-23 stays partial (a single pixel layer copies its pixels only); estimate unchanged | | 2026-10-14 | minor | G1: a PSD smart object's filter mask shows when the file opens (Photoshop stores the filtered pixels unmasked); export stores them that way too; Photoshop-oracle floor 185 → 188 of 258 | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 3eca518c27..6e8449e38e 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,6 +1,6 @@ # PhotoCraft vs Adobe Photoshop: target-app parity -> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-18 · **Change:** minor (fill and adjustment layers copy and paste whole, UI-217-23 partial, #2344; on-canvas corner radius widgets, TOOL-214-12; `.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 +> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-21 · **Change:** minor (TIFF spot plates, FILE-215-17's TIFF part, #7415; fill and adjustment layers copy and paste whole, UI-217-23 partial, #2344; on-canvas corner radius widgets, TOOL-214-12; `.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); @@ -175,7 +175,7 @@ parity for the area and are already contained in the dimension rows above. | Adjustments and filters | 70% | 120–200 | All present; smart-filter re-render matches Photoshop on 5 of 30 files; Filter Gallery looks approximate; no Neural Filters | | Type | 40% | 120–200 | Engine works; no type on a path, manual kerning, RTL paragraphs, OpenType panel UI, live Warp Text preview; Type tool freeze on macOS (#2518) | | Vector shapes and paths | 55% | 80–140 | Pen, Direct/Path Selection, shapes, shape strokes. Freeform and Curvature Pen (#1054). Add/Delete Anchor Point and Convert Point tools exist (`Tool` enum); on-canvas corner radius widgets on live rectangles (TOOL-214-12, 2026-10-13); missing path-point nudge; shape parity tracking issue #2496 | -| Colour management and modes | 70% | 60–100 | Own ICC engine, soft proof, CMYK/Lab/Indexed/Duotone/Multichannel; no Adobe CMYK profiles, no spot plates (FILE-215-17), monitor profile only at launch | +| Colour management and modes | 70% | 60–100 | Own ICC engine, soft proof, CMYK/Lab/Indexed/Duotone/Multichannel; no Adobe CMYK profiles, spot plates in TIFF only (FILE-215-17: no RGB/CMYK spot preview or PDF Separation), monitor profile only at launch | | Camera Raw and computational photo (Photomerge, HDR, lens) | 45% | 120–200 | Raw for DNG/CR2/NEF/ARW/RW2/ORF/RAF(uncompressed)/PEF; no CR3; ACR dialog partial (no masking, calibration); generic lens profiles only | | Automation, actions, batch, scripting | 45% | 120–200 | CLI/MCP/control channel ahead of Photoshop; Actions panel and recording not document-independent (AUTO-219-1/2); `.atn` load/save since 2026-10-12 (112 events mapped, the rest kept verbatim); no ExtendScript/UXP | | File I/O | 60% | 300–500 | See [file-format-parity.md](file-format-parity.md) | @@ -565,6 +565,7 @@ See [method, raw measurements and reproduction](five-algorithm-performance.md). | Date | Change | Summary | |---|---|---| +| 2026-10-21 | minor | Colour management and modes: spot plates now save and open in TIFF (#7415); estimates unchanged | | 2026-10-18 | minor | Layers: with no selection, Copy takes fill and adjustment layers whole and Paste recreates them (#2344); UI-217-23 stays partial; percentages unchanged | | 2026-10-13 | minor | Vector shapes: on-canvas corner radius widgets on live rectangles (TOOL-214-12); estimates unchanged | | 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 | diff --git a/scorecard/file_compat.toml b/scorecard/file_compat.toml index d7e82c9aea..84738c1455 100644 --- a/scorecard/file_compat.toml +++ b/scorecard/file_compat.toml @@ -50,9 +50,9 @@ note = "#426: SmartObject.perspective holds the projective map (transform keeps [[item]] id = "FILE-215-7" target = "Layered TIFF read and write (tag 37724), honouring the ask-before-saving pref" -status = "partial" +status = "done" issue = 215 -note = "psd tiff.rs (ImageSourceData, both byte orders), io tiff_layers.rs, ui tiff_options_ui.rs (Discard Layers and Save a Copy); extra alpha channels and a Quick Mask are not written (the TIFF codec holds one transparency sample)" +note = "psd tiff.rs (ImageSourceData, both byte orders), io tiff_layers.rs, ui tiff_options_ui.rs (Discard Layers and Save a Copy); extra alpha/spot channels and a Quick Mask are written as TIFF extra samples (at most 16) plus Photoshop resources for name, colour and solidity; Photoshop's MTrn marker is read (#7415). The TIFF Options Save Transparency choice isn't offered: channels are written as Photoshop does with it off" [[item]] id = "FILE-215-8" @@ -120,9 +120,9 @@ note = "doc advanced.rs + .pcraft + PSD/layered TIFF (knko infx clbl tsly lmgm v [[item]] id = "FILE-215-17" target = "CMYK/RGB documents preview spot inks; spot plates export (TIFF extra samples, PDF)" -status = "missing" +status = "partial" issue = 215 -note = "compose multichannel.rs:1 spot preview for Multichannel only" +note = "TIFF: spot channels written and read as extra samples with DisplayInfo (1077) ink colour and solidity, ink stored 0 = solid (#7415). Missing: spot ink preview in RGB/CMYK documents (compose multichannel.rs:1 previews Multichannel only) and PDF Separation" [[item]] id = "FILE-215-18" From f7f8fdcd89196ee98cdca46aed546a38ecb78160 Mon Sep 17 00:00:00 2001 From: Jason D Date: Wed, 21 Oct 2026 11:36:39 -0400 Subject: [PATCH 211/649] io: keep PSD output as on main; Photoshop spot polarity for TIFF only #7415 changed every PSD export (spot planes inverted, bit 3 on group dividers, a 14-byte LMsk, a fresh 1053) and dropped 1053 on PSD open. PSD export and import are back to main's behaviour; the layered TIFF asks for Photoshop's spot polarity through an opt-in switch (PsdExportOptions/PsdImportOptions::photoshop_spot_polarity), and the LMsk and flag bit 3 move into tiff_layers. - One helper, channel_map::photoshop_spot_plane, converts every spot plane in Photoshop's polarity (flat TIFF save/open, layered TIFF via the PSD paths). - DisplayInfo is read as on main (13-byte 1077, 14-byte 1007 records); Photoshop's PSDs and TIFFs all use 13. - 1053 is numbered from 3 in every mode, as all 12 Photoshop TIFFs are. A layered TIFF's 1053 is not kept on open, and a TIFF save never copies a PSD's. - Tests: PSD keeps spot and alpha planes straight with no 1053, an empty LMsk and main's flags; a PSD's 1053 survives open and save; a TIFF saved as PSD writes straight planes and no 1053. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Zer0C00L01 <12090083+Zer0C00L01@users.noreply.github.com> --- crates/io/src/channel_map.rs | 111 +++++++++++++++++++-------------- crates/io/src/lib.rs | 3 +- crates/io/src/pixels.rs | 29 ++------- crates/io/src/psd_export.rs | 90 +++++++++++++++++++++----- crates/io/src/psd_import.rs | 45 ++++++------- crates/io/src/tiff_layers.rs | 55 ++++++++-------- crates/io/tests/tiff_layers.rs | 19 +++--- 7 files changed, 211 insertions(+), 141 deletions(-) diff --git a/crates/io/src/channel_map.rs b/crates/io/src/channel_map.rs index 60b671101a..990027441a 100644 --- a/crates/io/src/channel_map.rs +++ b/crates/io/src/channel_map.rs @@ -1,14 +1,13 @@ //! Alpha / spot channel options <-> PSD `DisplayInfo` image resources (1077, and the older 1007). //! -//! Layout (Adobe PSD spec, "DisplayInfo", and a Photoshop 27 layered TIFF): resource 1077 -//! starts with a 4-byte version (1), then one record per extra channel: colour space (u16), -//! four u16 colour components, opacity (u16, 0..100) and kind (u8: 0 = colour indicates -//! selected areas, 1 = masked ("protected") areas, 2 = spot channel). Photoshop writes that -//! 13-byte record with no pad. Older files pad each record to 14 bytes; both are read. -//! Resource 1007 has the same records without the version, each followed by a padding byte. -//! When the merged image has transparency, Photoshop writes that channel's record first. +//! Layout (Adobe PSD spec, "DisplayInfo"): resource 1077 starts with a 4-byte version (1), then +//! one 13-byte record per extra channel: colour space (u16), four u16 colour components, opacity +//! (u16, 0..100) and kind (u8: 0 = colour indicates selected areas, 1 = masked ("protected") +//! areas, 2 = spot channel). Resource 1007 has the same records without the version and the spot +//! kind, each followed by a padding byte (14 bytes). Photoshop 27's TIFFs use the same 13-byte +//! 1077 records. -use photocraft_color::{Color, ColorMode}; +use photocraft_color::{Color, ColorMode, SampleType}; use photocraft_doc::{AlphaChannel, ColorIndicates}; pub(crate) const DISPLAY_INFO: u16 = 1077; @@ -24,18 +23,24 @@ const SPACE_CMYK: u16 = 2; const SPACE_LAB: u16 = 7; const SPACE_GRAY: u16 = 8; -/// Resource 1053: channel ids `1..=count`, one big-endian u32 each, with no length prefix. -/// Photoshop, ag-psd and psd-tools read u32s until the resource ends. -pub(crate) fn alpha_identifiers(count: usize) -> Vec { - alpha_identifiers_from(1, count) +/// Converts one spot channel's plane (native-endian samples) between the document's ink density +/// (1 = solid ink) and the way Photoshop stores a spot channel (0 = solid ink, the maximum = +/// bare paper; every TIFF Photoshop 27 saves stores it so). The conversion is its own inverse, +/// so it serves both open and save. Every reader and writer of Photoshop-polarity spot planes +/// goes through here: a change to the in-memory convention changes only this function. Alpha +/// channels are stored straight (the maximum = selected) and never come here. +pub(crate) fn photoshop_spot_plane(plane: &mut [u8], sample: SampleType) { + crate::pixels::invert_plane(plane, sample); } -/// Resource 1053 starting at `first` (a layered TIFF uses the sample's index in the IFD: -/// 3 for the spot after RGB, not 1). -pub(crate) fn alpha_identifiers_from(first: u32, count: usize) -> Vec { +/// Resource 1053 for `count` channels: one big-endian u32 identifier each, with no length prefix +/// (Photoshop, ag-psd and psd-tools read u32s until the resource ends). Photoshop 27.11 numbers a +/// new document's channels 3, 4, 5, … in every colour mode (RGB, CMYK, Gray and Lab, in its PSDs +/// and TIFFs alike), so these do too. +pub(crate) fn alpha_identifiers(count: usize) -> Vec { let mut out = Vec::with_capacity(count.saturating_mul(4)); for i in 0..count { - let id = first.saturating_add(u32::try_from(i).unwrap_or(u32::MAX)); + let id = 3u32.saturating_add(u32::try_from(i).unwrap_or(u32::MAX)); out.extend_from_slice(&id.to_be_bytes()); } out @@ -67,41 +72,25 @@ pub(crate) fn display_info(channels: &[&AlphaChannel], transparency: bool) -> Ve out } -/// 13 when every record is Photoshop's unpadded form, otherwise the 14-byte padded form. -/// -/// Lengths divisible by both (14, 28, … unpadded records, or 13, 26, … padded ones) take -/// the unpadded stride for resource 1077, which is what Photoshop 27 writes, and the padded -/// stride for the older 1007 resource, whose record includes the pad byte. -fn display_stride(body: &[u8], versioned: bool) -> usize { - let unpadded = !body.is_empty() && body.len().is_multiple_of(13); - let padded = !body.is_empty() && body.len().is_multiple_of(14); - if unpadded && (!padded || versioned) { 13 } else { 14 } +/// The records of a DisplayInfo resource (`versioned` = 1077: 13-byte records after a version; +/// else the older 1007 with 14-byte records). A trailing partial record is left out. +fn display_records(data: &[u8], versioned: bool) -> std::slice::ChunksExact<'_, u8> { + let (body, size) = if versioned { (data.get(4..).unwrap_or(&[]), 13) } else { (data, 14) }; + body.chunks_exact(size) } -/// Which of the first `count` DisplayInfo records are spot channels (kind 2). -/// Missing records are not spots. Alpha channels (kind 0 or 1) stay false: their samples -/// are stored straight, while a spot's samples are stored inverted. -pub(crate) fn spot_flags(data: &[u8], versioned: bool, count: usize) -> Vec { - let body = if versioned { data.get(4..).unwrap_or(&[]) } else { data }; - let stride = display_stride(body, versioned); - let mut out = vec![false; count]; - for (i, rec) in body.chunks(stride).take(count).enumerate() { - if rec.len() >= 13 { - out[i] = rec[12] == 2; - } - } - out +/// Which of the extra channels are spot channels (kind 2), after skipping `skip` records (the +/// merged transparency channel's), in the same records [`apply_display_info`] reads. A channel +/// without a record is not a spot. +pub(crate) fn spot_flags(data: &[u8], versioned: bool, skip: usize) -> Vec { + display_records(data, versioned).skip(skip).map(|rec| rec.get(12) == Some(&2)).collect() } -/// Applies a DisplayInfo resource (`versioned` = 1077: records after a version; else the older -/// 1007) to the imported channels in order, after skipping `skip` records (the merged -/// transparency channel's). Both the 13-byte records Photoshop writes and the 14-byte padded -/// form are read. +/// Applies a DisplayInfo resource (`versioned` = 1077: 13-byte records after a version; else the +/// older 1007 with 14-byte records) to the imported channels in order, after skipping `skip` +/// records (the merged transparency channel's). pub(crate) fn apply_display_info(data: &[u8], versioned: bool, skip: usize, channels: &mut [AlphaChannel]) { - let body = if versioned { data.get(4..).unwrap_or(&[]) } else { data }; - let stride = display_stride(body, versioned); - for (c, rec) in channels.iter_mut().zip(body.chunks(stride).skip(skip)) { - let Some(rec) = rec.get(..13) else { break }; + for (c, rec) in channels.iter_mut().zip(display_records(data, versioned).skip(skip)) { let u = |i: usize| u16::from_be_bytes([rec[i], rec[i + 1]]); let comps = [u(2), u(4), u(6), u(8)]; let color = decode_color(u(0), comps); @@ -199,9 +188,9 @@ mod tests { assert!((back[0].opacity - 0.3).abs() < 1e-6); assert_eq!(back[0].indicates, ColorIndicates::SelectedAreas); assert_eq!(back[1].spot, s.spot); - assert_eq!(alpha_identifiers(2), [0, 0, 0, 1, 0, 0, 0, 2]); + assert_eq!(spot_flags(&bytes, true, 0), [false, true]); + assert_eq!(alpha_identifiers(2), [0, 0, 0, 3, 0, 0, 0, 4]); assert!(alpha_identifiers(0).is_empty()); - assert_eq!(alpha_identifiers_from(3, 1), [0, 0, 0, 3]); // Photoshop 27 writes a 13-byte record (no pad): red spot, solidity 60. let ps = [0, 0, 0, 1, 0, 0, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0x3c, 2]; let mut spot = vec![AlphaChannel::new("S", Surface::new(PixelFormat::GRAY8))]; @@ -214,10 +203,13 @@ mod tests { apply_display_info(&with_t, true, 1, &mut back); assert_eq!(back[0].indicates, ColorIndicates::SelectedAreas); assert_eq!(back[1].spot, s.spot); + assert_eq!(spot_flags(&with_t, true, 1), [false, true]); // Truncated data is ignored rather than misread. let mut c = vec![AlphaChannel::new("x", Surface::new(PixelFormat::GRAY8))]; apply_display_info(&bytes[..10], true, 0, &mut c); assert_eq!(c[0].opacity, 0.5); + assert!(spot_flags(&bytes[..10], true, 0).is_empty()); + assert!(spot_flags(&bytes, true, 5).is_empty()); // 14 unpadded records are a multiple of 14 as well (14×13 = 13×14). Resource 1077 // still reads them as 13-byte records; the last spot's solidity must survive. @@ -235,6 +227,29 @@ mod tests { assert_eq!(got[13].spot.map(|(_, s)| (s * 100.0).round() as u16), many[13].spot.map(|(_, s)| (s * 100.0).round() as u16)); } + /// Photoshop's spot ink (0 = solid) and the document's density (1 = solid) at every depth, + /// both ways: the 25 % / 75 % columns of the Photoshop oracles store 191 / 64. + #[test] + fn photoshop_spot_plane_converts_both_ways() { + let mut p8 = vec![255u8, 64, 191, 0]; + photoshop_spot_plane(&mut p8, SampleType::U8); + assert_eq!(p8, [0, 191, 64, 255]); + photoshop_spot_plane(&mut p8, SampleType::U8); + assert_eq!(p8, [255, 64, 191, 0]); + let mut p16: Vec = [65535u16, 16448, 0].iter().flat_map(|v| v.to_ne_bytes()).collect(); + photoshop_spot_plane(&mut p16, SampleType::U16); + let back: Vec = p16.as_chunks::<2>().0.iter().map(|c| u16::from_ne_bytes(*c)).collect(); + assert_eq!(back, [0, 49087, 65535]); + let mut p32: Vec = [1.0f32, 0.25].iter().flat_map(|v| v.to_ne_bytes()).collect(); + photoshop_spot_plane(&mut p32, SampleType::F32); + let back: Vec = p32.as_chunks::<4>().0.iter().map(|c| f32::from_ne_bytes(*c)).collect(); + assert_eq!(back, [0.0, 0.75]); + // A trailing partial sample is left alone rather than misread. + let mut odd = vec![0u8, 0, 7]; + photoshop_spot_plane(&mut odd, SampleType::U16); + assert_eq!(odd, [0xff, 0xff, 7]); + } + #[test] fn decodes_other_spaces() { let g = decode_color(SPACE_GRAY, [10000, 0, 0, 0]); diff --git a/crates/io/src/lib.rs b/crates/io/src/lib.rs index 946abfbc75..70d66f8c5c 100644 --- a/crates/io/src/lib.rs +++ b/crates/io/src/lib.rs @@ -321,7 +321,8 @@ fn import_stages(name: &str, bytes: &[u8], ctl: &photocraft_raster::Interrupt, m psd_import::check_group_depth(&file)?; ctl.check().map_err(|_| IoError::Cancelled)?; ctl.progress(0.05); - let (mut document, warnings) = psd_import::psd_to_document_decoded(&file, ctl, merged).ok_or(IoError::Cancelled)?; + let (mut document, warnings) = + psd_import::psd_to_document_decoded(&file, ctl, merged, psd_import::PsdImportOptions::default()).ok_or(IoError::Cancelled)?; document.name = name.to_string(); text_import::prepare(&mut document); return Ok(ImportResult { document, warnings, source_read_only: false, preview_only: false }); diff --git a/crates/io/src/pixels.rs b/crates/io/src/pixels.rs index 7d58109714..23ecf88053 100644 --- a/crates/io/src/pixels.rs +++ b/crates/io/src/pixels.rs @@ -21,30 +21,11 @@ pub fn sample_for_depth(depth: u16) -> SampleType { } } -/// Complements every sample in `bytes`. Photoshop stores a spot channel as ink density -/// inverted: 0 is solid ink and the maximum sample is bare paper (the same convention as a -/// CMYK plate and as Multichannel). An alpha channel is not stored this way: 0 is empty and -/// the maximum sample is selected. `big_endian` is the PSD merged-image order; TIFF extra -/// samples are native-endian. -pub fn invert_plane(bytes: &mut [u8], s: SampleType, big_endian: bool) { - let bps = s.bytes(); - if bps == 0 { - return; - } - for c in bytes.chunks_exact_mut(bps) { - match s { - SampleType::U8 => c[0] = 255 - c[0], - SampleType::U16 => { - let v = if big_endian { u16::from_be_bytes([c[0], c[1]]) } else { u16::from_ne_bytes([c[0], c[1]]) }; - let w = 65535 - v; - c.copy_from_slice(&(if big_endian { w.to_be_bytes() } else { w.to_ne_bytes() })); - } - SampleType::F32 => { - let v = if big_endian { f32::from_be_bytes([c[0], c[1], c[2], c[3]]) } else { f32::from_ne_bytes([c[0], c[1], c[2], c[3]]) }; - let w = 1.0 - v; - c.copy_from_slice(&(if big_endian { w.to_be_bytes() } else { w.to_ne_bytes() })); - } - } +/// Complements every native-endian sample of one plane (`max − v`, `1 − v` for float). A +/// trailing partial sample is left unchanged. +pub(crate) fn invert_plane(bytes: &mut [u8], s: SampleType) { + for c in bytes.chunks_exact_mut(s.bytes().max(1)) { + invert_sample(c, s); } } diff --git a/crates/io/src/psd_export.rs b/crates/io/src/psd_export.rs index 81d3ebe5a4..483b305f00 100644 --- a/crates/io/src/psd_export.rs +++ b/crates/io/src/psd_export.rs @@ -50,6 +50,11 @@ pub struct PsdExportOptions { /// The path of the document's own file: linked smart objects are resolved against it /// ([`crate::doc_path::resolve`]) before they are read and embedded. pub document_path: Option, + /// Store spot channels as Photoshop's TIFFs do, 0 = solid ink (see + /// [`crate::channel_map::photoshop_spot_plane`]). Only the layered TIFF sets it: a PSD keeps + /// writing the document's density as it is (1 = solid ink), so files saved by earlier + /// versions keep reading the same. + pub photoshop_spot_polarity: bool, } impl Default for PsdExportOptions { @@ -61,6 +66,7 @@ impl Default for PsdExportOptions { merged_compression: Compression::Rle, maximize_compatibility: true, document_path: None, + photoshop_spot_polarity: false, } } } @@ -484,8 +490,6 @@ impl Ex { } flags.set_hidden(!l.visible); flags.set_transparency_protected(l.locks.transparency); - // Bit 3 (with bit 4 clear) is the flag Photoshop sets on every layer it writes. - flags.0 |= LayerFlags::BIT4_USEFUL; let mut blocks = vec![TaggedBlock::unicode_name(&l.name), TaggedBlock::layer_id(id)]; let lspf = blocks::lspf_from_locks(&l.locks); if lspf != 0 { @@ -1077,8 +1081,6 @@ impl Ex { match &l.content { LayerContent::Group(g) => { let id = self.fresh_id(); - let mut divider_flags = LayerFlags(0); - divider_flags.0 |= LayerFlags::BIT4_USEFUL; self.records.push(LayerRecord { channels: self.empty_channels(), blending_ranges: BlendingRanges::full(self.cc), @@ -1088,7 +1090,6 @@ impl Ex { TaggedBlock::layer_id(id), TaggedBlock::section_divider(SectionType::BoundingDivider, None, None), ], - flags: divider_flags, ..Default::default() }); self.emit(&g.children, tick); @@ -1710,10 +1711,11 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c }; for a in &extra { let s = if a.surface.format() != ex.mask_fmt { a.surface.convert(ex.mask_fmt) } else { a.surface.clone() }; - let bytes = s.to_interleaved(canvas); - // Spot ink is stored inverted (0 = solid, max = paper), the same way Multichannel - // and a Photoshop TIFF do. An alpha channel stays straight (max = selected). - planes.extend(deinterleave(&bytes, 1, sample, &[a.spot.is_some()]).remove(0)); + let mut bytes = s.to_interleaved(canvas); + if opts.photoshop_spot_polarity && a.spot.is_some() { + crate::channel_map::photoshop_spot_plane(&mut bytes, sample); + } + planes.extend(deinterleave(&bytes, 1, sample, &[false]).remove(0)); } let channels = (cc + usize::from(has_alpha) + extra.len()) as u16; let mode = if duotone_inks.is_some() { PsdMode::Duotone } else { psd_mode(fmt.mode) }; @@ -1744,7 +1746,6 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c resources.push(ImageResource::new(1006, pascal_names_resource(&names))); resources.push(ImageResource::new(1045, unicode_names_resource(&names))); resources.push(ImageResource::new(crate::channel_map::DISPLAY_INFO, crate::channel_map::display_info(&extra, has_alpha))); - resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers(extra.len()))); } if let Some(id) = quick_mask_id { let mut data = id.to_be_bytes().to_vec(); @@ -1827,10 +1828,6 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c if !keep_imported_resource(doc, *id, data) { continue; } - // A fresh 1053 was written with the extra channels. A preserved copy would be a second one. - if *id == crate::channel_map::ALPHA_IDENTIFIERS && !extra.is_empty() { - continue; - } let mut r = ImageResource::new(*id, data.to_vec()); r.name = legacy_name(name); resources.push(r); @@ -1881,7 +1878,7 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c resources, layer_info, layer_info_placement: placement, - global_layer_mask: (has_layers || !global_blocks.is_empty()).then(GlobalLayerMask::photoshop_default), + global_layer_mask: (has_layers || !global_blocks.is_empty()).then(GlobalLayerMask::default), global_blocks, layer_mask_trailing: Vec::new(), image_data, @@ -1958,6 +1955,69 @@ mod tests { assert!(back.layers.len() == 1 && bg.name == "Background" && bg.locks.transparency && bg.locks.position, "{:?}", bg.locks); } + /// A layered document with a spot and an alpha channel. Each channel holds 100 %, 25 %, 75 % + /// and 0 % in four columns, the layout of the Photoshop spot oracles. + fn spot_and_alpha_document() -> Document { + let mut doc = document(4, 1); + doc.layers.push(Layer::group("Group", vec![Layer::raster("Layer 1", doc.pixel_format())])); + let channel = |name: &str| { + let mut s = Surface::new(PixelFormat::GRAY8); + s.write_interleaved(doc.bounds(), &[255, 64, 191, 0]); + photocraft_doc::AlphaChannel::new(name, s) + }; + let mut spot = channel("Spot Color 1"); + spot.spot = Some((photocraft_doc::Color::rgb(0.0, 0.6, 1.0), 0.0)); + let alpha = channel("Alpha 1"); + doc.channels.extend([spot, alpha]); + doc + } + + /// Photoshop's spot polarity is for the layered TIFF only: a PSD stores a spot plane and an + /// alpha plane straight (255 = solid ink, 255 = selected) as before, so files saved by earlier + /// versions and this one read the same. It writes no resource 1053, an empty global layer + /// mask, and flag bit 3 on the layers but not on the group's closing divider. Opening it gives + /// the same ink back. + #[test] + fn psd_stores_spot_and_alpha_planes_straight() { + let doc = spot_and_alpha_document(); + let written = |photoshop_spot_polarity| { + let opts = PsdExportOptions { photoshop_spot_polarity, ..Default::default() }; + PsdFile::from_bytes(&document_to_psd_with(&doc, &opts).0.to_bytes().unwrap()).unwrap() + }; + let extra_planes = |file: &PsdFile| { + let planes = file.decode_merged().unwrap(); + planes[planes.len() - 2 * 4..].to_vec() + }; + let file = written(false); + assert_eq!(extra_planes(&file), [255, 64, 191, 0, 255, 64, 191, 0], "spot, then alpha"); + assert!(file.resource(crate::channel_map::ALPHA_IDENTIFIERS).is_none()); + assert_eq!(file.global_layer_mask.as_ref().map(|m| m.data.len()), Some(0)); + let flags: Vec = file.layers().iter().map(|l| l.flags.0 & LayerFlags::BIT4_USEFUL).collect(); + assert_eq!(flags, [0, LayerFlags::BIT4_USEFUL, LayerFlags::BIT4_USEFUL], "closing divider, layer, group"); + let back = crate::import("spot.psd", &file.to_bytes().unwrap()).unwrap().document; + assert!(back.channels[0].spot.is_some() && back.channels[1].spot.is_none()); + for c in &back.channels { + assert_eq!(c.surface.to_interleaved(back.bounds()), [255, 64, 191, 0], "{}", c.name); + } + // The layered TIFF's switch inverts the spot plane only. + assert_eq!(extra_planes(&written(true)), [0, 191, 64, 255, 255, 64, 191, 0]); + } + + /// Resource 1053 (alpha identifiers, in every Photoshop file with an extra channel) is kept + /// from an opened PSD and written back unchanged, as before. + #[test] + fn psd_alpha_identifiers_survive_open_and_save() { + let mut file = document_to_psd(&spot_and_alpha_document()); + let ids = [0, 0, 0, 3, 0, 0, 0, 2]; + file.resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, ids.to_vec())); + let opened = crate::import("ps.psd", &file.to_bytes().unwrap()).unwrap().document; + let saved = crate::export(&opened, "x.psd", &crate::ExportOptions::default()).unwrap(); + let again = PsdFile::from_bytes(&saved.bytes).unwrap(); + let kept: Vec<&ImageResource> = again.resources.iter().filter(|r| r.id == crate::channel_map::ALPHA_IDENTIFIERS).collect(); + assert_eq!(kept.len(), 1); + assert_eq!(kept[0].data, ids); + } + #[test] fn group_divider_id_wraps_without_colliding_with_imported_layer_ids() { let mut doc = document(8, 8); diff --git a/crates/io/src/psd_import.rs b/crates/io/src/psd_import.rs index 82f998143b..cf7c522e41 100644 --- a/crates/io/src/psd_import.rs +++ b/crates/io/src/psd_import.rs @@ -751,7 +751,16 @@ pub fn psd_to_document(file: &PsdFile) -> (Document, Vec) { /// [`psd_to_document`] for a background open: checks `ctl` per layer record and reports /// progress. `None` when cancelled. pub fn psd_to_document_with(file: &PsdFile, ctl: &photocraft_raster::Interrupt) -> Option<(Document, Vec)> { - psd_to_document_decoded(file, ctl, None) + psd_to_document_decoded(file, ctl, None, PsdImportOptions::default()) +} + +/// Options for [`psd_to_document_decoded`]. +#[derive(Debug, Clone, Copy, Default)] +pub(crate) struct PsdImportOptions { + /// Read spot channels as Photoshop's TIFFs store them, 0 = solid ink (see + /// [`crate::channel_map::photoshop_spot_plane`]). Only the layered TIFF sets it: a PSD's spot + /// planes are read as the document's density, as earlier versions saved them. + pub photoshop_spot_polarity: bool, } /// Whether the import reads the merged composite: for a flattened or multichannel file (it *is* @@ -776,6 +785,7 @@ pub(crate) fn psd_to_document_decoded( file: &PsdFile, ctl: &photocraft_raster::Interrupt, decoded: Option>>, + opts: PsdImportOptions, ) -> Option<(Document, Vec)> { let h = &file.header; let mut warnings = Vec::new(); @@ -832,10 +842,6 @@ pub(crate) fn psd_to_document_decoded( doc.clipping_path = Some(photocraft_doc::ClippingPath { name, flatness: 0.0 }); doc.metadata.psd_resources.push((r.id, String::from_utf8_lossy(&r.name).into_owned(), Arc::new(r.data.clone()))); } - // Resource 1053 is rewritten from the extra channels on a layered save, so keeping - // the copy just written would show up as new metadata. Multichannel has no such - // rewrite: the imported bytes are the channel ids, copied back when they still match. - crate::channel_map::ALPHA_IDENTIFIERS if !multichannel => {} id if MAPPED_RESOURCES.contains(&id) => {} id => doc.metadata.psd_resources.push((id, String::from_utf8_lossy(&r.name).into_owned(), Arc::new(r.data.clone()))), } @@ -1052,28 +1058,25 @@ pub(crate) fn psd_to_document_decoded( { let first = cc + usize::from(file.merged_has_alpha()); let names = file.resource(1045).map(|r| unicode_names(&r.data)).unwrap_or_default(); - let extra_n = usize::from(h.channels).saturating_sub(first); // Photoshop lists every extra channel, the merged transparency first when there is one. let skip = usize::from(file.merged_has_alpha() && names.len() == usize::from(h.channels).saturating_sub(cc)); - let names = names.get(skip..).unwrap_or(&[]); - // Spot planes are ink-inverted in the file (0 = solid). Alpha planes are not. - // DisplayInfo lists the transparency record first when `skip` is 1. - let spots = { - let n = extra_n.saturating_add(skip); - let all = if let Some(r) = file.resource(crate::channel_map::DISPLAY_INFO) { - crate::channel_map::spot_flags(&r.data, true, n) - } else if let Some(r) = file.resource(crate::channel_map::DISPLAY_INFO_OLD) { - crate::channel_map::spot_flags(&r.data, false, n) - } else { - vec![false; n] - }; - all.into_iter().skip(skip).collect::>() + let names = names.get(skip..).unwrap_or_default(); + // Which planes hold spot ink in Photoshop's polarity: the DisplayInfo records the + // channel options are read from below, the transparency's first when `skip` is 1. + let photoshop_spots = if !opts.photoshop_spot_polarity { + Vec::new() + } else if let Some(r) = file.resource(crate::channel_map::DISPLAY_INFO) { + crate::channel_map::spot_flags(&r.data, true, skip) + } else if let Some(r) = file.resource(crate::channel_map::DISPLAY_INFO_OLD) { + crate::channel_map::spot_flags(&r.data, false, skip) + } else { + Vec::new() }; for (k, idx) in (first..usize::from(h.channels)).enumerate() { let Some(p) = merged_plane(all, idx, plane) else { break }; let mut raw = be_to_ne_plane(p, depth, n); - if spots.get(k).copied().unwrap_or(false) { - crate::pixels::invert_plane(&mut raw, depth, false); + if photoshop_spots.get(k).copied().unwrap_or(false) { + crate::channel_map::photoshop_spot_plane(&mut raw, depth); } let mut s = Surface::new(cx.mask_fmt); s.write_interleaved(canvas, &raw); diff --git a/crates/io/src/tiff_layers.rs b/crates/io/src/tiff_layers.rs index 826c1557f7..932d88c82b 100644 --- a/crates/io/src/tiff_layers.rs +++ b/crates/io/src/tiff_layers.rs @@ -21,7 +21,7 @@ use photocraft_raster::Surface; use crate::flat::{csample, encode_image, image_to_document, layout_for, single_layer, try_buffer}; use crate::psd_export::PsdExportOptions; -use crate::psd_import::psd_to_document; +use crate::psd_import::{PsdImportOptions, psd_to_document_decoded}; use crate::{ExportOptions, ExportResult, ImportResult, IoError}; /// `true` when saving `doc` as TIFF writes layer data: anything beyond a single Background @@ -130,8 +130,13 @@ pub(crate) fn import_layered(name: &str, img: &Image, layers: &[u8]) -> Result 0 { - resources.retain(|r| r.id != crate::channel_map::ALPHA_IDENTIFIERS); - // Photoshop's spot TIFF (RGB, Save Transparency off) stores identifier 3: the spot's - // index among the IFD samples, not a 1-based count of user channels. - let first = u32::try_from(cc.saturating_add(usize::from(write_alpha))).unwrap_or(u32::MAX); - resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers_from(first, kept))); + resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers(kept))); } // Resource 1022 names a channel of the PSD merged image, which counts the transparency plane. // The IFD below does not, so the id moves back by one. @@ -371,6 +375,10 @@ fn tiff_image_source(doc: &Document, file: &photocraft_psd::PsdFile) -> ImageSou } if let Some(info) = &mut isd.layer_info { for layer in &mut info.layers { + // Photoshop sets flag bit 3 on every record it writes, group dividers included (299 of + // the 305 dividers in the corpus's Photoshop files). PhotoCraft's PSDs set it on + // layers only, unchanged here. + layer.flags.0 |= photocraft_psd::layer::LayerFlags::BIT4_USEFUL; photoshop_layer_blocks(&mut layer.blocks); } } @@ -577,9 +585,8 @@ fn channel_plane(channel: &AlphaChannel, canvas: Rect, sample: CSample) -> Resul if bytes.len() != expect { return Err(format!("channel \"{}\" does not cover the canvas", channel.name)); } - // Document density is 1 = solid ink. Photoshop's TIFF stores the opposite for a spot. if channel.spot.is_some() { - crate::pixels::invert_plane(&mut bytes, depth, false); + crate::channel_map::photoshop_spot_plane(&mut bytes, depth); } if sample == CSample::F16 { let mut out = Vec::with_capacity(n.saturating_mul(2)); @@ -784,8 +791,7 @@ pub(crate) fn stamp_flat_channels(doc: &Document, img: &mut Image) -> Vec img.meta.photoshop_resources = Some(bytes), Err(e) => warnings.push(format!("spot channel options were not written to the TIFF: {e}")), } @@ -794,7 +800,7 @@ pub(crate) fn stamp_flat_channels(doc: &Document, img: &mut Image) -> Vec, names: &[&str], channels: &[&AlphaChannel], quick_id: Option, first_id: u32) -> Result, IoError> { +fn channel_resources(existing: Option<&[u8]>, names: &[&str], channels: &[&AlphaChannel], quick_id: Option) -> Result, IoError> { let mut resources = match existing.filter(|b| !b.is_empty()) { Some(b) => resources_from_bytes(b)?.0, None => Vec::new(), @@ -805,7 +811,7 @@ fn channel_resources(existing: Option<&[u8]>, names: &[&str], channels: &[&Alpha resources.push(ImageResource::new(1006, crate::psd_export::pascal_names_resource(names))); resources.push(ImageResource::new(1045, crate::psd_export::unicode_names_resource(names))); resources.push(ImageResource::new(crate::channel_map::DISPLAY_INFO, crate::channel_map::display_info(channels, false))); - resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers_from(first_id, names.len()))); + resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers(names.len()))); if let Some(id) = quick_id { let mut data = id.to_be_bytes().to_vec(); data.push(0); @@ -834,19 +840,18 @@ pub(crate) fn channels_from_extras(doc: &mut Document, img: &Image) -> Vec { let name = names.get(k).cloned().filter(|s| !s.is_empty()).unwrap_or_else(|| format!("Alpha {}", k + 1)); doc.channels.push(AlphaChannel::new(name, surface)); @@ -877,8 +882,8 @@ pub(crate) fn channels_from_extras(doc: &mut Document, img: &Image) -> Vec Result { +/// `photoshop_spot`: the sample is a spot channel in Photoshop's polarity (0 = solid ink). +fn mask_from_plane(data: &[u8], w: u32, h: u32, n: usize, from: CSample, depth: SampleType, photoshop_spot: bool) -> Result { let rect = Rect::new(0, 0, w as i32, h as i32); let mut bytes = match (from, depth) { (CSample::U8, SampleType::U8) | (CSample::U16, SampleType::U16) | (CSample::F32, SampleType::F32) => { @@ -900,8 +905,8 @@ fn mask_from_plane(data: &[u8], w: u32, h: u32, n: usize, from: CSample, depth: } _ => return Err(format!("an extra TIFF sample ({from:?}) does not match the document depth and was dropped")), }; - if invert { - crate::pixels::invert_plane(&mut bytes, depth, false); + if photoshop_spot { + crate::channel_map::photoshop_spot_plane(&mut bytes, depth); } if bytes.len() != n.saturating_mul(depth.bytes()) { return Err("an extra TIFF sample did not match the image and was dropped".into()); diff --git a/crates/io/tests/tiff_layers.rs b/crates/io/tests/tiff_layers.rs index f19ccff7dc..49f0076728 100644 --- a/crates/io/tests/tiff_layers.rs +++ b/crates/io/tests/tiff_layers.rs @@ -532,7 +532,7 @@ fn dtf_like_spot_is_written_in_full() { assert_eq!(info.len(), 17, "{name}"); assert_eq!(u16::from_be_bytes([info[14], info[15]]), 60, "{name} solidity"); assert_eq!(info[16], 2, "{name} spot kind"); - // RGB occupies samples 0..2, so the spot's identifier is 3. + // Photoshop numbers a new document's channels from 3. assert_eq!(block(1053).data, 3u32.to_be_bytes(), "{name} channel id"); let back = import("dtf.tif", &r.bytes).unwrap().document; @@ -665,7 +665,7 @@ fn ink(d: &Document) -> (f32, f32) { fn photoshop_transparency_and_spot_tiff(doc: &Document, layers: bool) -> Vec { use photocraft_psd::{Compression, TaggedBlock}; - let opts = PsdExportOptions { merged_matte: false, merged_compression: Compression::Raw, ..Default::default() }; + let opts = PsdExportOptions { merged_matte: false, merged_compression: Compression::Raw, photoshop_spot_polarity: true, ..Default::default() }; let (file, _) = document_to_psd_with(doc, &opts); let planes = file.decode_merged().unwrap(); let n = 16; @@ -850,7 +850,8 @@ fn assert_photoshop_layered_tiff(bytes: &[u8], with_spot: bool) { /// Photoshop 27's Kato-Karate TIFF stores spot ink inverted: every non-white artwork pixel /// has spot 0, and the white background is spot 255. An alpha channel is the other way -/// around (255 = selected). Both polarities round-trip, in TIFF and in PSD. +/// around (255 = selected). A PSD keeps storing both planes straight, as earlier versions did, +/// and a TIFF opened and saved as PSD does the same. Everything round-trips. #[test] fn spot_ink_is_stored_as_zero_and_alpha_is_not() { use photocraft_color::{Color, PixelFormat}; @@ -890,10 +891,9 @@ fn spot_ink_is_stored_as_zero_and_alpha_is_not() { let first = 3 + usize::from(file.merged_has_alpha()); let spot_plane = &merged[first * plane..(first + 1) * plane]; let alpha_plane = &merged[(first + 1) * plane..(first + 2) * plane]; - // Background (0,0) and artwork (3,3). Spot: 0 = solid ink, max = paper. - // Alpha: max = selected, 0 = empty. - assert_stored(spot_plane, 0, depth, false, "psd spot background"); - assert_stored(spot_plane, (3 * w as usize + 3) * bps, depth, true, "psd spot art"); + // Background (0,0) and artwork (3,3), both straight: max = solid ink, max = selected. + assert_stored(spot_plane, 0, depth, true, "psd spot background"); + assert_stored(spot_plane, (3 * w as usize + 3) * bps, depth, false, "psd spot art"); assert_stored(alpha_plane, 0, depth, true, "psd alpha background"); assert_stored(alpha_plane, (3 * w as usize + 3) * bps, depth, false, "psd alpha art"); let back = import("pol.psd", &psd.bytes).unwrap().document; @@ -916,6 +916,11 @@ fn spot_ink_is_stored_as_zero_and_alpha_is_not() { let back = import("pol.tif", &r.bytes).unwrap().document; assert_eq!(back.channels[0].surface.to_interleaved(area), doc.channels[0].surface.to_interleaved(area), "{layers}"); assert_eq!(back.channels[1].surface.to_interleaved(area), doc.channels[1].surface.to_interleaved(area), "{layers}"); + // Saved as PSD: straight planes, and no 1053 (the TIFF's isn't kept on open). + let psd = PsdFile::from_bytes(&export(&back, "pol.psd", &ExportOptions::default()).unwrap().bytes).unwrap(); + let again = psd.decode_merged().unwrap(); + assert_eq!(again[again.len() - 2 * plane..], merged[(first * plane)..(first + 2) * plane], "{layers} tiff to psd"); + assert!(psd.resource(1053).is_none(), "{layers} tiff to psd"); } } } From 3db1ae122335d2313400303a63459ff5f1122512 Mon Sep 17 00:00:00 2001 From: Jason D Date: Wed, 21 Oct 2026 14:56:01 -0400 Subject: [PATCH 212/649] docs: regenerate the scorecard for TIFF channels FILE-215-7 (layered TIFF) done, FILE-215-17 (spot plates) partial. Co-Authored-By: Claude Opus 5.5 --- docs/scorecard.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/scorecard.md b/docs/scorecard.md index 42ae824b4d..f92ff987b2 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -7,7 +7,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js | Area | Done | Partial | Missing | Key numbers | |---|---:|---:|---:|---| | [Performance](#performance) | 3 | 22 | 25 | 59 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 20 not run, 5 not measurable yet (baseline 2026-10-05) | -| [File compatibility](#file-compatibility) | 7 | 14 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | +| [File compatibility](#file-compatibility) | 8 | 14 | 5 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 | | [Tools](#tools) | 33 | 11 | 0 | | | [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 170 (target 0) | | [Type](#type) | 4 | 3 | 2 | | @@ -107,7 +107,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t | FILE-215-4 | Adjustments (Hue/Sat + Colorize, Curves, Levels, Shadows/Highlights) apply as Smart Filters | done | [#215](https://github.com/storytold/photocraft/issues/215) | Image › Adjustments on a smart object records image.adjustments. as a smart filter (adjust_cmds.rs adjust_as_smart_filter; the selection becomes the filter mask), re-rendered from the source by adjust_as_filter and re-editable with layer.smartFilter.setParams; PSD maps Levels/Curves/Shadows-Highlights both ways (smart_map.rs). Opening the editor from the smart-filter row is FILE-215-5's row work | | FILE-215-5 | Smart Filter rows: collapse, mask thumb, blend icon, drag reorder, context menu, live preview | partial | [#215](https://github.com/storytold/photocraft/issues/215) | smart_ui.rs:31 rows + visibility + editor; no collapse, drag or context menu | | FILE-215-6 | Smart Object corner skew and perspective (quad or homography transform) | done | [#215](https://github.com/storytold/photocraft/issues/215) | #426: SmartObject.perspective holds the projective map (transform keeps its affine approximation); Distort / Perspective on a smart object set it (transform_cmds.rs, smart_cmds::set_placement), it re-renders from the source through the homography, Warp composes with it, and the PSD placement reads and writes nonAffineTransform / Trnf (io/blocks.rs placed_projective, smart_map.rs); tests distort_survives_edit_contents, warp_on_a_distorted_smart_object_follows_the_corners, placement survives the save | -| FILE-215-7 | Layered TIFF read and write (tag 37724), honouring the ask-before-saving pref | partial | [#215](https://github.com/storytold/photocraft/issues/215) | psd tiff.rs (ImageSourceData, both byte orders), io tiff_layers.rs, ui tiff_options_ui.rs (Discard Layers and Save a Copy); extra alpha channels and a Quick Mask are not written (the TIFF codec holds one transparency sample) | +| FILE-215-7 | Layered TIFF read and write (tag 37724), honouring the ask-before-saving pref | done | [#215](https://github.com/storytold/photocraft/issues/215) | psd tiff.rs (ImageSourceData, both byte orders), io tiff_layers.rs, ui tiff_options_ui.rs (Discard Layers and Save a Copy); extra alpha/spot channels and a Quick Mask are written as TIFF extra samples (at most 16) plus Photoshop resources for name, colour and solidity; Photoshop's MTrn marker is read (#7415). The TIFF Options Save Transparency choice isn't offered: channels are written as Photoshop does with it off | | FILE-215-8 | Large and BigTIFF import with banded decode across all IFDs | done | [#215](https://github.com/storytold/photocraft/issues/215) | codecs tiff_ifd.rs (bounds-checked IFD chain + SubIFD walk, classic and BigTIFF, cycle-safe; tiff_info / decode_tiff_page), tiff.rs banded parallel strip/tile decode, planar 1 and 2, BigTIFF write (tiff_bigtiff or > 4 GiB); io import_tiff_page; 30 MP RGB8 Deflate 345 -> 32 ms; no page picker in the UI yet | | FILE-215-9 | SVG opens and places as shape layers or a vector Smart Object | done | [#215](https://github.com/storytold/photocraft/issues/215) | io svg.rs: paths, groups, text outlines as shape layers (gradients approximated; clip/mask/filter/pattern/image subtrees rasterised); smart_cmds.rs renders an SVG source at its placement scale | | FILE-215-10 | Multi-page PDF save, PDF presentation, layer comps to PDF, vector/text output, PDF import | partial | [#215](https://github.com/storytold/photocraft/issues/215) | io pdf.rs: Save As / Save a Copy / CLI write one flattened RGB/Gray/CMYK page with ICC (#3401); print PDFs in print_cmds. Multi-page save, presentation, comps, vector/text output and PDF import (#2541) remain | @@ -117,7 +117,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t | FILE-215-14 | User swatch model with ACO/ASE import and export | done | [#215](https://github.com/storytold/photocraft/issues/215) | engine presets/swatches.rs (RGB/HSB/CMYK/Lab/Gray + verbatim colour books, persisted in prefs) + swatch_cmds.rs (swatches.*); psd aco.rs (v1/v2) and ase.rs (groups, spot/global) read+write; ui swatches_ui.rs, Color Picker Add to Swatches | | FILE-215-15 | Layer Style contour picker, curve editor, presets, .shc import/export | partial | [#2912](https://github.com/storytold/photocraft/issues/2912) | Layer Style dialog: contour thumbnail + preset picker (12 standard shapes, own control points) and Anti-aliased on Drop/Inner Shadow, Outer/Inner Glow, Satin, Bevel Gloss Contour and Contour element; Contour Editor (add/drag/delete, Corner, Input/Output, Preset, Load…/Save… .shc per Adobe's public spec, psd shc.rs); corner points render (compose contour_curve_lut) and map to PSD Cnty. Missing: a user contour library (New…, picker Load/Save/Replace Contours), Anti-aliased doesn't change the render yet, .shc not yet checked against a Photoshop-written file | | FILE-215-16 | Advanced Blending (knockout, blend as group, mask hides effects) end to end | partial | [#215](https://github.com/storytold/photocraft/issues/215) | doc advanced.rs + .pcraft + PSD/layered TIFF (knko infx clbl tsly lmgm vmgm), CPU compose advanced.rs (GPU falls back), blendingOptions command + dialog; 7 psd-tools knockout oracles now pass; knockout-isolated-groups (0.45 % AA edges), advanced-blending, blend-and-clipping still differ | -| FILE-215-17 | CMYK/RGB documents preview spot inks; spot plates export (TIFF extra samples, PDF) | missing | [#215](https://github.com/storytold/photocraft/issues/215) | compose multichannel.rs:1 spot preview for Multichannel only | +| FILE-215-17 | CMYK/RGB documents preview spot inks; spot plates export (TIFF extra samples, PDF) | partial | [#215](https://github.com/storytold/photocraft/issues/215) | TIFF: spot channels written and read as extra samples with DisplayInfo (1077) ink colour and solidity, ink stored 0 = solid (#7415). Missing: spot ink preview in RGB/CMYK documents (compose multichannel.rs:1 previews Multichannel only) and PDF Separation | | FILE-215-18 | Save for Web per-slice settings remembered; Export As remembers and offers nearest scaling | partial | [#215](https://github.com/storytold/photocraft/issues/215) | Save for Web settings survive a restart through the remembered dialog settings in prefs.dialogs (web_cmds::remember_web_settings stores them on a complete export, never the destination; file_ui.rs open_web seeds from the session's last export, else the preferences). export_dialog seeds Export As the same way (seed_remembered: format, quality, transparency, scale, metadata, TGA bits) and confirm remembers them as used. Missing: Export As nearest-neighbour scaling | | FILE-215-19 | Save As JPEG opens a JPEG Options dialog (quality 0-12, format options) | missing | [#215](https://github.com/storytold/photocraft/issues/215) | ExportSettings has jpeg_quality 1-100 only (lib.rs:118) | | FILE-215-20 | Artboard tool with handles and + buttons, Duplicate Artboard beside, vector PDF pages | partial | [#215](https://github.com/storytold/photocraft/issues/215) | artboard_tool.rs: Artboard tool draws, selects, moves and resizes boards by their handles (⇧ keeps proportions), its + buttons add a board or (⌥) a copy beside the selected one (#3033); Duplicate Artboard places the copy beside (#1584); raster PDF pages only | From 04211f3bf0a80441725ad7ea0f058723530f7ebc Mon Sep 17 00:00:00 2001 From: Jason D Date: Wed, 21 Oct 2026 18:12:41 -0400 Subject: [PATCH 213/649] io: leave the opaque-composite marker drop to the PSD export PR 2's psd_export already drops a kept merged-transparency marker when the composite is opaque. The layered TIFF still drops it when extra channels are stored, because there the composite keeps its transparency in the PSD model but the TIFF leaves that sample out of the IFD. Co-Authored-By: Claude Opus 5.5 --- crates/io/src/tiff_layers.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/io/src/tiff_layers.rs b/crates/io/src/tiff_layers.rs index 932d88c82b..4d9489d54a 100644 --- a/crates/io/src/tiff_layers.rs +++ b/crates/io/src/tiff_layers.rs @@ -369,8 +369,9 @@ fn tiff_image_source(doc: &Document, file: &photocraft_psd::PsdFile) -> ImageSou info.merged_alpha = false; } // A merged-transparency marker kept from an opened file (Photoshop's `MTrn`) would make the - // first spot read back as transparency: keep it only while the composite keeps that sample. - if spot_extras || !file.layer_info.as_ref().is_some_and(|l| l.merged_alpha) { + // first spot read back as transparency. The PSD export already drops it over an opaque + // composite; a transparent one keeps it there, but the TIFF leaves that sample out here. + if spot_extras { isd.global_blocks.retain(|b| !b.is_merged_transparency_marker()); } if let Some(info) = &mut isd.layer_info { From 8905fdccca1f8f918f46fe07b485e32a9ec6f96c Mon Sep 17 00:00:00 2001 From: David Mann Date: Thu, 22 Oct 2026 00:22:00 +0200 Subject: [PATCH 214/649] Integration: .asl gets its own Open filter, type.fillPath is a vector path (#4049, #6230) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - main's every_open_format_has_its_own_filter needs a named File › Open filter for every format: .asl (#4049) gets "Styles", as in Photoshop. - main's registry_filesystem_path_params_are_classified read type.fillPath's "path" (#6230) as a host file; it is a document vector path, like type.attachToPath. - docs: Type scorecard 5 / 4 / 1 in target-app-parity.md, 49 mapped smart filters in the scorecard. Co-Authored-By: Claude Opus 5.5 (1M context) --- apps/photocraft/src/services.rs | 1 + crates/automation/src/workspace.rs | 1 + docs/scorecard.md | 2 +- docs/target-app-parity.md | 2 +- scorecard/file_compat.toml | 2 +- 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/photocraft/src/services.rs b/apps/photocraft/src/services.rs index 57ecfdf4e0..2f02615329 100644 --- a/apps/photocraft/src/services.rs +++ b/apps/photocraft/src/services.rs @@ -70,6 +70,7 @@ const OPEN_FILTERS: &[(&str, &[&str])] = &[ ("Camera Raw", &["dng", "cr2", "cr3", "nef", "nrw", "arw", "pef", "orf", "rw2", "raf"]), ("Brushes", &["abr"]), ("Gradients", &["grd"]), + ("Styles", &["asl"]), ("Swatches", &["aco", "ase"]), ("Keyboard Shortcuts", &["kys"]), ]; diff --git a/crates/automation/src/workspace.rs b/crates/automation/src/workspace.rs index fca762a9c3..a9b0b6d8d8 100644 --- a/crates/automation/src/workspace.rs +++ b/crates/automation/src/workspace.rs @@ -925,6 +925,7 @@ mod tests { | "path.rename" | "path.stroke" | "type.attachToPath" + | "type.fillPath" | "type.detachFromPath" | "select.toWorkPath" | "layer.vectorMask.add" diff --git a/docs/scorecard.md b/docs/scorecard.md index 39d215bbd2..f4580ec088 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -103,7 +103,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t | Id | Target | Status | Issue | Note | |---|---|---|---|---| | FILE-215-1 | Smart Objects export as embedded Smart Objects (SoLd + lnk2), not flat pixels | done | [#215](https://github.com/storytold/photocraft/issues/215) | psd_export.rs smart_blocks: PlLd + SoLd, source in lnk2 (.pcraft -> PSB); engine tests/smart_psd.rs; Photoshop 2026 opens 8/16-bit exports as live smart objects. Linked files are embedded | -| FILE-215-2 | Smart Filters survive PSD save and re-open (filterFX descriptor read and written) | partial | [#215](https://github.com/storytold/photocraft/issues/215) | smart_map.rs: 41 filters plus Hue/Saturation, Perspective Warp, Filter Gallery (Chrome) and a verified Camera Raw subset mapped both ways, others kept verbatim, mask in FEid; io tests/smart_corpus.rs. PhotoCraft-only filters (Twirl, Liquify…) and unmapped Camera Raw settings are left out of filterFX with a warning | +| FILE-215-2 | Smart Filters survive PSD save and re-open (filterFX descriptor read and written) | partial | [#215](https://github.com/storytold/photocraft/issues/215) | smart_map.rs: 49 filters plus Hue/Saturation, Perspective Warp, Filter Gallery (Chrome) and a verified Camera Raw subset mapped both ways, others kept verbatim, mask in FEid; io tests/smart_corpus.rs. PhotoCraft-only filters (Twirl, Liquify…) and unmapped Camera Raw settings are left out of filterFX with a warning | | FILE-215-3 | Filter mask can be painted directly, with undo | missing | [#215](https://github.com/storytold/photocraft/issues/215) | smart_cmds.rs:382 mask only from the selection | | FILE-215-4 | Adjustments (Hue/Sat + Colorize, Curves, Levels, Shadows/Highlights) apply as Smart Filters | done | [#215](https://github.com/storytold/photocraft/issues/215) | Image › Adjustments on a smart object records image.adjustments. as a smart filter (adjust_cmds.rs adjust_as_smart_filter; the selection becomes the filter mask), re-rendered from the source by adjust_as_filter and re-editable with layer.smartFilter.setParams; PSD maps Levels/Curves/Shadows-Highlights both ways (smart_map.rs). Opening the editor from the smart-filter row is FILE-215-5's row work | | FILE-215-5 | Smart Filter rows: collapse, mask thumb, blend icon, drag reorder, context menu, live preview | partial | [#215](https://github.com/storytold/photocraft/issues/215) | smart_ui.rs:31 rows + visibility + editor; no collapse, drag or context menu | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index ff314305c9..124908ebdd 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -75,7 +75,7 @@ Weights reflect what a working Photoshop user depends on (photographers, retouch | Dimension | Weight | % ready | Remaining (agent-h) | Evidence | Detail | |---|---:|---:|---:|---|---| -| Features in depth (tools, layers, selections, type, filters, transforms) | 25% | 55% | 600–1,000 | Scorecard checklists: Tools 20 done / 15 partial / 6 missing, Type 4 / 4 / 2 (2026-10-15, area type partial), Automation 3 / 2 / 6. 14 tools missing; Select and Mask, Vanishing Point and Content-Aware Fill are parameter dialogs, not workspaces; type on a path partial; RTL paragraph direction UI and live Warp Text preview missing | [gaps.md](gaps.md) | +| Features in depth (tools, layers, selections, type, filters, transforms) | 25% | 55% | 600–1,000 | Scorecard checklists: Tools 20 done / 15 partial / 6 missing, Type 5 / 4 / 1 (2026-10-22, area type partial), Automation 3 / 2 / 6. 14 tools missing; Select and Mask, Vanishing Point and Content-Aware Fill are parameter dialogs, not workspaces; type on a path partial; RTL paragraph direction UI missing | [gaps.md](gaps.md) | | UI / UX fidelity and feel | 15% | 40% | 350–600 | ~150 open UI issues; Workspace checklist 13 / 5 / 5 (2026-10-12; 5 / 7 / 11 on 2026-10-10); 27 of 156 preferences do nothing (was 46 of 149); no floating panel groups, thin Color panel, brush lag and pressure jumps reported | [ui-parity.md](ui-parity.md), [brush-parity.md](brush-parity.md) | | File formats and fidelity | 15% | 60% | 300–500 | PSD oracle on Photoshop-authored files 133/256 (52%); io corpus 146/170 (86%); psd-tools 236/309 (76%); round trips ~100% of corpus; but users report Photoshop refusing our files (#1281, #2469; a text-layer case, #2374, was fixed 2026-10-10); no Photoshop PDF, EPS, JPEG 2000, JPEG XL, AVIF read, CR3 | [file-format-parity.md](file-format-parity.md) | | Performance | 10% | 25% | 200–350 | 3 of 25 budgeted scenarios meet budget (baseline 2026-10-05); 150-layer nudge crashes the GPU path (P12); layer move on 15000×10000 16-bit 2.7 s p50; users report brush and cursor lag (#2619, #2566, #1994) | [scorecard.md](scorecard.md#performance) | diff --git a/scorecard/file_compat.toml b/scorecard/file_compat.toml index 89211fb1da..1e15c8e598 100644 --- a/scorecard/file_compat.toml +++ b/scorecard/file_compat.toml @@ -17,7 +17,7 @@ id = "FILE-215-2" target = "Smart Filters survive PSD save and re-open (filterFX descriptor read and written)" status = "partial" issue = 215 -note = "smart_map.rs: 41 filters plus Hue/Saturation, Perspective Warp, Filter Gallery (Chrome) and a verified Camera Raw subset mapped both ways, others kept verbatim, mask in FEid; io tests/smart_corpus.rs. PhotoCraft-only filters (Twirl, Liquify…) and unmapped Camera Raw settings are left out of filterFX with a warning" +note = "smart_map.rs: 49 filters plus Hue/Saturation, Perspective Warp, Filter Gallery (Chrome) and a verified Camera Raw subset mapped both ways, others kept verbatim, mask in FEid; io tests/smart_corpus.rs. PhotoCraft-only filters (Twirl, Liquify…) and unmapped Camera Raw settings are left out of filterFX with a warning" [[item]] id = "FILE-215-3" From d26d34f9670b4412c01be707df66c5d99cf0d05a Mon Sep 17 00:00:00 2001 From: SBaksa Date: Thu, 22 Oct 2026 10:52:35 +1100 Subject: [PATCH 215/649] Raw: read floating-point JPEG XL raw data, as lossy DNGs store it (fixes #8125) A DNG converter's lossy output stores demosaiced LinearRaw as JPEG XL with SampleFormat 3 (floating point). The reader refused any floating-point raw data, so such a file opened its small preview instead ("floating-point raw data is not supported yet"). read_plane now accepts 16, 24 or 32-bit floats when they are JPEG XL compressed: jxl::decode reads them as f32 and scales them so the file's white level (default 1.0) becomes 65535, clipping outside 0..=65535. Plane carries that factor, and the DNG reader scales the stated black and white levels by it. Floating-point data in any other compression is still refused, now saying so. DngSpec gains raw_extra (extra raw-IFD entries) for the tests. --- crates/io/tests/raw.rs | 22 +++++++++++++++++ crates/raw/src/dng.rs | 12 +++++---- crates/raw/src/jxl.rs | 14 ++++++++--- crates/raw/src/nefc.rs | 4 +-- crates/raw/src/sensor.rs | 21 +++++++++++++--- crates/raw/src/sony.rs | 2 +- crates/raw/src/testgen.rs | 4 +++ crates/raw/tests/dng.rs | 51 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 115 insertions(+), 15 deletions(-) diff --git a/crates/io/tests/raw.rs b/crates/io/tests/raw.rs index 9a8a0798ca..27f4915ce6 100644 --- a/crates/io/tests/raw.rs +++ b/crates/io/tests/raw.rs @@ -22,6 +22,28 @@ fn dng_opens_as_16_bit_prophoto() { assert!(r.warnings.iter().any(|w| w.contains("DNG") && w.contains("ProPhoto")), "{:?}", r.warnings); } +/// #8125: a lossy DNG's floating-point LinearRaw data, JPEG XL-compressed, is developed (not +/// replaced by a preview). The test codestream is an integer one the reader takes as floats. +#[test] +fn floating_point_jpeg_xl_dng_is_developed() { + use photocraft_raw::testgen::DngStorage; + use zune_core::{bit_depth::BitDepth, colorspace::ColorSpace, options::EncoderOptions}; + let (w, h) = (24, 16); + let data: Vec = scene(w, h).iter().flat_map(|p| p.map(|v| (v * 20000.0) as u16)).collect(); + let bytes: Vec = data.iter().flat_map(|v| v.to_ne_bytes()).collect(); + let mut segment = Vec::new(); + zune_jpegxl::JxlSimpleEncoder::new(&bytes, EncoderOptions::new(w, h, ColorSpace::RGB, BitDepth::Sixteen)).encode(&mut segment).unwrap(); + let mut spec = DngSpec::cfa(w, h, data); + spec.samples = 3; + spec.white = 0; + spec.storage = DngStorage::JxlStrips { rows: h }; + spec.jxl_segments = vec![segment]; + spec.raw_extra = vec![(339, Val::Short(vec![3; 3]))]; + let r = import("lossy.dng", &spec.build()).unwrap(); + assert_eq!((r.document.size.width, r.document.size.height, r.document.depth), (24, 16, SampleType::U16)); + assert!(r.warnings.iter().all(|w| !w.contains("preview")), "{:?}", r.warnings); +} + /// #3497: a monochrome (one-sample LinearRaw) DNG, as VueScan writes film scans, opens as a /// 16-bit RGB document (neutral grey) instead of failing as unsupported. #[test] diff --git a/crates/raw/src/dng.rs b/crates/raw/src/dng.rs index e8422b5419..a17ab41a32 100644 --- a/crates/raw/src/dng.rs +++ b/crates/raw/src/dng.rs @@ -221,8 +221,10 @@ pub(crate) fn decode(t: &Tiff, limits: &Limits) -> Result { Some(l) => f32::from(l.iter().copied().max().unwrap_or(u16::MAX)), None => max, }; + // Floating-point levels are in the floats' units: scale them as the samples were. + let unit = plane.float_scale.unwrap_or(1.0); let wl = t.tag_floats(&raw, tag::WHITE_LEVEL); - let white = [0, 1, 2].map(|s| wl.get(s).or_else(|| wl.first()).map(|v| *v as f32).filter(|v| *v > 0.0).unwrap_or(white_default)); + let white = [0, 1, 2].map(|s| wl.get(s).or_else(|| wl.first()).map(|v| *v as f32 * unit).filter(|v| *v > 0.0).unwrap_or(white_default)); let (rows, cols) = match t.tag_uints(&raw, tag::BLACK_LEVEL_REPEAT_DIM).as_slice() { [r, c] if (1..=16).contains(r) && (1..=16).contains(c) => (*r as usize, *c as usize), @@ -230,17 +232,17 @@ pub(crate) fn decode(t: &Tiff, limits: &Limits) -> Result { }; let bl = t.tag_floats(&raw, tag::BLACK_LEVEL); let mut black = if bl.len() == rows * cols * samples { - BlackLevels { rows, cols, values: bl.iter().map(|v| *v as f32).collect(), delta_h: Vec::new(), delta_v: Vec::new() } + BlackLevels { rows, cols, values: bl.iter().map(|v| *v as f32 * unit).collect(), delta_h: Vec::new(), delta_v: Vec::new() } } else { - BlackLevels::uniform(bl.first().copied().unwrap_or(0.0) as f32) + BlackLevels::uniform(bl.first().copied().unwrap_or(0.0) as f32 * unit) }; let dh = t.tag_floats(&raw, tag::BLACK_LEVEL_DELTA_H); if dh.len() == active.width { - black.delta_h = dh.iter().map(|v| *v as f32).collect(); + black.delta_h = dh.iter().map(|v| *v as f32 * unit).collect(); } let dv = t.tag_floats(&raw, tag::BLACK_LEVEL_DELTA_V); if dv.len() == active.height { - black.delta_v = dv.iter().map(|v| *v as f32).collect(); + black.delta_v = dv.iter().map(|v| *v as f32 * unit).collect(); } let color = color_info(t, &ifd0); diff --git a/crates/raw/src/jxl.rs b/crates/raw/src/jxl.rs index 0717dbb3cd..5eec769211 100644 --- a/crates/raw/src/jxl.rs +++ b/crates/raw/src/jxl.rs @@ -18,14 +18,15 @@ use crate::error::{RawError, Result}; /// The browser build has no JPEG XL decoder (see the module docs). #[cfg(target_arch = "wasm32")] -pub(crate) fn decode(_src: &[u8], _w: usize, _h: usize, _samples: usize, _bits: u32, _limits: &Limits) -> Result> { +pub(crate) fn decode(_src: &[u8], _w: usize, _h: usize, _samples: usize, _bits: u32, _float_scale: Option, _limits: &Limits) -> Result> { Err(RawError::unsupported("JPEG XL-compressed DNG (DNG 1.7) can't be opened in the browser version of PhotoCraft; open it in the desktop app")) } /// Decodes one segment into `w * h * samples` interleaved samples at `bits` per sample (the -/// TIFF BitsPerSample, which DNG requires the codestream's bit depth to match). +/// TIFF BitsPerSample, which DNG requires the codestream's bit depth to match). Floating-point +/// samples (SampleFormat 3) come back multiplied by `float_scale`, clipped to 0..=65535. #[cfg(not(target_arch = "wasm32"))] -pub(crate) fn decode(src: &[u8], w: usize, h: usize, samples: usize, bits: u32, limits: &Limits) -> Result> { +pub(crate) fn decode(src: &[u8], w: usize, h: usize, samples: usize, bits: u32, float_scale: Option, limits: &Limits) -> Result> { limits.check(w as u64, h as u64, samples as u64 * 2)?; // jxl-oxide decodes into f32/i32 planes: allow a few times the output size, and never more // than the caller's per-buffer limit. @@ -50,6 +51,13 @@ pub(crate) fn decode(src: &[u8], w: usize, h: usize, samples: usize, bits: u32, return Err(RawError::unsupported("rotated JPEG XL raw tile")); } let n = w.checked_mul(h).and_then(|p| p.checked_mul(samples)).ok_or_else(|| RawError::malformed("JPEG XL raw tile is too large"))?; + if let Some(scale) = float_scale { + let mut f = vec![0f32; n]; + if stream.write_to_buffer(&mut f) != n { + return Err(RawError::malformed("JPEG XL raw data is truncated")); + } + return Ok(f.into_iter().map(|v| if v.is_nan() { 0 } else { (v * scale).clamp(0.0, 65535.0).round() as u16 }).collect()); + } let mut out = vec![0u16; n]; if stream.write_to_buffer(&mut out) != n { return Err(RawError::malformed("JPEG XL raw data is truncated")); diff --git a/crates/raw/src/nefc.rs b/crates/raw/src/nefc.rs index db1f8b1d74..2ae312917d 100644 --- a/crates/raw/src/nefc.rs +++ b/crates/raw/src/nefc.rs @@ -69,7 +69,7 @@ pub(crate) fn read_packed(t: &Tiff, ifd: &Ifd, bits: u32, limits: &Limits) -> Re }; let src = t.bytes(*off as usize, *len as usize).ok_or_else(|| RawError::malformed("packed NEF strip lies outside the file"))?; let data = unpack_little_rows(src, w, h, bits)?; - Ok(Plane { width: w, height: h, samples: 1, bits, data }) + Ok(Plane { width: w, height: h, samples: 1, bits, data, float_scale: None }) } fn unpack_little_rows(src: &[u8], w: usize, h: usize, bits: u32) -> Result> { @@ -377,7 +377,7 @@ pub(crate) fn read_compressed(t: &Tiff, raw: &Ifd, note: Option<&(Tiff, Ifd)>, l let end = (last as usize).saturating_add(last_len as usize).min(t.data.len()); let src = t.data.get(start..end).filter(|s| !s.is_empty()).ok_or_else(|| RawError::malformed("raw data lies outside the file"))?; let data = decode(src, width, height, bits, &table)?; - Ok(Plane { width, height, samples: 1, bits, data }) + Ok(Plane { width, height, samples: 1, bits, data, float_scale: None }) } #[cfg(test)] diff --git a/crates/raw/src/sensor.rs b/crates/raw/src/sensor.rs index 8defea86ca..f45ba8738e 100644 --- a/crates/raw/src/sensor.rs +++ b/crates/raw/src/sensor.rs @@ -189,6 +189,9 @@ pub(crate) struct Plane { pub samples: usize, pub bits: u32, pub data: Vec, + /// For floating-point samples, the factor they were multiplied by (their white level becomes + /// 65535, `bits` is then 16): the file's black and white levels are scaled by it too. + pub float_scale: Option, } pub(crate) struct Segment { @@ -237,9 +240,19 @@ pub(crate) fn read_plane(t: &Tiff, ifd: &Ifd, limits: &Limits, layout: JpegLayou if !(1..=4).contains(&samples) { return Err(RawError::unsupported(format!("{samples} samples per pixel"))); } - if t.tag_uint(ifd, tag::SAMPLE_FORMAT) == Some(3) { - return Err(RawError::unsupported("floating-point raw data")); + // Floating-point data is read when it is JPEG XL-compressed, as converters write lossy + // LinearRaw (DNG 1.7, #8125): 16, 24 or 32-bit floats, read as 16-bit samples. + let float = t.tag_uint(ifd, tag::SAMPLE_FORMAT) == Some(3); + if float && compression != JPEG_XL { + return Err(RawError::unsupported("floating-point raw data that isn't JPEG XL-compressed")); } + if float && !matches!(bits, 16 | 24 | 32) { + return Err(RawError::unsupported(format!("{bits}-bit floating-point raw samples"))); + } + let bits = if float { 16 } else { bits }; + // The floats' white level (default 1.0, DNG 1.7 WhiteLevel) becomes 65535. + let float_scale = + float.then(|| 65535.0 / t.tag_floats(ifd, tag::WHITE_LEVEL).first().map(|v| *v as f32).filter(|v| v.is_finite() && *v > 0.0).unwrap_or(1.0)); if !(1..=16).contains(&bits) { return Err(RawError::unsupported(format!("{bits}-bit raw samples"))); } @@ -288,7 +301,7 @@ pub(crate) fn read_plane(t: &Tiff, ifd: &Ifd, limits: &Limits, layout: JpegLayou // A JPEG XL segment codes only the rows inside the image (strips) or the whole tile. JPEG_XL => { let coded_rows = if tiled { s.h } else { rows }; - let mut v = jxl::decode(src, s.w, coded_rows, samples, bits, limits)?; + let mut v = jxl::decode(src, s.w, coded_rows, samples, bits, float_scale, limits)?; v.resize(s.w * s.h * samples, 0); Ok(v) } @@ -331,7 +344,7 @@ pub(crate) fn read_plane(t: &Tiff, ifd: &Ifd, limits: &Limits, layout: JpegLayou data[at..at + cols * samples].copy_from_slice(src); } } - Ok(Plane { width, height, samples, bits, data }) + Ok(Plane { width, height, samples, bits, data, float_scale }) } pub(crate) fn segments(t: &Tiff, ifd: &Ifd, width: usize, height: usize) -> Result> { diff --git a/crates/raw/src/sony.rs b/crates/raw/src/sony.rs index e1961680df..06919f62ee 100644 --- a/crates/raw/src/sony.rs +++ b/crates/raw/src/sony.rs @@ -143,7 +143,7 @@ pub(crate) fn read_craw(t: &Tiff, ifd: &Ifd, limits: &Limits) -> Result { } } }); - Ok(Plane { width, height, samples: 1, bits: 14, data }) + Ok(Plane { width, height, samples: 1, bits: 14, data, float_scale: None }) } #[cfg(test)] diff --git a/crates/raw/src/testgen.rs b/crates/raw/src/testgen.rs index 9d8b8fb94c..db43cc26bd 100644 --- a/crates/raw/src/testgen.rs +++ b/crates/raw/src/testgen.rs @@ -487,6 +487,8 @@ pub struct DngSpec { pub model: String, /// Extra IFD0 entries, written after the generated ones (e.g. malformed colour tags). pub ifd0_extra: Vec<(u16, Val)>, + /// Extra raw-IFD entries, written after the generated ones (e.g. SampleFormat). + pub raw_extra: Vec<(u16, Val)>, } impl DngSpec { @@ -524,6 +526,7 @@ impl DngSpec { make: "Photocraft".into(), model: "Synthetic".into(), ifd0_extra: Vec::new(), + raw_extra: Vec::new(), } } @@ -772,6 +775,7 @@ impl DngSpec { if let Some(l) = &self.linearization { raw.push((50712, Val::Short(l.clone()))); } + raw.extend(self.raw_extra.iter().cloned()); let raw_ifd = t.ifd(raw); // IFD0: a tiny RGB thumbnail plus the DNG metadata. let thumb = t.blob(vec![128; 3 * 4]); diff --git a/crates/raw/tests/dng.rs b/crates/raw/tests/dng.rs index 7cc04d2a92..71f9111865 100644 --- a/crates/raw/tests/dng.rs +++ b/crates/raw/tests/dng.rs @@ -685,6 +685,57 @@ fn jpeg_xl_linear_raw_develops() { assert_eq!(develop(&spec.build(), &DevelopOptions::default()).unwrap().rgb, d.rgb); } +/// A LinearRaw JPEG XL strip of `data` (16-bit samples) whose raw IFD says the samples are +/// floating-point (SampleFormat 3), as converters write lossy DNGs (#8125). The codestream is +/// an integer one (the test encoder writes no floats): the decoder reads it as floats in 0..=1, +/// the same values a float codestream of `data / 65535` holds. +fn float_jxl_dng(data: &[u16], w: usize, h: usize, white: Option) -> DngSpec { + let mut spec = DngSpec::cfa(w, h, data.to_vec()); + spec.samples = 3; + spec.white = 0; + spec.storage = DngStorage::JxlStrips { rows: h }; + spec.jxl_segments = vec![jxl(data, w, h, 3, 16)]; + spec.raw_extra = vec![(339, Val::Short(vec![3; 3]))]; + if let Some(white) = white { + spec.raw_extra.push((50717, Val::Double(vec![white; 3]))); + } + spec +} + +#[test] +fn floating_point_jpeg_xl_linear_raw_decodes() { + let (w, h) = (24, 16); + let data = noise(w * h * 3, 16); + // White level 1.0 (the default) becomes 65535: the samples read back as stored. + let s = sensor(&float_jxl_dng(&data, w, h, None).build()); + assert_eq!((s.width, s.height, s.samples), (w, h, 3)); + assert_eq!(s.data, data); + assert_eq!(s.white, [65535.0; 3]); + // A stated white level of 0.5 becomes 65535 too: samples double, those above it clip. + let s = sensor(&float_jxl_dng(&data, w, h, Some(0.5)).build()); + assert_eq!(s.white, [65535.0; 3]); + assert_eq!(s.data, data.iter().map(|&v| (u32::from(v) * 2).min(65535) as u16).collect::>()); + // It develops like the same samples stored as integers. + let pixels: Vec = scene(w, h).iter().flat_map(|p| p.map(|v| (v * 20000.0) as u16)).collect(); + let float = develop(&float_jxl_dng(&pixels, w, h, None).build(), &DevelopOptions::default()).unwrap(); + let mut ints = DngSpec::cfa(w, h, pixels.clone()); + ints.samples = 3; + ints.white = 65535; + ints.storage = DngStorage::Strips { rows: h }; + assert_eq!(float.rgb, develop(&ints.build(), &DevelopOptions::default()).unwrap().rgb); +} + +#[test] +fn floating_point_raw_data_that_isnt_jpeg_xl_is_unsupported() { + let (w, h) = (8, 4); + let mut spec = float_jxl_dng(&noise(w * h * 3, 16), w, h, None); + spec.storage = DngStorage::Strips { rows: h }; + match decode(&spec.build(), &Limits::default()) { + Err(RawError::Unsupported(m)) => assert!(m.contains("floating-point"), "{m}"), + other => panic!("expected unsupported, got {other:?}"), + } +} + #[test] fn jpeg_xl_mismatches_are_errors() { let (w, h) = (16, 8); From b79475b65bc4b8190a481c6be1dec72402d3bd7a Mon Sep 17 00:00:00 2001 From: SBaksa Date: Thu, 22 Oct 2026 12:16:46 +1100 Subject: [PATCH 216/649] Raw: charge a float JPEG XL tile's f32 buffer to the limits; try smaller JPEG XL previews when the largest doesn't decode Floating-point samples are read into four bytes each before they become 16-bit, but jxl::decode charged the limits for two. It now charges four. embedded_jxl_preview tried only the largest JPEG XL preview, so one over the limits or damaged left the import with the small JPEG thumbnail even when a smaller JPEG XL preview decodes. It now tries them from the largest down. --- crates/raw/src/jxl.rs | 4 +++- crates/raw/src/preview.rs | 12 ++++++----- crates/raw/tests/dng.rs | 44 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/crates/raw/src/jxl.rs b/crates/raw/src/jxl.rs index 5eec769211..8dc2ff064f 100644 --- a/crates/raw/src/jxl.rs +++ b/crates/raw/src/jxl.rs @@ -27,7 +27,9 @@ pub(crate) fn decode(_src: &[u8], _w: usize, _h: usize, _samples: usize, _bits: /// samples (SampleFormat 3) come back multiplied by `float_scale`, clipped to 0..=65535. #[cfg(not(target_arch = "wasm32"))] pub(crate) fn decode(src: &[u8], w: usize, h: usize, samples: usize, bits: u32, float_scale: Option, limits: &Limits) -> Result> { - limits.check(w as u64, h as u64, samples as u64 * 2)?; + // Floating-point samples are read into an f32 buffer first: four bytes a sample, not two. + let sample_bytes = if float_scale.is_some() { 4 } else { 2 }; + limits.check(w as u64, h as u64, samples as u64 * sample_bytes)?; // jxl-oxide decodes into f32/i32 planes: allow a few times the output size, and never more // than the caller's per-buffer limit. let budget = (w as u64).saturating_mul(h as u64).saturating_mul(samples as u64).saturating_mul(16).min(limits.max_alloc); diff --git a/crates/raw/src/preview.rs b/crates/raw/src/preview.rs index 489eea3b9e..9ff07c3115 100644 --- a/crates/raw/src/preview.rs +++ b/crates/raw/src/preview.rs @@ -120,8 +120,9 @@ pub struct DecodedPreview { /// DNG PreviewColorSpace (DNG Specification 1.7). const PREVIEW_COLOR_SPACE: u16 = 50970; -/// The largest JPEG XL-compressed RGB preview of a DNG, decoded within `limits`. `None` when the -/// file has none, or it doesn't decode (always in the browser build, which has no JPEG XL decoder). +/// The largest JPEG XL-compressed RGB preview of a DNG that decodes within `limits`: larger ones +/// that don't (over the limits, or damaged) give way to the next. `None` when none decodes +/// (always in the browser build, which has no JPEG XL decoder). pub fn embedded_jxl_preview(bytes: &[u8], limits: &Limits) -> Option { let t = Tiff::new(bytes)?; let ifd0 = t.ifd_at(t.first_ifd, 0)?; @@ -129,13 +130,14 @@ pub fn embedded_jxl_preview(bytes: &[u8], limits: &Limits) -> Option = t .all_ifds() .into_iter() .filter(|i| t.tag_uint(i, tag::NEW_SUBFILE_TYPE) == Some(1)) .filter(|i| t.tag_uint(i, tag::COMPRESSION) == Some(JPEG_XL) && t.tag_uint(i, tag::SAMPLES_PER_PIXEL) == Some(3)) - .max_by_key(area)?; - let plane = read_plane(&t, &ifd, limits, JpegLayout::Flat).ok()?; + .collect(); + previews.sort_by_key(|i| std::cmp::Reverse(area(i))); + let (ifd, plane) = previews.into_iter().find_map(|i| read_plane(&t, &i, limits, JpegLayout::Flat).ok().map(|p| (i, p)))?; let color_space = match t.tag_uint(&ifd, PREVIEW_COLOR_SPACE).or_else(|| t.tag_uint(&ifd0, PREVIEW_COLOR_SPACE)) { Some(2) => Some(PreviewColorSpace::Srgb), Some(3) => Some(PreviewColorSpace::AdobeRgb), diff --git a/crates/raw/tests/dng.rs b/crates/raw/tests/dng.rs index 71f9111865..c336c97484 100644 --- a/crates/raw/tests/dng.rs +++ b/crates/raw/tests/dng.rs @@ -736,6 +736,50 @@ fn floating_point_raw_data_that_isnt_jpeg_xl_is_unsupported() { } } +/// Floating-point samples are read into four bytes each before they become 16-bit: the limits +/// are charged for that buffer, not for the two-byte result. +#[test] +fn floating_point_jpeg_xl_is_charged_four_bytes_a_sample() { + let (w, h) = (24, 16); + let bytes = float_jxl_dng(&noise(w * h * 3, 16), w, h, None).build(); + let limits = Limits { max_alloc: (w * h * 3 * 2) as u64, ..Limits::default() }; + match decode(&bytes, &limits) { + Err(RawError::LimitExceeded(_)) => {} + other => panic!("expected the limits to refuse the f32 buffer, got {other:?}"), + } +} + +/// When the largest JPEG XL preview doesn't decode, the next largest is used. +#[test] +fn a_jpeg_xl_preview_that_does_not_decode_gives_way_to_a_smaller_one() { + use photocraft_raw::testgen::TiffBuilder; + let mut t = TiffBuilder::default(); + let preview = |t: &mut TiffBuilder, w: usize, h: usize, stream: Vec| { + let len = stream.len() as u32; + let strip = t.blob(stream); + t.ifd(vec![ + (254, Val::Long(vec![1])), + (256, Val::Long(vec![w as u32])), + (257, Val::Long(vec![h as u32])), + (258, Val::Short(vec![8, 8, 8])), + (259, Val::Short(vec![52546])), + (262, Val::Short(vec![2])), + (273, Val::Blobs(vec![strip])), + (277, Val::Short(vec![3])), + (278, Val::Long(vec![h as u32])), + (279, Val::Long(vec![len])), + ]) + }; + let small = noise(20 * 15 * 3, 8); + let damaged = preview(&mut t, 40, 30, vec![0xFF, 0x0A, 0, 0, 0, 0, 0, 0]); + let valid = preview(&mut t, 20, 15, jxl(&small, 20, 15, 3, 8)); + let ifd0 = t.ifd(vec![(254, Val::Long(vec![1])), (330, Val::Ifds(vec![damaged, valid])), (50706, Val::Byte(vec![1, 7, 0, 0]))]); + t.chain = vec![ifd0]; + let p = embedded_jxl_preview(&t.build(), &Limits::default()).expect("the 20×15 preview"); + assert_eq!((p.width, p.height, p.bits), (20, 15, 8)); + assert_eq!(p.rgb, small); +} + #[test] fn jpeg_xl_mismatches_are_errors() { let (w, h) = (16, 8); From 0635061b865e5c4e8ce63f24834f32f082577ee4 Mon Sep 17 00:00:00 2001 From: skylar taylor-barrick Date: Mon, 19 Oct 2026 13:58:58 -0600 Subject: [PATCH 217/649] fix(retouch): preserve Smudge pickup through live stroke release --- crates/engine/src/retouch_cmds.rs | 64 ++++++- crates/engine/tests/pr7281_adversarial.rs | 216 ++++++++++++++++++++++ crates/paint/src/retouch.rs | 8 +- crates/ui-egui/src/stroke_timing_tests.rs | 56 ++++++ 4 files changed, 333 insertions(+), 11 deletions(-) create mode 100644 crates/engine/tests/pr7281_adversarial.rs diff --git a/crates/engine/src/retouch_cmds.rs b/crates/engine/src/retouch_cmds.rs index 152e4733b5..db47fcacec 100644 --- a/crates/engine/src/retouch_cmds.rs +++ b/crates/engine/src/retouch_cmds.rs @@ -992,6 +992,37 @@ enum DabTool { /// One dab's edit of the working copy. pub(crate) type DabEffect = Box; +/// Pixels an effect reads beyond the dab it writes. Smudge's pickup is a fixed-size square, +/// independent of pressure, roundness and the dab's current angle. +#[derive(Clone, Copy)] +enum DabNeighborhood { + Halo(i32), + Smudge(i32), +} + +impl DabNeighborhood { + fn halo(self) -> i32 { + match self { + Self::Halo(radius) | Self::Smudge(radius) => radius, + } + } + + fn read_rect(self, rect: Rect, dab: &photocraft_paint::Dab) -> Rect { + match self { + Self::Halo(radius) => rect.inflate(radius), + Self::Smudge(radius) => { + let (x, y) = (dab.center.x.floor() as i32, dab.center.y.floor() as i32); + rect.union(&Rect::new( + x.saturating_sub(radius), + y.saturating_sub(radius), + x.saturating_add(radius).saturating_add(1), + y.saturating_add(radius).saturating_add(1), + )) + } + } + } +} + impl DabTool { /// The tool for `cmd` and its history label. fn parse(s: &Session, cmd: &str, p: &Value, stroke: &Stroke) -> Result<(Self, &'static str)> { @@ -1033,10 +1064,11 @@ impl DabTool { } /// How far around each dab the effect reads (Blur and Sharpen read a neighbourhood). - fn halo(&self) -> i32 { + fn neighborhood(&self) -> DabNeighborhood { match self { - Self::Focus { sigma, .. } => (sigma * 3.0).ceil() as i32 + 1, - _ => 0, + Self::Focus { sigma, .. } => DabNeighborhood::Halo((sigma * 3.0).ceil() as i32 + 1), + Self::Smudge { max_size, .. } => DabNeighborhood::Smudge(Smudge::sampling_radius(*max_size)), + _ => DabNeighborhood::Halo(0), } } @@ -1108,7 +1140,7 @@ fn dab_cmd(s: &mut Session, p: &Value, cmd: &str) -> Result { let fmt = surf.format(); let mut effect = tool.effect(fmt, stroke.brush.spacing); let mut sampler = all.then(|| AllLayers::new(pre, fmt)); - Ok(apply_dab_stroke(surf, &stroke, sel, lock, tool.halo(), |work, fp| match &mut sampler { + Ok(apply_dab_stroke(surf, &stroke, sel, lock, tool.neighborhood().halo(), |work, fp| match &mut sampler { Some(all) => all.dab(work, fp, |w, f| effect(w, f)), None => effect(work, fp), })) @@ -1208,7 +1240,7 @@ pub struct LiveDab { renderer: photocraft_paint::StrokeRenderer, done: usize, effect: DabEffect, - halo: i32, + neighborhood: DabNeighborhood, pre_surf: Surface, work: WorkTiles, id: Option, @@ -1244,9 +1276,9 @@ impl LiveDab { } let (stroke, id) = parse_brush(s, p, cmd)?; let (tool, _) = DabTool::parse(s, cmd, p, &stroke)?; - let (halo, spacing, brush) = (tool.halo(), stroke.brush.spacing, Box::new(stroke.brush.clone())); + let (neighborhood, spacing, brush) = (tool.neighborhood(), stroke.brush.spacing, Box::new(stroke.brush.clone())); let effect = tool.clone(); - let mut live = Self::with_effect(s, cmd, p, stroke, id, halo, |pre| effect.effect(pre.format(), spacing))?; + let mut live = Self::with_neighborhood(s, cmd, p, stroke, id, neighborhood, |pre| effect.effect(pre.format(), spacing))?; live.tool = Some((tool, brush)); Ok(live) } @@ -1261,6 +1293,18 @@ impl LiveDab { id: Option, halo: i32, effect: impl FnOnce(&Surface) -> DabEffect, + ) -> Result { + Self::with_neighborhood(s, cmd, p, stroke, id, DabNeighborhood::Halo(halo), effect) + } + + fn with_neighborhood( + s: &Session, + cmd: &str, + p: &Value, + stroke: Stroke, + id: Option, + neighborhood: DabNeighborhood, + effect: impl FnOnce(&Surface) -> DabEffect, ) -> Result { let st = s.active().ok_or(EngineError::NoDocument)?; let base = (st.doc.id, st.revision); @@ -1293,7 +1337,7 @@ impl LiveDab { renderer, done: 0, effect, - halo, + neighborhood, work: WorkTiles::new(pre_surf.channels()), pre_surf, id, @@ -1335,7 +1379,7 @@ impl LiveDab { if r.is_empty() { continue; } - let mut region = self.work.read(&self.pre_surf, r.inflate(self.halo)); + let mut region = self.work.read(&self.pre_surf, self.neighborhood.read_rect(r, d)); (self.effect)(&mut region, &ctx.footprint(d, self.done + k)); self.work.write(&self.pre_surf, ®ion.crop(r)); dmg = dmg.union(&r); @@ -1367,7 +1411,7 @@ impl LiveDab { let ds = self.renderer.tail_dabs(); let r = ds.iter().fold(Rect::EMPTY, |a, d| a.union(&ctx.dab_rect(d, false))); if !r.is_empty() { - let mut region = self.work.read(&self.pre_surf, r.inflate(self.halo)); + let mut region = self.work.read(&self.pre_surf, r.inflate(self.neighborhood.halo())); for (k, d) in ds.iter().enumerate() { (self.effect)(&mut region, &ctx.footprint(d, self.done + k)); } diff --git a/crates/engine/tests/pr7281_adversarial.rs b/crates/engine/tests/pr7281_adversarial.rs new file mode 100644 index 0000000000..aae7e32b53 --- /dev/null +++ b/crates/engine/tests/pr7281_adversarial.rs @@ -0,0 +1,216 @@ +use photocraft_engine::{Session, retouch_cmds::LiveDab}; +use photocraft_paint::StrokePoint; +use serde_json::json; + +fn setup(depth: u32, mode: &str) -> Session { + let mut s = Session::new(); + s.execute("file.new", json!({"width":200,"height":120,"depth":depth,"mode":mode})).unwrap(); + s.execute("layer.new.layer", json!({})).unwrap(); + s.edit("texture", |doc, active| { + let bounds = doc.bounds(); + let surf = doc.layer_mut(active.unwrap()).unwrap().surface_mut().unwrap(); + let fmt = surf.format(); + let mut px = Vec::new(); + for y in 0..120 { + for x in 0..200 { + px.extend(photocraft_raster::from_rgba( + &fmt, + [((x * 7 + y * 3) % 31) as f32 / 31.0, x as f32 / 200.0, y as f32 / 120.0, 0.4 + ((x + y) % 7) as f32 / 12.0], + )); + } + } + surf.write_region(bounds, &px); + Ok(()) + }) + .unwrap(); + s +} + +fn pixels(s: &Session) -> Vec { + let st = s.active().unwrap(); + st.doc.layer(st.active_layer.unwrap()).unwrap().surface().unwrap().read_region(st.doc.bounds()) +} + +#[test] +fn pressure_shape_and_smoothing_match_replay() { + let mut failures = Vec::new(); + for cmd in ["paint.smudge", "paint.blur", "paint.sharpen", "paint.dodge", "paint.burn", "paint.sponge"] { + for case in ["pressure", "locked", "ellipse", "smoothing", "scattering"] { + for depth in [8, 16, 32] { + let mut s = setup(depth, "rgb"); + match case { + "locked" => { + s.edit("lock alpha", |doc, active| { + doc.layer_mut(active.unwrap()).unwrap().locks.transparency = true; + Ok(()) + }) + .unwrap(); + } + "ellipse" => { + s.tools.brush.roundness = 0.2; + s.tools.brush.angle = 37.0; + } + "smoothing" => { + s.tools.brush.smoothing.amount = 0.6; + } + "scattering" => { + s.tools.brush.scattering.enabled = true; + s.tools.brush.scattering.scatter.jitter = 1.0; + } + _ => {} + } + let points = [[40.0, 40.0, 0.1], [65.0, 50.0, 0.4], [100.0, 60.0, 1.0], [140.0, 70.0, 0.7], [60.0, 40.0, 0.2]]; + let params = json!({"points":points,"size":40,"hardness":70,"strength":80,"opacity":55,"spacing":25}); + s.execute(cmd, params.clone()).unwrap(); + let want = pixels(&s); + s.execute("edit.undo", json!({})).unwrap(); + let mut start = params.clone(); + start["points"] = json!([points[0]]); + let mut live = LiveDab::begin(&s, cmd, &start).unwrap(); + for q in &points[1..] { + live.push(&[StrokePoint::new(q[0], q[1], q[2] as f32)]).unwrap(); + } + s.offer_live_dab(live).unwrap(); + let result = s.execute(cmd, params).unwrap(); + assert_eq!(result["fromLive"], true); + let got = pixels(&s); + let count = got.iter().zip(&want).filter(|(a, b)| a != b).count(); + let max = got.iter().zip(&want).map(|(a, b)| (a - b).abs()).fold(0.0f32, f32::max); + if count > 0 { + failures.push(format!("{cmd} {case} depth={depth}: {count} channels differ, max={max}")); + } + } + } + } + assert!(failures.is_empty(), "{}", failures.join("\n")); +} + +#[test] +fn native_modes_selection_and_lock_match_replay() { + for mode in ["rgb", "gray", "cmyk", "lab"] { + for depth in [8, 16, 32] { + let mut s = setup(depth, mode); + s.edit("lock alpha", |doc, active| { + doc.layer_mut(active.unwrap()).unwrap().locks.transparency = true; + Ok(()) + }) + .unwrap(); + s.execute("select.rect", json!({"x":30,"y":20,"width":110,"height":60})).unwrap(); + let points = [[-10.0, 30.0], [80.0, 50.0], [160.0, 80.0], [60.0, 60.0]]; + for cmd in ["paint.blur", "paint.sharpen", "paint.dodge", "paint.burn", "paint.sponge", "paint.smudge"] { + let params = json!({"points":points,"size":30,"hardness":40,"strength":70,"opacity":37}); + let expected_damage = s.execute(cmd, params.clone()).unwrap()["damage"].clone(); + let want = pixels(&s); + s.execute("edit.undo", json!({})).unwrap(); + let mut start = params.clone(); + start["points"] = json!([points[0]]); + let mut live = LiveDab::begin(&s, cmd, &start).unwrap(); + for q in &points[1..] { + live.push(&[StrokePoint::new(q[0], q[1], 1.0)]).unwrap(); + } + s.offer_live_dab(live).unwrap(); + let result = s.execute(cmd, params).unwrap(); + assert_eq!(result["fromLive"], true); + assert_eq!(result["damage"], expected_damage); + assert_eq!(pixels(&s), want, "{mode} {depth} {cmd}"); + s.execute("edit.undo", json!({})).unwrap(); + } + } + } +} + +#[test] +fn changed_document_refuses_live_pixels() { + let mut s = setup(8, "rgb"); + let p = json!({"points":[[40,40],[80,60]],"size":30}); + let live = LiveDab::begin(&s, "paint.blur", &p).unwrap(); + s.execute("paint.stroke", json!({"points":[[40,40],[80,60]],"color":"#ffffff","size":20})).unwrap(); + let mut replay = Session::new(); + replay.add_document((*s.active().unwrap().doc).clone(), None); + replay.tools.brush = s.tools.brush.clone(); + s.offer_live_dab(live).unwrap(); + assert!(s.execute("paint.blur", p.clone()).unwrap().get("fromLive").is_none()); + replay.execute("paint.blur", p).unwrap(); + assert_eq!(pixels(&s), pixels(&replay)); +} + +/// An independent paint-level oracle gives Smudge a generously padded working region. Pixels +/// picked up by the initial small dab must not depend on the final stroke's bounding rectangle. +#[test] +fn smudge_pickup_matches_full_neighborhood_when_pressure_expands() { + use photocraft_paint::{ + Stroke, + retouch::{Smudge, apply_dab_stroke}, + }; + + let points = [[40.0, 40.0, 0.1], [65.0, 50.0, 0.4], [100.0, 60.0, 1.0], [140.0, 70.0, 0.7], [60.0, 40.0, 0.2]]; + for depth in [8, 16, 32] { + let mut s = setup(depth, "rgb"); + let params = json!({"points":points,"size":40,"hardness":70,"strength":80,"opacity":55,"spacing":25}); + let (mut expected, lock) = { + let st = s.active().unwrap(); + let id = st.active_layer.unwrap(); + (st.doc.layer(id).unwrap().surface().unwrap().clone(), st.doc.effective_locks(id).transparency) + }; + let stroke = Stroke { + brush: photocraft_engine::retouch_cmds::stroke_brush(&s.tools.brush, ¶ms), + points: points.iter().map(|q| StrokePoint::new(q[0], q[1], q[2] as f32)).collect(), + }; + let mut effect = Smudge::new(0.8, None, 40.0).with_alpha(Some(3)); + apply_dab_stroke(&mut expected, &stroke, None, lock, 40, |work, fp| effect.dab(work, fp)); + let bounds = s.active().unwrap().doc.bounds(); + let want = expected.read_region(bounds); + s.execute("paint.smudge", params.clone()).unwrap(); + assert!(pixels(&s) == want, "command must read the whole pickup square at depth {depth}"); + s.execute("edit.undo", json!({})).unwrap(); + let live = LiveDab::begin(&s, "paint.smudge", ¶ms).unwrap(); + s.offer_live_dab(live).unwrap(); + assert_eq!(s.execute("paint.smudge", params).unwrap()["fromLive"], true); + assert!(pixels(&s) == want, "a single batch uses the same pickup square at depth {depth}"); + } +} + +#[test] +fn pressure_sized_live_dabs_commit_only_the_requested_mask_or_channel() { + use photocraft_raster::Surface; + + let fill = |surface: &mut Surface| { + let values: Vec = (0..120).flat_map(|y| (0..200).map(move |x| ((x * 7 + y * 3) % 31) as f32 / 31.0)).collect(); + surface.write_region(photocraft_geom::Rect::new(0, 0, 200, 120), &values); + }; + for depth in [8, 16, 32] { + let mut s = setup(depth, "rgb"); + s.execute("layer.new.layer", json!({})).unwrap(); + s.execute("layer.layerMask.revealAll", json!({})).unwrap(); + s.execute("channel.new", json!({"fill":"white"})).unwrap(); + s.execute("select.editInQuickMaskMode", json!({"on":true})).unwrap(); + s.edit("mask texture", |doc, active| { + fill(&mut doc.layer_mut(active.unwrap()).unwrap().mask.as_mut().unwrap().surface); + fill(&mut doc.channels[0].surface); + fill(&mut doc.quick_mask.as_mut().unwrap().surface); + Ok(()) + }) + .unwrap(); + let before = s.active().unwrap().doc.clone(); + for target in [json!("mask"), json!({"channel":0}), json!("quickMask")] { + for cmd in ["paint.smudge", "paint.blur", "paint.sharpen", "paint.dodge", "paint.burn", "paint.sponge"] { + let points = [[40.0, 40.0, 0.1], [65.0, 50.0, 0.4], [100.0, 60.0, 1.0], [140.0, 70.0, 0.7], [60.0, 40.0, 0.2]]; + let params = json!({"target":target,"points":points,"size":40,"hardness":70,"strength":80,"opacity":55,"spacing":25}); + s.execute(cmd, params.clone()).unwrap(); + let want = s.active().unwrap().doc.clone(); + s.execute("edit.undo", json!({})).unwrap(); + let mut start = params.clone(); + start["points"] = json!([points[0]]); + let mut live = LiveDab::begin(&s, cmd, &start).unwrap(); + for q in &points[1..] { + live.push(&[StrokePoint::new(q[0], q[1], q[2] as f32)]).unwrap(); + } + s.offer_live_dab(live).unwrap(); + assert_eq!(s.execute(cmd, params).unwrap()["fromLive"], true); + assert_eq!(s.active().unwrap().doc, want, "depth={depth} {cmd} target={target}"); + s.execute("edit.undo", json!({})).unwrap(); + assert_eq!(s.active().unwrap().doc, before); + } + } + } +} diff --git a/crates/paint/src/retouch.rs b/crates/paint/src/retouch.rs index 5d77f2319c..06bafe6cfb 100644 --- a/crates/paint/src/retouch.rs +++ b/crates/paint/src/retouch.rs @@ -340,8 +340,14 @@ pub struct Smudge { } impl Smudge { + /// Radius of the carried-colour buffer, including pixels outside a pressure-sized dab. + /// Both the first pickup and every subsequent pickup need this entire neighbourhood. + pub fn sampling_radius(max_brush_size: f32) -> i32 { + ((max_brush_size / 2.0).ceil() as i32).saturating_add(2) + } + pub fn new(strength: f32, finger: Option>, max_brush_size: f32) -> Self { - Self { strength: strength.clamp(0.0, 1.0), finger, radius: (max_brush_size / 2.0).ceil() as i32 + 2, alpha: None, carry: None } + Self { strength: strength.clamp(0.0, 1.0), finger, radius: Self::sampling_radius(max_brush_size), alpha: None, carry: None } } /// Mix in premultiplied space using alpha channel `a` (the format's [`alpha_index`]). diff --git a/crates/ui-egui/src/stroke_timing_tests.rs b/crates/ui-egui/src/stroke_timing_tests.rs index aa57ce2b52..ac88a6c899 100644 --- a/crates/ui-egui/src/stroke_timing_tests.rs +++ b/crates/ui-egui/src/stroke_timing_tests.rs @@ -499,3 +499,59 @@ fn releasing_a_sequential_dab_stroke_commits_what_a_replay_paints() { assert!(a.px.iter().zip(&b.px).all(|(x, y)| x == y), "{cmd}: live commit and replay differ"); } } + +/// Pressure changes Smudge's painted footprint, but not the square of colour it carries. +/// Exercise the actual pen → live preview → release handoff → journal replay, then undo/redo. +#[test] +fn pressure_sized_smudge_release_matches_replay_and_undo_redo() { + use crate::stylus::PenSample; + + let setup = |run: &mut dyn FnMut(&str, Value)| { + run("tools.setBrush", json!({"brush": {"size":40,"hardness":0.7,"pressureSize":true,"smoothing":{"amount":0.4}}})); + run("paint.stroke", json!({"points":[[10,20],[190,80]],"size":30,"color":"#2060c0"})); + }; + let mut h = harness(); + h.state_mut().ui.tool = Tool::Smudge; + h.run_steps(1); + setup(&mut |id, p| { + h.state_mut().run(id, p).unwrap(); + }); + let before = h.state().session.active().unwrap().doc.clone(); + h.state_mut().ui.tool_options.strength = 80.0; + h.run_steps(1); + let pen = |pressure| Some(PenSample { pressure, ..Default::default() }); + h.state().stylus.feed.set(pen(0.1)); + move_to(&mut h, 40.0, 30.0); + button(&mut h, 40.0, 30.0, true); + for (x, y, pressure) in [(65.0, 40.0, 0.4), (100.0, 55.0, 1.0), (140.0, 70.0, 0.7), (60.0, 40.0, 0.2)] { + h.state().stylus.feed.set(pen(pressure)); + move_to(&mut h, x, y); + } + assert!(h.state().live_stroke.is_some()); + button(&mut h, 60.0, 40.0, false); + h.run_steps(2); + assert!(h.state().retouch_from_live, "release must actually reuse the live pixels"); + let (_, params) = h.state().session.journal.iter().rev().find(|(id, _)| id == "paint.smudge").cloned().unwrap(); + let points = params["points"].as_array().unwrap(); + assert!(points.iter().any(|p| p[2].as_f64().unwrap() < 0.2)); + assert!(points.iter().any(|p| p[2].as_f64().unwrap() > 0.9)); + + let mut fresh = photocraft_engine::Session::new(); + fresh.execute("file.new", json!({"width":200,"height":100,"background":"white"})).unwrap(); + setup(&mut |id, p| { + fresh.execute(id, p).unwrap(); + }); + assert_eq!(h.state().session.tools.brush, fresh.tools.brush, "replay uses the Smudge tool's actual brush"); + assert!( + photocraft_compose::render(&before, before.bounds()).px == photocraft_compose::render(&fresh.active().unwrap().doc, before.bounds()).px, + "the replay fixture starts with identical pixels" + ); + assert!(fresh.execute("paint.smudge", params).unwrap().get("fromLive").is_none()); + let committed = h.state().session.active().unwrap().doc.clone(); + let expected = photocraft_compose::render(&fresh.active().unwrap().doc, committed.bounds()); + assert!(photocraft_compose::render(&committed, committed.bounds()).px == expected.px, "live commit and replay must paint identical pixels"); + h.state_mut().run("edit.undo", json!({})).unwrap(); + assert_eq!(h.state().session.active().unwrap().doc, before); + h.state_mut().run("edit.redo", json!({})).unwrap(); + assert_eq!(h.state().session.active().unwrap().doc, committed); +} From f4cff2780cafa788bc3d3ce321cacec00b535442 Mon Sep 17 00:00:00 2001 From: skylar taylor-barrick Date: Mon, 19 Oct 2026 14:03:11 -0600 Subject: [PATCH 218/649] test(retouch): name live dab replay regressions by behavior --- .../tests/{pr7281_adversarial.rs => live_dab_matches_replay.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename crates/engine/tests/{pr7281_adversarial.rs => live_dab_matches_replay.rs} (100%) diff --git a/crates/engine/tests/pr7281_adversarial.rs b/crates/engine/tests/live_dab_matches_replay.rs similarity index 100% rename from crates/engine/tests/pr7281_adversarial.rs rename to crates/engine/tests/live_dab_matches_replay.rs From 16d1bc2f1f1e8aa8ac603bbf151244607bd60bbb Mon Sep 17 00:00:00 2001 From: Khawar Zamman Wani Date: Thu, 22 Oct 2026 08:31:29 +0530 Subject: [PATCH 219/649] fix(retouch): carry the Smudge pickup neighborhood through with_effect_on main split LiveDab's constructor into with_effect (session) and with_effect_on (a prepared document copy) after #7848's fix was written, so the cherry-picked fix no longer compiled. with_effect_on keeps its halo signature for the eraser and Pattern Stamp callers; the body moves to with_neighborhood_on, which Smudge's live stroke reaches through with_neighborhood. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/retouch_cmds.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/retouch_cmds.rs b/crates/engine/src/retouch_cmds.rs index db47fcacec..eae429f8c0 100644 --- a/crates/engine/src/retouch_cmds.rs +++ b/crates/engine/src/retouch_cmds.rs @@ -1309,7 +1309,7 @@ impl LiveDab { let st = s.active().ok_or(EngineError::NoDocument)?; let base = (st.doc.id, st.revision); let doc = (*st.doc).clone(); - let mut live = Self::with_effect_on(doc, cmd, p, stroke, id, halo, effect)?; + let mut live = Self::with_neighborhood_on(doc, cmd, p, stroke, id, neighborhood, effect)?; live.base = Some(base); Ok(live) } @@ -1317,13 +1317,25 @@ impl LiveDab { /// [`Self::with_effect`] on `doc`, a copy of the active document with what the commit's own /// edit does first (the Background Eraser's Background turned into a normal layer, say). pub(crate) fn with_effect_on( - mut doc: Document, + doc: Document, cmd: &str, p: &Value, stroke: Stroke, id: Option, halo: i32, effect: impl FnOnce(&Surface) -> DabEffect, + ) -> Result { + Self::with_neighborhood_on(doc, cmd, p, stroke, id, DabNeighborhood::Halo(halo), effect) + } + + fn with_neighborhood_on( + mut doc: Document, + cmd: &str, + p: &Value, + stroke: Stroke, + id: Option, + neighborhood: DabNeighborhood, + effect: impl FnOnce(&Surface) -> DabEffect, ) -> Result { let sel = doc.selection.clone(); let (surf, lock) = crate::channel_cmds::target_surface(&mut doc, id, p)?; From bea003acd8fe067c47d16fccb76baf1ce16d7d20 Mon Sep 17 00:00:00 2001 From: Yonghyuk Choi Date: Thu, 22 Oct 2026 12:38:20 +0900 Subject: [PATCH 220/649] Rebuild unrecorded Gradient Overlays from their end colours --- crates/doc/src/effects.rs | 1 + .../src/layer_style/gradient_overlay.rs | 71 ++++++++++++++++++- .../src/layer_style/gradient_method_tests.rs | 46 ++++++++++++ docs/control-protocol.md | 2 +- 4 files changed, 117 insertions(+), 3 deletions(-) diff --git a/crates/doc/src/effects.rs b/crates/doc/src/effects.rs index 62efbf34d8..4e3f32a97f 100644 --- a/crates/doc/src/effects.rs +++ b/crates/doc/src/effects.rs @@ -39,6 +39,7 @@ pub struct Gradient { /// Editable colour stops behind a Gradient Overlay's baked render stops. /// Older documents have no interpolation record and keep their existing appearance. +/// Writers must rebake `gradient.stops` from this record, or clear it when replacing the curve. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct GradientInterpolation { pub method: String, diff --git a/crates/engine/src/layer_style/gradient_overlay.rs b/crates/engine/src/layer_style/gradient_overlay.rs index e46109d86f..9caf82f714 100644 --- a/crates/engine/src/layer_style/gradient_overlay.rs +++ b/crates/engine/src/layer_style/gradient_overlay.rs @@ -19,6 +19,7 @@ fn edit_endpoint(stop: Option<&mut (f32, Color)>, params: &Value, key: &str) { } } +/// Edits recorded source stops, initializing legacy curves from their end colours. pub(super) fn overlay(gradient: &mut Gradient, interpolation: &mut Option, params: &Value) { // Reset to Default restores the factory's unbaked interpolation too. if params.get("method").and_then(Value::as_str) == Some("custom") { @@ -37,7 +38,9 @@ pub(super) fn overlay(gradient: &mut Gradient, interpolation: &mut Option 2); + let source_ends = vec![(0.0, gradient.stops.first().unwrap().1), (1.0, gradient.stops.last().unwrap().1)]; + let mut fx = + Effect::GradientOverlay { common: FxCommon::new(BlendMode::Normal, 1.0), gradient: gradient.clone(), dither: true, interpolation: None }; + super::super::overlay_effect(&mut fx, &json!({"method": "linear"})); + let mut expected = gradient; + expected.stops = bake_gradient(source_ends.clone(), &[0.5], 1.0, GradientMethod::Linear); + assert_eq!( + fx, + Effect::GradientOverlay { + common: FxCommon::new(BlendMode::Normal, 1.0), + gradient: expected, + dither: true, + interpolation: Some(GradientInterpolation { method: "linear".into(), smoothness: 100.0, stops: source_ends }), + } + ); + } + } + + #[test] + fn endpoint_edits_after_selecting_a_method_recolour_the_whole_baked_overlay() { + for same_edit in [false, true] { + let mut fx = Effect::GradientOverlay { + common: FxCommon::new(BlendMode::Normal, 1.0), + gradient: Gradient { + stops: bake_gradient(vec![(0.0, Color::BLACK), (1.0, Color::WHITE)], &[0.5], 1.0, GradientMethod::Smooth), + ..Gradient::default() + }, + dither: false, + interpolation: None, + }; + if same_edit { + super::super::overlay_effect(&mut fx, &json!({"method": "classic", "from": "#ff0000", "to": "#0000ff"})); + } else { + super::super::overlay_effect(&mut fx, &json!({"method": "classic"})); + super::super::overlay_effect(&mut fx, &json!({"from": "#ff0000", "to": "#0000ff"})); + } + let ends = vec![(0.0, Color::rgb(1.0, 0.0, 0.0)), (1.0, Color::rgb(0.0, 0.0, 1.0))]; + let Effect::GradientOverlay { gradient, interpolation, .. } = fx else { panic!("expected overlay") }; + assert_eq!(gradient.stops, bake_gradient(ends.clone(), &[0.5], 1.0, GradientMethod::Classic)); + assert_eq!(interpolation.unwrap().stops, ends); + } + } + #[test] fn changing_method_keeps_all_source_stops_and_transparency() { let mut gradient = Gradient { @@ -78,7 +139,8 @@ mod tests { ..Gradient::default() }; let original = gradient.clone(); - let mut source = None; + let mut source = Some(GradientInterpolation { method: "classic".into(), smoothness: 100.0, stops: original.stops.clone() }); + gradient.stops = bake_gradient(original.stops.clone(), &[0.5, 0.5], 1.0, GradientMethod::Classic); for method in ["classic", "smooth", "perceptual", "linear", "classic"] { overlay(&mut gradient, &mut source, &json!({"method": method})); let source = source.as_ref().unwrap(); @@ -90,6 +152,11 @@ mod tests { assert_eq!(gradient.align, original.align); assert_eq!(gradient.offset, original.offset); } + overlay(&mut gradient, &mut source, &json!({"from": "#112233", "to": "#445566"})); + let source = source.unwrap(); + assert_eq!(source.stops.len(), 3); + assert_eq!(source.stops[1], original.stops[1], "endpoint edits preserve the middle source stop"); + assert_eq!(gradient.stops, bake_gradient(source.stops, &[0.5, 0.5], 1.0, GradientMethod::Classic)); } #[test] diff --git a/crates/ui-egui/src/layer_style/gradient_method_tests.rs b/crates/ui-egui/src/layer_style/gradient_method_tests.rs index ef5d062f9a..2578c1ab51 100644 --- a/crates/ui-egui/src/layer_style/gradient_method_tests.rs +++ b/crates/ui-egui/src/layer_style/gradient_method_tests.rs @@ -68,3 +68,49 @@ fn all_four_methods_roundtrip_through_the_dialog() { assert_eq!(effect(&app), &before); } } + +#[test] +fn baked_overlay_is_unchanged_until_method_selection_then_edits_the_whole_curve() { + use photocraft_color::Color; + use photocraft_io::{GradientMethod, bake_gradient}; + + let mut app = app(); + app.run("layer.layerStyle.gradientOverlay", json!({})).unwrap(); + // PSD import and older method commands leave a baked curve without a source record. + let state = app.session.active_mut().unwrap(); + let fx = &mut std::sync::Arc::make_mut(&mut state.doc).layer_mut(state.active_layer.unwrap()).unwrap().effects.items[0]; + let Effect::GradientOverlay { gradient, interpolation, .. } = fx else { panic!("expected overlay") }; + gradient.stops = bake_gradient(vec![(0.0, Color::BLACK), (1.0, Color::WHITE)], &[0.5], 1.0, GradientMethod::Smooth); + *interpolation = None; + let source_ends = vec![(0.0, gradient.stops.first().unwrap().1), (1.0, gradient.stops.last().unwrap().1)]; + + let original = effect(&app).clone(); + let mut pending = fields(&app); + let id = pending["effects"][0]["id"].as_str().unwrap().to_string(); + assert_eq!(pending["effects"][0]["params"]["method"], "custom"); + confirm(&mut app, &pending).unwrap(); + assert_eq!(effect(&app), &original); + + set_param(&mut pending, &id, "method", json!("linear")); + confirm(&mut app, &pending).unwrap(); + let selected = effect(&app).clone(); + let Effect::GradientOverlay { gradient, interpolation, .. } = &selected else { panic!("expected overlay") }; + assert_eq!(gradient.stops, bake_gradient(source_ends, &[0.5], 1.0, GradientMethod::Linear)); + assert_eq!(interpolation.as_ref().unwrap().stops.len(), 2); + + let mut reopened = fields(&app); + assert_eq!(reopened["effects"][0]["params"]["method"], "linear"); + set_param(&mut reopened, &id, "from", json!("#ff0000")); + set_param(&mut reopened, &id, "to", json!("#0000ff")); + confirm(&mut app, &reopened).unwrap(); + let edited = effect(&app).clone(); + let Effect::GradientOverlay { gradient, .. } = &edited else { panic!("expected overlay") }; + assert_eq!(gradient.stops, bake_gradient(vec![(0.0, Color::rgb(1.0, 0.0, 0.0)), (1.0, Color::rgb(0.0, 0.0, 1.0))], &[0.5], 1.0, GradientMethod::Linear)); + app.run("edit.undo", json!({})).unwrap(); + assert_eq!(effect(&app), &selected); + app.run("edit.redo", json!({})).unwrap(); + assert_eq!(effect(&app), &edited); + let reopened = fields(&app); + confirm(&mut app, &reopened).unwrap(); + assert_eq!(effect(&app), &edited); +} diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 2ed97cae61..55ca0c25e1 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -67,7 +67,7 @@ The transport is `apps/photocraft/src/control_server.rs`, and the handlers are i - The shell's own dialogs (Window › Workspace › New Workspace / Delete Workspace, View › Pixel Aspect Ratio › Custom Pixel Aspect Ratio…, View › Show › Show Extras Options…, View › 32-bit Preview Options…) are listed in `ui.inspect`'s `dialogs` with the id `"shell"` (at most one is open). `ui.dialog.set`, `ui.dialog.confirm` and `ui.dialog.cancel` take `{"dialog": "shell"}`; OK runs the dialog's command and keeps the dialog open if it fails - The unsaved-changes prompt (closing a document, Revert, quitting with unsaved work) is listed in `ui.inspect`'s `dialogs` with the id `"discard"` while it is up: `fields` gives the waiting `command` (`file.close`, `file.exit`…), the `document` it asks about, how many are `remaining`, and its `choices`. `ui.dialog.confirm` takes `{"dialog": "discard", "choice": "save" | "dontSave" | "cancel"}` (default `save`; Revert takes `dontSave` or `cancel`) and answers it as the window's buttons do, one document at a time; `ui.dialog.cancel` with `{"dialog": "discard"}` cancels it. Save of an untitled document opens the save dialog first, so the reply's `fileDialog` is true and the prompt stays open until that is answered. - Layer Style (`layerStyle {effect?}` opens on that effect kind): the fields hold the dialog's whole state, so agents read and drive it like a user. `effects` lists every effect instance in the layer's order as `{id, kind, on, params, fx}` (`fx` is the effect snapshot the dialog loaded; OK edits that snapshot with `params`, so anything the dialog doesn't model survives). `selected` picks the page (`blendingOptions` or an instance id), `preview` (default on) gates the live canvas preview, `p:blendingOptions` edits blend mode/opacity/fill opacity, and `patternList` names the usable patterns. OK replaces the layer's effects in one step (`layer.layerStyle.replace`); Cancel discards. "New Style…" saves the pending state via `style.presets.new {effects}`, a swatch click applies a style preset, and Make/Reset Default use `layer.layerStyle.makeDefault` / `layer.layerStyle.defaultFor` - - Gradient Overlay exposes `params.method` (`smooth`, `perceptual`, `linear`, `classic`). `custom` denotes an existing curve without a recorded method and preserves it. Choosing a method retains the full source colour-stop list; later endpoint edits rebuild the colour curve using that method. The source stops, smoothness and method survive dialog reopening, undo/redo and native `.pcraft` saves. Saving a style preset through "New Style…" may lose the multi-stop source curve: it passes only params to `style.presets.new`, and `effect_from_params` rebuilds the effect from the default gradient. PSD export continues to write the baked appearance; reopening that PSD shows Custom because editable interpolation metadata is not exported yet. Opacity interpolation and the multi-stop editor are separate work. + - Gradient Overlay exposes `params.method` (`smooth`, `perceptual`, `linear`, `classic`). `custom` denotes an existing curve without a recorded method and preserves it. Choosing a method retains all recorded source colour stops. If no source record exists (including baked PSD imports), choosing a method rebuilds from the two end colours, matching legacy command behaviour; the old curve stays unchanged until that choice. Later endpoint edits rebuild the colour curve using the recorded method. The source stops, smoothness and method survive dialog reopening, undo/redo and native `.pcraft` saves. Saving a style preset through "New Style…" may lose the multi-stop source curve: it passes only params to `style.presets.new`, and `effect_from_params` rebuilds the effect from the default gradient. PSD export continues to write the baked appearance; reopening that PSD shows Custom because editable interpolation metadata is not exported yet. Opacity interpolation and the multi-stop editor are separate work. - Preferences (`ui.menu.invoke {id: "edit.preferences.interface"}`) exposes the sections in its `values` field. Apply (`ui.dialog.apply`) and OK (`ui.dialog.confirm`) on Preferences are refused over control because automation denies whole-preferences updates and filesystem-bearing preference sections. A refused `ui.dialog.apply` returns an error and keeps the dialog open; a refused `ui.dialog.confirm` returns an error but closes and removes the dialog. `ui.dialog.cancel` closes the dialog without saving. Individual safe preferences can instead be changed with `engine.execute` using `prefs.set` (e.g. `{"command": "prefs.set", "params": {"path": "interface.showTooltips", "value": false}}`). Settings marked for the next launch still require a restart. - Edit › Fill… (`ui.menu.invoke {id: "edit.fill"}`, Shift+F5, Shift+Backspace) opens the Fill dialog; its fields are `edit.fill`'s params (`contents`, `color`, `pattern`, `colorAdaptation`, `mode`, `opacity`, `preserveTransparency`), and OK remembers them in the preferences (`dialogs["edit.fill"]`). - Save for Web (`ui.menu.invoke {id: "file.export.saveForWebLegacy"}`) is resizable with independently scrolling settings. Dialog fields `__view` (`original|optimized|2up|4up`), `__zoom` (`null` = Fit, otherwise a factor; 1 = 100% in physical display pixels), and `__center: [u,v]` control the shared preview navigation. `__previewRects` reports pane rectangles in screen points. Drag a preview to pan, scroll/pinch to zoom at the pointer, or double-click to fit. GIF/PNG-8 expose `colorTable: ["#rrggbb", …]` (opaque source entries) and `colorTableEdits: {"0":"#rrggbb", …}` (zero-based replacements after quantization). A swatch opens a color picker; edits update the preview and saved file without remapping pixel indices or changing the document. Reset clears replacements. Changing palette/size/matte/transparency settings regenerates the table and clears index-based edits. Previews and generated tables use a bounded 2048-pixel proxy; full-size export uses that explicit table unchanged. `__paletteApproximate` reports proxy-derived palette generation, and enlarged proxy previews are labelled. The engine export command accepts the same table/edit parameters; its no-path estimate returns the source `colorTable` and `transparentIndex` as well as size statistics. Opening a new dialog does not carry a previous image's table across. From 308460fa4e6699c41961c0693de42d1dad32b779 Mon Sep 17 00:00:00 2001 From: Khawar Zamman Wani Date: Thu, 22 Oct 2026 09:57:46 +0530 Subject: [PATCH 221/649] style: cargo fmt Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/color_panel_ui.rs | 2 +- crates/ui-egui/src/panels.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/ui-egui/src/color_panel_ui.rs b/crates/ui-egui/src/color_panel_ui.rs index 12f01ebf2c..35b6593f4d 100644 --- a/crates/ui-egui/src/color_panel_ui.rs +++ b/crates/ui-egui/src/color_panel_ui.rs @@ -14,12 +14,12 @@ use serde_json::json; use crate::PhotocraftApp; use crate::color_picker_ui::{hex, not_web_safe, out_of_gamut}; -use photocraft_color::convert::{hsb_to_rgb, rgb_to_hsb}; use crate::panels::{color_field_fill_id, field_chips, field_hsva, srgb_hsva}; use crate::state::{ColorPanelMode, ColorRamp}; use crate::theme::Tokens; use crate::widgets; use photocraft_color::convert; +use photocraft_color::convert::{hsb_to_rgb, rgb_to_hsb}; /// Width of the chips column, as the cube field's. const CHIPS_W: f32 = 38.0; diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index c91634ef6a..5bb1f66acc 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -4724,7 +4724,6 @@ mod color_tests { } } - /// The Color panel's hex readout is editable, with or without the leading `#`. #[test] fn color_panel_hex_field_takes_a_typed_hex() { From 48fb3064ec18d44d2f1a3a1fe510fc42ce7e4086 Mon Sep 17 00:00:00 2001 From: Nicolas Falesy <112726756+nicolasfalesy@users.noreply.github.com> Date: Thu, 22 Oct 2026 00:36:58 -0400 Subject: [PATCH 222/649] perf(camera-raw): scopes under budget, histogram and overlays in parallel (P36) Every new Camera Raw preview ran three per-pixel passes over the 447k-pixel proxy on one thread: the RGB histogram (2.7 ms), the clipping warning overlay (1.5-2 ms) and the selection mask blend (0.7 ms). They now run with rayon (plain loops on wasm32). Histogram blocks add with saturating integer sums, so the counts equal one pass. camera_raw_bench, Core Ultra X7 358H: interactive scope update (P36) p95 11.0 -> 8.1 ms (budget 10), exposure proxy update (P31) p50 6.1 -> 4.1 ms. Part of #211. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CD2ipSyvx1tYwnHJZyDs59 --- crates/algo/src/histogram.rs | 55 ++++++++++++++++++++ crates/ui-egui/src/camera_raw_scope_ui.rs | 61 ++++++++++++----------- crates/ui-egui/src/camera_raw_ui.rs | 14 +++++- 3 files changed, 101 insertions(+), 29 deletions(-) diff --git a/crates/algo/src/histogram.rs b/crates/algo/src/histogram.rs index 4a4fb45e20..2d3df42dc9 100644 --- a/crates/algo/src/histogram.rs +++ b/crates/algo/src/histogram.rs @@ -28,6 +28,18 @@ impl RgbHistogram { /// Each visible pixel counts once, including partially transparent pixels. Non-finite /// pixels are rejected as a whole; transparent RGB cannot contribute phantom peaks. pub fn from_rgba(pixels: &[[f32; 4]]) -> Self { + // Camera Raw counts its whole proxy (~450k pixels) on every slider step, so the count + // runs in blocks across cores (#211, P36). Integer sums don't depend on the order the + // blocks finish in, so the result is the same as one pass over all pixels. + #[cfg(not(target_arch = "wasm32"))] + if pixels.len() >= PARALLEL_PIXELS { + use rayon::prelude::*; + return pixels.par_chunks(PARALLEL_PIXELS / 2).map(Self::count).reduce(Self::default, Self::merge); + } + Self::count(pixels) + } + + fn count(pixels: &[[f32; 4]]) -> Self { let mut h = Self::default(); for pixel in pixels { if !pixel[3].is_finite() { @@ -68,8 +80,29 @@ impl RgbHistogram { } h } + + /// Sum of two block counts. Saturating like the counters themselves. + #[cfg(not(target_arch = "wasm32"))] + fn merge(mut self, other: Self) -> Self { + let add = |a: &mut [u64], b: &[u64]| a.iter_mut().zip(b).for_each(|(a, b)| *a = a.saturating_add(*b)); + for (a, b) in self.channels.iter_mut().zip(&other.channels) { + add(a, b); + } + add(&mut self.underflow, &other.underflow); + add(&mut self.overflow, &other.overflow); + add(&mut self.shadows, &other.shadows); + add(&mut self.highlights, &other.highlights); + self.samples = self.samples.saturating_add(other.samples); + self.transparent = self.transparent.saturating_add(other.transparent); + self.invalid = self.invalid.saturating_add(other.invalid); + self + } } +/// Below this many pixels one pass is faster than splitting the count across cores. +#[cfg(not(target_arch = "wasm32"))] +const PARALLEL_PIXELS: usize = 64 * 1024; + /// Clipped channels of one visible straight RGBA pixel as bit masks (bit 0=R, 1=G, 2=B): /// `(shadows, highlights)` at exact endpoints ≤0 / ≥1, not rounded edge bins. /// Transparent and non-finite pixels clip nothing. @@ -94,6 +127,28 @@ pub fn clipping(p: [f32; 4]) -> (u8, u8) { mod tests { use super::*; + #[test] + fn matches_the_single_pass_on_every_domain_and_across_block_edges() { + // Every special value at every channel, plus a dense ramp through each bin's rounding + // edge; lengths around the parallel threshold and its block size. + let special = [0.0, -0.0, 1.0, -1e-7, 1.0 + 1e-7, 0.5 / 255.0, 254.5 / 255.0, -3.0, 4.0, f32::NAN, f32::INFINITY, f32::NEG_INFINITY, f32::MIN_POSITIVE]; + let mut pool: Vec<[f32; 4]> = Vec::new(); + for (i, &v) in special.iter().enumerate() { + for alpha in [1.0, 0.5, 0.0, -1.0, f32::NAN] { + pool.push([v, special[(i + 3) % special.len()], 0.25, alpha]); + pool.push([0.75, v, special[(i + 5) % special.len()], alpha]); + } + } + pool.extend((0..4096).map(|i| { + let v = i as f32 / 4095.0 * 1.2 - 0.1; + [v, 1.0 - v, (v * 7.0).fract(), 1.0] + })); + for len in [0, 1, PARALLEL_PIXELS / 2 + 1, PARALLEL_PIXELS - 1, PARALLEL_PIXELS, 3 * PARALLEL_PIXELS + 17] { + let pixels: Vec<_> = (0..len).map(|i| pool[(i * 7919) % pool.len()]).collect(); + assert_eq!(RgbHistogram::from_rgba(&pixels), RgbHistogram::count(&pixels), "{len} pixels"); + } + } + #[test] fn exact_bins_and_channel_totals() { let pixels: Vec<_> = (0..BINS).map(|i| [i as f32 / 255.0, (255 - i) as f32 / 255.0, 0.5, 0.25]).collect(); diff --git a/crates/ui-egui/src/camera_raw_scope_ui.rs b/crates/ui-egui/src/camera_raw_scope_ui.rs index 9cb5233d00..4e93b72df9 100644 --- a/crates/ui-egui/src/camera_raw_scope_ui.rs +++ b/crates/ui-egui/src/camera_raw_scope_ui.rs @@ -619,36 +619,41 @@ pub(crate) fn preview(ui: &mut egui::Ui, d: &mut CameraRawDialog, view: &mut Cam } else if mode != ClippingMode::None { if d.scope.overlay_key != Some(key) || d.scope.overlay_detail { d.scope.overlay_detail = false; - let colors = d - .pixels() - .iter() - .map(|p| { - let (lo, hi) = clipping(*p); - if p[3] <= 0.0 || !p.iter().all(|v| v.is_finite()) { - return Color32::TRANSPARENT; - } - match mode { - ClippingMode::ShadowChannels => t.histogram_color(7 ^ lo), - ClippingMode::HighlightChannels => { - if hi == 0 { - t.histogram_background() - } else { - t.histogram_color(hi) - } + let color = |p: &[f32; 4]| { + let (lo, hi) = clipping(*p); + if p[3] <= 0.0 || !p.iter().all(|v| v.is_finite()) { + return Color32::TRANSPARENT; + } + match mode { + ClippingMode::ShadowChannels => t.histogram_color(7 ^ lo), + ClippingMode::HighlightChannels => { + if hi == 0 { + t.histogram_background() + } else { + t.histogram_color(hi) } - ClippingMode::Warnings(warnings) => { - if warnings & 2 != 0 && hi != 0 { - t.histogram_color(1) - } else if warnings & 1 != 0 && lo != 0 { - t.histogram_color(4) - } else { - Color32::TRANSPARENT - } - } - ClippingMode::None => Color32::TRANSPARENT, } - }) - .collect(); + ClippingMode::Warnings(warnings) => { + if warnings & 2 != 0 && hi != 0 { + t.histogram_color(1) + } else if warnings & 1 != 0 && lo != 0 { + t.histogram_color(4) + } else { + Color32::TRANSPARENT + } + } + ClippingMode::None => Color32::TRANSPARENT, + } + }; + // Rebuilt for every new preview while a warning is on: one colour per proxy pixel, + // each independent, so it runs across cores (#211, P36). + #[cfg(not(target_arch = "wasm32"))] + let colors = { + use rayon::prelude::*; + d.pixels().par_iter().with_min_len(crate::camera_raw_ui::PARALLEL_MIN_PIXELS).map(color).collect() + }; + #[cfg(target_arch = "wasm32")] + let colors = d.pixels().iter().map(color).collect(); let image = egui::ColorImage::new([d.pw, d.ph], colors); match &mut d.scope.overlay_tex { Some(t) => t.set(image, egui::TextureOptions::NEAREST), diff --git a/crates/ui-egui/src/camera_raw_ui.rs b/crates/ui-egui/src/camera_raw_ui.rs index 090c0a0b3c..8641dc4024 100644 --- a/crates/ui-egui/src/camera_raw_ui.rs +++ b/crates/ui-egui/src/camera_raw_ui.rs @@ -26,6 +26,10 @@ use crate::theme::Tokens; use crate::widgets; const PROXY_SIDE: usize = 900; +/// Smallest run of proxy pixels one rayon task takes in the per-pixel passes: below it the +/// split costs more than the work. +#[cfg(not(target_arch = "wasm32"))] +pub(crate) const PARALLEL_MIN_PIXELS: usize = 16 * 1024; const PANEL_W: f32 = 330.0; const BANDS: [&str; 8] = ["Red", "Orange", "Yellow", "Green", "Aqua", "Blue", "Purple", "Magenta"]; @@ -278,11 +282,19 @@ impl ProxyJob { } photocraft_algo::camera_raw::develop(&mut px, pw, ph, &p, self.float); if let Some(mask) = &self.selection { - for ((out, original), coverage) in px.iter_mut().zip(self.proxy.iter()).zip(mask.iter()) { + let blend = |(out, (original, coverage)): (&mut [f32; 4], (&[f32; 4], &f32))| { for (out, original) in out.iter_mut().zip(original) { *out = *original + (*out - *original) * coverage; } + }; + // Each pixel is independent, so bands of the proxy blend in parallel (#211, P36). + #[cfg(not(target_arch = "wasm32"))] + { + use rayon::prelude::*; + px.par_iter_mut().zip(self.proxy.par_iter().zip(mask.par_iter())).with_min_len(PARALLEL_MIN_PIXELS).for_each(blend); } + #[cfg(target_arch = "wasm32")] + px.iter_mut().zip(self.proxy.iter().zip(mask.iter())).for_each(blend); } let histogram_start = crate::gpu_canvas::now_ms(); let histogram = RgbHistogram::from_rgba(&px); From b92ac6fab075025799558b7880f4b82f9a10b23b Mon Sep 17 00:00:00 2001 From: Jason D Date: Wed, 21 Oct 2026 13:31:01 -0400 Subject: [PATCH 223/649] PSD: spot channels in Photoshop's polarity; earlier PhotoCraft PSDs keep their ink Photoshop 27.11 stores spot ink 0 = solid in every PSD it saves (its 7 spot PSDs store the 100/25/75/0 % columns as 0/191/64/255) and numbers the extra channels 3, 4, 5 in resource 1053, after 0 for the merged transparency. PhotoCraft's PSDs stored the ink straight and wrote no 1053. - PSD save and open use Photoshop's polarity through channel_map::photoshop_spot_plane; alpha channels stay straight and the in-memory convention (1 = solid ink) is unchanged. - A fresh 1053 is written with the extra channels; a kept one is never written next to it. - psd_import::earlier_photocraft_spot_planes: a PSD whose 1077 marks a spot, with no 1053 and the exact 1057 PhotoCraft 0.1.0-0.7.0 (CS6, NUL) or 0.8.2-0.11.1 (2026) wrote, is read straight, so it keeps its ink. - Part 3's switch (PsdExportOptions::photoshop_spot_polarity, PsdImportOptions) is gone: PSD and the layered TIFF share one path. - PSD keeps main's empty LMsk and layer flags; Multichannel is unchanged. - Docs: file-format parity, gaps G10, target-app parity, FILE-215-17 note. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Zer0C00L01 <12090083+Zer0C00L01@users.noreply.github.com> --- crates/io/src/channel_map.rs | 59 ++++++++-- crates/io/src/lib.rs | 3 +- crates/io/src/psd_export.rs | 96 +++++++++------ crates/io/src/psd_import.rs | 209 +++++++++++++++++++++++++++++++-- crates/io/src/tiff_layers.rs | 22 ++-- crates/io/tests/tiff_layers.rs | 51 ++++++-- docs/file-format-parity.md | 5 +- docs/gaps.md | 8 +- docs/target-app-parity.md | 5 +- scorecard/file_compat.toml | 2 +- 10 files changed, 369 insertions(+), 91 deletions(-) diff --git a/crates/io/src/channel_map.rs b/crates/io/src/channel_map.rs index 990027441a..c32553324f 100644 --- a/crates/io/src/channel_map.rs +++ b/crates/io/src/channel_map.rs @@ -25,10 +25,10 @@ const SPACE_GRAY: u16 = 8; /// Converts one spot channel's plane (native-endian samples) between the document's ink density /// (1 = solid ink) and the way Photoshop stores a spot channel (0 = solid ink, the maximum = -/// bare paper; every TIFF Photoshop 27 saves stores it so). The conversion is its own inverse, -/// so it serves both open and save. Every reader and writer of Photoshop-polarity spot planes -/// goes through here: a change to the in-memory convention changes only this function. Alpha -/// channels are stored straight (the maximum = selected) and never come here. +/// bare paper; every PSD and TIFF Photoshop 27.11 saves stores it so). The conversion is its own +/// inverse, so it serves both open and save. Every reader and writer of Photoshop-polarity spot +/// planes goes through here: a change to the in-memory convention changes only this function. +/// Alpha channels are stored straight (the maximum = selected) and never come here. pub(crate) fn photoshop_spot_plane(plane: &mut [u8], sample: SampleType) { crate::pixels::invert_plane(plane, sample); } @@ -36,9 +36,13 @@ pub(crate) fn photoshop_spot_plane(plane: &mut [u8], sample: SampleType) { /// Resource 1053 for `count` channels: one big-endian u32 identifier each, with no length prefix /// (Photoshop, ag-psd and psd-tools read u32s until the resource ends). Photoshop 27.11 numbers a /// new document's channels 3, 4, 5, … in every colour mode (RGB, CMYK, Gray and Lab, in its PSDs -/// and TIFFs alike), so these do too. -pub(crate) fn alpha_identifiers(count: usize) -> Vec { - let mut out = Vec::with_capacity(count.saturating_mul(4)); +/// and TIFFs alike), so these do too. `transparency`: the merged image's transparency channel +/// comes first, with identifier 0 (Photoshop's transparent PSD lists `0, 3, 4, 5`). +pub(crate) fn alpha_identifiers(transparency: bool, count: usize) -> Vec { + let mut out = Vec::with_capacity(count.saturating_add(1).saturating_mul(4)); + if transparency { + out.extend_from_slice(&0u32.to_be_bytes()); + } for i in 0..count { let id = 3u32.saturating_add(u32::try_from(i).unwrap_or(u32::MAX)); out.extend_from_slice(&id.to_be_bytes()); @@ -86,6 +90,14 @@ pub(crate) fn spot_flags(data: &[u8], versioned: bool, skip: usize) -> Vec display_records(data, versioned).skip(skip).map(|rec| rec.get(12) == Some(&2)).collect() } +/// Whether a DisplayInfo resource 1077 marks any channel as a spot (kind 2), in 13-byte records +/// (Photoshop's, and PhotoCraft's since 0.8.2) or in the 14-byte padded records PhotoCraft wrote +/// up to 0.7.0. +pub(crate) fn display_info_marks_spot(data: &[u8]) -> bool { + let body = data.get(4..).unwrap_or_default(); + [13, 14].into_iter().any(|size| body.chunks_exact(size).any(|rec| rec.get(12) == Some(&2))) +} + /// Applies a DisplayInfo resource (`versioned` = 1077: 13-byte records after a version; else the /// older 1007 with 14-byte records) to the imported channels in order, after skipping `skip` /// records (the merged transparency channel's). @@ -189,8 +201,9 @@ mod tests { assert_eq!(back[0].indicates, ColorIndicates::SelectedAreas); assert_eq!(back[1].spot, s.spot); assert_eq!(spot_flags(&bytes, true, 0), [false, true]); - assert_eq!(alpha_identifiers(2), [0, 0, 0, 3, 0, 0, 0, 4]); - assert!(alpha_identifiers(0).is_empty()); + assert!(display_info_marks_spot(&bytes)); + assert!(!display_info_marks_spot(&display_info(&[&a], true)), "alpha and transparency records only"); + assert!(!display_info_marks_spot(&bytes[..10])); // Photoshop 27 writes a 13-byte record (no pad): red spot, solidity 60. let ps = [0, 0, 0, 1, 0, 0, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0x3c, 2]; let mut spot = vec![AlphaChannel::new("S", Surface::new(PixelFormat::GRAY8))]; @@ -227,6 +240,34 @@ mod tests { assert_eq!(got[13].spot.map(|(_, s)| (s * 100.0).round() as u16), many[13].spot.map(|(_, s)| (s * 100.0).round() as u16)); } + /// Resource 1053 as Photoshop 27.11 numbers a new document's channels: 3, 4, 5 in every colour + /// mode, with the merged transparency first as 0 (its transparent PSD lists `0, 3, 4, 5`). + #[test] + fn alpha_identifiers_are_numbered_as_photoshop_does() { + let ids = |transparency, count| alpha_identifiers(transparency, count).as_chunks::<4>().0.iter().map(|c| u32::from_be_bytes(*c)).collect::>(); + assert_eq!(ids(false, 3), [3, 4, 5]); + assert_eq!(ids(true, 3), [0, 3, 4, 5]); + assert_eq!(ids(false, 1), [3]); + assert!(ids(false, 0).is_empty()); + assert_eq!(ids(true, 0), [0]); + assert_eq!(alpha_identifiers(false, 2), [0, 0, 0, 3, 0, 0, 0, 4]); + } + + /// PhotoCraft 0.1.0 to 0.7.0 padded each 1077 record to 14 bytes, so a spot after the first + /// record sits where a 13-byte reader finds no kind 2; it is still recognised. + #[test] + fn a_spot_is_found_in_padded_records() { + let alpha = |kind: u8| [0, 0, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 50, kind, 0]; + let mut old = 1u32.to_be_bytes().to_vec(); + old.extend_from_slice(&alpha(1)); + old.extend_from_slice(&alpha(0)); + old.extend_from_slice(&alpha(2)); + assert_eq!(spot_flags(&old, true, 0), [false, false, false], "13-byte records misread the padded ones"); + assert!(display_info_marks_spot(&old)); + old.truncate(old.len() - 14); + assert!(!display_info_marks_spot(&old), "two alpha records"); + } + /// Photoshop's spot ink (0 = solid) and the document's density (1 = solid) at every depth, /// both ways: the 25 % / 75 % columns of the Photoshop oracles store 191 / 64. #[test] diff --git a/crates/io/src/lib.rs b/crates/io/src/lib.rs index 70d66f8c5c..946abfbc75 100644 --- a/crates/io/src/lib.rs +++ b/crates/io/src/lib.rs @@ -321,8 +321,7 @@ fn import_stages(name: &str, bytes: &[u8], ctl: &photocraft_raster::Interrupt, m psd_import::check_group_depth(&file)?; ctl.check().map_err(|_| IoError::Cancelled)?; ctl.progress(0.05); - let (mut document, warnings) = - psd_import::psd_to_document_decoded(&file, ctl, merged, psd_import::PsdImportOptions::default()).ok_or(IoError::Cancelled)?; + let (mut document, warnings) = psd_import::psd_to_document_decoded(&file, ctl, merged).ok_or(IoError::Cancelled)?; document.name = name.to_string(); text_import::prepare(&mut document); return Ok(ImportResult { document, warnings, source_read_only: false, preview_only: false }); diff --git a/crates/io/src/psd_export.rs b/crates/io/src/psd_export.rs index 483b305f00..daa25ca2bc 100644 --- a/crates/io/src/psd_export.rs +++ b/crates/io/src/psd_export.rs @@ -50,11 +50,6 @@ pub struct PsdExportOptions { /// The path of the document's own file: linked smart objects are resolved against it /// ([`crate::doc_path::resolve`]) before they are read and embedded. pub document_path: Option, - /// Store spot channels as Photoshop's TIFFs do, 0 = solid ink (see - /// [`crate::channel_map::photoshop_spot_plane`]). Only the layered TIFF sets it: a PSD keeps - /// writing the document's density as it is (1 = solid ink), so files saved by earlier - /// versions keep reading the same. - pub photoshop_spot_polarity: bool, } impl Default for PsdExportOptions { @@ -66,7 +61,6 @@ impl Default for PsdExportOptions { merged_compression: Compression::Rle, maximize_compatibility: true, document_path: None, - photoshop_spot_polarity: false, } } } @@ -1712,7 +1706,8 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c for a in &extra { let s = if a.surface.format() != ex.mask_fmt { a.surface.convert(ex.mask_fmt) } else { a.surface.clone() }; let mut bytes = s.to_interleaved(canvas); - if opts.photoshop_spot_polarity && a.spot.is_some() { + // Spot ink as Photoshop stores it (0 = solid); an alpha channel stays straight. + if a.spot.is_some() { crate::channel_map::photoshop_spot_plane(&mut bytes, sample); } planes.extend(deinterleave(&bytes, 1, sample, &[false]).remove(0)); @@ -1746,6 +1741,9 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c resources.push(ImageResource::new(1006, pascal_names_resource(&names))); resources.push(ImageResource::new(1045, unicode_names_resource(&names))); resources.push(ImageResource::new(crate::channel_map::DISPLAY_INFO, crate::channel_map::display_info(&extra, has_alpha))); + // Photoshop writes 1053 in every file with an extra channel. Its absence is how a file from + // an earlier PhotoCraft is told apart (`psd_import::earlier_photocraft_spot_planes`). + resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers(has_alpha, extra.len()))); } if let Some(id) = quick_mask_id { let mut data = id.to_be_bytes().to_vec(); @@ -1828,6 +1826,10 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c if !keep_imported_resource(doc, *id, data) { continue; } + // A fresh 1053 was written with the extra channels; a preserved copy would be a second one. + if *id == crate::channel_map::ALPHA_IDENTIFIERS && !extra.is_empty() { + continue; + } let mut r = ImageResource::new(*id, data.to_vec()); r.name = legacy_name(name); resources.push(r); @@ -1972,25 +1974,28 @@ mod tests { doc } - /// Photoshop's spot polarity is for the layered TIFF only: a PSD stores a spot plane and an - /// alpha plane straight (255 = solid ink, 255 = selected) as before, so files saved by earlier - /// versions and this one read the same. It writes no resource 1053, an empty global layer - /// mask, and flag bit 3 on the layers but not on the group's closing divider. Opening it gives - /// the same ink back. + /// The extra planes after the colour channels (and the merged transparency) of `file`. + fn extra_planes(file: &PsdFile, count: usize) -> Vec { + let planes = file.decode_merged().unwrap(); + let plane = (file.header.width * file.header.height) as usize * usize::from(file.header.depth / 8); + planes[planes.len() - count * plane..].to_vec() + } + + /// Resource 1053's identifiers. + fn alpha_ids(file: &PsdFile) -> Option> { + file.resource(crate::channel_map::ALPHA_IDENTIFIERS).map(|r| r.data.as_chunks::<4>().0.iter().map(|c| u32::from_be_bytes(*c)).collect()) + } + + /// A PSD stores spot ink as Photoshop's own PSDs do (0 = solid ink: the 100, 25, 75 and 0 % + /// columns are 0, 191, 64, 255) and an alpha channel straight (255 = selected). The global + /// layer mask stays empty and flag bit 3 stays on the layers only, not on the group's closing + /// divider: Photoshop opens those as they are, and 509 of the corpus's 721 Photoshop PSDs have + /// an empty mask too. Opening the file gives the same ink back. #[test] - fn psd_stores_spot_and_alpha_planes_straight() { + fn psd_stores_spot_ink_as_photoshop_does() { let doc = spot_and_alpha_document(); - let written = |photoshop_spot_polarity| { - let opts = PsdExportOptions { photoshop_spot_polarity, ..Default::default() }; - PsdFile::from_bytes(&document_to_psd_with(&doc, &opts).0.to_bytes().unwrap()).unwrap() - }; - let extra_planes = |file: &PsdFile| { - let planes = file.decode_merged().unwrap(); - planes[planes.len() - 2 * 4..].to_vec() - }; - let file = written(false); - assert_eq!(extra_planes(&file), [255, 64, 191, 0, 255, 64, 191, 0], "spot, then alpha"); - assert!(file.resource(crate::channel_map::ALPHA_IDENTIFIERS).is_none()); + let file = PsdFile::from_bytes(&document_to_psd(&doc).to_bytes().unwrap()).unwrap(); + assert_eq!(extra_planes(&file, 2), [0, 191, 64, 255, 255, 64, 191, 0], "spot, then alpha"); assert_eq!(file.global_layer_mask.as_ref().map(|m| m.data.len()), Some(0)); let flags: Vec = file.layers().iter().map(|l| l.flags.0 & LayerFlags::BIT4_USEFUL).collect(); assert_eq!(flags, [0, LayerFlags::BIT4_USEFUL, LayerFlags::BIT4_USEFUL], "closing divider, layer, group"); @@ -1999,23 +2004,46 @@ mod tests { for c in &back.channels { assert_eq!(c.surface.to_interleaved(back.bounds()), [255, 64, 191, 0], "{}", c.name); } - // The layered TIFF's switch inverts the spot plane only. - assert_eq!(extra_planes(&written(true)), [0, 191, 64, 255, 255, 64, 191, 0]); } - /// Resource 1053 (alpha identifiers, in every Photoshop file with an extra channel) is kept - /// from an opened PSD and written back unchanged, as before. + /// Resource 1053 numbers the extra channels as Photoshop 27.11 does in a new document: 3, 4, 5 + /// in every colour mode, after 0 for the merged transparency when there is one (its + /// transparent PSD lists `0, 3, 4, 5`). A Quick Mask is an extra channel too. Without extra + /// channels there is none. #[test] - fn psd_alpha_identifiers_survive_open_and_save() { + fn psd_alpha_identifiers_number_the_channels_as_photoshop_does() { + use photocraft_color::Color; + let size = photocraft_geom::Size::new(4, 1); + for mode in [ColorMode::Rgb, ColorMode::Cmyk, ColorMode::Grayscale, ColorMode::Lab] { + let mut doc = Document::with_background("bg", size, mode, SampleType::U8, Color::rgb(1.0, 1.0, 1.0)); + assert_eq!(alpha_ids(&document_to_psd(&doc)), None, "{mode:?} without channels"); + doc.channels = spot_and_alpha_document().channels; + let file = document_to_psd(&doc); + assert!(!file.merged_has_alpha(), "{mode:?}"); + assert_eq!(alpha_ids(&file), Some(vec![3, 4]), "{mode:?}"); + doc.quick_mask = Some(photocraft_doc::AlphaChannel::new("Quick Mask", Surface::new(PixelFormat::GRAY8))); + assert_eq!(alpha_ids(&document_to_psd(&doc)), Some(vec![3, 4, 5]), "{mode:?} with a Quick Mask"); + } + // The empty layer leaves the composite transparent. + let file = document_to_psd(&spot_and_alpha_document()); + assert!(file.merged_has_alpha()); + assert_eq!(alpha_ids(&file), Some(vec![0, 3, 4])); + } + + /// A Photoshop file's own 1053 is kept on open (as every unmapped resource is), but a save + /// writes one fresh 1053 for the channels the document has, never the kept one as well. The + /// identifiers here, 3 and 2, are those of psd-tools' `cmyk-alpha-spot.psd` (Photoshop 24.7). + #[test] + fn a_kept_alpha_identifiers_resource_is_not_written_twice() { let mut file = document_to_psd(&spot_and_alpha_document()); - let ids = [0, 0, 0, 3, 0, 0, 0, 2]; - file.resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, ids.to_vec())); + file.resources.retain(|r| r.id != crate::channel_map::ALPHA_IDENTIFIERS); + file.resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, [0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2].to_vec())); let opened = crate::import("ps.psd", &file.to_bytes().unwrap()).unwrap().document; + assert!(opened.metadata.psd_resources.iter().any(|(id, ..)| *id == crate::channel_map::ALPHA_IDENTIFIERS)); let saved = crate::export(&opened, "x.psd", &crate::ExportOptions::default()).unwrap(); let again = PsdFile::from_bytes(&saved.bytes).unwrap(); - let kept: Vec<&ImageResource> = again.resources.iter().filter(|r| r.id == crate::channel_map::ALPHA_IDENTIFIERS).collect(); - assert_eq!(kept.len(), 1); - assert_eq!(kept[0].data, ids); + assert_eq!(again.resources.iter().filter(|r| r.id == crate::channel_map::ALPHA_IDENTIFIERS).count(), 1); + assert_eq!(alpha_ids(&again), Some(vec![0, 3, 4])); } #[test] diff --git a/crates/io/src/psd_import.rs b/crates/io/src/psd_import.rs index cf7c522e41..14118c2c86 100644 --- a/crates/io/src/psd_import.rs +++ b/crates/io/src/psd_import.rs @@ -751,16 +751,48 @@ pub fn psd_to_document(file: &PsdFile) -> (Document, Vec) { /// [`psd_to_document`] for a background open: checks `ctl` per layer record and reports /// progress. `None` when cancelled. pub fn psd_to_document_with(file: &PsdFile, ctl: &photocraft_raster::Interrupt) -> Option<(Document, Vec)> { - psd_to_document_decoded(file, ctl, None, PsdImportOptions::default()) + psd_to_document_decoded(file, ctl, None) } -/// Options for [`psd_to_document_decoded`]. -#[derive(Debug, Clone, Copy, Default)] -pub(crate) struct PsdImportOptions { - /// Read spot channels as Photoshop's TIFFs store them, 0 = solid ink (see - /// [`crate::channel_map::photoshop_spot_plane`]). Only the layered TIFF sets it: a PSD's spot - /// planes are read as the document's density, as earlier versions saved them. - pub photoshop_spot_polarity: bool, +/// Whether `file` stores its spot planes the way earlier PhotoCraft versions (releases 0.1.0 to +/// 0.11.1) wrote them: straight (the maximum = solid ink), the opposite of Photoshop, which +/// stores 0 = solid ink in every PSD and TIFF it saves. Their files are recognised by three +/// things together: +/// +/// - DisplayInfo (1077) marks at least one spot channel; +/// - there is no Alpha Identifiers resource (1053). Photoshop has written it in every file with +/// an extra channel since version 6, and PhotoCraft writes it now, but no earlier PhotoCraft did; +/// - the version info (1057) is byte for byte what those versions wrote: writer "Adobe Photoshop" +/// with reader "Adobe Photoshop CS6", both NUL-terminated (0.1.0 to 0.7.0), or reader "Adobe +/// Photoshop 2026" without a NUL (0.8.2 on), with either merged-data flag. +/// +/// Any other file is read in Photoshop's polarity. psd-tools' `cmyk-spot.psd`, for one, also has +/// spots and no 1053, but names psd-tools in 1057 and stores Photoshop's polarity. A Photoshop +/// file that an earlier PhotoCraft opened and saved again kept Photoshop's 1053 and its planes as +/// Photoshop stored them, so it is read in Photoshop's polarity too. +/// +/// Keeping these files' ink is the only reason this exists: deleting it (and its one caller) +/// reads every file in Photoshop's polarity, at the cost of inverting the spot ink of PSDs saved +/// by those versions. +pub(crate) fn earlier_photocraft_spot_planes(file: &PsdFile) -> bool { + use photocraft_psd::descriptor::UnicodeString; + use photocraft_psd::resources::VersionInfo; + + let marks_spot = file.resource(crate::channel_map::DISPLAY_INFO).is_some_and(|r| crate::channel_map::display_info_marks_spot(&r.data)); + if !marks_spot || file.resource(crate::channel_map::ALPHA_IDENTIFIERS).is_some() { + return false; + } + let Some(r) = file.resource(ids::VERSION_INFO) else { return false }; + // Byte for byte: a resource with anything after the fields is someone else's. + let Ok(v) = VersionInfo::from_bytes(&r.data) else { return false }; + if v.to_bytes() != r.data { + return false; + } + let writers = [ + (UnicodeString::new_nul("Adobe Photoshop"), UnicodeString::new_nul("Adobe Photoshop CS6")), + (UnicodeString::new("Adobe Photoshop"), UnicodeString::new("Adobe Photoshop 2026")), + ]; + v.version == 1 && v.file_version == 1 && writers.iter().any(|(writer, reader)| v.writer == *writer && v.reader == *reader) } /// Whether the import reads the merged composite: for a flattened or multichannel file (it *is* @@ -785,7 +817,6 @@ pub(crate) fn psd_to_document_decoded( file: &PsdFile, ctl: &photocraft_raster::Interrupt, decoded: Option>>, - opts: PsdImportOptions, ) -> Option<(Document, Vec)> { let h = &file.header; let mut warnings = Vec::new(); @@ -1061,9 +1092,10 @@ pub(crate) fn psd_to_document_decoded( // Photoshop lists every extra channel, the merged transparency first when there is one. let skip = usize::from(file.merged_has_alpha() && names.len() == usize::from(h.channels).saturating_sub(cc)); let names = names.get(skip..).unwrap_or_default(); - // Which planes hold spot ink in Photoshop's polarity: the DisplayInfo records the - // channel options are read from below, the transparency's first when `skip` is 1. - let photoshop_spots = if !opts.photoshop_spot_polarity { + // Which planes hold spot ink in Photoshop's polarity (0 = solid): the DisplayInfo records + // the channel options are read from below, the transparency's first when `skip` is 1. + // A file from an earlier PhotoCraft stores them straight and is read as it was written. + let photoshop_spots = if earlier_photocraft_spot_planes(file) { Vec::new() } else if let Some(r) = file.resource(crate::channel_map::DISPLAY_INFO) { crate::channel_map::spot_flags(&r.data, true, skip) @@ -1121,7 +1153,9 @@ pub(crate) fn psd_to_document_decoded( #[cfg(test)] mod tests { use super::*; - use photocraft_psd::{Compression, PsdError, Version, testgen}; + use photocraft_psd::descriptor::UnicodeString; + use photocraft_psd::resources::VersionInfo; + use photocraft_psd::{Compression, ImageData, ImageResource, PsdError, Version, testgen}; /// #5200: the Multichannel fallback checks its RGBA output against the budget before /// allocating it (here a 2x2 image, 16 bytes, against caps of 15 and 16 bytes). @@ -1167,4 +1201,153 @@ mod tests { assert_eq!(merged_plane(&all, 2, 2), None); assert_eq!(merged_plane(&all, usize::MAX, 2), None); } + + /// Resource 1057's data. + fn version_info(writer: UnicodeString, reader: UnicodeString, has_real_merged_data: bool) -> Vec { + VersionInfo { version: 1, has_real_merged_data, writer, reader, file_version: 1 }.to_bytes() + } + + /// The 1057 PhotoCraft 0.1.0 to 0.7.0 wrote: Photoshop CS6's names, NUL-terminated. + fn version_info_cs6(has_real_merged_data: bool) -> Vec { + version_info(UnicodeString::new_nul("Adobe Photoshop"), UnicodeString::new_nul("Adobe Photoshop CS6"), has_real_merged_data) + } + + /// The 1057 PhotoCraft writes since 0.8.2: Photoshop 2026's bytes, no NUL. + fn version_info_2026(has_real_merged_data: bool) -> Vec { + photocraft_psd::resources::version_info_resource(has_real_merged_data).data + } + + /// An opaque 4 × 1 RGB document with the Photoshop spot oracles' channels in their order: + /// "Spot A", "Alpha 1" and "Spot B", each holding 100, 25, 75 and 0 % in four columns. + fn channels_document(depth: SampleType) -> Document { + let mut doc = Document::with_background("old", Size::new(4, 1), ColorMode::Rgb, depth, photocraft_color::Color::rgb(1.0, 1.0, 1.0)); + let gray = PixelFormat::new(ColorMode::Grayscale, depth, false); + let canvas = doc.bounds(); + let channel = |name: &str, spot: Option<(photocraft_color::Color, f32)>| { + let mut s = Surface::new(gray); + s.write_region(canvas, &[1.0, 0.25, 0.75, 0.0]); + AlphaChannel { spot, ..AlphaChannel::new(name, s) } + }; + doc.channels.push(channel("Spot A", Some((photocraft_color::Color::rgb(0.0, 0.627, 1.0), 0.0)))); + doc.channels.push(channel("Alpha 1", None)); + doc.channels.push(channel("Spot B", Some((photocraft_color::Color::rgb(1.0, 0.0, 0.627), 0.5)))); + doc + } + + /// Each channel's values on an 8-bit scale. + fn ink(doc: &Document) -> Vec> { + doc.channels.iter().map(|c| c.surface.read_region(doc.bounds()).iter().map(|v| (v * 255.0).round() as u8).collect()).collect() + } + + fn spots(doc: &Document) -> Vec { + doc.channels.iter().map(|c| c.spot.is_some()).collect() + } + + /// `doc` (opaque, 8 or 16-bit) saved the way PhotoCraft 0.1.0 to 0.11.1 saved it: spot planes + /// straight (the maximum = solid ink), no 1053, and `version_info` as resource 1057. `padded` + /// lays DisplayInfo out in the 14-byte records of 0.1.0 to 0.7.0. + fn as_earlier_photocraft_saved(doc: &Document, version_info: Vec, padded: bool) -> Vec { + let mut file = crate::psd_export::document_to_psd(doc); + assert!(!file.merged_has_alpha()); + file.resources.retain(|r| r.id != crate::channel_map::ALPHA_IDENTIFIERS); + for r in &mut file.resources { + match r.id { + ids::VERSION_INFO => r.data = version_info.clone(), + crate::channel_map::DISPLAY_INFO if padded => { + let (version, records) = r.data.split_at(4); + r.data = version.iter().copied().chain(records.chunks(13).flat_map(|rec| rec.iter().copied().chain([0]))).collect(); + } + _ => {} + } + } + let mut planes = file.decode_merged().unwrap(); + let plane = planes.len() / usize::from(file.header.channels); + for (k, c) in doc.channels.iter().enumerate() { + if c.spot.is_some() { + // At 8 and 16 bits the complement of a sample is that of each of its bytes. + planes[(3 + k) * plane..(4 + k) * plane].iter_mut().for_each(|b| *b = !*b); + } + } + file.image_data = ImageData::encode(Compression::Raw, &planes, &file.header).unwrap(); + file.to_bytes().unwrap() + } + + /// PSDs that PhotoCraft 0.1.0 to 0.11.1 saved with spot channels store them straight. They + /// open with the ink they had in those versions (which read every plane straight), whichever + /// 1057 they carry. Saved again, they get Photoshop's polarity and a 1053, and reopen with the + /// same ink. (A 0.1.0 to 0.7.0 file's padded records misread every channel's options after + /// the first, here Spot B's kind, as those versions' successors always have; its ink is kept.) + #[test] + fn spot_planes_from_earlier_photocraft_keep_their_ink() { + for depth in [SampleType::U8, SampleType::U16] { + let doc = channels_document(depth); + let cases = [ + ("0.1.0 to 0.7.0", version_info_cs6(true), true), + ("0.8.2 on", version_info_2026(true), false), + ("0.8.2 on, Maximize Compatibility off", version_info_2026(false), false), + ("0.1.0 to 0.7.0, 13-byte records", version_info_cs6(true), false), + ]; + for (what, version_info, padded) in cases { + let bytes = as_earlier_photocraft_saved(&doc, version_info, padded); + assert!(earlier_photocraft_spot_planes(&PsdFile::from_bytes(&bytes).unwrap()), "{what}"); + let opened = crate::import("old.psd", &bytes).unwrap().document; + assert_eq!(ink(&opened), ink(&doc), "{depth:?} {what}: the ink earlier versions opened"); + assert!(spots(&opened)[0], "{depth:?} {what}"); + if !padded { + assert_eq!(spots(&opened), spots(&doc), "{depth:?} {what}"); + } + let saved = crate::export(&opened, "old.psd", &crate::ExportOptions::default()).unwrap(); + let file = PsdFile::from_bytes(&saved.bytes).unwrap(); + assert!(file.resource(crate::channel_map::ALPHA_IDENTIFIERS).is_some() && !earlier_photocraft_spot_planes(&file), "{what}"); + let again = crate::import("again.psd", &saved.bytes).unwrap().document; + assert_eq!(ink(&again), ink(&doc), "{depth:?} {what}: saved again"); + assert_eq!(spots(&again), spots(&opened), "{depth:?} {what}: saved again"); + } + } + } + + /// A file with spots and no 1053 that no earlier PhotoCraft wrote is read in Photoshop's + /// polarity (0 = solid ink). psd-tools' `cmyk-spot.psd` is one: its 1057 names psd-tools as + /// writer and reader. So is a file with no 1057, with Photoshop CS6's names without the NUL, + /// or with bytes after PhotoCraft's. + #[test] + fn other_files_without_alpha_identifiers_use_photoshop_polarity() { + let doc = channels_document(SampleType::U8); + let mut trailing = version_info_2026(true); + trailing.extend([0, 0]); + let cases = [ + ("psd-tools", Some(version_info(UnicodeString::new("psd-tools 1.10.0"), UnicodeString::new("psd-tools 1.10.0"), true))), + ("no 1057", None), + ("CS6 without a NUL", Some(version_info(UnicodeString::new("Adobe Photoshop"), UnicodeString::new("Adobe Photoshop CS6"), true))), + ("bytes after PhotoCraft's 1057", Some(trailing)), + ]; + for (what, info) in cases { + // Photoshop's polarity, as this version writes it, without 1053. + let mut file = crate::psd_export::document_to_psd(&doc); + file.resources.retain(|r| r.id != crate::channel_map::ALPHA_IDENTIFIERS && r.id != ids::VERSION_INFO); + file.resources.extend(info.map(|d| ImageResource::new(ids::VERSION_INFO, d))); + let bytes = file.to_bytes().unwrap(); + assert!(!earlier_photocraft_spot_planes(&PsdFile::from_bytes(&bytes).unwrap()), "{what}"); + let opened = crate::import("x.psd", &bytes).unwrap().document; + assert_eq!(ink(&opened), ink(&doc), "{what}"); + assert_eq!(spots(&opened), spots(&doc), "{what}"); + } + } + + /// The rule needs a spot in DisplayInfo and no 1053, besides PhotoCraft's 1057. + #[test] + fn the_earlier_photocraft_rule_needs_a_spot_and_no_alpha_identifiers() { + let mut doc = channels_document(SampleType::U8); + let old = PsdFile::from_bytes(&as_earlier_photocraft_saved(&doc, version_info_2026(true), false)).unwrap(); + assert!(earlier_photocraft_spot_planes(&old)); + let mut with_ids = old.clone(); + with_ids.resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers(false, 3))); + assert!(!earlier_photocraft_spot_planes(&with_ids), "a 1053"); + let mut no_info = old.clone(); + no_info.resources.retain(|r| r.id != crate::channel_map::DISPLAY_INFO); + assert!(!earlier_photocraft_spot_planes(&no_info), "no DisplayInfo"); + doc.channels.retain(|c| c.spot.is_none()); + let alpha_only = PsdFile::from_bytes(&as_earlier_photocraft_saved(&doc, version_info_2026(true), false)).unwrap(); + assert!(!earlier_photocraft_spot_planes(&alpha_only), "alpha channels only"); + } } diff --git a/crates/io/src/tiff_layers.rs b/crates/io/src/tiff_layers.rs index 4d9489d54a..2764ad83ce 100644 --- a/crates/io/src/tiff_layers.rs +++ b/crates/io/src/tiff_layers.rs @@ -21,7 +21,7 @@ use photocraft_raster::Surface; use crate::flat::{csample, encode_image, image_to_document, layout_for, single_layer, try_buffer}; use crate::psd_export::PsdExportOptions; -use crate::psd_import::{PsdImportOptions, psd_to_document_decoded}; +use crate::psd_import::psd_to_document; use crate::{ExportOptions, ExportResult, ImportResult, IoError}; /// `true` when saving `doc` as TIFF writes layer data: anything beyond a single Background @@ -130,13 +130,11 @@ pub(crate) fn import_layered(name: &str, img: &Image, layers: &[u8]) -> Result 0 { - resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers(kept))); + resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers(false, kept))); } // Resource 1022 names a channel of the PSD merged image, which counts the transparency plane. // The IFD below does not, so the id moves back by one. @@ -812,7 +808,7 @@ fn channel_resources(existing: Option<&[u8]>, names: &[&str], channels: &[&Alpha resources.push(ImageResource::new(1006, crate::psd_export::pascal_names_resource(names))); resources.push(ImageResource::new(1045, crate::psd_export::unicode_names_resource(names))); resources.push(ImageResource::new(crate::channel_map::DISPLAY_INFO, crate::channel_map::display_info(channels, false))); - resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers(names.len()))); + resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers(false, names.len()))); if let Some(id) = quick_id { let mut data = id.to_be_bytes().to_vec(); data.push(0); diff --git a/crates/io/tests/tiff_layers.rs b/crates/io/tests/tiff_layers.rs index 49f0076728..8caf15c7c8 100644 --- a/crates/io/tests/tiff_layers.rs +++ b/crates/io/tests/tiff_layers.rs @@ -665,7 +665,7 @@ fn ink(d: &Document) -> (f32, f32) { fn photoshop_transparency_and_spot_tiff(doc: &Document, layers: bool) -> Vec { use photocraft_psd::{Compression, TaggedBlock}; - let opts = PsdExportOptions { merged_matte: false, merged_compression: Compression::Raw, photoshop_spot_polarity: true, ..Default::default() }; + let opts = PsdExportOptions { merged_matte: false, merged_compression: Compression::Raw, ..Default::default() }; let (file, _) = document_to_psd_with(doc, &opts); let planes = file.decode_merged().unwrap(); let n = 16; @@ -850,8 +850,8 @@ fn assert_photoshop_layered_tiff(bytes: &[u8], with_spot: bool) { /// Photoshop 27's Kato-Karate TIFF stores spot ink inverted: every non-white artwork pixel /// has spot 0, and the white background is spot 255. An alpha channel is the other way -/// around (255 = selected). A PSD keeps storing both planes straight, as earlier versions did, -/// and a TIFF opened and saved as PSD does the same. Everything round-trips. +/// around (255 = selected). Photoshop's PSDs store both the same way, and so does a PSD saved +/// here. Everything round-trips, PSD → TIFF → PSD included. #[test] fn spot_ink_is_stored_as_zero_and_alpha_is_not() { use photocraft_color::{Color, PixelFormat}; @@ -891,11 +891,14 @@ fn spot_ink_is_stored_as_zero_and_alpha_is_not() { let first = 3 + usize::from(file.merged_has_alpha()); let spot_plane = &merged[first * plane..(first + 1) * plane]; let alpha_plane = &merged[(first + 1) * plane..(first + 2) * plane]; - // Background (0,0) and artwork (3,3), both straight: max = solid ink, max = selected. - assert_stored(spot_plane, 0, depth, true, "psd spot background"); - assert_stored(spot_plane, (3 * w as usize + 3) * bps, depth, false, "psd spot art"); + // Background (0,0) and artwork (3,3). Spot: 0 = solid ink, max = paper. + // Alpha: max = selected, 0 = empty. + assert_stored(spot_plane, 0, depth, false, "psd spot background"); + assert_stored(spot_plane, (3 * w as usize + 3) * bps, depth, true, "psd spot art"); assert_stored(alpha_plane, 0, depth, true, "psd alpha background"); assert_stored(alpha_plane, (3 * w as usize + 3) * bps, depth, false, "psd alpha art"); + // The merged transparency (0), then the spot and the alpha channel (3, 4). + assert_eq!(file.resource(1053).map(|r| identifiers(&r.data)), Some(vec![0, 3, 4]), "{depth:?}"); let back = import("pol.psd", &psd.bytes).unwrap().document; let area = Rect::new(0, 0, w as i32, h as i32); assert_eq!(back.channels[0].surface.to_interleaved(area), doc.channels[0].surface.to_interleaved(area), "{depth:?} psd spot"); @@ -905,7 +908,8 @@ fn spot_ink_is_stored_as_zero_and_alpha_is_not() { if depth == SampleType::U8 { for layers in [false, true] { - let r = export(&doc, "pol.tif", &ExportOptions { tiff_layers: layers, ..ExportOptions::default() }).unwrap(); + // The document as opened from the PSD, so the PSD's own resources come along. + let r = export(&back, "pol.tif", &ExportOptions { tiff_layers: layers, ..ExportOptions::default() }).unwrap(); let (spp, _bps, extra, _rows, samples) = independent_samples(&r.bytes); assert_eq!((spp, extra.as_slice()), (5, [0u16, 0].as_slice()), "{layers}"); // Reference TIFF: artwork spot sample is 0, background spot sample is 255. @@ -913,19 +917,40 @@ fn spot_ink_is_stored_as_zero_and_alpha_is_not() { assert_eq!(samples[(3 * w as usize + 3) * 5 + 3], 0, "{layers} art spot"); assert_eq!(samples[4], 0, "{layers} background alpha"); assert_eq!(samples[(3 * w as usize + 3) * 5 + 4], 255, "{layers} art alpha"); - let back = import("pol.tif", &r.bytes).unwrap().document; - assert_eq!(back.channels[0].surface.to_interleaved(area), doc.channels[0].surface.to_interleaved(area), "{layers}"); - assert_eq!(back.channels[1].surface.to_interleaved(area), doc.channels[1].surface.to_interleaved(area), "{layers}"); - // Saved as PSD: straight planes, and no 1053 (the TIFF's isn't kept on open). - let psd = PsdFile::from_bytes(&export(&back, "pol.psd", &ExportOptions::default()).unwrap().bytes).unwrap(); + // One identifier per extra sample, numbered from 3 (no transparency sample). + assert_eq!(tiff_alpha_identifiers(&r.bytes), [3, 4], "{layers}"); + let from_tiff = import("pol.tif", &r.bytes).unwrap().document; + assert_eq!(from_tiff.channels[0].surface.to_interleaved(area), doc.channels[0].surface.to_interleaved(area), "{layers}"); + assert_eq!(from_tiff.channels[1].surface.to_interleaved(area), doc.channels[1].surface.to_interleaved(area), "{layers}"); + assert!(from_tiff.channels[0].spot.is_some() && from_tiff.channels[1].spot.is_none(), "{layers}"); + // Saved as PSD again: the first PSD's planes, and one 1053 of its own. The flat TIFF's + // composite was matted on white, so only the layered one brings transparency back. + let psd = PsdFile::from_bytes(&export(&from_tiff, "pol.psd", &ExportOptions::default()).unwrap().bytes).unwrap(); let again = psd.decode_merged().unwrap(); assert_eq!(again[again.len() - 2 * plane..], merged[(first * plane)..(first + 2) * plane], "{layers} tiff to psd"); - assert!(psd.resource(1053).is_none(), "{layers} tiff to psd"); + assert_eq!(psd.merged_has_alpha(), layers, "{layers} tiff to psd"); + let want: Vec = if layers { vec![0, 3, 4] } else { vec![3, 4] }; + assert_eq!(psd.resources.iter().filter(|r| r.id == 1053).map(|r| identifiers(&r.data)).collect::>(), [want], "{layers} tiff to psd"); + let reopened = import("pol.psd", &psd.to_bytes().unwrap()).unwrap().document; + assert_eq!(reopened.channels[0].surface.to_interleaved(area), doc.channels[0].surface.to_interleaved(area), "{layers}"); + assert_eq!(reopened.channels[1].surface.to_interleaved(area), doc.channels[1].surface.to_interleaved(area), "{layers}"); } } } } +/// The big-endian u32s of a resource 1053. +fn identifiers(data: &[u8]) -> Vec { + data.as_chunks::<4>().0.iter().map(|c| u32::from_be_bytes(*c)).collect() +} + +/// The identifiers in a TIFF's resource 1053 (none without one). +fn tiff_alpha_identifiers(bytes: &[u8]) -> Vec { + let resources = tags(bytes).0.expect("photoshop resources"); + let (blocks, _) = photocraft_psd::tiff::resources_from_bytes(&resources).unwrap(); + blocks.iter().find(|b| b.id == 1053).map(|b| identifiers(&b.data)).unwrap_or_default() +} + /// `at` addresses one sample of a big-endian PSD plane. `zero` expects 0; otherwise the /// maximum sample (255 / 65535 / 1.0). fn assert_stored(plane: &[u8], at: usize, depth: SampleType, zero: bool, what: &str) { diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index e2fc72c8ed..a2752b1346 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File-format parity -> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-21 · **Change:** minor (TIFF writes and reads alpha and spot channels as extra samples with Photoshop's channel resources, PSD output unchanged, FILE-215-7, FILE-215-17's TIFF part, #7415; earlier the same day: Photoshop's `MTrn` merged-transparency marker, from a layered TIFF saved with Save Transparency, marks the merged transparency; earlier: DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-21 · **Change:** minor (PSD stores spot channels as Photoshop does, ink 0 = solid, and numbers them in 1053; PSDs from earlier PhotoCraft versions keep their ink; earlier the same day: TIFF writes and reads alpha and spot channels as extra samples with Photoshop's channel resources, PSD output unchanged, FILE-215-7, FILE-215-17's TIFF part, #7415; earlier the same day: Photoshop's `MTrn` merged-transparency marker, from a layered TIFF saved with Save Transparency, marks the merged transparency; earlier: DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; 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 @@ -21,7 +21,7 @@ XL are missing (gap G10). Remaining: 300–500 h including PSD fidelity. | Format | Photoshop | PhotoCraft read | PhotoCraft write | Fidelity and tests | |---|---|---|---|---| -| PSD | R/W | yes | yes | 1/8/16/32-bit; Bitmap, Gray, Indexed, RGB, CMYK, Multichannel, Lab, Duotone; layers, groups, masks, vector masks, adjustment and fill layers, effects, text, shapes, smart objects (SoLd/lnk2; CS2 PlLd/lnkD read with their warp, kept as is or re-saved as SoLd once edited), smart filters (14 mapped plus Filter Gallery with Chrome, rest verbatim), slices, comps, Advanced Blending. Oracle floors: Photoshop-authored 188/258, io 148/170, psd-tools 249/309; round trip ≥ 169/170, 308/309, 258/256. Known failures: #1281, #2469 (#2374, text layers, closed 2026-10-10; #2465, CS2 `PlLd`-only smart objects, fixed 2026-10-12) | +| PSD | R/W | yes | yes | 1/8/16/32-bit; Bitmap, Gray, Indexed, RGB, CMYK, Multichannel, Lab, Duotone; layers, groups, masks, vector masks, adjustment and fill layers, effects, text, shapes, smart objects (SoLd/lnk2; CS2 PlLd/lnkD read with their warp, kept as is or re-saved as SoLd once edited), smart filters (14 mapped plus Filter Gallery with Chrome, rest verbatim), slices, comps, Advanced Blending; alpha and spot channels as Photoshop stores them (spot ink 0 = solid, channel identifiers in 1053), and PSDs with spot channels from PhotoCraft 0.1.0–0.11.1, which stored the ink the other way round, keep their ink. Oracle floors: Photoshop-authored 188/258, io 148/170, psd-tools 249/309; round trip ≥ 169/170, 308/309, 258/256. Known failures: #1281, #2469 (#2374, text layers, closed 2026-10-10; #2465, CS2 `PlLd`-only smart objects, fixed 2026-10-12) | | PSB | R/W | yes | yes | Auto-switches above 2 GB (REL-212-2); 4–5 GB fixtures generated (FILE-216-2); > 4 GB fails on Windows (#375) | | Cloud PSD (.psdc) | R/W | no | no | Out of scope (Adobe cloud) | | TIFF | R/W | yes | yes | 8/16/32f, Gray/RGB/CMYK, BigTIFF, every IFD, banded parallel decode; layered TIFF both byte orders (FILE-215-7); alpha and spot channels as extra samples (at most 16) with Photoshop's names, ink colours and solidity, spot ink stored 0 = solid (#7415); no Save Transparency choice yet (channels are written as Photoshop does with it off) | @@ -142,6 +142,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings. | Date | Change | Summary | |---|---|---| +| 2026-10-21 | minor | PSD: spot channels are stored and read as Photoshop 27.11's PSDs store them (ink 0 = solid; all 7 of its spot PSDs store the 100/25/75/0 % columns as 0/191/64/255), and resource 1053 numbers the extra channels 3, 4, 5, … after 0 for the merged transparency. A PSD with spot channels and no 1053 whose 1057 is exactly what PhotoCraft 0.1.0–0.11.1 wrote is read as those versions stored it (straight), so it keeps its ink. Multichannel is unchanged (#7415 split, part 4) | | 2026-10-21 | minor | TIFF: alpha and spot channels are written and read as extra samples (at most 16) with Photoshop's channel resources (1006, 1045, 1077, 1053), spot ink stored 0 = solid as Photoshop 27.11's TIFFs store it; PSD output is unchanged. FILE-215-7 done, FILE-215-17 partial (its TIFF part) (#7415, supersedes #3121) | | 2026-10-21 | patch | PSD and layered TIFF: the `MTrn` block Photoshop writes in a layered TIFF saved with Save Transparency (a positive layer count, `nrTM` in an `II` file) marks the merged image's first extra channel as its transparency, like `Mtrn`/`Mt16`/`Mt32`: such a file no longer opens with its transparency also as an alpha channel (named "Transparency" in Photoshop 27.11's file), and a PSD save no longer writes it twice. A PSD save with an opaque composite drops any of these markers kept from the opened file, so its first alpha channel no longer reopens as transparency and vanishes (split from #7415; credit #3121) | | 2026-10-15 | minor | DDS textures save (#1327): uncompressed or BC1/BC2/BC3 (DXT1/3/5) from a clean-room block encoder, optional box-filtered mip chain, legacy header; DDS Options in Save As and Save a Copy, `ddsCompression`/`ddsMipmaps` for scripts, the CLI and MCP | diff --git a/docs/gaps.md b/docs/gaps.md index 647c121998..bfeb37cd29 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where PhotoCraft falls short of Photoshop -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-21 · **Change:** minor (G10: TIFF alpha and spot channels written and read as extra samples, FILE-215-7 done, FILE-215-17's TIFF part, #7415; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-21 · **Change:** minor (G10: PSD spot channels in Photoshop's polarity, earlier PhotoCraft PSDs keep their ink; earlier the same day: G10: TIFF alpha and spot channels written and read as extra samples, FILE-215-7 done, FILE-215-17's TIFF part, #7415; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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 @@ -230,10 +230,13 @@ what an agent can't finish alone. write (FILE-215-10, #2541; a single flattened page now saves via Save As / Save a Copy / CLI, 2026-10-11, #3401), AVIF read (#463) and default-build AVIF write, JPEG XL, JPEG 2000 (#1047), Cineon write (read landed), DICOM, EPS/DCS, Pixar, IFF, WBMP, MPO/JPS, PICT, Scitex CT, Photoshop - Raw; spot plates beyond TIFF: spot ink preview in RGB/CMYK documents and PDF Separation + Raw; spot plates beyond PSD and TIFF: spot ink preview in RGB/CMYK documents and PDF Separation (FILE-215-17); .atn, .asl, .shc, .csh presets (FILE-215-15); C2PA (#1050). - **Detail:** [`file-format-parity.md`](file-format-parity.md). +- **Progress (2026-10-21, #7415 split):** PSD stores and reads spot channels as Photoshop does (ink + 0 = solid) and writes their identifiers (1053); PSDs from PhotoCraft 0.1.0–0.11.1, which stored + spot ink the other way round, keep their ink. - **Progress (2026-10-21, #7415):** TIFF writes and reads alpha and spot channels as extra samples with Photoshop's names, ink colours and solidity (FILE-215-7 done; FILE-215-17's TIFF part). - **Progress (2026-10-13):** Cineon (`.cin`) 10-bit gray/RGB frames open read-only, sharing the @@ -277,6 +280,7 @@ what an agent can't finish alone. | Date | Change | Summary | |---|---|---| +| 2026-10-21 | minor | G10: PSD stores and reads spot channels as Photoshop does (ink 0 = solid) with their identifiers (1053); PSDs from PhotoCraft 0.1.0–0.11.1 keep their ink (#7415 split, part 4); FILE-215-17 stays partial; estimate unchanged | | 2026-10-21 | minor | G10: TIFF alpha and spot channels written and read as extra samples with Photoshop's channel resources, PSD output unchanged (#7415); FILE-215-7 leaves the list, FILE-215-17 narrows to RGB/CMYK spot preview and PDF Separation | | 2026-10-15 | minor | G1 / #5972 A1: render only provably constant-RGB `GdFl` noise fills; variable noise synthesis remains open | | 2026-10-18 | minor | G9: with no selection, Copy takes fill and adjustment layers whole and Paste recreates them (#2344); UI-217-23 stays partial (a single pixel layer copies its pixels only); estimate unchanged | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 6e8449e38e..b76db16467 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,6 +1,6 @@ # PhotoCraft vs Adobe Photoshop: target-app parity -> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-21 · **Change:** minor (TIFF spot plates, FILE-215-17's TIFF part, #7415; fill and adjustment layers copy and paste whole, UI-217-23 partial, #2344; on-canvas corner radius widgets, TOOL-214-12; `.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 +> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-21 · **Change:** minor (PSD spot plates in Photoshop's polarity, #7415 split; earlier the same day: TIFF spot plates, FILE-215-17's TIFF part, #7415; fill and adjustment layers copy and paste whole, UI-217-23 partial, #2344; on-canvas corner radius widgets, TOOL-214-12; `.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); @@ -175,7 +175,7 @@ parity for the area and are already contained in the dimension rows above. | Adjustments and filters | 70% | 120–200 | All present; smart-filter re-render matches Photoshop on 5 of 30 files; Filter Gallery looks approximate; no Neural Filters | | Type | 40% | 120–200 | Engine works; no type on a path, manual kerning, RTL paragraphs, OpenType panel UI, live Warp Text preview; Type tool freeze on macOS (#2518) | | Vector shapes and paths | 55% | 80–140 | Pen, Direct/Path Selection, shapes, shape strokes. Freeform and Curvature Pen (#1054). Add/Delete Anchor Point and Convert Point tools exist (`Tool` enum); on-canvas corner radius widgets on live rectangles (TOOL-214-12, 2026-10-13); missing path-point nudge; shape parity tracking issue #2496 | -| Colour management and modes | 70% | 60–100 | Own ICC engine, soft proof, CMYK/Lab/Indexed/Duotone/Multichannel; no Adobe CMYK profiles, spot plates in TIFF only (FILE-215-17: no RGB/CMYK spot preview or PDF Separation), monitor profile only at launch | +| Colour management and modes | 70% | 60–100 | Own ICC engine, soft proof, CMYK/Lab/Indexed/Duotone/Multichannel; no Adobe CMYK profiles, spot plates in PSD and TIFF only (FILE-215-17: no RGB/CMYK spot preview or PDF Separation), monitor profile only at launch | | Camera Raw and computational photo (Photomerge, HDR, lens) | 45% | 120–200 | Raw for DNG/CR2/NEF/ARW/RW2/ORF/RAF(uncompressed)/PEF; no CR3; ACR dialog partial (no masking, calibration); generic lens profiles only | | Automation, actions, batch, scripting | 45% | 120–200 | CLI/MCP/control channel ahead of Photoshop; Actions panel and recording not document-independent (AUTO-219-1/2); `.atn` load/save since 2026-10-12 (112 events mapped, the rest kept verbatim); no ExtendScript/UXP | | File I/O | 60% | 300–500 | See [file-format-parity.md](file-format-parity.md) | @@ -565,6 +565,7 @@ See [method, raw measurements and reproduction](five-algorithm-performance.md). | Date | Change | Summary | |---|---|---| +| 2026-10-21 | minor | Colour management and modes: PSD spot plates are stored as Photoshop stores them (ink 0 = solid), and PSDs from earlier PhotoCraft versions keep their ink (#7415 split, part 4); estimates unchanged | | 2026-10-21 | minor | Colour management and modes: spot plates now save and open in TIFF (#7415); estimates unchanged | | 2026-10-18 | minor | Layers: with no selection, Copy takes fill and adjustment layers whole and Paste recreates them (#2344); UI-217-23 stays partial; percentages unchanged | | 2026-10-13 | minor | Vector shapes: on-canvas corner radius widgets on live rectangles (TOOL-214-12); estimates unchanged | diff --git a/scorecard/file_compat.toml b/scorecard/file_compat.toml index 84738c1455..b9a2c1a744 100644 --- a/scorecard/file_compat.toml +++ b/scorecard/file_compat.toml @@ -122,7 +122,7 @@ id = "FILE-215-17" target = "CMYK/RGB documents preview spot inks; spot plates export (TIFF extra samples, PDF)" status = "partial" issue = 215 -note = "TIFF: spot channels written and read as extra samples with DisplayInfo (1077) ink colour and solidity, ink stored 0 = solid (#7415). Missing: spot ink preview in RGB/CMYK documents (compose multichannel.rs:1 previews Multichannel only) and PDF Separation" +note = "TIFF: spot channels written and read as extra samples with DisplayInfo (1077) ink colour and solidity, ink stored 0 = solid (#7415). PSD: spot planes stored and read 0 = solid as Photoshop does, identifiers in 1053; PhotoCraft 0.1.0–0.11.1 PSDs (straight planes) keep their ink. Missing: spot ink preview in RGB/CMYK documents (compose multichannel.rs:1 previews Multichannel only) and PDF Separation" [[item]] id = "FILE-215-18" From 9ec668e86d7395e92a6b5e0e41c7d0b46e6030cb Mon Sep 17 00:00:00 2001 From: Jason D Date: Wed, 21 Oct 2026 13:33:58 -0400 Subject: [PATCH 224/649] psd_import: test an early PhotoCraft PSD whose first extra channel is an alpha In 0.1.0-0.7.0's 14-byte DisplayInfo records the spots after an alpha channel are found only by the padded reading; the planes are read straight and keep their ink. A 2 % spot's opacity byte reads as kind 2 in 13-byte records: without the rule that plane would be inverted. Co-Authored-By: Claude Opus 5.5 --- crates/io/src/psd_import.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/crates/io/src/psd_import.rs b/crates/io/src/psd_import.rs index 14118c2c86..0fa5470f4b 100644 --- a/crates/io/src/psd_import.rs +++ b/crates/io/src/psd_import.rs @@ -1306,6 +1306,38 @@ mod tests { } } + /// A 0.1.0 to 0.7.0 file whose first extra channel is an alpha channel, spots after it. In its + /// 14-byte DisplayInfo records the spots' kind bytes sit where a 13-byte reader (main's, and + /// this one's) doesn't look, so only the padded reading finds a spot for the rule. Every plane + /// is then read straight, as those versions read it, and keeps its ink. The 13-byte reader + /// opens each channel's options from shifted bytes, as on main: here every channel opens as + /// an alpha channel. A spot of 2 % solidity puts a 2 where that reader looks for the kind, so + /// that channel opens as a spot: without the rule its plane would be inverted. Saved again and + /// reopened, every channel keeps its ink and kind. + #[test] + fn an_early_file_with_an_alpha_channel_first_keeps_its_ink() { + for solidity in [0.0, 0.02] { + let mut doc = channels_document(SampleType::U8); + doc.channels.swap(0, 1); + doc.channels[1].spot = Some((photocraft_color::Color::rgb(0.0, 0.627, 1.0), solidity)); + let names: Vec<&str> = doc.channels.iter().map(|c| c.name.as_str()).collect(); + assert_eq!(names, ["Alpha 1", "Spot A", "Spot B"]); + let bytes = as_earlier_photocraft_saved(&doc, version_info_cs6(true), true); + let file = PsdFile::from_bytes(&bytes).unwrap(); + let info = &file.resource(crate::channel_map::DISPLAY_INFO).unwrap().data; + let misread = solidity > 0.0; + assert_eq!(crate::channel_map::spot_flags(info, true, 0), [false, misread, false], "{solidity}: 13-byte records"); + assert!(earlier_photocraft_spot_planes(&file), "{solidity}: found in the 14-byte records"); + let opened = crate::import("old.psd", &bytes).unwrap().document; + assert_eq!(ink(&opened), ink(&doc), "{solidity}: the ink 0.7.0 opened"); + assert_eq!(spots(&opened), [false, misread, false], "{solidity}: kinds as main reads them"); + let saved = crate::export(&opened, "old.psd", &crate::ExportOptions::default()).unwrap(); + let again = crate::import("again.psd", &saved.bytes).unwrap().document; + assert_eq!(ink(&again), ink(&doc), "{solidity}: saved again"); + assert_eq!(spots(&again), spots(&opened), "{solidity}: saved again"); + } + } + /// A file with spots and no 1053 that no earlier PhotoCraft wrote is read in Photoshop's /// polarity (0 = solid ink). psd-tools' `cmyk-spot.psd` is one: its 1057 names psd-tools as /// writer and reader. So is a file with no 1057, with Photoshop CS6's names without the NUL, From 6e3fe3dd9e3f0b147cc6512b4e4b1300a7e2455a Mon Sep 17 00:00:00 2001 From: Jason D Date: Wed, 21 Oct 2026 16:26:58 -0400 Subject: [PATCH 225/649] io: drop 1053 on PSD open; never copy a kept one on save Every save now writes 1053 for the extra channels, so a copy kept on open grew the document's metadata on each round trip (the roundtrip and tiff_layers suites caught it), as #7415 found. Multichannel keeps its 1053. The layered writer never copies a kept 1053: next to the fresh one it would be a second, and without channels it would list channels that are gone. Co-Authored-By: Claude Opus 5.5 --- crates/io/src/psd_export.rs | 27 +++++++++++++++++---------- crates/io/src/psd_import.rs | 4 ++++ crates/io/src/tiff_layers.rs | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/crates/io/src/psd_export.rs b/crates/io/src/psd_export.rs index daa25ca2bc..256f578236 100644 --- a/crates/io/src/psd_export.rs +++ b/crates/io/src/psd_export.rs @@ -1826,8 +1826,10 @@ fn document_to_psd_nested(doc: &Document, opts: &PsdExportOptions, depth: u32, c if !keep_imported_resource(doc, *id, data) { continue; } - // A fresh 1053 was written with the extra channels; a preserved copy would be a second one. - if *id == crate::channel_map::ALPHA_IDENTIFIERS && !extra.is_empty() { + // 1053 is written afresh with the extra channels. A kept copy (from a Multichannel file, or + // a document saved by an earlier version) would be a second one, or list channels that + // are gone. + if *id == crate::channel_map::ALPHA_IDENTIFIERS { continue; } let mut r = ImageResource::new(*id, data.to_vec()); @@ -2030,20 +2032,25 @@ mod tests { assert_eq!(alpha_ids(&file), Some(vec![0, 3, 4])); } - /// A Photoshop file's own 1053 is kept on open (as every unmapped resource is), but a save - /// writes one fresh 1053 for the channels the document has, never the kept one as well. The + /// A save writes one fresh 1053 for the channels the document has. A Photoshop file's own is + /// not kept on open (it would be new metadata after every round trip), and one a document + /// carries anyway (kept by an earlier version) is never written: next to the fresh one it + /// would be a second, and without channels it would list channels that are gone. The /// identifiers here, 3 and 2, are those of psd-tools' `cmyk-alpha-spot.psd` (Photoshop 24.7). #[test] - fn a_kept_alpha_identifiers_resource_is_not_written_twice() { + fn a_kept_alpha_identifiers_resource_is_not_written() { + let kept = || (crate::channel_map::ALPHA_IDENTIFIERS, String::new(), std::sync::Arc::new([0, 0, 0, 3, 0, 0, 0, 2].to_vec())); let mut file = document_to_psd(&spot_and_alpha_document()); file.resources.retain(|r| r.id != crate::channel_map::ALPHA_IDENTIFIERS); - file.resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, [0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2].to_vec())); - let opened = crate::import("ps.psd", &file.to_bytes().unwrap()).unwrap().document; - assert!(opened.metadata.psd_resources.iter().any(|(id, ..)| *id == crate::channel_map::ALPHA_IDENTIFIERS)); - let saved = crate::export(&opened, "x.psd", &crate::ExportOptions::default()).unwrap(); - let again = PsdFile::from_bytes(&saved.bytes).unwrap(); + file.resources.push(ImageResource::new(kept().0, kept().2.to_vec())); + let mut opened = crate::import("ps.psd", &file.to_bytes().unwrap()).unwrap().document; + assert!(!opened.metadata.psd_resources.iter().any(|(id, ..)| *id == crate::channel_map::ALPHA_IDENTIFIERS)); + opened.metadata.psd_resources.push(kept()); + let again = PsdFile::from_bytes(&crate::export(&opened, "x.psd", &crate::ExportOptions::default()).unwrap().bytes).unwrap(); assert_eq!(again.resources.iter().filter(|r| r.id == crate::channel_map::ALPHA_IDENTIFIERS).count(), 1); assert_eq!(alpha_ids(&again), Some(vec![0, 3, 4])); + opened.channels.clear(); + assert_eq!(alpha_ids(&document_to_psd(&opened)), None, "no channels left"); } #[test] diff --git a/crates/io/src/psd_import.rs b/crates/io/src/psd_import.rs index 0fa5470f4b..fbfa691c62 100644 --- a/crates/io/src/psd_import.rs +++ b/crates/io/src/psd_import.rs @@ -873,6 +873,10 @@ pub(crate) fn psd_to_document_decoded( doc.clipping_path = Some(photocraft_doc::ClippingPath { name, flatness: 0.0 }); doc.metadata.psd_resources.push((r.id, String::from_utf8_lossy(&r.name).into_owned(), Arc::new(r.data.clone()))); } + // Resource 1053 is written afresh with the extra channels on every save, so a kept copy + // would be new metadata after each round trip. Multichannel has no such rewrite: the + // imported bytes are the channel ids, copied back while they still match. + crate::channel_map::ALPHA_IDENTIFIERS if !multichannel => {} id if MAPPED_RESOURCES.contains(&id) => {} id => doc.metadata.psd_resources.push((id, String::from_utf8_lossy(&r.name).into_owned(), Arc::new(r.data.clone()))), } diff --git a/crates/io/src/tiff_layers.rs b/crates/io/src/tiff_layers.rs index 2764ad83ce..401495a1ec 100644 --- a/crates/io/src/tiff_layers.rs +++ b/crates/io/src/tiff_layers.rs @@ -296,7 +296,7 @@ pub(crate) fn export_layered(doc: &Document, opts: &ExportOptions, ctl: &photocr // it, so a plain transparent TIFF still opens with alpha. let write_alpha = has_alpha && kept == 0; // One identifier per extra sample actually stored. The PSD model's 1053 lists the merged - // transparency too, and a kept one lists an opened file's channels, so neither is copied. + // transparency too, which the IFD leaves out next to extra samples, so it is not copied. resources.retain(|r| r.id != crate::channel_map::ALPHA_IDENTIFIERS); if kept > 0 { resources.push(ImageResource::new(crate::channel_map::ALPHA_IDENTIFIERS, crate::channel_map::alpha_identifiers(false, kept))); From 9451ed7557409b766d930559c1d2a6631a8f4142 Mon Sep 17 00:00:00 2001 From: Nicolas Falesy <112726756+nicolasfalesy@users.noreply.github.com> Date: Thu, 22 Oct 2026 00:49:01 -0400 Subject: [PATCH 226/649] test(histogram): build the parallel-path test only off wasm32 (CodeRabbit) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CD2ipSyvx1tYwnHJZyDs59 --- crates/algo/src/histogram.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/algo/src/histogram.rs b/crates/algo/src/histogram.rs index 2d3df42dc9..849b222c2a 100644 --- a/crates/algo/src/histogram.rs +++ b/crates/algo/src/histogram.rs @@ -127,6 +127,8 @@ pub fn clipping(p: [f32; 4]) -> (u8, u8) { mod tests { use super::*; + // The parallel path, and its threshold, exist only off wasm32. + #[cfg(not(target_arch = "wasm32"))] #[test] fn matches_the_single_pass_on_every_domain_and_across_block_edges() { // Every special value at every channel, plus a dense ramp through each bin's rounding From b2c5056a088a4072e8dcd64cc95f7010d1f0d434 Mon Sep 17 00:00:00 2001 From: Khawar Zamman Wani Date: Thu, 22 Oct 2026 10:28:45 +0530 Subject: [PATCH 227/649] fix(color-panel): non-finite pointer no longer panics the wheel; ramp drag keeps its ends triangle_sv returns None for a non-finite point instead of clamping with a NaN bound. A drag on the Current Colors ramp draws and picks from the ends it began with, so a held pick no longer drifts toward the background. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/color_panel_tests.rs | 38 +++++++++++++++++++++++++ crates/ui-egui/src/color_panel_ui.rs | 29 ++++++++++++++----- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/color_panel_tests.rs b/crates/ui-egui/src/color_panel_tests.rs index 956d07ad42..5922fa9001 100644 --- a/crates/ui-egui/src/color_panel_tests.rs +++ b/crates/ui-egui/src/color_panel_tests.rs @@ -247,6 +247,44 @@ fn ramp_picks_and_shift_click_cycles_and_alt_picks_the_other_colour() { assert!(bytes(h.state().session.tools.foreground).iter().all(|v| *v > 245)); } +/// A drag on the Current Colors ramp picks from the ends it began with: holding still keeps the +/// colour under the pointer instead of drifting toward the background. +#[test] +fn current_colors_ramp_drag_keeps_its_ends() { + let mut h = color_tab(ThemeKind::BreezeDark, ColorPanelMode::RgbSliders, [0.0, 0.0, 0.0, 1.0]); + h.state_mut().session.tools.background = [1.0, 1.0, 1.0, 1.0]; + h.state_mut().ui.color_panel.ramp = ColorRamp::CurrentColors; + h.run_steps(2); + let ramp: Rect = h.get_by_label("Color Ramp").rect(); + let p = ramp.center(); + h.hover_at(p); + h.event(egui::Event::PointerButton { pos: p, button: egui::PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE }); + h.run_steps(1); + // Move away and back to start the drag, then hold still for a while. + for q in [p + vec2(12.0, 0.0), p] { + h.event(egui::Event::PointerMoved(q)); + h.run_steps(1); + } + h.run_steps(20); + h.event(egui::Event::PointerButton { pos: p, button: egui::PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE }); + h.run_steps(2); + let expected = ramp_color(ColorRamp::CurrentColors, false, [0.0; 3], [1.0; 3], (p.x - ramp.left()) / ramp.width(), 0.5); + let got = bytes(h.state().session.tools.foreground); + for (g, e) in got.iter().zip(expected) { + assert!(i32::from(*g).abs_diff((e * 255.0).round() as i32) <= 3, "{got:?} vs {expected:?}"); + } +} + +/// A non-finite pointer (a huge synthetic `ui.move`) misses the triangle instead of panicking. +#[test] +fn triangle_ignores_non_finite_points() { + let tri = [pos2(100.0, 0.0), pos2(0.0, 0.0), pos2(0.0, 100.0)]; + for p in [pos2(f32::INFINITY, f32::INFINITY), pos2(f32::NAN, 1.0), pos2(f32::NEG_INFINITY, f32::INFINITY)] { + assert_eq!(crate::color_panel_ui::triangle_sv(tri, p), None, "{p:?}"); + } + assert!(crate::color_panel_ui::triangle_sv(tri, pos2(10.0, 10.0)).is_some()); +} + #[test] fn color_wheel_ring_sets_hue_and_triangle_sets_saturation_and_brightness() { let mut h = color_tab(ThemeKind::Pro, ColorPanelMode::ColorWheel, [0.0, 0.0, 1.0, 1.0]); diff --git a/crates/ui-egui/src/color_panel_ui.rs b/crates/ui-egui/src/color_panel_ui.rs index 35b6593f4d..e015be052a 100644 --- a/crates/ui-egui/src/color_panel_ui.rs +++ b/crates/ui-egui/src/color_panel_ui.rs @@ -471,8 +471,17 @@ fn ramp(app: &mut PhotocraftApp, ui: &mut egui::Ui, height: f32) { let bar = Rect::from_min_max(all.min, pos2(all.right() - BOXES_W - 2.0, all.bottom())); let boxes = Rect::from_min_max(pos2(all.right() - BOXES_W, all.top()), all.max); let cp = app.ui.color_panel; - let fg = rgb3(app.session.tools.foreground); - let bg = rgb3(app.session.tools.background); + let ramp_id = ui.id().with("color-panel-ramp"); + // A pick changes the foreground or background, so a drag keeps the Current Colors ends it began + // with; otherwise the ramp would slide under the pointer and a held pick would drift. + let ends_id = ramp_id.with("ends"); + let live = (rgb3(app.session.tools.foreground), rgb3(app.session.tools.background)); + let (fg, bg) = if ui.ctx().is_being_dragged(ramp_id) { + ui.data(|d| d.get_temp::<([f32; 3], [f32; 3])>(ends_id)).unwrap_or(live) + } else { + ui.data_mut(|d| d.insert_temp(ends_id, live)); + live + }; let colors = ramp_colors(ui, cp.ramp, cp.web_safe_ramp, fg, bg); ui.painter().add(ramp_mesh(bar, &colors, cp.web_safe_ramp)); ui.painter().rect_stroke(bar, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Outside); @@ -481,7 +490,7 @@ fn ramp(app: &mut PhotocraftApp, ui: &mut egui::Ui, height: f32) { ui.painter().rect_filled(white, 0.0, Color32::WHITE); ui.painter().rect_filled(black, 0.0, Color32::BLACK); ui.painter().rect_stroke(boxes, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Outside); - let resp = ui.interact(bar, ui.id().with("color-panel-ramp"), Sense::click_and_drag()); + let resp = ui.interact(bar, ramp_id, Sense::click_and_drag()); resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Other, ui.is_enabled(), "Color Ramp")); let mods = ui.input(|i| i.modifiers); let target = cp.background != mods.alt; @@ -643,15 +652,21 @@ fn triangle_point([hue, white, black]: [Pos2; 3], s: f32, b: f32) -> Pos2 { black + (white - black) * b + (hue - white) * (b * s) } -/// Saturation and brightness at `p`, clamped into the triangle; `None` for a degenerate one. -fn triangle_sv([hue, white, black]: [Pos2; 3], p: Pos2) -> Option<(f32, f32)> { +/// Saturation and brightness at `p`, clamped into the triangle; `None` for a degenerate one or a +/// non-finite `p`. +pub(crate) fn triangle_sv([hue, white, black]: [Pos2; 3], p: Pos2) -> Option<(f32, f32)> { let (a, c, d) = (white - black, hue - white, p - black); let det = a.x * c.y - a.y * c.x; if det.abs() < 1e-6 { return None; } - let b = ((d.x * c.y - d.y * c.x) / det).clamp(0.0, 1.0); - let bs = ((a.x * d.y - a.y * d.x) / det).clamp(0.0, b); + let (b, bs) = ((d.x * c.y - d.y * c.x) / det, (a.x * d.y - a.y * d.x) / det); + // A NaN `b` would panic as a clamp bound. + if !b.is_finite() || !bs.is_finite() { + return None; + } + let b = b.clamp(0.0, 1.0); + let bs = bs.clamp(0.0, b); Some((if b > 0.0 { bs / b } else { 0.0 }, b)) } From 4571843c27f668de1c38d4de29b60d19264c068c Mon Sep 17 00:00:00 2001 From: Matt Van Horn Date: Fri, 9 Oct 2026 01:22:02 +0000 Subject: [PATCH 228/649] Add Art History Brush to the Y-group flyout paint.artHistoryBrush stamps oriented dabs sampled from a history state. Styles cover Tight/Loose Short, Medium, Long, Dab, Tight Curl and Loose Curl. Area sets spacing; Tolerance skips dabs whose footprint already matches the source. Scatter is seeded so a stroke replays bit-for-bit. The Y flyout lists History Brush then Art History Brush. The options bar exposes Style, Area and Tolerance. Includes a 24 MP release bench. --- README.md | 4 +- crates/algo/src/art_history.rs | 973 ++++++++++++++++++ crates/algo/src/lib.rs | 1 + crates/engine/examples/bench_art_history.rs | 60 ++ crates/engine/src/channel_cmds.rs | 1 + crates/engine/src/hidden_target.rs | 1 + crates/engine/src/retouch_cmds.rs | 16 +- crates/engine/src/retouch_cmds/art_history.rs | 478 +++++++++ crates/engine/src/retouch_cmds/tests.rs | 8 +- crates/ui-egui/src/canvas.rs | 1 + crates/ui-egui/src/i18n/cs.tsv | 13 + crates/ui-egui/src/i18n/de.tsv | 13 + crates/ui-egui/src/i18n/el.tsv | 12 + crates/ui-egui/src/i18n/es.tsv | 12 + crates/ui-egui/src/i18n/fr.tsv | 13 + crates/ui-egui/src/i18n/id.tsv | 15 +- crates/ui-egui/src/i18n/it.tsv | 12 + crates/ui-egui/src/i18n/ja.tsv | 12 + crates/ui-egui/src/i18n/ko.tsv | 13 + crates/ui-egui/src/i18n/nl.tsv | 12 + crates/ui-egui/src/i18n/pl.tsv | 12 + crates/ui-egui/src/i18n/pt-br.tsv | 12 + crates/ui-egui/src/i18n/ru.tsv | 12 + crates/ui-egui/src/i18n/uk.tsv | 12 + crates/ui-egui/src/i18n/vi.tsv | 13 + crates/ui-egui/src/i18n/zh-hans.tsv | 14 + crates/ui-egui/src/i18n/zh-hant.tsv | 14 + crates/ui-egui/src/icons.rs | 1 + crates/ui-egui/src/panels.rs | 42 +- crates/ui-egui/src/retouch_ui.rs | 82 +- crates/ui-egui/src/state.rs | 29 +- crates/ui-egui/src/tool_reset.rs | 1 + docs/scorecard.md | 3 +- docs/target-app-parity.md | 2 +- scorecard/tools.toml | 7 + 35 files changed, 1911 insertions(+), 15 deletions(-) create mode 100644 crates/algo/src/art_history.rs create mode 100644 crates/engine/examples/bench_art_history.rs create mode 100644 crates/engine/src/retouch_cmds/art_history.rs diff --git a/README.md b/README.md index 1de756458a..e80617155f 100644 --- a/README.md +++ b/README.md @@ -181,8 +181,8 @@ Every screenshot here is the real app at work on public-domain art, rendered off
-

🧰 67 tools

- Move · Artboard · Rectangular and Elliptical Marquee · Single Row Marquee · Single Column Marquee · Lasso · Polygonal Lasso · Magnetic Lasso · Object Selection · Quick Selection · Magic Wand · Crop · Perspective Crop · Slice · Slice Select · Frame · Eyedropper · Color Sampler · Ruler · Note · Count · Remove · Spot Healing Brush · Healing Brush · Patch · Content-Aware Move · Red Eye · Brush · Pencil · Mixer Brush · Color Replacement · Clone Stamp · Pattern Stamp · History Brush · Eraser · Background Eraser · Magic Eraser · Gradient · Paint Bucket · Blur · Sharpen · Smudge · Dodge · Burn · Sponge · Pen · Freeform Pen · Curvature Pen · Add Anchor Point · Delete Anchor Point · Convert Point · Horizontal and Vertical Type · Horizontal and Vertical Type Mask · Path Selection · Direct Selection · Rectangle · Ellipse · Triangle · Polygon · Line · Custom Shape · Hand · Rotate View · Zoom +

🧰 68 tools

+ Move · Artboard · Rectangular and Elliptical Marquee · Single Row Marquee · Single Column Marquee · Lasso · Polygonal Lasso · Magnetic Lasso · Object Selection · Quick Selection · Magic Wand · Crop · Perspective Crop · Slice · Slice Select · Frame · Eyedropper · Color Sampler · Ruler · Note · Count · Remove · Spot Healing Brush · Healing Brush · Patch · Content-Aware Move · Red Eye · Brush · Pencil · Mixer Brush · Color Replacement · Clone Stamp · Pattern Stamp · History Brush · Art History Brush · Eraser · Background Eraser · Magic Eraser · Gradient · Paint Bucket · Blur · Sharpen · Smudge · Dodge · Burn · Sponge · Pen · Freeform Pen · Curvature Pen · Add Anchor Point · Delete Anchor Point · Convert Point · Horizontal and Vertical Type · Horizontal and Vertical Type Mask · Path Selection · Direct Selection · Rectangle · Ellipse · Triangle · Polygon · Line · Custom Shape · Hand · Rotate View · Zoom

🖌️ A real brush engine

diff --git a/crates/algo/src/art_history.rs b/crates/algo/src/art_history.rs new file mode 100644 index 0000000000..394b825b0f --- /dev/null +++ b/crates/algo/src/art_history.rs @@ -0,0 +1,973 @@ +//! Oriented history-state dabs: sample a snapshot patch, pose it along the stroke, and stamp. +//! +//! Tile processing reads a halo around each destination tile so a dab whose centre sits one pixel +//! inside a tile still sees the same source as an untiled pass. Scatter is seeded, so the same +//! stroke is replayable. + +#![allow(clippy::needless_range_loop)] + +/// Mixes the history-state index into dab scatter so two documents with different snapshots diverge. +pub const RNG_SEED: u32 = 0xA7B1_57E0; + +/// Largest number of dabs one stroke may emit. +pub const MAX_DABS: usize = 4096; + +/// Largest coverage rectangle, in pixels, a stroke may allocate. +pub const MAX_COVERAGE: u64 = 4096 * 4096; + +/// Why [`stamp`] refused to write. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum StampError { + /// A zero-sized buffer, no dabs, or nothing to cover. + Empty, + /// Source and destination disagree on channel count. + Mismatched, + /// The read/write window would exceed [`MAX_COVERAGE`]. + TooLarge, +} + +/// Named dab layout. Multipliers are documented in the command params; keep them stable. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Style { + TightShort, + TightMedium, + TightLong, + LooseMedium, + LooseLong, + Dab, + TightCurl, + LooseCurl, +} + +impl Style { + /// Parse a command-style identifier (`tightMedium`, …). + pub fn parse(name: &str) -> Option { + Some(match name { + "tightShort" => Self::TightShort, + "tightMedium" => Self::TightMedium, + "tightLong" => Self::TightLong, + "looseMedium" => Self::LooseMedium, + "looseLong" => Self::LooseLong, + "dab" => Self::Dab, + "tightCurl" => Self::TightCurl, + "looseCurl" => Self::LooseCurl, + _ => return None, + }) + } + + /// Stable id used in command params. + pub fn as_str(self) -> &'static str { + match self { + Self::TightShort => "tightShort", + Self::TightMedium => "tightMedium", + Self::TightLong => "tightLong", + Self::LooseMedium => "looseMedium", + Self::LooseLong => "looseLong", + Self::Dab => "dab", + Self::TightCurl => "tightCurl", + Self::LooseCurl => "looseCurl", + } + } + + fn spacing_mul(self) -> f32 { + match self { + Self::TightShort => 0.35, + Self::TightMedium => 0.55, + Self::TightLong => 0.85, + Self::LooseMedium => 0.70, + Self::LooseLong => 1.10, + Self::Dab => 1.60, + Self::TightCurl => 0.50, + Self::LooseCurl => 0.80, + } + } + + fn scatter_mul(self) -> f32 { + match self { + Self::TightShort => 0.00, + Self::TightMedium => 0.00, + Self::TightLong => 0.05, + Self::LooseMedium => 0.45, + Self::LooseLong => 0.70, + Self::Dab => 0.10, + Self::TightCurl => 0.05, + Self::LooseCurl => 0.40, + } + } + + fn curl_deg(self) -> f32 { + match self { + Self::TightCurl => 18.0, + Self::LooseCurl => 28.0, + _ => 0.0, + } + } + + fn size_mul(self) -> f32 { + match self { + Self::TightShort => 0.7, + Self::TightMedium => 0.9, + Self::TightLong => 1.1, + Self::LooseMedium => 1.0, + Self::LooseLong => 1.2, + Self::Dab => 1.0, + Self::TightCurl => 0.9, + Self::LooseCurl => 1.1, + } + } +} + +/// One posed dab in document pixels. +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct Dab { + pub x: f32, + pub y: f32, + pub theta: f32, + pub radius: f32, + pub pressure: f32, +} + +/// Spacing along the stroke, in pixels. +pub fn spacing_px(size: f32, area: f32, style: Style) -> Option { + if !(size.is_finite() && area.is_finite()) || size <= 0.0 { + return None; + } + let s = size * style.spacing_mul() * (0.25 + 0.02 * area); + if s.is_finite() && s > 0.0 { Some(s) } else { None } +} + +/// Extra pixels each destination tile must read from the source. +pub fn halo_radius(size: f32, style: Style) -> Option { + if !size.is_finite() || size <= 0.0 { + return None; + } + let v = (size * style.size_mul() / 2.0 + style.scatter_mul() * size + 2.0).ceil(); + if !v.is_finite() || v > 1_000_000.0 { + return None; + } + Some(v as i32) +} + +/// Side of the rotated source square (`ceil(size · size_mul) + 2`). +pub fn sample_side(size: f32, style: Style) -> Option { + if !size.is_finite() || size <= 0.0 { + return None; + } + let v = (size * style.size_mul()).ceil() + 2.0; + if !v.is_finite() || v > 1_000_000.0 { + return None; + } + Some(v as i32) +} + +fn mix32(seed: u32, dab: u32, lane: u32) -> u32 { + let mut x = seed ^ dab.wrapping_mul(0x9E37_79B9) ^ lane.wrapping_mul(0x85EB_CA6B); + x = x.wrapping_add(0x9E37_79B9); + x ^= x >> 16; + x = x.wrapping_mul(0x7FEB_352D); + x ^= x >> 15; + x = x.wrapping_mul(0x846C_A68B); + x ^= x >> 16; + x +} + +fn signed01(seed: u32, dab: u32, lane: u32) -> f32 { + let u = mix32(seed, dab, lane) >> 8; + (u as f32) * (2.0 / 16_777_215.0) - 1.0 +} + +fn dab_radius(size: f32, style: Style) -> Option { + let r = size * style.size_mul() * 0.5; + if r.is_finite() && r > 0.0 { Some(r) } else { None } +} + +/// Walk `points` and emit posed dabs. `seed` is typically [`RNG_SEED`] XOR the history index. +pub fn place_dabs(points: &[[f32; 2]], size: f32, area: f32, style: Style, seed: u32) -> Result, StampError> { + if points.is_empty() { + return Err(StampError::Empty); + } + let spacing = spacing_px(size, area, style).ok_or(StampError::Empty)?; + let radius = dab_radius(size, style).ok_or(StampError::TooLarge)?; + let curl = style.curl_deg().to_radians(); + let scatter = style.scatter_mul(); + let mut out = Vec::new(); + let mut emit = |i: u32, x: f32, y: f32, tx: f32, ty: f32, pressure: f32| -> Result<(), StampError> { + if !(x.is_finite() && y.is_finite() && tx.is_finite() && ty.is_finite()) { + return Err(StampError::Empty); + } + let u = signed01(seed, i, 1); + let v = signed01(seed, i, 2); + let w = signed01(seed, i, 3); + let dx = scatter * size * u; + let dy = scatter * size * v; + let (cx, cy) = (x + dx, y + dy); + if !(cx.is_finite() && cy.is_finite()) { + return Err(StampError::TooLarge); + } + let theta = ty.atan2(tx) + (i as f32) * curl + scatter * w; + if !theta.is_finite() { + return Err(StampError::Empty); + } + if out.len() >= MAX_DABS { + return Err(StampError::TooLarge); + } + out.push(Dab { x: cx, y: cy, theta, radius, pressure: pressure.clamp(0.0, 1.0) }); + Ok(()) + }; + + let Some(first) = points.first() else { + return Err(StampError::Empty); + }; + if !first[0].is_finite() || !first[1].is_finite() { + return Err(StampError::Empty); + } + let (mut px, mut py) = (first[0], first[1]); + let (mut tx, mut ty) = (1.0f32, 0.0f32); + if let Some(second) = points.get(1) { + tx = second[0] - px; + ty = second[1] - py; + if tx == 0.0 && ty == 0.0 { + tx = 1.0; + } + } + emit(0, px, py, tx, ty, 1.0)?; + + let mut carry = 0.0f32; + let mut i = 1u32; + for w in points.windows(2) { + let (Some(a), Some(b)) = (w.first(), w.get(1)) else { continue }; + if !(a[0].is_finite() && a[1].is_finite() && b[0].is_finite() && b[1].is_finite()) { + return Err(StampError::Empty); + } + let (dx, dy) = (b[0] - a[0], b[1] - a[1]); + let len = dx.hypot(dy); + if !len.is_finite() { + return Err(StampError::Empty); + } + if len < 1.0e-6 { + continue; + } + tx = dx; + ty = dy; + let mut consumed = 0.0f32; + while carry + (len - consumed) >= spacing { + let need = spacing - carry; + if !need.is_finite() || need < 0.0 { + return Err(StampError::Empty); + } + consumed += need; + if consumed > len { + break; + } + let t = consumed / len; + px = a[0] + dx * t; + py = a[1] + dy * t; + emit(i, px, py, tx, ty, 1.0)?; + i = i.saturating_add(1); + carry = 0.0; + } + carry += len - consumed; + if !carry.is_finite() { + return Err(StampError::Empty); + } + } + if out.is_empty() { Err(StampError::Empty) } else { Ok(out) } +} + +/// Bounding rectangle of a dab, in document pixels (1 px of anti-alias slack). +pub fn dab_bounds(dab: &Dab) -> Option<(i32, i32, i32, i32)> { + let r = dab.radius + 1.0; + if !r.is_finite() { + return None; + } + let x0 = (dab.x - r).floor(); + let y0 = (dab.y - r).floor(); + let x1 = (dab.x + r).ceil(); + let y1 = (dab.y + r).ceil(); + if !(x0.is_finite() && y0.is_finite() && x1.is_finite() && y1.is_finite()) { + return None; + } + let clamp = |v: f32| v.clamp(i32::MIN as f32, i32::MAX as f32) as i32; + Some((clamp(x0), clamp(y0), clamp(x1), clamp(y1))) +} + +fn coverage_at(dab: &Dab, x: i32, y: i32, hardness: f32) -> f32 { + let dx = x as f32 + 0.5 - dab.x; + let dy = y as f32 + 0.5 - dab.y; + let d = dx.hypot(dy); + if !d.is_finite() || d >= dab.radius + 0.5 { + return 0.0; + } + let edge = (dab.radius + 0.5 - d).clamp(0.0, 1.0); + let h = hardness.clamp(0.0, 1.0); + let inner = dab.radius * h; + let falloff = if d <= inner || dab.radius - inner < 1.0e-3 { + 1.0 + } else { + let t = ((d - inner) / (dab.radius - inner)).clamp(0.0, 1.0); + 1.0 - t * t * (3.0 - 2.0 * t) + }; + edge * falloff +} + +fn pixel_index(x: usize, y: usize, w: usize, h: usize, ch: usize) -> Option { + if x >= w || y >= h || ch == 0 { + return None; + } + y.checked_mul(w)?.checked_add(x)?.checked_mul(ch) +} + +fn origin_index(origin: (i32, i32), x: i32, y: i32, w: usize, h: usize, ch: usize) -> Option { + let dx = x.checked_sub(origin.0)?; + let dy = y.checked_sub(origin.1)?; + pixel_index(usize::try_from(dx).ok()?, usize::try_from(dy).ok()?, w, h, ch) +} + +fn floor_i32(v: f32) -> i32 { + v.clamp(-2_147_483_648.0, 2_147_483_647.0).floor() as i32 +} + +struct SrcView<'a> { + data: &'a [f32], + w: usize, + h: usize, + origin: (i32, i32), + ch: usize, +} + +fn sample_bilinear(src: SrcView<'_>, sx: f32, sy: f32, out: &mut [f32]) -> bool { + let ch = src.ch; + if ch == 0 || out.len() < ch { + return false; + } + let dst = &mut out[..ch]; + dst.fill(0.0); + if !(sx.is_finite() && sy.is_finite()) { + return false; + } + let lx = sx - src.origin.0 as f32; + let ly = sy - src.origin.1 as f32; + if !(lx.is_finite() && ly.is_finite()) { + return false; + } + let x0 = floor_i32(lx); + let y0 = floor_i32(ly); + let fx = (lx - x0 as f32).clamp(0.0, 1.0); + let fy = (ly - y0 as f32).clamp(0.0, 1.0); + let mut any = false; + for (iy, wy) in [(0i32, 1.0 - fy), (1i32, fy)] { + for (ix, wx) in [(0i32, 1.0 - fx), (1i32, fx)] { + let wt = wx * wy; + if wt <= 0.0 { + continue; + } + let px = x0.saturating_add(ix); + let py = y0.saturating_add(iy); + if px < 0 || py < 0 { + continue; + } + let (Ok(ux), Ok(uy)) = (usize::try_from(px), usize::try_from(py)) else { continue }; + let Some(base) = pixel_index(ux, uy, src.w, src.h, ch) else { continue }; + let Some(pxs) = src.data.get(base..base.saturating_add(ch)) else { continue }; + for (d, s) in dst.iter_mut().zip(pxs.iter()) { + *d += *s * wt; + } + any = true; + } + } + any +} + +fn rotated_source(dab: &Dab, x: i32, y: i32) -> (f32, f32) { + let dx = x as f32 + 0.5 - dab.x; + let dy = y as f32 + 0.5 - dab.y; + let (c, s) = (dab.theta.cos(), dab.theta.sin()); + (dab.x + c * dx + s * dy, dab.y - s * dx + c * dy) +} + +fn over_native(dst: &mut [f32], src: &[f32], k: f32, alpha: Option, lock: bool) { + if k <= 0.0 { + return; + } + match alpha { + Some(a) => { + let Some((&da, &sa0)) = dst.get(a).zip(src.get(a)) else { return }; + let sa = sa0 * k; + let oa = sa + da * (1.0 - sa); + if oa > 0.0 { + for c in 0..a { + let Some(d) = dst.get_mut(c) else { continue }; + let Some(&s) = src.get(c) else { continue }; + *d = (s * sa + *d * da * (1.0 - sa)) / oa; + } + } + if !lock && let Some(d) = dst.get_mut(a) { + *d = oa; + } + } + None => { + for (d, s) in dst.iter_mut().zip(src.iter()) { + *d += (*s - *d) * k; + } + } + } +} + +fn buf_len(w: usize, h: usize, ch: usize) -> Option { + w.checked_mul(h)?.checked_mul(ch) +} + +/// Parameters for [`stamp`]. +pub struct StampParams<'a> { + pub dest: &'a mut [f32], + pub dest_w: usize, + pub dest_h: usize, + pub dest_origin: (i32, i32), + pub src: &'a [f32], + pub src_w: usize, + pub src_h: usize, + pub src_origin: (i32, i32), + pub ch: usize, + pub dabs: &'a [Dab], + pub hardness: f32, + pub opacity: f32, + pub flow: f32, + pub tolerance: f32, + /// Destination tile edge; `0` processes the whole buffer as one tile. + pub tile: i32, + pub halo: i32, + pub selection: Option<&'a [f32]>, + pub lock_transparent: bool, + pub alpha: Option, +} + +fn dest_pixels(p: &StampParams<'_>) -> Result { + let n = buf_len(p.dest_w, p.dest_h, p.ch).ok_or(StampError::TooLarge)?; + if p.dest.len() < n { + return Err(StampError::Empty); + } + let sn = buf_len(p.src_w, p.src_h, p.ch).ok_or(StampError::TooLarge)?; + if p.src.len() < sn { + return Err(StampError::Empty); + } + if p.ch == 0 || p.dest_w == 0 || p.dest_h == 0 { + return Err(StampError::Empty); + } + Ok(n as u64) +} + +fn tile_grid(w: usize, h: usize, origin: (i32, i32), tile: i32) -> Vec<(i32, i32, i32, i32)> { + let (x0, y0) = origin; + let x1 = x0.saturating_add(w.min(i32::MAX as usize) as i32); + let y1 = y0.saturating_add(h.min(i32::MAX as usize) as i32); + if tile <= 0 { + return vec![(x0, y0, x1, y1)]; + } + let mut tiles = Vec::new(); + let mut y = y0; + while y < y1 { + let ny = y.saturating_add(tile).min(y1); + let mut x = x0; + while x < x1 { + let nx = x.saturating_add(tile).min(x1); + tiles.push((x, y, nx, ny)); + x = nx; + } + y = ny; + } + tiles +} + +fn stamp_dab_on_rect(p: &mut StampParams<'_>, dab: &Dab, rect: (i32, i32, i32, i32), src_rect: (i32, i32, i32, i32)) -> Result { + let (x0, y0, x1, y1) = rect; + if x1 <= x0 || y1 <= y0 { + return Ok(0); + } + let (sx0, sy0, sx1, sy1) = src_rect; + let Some(tw) = (x1 as i64 - x0 as i64).try_into().ok().filter(|w: &usize| *w > 0) else { + return Err(StampError::TooLarge); + }; + let Some(th) = (y1 as i64 - y0 as i64).try_into().ok().filter(|h: &usize| *h > 0) else { + return Err(StampError::TooLarge); + }; + let area = (tw as u64).saturating_mul(th as u64); + if area > MAX_COVERAGE { + return Err(StampError::TooLarge); + } + let n = tw.checked_mul(th).and_then(|m| m.checked_mul(p.ch)).ok_or(StampError::TooLarge)?; + let mut local = vec![0.0f32; n]; + let mut cov = vec![0.0f32; tw.checked_mul(th).ok_or(StampError::TooLarge)?]; + // Copy dest tile into local. + for y in y0..y1 { + for x in x0..x1 { + let lx = (x - x0) as usize; + let ly = (y - y0) as usize; + let Some(di) = origin_index(p.dest_origin, x, y, p.dest_w, p.dest_h, p.ch) else { continue }; + let Some(li) = pixel_index(lx, ly, tw, th, p.ch) else { continue }; + if let (Some(dst), Some(src)) = (local.get_mut(li..li + p.ch), p.dest.get(di..di + p.ch)) { + dst.copy_from_slice(src); + } + if let Some(c) = cov.get_mut(ly.saturating_mul(tw).saturating_add(lx)) { + *c = coverage_at(dab, x, y, p.hardness); + } + } + } + + // Cropped source window (halo). Samples outside it look empty — that is the seam if halo is short. + let sw = (sx1 - sx0).max(0) as usize; + let sh = (sy1 - sy0).max(0) as usize; + let sn = sw.checked_mul(sh).and_then(|m| m.checked_mul(p.ch)).ok_or(StampError::TooLarge)?; + let mut src_win = vec![0.0f32; sn]; + for y in sy0..sy1 { + for x in sx0..sx1 { + let Some(si) = origin_index(p.src_origin, x, y, p.src_w, p.src_h, p.ch) else { continue }; + let Some(wi) = origin_index((sx0, sy0), x, y, sw, sh, p.ch) else { continue }; + if let (Some(d), Some(s)) = (src_win.get_mut(wi..wi + p.ch), p.src.get(si..si + p.ch)) { + d.copy_from_slice(s); + } + } + } + + let mut sampled = vec![0.0f32; p.ch]; + let mut written = 0u32; + let k_stroke = (p.opacity * p.flow * dab.pressure).clamp(0.0, 1.0); + for y in y0..y1 { + for x in x0..x1 { + let lx = (x - x0) as usize; + let ly = (y - y0) as usize; + let Some(&c) = cov.get(ly.saturating_mul(tw).saturating_add(lx)) else { continue }; + if c <= 0.0 { + continue; + } + let mut k = c * k_stroke; + if let Some(sel) = p.selection { + let Some(si) = origin_index(p.dest_origin, x, y, p.dest_w, p.dest_h, 1) else { continue }; + let Some(&sv) = sel.get(si) else { continue }; + k *= sv.clamp(0.0, 1.0); + } + if k <= 0.0 { + continue; + } + let (sx, sy) = rotated_source(dab, x, y); + if !sample_bilinear(SrcView { data: &src_win, w: sw, h: sh, origin: (sx0, sy0), ch: p.ch }, sx, sy, &mut sampled) { + continue; + } + let Some(li) = pixel_index(lx, ly, tw, th, p.ch) else { continue }; + let Some(dst) = local.get_mut(li..li + p.ch) else { continue }; + if p.lock_transparent && p.alpha.is_some_and(|a| dst.get(a).is_some_and(|&v| v <= 0.0)) { + continue; + } + over_native(dst, &sampled, k, p.alpha, p.lock_transparent); + written = written.saturating_add(1); + } + } + + // Write the dest tile back (not the halo). + for y in y0..y1 { + for x in x0..x1 { + let lx = (x - x0) as usize; + let ly = (y - y0) as usize; + let Some(di) = origin_index(p.dest_origin, x, y, p.dest_w, p.dest_h, p.ch) else { continue }; + let Some(li) = pixel_index(lx, ly, tw, th, p.ch) else { continue }; + if let (Some(dst), Some(src)) = (p.dest.get_mut(di..di + p.ch), local.get(li..li + p.ch)) { + dst.copy_from_slice(src); + } + } + } + Ok(written) +} + +fn dab_intersects(dab: &Dab, tile: (i32, i32, i32, i32)) -> bool { + let Some((x0, y0, x1, y1)) = dab_bounds(dab) else { return false }; + x0 < tile.2 && x1 > tile.0 && y0 < tile.3 && y1 > tile.1 +} + +/// Mean `|src − dest|` over the dab's covered pixels (working-space peak is 1). `None` if nothing is covered. +fn dab_mean_diff(p: &StampParams<'_>, dab: &Dab) -> Option { + let (x0, y0, x1, y1) = dab_bounds(dab)?; + let mut sampled = vec![0.0f32; p.ch]; + let mut sum = 0.0f32; + let mut count = 0u32; + for y in y0..y1 { + for x in x0..x1 { + if coverage_at(dab, x, y, p.hardness) <= 0.0 { + continue; + } + let Some(di) = origin_index(p.dest_origin, x, y, p.dest_w, p.dest_h, p.ch) else { continue }; + let Some(dst) = p.dest.get(di..di.saturating_add(p.ch)) else { continue }; + let (sx, sy) = rotated_source(dab, x, y); + if !sample_bilinear(SrcView { data: p.src, w: p.src_w, h: p.src_h, origin: p.src_origin, ch: p.ch }, sx, sy, &mut sampled) { + continue; + } + let nch = p.ch.min(dst.len()).min(sampled.len()); + if nch == 0 { + continue; + } + let mut mad = 0.0f32; + for i in 0..nch { + let Some((&s, &d)) = sampled.get(i).zip(dst.get(i)) else { continue }; + mad += (s - d).abs(); + } + sum += mad / nch as f32; + count = count.saturating_add(1); + } + } + if count == 0 { + return None; + } + let mean = sum / count as f32; + mean.is_finite().then_some(mean) +} + +/// Stamp posed dabs into `dest`, reading `src` with a halo around each destination tile. +/// +/// Sequential dabs overlap: dab *n* sees dab *n − 1*. Returns how many destination pixels were +/// written (tolerance-skipped dabs count as zero). +pub fn stamp(p: &mut StampParams<'_>) -> Result { + dest_pixels(p)?; + if p.src_w == 0 || p.src_h == 0 { + return Err(StampError::Empty); + } + if p.dabs.is_empty() { + return Err(StampError::Empty); + } + let dest_area = (p.dest_w as u64).saturating_mul(p.dest_h as u64); + if dest_area > MAX_COVERAGE { + return Err(StampError::TooLarge); + } + let tiles = tile_grid(p.dest_w, p.dest_h, p.dest_origin, p.tile); + let halo = p.halo.max(0); + let mut written = 0u32; + let dabs: Vec = p.dabs.to_vec(); + for dab in &dabs { + let Some(bounds) = dab_bounds(dab) else { continue }; + if p.tolerance > 0.0 && dab_mean_diff(p, dab).is_some_and(|m| m < p.tolerance) { + continue; + } + let overlapping: Vec<(i32, i32, i32, i32)> = tiles.iter().copied().filter(|t| dab_intersects(dab, *t)).collect(); + if overlapping.is_empty() { + continue; + } + // Sequential tiles: each writes dest before the next dab. Parallel tiles of one dab do not + // share destination pixels, so they can run independently; we still apply them in order + // here so overlapping dabs stay deterministic. + for tile in overlapping { + let src_rect = (tile.0.saturating_sub(halo), tile.1.saturating_sub(halo), tile.2.saturating_add(halo), tile.3.saturating_add(halo)); + let (bx0, by0, bx1, by1) = bounds; + let dest_rect = (tile.0.max(bx0), tile.1.max(by0), tile.2.min(bx1), tile.3.min(by1)); + written = written.saturating_add(stamp_dab_on_rect(p, dab, dest_rect, src_rect)?); + } + } + Ok(written) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn fill(w: usize, h: usize, ch: usize, f: impl Fn(i32, i32, usize) -> f32) -> Vec { + let mut v = vec![0.0; w * h * ch]; + for y in 0..h { + for x in 0..w { + for c in 0..ch { + v[(y * w + x) * ch + c] = f(x as i32, y as i32, c); + } + } + } + v + } + + fn horizontal(len: f32) -> Vec<[f32; 2]> { + vec![[10.0, 32.0], [10.0 + len, 32.0]] + } + + #[test] + fn tight_short_emits_more_dabs_than_tight_long() { + let pts = horizontal(100.0); + let short = place_dabs(&pts, 10.0, 50.0, Style::TightShort, RNG_SEED).unwrap(); + let long = place_dabs(&pts, 10.0, 50.0, Style::TightLong, RNG_SEED).unwrap(); + assert!(short.len() > long.len(), "short {} long {}", short.len(), long.len()); + let s = spacing_px(10.0, 50.0, Style::TightShort).unwrap(); + let l = spacing_px(10.0, 50.0, Style::TightLong).unwrap(); + assert!(s < l, "{s} {l}"); + } + + #[test] + fn tight_curl_angles_increase_and_loose_curl_scatters() { + let pts = horizontal(80.0); + let tight = place_dabs(&pts, 12.0, 50.0, Style::TightCurl, RNG_SEED).unwrap(); + let loose = place_dabs(&pts, 12.0, 50.0, Style::LooseCurl, RNG_SEED).unwrap(); + assert!(tight.len() >= 3 && loose.len() >= 3); + let dt: Vec = tight.windows(2).map(|w| w[1].theta - w[0].theta).collect(); + assert!(dt.iter().all(|d| *d > 0.05), "tight curl steps {dt:?}"); + let dl: Vec = loose.windows(2).map(|w| w[1].theta - w[0].theta).collect(); + let mean = |v: &[f32]| v.iter().sum::() / v.len() as f32; + assert!(mean(&dl) > mean(&dt), "loose curl {dl:?} vs tight {dt:?}"); + let scatter_t: f32 = tight.iter().map(|d| (d.y - 32.0).abs()).sum(); + let scatter_l: f32 = loose.iter().map(|d| (d.y - 32.0).abs()).sum(); + assert!(scatter_l > scatter_t, "loose scatter {scatter_l} tight {scatter_t}"); + } + + #[test] + fn seeded_scatter_is_replayable() { + let pts = horizontal(60.0); + let a = place_dabs(&pts, 16.0, 40.0, Style::LooseMedium, RNG_SEED ^ 3).unwrap(); + let b = place_dabs(&pts, 16.0, 40.0, Style::LooseMedium, RNG_SEED ^ 3).unwrap(); + assert_eq!(a, b); + let c = place_dabs(&pts, 16.0, 40.0, Style::LooseMedium, RNG_SEED ^ 4).unwrap(); + assert_ne!(a, c); + } + + fn fixture(ch: usize) -> (usize, usize, Vec, Vec, Dab) { + let (w, h) = (128usize, 96usize); + let src = fill(w, h, ch, |x, y, c| if c + 1 == ch && ch > 1 { 1.0 } else { ((x * 13 + y * 7 + c as i32 * 3).rem_euclid(251) as f32) / 255.0 }); + let dest0 = fill(w, h, ch, |_, _, c| if c + 1 == ch && ch > 1 { 1.0 } else { 0.1 }); + // Centre 1 px inside a 64-tile so the rotated read crosses the seam. + let dab = Dab { x: 63.0, y: 40.0, theta: 0.4, radius: 18.0, pressure: 1.0 }; + (w, h, src, dest0, dab) + } + + #[allow(clippy::too_many_arguments)] + fn stamp_run(w: usize, h: usize, ch: usize, src: &[f32], dest: &mut [f32], dab: &Dab, tile: i32, halo: i32) -> u32 { + let mut p = StampParams { + dest, + dest_w: w, + dest_h: h, + dest_origin: (0, 0), + src, + src_w: w, + src_h: h, + src_origin: (0, 0), + ch, + dabs: std::slice::from_ref(dab), + hardness: 1.0, + opacity: 1.0, + flow: 1.0, + tolerance: 0.0, + tile, + halo, + selection: None, + lock_transparent: false, + alpha: (ch > 1).then_some(ch - 1), + }; + stamp(&mut p).unwrap() + } + + fn max_abs(a: &[f32], b: &[f32]) -> f32 { + a.iter().zip(b).fold(0.0f32, |m, (x, y)| m.max((x - y).abs())) + } + + fn max_u8(a: &[f32], b: &[f32]) -> i32 { + a.iter() + .zip(b) + .map(|(x, y)| { + let q = |v: f32| (v.clamp(0.0, 1.0) * 255.0).round() as i32; + (q(*x) - q(*y)).abs() + }) + .max() + .unwrap_or(0) + } + + #[test] + fn tiled_stamp_matches_untiled_at_a_tile_seam() { + let halo = halo_radius(40.0, Style::LooseMedium).unwrap(); + let (w, h, src, dest0, dab) = fixture(4); + let mut tiled = dest0.clone(); + let mut flat = dest0.clone(); + let n_t = stamp_run(w, h, 4, &src, &mut tiled, &dab, 64, halo); + let n_f = stamp_run(w, h, 4, &src, &mut flat, &dab, 0, halo); + assert!(n_t > 0 && n_f > 0, "wrote {n_t} tiled / {n_f} flat"); + assert_eq!(max_u8(&tiled, &flat), 0, "8-bit seam"); + assert!(max_abs(&tiled, &flat) <= 1.0 / 32_767.0, "16-bit seam {}", max_abs(&tiled, &flat)); + assert!(max_abs(&tiled, &flat) <= 1.0e-5, "32f seam {}", max_abs(&tiled, &flat)); + + let (w, h, src, dest0, dab) = fixture(1); + let mut tiled = dest0.clone(); + let mut flat = dest0; + stamp_run(w, h, 1, &src, &mut tiled, &dab, 64, halo); + stamp_run(w, h, 1, &src, &mut flat, &dab, 0, halo); + assert_eq!(max_u8(&tiled, &flat), 0, "gray 8-bit seam"); + } + + #[test] + fn short_halo_disagrees_with_untiled_reference() { + let (w, h, src, dest0, dab) = fixture(4); + let halo = halo_radius(40.0, Style::LooseMedium).unwrap(); + let mut short = dest0.clone(); + let mut full = dest0; + stamp_run(w, h, 4, &src, &mut short, &dab, 64, 1); + stamp_run(w, h, 4, &src, &mut full, &dab, 0, halo); + assert!(max_abs(&short, &full) > 1.0e-3, "a 1 px halo must miss the rotated read"); + } + + #[test] + fn halo_covers_rotated_read_reach() { + let size = 40.0; + for style in + [Style::TightShort, Style::TightMedium, Style::TightLong, Style::LooseMedium, Style::LooseLong, Style::Dab, Style::TightCurl, Style::LooseCurl] + { + let halo = halo_radius(size, style).unwrap(); + let side = sample_side(size, style).unwrap(); + let reach = (side + 1) / 2; + assert!(halo >= reach, "{:?}: halo {halo} < reach {reach} (side {side})", style.as_str()); + } + } + + #[test] + fn tolerance_skips_an_unchanged_layer() { + let (w, h, ch) = (48usize, 48usize, 4); + let src = fill(w, h, ch, |x, y, c| if c == 3 { 1.0 } else { (x + y) as f32 / 100.0 }); + let mut dest = src.clone(); + let dab = Dab { x: 24.0, y: 24.0, theta: 0.0, radius: 8.0, pressure: 1.0 }; + let mut p = StampParams { + dest: &mut dest, + dest_w: w, + dest_h: h, + dest_origin: (0, 0), + src: &src, + src_w: w, + src_h: h, + src_origin: (0, 0), + ch, + dabs: std::slice::from_ref(&dab), + hardness: 1.0, + opacity: 1.0, + flow: 1.0, + tolerance: 1.0, + tile: 0, + halo: 4, + selection: None, + lock_transparent: false, + alpha: Some(3), + }; + let n = stamp(&mut p).unwrap(); + assert_eq!(n, 0); + assert_eq!(dest, src); + } + + #[test] + fn tolerance_zero_writes_where_history_differs() { + let (w, h, ch) = (48usize, 48usize, 4); + let src = fill(w, h, ch, |_, _, c| if c == 3 { 1.0 } else { 0.9 }); + let mut dest = fill(w, h, ch, |_, _, c| if c == 3 { 1.0 } else { 0.1 }); + let dab = Dab { x: 24.0, y: 24.0, theta: 0.0, radius: 8.0, pressure: 1.0 }; + let mut p = StampParams { + dest: &mut dest, + dest_w: w, + dest_h: h, + dest_origin: (0, 0), + src: &src, + src_w: w, + src_h: h, + src_origin: (0, 0), + ch, + dabs: std::slice::from_ref(&dab), + hardness: 1.0, + opacity: 1.0, + flow: 1.0, + tolerance: 0.0, + tile: 0, + halo: 4, + selection: None, + lock_transparent: false, + alpha: Some(3), + }; + let n = stamp(&mut p).unwrap(); + assert!(n > 0); + let i = (24 * w + 24) * ch; + assert!((dest[i] - 0.9).abs() < 1.0e-5, "{}", dest[i]); + } + + #[test] + fn empty_or_mismatched_buffers_error() { + let mut dest = vec![0.0f32; 16]; + let src = vec![0.0f32; 16]; + let dab = Dab { x: 1.0, y: 1.0, theta: 0.0, radius: 1.0, pressure: 1.0 }; + let mut p = StampParams { + dest: &mut dest, + dest_w: 0, + dest_h: 4, + dest_origin: (0, 0), + src: &src, + src_w: 4, + src_h: 4, + src_origin: (0, 0), + ch: 1, + dabs: std::slice::from_ref(&dab), + hardness: 1.0, + opacity: 1.0, + flow: 1.0, + tolerance: 0.0, + tile: 0, + halo: 1, + selection: None, + lock_transparent: false, + alpha: None, + }; + assert_eq!(stamp(&mut p), Err(StampError::Empty)); + let mut dest = vec![0.0f32; 16]; + let src = vec![0.0f32; 8]; + let mut p = StampParams { + dest: &mut dest, + dest_w: 4, + dest_h: 4, + dest_origin: (0, 0), + src: &src, + src_w: 2, + src_h: 2, + src_origin: (0, 0), + ch: 4, + dabs: std::slice::from_ref(&dab), + hardness: 1.0, + opacity: 1.0, + flow: 1.0, + tolerance: 0.0, + tile: 0, + halo: 1, + selection: None, + lock_transparent: false, + alpha: None, + }; + assert!(stamp(&mut p).is_err()); + assert!(place_dabs(&[], 10.0, 50.0, Style::TightMedium, 0).is_err()); + assert!(Style::parse("nope").is_none()); + assert_eq!(Style::parse("tightMedium"), Some(Style::TightMedium)); + } + + #[test] + fn two_stamps_with_the_same_seed_match() { + let pts = horizontal(50.0); + let dabs = place_dabs(&pts, 12.0, 50.0, Style::LooseCurl, RNG_SEED).unwrap(); + let (w, h, ch) = (80usize, 64usize, 4); + let src = fill(w, h, ch, |x, y, c| if c == 3 { 1.0 } else { (x + 3 * y) as f32 / 200.0 }); + let dest0 = fill(w, h, ch, |_, _, c| if c == 3 { 1.0 } else { 0.2 }); + let run = |dest: &mut [f32]| { + let mut p = StampParams { + dest, + dest_w: w, + dest_h: h, + dest_origin: (0, 0), + src: &src, + src_w: w, + src_h: h, + src_origin: (0, 0), + ch, + dabs: &dabs, + hardness: 0.8, + opacity: 1.0, + flow: 1.0, + tolerance: 0.0, + tile: 64, + halo: halo_radius(12.0, Style::LooseCurl).unwrap(), + selection: None, + lock_transparent: false, + alpha: Some(3), + }; + stamp(&mut p).unwrap() + }; + let mut a = dest0.clone(); + let mut b = dest0; + assert_eq!(run(&mut a), run(&mut b)); + assert_eq!(a, b); + } +} diff --git a/crates/algo/src/lib.rs b/crates/algo/src/lib.rs index 35c195f399..41a453b6b3 100644 --- a/crates/algo/src/lib.rs +++ b/crates/algo/src/lib.rs @@ -18,6 +18,7 @@ #![forbid(unsafe_code)] #![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] +pub mod art_history; mod artistic; mod artistic_fx; mod blur; diff --git a/crates/engine/examples/bench_art_history.rs b/crates/engine/examples/bench_art_history.rs new file mode 100644 index 0000000000..e66949eb96 --- /dev/null +++ b/crates/engine/examples/bench_art_history.rs @@ -0,0 +1,60 @@ +//! 24 MP timing of Art History Brush on a representative stroke. +//! `cargo run --release -p photocraft-engine --example bench_art_history` +use std::time::Instant; + +use photocraft_engine::Session; +use photocraft_geom::Rect; +use serde_json::json; + +fn main() { + let (w, h) = (6016u32, 4000u32); + let mut s = Session::new(); + s.execute("file.new", json!({"width": w, "height": h, "depth": 8, "mode": "rgb"})).unwrap(); + s.edit("texture", |doc, active| { + let surf = doc.layer_mut(active.unwrap()).unwrap().surface_mut().unwrap(); + let fmt = surf.format(); + let row: Vec = (0..w) + .flat_map(|x| { + let t = (x % 256) as f32 / 255.0; + photocraft_raster::from_rgba(&fmt, [t, 0.35, 1.0 - t, 1.0]) + }) + .collect(); + for y in 0..h as i32 { + surf.write_region(Rect::new(0, y, w as i32, y + 1), &row); + } + Ok(()) + }) + .unwrap(); + s.execute("edit.fill", json!({"color": "#606060"})).unwrap(); + + let points: Vec<[i32; 2]> = (0..200).map(|i| [2800 + i, 2000]).collect(); + let run = |s: &mut Session, style: &str| { + s.execute( + "paint.artHistoryBrush", + json!({ + "points": points, + "size": 40, + "hardness": 100, + "area": 50, + "tolerance": 0, + "style": style, + "state": 0 + }), + ) + .unwrap(); + }; + // Warm the allocator / tile cache. + run(&mut s, "tightMedium"); + s.undo(); + + for style in ["tightMedium", "looseCurl"] { + let t = Instant::now(); + run(&mut s, style); + let ms = t.elapsed().as_secs_f64() * 1000.0; + println!( + "artHistoryBrush document {w}×{h} ({:.1} MP) stroke 200 px size 40 area 50 style {style} {ms:.3} ms", + (w as u64 * h as u64) as f64 / 1e6 + ); + s.undo(); + } +} diff --git a/crates/engine/src/channel_cmds.rs b/crates/engine/src/channel_cmds.rs index 345abc377f..b9f1512a48 100644 --- a/crates/engine/src/channel_cmds.rs +++ b/crates/engine/src/channel_cmds.rs @@ -731,6 +731,7 @@ fn routed(id: &str) -> bool { | "paint.sharpen" | "paint.smudge" | "paint.historyBrush" + | "paint.artHistoryBrush" | "paint.redEye" | "paint.remove" ) diff --git a/crates/engine/src/hidden_target.rs b/crates/engine/src/hidden_target.rs index 249317354a..977d642f21 100644 --- a/crates/engine/src/hidden_target.rs +++ b/crates/engine/src/hidden_target.rs @@ -32,6 +32,7 @@ const GATED: &[&str] = &[ "paint.sharpen", "paint.smudge", "paint.historyBrush", + "paint.artHistoryBrush", "layer.translate", ]; diff --git a/crates/engine/src/retouch_cmds.rs b/crates/engine/src/retouch_cmds.rs index 005377328f..ead6665946 100644 --- a/crates/engine/src/retouch_cmds.rs +++ b/crates/engine/src/retouch_cmds.rs @@ -1,5 +1,6 @@ //! Retouching tools as commands: Clone Stamp, Pattern Stamp, Healing Brush, Spot Healing Brush, -//! Patch, Content-Aware Move, Remove, Dodge, Burn, Sponge, Blur, Sharpen, Smudge and History Brush. +//! Patch, Content-Aware Move, Remove, Dodge, Burn, Sponge, Blur, Sharpen, Smudge, History Brush and +//! Art History Brush. //! //! Every command takes a Photoshop-style brush (`points`, `size`, `hardness`, `opacity`, `flow`, //! `spacing`, `layer`), respects the active selection as a mask and the layer's transparency lock, and @@ -24,6 +25,7 @@ use serde_json::{Value, json}; use crate::commands::{CommandSpec, blend_from_str}; use crate::{EngineError, Result, Session}; +mod art_history; mod content_aware_move; mod patch; mod pattern_stamp; @@ -1522,6 +1524,18 @@ pub fn specs() -> Vec { run: history_brush, journal: true, }, + CommandSpec { + id: "paint.artHistoryBrush", + label: "Art History Brush", + menu: &[], + shortcut: None, + params: brush_params!( + r#","state":index=0 (oldest held snapshot),"style":"tightShort|tightMedium|tightLong|looseMedium|looseLong|dab|tightCurl|looseCurl"="tightMedium","area":0..100=50,"tolerance":0..100=50"# + ), + enabled: has_pixel_layer, + run: art_history::run, + journal: true, + }, ] } diff --git a/crates/engine/src/retouch_cmds/art_history.rs b/crates/engine/src/retouch_cmds/art_history.rs new file mode 100644 index 0000000000..32d6962f9d --- /dev/null +++ b/crates/engine/src/retouch_cmds/art_history.rs @@ -0,0 +1,478 @@ +//! Art History Brush: stylized, oriented dabs sampled from a history state. + +use photocraft_algo::art_history::{self, Dab, MAX_COVERAGE, MAX_DABS, RNG_SEED, StampError, StampParams, Style}; +use photocraft_color::BlendMode; +use photocraft_geom::Rect; +use photocraft_paint::MAX_BRUSH_SIZE; +use photocraft_paint::retouch::{Region, alpha_index}; +use photocraft_raster::{from_rgba_into, to_rgba}; +use serde_json::{Value, json}; + +use super::*; + +const CMD: &str = "paint.artHistoryBrush"; +const MAX_POINTS: usize = 4096; + +fn err(msg: impl Into) -> EngineError { + bad(CMD, msg) +} + +fn object(p: &Value) -> Result<&serde_json::Map> { + p.as_object().ok_or_else(|| err("expected an object")) +} + +fn finite(v: Option<&Value>, _key: &str) -> Result> { + match v { + None | Some(Value::Null) => Ok(None), + Some(v) => v.as_f64().filter(|x| x.is_finite()).map(|x| x as f32).ok_or_else(|| err("invalid number")).map(Some), + } +} + +fn finite_key(p: &Value, key: &str, default: f32) -> Result { + match finite(p.get(key), key)? { + None => Ok(default), + Some(v) => Ok(v), + } +} + +fn ranged(p: &Value, key: &str, default: f32, lo: f32, hi: f32) -> Result { + let v = finite_key(p, key, default)?; + if (lo..=hi).contains(&v) { Ok(v) } else { Err(err(format!("`{key}` must be a number {lo}..{hi}"))) } +} + +fn points(p: &Value) -> Result> { + let Some(arr) = p.get("points").and_then(Value::as_array) else { + return Err(err("no stroke points")); + }; + if arr.is_empty() { + return Err(err("no stroke points")); + } + if arr.len() > MAX_POINTS { + return Err(err("too many points")); + } + let mut out = Vec::with_capacity(arr.len()); + for q in arr { + let Some(a) = q.as_array() else { + return Err(err("invalid number")); + }; + let (Some(x), Some(y)) = (a.first(), a.get(1)) else { + return Err(err("invalid number")); + }; + let x = x.as_f64().filter(|v| v.is_finite()).ok_or_else(|| err("invalid number"))?; + let y = y.as_f64().filter(|v| v.is_finite()).ok_or_else(|| err("invalid number"))?; + if let Some(pr) = a.get(2) + && pr.as_f64().filter(|v| v.is_finite()).is_none() + { + return Err(err("invalid number")); + } + out.push([x as f32, y as f32]); + } + if out.is_empty() { + return Err(err("no stroke points")); + } + Ok(out) +} + +fn style_of(p: &Value) -> Result

PuYCoMAY;v8s7!u(qWB77!+}SLgk%*I!MKbTIOWs94Ze@mvA?5 z*+D--A4eYO>ax``xibRi7H3C1R~9f+H6tltxP<26;T~Ygb48*ObI&w^8jo~oJ$(5P zq6($T-MFlcr~8?Tc$UdVTkRiv6l^4qqa7FEvXj-tLmQ~6P37Th6w2J@%Gc+p1~h?- z+NAGRC=>gbTyjw|BM*jBTi{B3a}dyVGi`G|_VEEwX!+1e6*<|au%xDuj`HfOuM*P^ zq$(Ky_*s)yl>n)U)lP=1(YdS_7kEZ$HDR}>qGe`f)dtxt6t5&X7h1{r@KuGtHp60u zqf5rkbR7}$JaGi`)@$ZG@-dju46vH$K@51Ja=_oEPMqGy@k0kt6G!miDUMncMlH>P zc3IjQJTPb)ySoZ62BR8UL4+U-w?a+++X5}e47UILF}CYG=$n~}uDPp>(_yJpB0E&; z#4&7^inPjW-*xMtruChtuk0?`wV@6cA3u4k&L% z+x1ZzOE8*8*N*XrM(jfWhc)9Zntv~X-g*-Q-H;mWe=aRK=ang1bYnFYWK+TGYzg{!YxBU_)Kc|rS*lISAJ{Lh_^60q z$Q`Xbu2>a+Ci zfE9Zy5l}wTz(3s?C@)g6QPxJbWFOG|g>*cr_mYpOL^*@FmfZL(FsagUbajAVYCRVC zGjc}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