mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Merge upstream/main into fix/atn-panel-menu-10706
This commit is contained in:
commit
4ff984e166
276 files changed
+9068
-2202
No files matched your search
@@ -33,6 +33,12 @@ test-group = 'gpu'
|
||||
fail-fast = false
|
||||
slow-timeout = { period = "60s", terminate-after = 10 }
|
||||
failure-output = "immediate-final"
|
||||
# The gate's shards run the tests from a nextest archive (`cargo xtask ci archive`) and start them
|
||||
# with the xtask binary the archive carries, so a shard builds nothing. Only one of the two exists.
|
||||
archive.include = [
|
||||
{ path = "debug/xtask", relative-to = "target", depth = 0, on-missing = "ignore" },
|
||||
{ path = "debug/xtask.exe", relative-to = "target", depth = 0, on-missing = "ignore" },
|
||||
]
|
||||
|
||||
# Keep phase timings for the remaining expensive Windows GPU regressions visible. This does
|
||||
# not relax their timeout, isolate failures differently or remove any test cases.
|
||||
|
||||
+80
-30
@@ -2,10 +2,14 @@ name: CI
|
||||
|
||||
# Quality gates for every push to main and every pull request. The Linux and Windows tests run
|
||||
# through the suite's shared gate workflow in craft-common-actions (`cargo xtask ci`, split over the
|
||||
# gate's jobs); the test variant and the corpus, web and fuzz jobs are PhotoCraft's own.
|
||||
# gate's jobs); the test variant and the corpus, web and fuzz jobs are PhotoCraft's own. Every night
|
||||
# the Linux gate alone runs a cold build: the safety net for the workspace crates it keeps between
|
||||
# runs (`cache-workspace-crates`), and a fresh start for that cache entry.
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: "11 3 * * *"
|
||||
pull_request:
|
||||
# `labeled` so that adding `full-ci` to an open PR starts a run with Windows in it.
|
||||
types: [opened, synchronize, reopened, labeled]
|
||||
@@ -70,7 +74,7 @@ concurrency:
|
||||
jobs:
|
||||
# Git dependencies come from github.com/storytold, and Cargo.lock is complete and up to date.
|
||||
git-sources:
|
||||
if: github.event.action != 'labeled' || github.event.label.name == 'full-ci'
|
||||
if: github.event_name != 'schedule' && (github.event.action != 'labeled' || github.event.label.name == 'full-ci')
|
||||
# Tracks @main so suite-wide CI fixes reach every app without a PR in each repository.
|
||||
uses: storytold/craft-common-actions/.github/workflows/git-sources.yml@main
|
||||
|
||||
@@ -86,7 +90,7 @@ jobs:
|
||||
# `windows_skip`: the platform-neutral packages whose Windows tests a pull request skips because nothing it
|
||||
# changes reaches them (same script); empty on main and `full-ci`.
|
||||
platforms:
|
||||
if: github.event.action != 'labeled' || github.event.label.name == 'full-ci'
|
||||
if: github.event_name != 'schedule' && (github.event.action != 'labeled' || github.event.label.name == 'full-ci')
|
||||
timeout-minutes: 10
|
||||
name: select platforms
|
||||
runs-on: ubuntu-latest
|
||||
@@ -145,13 +149,17 @@ jobs:
|
||||
fi
|
||||
|
||||
# The Linux gate (craft-common-actions gate.yml). Its `lint` leg runs the checks that need no test
|
||||
# build; four test shards each build the tests from the restored cache and run their share
|
||||
# (scripts/ci-test-shard.sh). Shard 1 runs nextest's `gpu` group alone, on lavapipe, and fails on
|
||||
# a skipped GPU comparison (scripts/ci-gpu-lavapipe.py); shards 2-4 split the other tests, and
|
||||
# shard 2 runs the doctests. The `gpu` group is ~2400 test-seconds on 4 slots (~12 min with its
|
||||
# slowest test, ~8 once the five slow UI tests are fixed); the other ~5900 test-seconds over 3
|
||||
# shards are ~8 min each, so a fifth shard would not shorten the gate. Its rust-cache entry is
|
||||
# the one `test (without heif)` restores.
|
||||
# build. The `build` job builds the tests once into a nextest archive (`cargo xtask ci archive`),
|
||||
# uploads it and then runs the doctests; four test shards download the archive and run their
|
||||
# share (scripts/ci-test-shard.sh). Shard 1 runs nextest's `gpu` group alone, on lavapipe, and
|
||||
# fails on a skipped GPU comparison (scripts/ci-gpu-lavapipe.py); shards 2-4 split the other
|
||||
# tests. The `gpu` group is ~840 test-seconds on 4 slots (~3.5 min); the other ~6900
|
||||
# test-seconds over 3 shards are ~8.5-10.5 min each.
|
||||
# The build keeps the compiled workspace crates between runs (`cache-workspace-crates`), so a
|
||||
# pull request rebuilds only the crates its changes reach. Each main run's build job saves a
|
||||
# rolling entry of its own, which `test (without heif)` restores too; `gate-cache-prune` keeps
|
||||
# the newest one. The lint legs keep no cache (`lint-cache: false`): a cold lint leg costs
|
||||
# minutes, and their entries (~1 GB per OS) would not fit the 10 GB cache budget.
|
||||
gate:
|
||||
if: github.event.action != 'labeled' || github.event.label.name == 'full-ci'
|
||||
# Tracks @main so suite-wide CI fixes reach every app without a PR in each repository.
|
||||
@@ -175,28 +183,28 @@ jobs:
|
||||
LPDEST=photocraft-no-such-printer
|
||||
CARGO_PROFILE_TEST_STRIP=symbols
|
||||
timeout-minutes: 100
|
||||
# On main, a `cache warm` leg builds xtask and the tests, as each shard does, and saves the
|
||||
# dependency cache as soon as the build succeeds; the shards then only restore, so a failing
|
||||
# test cannot keep the entry from being saved (craft-common-actions#270). The lint leg keeps
|
||||
# its own entry.
|
||||
warm-command: cargo xtask ci build
|
||||
cache-workspace-crates: true
|
||||
lint-cache: false
|
||||
cold-build: ${{ github.event_name == 'schedule' }}
|
||||
# fmt, egui-fork, clippy, layers, panel-commands, scorecard, the wasm32 check and the
|
||||
# missing-translations report (`cargo xtask ci lint`, xtask/src/main.rs), and the CI scripts'
|
||||
# own tests.
|
||||
lint-command: python3 scripts/test-ci-gpu-lavapipe.py && python3 scripts/test-ci-windows-gpu-tests.py && cargo xtask ci lint
|
||||
archive-command: cargo xtask ci archive
|
||||
after-archive-command: cargo xtask ci doctest
|
||||
test-shards: 4
|
||||
# The tests and panic_hunt with `--locked --features heif` (TEST_TARGETS in xtask/src/main.rs).
|
||||
shard-command: bash scripts/ci-test-shard.sh --gpu-shard
|
||||
|
||||
# The Windows tests and Clippy on the same gate, when `platforms` says the run needs them: a
|
||||
# `lint` leg runs Clippy, and six shards each build the tests and run their hash partition;
|
||||
# shard 1 also runs the doctests. Windows runs the tests ~1.75x slower than Linux: ~55 min on
|
||||
# one runner, ~9 min per shard. A seventh shard would not shorten the slowest one while its
|
||||
# slowest test alone takes ~9.6 min (the shortcut-dispatch UI test). The browser apps are wasm
|
||||
# targets, so their native tests are left out;
|
||||
# pull requests also leave out photocraft-gpu and the platform-neutral packages nothing they change
|
||||
# reaches (`windows_gpu`, `windows_skip`). The `cache warm` leg (main only) builds what main's
|
||||
# build job builds.
|
||||
# `lint` leg runs Clippy, the `build` job builds the tests once into a nextest archive and then
|
||||
# runs the doctests, and six shards run their slice of the tests from the archive. Windows runs
|
||||
# the tests ~1.75x slower than Linux: ~55 min on one runner, ~9 min per shard. A seventh shard
|
||||
# would not shorten the slowest one while its slowest test alone takes ~9.6 min (the
|
||||
# shortcut-dispatch UI test). The browser apps are wasm targets, so their native tests are left
|
||||
# out; pull requests also leave out photocraft-gpu and the platform-neutral packages nothing they
|
||||
# change reaches (`windows_gpu`, `windows_skip`). Windows keeps a dependency-only cache entry:
|
||||
# its workspace crates would not fit the repository's cache budget beside Linux's.
|
||||
windows:
|
||||
needs: platforms
|
||||
if: needs.platforms.outputs.windows == 'true'
|
||||
@@ -204,6 +212,7 @@ jobs:
|
||||
uses: storytold/craft-common-actions/.github/workflows/gate.yml@main
|
||||
with:
|
||||
os: '["windows-latest"]'
|
||||
lint-cache: false
|
||||
# The all-language UI tests shape real Japanese, Chinese, Korean and Devanagari labels with
|
||||
# kittest's strict `MissingGlyphPolicy::Panic`, and a hosted Windows image has no guaranteed
|
||||
# Japanese or Simplified Chinese system font. Same pinned central fonts as Linux and release.
|
||||
@@ -229,17 +238,57 @@ jobs:
|
||||
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS=-Clink-arg=/OPT:NOICF -Clink-arg=/DEBUG:NONE
|
||||
PHOTOCRAFT_CI_EXCLUDE=photocraft-web photocraft-web-boot ${{ needs.platforms.outputs.windows_gpu == 'false' && 'photocraft-gpu' || '' }} ${{ needs.platforms.outputs.windows_skip }}
|
||||
timeout-minutes: 100
|
||||
warm-command: cargo xtask ci build
|
||||
lint-command: cargo xtask ci clippy
|
||||
archive-command: cargo xtask ci archive
|
||||
after-archive-command: cargo xtask ci doctest
|
||||
test-shards: 6
|
||||
shard-command: bash scripts/ci-test-shard.sh
|
||||
|
||||
# The Linux gate's build job saves a rolling cache entry of its own on every main and nightly run
|
||||
# (`cache-workspace-crates`), about 3.8 GB, and every run restores only the newest. This deletes
|
||||
# the older ones at once instead of leaving them to the 10 GB budget's eviction, which would
|
||||
# evict other entries too.
|
||||
gate-cache-prune:
|
||||
needs: gate
|
||||
if: ${{ !cancelled() && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
|
||||
timeout-minutes: 5
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
actions: write
|
||||
steps:
|
||||
- name: Harden runner
|
||||
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
|
||||
with:
|
||||
egress-policy: audit
|
||||
- name: Delete all but the newest rolling entry of each job and runner
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
REPO: ${{ github.repository }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# `<version>-rust-<profile>-<job>-crates-<os>-<arch>-<run>-<attempt>-...`, newest first.
|
||||
gh cache list --repo "$REPO" --ref refs/heads/main --limit 100 --sort created_at --order desc --json id,key \
|
||||
--jq '.[] | "\(.id) \(.key)"' > "$RUNNER_TEMP/caches"
|
||||
declare -A kept
|
||||
while read -r id key; do
|
||||
[[ "$key" =~ ^.+-rust-[0-9a-f]{64}-(.+-crates-[A-Za-z_]+-[a-z0-9]+)-[0-9]+-[0-9]+- ]] || continue
|
||||
entry=${BASH_REMATCH[1]}
|
||||
if [ -n "${kept[$entry]:-}" ]; then
|
||||
echo "delete $key"
|
||||
gh cache delete "$id" --repo "$REPO"
|
||||
else
|
||||
kept[$entry]=1
|
||||
echo "keep $key"
|
||||
fi
|
||||
done < "$RUNNER_TEMP/caches"
|
||||
|
||||
# The same codecs without the optional decoder: HEIC must stay a clear "not in this build" error
|
||||
# for distributors who leave it out. Runs beside the gate and restores the gate's dependency
|
||||
# cache without saving one: the dependencies are the same, and the 10 GB cache budget is tight
|
||||
# (#2688).
|
||||
# for distributors who leave it out. Runs beside the gate and restores the gate's newest rolling
|
||||
# cache entry without saving one: the dependencies are the same, and the 10 GB cache budget is
|
||||
# tight (#2688). Its sources keep their checkout mtimes, so the workspace crates it builds are
|
||||
# rebuilt.
|
||||
test-without-heif:
|
||||
if: github.event.action != 'labeled' || github.event.label.name == 'full-ci'
|
||||
if: github.event_name != 'schedule' && (github.event.action != 'labeled' || github.event.label.name == 'full-ci')
|
||||
timeout-minutes: 60
|
||||
name: test (without heif)
|
||||
# The gate's runner: its cache entry is keyed on the OS.
|
||||
@@ -277,11 +326,12 @@ jobs:
|
||||
|
||||
# The gate's own key (the shared action computes it), restore only. The toolchain action
|
||||
# exports CARGO_HOME, which the gate's legs do not have; align-environment leaves it out of
|
||||
# the key.
|
||||
# the cache paths.
|
||||
- uses: storytold/craft-common-actions/actions/rust-cache@main
|
||||
with:
|
||||
cache-version: v2
|
||||
job: gate
|
||||
cache-workspace-crates: "true"
|
||||
align-environment: "true"
|
||||
|
||||
- uses: step-security/taiki-e-install-action@76747d22a7567cc4438546a84f11bdf18e670ab8 # v2.87.32
|
||||
@@ -292,7 +342,7 @@ jobs:
|
||||
run: cargo nextest run -p photocraft-io --locked --profile ci
|
||||
|
||||
corpus:
|
||||
if: github.event.action != 'labeled' || github.event.label.name == 'full-ci'
|
||||
if: github.event_name != 'schedule' && (github.event.action != 'labeled' || github.event.label.name == 'full-ci')
|
||||
timeout-minutes: 30
|
||||
# Real-file corpus tests (cargo feature `corpus`), on every PR and on main. The corpora are
|
||||
# pinned in xtask/src/corpus_pins.rs and sha256-verified (xtask/*.sha256) after both a cache
|
||||
|
||||
@@ -21,4 +21,6 @@ jobs:
|
||||
with:
|
||||
timeout-minutes: 120
|
||||
fonts-ref: cc9269cd8d8258785dac603fba3122e5d2556795
|
||||
# The coverage build's ~1.3 GB cache would not fit the repository's 10 GB cache budget.
|
||||
build-cache: false
|
||||
secrets: inherit
|
||||
Generated
+119
-111
@@ -1365,7 +1365,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-automation",
|
||||
"craft-behavior",
|
||||
@@ -1404,7 +1404,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-affinity"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"flate2",
|
||||
@@ -1425,7 +1425,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-atomic"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"rustix 1.1.5",
|
||||
]
|
||||
@@ -1433,7 +1433,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-automation"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"craft-ai-agents",
|
||||
@@ -1459,7 +1459,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-behavior"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"bitflags 2.13.2",
|
||||
@@ -1475,7 +1475,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-browse"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-docpath",
|
||||
@@ -1493,7 +1493,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cloud-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"egui",
|
||||
]
|
||||
@@ -1501,7 +1501,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cms"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"md-5",
|
||||
"rayon",
|
||||
@@ -1510,7 +1510,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-color-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-cms",
|
||||
@@ -1530,17 +1530,17 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-crs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-metadata 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-metadata 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-crw"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -1548,7 +1548,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dds"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
@@ -1564,7 +1564,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dialogs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"block2 0.6.2",
|
||||
"craft-atomic",
|
||||
@@ -1587,7 +1587,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-docpath"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
@@ -1595,7 +1595,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-draw"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-color-ui",
|
||||
@@ -1614,21 +1614,21 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-eps"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
|
||||
[[package]]
|
||||
name = "craft-file-formats"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-eps",
|
||||
"craft-idml",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-kra",
|
||||
"craft-ora",
|
||||
"craft-pcraft-bundle",
|
||||
"craft-raw",
|
||||
"craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-zip",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -1637,7 +1637,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-flags"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"dirs",
|
||||
@@ -1647,7 +1647,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-catalog"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"fontique",
|
||||
"harfrust 0.13.3",
|
||||
@@ -1662,7 +1662,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-manager"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-font-catalog",
|
||||
@@ -1681,7 +1681,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-store"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"cap-primitives",
|
||||
"craft-atomic",
|
||||
@@ -1702,12 +1702,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-fonts-build"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
|
||||
[[package]]
|
||||
name = "craft-heif"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"heic-rs",
|
||||
"rayon",
|
||||
@@ -1716,7 +1716,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-host"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"craft-i18n",
|
||||
@@ -1729,7 +1729,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-i18n"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"fixed_decimal",
|
||||
@@ -1757,9 +1757,9 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-idml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-zip",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -1767,13 +1767,13 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-image-codecs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-dds 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-dds 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-heif",
|
||||
"craft-jpeg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-metadata 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-tiff 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-jpeg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-metadata 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-tiff 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"crc32fast",
|
||||
"exr",
|
||||
"flate2",
|
||||
@@ -1822,7 +1822,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-imaging"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-color-ui",
|
||||
@@ -1845,7 +1845,7 @@ source = "git+https://github.com/storytold/craft-libs?rev=e7873217287876f76a0455
|
||||
[[package]]
|
||||
name = "craft-jpeg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -1861,11 +1861,11 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-keymap"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-host",
|
||||
"craft-i18n",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"egui",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -1874,9 +1874,9 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-kra"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-zip",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -1884,7 +1884,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-layers"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-i18n",
|
||||
@@ -1898,7 +1898,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-menu"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -1916,11 +1916,11 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-metadata"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"brotli-decompressor 6.3.2",
|
||||
"chrono",
|
||||
"craft-tiff 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-tiff 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"quick-xml 0.41.0",
|
||||
"serde",
|
||||
]
|
||||
@@ -1940,9 +1940,9 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ora"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-zip",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -1950,7 +1950,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pages"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-text",
|
||||
@@ -1964,7 +1964,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pcraft-bundle"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"craft-atomic",
|
||||
@@ -1977,7 +1977,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pcraft-format"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"serde",
|
||||
@@ -1988,7 +1988,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pdf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"flate2",
|
||||
@@ -2003,7 +2003,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pdn"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2012,7 +2012,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-platform"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-io",
|
||||
@@ -2038,7 +2038,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-plist"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -2046,7 +2046,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-print"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-ui",
|
||||
@@ -2064,7 +2064,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-psd"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"flate2",
|
||||
@@ -2075,7 +2075,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-quit"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"dispatch2",
|
||||
"egui",
|
||||
@@ -2086,12 +2086,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-raw"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"craft-crw",
|
||||
"craft-metadata 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-tiff 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-metadata 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-tiff 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"jxl-oxide",
|
||||
"miniz_oxide 0.9.1",
|
||||
"rayon",
|
||||
@@ -2104,7 +2104,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-review"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2121,7 +2121,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-settings"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"craft-host",
|
||||
@@ -2135,9 +2135,9 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-svg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"flate2",
|
||||
"kurbo 0.13.1",
|
||||
"quick-xml 0.41.0",
|
||||
@@ -2173,7 +2173,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-table"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -2185,7 +2185,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-text"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-font-manager",
|
||||
@@ -2208,7 +2208,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-theme"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"ecolor",
|
||||
@@ -2221,7 +2221,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-theme-editor"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-theme",
|
||||
@@ -2232,7 +2232,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-theme-store"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"craft-behavior",
|
||||
@@ -2247,7 +2247,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-tiff"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2265,7 +2265,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-time"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2274,7 +2274,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-timeline"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -2289,7 +2289,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-cloud-ui",
|
||||
"craft-ui-canvas",
|
||||
@@ -2303,7 +2303,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-canvas"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-i18n",
|
||||
@@ -2319,7 +2319,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-contract"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"craft-behavior",
|
||||
@@ -2331,7 +2331,7 @@ dependencies = [
|
||||
"craft-platform",
|
||||
"craft-quit",
|
||||
"craft-settings",
|
||||
"craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-theme",
|
||||
"craft-ui-macros",
|
||||
"craft-window",
|
||||
@@ -2353,7 +2353,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-macros"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
@@ -2364,7 +2364,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-panels"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2382,7 +2382,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-patterns"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2403,13 +2403,13 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-shell"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
"craft-i18n",
|
||||
"craft-platform",
|
||||
"craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-theme",
|
||||
"craft-ui-macros",
|
||||
"craft-ui-panels",
|
||||
@@ -2422,7 +2422,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-widgets"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2439,7 +2439,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-update"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"craft-host",
|
||||
@@ -2468,7 +2468,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-win32"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"winsafe",
|
||||
]
|
||||
@@ -2476,7 +2476,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-window"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"craft-behavior",
|
||||
@@ -2506,7 +2506,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xcf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2515,7 +2515,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"serde",
|
||||
@@ -2535,7 +2535,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-zip"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"thiserror 2.0.21",
|
||||
@@ -3998,7 +3998,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro"
|
||||
version = "0.7.1"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"hayro-interpret",
|
||||
@@ -4028,7 +4028,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-interpret"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"hayro-cmap",
|
||||
@@ -4046,7 +4046,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-jbig2"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"fearless_simd",
|
||||
"hayro-ccitt",
|
||||
@@ -4070,7 +4070,7 @@ checksum = "bc2d80da85f31c3fdc0366431f44cfd645a9da1e242ed1f4a61f213d9765660f"
|
||||
[[package]]
|
||||
name = "hayro-syntax"
|
||||
version = "0.7.2"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"hayro-ccitt",
|
||||
@@ -5154,7 +5154,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4"
|
||||
[[package]]
|
||||
name = "linesweeper"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"kurbo 0.13.1",
|
||||
@@ -6371,10 +6371,10 @@ dependencies = [
|
||||
"core-graphics2",
|
||||
"craft",
|
||||
"craft-cms",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=7b8c1eccea0c695a495ab279c9523e6efcc9b8be)",
|
||||
"craft-update",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"eframe",
|
||||
"egui",
|
||||
"egui_kittest",
|
||||
@@ -6418,7 +6418,7 @@ name = "photocraft-algo"
|
||||
version = "0.23.1"
|
||||
dependencies = [
|
||||
"craft",
|
||||
"craft-metadata 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-metadata 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"criterion",
|
||||
"photocraft-color",
|
||||
"photocraft-geom",
|
||||
@@ -6438,7 +6438,7 @@ dependencies = [
|
||||
"cap-std",
|
||||
"clap",
|
||||
"craft",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-psd",
|
||||
"getrandom 0.3.4",
|
||||
"photocraft-color",
|
||||
@@ -6471,7 +6471,7 @@ dependencies = [
|
||||
"clap_mangen",
|
||||
"craft",
|
||||
"craft-cms",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-psd",
|
||||
"photocraft-automation",
|
||||
"photocraft-doc",
|
||||
@@ -6535,11 +6535,11 @@ dependencies = [
|
||||
"craft-affinity",
|
||||
"craft-cms",
|
||||
"craft-file-formats",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-pcraft-format",
|
||||
"craft-print",
|
||||
"craft-psd",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"exr",
|
||||
"flate2",
|
||||
"photocraft-algo",
|
||||
@@ -6575,7 +6575,7 @@ name = "photocraft-format"
|
||||
version = "0.23.1"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-pcraft-bundle",
|
||||
"craft-pcraft-format",
|
||||
"craft-zip",
|
||||
@@ -6635,16 +6635,16 @@ dependencies = [
|
||||
"craft-crs",
|
||||
"craft-docpath",
|
||||
"craft-file-formats",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-kra",
|
||||
"craft-ora",
|
||||
"craft-pdf",
|
||||
"craft-pdn",
|
||||
"craft-psd",
|
||||
"craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=7b8c1eccea0c695a495ab279c9523e6efcc9b8be)",
|
||||
"craft-tiff 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-tiff 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-xcf",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"crc32fast",
|
||||
"flate2",
|
||||
"kurbo 0.13.1",
|
||||
@@ -6677,6 +6677,14 @@ dependencies = [
|
||||
"craft-ipp",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "photocraft-oil-round-proof"
|
||||
version = "0.23.1"
|
||||
dependencies = [
|
||||
"photocraft-algo",
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "photocraft-ops"
|
||||
version = "0.23.1"
|
||||
@@ -6735,7 +6743,7 @@ dependencies = [
|
||||
name = "photocraft-raw"
|
||||
version = "0.23.1"
|
||||
dependencies = [
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-raw",
|
||||
"flate2",
|
||||
"image",
|
||||
@@ -6797,7 +6805,7 @@ dependencies = [
|
||||
"craft",
|
||||
"craft-file-formats",
|
||||
"craft-i18n",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-print",
|
||||
"craft-psd",
|
||||
"eframe",
|
||||
@@ -6846,7 +6854,7 @@ dependencies = [
|
||||
name = "photocraft-web"
|
||||
version = "0.23.1"
|
||||
dependencies = [
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb)",
|
||||
"craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee)",
|
||||
"craft-psd",
|
||||
"eframe",
|
||||
"egui",
|
||||
@@ -11216,14 +11224,14 @@ source = "git+https://github.com/storytold/egui.git?rev=e9711ca9b69772f875ae0d1c
|
||||
[[patch.unused]]
|
||||
name = "hayro-cmap"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
|
||||
[[patch.unused]]
|
||||
name = "hayro-postscript"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
|
||||
[[patch.unused]]
|
||||
name = "krilla"
|
||||
version = "0.8.2"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=04ba41419b99967e4d2b990cdfe5d80184be64ee#04ba41419b99967e4d2b990cdfe5d80184be64ee"
|
||||
+38
-34
@@ -12,19 +12,19 @@ rust-version = "1.95"
|
||||
[workspace.dependencies]
|
||||
# The craft framework through its facade (`craft::ui::…`). The egui `[patch]` below must match
|
||||
# `craft::egui_fork::REV` (checked by `cargo xtask ci`).
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb", default-features = false }
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee", default-features = false }
|
||||
# internal
|
||||
photocraft-geom = { path = "crates/geom" }
|
||||
photocraft-color = { path = "crates/color" }
|
||||
photocraft-raster = { path = "crates/raster" }
|
||||
photocraft-doc = { path = "crates/doc" }
|
||||
photocraft-ops = { path = "crates/ops" }
|
||||
craft-plist = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
photocraft-codecs = { package = "craft-image-codecs", git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
photocraft-formats = { package = "craft-file-formats", git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb", features = ["raster-codecs", "pdf", "svg", "ora", "kra", "xcf", "pdn", "raw", "psd", "affinity", "pcraft"] }
|
||||
craft-plist = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
photocraft-codecs = { package = "craft-image-codecs", git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
photocraft-formats = { package = "craft-file-formats", git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee", features = ["raster-codecs", "pdf", "svg", "ora", "kra", "xcf", "pdn", "raw", "psd", "affinity", "pcraft"] }
|
||||
photocraft-raw = { path = "crates/raw" }
|
||||
craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
photocraft-compose = { path = "crates/compose" }
|
||||
photocraft-gpu = { path = "crates/gpu" }
|
||||
photocraft-paint = { path = "crates/paint" }
|
||||
@@ -43,34 +43,34 @@ photocraft-ipp = { path = "crates/ipp" }
|
||||
|
||||
# external
|
||||
# ICC colour management: the shared crate (replaces crates/cms; craft-libs#779).
|
||||
craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-print = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
craft-print = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
# HEIC/HEIF: the shared decoder (replaces crates/heif; craft-libs#784).
|
||||
craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb", features = ["raster", "write-raster"] }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-pcraft-bundle = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee", features = ["raster", "write-raster"] }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
craft-pcraft-bundle = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
# Keep the shared embedded-image validation API until the framework revision includes it.
|
||||
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "7b8c1eccea0c695a495ab279c9523e6efcc9b8be", features = ["tree-render", "tree-render-system-fonts"] }
|
||||
craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
# Camera-field EXIF reader/writer, shared prerequisite craft-libs#1563.
|
||||
craft-metadata = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-crs = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-metadata = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
craft-crs = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
# Interface translations: lookup, fallback, CLDR plurals and language names over the craft-i18n
|
||||
# catalogs that `crates/ui-egui/build.rs` embeds from `CRAFT_I18N_DIR` (storytold/craft-i18n, at
|
||||
# the commit in `craft-i18n.rev`). Already in the tree through craft.
|
||||
craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
# craft-update: app-specific pretend versions apply to startup and manual checks.
|
||||
craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb", features = ["ui"] }
|
||||
craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee", features = ["ui"] }
|
||||
thiserror = "2"
|
||||
serde = { version = "1", features = ["derive", "rc"] }
|
||||
serde_json = "1"
|
||||
@@ -176,6 +176,10 @@ opt-level = 0
|
||||
[profile.test.package.photocraft-engine]
|
||||
opt-level = 0
|
||||
|
||||
# Only the exhaustive rounding proof needs maximum optimization; algo stays at its usual level.
|
||||
[profile.test.package.photocraft-oil-round-proof]
|
||||
opt-level = 3
|
||||
|
||||
# Test builds compile the craft UI framework (the `craft` facade and the craft-libs crates behind
|
||||
# it) below the opt-level 2 of `package."*"` above. The workspace unifies the facade's features, so
|
||||
# every crate that uses `craft`, photocraft-text included, waits for the whole framework. At 2 the
|
||||
@@ -331,14 +335,14 @@ opt-level = 3
|
||||
# Keep the complete egui family and native event bridge on reviewed fork commits.
|
||||
|
||||
[patch.crates-io]
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
hayro = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
hayro = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "e9711ca9b69772f875ae0d1cef1977ff8c16234d" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "e9711ca9b69772f875ae0d1cef1977ff8c16234d" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "e9711ca9b69772f875ae0d1cef1977ff8c16234d" }
|
||||
|
||||
@@ -10,7 +10,10 @@ const PRINT_ONLY: [&str; 2] = ["windows.data.pdf.dll", "prntvpt.dll"];
|
||||
/// The built exe names each print-only DLL in its delay-load table, never its import table.
|
||||
#[test]
|
||||
fn print_only_system_dlls_are_delay_loaded() {
|
||||
let exe = std::fs::read(env!("CARGO_BIN_EXE_photocraft")).unwrap();
|
||||
// The run-time variable first: a run from a nextest archive points it at the extracted exe,
|
||||
// while the compile-time path names the directory the archive was built in.
|
||||
let path = std::env::var("CARGO_BIN_EXE_photocraft").unwrap_or_else(|_| env!("CARGO_BIN_EXE_photocraft").to_string());
|
||||
let exe = std::fs::read(path).unwrap();
|
||||
let pe = Pe::parse(&exe);
|
||||
let imports = pe.dll_names(1, 20, 12);
|
||||
let delayed = pe.dll_names(13, 32, 4);
|
||||
|
||||
@@ -442,6 +442,7 @@ pub struct StampParams<'a> {
|
||||
pub hardness: f32,
|
||||
pub opacity: f32,
|
||||
pub flow: f32,
|
||||
/// Tolerance as a fraction (Tolerance 50 % is `0.5`).
|
||||
pub tolerance: f32,
|
||||
/// Destination tile edge; `0` processes the whole buffer as one tile.
|
||||
pub tile: i32,
|
||||
@@ -581,26 +582,41 @@ fn dab_intersects(dab: &Dab, tile: (i32, i32, i32, i32)) -> bool {
|
||||
x0 < tile.2 && x1 > tile.0 && y0 < tile.3 && y1 > tile.1
|
||||
}
|
||||
|
||||
/// Mean difference between `src` and `dest` over the dab's covered pixels (working-space peak is
|
||||
/// 1, so a tolerance of 50% is `0.5`). Per pixel it is the larger of the mean colour change and the
|
||||
/// alpha change: an opaque pixel's unchanged alpha must not water a colour change down, and the
|
||||
/// Eraser keeps the colour and lowers only the alpha. Fully transparent source samples are left
|
||||
/// out; a dab whose samples are all transparent has a mean of `0.0`. `None` if nothing is covered.
|
||||
fn dab_mean_diff(p: &StampParams<'_>, dab: &Dab) -> Option<f32> {
|
||||
let (x0, y0, x1, y1) = dab_bounds(dab)?;
|
||||
/// Radius, in pixels, of the neighbourhood around a stroke's start that Tolerance measures.
|
||||
const START_RADIUS: f32 = 2.5;
|
||||
|
||||
/// Difference, in working-space units, that 100 % Tolerance asks for. The reference application
|
||||
/// starts strokes on a 20-level change (about 8 %) at Tolerance 10 but not 20, and on red over grey
|
||||
/// (about 50 %) at 80 but not 90, which a linear threshold of `0.6 × Tolerance` reproduces.
|
||||
const TOLERANCE_SCALE: f32 = 0.6;
|
||||
|
||||
/// Mean difference between `src` and `dest` around the dab's centre, where its stroke starts
|
||||
/// (working-space peak is 1). Per pixel it is the larger of the mean colour change and the alpha
|
||||
/// change: an opaque pixel's unchanged alpha must not water a colour change down, and the Eraser
|
||||
/// keeps the colour and lowers only the alpha. Fully transparent source samples are left out; a
|
||||
/// start whose samples are all transparent has a mean of `0.0`. `None` if nothing is there.
|
||||
fn start_diff(p: &StampParams<'_>, dab: &Dab) -> Option<f32> {
|
||||
if !(dab.x.is_finite() && dab.y.is_finite()) {
|
||||
return None;
|
||||
}
|
||||
let x0 = floor_i32(dab.x - START_RADIUS);
|
||||
let y0 = floor_i32(dab.y - START_RADIUS);
|
||||
let x1 = floor_i32(dab.x + START_RADIUS).saturating_add(1);
|
||||
let y1 = floor_i32(dab.y + START_RADIUS).saturating_add(1);
|
||||
let mut sampled = vec![0.0f32; p.ch];
|
||||
let mut sum = 0.0f32;
|
||||
let mut count = 0u32;
|
||||
let mut transparent = 0u32;
|
||||
for y in y0..y1 {
|
||||
for x in x0..x1 {
|
||||
if coverage_at(dab, x, y, p.hardness) <= 0.0 {
|
||||
// The history state at the same position, not the dab's rotated read.
|
||||
let (cx, cy) = (x as f32 + 0.5, y as f32 + 0.5);
|
||||
if (cx - dab.x).hypot(cy - dab.y) > START_RADIUS {
|
||||
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, alpha: p.alpha }, sx, sy, &mut sampled) {
|
||||
if !sample_bilinear(SrcView { data: p.src, w: p.src_w, h: p.src_h, origin: p.src_origin, ch: p.ch, alpha: p.alpha }, cx, cy, &mut sampled) {
|
||||
continue;
|
||||
}
|
||||
let nch = p.ch.min(dst.len()).min(sampled.len());
|
||||
@@ -636,8 +652,10 @@ fn dab_mean_diff(p: &StampParams<'_>, dab: &Dab) -> Option<f32> {
|
||||
|
||||
/// Stamp posed dabs into `dest`, tile by tile, reading `src` at each dab's rotated positions.
|
||||
///
|
||||
/// Sequential dabs overlap: dab *n* sees dab *n − 1*. Returns how many destination pixels were
|
||||
/// written (tolerance-skipped dabs count as zero).
|
||||
/// Sequential dabs overlap: dab *n* sees dab *n − 1*. Tolerance is decided where a dab starts
|
||||
/// (around its centre), so a dab that starts on a changed area also paints the unchanged pixels
|
||||
/// it reaches. Returns how many destination pixels were written (tolerance-skipped dabs count as
|
||||
/// zero).
|
||||
pub fn stamp(p: &mut StampParams<'_>) -> Result<u32, StampError> {
|
||||
dest_pixels(p)?;
|
||||
if p.src_w == 0 || p.src_h == 0 {
|
||||
@@ -653,9 +671,10 @@ pub fn stamp(p: &mut StampParams<'_>) -> Result<u32, StampError> {
|
||||
let tiles = tile_grid(p.dest_w, p.dest_h, p.dest_origin, p.tile);
|
||||
let mut written = 0u32;
|
||||
let dabs: Vec<Dab> = p.dabs.to_vec();
|
||||
let threshold = p.tolerance * TOLERANCE_SCALE;
|
||||
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) {
|
||||
if p.tolerance > 0.0 && start_diff(p, dab).is_some_and(|m| m < threshold) {
|
||||
continue;
|
||||
}
|
||||
let overlapping: Vec<(i32, i32, i32, i32)> = tiles.iter().copied().filter(|t| dab_intersects(dab, *t)).collect();
|
||||
@@ -676,3 +695,5 @@ pub fn stamp(p: &mut StampParams<'_>) -> Result<u32, StampError> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
#[cfg(test)]
|
||||
mod tolerance_tests;
|
||||
@@ -23,7 +23,8 @@ fn tolerance_ignores_fully_transparent_samples() {
|
||||
}
|
||||
});
|
||||
let dab = Dab { x: 1.0, y: 0.5, theta: 0.0, radius: 2.0, pressure: 1.0 };
|
||||
for tolerance in [0.6, 0.3] {
|
||||
// Mean difference 0.4: under the 0.6 x Tolerance threshold at 1.0, over it at 0.3.
|
||||
for tolerance in [1.0, 0.3] {
|
||||
let mut dest = before.clone();
|
||||
let written = stamp(&mut StampParams {
|
||||
dest: &mut dest,
|
||||
@@ -46,7 +47,7 @@ fn tolerance_ignores_fully_transparent_samples() {
|
||||
alpha: Some(ch - 1),
|
||||
})
|
||||
.unwrap();
|
||||
if tolerance == 0.6 {
|
||||
if tolerance == 1.0 {
|
||||
assert_eq!(written, 0, "channels={ch}, hidden={hidden}");
|
||||
assert_eq!(dest, before);
|
||||
} else {
|
||||
@@ -377,12 +378,13 @@ fn tolerance_zero_writes_where_history_differs() {
|
||||
|
||||
#[test]
|
||||
fn tolerance_ignores_unchanged_alpha() {
|
||||
// Colour moved by 0.3 and alpha did not: the 0.25 threshold must not see a 0.225 average.
|
||||
// Colour moved by 0.3 and alpha did not: the 0.27 threshold (Tolerance 45 %) must not see a
|
||||
// 0.225 average.
|
||||
let (w, h, ch) = (48usize, 48usize, 4);
|
||||
let src = fill(w, h, ch, |_, _, c| if c == 3 { 1.0 } else { 0.6 });
|
||||
let dest0 = fill(w, h, ch, |_, _, c| if c == 3 { 1.0 } else { 0.3 });
|
||||
let dab = Dab { x: 24.0, y: 24.0, theta: 0.0, radius: 8.0, pressure: 1.0 };
|
||||
for (tolerance, paints) in [(0.25, true), (0.35, false)] {
|
||||
for (tolerance, paints) in [(0.45, true), (0.55, false)] {
|
||||
let mut dest = dest0.clone();
|
||||
let mut p = StampParams {
|
||||
dest: &mut dest,
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
//! Tolerance decides where a stroke may start, with the reference application's threshold (#12633).
|
||||
|
||||
use super::*;
|
||||
|
||||
const W: usize = 80;
|
||||
const H: usize = 40;
|
||||
const CH: usize = 4;
|
||||
|
||||
fn level(v: u8) -> f32 {
|
||||
f32::from(v) / 255.0
|
||||
}
|
||||
|
||||
/// Source: grey on the left half, green on the right half (the measured Setup state).
|
||||
fn setup_source() -> Vec<f32> {
|
||||
image(|x| if x < W / 2 { [128, 128, 128] } else { [40, 160, 60] })
|
||||
}
|
||||
|
||||
/// Current layer: red on the left half (far from grey), 20 levels off the green on the right.
|
||||
fn current_layer() -> Vec<f32> {
|
||||
image(|x| if x < W / 2 { [255, 0, 0] } else { [60, 180, 80] })
|
||||
}
|
||||
|
||||
fn image(rgb: impl Fn(usize) -> [u8; 3]) -> Vec<f32> {
|
||||
let mut v = Vec::with_capacity(W * H * CH);
|
||||
for _ in 0..H {
|
||||
for x in 0..W {
|
||||
let [r, g, b] = rgb(x);
|
||||
v.extend_from_slice(&[level(r), level(g), level(b), 1.0]);
|
||||
}
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
fn dab(x: f32, radius: f32) -> Dab {
|
||||
Dab { x, y: H as f32 / 2.0, theta: 0.0, radius, pressure: 1.0 }
|
||||
}
|
||||
|
||||
/// Stamps `dabs` at `tolerance` (a fraction, Tolerance 50 % = 0.5) and returns the new layer.
|
||||
fn paint(dest: &[f32], dabs: &[Dab], tolerance: f32) -> Vec<f32> {
|
||||
let src = setup_source();
|
||||
let mut out = dest.to_vec();
|
||||
let mut p = StampParams {
|
||||
dest: &mut out,
|
||||
dest_w: W,
|
||||
dest_h: H,
|
||||
dest_origin: (0, 0),
|
||||
src: &src,
|
||||
src_w: W,
|
||||
src_h: H,
|
||||
src_origin: (0, 0),
|
||||
ch: CH,
|
||||
dabs,
|
||||
hardness: 1.0,
|
||||
opacity: 1.0,
|
||||
flow: 1.0,
|
||||
tolerance,
|
||||
tile: 0,
|
||||
selection: None,
|
||||
lock_transparent: false,
|
||||
alpha: Some(3),
|
||||
};
|
||||
stamp(&mut p).unwrap();
|
||||
out
|
||||
}
|
||||
|
||||
/// Pixels changed in columns `x0..x1`.
|
||||
fn changed(before: &[f32], after: &[f32], x0: usize, x1: usize) -> usize {
|
||||
let mut n = 0;
|
||||
for y in 0..H {
|
||||
for x in x0..x1 {
|
||||
let i = (y * W + x) * CH;
|
||||
if (0..CH).any(|c| (before[i + c] - after[i + c]).abs() > 1.0e-4) {
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
n
|
||||
}
|
||||
|
||||
const LEFT: f32 = 12.0;
|
||||
const RIGHT: f32 = 68.0;
|
||||
|
||||
#[test]
|
||||
fn a_small_difference_starts_strokes_at_10_but_not_at_20() {
|
||||
let before = current_layer();
|
||||
let dabs = [dab(RIGHT, 6.0)];
|
||||
assert!(changed(&before, &paint(&before, &dabs, 0.10), 40, 80) > 0, "20 levels off paints at Tolerance 10");
|
||||
assert_eq!(changed(&before, &paint(&before, &dabs, 0.20), 0, 80), 0, "20 levels off paints nothing at Tolerance 20");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn red_over_grey_starts_strokes_up_to_80_and_nothing_from_90() {
|
||||
let before = current_layer();
|
||||
let dabs = [dab(LEFT, 6.0)];
|
||||
for tolerance in [0.60, 0.80] {
|
||||
assert!(changed(&before, &paint(&before, &dabs, tolerance), 0, 40) > 0, "red over grey paints at {tolerance}");
|
||||
}
|
||||
let both = [dab(LEFT, 6.0), dab(RIGHT, 6.0)];
|
||||
for tolerance in [0.90, 0.95, 0.99, 1.0] {
|
||||
assert_eq!(changed(&before, &paint(&before, &both, tolerance), 0, 80), 0, "nothing paints at {tolerance}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tolerance_zero_paints_everywhere() {
|
||||
let before = current_layer();
|
||||
let after = paint(&before, &[dab(LEFT, 6.0), dab(RIGHT, 6.0)], 0.0);
|
||||
assert!(changed(&before, &after, 0, 40) > 0);
|
||||
assert!(changed(&before, &after, 40, 80) > 0);
|
||||
// Even where the layer equals the source, the dab is stamped (nothing visible changes).
|
||||
let src = setup_source();
|
||||
let mut out = src.clone();
|
||||
let d = [dab(LEFT, 6.0)];
|
||||
let mut p = StampParams {
|
||||
dest: &mut out,
|
||||
dest_w: W,
|
||||
dest_h: H,
|
||||
dest_origin: (0, 0),
|
||||
src: &src,
|
||||
src_w: W,
|
||||
src_h: H,
|
||||
src_origin: (0, 0),
|
||||
ch: CH,
|
||||
dabs: &d,
|
||||
hardness: 1.0,
|
||||
opacity: 1.0,
|
||||
flow: 1.0,
|
||||
tolerance: 0.0,
|
||||
tile: 0,
|
||||
selection: None,
|
||||
lock_transparent: false,
|
||||
alpha: Some(3),
|
||||
};
|
||||
assert!(stamp(&mut p).unwrap() > 0);
|
||||
}
|
||||
|
||||
/// Several dabs across both halves at Tolerance 20: only those starting on the red half paint, and
|
||||
/// the right half changes only where a red-half dab reaches into it.
|
||||
#[test]
|
||||
fn at_20_strokes_start_only_on_the_large_difference() {
|
||||
let before = current_layer();
|
||||
let dabs: Vec<Dab> = [8.0, 20.0, 36.0, 52.0, 64.0, 76.0].iter().map(|&x| dab(x, 6.0)).collect();
|
||||
let after = paint(&before, &dabs, 0.20);
|
||||
assert!(changed(&before, &after, 0, 40) > 0);
|
||||
assert_eq!(changed(&before, &after, 44, 80), 0, "no dab starts on the 20-level half");
|
||||
assert!(changed(&before, &after, 40, 44) > 0, "the dab at x 36 runs into the right half");
|
||||
}
|
||||
|
||||
/// The rule is where a stroke starts, not the mean under the whole dab: a big dab that starts just
|
||||
/// inside the red half paints over the right half too, and one that starts just inside the right
|
||||
/// half paints nothing although a large part of it covers red.
|
||||
#[test]
|
||||
fn the_start_decides_not_the_whole_dab() {
|
||||
let before = current_layer();
|
||||
let started_on_red = paint(&before, &[dab(37.0, 14.0)], 0.80);
|
||||
assert!(changed(&before, &started_on_red, 40, 80) > 0, "a stroke started on red runs into the green half");
|
||||
let started_on_green = paint(&before, &[dab(43.0, 14.0)], 0.20);
|
||||
assert_eq!(changed(&before, &started_on_green, 0, 80), 0, "a stroke started on the 20-level half stays unpainted");
|
||||
}
|
||||
@@ -255,7 +255,11 @@ fn layer_box_blurs_match_direct_convolution_at_any_radius() {
|
||||
SampleType::U16 => 1.0 / 65535.0,
|
||||
_ => 0.0,
|
||||
} + 2e-5;
|
||||
for p in ¶ms {
|
||||
// Each format sees both blur modes; each radius is covered across formats.
|
||||
for (pi, p) in params.iter().enumerate() {
|
||||
if pi % 2 != i % 2 {
|
||||
continue;
|
||||
}
|
||||
let boxes = box_widths(p).expect("a box-pass blur");
|
||||
let reach: i32 = boxes.iter().map(|w| (w / 2) as i32).sum();
|
||||
let area = crate::output_area(p, s.content_bounds(), canvas, None);
|
||||
|
||||
@@ -110,12 +110,14 @@ fn offset_fast_path_matches_the_per_channel_oracle() {
|
||||
for (mode, n, alpha) in layouts {
|
||||
let src = image(win, n, alpha);
|
||||
let ctx = Ctx { bounds: win, mode, alpha };
|
||||
for radius in [0.1f32, 1.0, 3.0, 12.0, 17.5] {
|
||||
// Centre only, unit stride, and a coarse stride for both qualities. At 13 the inner
|
||||
// rectangle still has pixels, so coarse offsets exercise the fast path too.
|
||||
for radius in [0.1f32, 3.0, 13.0] {
|
||||
let ri = f32::ceil(radius) as i32;
|
||||
// The usual tile (the window less the halo), the whole window, and one sticking out of it.
|
||||
let inner = Rect::new(win.x0 + ri, win.y0 + ri, win.x1 - ri, win.y1 - ri);
|
||||
for out in [inner, win, Rect::new(-12, -9, 10, 8), Rect::EMPTY] {
|
||||
// Quality only sets the offset stride: Low a coarse one, High every offset at these radii (#15652).
|
||||
// Quality selects the offset stride; both paths are compared to the oracle.
|
||||
for quality in [BlurQuality::Low, BlurQuality::High] {
|
||||
for sm in [SmartBlurMode::Normal, SmartBlurMode::EdgeOnly, SmartBlurMode::OverlayEdge] {
|
||||
for threshold in [8.0, 60.0] {
|
||||
|
||||
@@ -149,9 +149,13 @@ fn iris_depths_models_selection_tiles_and_cancellation() {
|
||||
let mut selection = Surface::new(PixelFormat::GRAY8);
|
||||
selection.fill_rect(bounds, &[0.4]);
|
||||
selection.fill_rect(Rect::new(3, 19, 35, 44), &[1.0]);
|
||||
for mode in [ColorMode::Rgb, ColorMode::Grayscale, ColorMode::Cmyk, ColorMode::Lab] {
|
||||
for sample in [SampleType::U8, SampleType::U16, SampleType::F32] {
|
||||
for alpha in [false, true] {
|
||||
// Cover every mode/sample pair and both alpha values for each mode and sample.
|
||||
for (mi, mode) in [ColorMode::Rgb, ColorMode::Grayscale, ColorMode::Cmyk, ColorMode::Lab].into_iter().enumerate() {
|
||||
for (si, sample) in [SampleType::U8, SampleType::U16, SampleType::F32].into_iter().enumerate() {
|
||||
for (ai, alpha) in [false, true].into_iter().enumerate() {
|
||||
if (mi + si) % 2 != ai {
|
||||
continue;
|
||||
}
|
||||
let fmt = PixelFormat::new(mode, sample, alpha);
|
||||
let mut surface = Surface::new(fmt);
|
||||
surface.write_region(bounds, &image(bounds, fmt.channels()).data);
|
||||
|
||||
@@ -186,10 +186,10 @@ fn a_hole_is_as_thick_as_it_is_through_not_along() {
|
||||
#[test]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn thin_holes_are_filled_the_same_on_any_number_of_threads() {
|
||||
let (w, h) = (300, 200);
|
||||
let (w, h) = (150, 100);
|
||||
let img = busy(w, h, 3, 5);
|
||||
// A wavy line 6 px thick across the image.
|
||||
let hole: Vec<bool> = (0..w * h).map(|i| (((i % w) as f32 * 0.05).sin() * 30.0 + 100.0 - (i / w) as f32).abs() < 3.0).collect();
|
||||
let hole: Vec<bool> = (0..w * h).map(|i| (((i % w) as f32 * 0.05).sin() * 15.0 + 50.0 - (i / w) as f32).abs() < 3.0).collect();
|
||||
let px = roles(w, h, &hole);
|
||||
let run = |threads: usize| {
|
||||
let pool = rayon::ThreadPoolBuilder::new().num_threads(threads).build().unwrap();
|
||||
|
||||
+2
-30
@@ -30,16 +30,8 @@ fn stroke_len(stylization: f32) -> f32 {
|
||||
1.5 + stylization.clamp(0.1, 10.0) * 2.0
|
||||
}
|
||||
|
||||
/// `f32::round` (half away from zero) as an integer, without the `roundf` call `f32::round`
|
||||
/// makes on the baseline x86-64 target. The sum is taken in `f64`, where `v ± 0.5` is exact for
|
||||
/// every `f32` the cast does not saturate (an `f32` sum is not: `0.49999997 + 0.5` rounds up to
|
||||
/// `1.0`), so the result equals `v.round() as i32` for every `f32`, NaN (0) and the saturating
|
||||
/// ends included.
|
||||
#[inline]
|
||||
fn round_i32(v: f32) -> i32 {
|
||||
let v = f64::from(v);
|
||||
(v + 0.5f64.copysign(v)) as i32
|
||||
}
|
||||
mod round;
|
||||
use round::round_i32;
|
||||
|
||||
/// [`round_i32`] clamped into `0..n`.
|
||||
#[inline]
|
||||
@@ -250,24 +242,4 @@ mod tests {
|
||||
assert_eq!(round_index(f32::INFINITY, n), ((n - 1) as f32) as usize);
|
||||
}
|
||||
}
|
||||
|
||||
/// Every `f32` bit pattern in [-4096, 4096] (both signs, about 2.3e9 values, split across
|
||||
/// threads) rounds exactly like `f32::round`.
|
||||
#[test]
|
||||
fn rounding_matches_the_standard_library_for_every_f32_up_to_4096() {
|
||||
use rayon::prelude::*;
|
||||
let last = 4096.0f32.to_bits();
|
||||
let bad = (0..=last >> 20)
|
||||
.into_par_iter()
|
||||
.filter_map(|hi| {
|
||||
let lo = hi << 20;
|
||||
let hi_end = (lo | 0xf_ffff).min(last);
|
||||
(lo..=hi_end).find_map(|bits| {
|
||||
let v = f32::from_bits(bits);
|
||||
[v, -v].into_iter().find(|v| round_i32(*v) != v.round() as i32)
|
||||
})
|
||||
})
|
||||
.min_by(|a, b| a.abs().total_cmp(&b.abs()));
|
||||
assert_eq!(bad, None, "round_i32 differs from f32::round");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/// `f32::round` (half away from zero) as an integer, without the `roundf` call `f32::round`
|
||||
/// makes on the baseline x86-64 target. The sum is taken in `f64`, where `v ± 0.5` is exact for
|
||||
/// every `f32` the cast does not saturate (an `f32` sum is not: `0.49999997 + 0.5` rounds up to
|
||||
/// `1.0`), so the result equals `v.round() as i32` for every `f32`, NaN (0) and the saturating
|
||||
/// ends included.
|
||||
#[inline]
|
||||
pub(super) fn round_i32(v: f32) -> i32 {
|
||||
let v = f64::from(v);
|
||||
(v + 0.5f64.copysign(v)) as i32
|
||||
}
|
||||
@@ -367,7 +367,7 @@ fn multiband_matches_the_serial_code() {
|
||||
/// none and everything, pass through every split the images can have (#15652; it swept 47 budgets).
|
||||
#[test]
|
||||
fn multiband_batches_match_the_serial_code() {
|
||||
for (n, &(w, h)) in [(40usize, 30usize), (97, 61), (201, 129)].iter().enumerate() {
|
||||
for (n, &(w, h)) in [(40usize, 30usize), (97, 61)].iter().enumerate() {
|
||||
for ch in [1usize, 3] {
|
||||
let (imgs, wts) = rois(w, h, ch, n as u64 * 17 + ch as u64);
|
||||
for levels in [1usize, 3, 5] {
|
||||
|
||||
@@ -127,9 +127,13 @@ fn halftone_unusual_coordinates_and_params_keep_direct_semantics() {
|
||||
fn tiled_filters_match_scalar_at_all_depths_with_soft_selection() {
|
||||
use crate::{FilterParams, apply_tiled};
|
||||
let bounds = Rect::new(-17, -9, 26, 24);
|
||||
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] {
|
||||
// Every mode/depth pair and both alpha values for each mode and depth.
|
||||
for (mi, mode) in [ColorMode::Rgb, ColorMode::Grayscale, ColorMode::Cmyk, ColorMode::Lab].into_iter().enumerate() {
|
||||
for (di, depth) in [SampleType::U8, SampleType::U16, SampleType::F32].into_iter().enumerate() {
|
||||
for (ai, alpha) in [false, true].into_iter().enumerate() {
|
||||
if (mi + di) % 2 != ai {
|
||||
continue;
|
||||
}
|
||||
let ctx = Ctx { bounds, mode, alpha };
|
||||
let src = fixture(bounds, &ctx, 2);
|
||||
let mut surface = Surface::new(PixelFormat::new(mode, depth, alpha));
|
||||
@@ -198,14 +202,18 @@ fn cell_filters_match_scalar_models_edges_and_fractional_cells() {
|
||||
// The cell filters see the mode only as a channel count, CMYK's ink direction (`subtractive`) and the native
|
||||
// background, so Lab adds nothing to RGB; cells of 100 and 300 are both past every `out`, and the seed has no
|
||||
// branch (0 and u32::MAX keep the wrapping ends) (#15652).
|
||||
for mode in [ColorMode::Rgb, ColorMode::Grayscale, ColorMode::Cmyk, ColorMode::Multichannel] {
|
||||
for alpha in [false, true] {
|
||||
for (mi, mode) in [ColorMode::Rgb, ColorMode::Grayscale, ColorMode::Cmyk, ColorMode::Multichannel].into_iter().enumerate() {
|
||||
for (ai, alpha) in [false, true].into_iter().enumerate() {
|
||||
let ctx = Ctx { bounds, mode, alpha };
|
||||
for pattern in 0..5 {
|
||||
for halo in [0, 7] {
|
||||
let src = fixture(bounds.inflate(halo), &ctx, pattern);
|
||||
for out in [bounds, Rect::new(-23, -15, 37, 31), Rect::new(-7, 2, 18, 13)] {
|
||||
for cell in [2.0, 3.75, 10.0, 300.0] {
|
||||
// Retain every mode/alpha pair and all four cell sizes for each mode.
|
||||
for (ci, cell) in [2.0, 3.75, 10.0, 300.0].into_iter().enumerate() {
|
||||
if ci % 2 != (mi + ai) % 2 {
|
||||
continue;
|
||||
}
|
||||
for seed in [0, u32::MAX] {
|
||||
let got = cells::crystallize(&src, out, &ctx, cell, seed).unwrap();
|
||||
assert_bits(&got, &crystallize_direct(&src, out, &ctx, cell, seed));
|
||||
|
||||
+23
-15
@@ -150,6 +150,11 @@ fn read_rgba(src: &Image, ctx: &Ctx, x: i32, y: i32) -> [f32; 4] {
|
||||
|
||||
/// Relight `out` of `src`. Identity when `intensity` is 0 (or not finite).
|
||||
pub(crate) fn relight(src: &Image, out: Rect, ctx: &Ctx, p: Params) -> Vec<f32> {
|
||||
relight_with_luma_budget(src, out, ctx, p, MAX_LUMA_PIXELS)
|
||||
}
|
||||
|
||||
/// Relight with a bound on the luma field allocated by each band.
|
||||
fn relight_with_luma_budget(src: &Image, out: Rect, ctx: &Ctx, p: Params, max_luma_pixels: usize) -> Vec<f32> {
|
||||
let n = src.ch;
|
||||
if out.is_empty() || n == 0 {
|
||||
return src.crop(out);
|
||||
@@ -160,14 +165,14 @@ pub(crate) fn relight(src: &Image, out: Rect, ctx: &Ctx, p: Params) -> Vec<f32>
|
||||
let sig = sigma(p.softness, ctx.bounds);
|
||||
let step = step_for_sigma(sig);
|
||||
let reach = read_radius(sig);
|
||||
if let Some(band_h) = luma_band_rows(out, reach) {
|
||||
if let Some(band_h) = luma_band_rows(out, reach, max_luma_pixels) {
|
||||
return relight_bands(src, out, ctx, p, sig, step, band_h);
|
||||
}
|
||||
relight_rect(src, out, ctx, p, sig, step)
|
||||
}
|
||||
|
||||
/// Horizontal strip height so the inflated luma field stays within [`MAX_LUMA_PIXELS`].
|
||||
fn luma_band_rows(out: Rect, reach: i32) -> Option<i32> {
|
||||
fn luma_band_rows(out: Rect, reach: i32, max_luma_pixels: usize) -> Option<i32> {
|
||||
let margin = 2usize.saturating_mul(reach.max(0) as usize);
|
||||
let yw = (out.width() as usize).saturating_add(margin);
|
||||
let yh = (out.height() as usize).saturating_add(margin);
|
||||
@@ -179,10 +184,10 @@ fn luma_band_rows(out: Rect, reach: i32) -> Option<i32> {
|
||||
Some(_) => return None,
|
||||
None => usize::MAX,
|
||||
};
|
||||
if n <= MAX_LUMA_PIXELS {
|
||||
if n <= max_luma_pixels {
|
||||
return None;
|
||||
}
|
||||
let max_yh = (MAX_LUMA_PIXELS / yw).max(1);
|
||||
let max_yh = (max_luma_pixels / yw).max(1);
|
||||
let inner = max_yh.saturating_sub(margin).max(1).min(i32::MAX as usize) as i32;
|
||||
if inner >= out.height() as i32 { None } else { Some(inner.max(1)) }
|
||||
}
|
||||
@@ -534,10 +539,9 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layers_above_8mp_are_relit() {
|
||||
// 4096×2048 = 8.39 MP. A single full-frame kernel call inflates past 8 MP of luma,
|
||||
// which used to return the input unchanged. Force one tile so that path is taken.
|
||||
let (w, h) = (4096, 2048);
|
||||
fn layers_above_the_luma_budget_are_relit() {
|
||||
// A small budget exercises the same banding path as an 8 MP luma field.
|
||||
let (w, h) = (256, 128);
|
||||
let bounds = Rect::new(0, 0, w, h);
|
||||
let mut s = Surface::new(PixelFormat::RGBA8);
|
||||
let bytes: Vec<u8> = (0..h)
|
||||
@@ -550,15 +554,19 @@ mod tests {
|
||||
})
|
||||
.collect();
|
||||
s.write_interleaved(bounds, &bytes);
|
||||
let p = relight_p(180.0, 30.0, 90.0, 12.0, 0.0, 25.0);
|
||||
let area = output_area(&p, s.content_bounds(), bounds, None);
|
||||
let p = Params { angle: 180.0, elevation: 30.0, intensity: 90.0, ambient: 12.0, warmth: 0.0, softness: 25.0 };
|
||||
let reach = read_radius(sigma(p.softness, bounds));
|
||||
assert!(luma_band_rows(bounds, reach, 20_000).is_some());
|
||||
let src = Image::read_clamped(&s, bounds.inflate(reach), bounds);
|
||||
let ctx = Ctx { bounds, mode: ColorMode::Rgb, alpha: true };
|
||||
let before = s.pixel(w / 2, h / 2);
|
||||
let out = apply_tiled(&s, &p, area, bounds, None, 8192, None);
|
||||
let after = out.pixel(w / 2, h / 2);
|
||||
let out = relight_with_luma_budget(&src, bounds, &ctx, p, 20_000);
|
||||
let pixel = |x: i32, y: i32| &out[((y * w + x) * 4) as usize..][..4];
|
||||
let after = pixel(w / 2, h / 2);
|
||||
assert!(after.iter().all(|c| c.is_finite()), "{after:?}");
|
||||
let d = max_diff(&before, &after);
|
||||
assert!(d > 1e-4, "8 MP+ layer was left unchanged (max diff {d})");
|
||||
assert!(max_diff(&s.pixel(8, 8), &out.pixel(8, 8)) > 1e-4);
|
||||
let d = max_diff(&before, after);
|
||||
assert!(d > 1e-4, "over-budget layer was left unchanged (max diff {d})");
|
||||
assert!(max_diff(&s.pixel(8, 8), pixel(8, 8)) > 1e-4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -273,6 +273,10 @@ mod tests {
|
||||
let fmt = PixelFormat::new(mode, depth, true);
|
||||
for (w, h) in [(512, 512), (900, 240), (2400, 1200)] {
|
||||
for seed in [0, 3, 7, 18916] {
|
||||
// One seed exercises the large canvas; all seeds still run at both smaller sizes.
|
||||
if w == 2400 && seed != 0 {
|
||||
continue;
|
||||
}
|
||||
let px = render(fmt, w, h, seed, (BLACK, WHITE), None);
|
||||
let v: Vec<f32> = px.chunks_exact(fmt.channels()).map(|p| p[0]).collect();
|
||||
let n = v.len() as f32;
|
||||
|
||||
@@ -297,23 +297,23 @@ fn canvas_edges_repeat_instead_of_fading() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Two tiles in opposite corners of a 100000 px square: the content bounds are huge but
|
||||
/// Two tiles in opposite corners of a 20096 px square: the content bounds are huge but
|
||||
/// almost nothing is stored. Shrinking it to one pixel must neither allocate a window
|
||||
/// proportional to the scale (#713) nor read the empty middle.
|
||||
#[test]
|
||||
fn tiny_target_of_a_huge_sparse_source() {
|
||||
let mut s = Surface::new(PixelFormat::RGBA32F);
|
||||
s.fill_rect(Rect::new(0, 0, 256, 256), &[1.0, 1.0, 1.0, 1.0]);
|
||||
s.fill_rect(Rect::new(99_840, 99_840, 100_096, 100_096), &[1.0, 1.0, 1.0, 1.0]);
|
||||
let k = 1.0 / 100_096.0;
|
||||
s.fill_rect(Rect::new(19_840, 19_840, 20_096, 20_096), &[1.0, 1.0, 1.0, 1.0]);
|
||||
let k = 1.0 / 20_096.0;
|
||||
let o = resize_surface(&s, k, k, Resample::Bicubic);
|
||||
assert_eq!(o.content_bounds(), Rect::new(0, 0, 1, 1));
|
||||
let p = o.pixel(0, 0);
|
||||
// Two 256² tiles out of 100096²: nearly transparent, and white where it isn't.
|
||||
// Two 256² tiles out of 20096²: nearly transparent, and white where it isn't.
|
||||
assert!(p[3] >= 0.0 && p[3] < 1e-3 && p.iter().all(|v| v.is_finite()), "{p:?}");
|
||||
// Squashed to one row but kept wide: the whole height feeds one band of output rows,
|
||||
// which must not hold a full-height intermediate.
|
||||
let o = resize_surface(&s, 1000.0 / 100_096.0, k, Resample::Bicubic);
|
||||
let o = resize_surface(&s, 1000.0 / 20_096.0, k, Resample::Bicubic);
|
||||
let b = o.content_bounds();
|
||||
assert!(b.height() == 1 && (1000..=1001).contains(&b.width()), "{b:?}");
|
||||
assert!(o.pixel(0, 0)[3] > 0.0 && o.pixel(500, 0)[3] == 0.0, "{:?} {:?}", o.pixel(0, 0), o.pixel(500, 0));
|
||||
|
||||
@@ -82,16 +82,16 @@ fn quick_selection_workflow_release_comparison() {
|
||||
|
||||
#[test]
|
||||
fn quick_selection_preserves_textures_low_contrast_and_thin_features() {
|
||||
let (w, h) = (360usize, 280usize);
|
||||
let (w, h) = (180usize, 140usize);
|
||||
let canvas = Rect::new(0, 0, w as i32, h as i32);
|
||||
for kind in 0..6 {
|
||||
let img = RgbImage::from_fn(w, h, |x, y| {
|
||||
let inside = if kind == 2 {
|
||||
(x as f32 - 180.0).hypot(y as f32 - 140.0) < 72.0
|
||||
(x as f32 - 90.0).hypot(y as f32 - 70.0) < 36.0
|
||||
} else if kind == 3 {
|
||||
y > 130 && y < 145
|
||||
y > 65 && y < 73
|
||||
} else {
|
||||
x > 60 && x < 300 && y > 60 && y < 220
|
||||
x > 30 && x < 150 && y > 30 && y < 110
|
||||
};
|
||||
let t = ((x * 23 + y * 19) % 101) as f32 / 100.0;
|
||||
match kind {
|
||||
@@ -102,7 +102,7 @@ fn quick_selection_preserves_textures_low_contrast_and_thin_features() {
|
||||
[0.4, 0.3 + t * 0.1, 0.2]
|
||||
}
|
||||
}
|
||||
1 => [0.4 + x as f32 / 1800.0, 0.3 + y as f32 / 1400.0, t * 0.02],
|
||||
1 => [0.4 + x as f32 / 900.0, 0.3 + y as f32 / 700.0, t * 0.02],
|
||||
4 => [t, ((x * 7 + y * 31) % 79) as f32 / 78.0, 0.4],
|
||||
5 => [0.4; 3],
|
||||
_ => {
|
||||
@@ -115,8 +115,9 @@ fn quick_selection_preserves_textures_low_contrast_and_thin_features() {
|
||||
}
|
||||
});
|
||||
let sampler = ImageSampler { img: &img, origin: (0, 0) };
|
||||
for (points, brush) in [(vec![(180.0, 140.0)], 12.0), (vec![(90.0, 140.0), (270.0, 140.0)], 40.0), (vec![(1.0, 1.0), (160.0, 130.0)], 64.0)] {
|
||||
for direct_px in [10_000, 300_000] {
|
||||
for (points, brush) in [(vec![(90.0, 70.0)], 6.0), (vec![(45.0, 70.0), (135.0, 70.0)], 20.0), (vec![(1.0, 1.0), (80.0, 65.0)], 32.0)] {
|
||||
// Scale the coarse-cut threshold with the canvas area; the second case stays direct.
|
||||
for direct_px in [2_500, 300_000] {
|
||||
let tune = quick::Tuning { direct_px, ..quick::Tuning::default() };
|
||||
let old = quick::quick_select_using::<false>(&sampler, canvas, &points, brush, &tune);
|
||||
let new = quick::quick_select_using::<true>(&sampler, canvas, &points, brush, &tune);
|
||||
|
||||
@@ -183,13 +183,17 @@ fn exact_tiled_selected_outputs_and_cancellation() {
|
||||
let mut sel = Surface::new(PixelFormat::GRAY8);
|
||||
sel.fill_rect(area, &[0.4]);
|
||||
sel.fill_rect(Rect::new(250, 250, 270, 265), &[1.0]);
|
||||
for depth in SampleType::ALL {
|
||||
for (di, depth) in SampleType::ALL.into_iter().enumerate() {
|
||||
let surface = source(bounds, PixelFormat::new(ColorMode::Rgb, depth, true));
|
||||
for radius in [0.6, 3.0, 10.0] {
|
||||
for (ri, radius) in [0.6, 3.0, 10.0].into_iter().enumerate() {
|
||||
let p = crate::FilterParams::UnsharpMask { amount: 150.0, radius, threshold: 8.0 };
|
||||
for extent in [None, Some(bounds)] {
|
||||
let expected = apply_reference(&surface, &p, area, bounds, Some(&sel), extent, 256);
|
||||
for tile in [63, 256, 512] {
|
||||
// Keep every depth/radius, depth/tile and radius/tile pair, with both extents.
|
||||
for (ti, tile) in [63, 256, 512].into_iter().enumerate() {
|
||||
if ti != (di + ri) % 3 {
|
||||
continue;
|
||||
}
|
||||
let actual = crate::apply_tiled(&surface, &p, area, bounds, Some(&sel), tile, extent);
|
||||
assert_eq!(expected.to_interleaved(bounds), actual.to_interleaved(bounds));
|
||||
}
|
||||
|
||||
@@ -44,8 +44,11 @@ fn swept_blocks_match_the_pixel_search_part(part: u64) {
|
||||
let repeat = !seen.insert((n, alpha, mode == ColorMode::Cmyk));
|
||||
for kind in 0..5 {
|
||||
let src = image(bounds.inflate(20), n, kind);
|
||||
for (size, depth) in [(2.0, 0.0), (2.0, 255.0), (3.5, 190.0), (8.0, 64.0), (22.0, 255.0), (255.0, 100.0)] {
|
||||
for flags in (0..8).filter(|f| !repeat || f & 1 != 0) {
|
||||
for (si, (size, depth)) in [(2.0, 0.0), (2.0, 255.0), (3.5, 190.0), (8.0, 64.0), (22.0, 255.0), (255.0, 100.0)].into_iter().enumerate() {
|
||||
// For distinct channel layouts each kind and size sees every flag
|
||||
// combination. Repeated layouts keep one level-based case per pair.
|
||||
let first = (kind + si) % 8;
|
||||
for flags in (0..8).filter(|f| (!repeat || f & 1 != 0) && (*f == first || *f == (first + 3) % 8)) {
|
||||
case += 1;
|
||||
if !sweep.includes(case) {
|
||||
continue;
|
||||
|
||||
@@ -34,6 +34,7 @@ impl BandRenderer for QueuedDiagnosticsRenderer {
|
||||
|
||||
#[test]
|
||||
fn native_save_refuses_previews_rendered_from_unreadable_scratch() {
|
||||
photocraft_raster::spill::use_test_volume_space();
|
||||
let dir = std::env::temp_dir().join(format!("photocraft-automation-scratch-save-{}", std::process::id()));
|
||||
spill::configure(Some(&dir), 1).unwrap();
|
||||
let mut doc = Document::new("Scratch", Size::new(512, 256), ColorMode::Rgb, SampleType::U8);
|
||||
|
||||
@@ -46,7 +46,70 @@ pub enum BlendMode {
|
||||
PaintNetColorDodge,
|
||||
}
|
||||
|
||||
/// Parse legacy command names and labels, retaining their case and punctuation tolerance.
|
||||
pub fn parse_blend(s: &str) -> Option<BlendMode> {
|
||||
fn normalize(value: &str) -> String {
|
||||
value.to_ascii_lowercase().replace([' ', '_', '-', '(', ')'], "")
|
||||
}
|
||||
static ALIASES: std::sync::OnceLock<std::collections::HashMap<String, BlendMode>> = std::sync::OnceLock::new();
|
||||
let aliases = ALIASES.get_or_init(|| {
|
||||
let mut aliases = std::collections::HashMap::new();
|
||||
for mode in std::iter::once(BlendMode::PassThrough).chain(BlendMode::layer_modes()) {
|
||||
aliases.entry(normalize(mode.label())).or_insert(mode);
|
||||
aliases.entry(normalize(&format!("{mode:?}"))).or_insert(mode);
|
||||
}
|
||||
aliases
|
||||
});
|
||||
aliases.get(&normalize(s)).copied()
|
||||
}
|
||||
|
||||
impl BlendMode {
|
||||
/// Stable key used by the Layers panel.
|
||||
pub fn key(self) -> &'static str {
|
||||
match self {
|
||||
Self::PassThrough => "passthrough",
|
||||
Self::Normal => "normal",
|
||||
Self::Dissolve => "dissolve",
|
||||
Self::Darken => "darken",
|
||||
Self::Multiply => "multiply",
|
||||
Self::ColorBurn => "colorburn",
|
||||
Self::LinearBurn => "linearburn",
|
||||
Self::DarkerColor => "darkercolor",
|
||||
Self::Lighten => "lighten",
|
||||
Self::Screen => "screen",
|
||||
Self::ColorDodge => "colordodge",
|
||||
Self::LinearDodge => "lineardodgeadd",
|
||||
Self::LighterColor => "lightercolor",
|
||||
Self::Overlay => "overlay",
|
||||
Self::SoftLight => "softlight",
|
||||
Self::HardLight => "hardlight",
|
||||
Self::VividLight => "vividlight",
|
||||
Self::LinearLight => "linearlight",
|
||||
Self::PinLight => "pinlight",
|
||||
Self::HardMix => "hardmix",
|
||||
Self::Difference => "difference",
|
||||
Self::Exclusion => "exclusion",
|
||||
Self::Subtract => "subtract",
|
||||
Self::Divide => "divide",
|
||||
Self::Hue => "hue",
|
||||
Self::Saturation => "saturation",
|
||||
Self::Color => "color",
|
||||
Self::Luminosity => "luminosity",
|
||||
Self::Reflect => "reflect",
|
||||
Self::Glow => "glow",
|
||||
Self::Negation => "negation",
|
||||
Self::Xor => "xor",
|
||||
Self::PaintNetColorBurn => "colorburnpaint.net",
|
||||
Self::PaintNetColorDodge => "colordodgepaint.net",
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolve a canonical Layers panel key.
|
||||
pub fn from_key(key: &str) -> Option<Self> {
|
||||
static MODES: std::sync::OnceLock<std::collections::HashMap<&'static str, BlendMode>> = std::sync::OnceLock::new();
|
||||
MODES.get_or_init(|| std::iter::once(Self::PassThrough).chain(Self::layer_modes()).map(|mode| (mode.key(), mode)).collect()).get(key).copied()
|
||||
}
|
||||
|
||||
/// Paint.NET modes without an exact Photoshop equivalent.
|
||||
pub const PAINT_NET_MODES: [BlendMode; 6] = [Self::Reflect, Self::Glow, Self::Negation, Self::Xor, Self::PaintNetColorBurn, Self::PaintNetColorDodge];
|
||||
|
||||
@@ -623,3 +686,37 @@ pub fn composite_atop(mode: BlendMode, backdrop: [f32; 4], source: [f32; 4], opa
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[cfg(test)]
|
||||
mod key_tests {
|
||||
use super::BlendMode;
|
||||
|
||||
#[test]
|
||||
fn parser_preserves_legacy_names_and_normalization() {
|
||||
let normalize = |s: &str| s.to_ascii_lowercase().replace([' ', '_', '-', '(', ')'], "");
|
||||
let legacy = |s: &str| {
|
||||
let wanted = normalize(s);
|
||||
std::iter::once(BlendMode::PassThrough)
|
||||
.chain(BlendMode::layer_modes())
|
||||
.find(|mode| normalize(mode.label()) == wanted || normalize(&format!("{mode:?}")) == wanted)
|
||||
};
|
||||
for mode in std::iter::once(BlendMode::PassThrough).chain(BlendMode::layer_modes()) {
|
||||
for name in [mode.label().to_owned(), format!("{mode:?}"), mode.label().to_ascii_uppercase().replace(' ', "_-")] {
|
||||
assert_eq!(super::parse_blend(&name), legacy(&name), "{name}");
|
||||
}
|
||||
}
|
||||
for name in ["", "not a mode", "color.burn", "é"] {
|
||||
assert_eq!(super::parse_blend(name), legacy(name), "{name}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn canonical_keys_match_legacy_panel_names_and_round_trip() {
|
||||
for mode in std::iter::once(BlendMode::PassThrough).chain(BlendMode::layer_modes()) {
|
||||
let old = mode.label().to_ascii_lowercase().replace([' ', '_', '-', '(', ')'], "");
|
||||
assert_eq!(mode.key(), old);
|
||||
assert_eq!(BlendMode::from_key(&old), Some(mode));
|
||||
}
|
||||
assert_eq!(BlendMode::from_key("no-such-mode"), None);
|
||||
}
|
||||
}
|
||||
@@ -1704,7 +1704,8 @@ fn normal_onto_nothing_is_exact() {
|
||||
};
|
||||
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 })];
|
||||
vec![build(&LayerSpec::Group { children: vec![shape, inv], pass_through: false, blend: BlendMode::Normal, opacity: 1.0, fill: 1.0, mask: None })]
|
||||
.into();
|
||||
assert_matches_reference(&d);
|
||||
assert_eq!(render1(&d, 0, 0)[..4], [0.0; 4]);
|
||||
}
|
||||
|
||||
@@ -193,11 +193,15 @@ pub(super) fn bevel_maps(shape: &Map, b: &Bevel, light: &GlobalLight, tex: &Text
|
||||
let on_bevel = |x: i64, y: i64| {
|
||||
hmap.get(x, y) > BEVEL_H_EPS || (reach_past && [(1, 0), (-1, 0), (0, 1), (0, -1)].iter().any(|(dx, dy)| hmap.get(x + dx, y + dy) > BEVEL_H_EPS))
|
||||
};
|
||||
// The gloss contour remaps the shading `n · light` before it splits into highlight (above
|
||||
// what it maps a flat face's `sin(altitude)` to) and shadow. Applied to the highlight and shadow amounts
|
||||
// instead, a contour that starts high (Rolling Slope - Descending) lit every pixel the light
|
||||
// missed, so a bevelled glyph's flat face took the full highlight (#7360) where Photoshop
|
||||
// leaves it at the layer's colour. The Linear contour changes nothing either way.
|
||||
// The gloss contour remaps the shading `n · light` before it splits into highlight (above a
|
||||
// flat face's own, unmapped `sin(altitude)`) and shadow (below it). Applied to the highlight
|
||||
// and shadow amounts instead, a contour that starts high (Rolling Slope - Descending) lit
|
||||
// every pixel the light missed (#7360). With the mapped `lut(sin(altitude))` as the neutral,
|
||||
// a high light washed out whole faces: at altitude 69 that contour maps the flat 0.93 to
|
||||
// 0.16, so every slope above 0.16 took the full highlight where Photoshop only glints where
|
||||
// the shading nears 0. A contour that moves the flat shading lights or darkens the flat face
|
||||
// too, as Photoshop does (oracles bevel-inner-gloss-ramp-peak / -double-ring-aa: faces at
|
||||
// the full highlight and a 0.69 shadow). The Linear contour changes nothing either way.
|
||||
let gloss = contour_lut(&b.gloss_contour);
|
||||
let shade_into = |depth: f32, region_kind: u8| -> (Map, Map) {
|
||||
let (mut hi, mut sh) = (Map::new(shape.w, shape.h, 0.0), Map::new(shape.w, shape.h, 0.0));
|
||||
@@ -219,7 +223,7 @@ pub(super) fn bevel_maps(shape: &Map, b: &Bevel, light: &GlobalLight, tex: &Text
|
||||
let len = (n[0] * n[0] + n[1] * n[1] + 1.0).sqrt();
|
||||
let shade = (n[0] * light_v[0] + n[1] * light_v[1] + n[2] * light_v[2]) / len;
|
||||
let region = if region_kind == 0 { shape.v[i] } else { f32::from(shape.v[i] < 1.0 - INSIDE_EPS && on_bevel(x, y)) };
|
||||
let k = gloss.as_ref().map_or(shade - se, |l| lut_at(l, shade) - lut_at(l, se));
|
||||
let k = gloss.as_ref().map_or(shade, |l| lut_at(l, shade)) - se;
|
||||
if k > 0.0 {
|
||||
hi_row[x as usize] = (k / (1.0 - se).max(1e-3)).clamp(0.0, 1.0) * region;
|
||||
} else {
|
||||
|
||||
@@ -199,6 +199,64 @@ fn smooth_inner_bevel_lights_the_top_edge_inside_only() {
|
||||
assert!(at(&maps[0], 20, 15) < 0.05);
|
||||
}
|
||||
|
||||
/// A gloss contour from Photoshop's 0–255 contour editor points.
|
||||
fn gloss_of(points: &[(f32, f32)]) -> Contour {
|
||||
Contour::Custom {
|
||||
name: "gloss".into(),
|
||||
points: points.iter().map(|&(i, o)| photocraft_doc::adjust::CurvePoint { input: i / 255.0, output: o / 255.0 }).collect(),
|
||||
corners: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
/// Smooth inner bevel highlight and shadow maps of `shape` with `gloss`, light from `angle` at
|
||||
/// `altitude`.
|
||||
fn gloss_maps(shape: &Map, gloss: Contour, angle: f32, altitude: f32, size: f32, depth: f32) -> Vec<Map> {
|
||||
let mut b = bevel_of(BevelStyle::InnerBevel, BevelTechnique::Smooth);
|
||||
(b.angle, b.altitude, b.size, b.depth, b.gloss_contour) = (angle, altitude, size, depth, gloss);
|
||||
bevel_maps(shape, &b, &GlobalLight::default(), &no_tex(), &PreparedPatterns::new(&[], PREPARED_PATTERN_BYTES)).0
|
||||
}
|
||||
|
||||
/// The gloss contour maps the shading, and the flat face's own unmapped shading `sin(altitude)`
|
||||
/// stays the neutral. Photoshop's own composite of a purchased style pack's type (Rolling Slope -
|
||||
/// Descending at altitude 69, 16 px smooth inner bevel at 358 %): the face stays at its colour, with white
|
||||
/// glints only where the shading is within ~0.015 of zero (measured per pixel against this
|
||||
/// bevel's shading). With the mapped `lut(sin 69°)` = 0.16 as the neutral, every slope pixel
|
||||
/// whose mapped shading came out above it took the full highlight, and the type rendered white.
|
||||
#[test]
|
||||
fn high_altitude_descending_gloss_only_glints_where_the_light_misses() {
|
||||
let n = 80;
|
||||
let mut shape = Map::new(n, n, 0.0);
|
||||
for y in 10..70 {
|
||||
for x in 20..60 {
|
||||
shape.v[y * n + x] = 1.0;
|
||||
}
|
||||
}
|
||||
let rolling = gloss_of(&[(2.0, 255.0), (53.0, 100.0), (97.0, 107.0), (179.0, 153.0), (252.0, 0.0)]);
|
||||
// Light from the left: the bar's right slope faces away from it.
|
||||
let maps = gloss_maps(&shape, rolling, 180.0, 69.0, 16.0, 3.58);
|
||||
let row: Vec<f32> = (20..60).map(|x| maps[0].v[40 * n + x]).collect();
|
||||
let lit = row.iter().filter(|v| **v > 0.05).count();
|
||||
assert!(lit <= 8, "only a few glint pixels, not the whole face: {row:?}");
|
||||
assert!(row[..20].iter().all(|v| *v < 0.05), "no highlight on the slope facing the light: {row:?}");
|
||||
assert!(row[20..].iter().any(|v| *v > 0.9), "a full glint where the slope faces away: {row:?}");
|
||||
}
|
||||
|
||||
/// Photoshop 27.11 oracles (corpus `bevel-inner-gloss-ramp-peak` / `-double-ring-aa`: 12 px
|
||||
/// smooth inner bevel at altitude 30, Screen white and Multiply black at 75 % over (90, 120,
|
||||
/// 170)): a contour that maps the flat shading 0.5 above or below 0.5 lights or darkens the flat
|
||||
/// face too. Ramp-peak (0,0)(128,255)(255,0) paints the face (214, 221, 234), the full
|
||||
/// highlight; double-ring (…, (128, 40), …) paints it (44, 58, 83), a 0.69 shadow.
|
||||
#[test]
|
||||
fn a_gloss_contour_lights_or_darkens_the_flat_face_around_the_unmapped_neutral() {
|
||||
let shape = square(40, 5, 35);
|
||||
let face = |m: &Map| m.v[20 * 40 + 20];
|
||||
let peak = gloss_maps(&shape, gloss_of(&[(0.0, 0.0), (128.0, 255.0), (255.0, 0.0)]), 120.0, 30.0, 5.0, 1.0);
|
||||
assert!(face(&peak[0]) > 0.99 && face(&peak[1]) == 0.0, "ramp-peak: full highlight, {} / {}", face(&peak[0]), face(&peak[1]));
|
||||
let ring = gloss_maps(&shape, gloss_of(&[(0.0, 0.0), (64.0, 255.0), (128.0, 40.0), (192.0, 255.0), (255.0, 0.0)]), 120.0, 30.0, 5.0, 1.0);
|
||||
// (0.5 − 40/255) / 0.5: 90 × (1 − 0.75 × 0.686) = 43.7.
|
||||
assert!(face(&ring[0]) == 0.0 && (face(&ring[1]) - 0.686).abs() < 0.02, "double-ring: shadow {}", face(&ring[1]));
|
||||
}
|
||||
|
||||
/// Photoshop 27.11, measured across a straight edge (size 10, depth 100 %, light from the top
|
||||
/// at 30°): a chisel facet has the slope `depth × size / (2 (size + 1))`, flat right up to the
|
||||
/// edge pixel for Inner Hard; Inner Soft's edge pixel is half as steep again; Outer Hard
|
||||
|
||||
@@ -170,10 +170,10 @@ fn a_stroked_shapes_mask_applies_to_fill_and_stroke_together() {
|
||||
assert!(close4(p, [0.0, 1.0, 0.0, 0.5]), "{p:?}");
|
||||
// With effects too.
|
||||
l.effects.items = vec![Effect::ColorOverlay { common: FxCommon::new(BlendMode::Normal, 1.0), color: Color::rgb(1.0, 1.0, 1.0) }];
|
||||
d.layers = vec![l.clone()];
|
||||
d.layers = vec![l.clone()].into();
|
||||
let p = px(&d, 12, 20);
|
||||
assert!(close4(p, [0.0, 1.0, 0.0, 0.5]), "without clipped layers: {p:?}");
|
||||
d.layers = vec![l, clip];
|
||||
d.layers = vec![l, clip].into();
|
||||
let p = px(&d, 12, 20);
|
||||
assert!(close4(p, [0.0, 1.0, 0.0, 0.5]), "{p:?}");
|
||||
}
|
||||
|
||||
+69
-10
@@ -404,7 +404,7 @@ fn every_blend_mode_matches_reference_on_opaque_pixels() {
|
||||
let mut top = Layer::raster("t", PixelFormat::RGBA32F);
|
||||
top.surface_mut().unwrap().fill_rect(Rect::new(0, 0, 2, 2), &source);
|
||||
top.blend = mode;
|
||||
d.layers = vec![bottom, top];
|
||||
d.layers = vec![bottom, top].into();
|
||||
let got = px(&d, 0, 0);
|
||||
// A 32-bit document: Add / Divide don't clip at 1 (Divide gives 0.6 / 0.2 = 3 in red).
|
||||
psblend::HDR.with(|h| h.set(true));
|
||||
@@ -434,7 +434,7 @@ fn full_coverage_adjustment_keeps_its_result_over_huge_hdr_values() {
|
||||
dither: false,
|
||||
source: None,
|
||||
};
|
||||
d.layers = vec![base, Layer::new("look", LayerContent::Adjustment(look))];
|
||||
d.layers = vec![base, Layer::new("look", LayerContent::Adjustment(look))].into();
|
||||
let got = px(&d, 0, 0);
|
||||
for c in &got[..3] {
|
||||
assert!((c - 0.5).abs() < 1e-6, "{v}: {got:?}");
|
||||
@@ -479,7 +479,7 @@ fn blend_px(depth: SampleType, mode: BlendMode, bottom: [f32; 3], top: [f32; 3])
|
||||
let mut t = Layer::raster("t", fmt);
|
||||
t.surface_mut().unwrap().fill_rect(Rect::new(0, 0, 1, 1), &photocraft_raster::from_rgba(&fmt, [top[0], top[1], top[2], 1.0]));
|
||||
t.blend = mode;
|
||||
d.layers = vec![b, t];
|
||||
d.layers = vec![b, t].into();
|
||||
px(&d, 0, 0)
|
||||
}
|
||||
|
||||
@@ -1988,10 +1988,12 @@ fn satin_and_bevel_stay_inside_shape() {
|
||||
|
||||
/// #7360: a gloss contour that starts high (Rolling Slope - Descending, as the reporter's PSD
|
||||
/// uses) left a bevelled shape's flat face at the full Overlay highlight, (255, 40, 42) on a
|
||||
/// (151, 22, 23) fill, where Photoshop leaves the face at the fill colour. The contour maps the
|
||||
/// shading, so the flat face stays neutral and only the slopes are shaded.
|
||||
/// (151, 22, 23) fill. The contour maps the shading, with the unmapped flat shading
|
||||
/// `sin(altitude)` as the neutral, so the face only takes what the contour moves 0.5 by:
|
||||
/// Rolling Slope maps it to 0.55, a 0.09 highlight, (161, 24, 25). Photoshop's own composite of
|
||||
/// the reporter's repro has the glyph's face at 151–161 in red, not the exact fill.
|
||||
#[test]
|
||||
fn a_gloss_contour_leaves_the_flat_face_of_a_bevel_unlit() {
|
||||
fn a_gloss_contour_leaves_the_flat_face_of_a_bevel_near_its_fill() {
|
||||
let fill = [151.0 / 255.0, 22.0 / 255.0, 23.0 / 255.0, 1.0];
|
||||
let rolling = photocraft_doc::Contour::Custom {
|
||||
name: "Rolling Slope - Descending".into(),
|
||||
@@ -2029,14 +2031,71 @@ fn a_gloss_contour_leaves_the_flat_face_of_a_bevel_unlit() {
|
||||
};
|
||||
let d = render(rolling);
|
||||
for (x, y) in [(20, 20), (16, 22), (24, 16)] {
|
||||
let p = px(&d, x, y);
|
||||
assert!(close4(p, fill), "flat face ({x},{y}) keeps the fill: {:?}", p.map(|v| (v * 255.0).round()));
|
||||
let p = px(&d, x, y).map(|v| (v * 255.0).round());
|
||||
assert!((158.0..=164.0).contains(&p[0]) && (22.0..=26.0).contains(&p[1]), "flat face ({x},{y}) near the fill: {p:?}");
|
||||
}
|
||||
let linear = render(photocraft_doc::Contour::Linear);
|
||||
assert!(close4(px(&linear, 20, 20), fill), "Linear leaves the flat face too");
|
||||
assert!(!close4(px(&d, 20, 11), fill), "the slopes are still shaded");
|
||||
}
|
||||
|
||||
/// A deep bevel under a high light with a descending gloss contour (altitude 69, 358 %, Rolling
|
||||
/// Slope - Descending, Screen white 78 %) keeps a red shape red at every depth: the slopes are
|
||||
/// shaded around the unmapped `sin(altitude)`, so only the steepest pixels facing away glint.
|
||||
/// Mapped through the contour, that neutral fell to 0.16 and the whole shape rendered white.
|
||||
#[test]
|
||||
fn a_high_light_descending_gloss_keeps_the_face_its_colour_at_every_depth() {
|
||||
let red = [0.6, 0.0, 0.0, 1.0];
|
||||
let rolling = photocraft_doc::Contour::Custom {
|
||||
name: "Rolling Slope - Descending".into(),
|
||||
points: [(0.0078, 1.0), (0.2078, 0.3922), (0.3804, 0.4196), (0.7020, 0.6), (0.9882, 0.0)]
|
||||
.iter()
|
||||
.map(|&(input, output)| CurvePoint { input, output })
|
||||
.collect(),
|
||||
corners: vec![],
|
||||
};
|
||||
let mut first: Option<Vec<[f32; 4]>> = None;
|
||||
for depth in [SampleType::U8, SampleType::U16, SampleType::F32] {
|
||||
let mut d = Document::with_background("t", Size::new(80, 80), ColorMode::Rgb, depth, Color::BLACK);
|
||||
let mut l = Layer::raster("bar", d.pixel_format());
|
||||
l.surface_mut().unwrap().fill_rect(Rect::new(20, 10, 60, 70), &red);
|
||||
l.effects.items = vec![Effect::BevelEmboss(photocraft_doc::Bevel {
|
||||
enabled: true,
|
||||
style: photocraft_doc::BevelStyle::InnerBevel,
|
||||
technique: photocraft_doc::BevelTechnique::Smooth,
|
||||
depth: 3.58,
|
||||
up: true,
|
||||
size: 16.0,
|
||||
soften: 0.0,
|
||||
angle: 180.0,
|
||||
altitude: 69.0,
|
||||
use_global_light: false,
|
||||
gloss_contour: rolling.clone(),
|
||||
gloss_anti_alias: false,
|
||||
highlight: FxCommon::new(photocraft_color::BlendMode::Screen, 0.78),
|
||||
highlight_color: Color::WHITE,
|
||||
shadow: FxCommon::new(photocraft_color::BlendMode::Multiply, 0.09),
|
||||
shadow_color: Color::BLACK,
|
||||
contour: None,
|
||||
texture: None,
|
||||
})];
|
||||
d.layers.push(l);
|
||||
// The slope facing the light, the middle, and a slope pixel facing away short of its glint.
|
||||
let got: Vec<[f32; 4]> = [(23, 40), (30, 40), (40, 40), (50, 40)].iter().map(|&(x, y)| px(&d, x, y)).collect();
|
||||
for (p, at) in got.iter().zip([23, 30, 40, 50]) {
|
||||
assert!(p[0] > 0.5 && p[1] < 0.05 && p[2] < 0.05, "{depth:?} x={at}: still red, not washed white: {p:?}");
|
||||
}
|
||||
match &first {
|
||||
None => first = Some(got),
|
||||
Some(f) => {
|
||||
for (a, b) in f.iter().zip(&got) {
|
||||
assert!(a.iter().zip(b).all(|(x, y)| (x - y).abs() <= 3.0 / 255.0), "{depth:?} agrees with 8-bit: {a:?} vs {b:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clipped_layer_effects_are_clipped_to_base() {
|
||||
let mut d = doc_white(40, 40);
|
||||
@@ -3294,7 +3353,7 @@ fn exposure_scales_32_bit_samples_as_stored() {
|
||||
let mut d = Document::new("e", Size::new(1, 1), ColorMode::Rgb, depth);
|
||||
let mut l = Layer::raster("px", fmt);
|
||||
l.surface_mut().unwrap().fill_rect(Rect::new(0, 0, 1, 1), &[0.2, 0.2, 0.2, 1.0]);
|
||||
d.layers = vec![l, Layer::new("exp", LayerContent::Adjustment(plus_one_stop.clone()))];
|
||||
d.layers = vec![l, Layer::new("exp", LayerContent::Adjustment(plus_one_stop.clone()))].into();
|
||||
let got = px(&d, 0, 0)[0];
|
||||
assert!((got - want).abs() < 2e-3, "{depth:?}: {got}");
|
||||
}
|
||||
@@ -3384,7 +3443,7 @@ fn float_adjustments_preserve_hdr_range() {
|
||||
let mut d = Document::new("HDR", Size::new(1, 1), ColorMode::Rgb, SampleType::F32);
|
||||
let mut l = Layer::raster("pixels", PixelFormat::RGBA32F);
|
||||
l.surface_mut().unwrap().fill_rect(Rect::new(0, 0, 1, 1), &[4.0, 2.0, 0.5, 0.75]);
|
||||
d.layers = vec![l, Layer::new("adjustment", LayerContent::Adjustment(adj.clone()))];
|
||||
d.layers = vec![l, Layer::new("adjustment", LayerContent::Adjustment(adj.clone()))].into();
|
||||
let got = px(&d, 0, 0);
|
||||
for (a, b) in got[..3].iter().zip(want) {
|
||||
assert!((a - b).abs() < 1e-5, "{adj:?}: {got:?} vs {want:?}");
|
||||
|
||||
@@ -8,6 +8,7 @@ use std::io::{Read, Seek, SeekFrom, Write};
|
||||
|
||||
#[test]
|
||||
fn failed_effect_build_is_not_reused_after_original_pixels_recover() {
|
||||
photocraft_raster::spill::use_test_volume_space();
|
||||
let dir = std::env::temp_dir().join(format!("photocraft-compose-scratch-retry-{}", std::process::id()));
|
||||
spill::configure(Some(&dir), 1).unwrap();
|
||||
let mut doc = Document::new("Shadow", Size::new(64, 64), ColorMode::Rgb, SampleType::U8);
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
//! The document's layer stack with a lazily built id index.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use crate::{Layer, LayerId, LayerPath};
|
||||
|
||||
/// Where a layer sits in the stack.
|
||||
#[derive(Clone, Debug)]
|
||||
struct Entry {
|
||||
path: LayerPath,
|
||||
parent: Option<LayerId>,
|
||||
}
|
||||
|
||||
/// Id to position for every layer, nested ones included.
|
||||
#[derive(Debug, Default)]
|
||||
pub struct LayerIndex {
|
||||
entries: HashMap<LayerId, Entry>,
|
||||
serial: u64,
|
||||
}
|
||||
|
||||
static SERIAL: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1);
|
||||
|
||||
impl LayerIndex {
|
||||
fn build(layers: &[Layer]) -> Self {
|
||||
fn rec(layers: &[Layer], parent: Option<LayerId>, path: &mut LayerPath, out: &mut HashMap<LayerId, Entry>) {
|
||||
for (i, l) in layers.iter().enumerate() {
|
||||
path.push(i);
|
||||
out.entry(l.id).or_insert_with(|| Entry { path: path.clone(), parent });
|
||||
if let Some(ch) = l.children() {
|
||||
rec(ch, Some(l.id), path, out);
|
||||
}
|
||||
path.pop();
|
||||
}
|
||||
}
|
||||
let mut entries = HashMap::with_capacity(layers.len());
|
||||
rec(layers, None, &mut Vec::new(), &mut entries);
|
||||
Self { entries, serial: SERIAL.fetch_add(1, std::sync::atomic::Ordering::Relaxed) }
|
||||
}
|
||||
|
||||
/// The layer's path from the root. Paths order layers bottom-to-top as the depth-first walk does.
|
||||
pub fn path(&self, id: LayerId) -> Option<&[usize]> {
|
||||
self.entries.get(&id).map(|e| e.path.as_slice())
|
||||
}
|
||||
|
||||
/// The group holding the layer; `None` at the root or for an unknown id.
|
||||
pub fn parent(&self, id: LayerId) -> Option<LayerId> {
|
||||
self.entries.get(&id)?.parent
|
||||
}
|
||||
|
||||
/// Nesting depth: 0 at the root.
|
||||
pub fn depth(&self, id: LayerId) -> Option<usize> {
|
||||
self.entries.get(&id).map(|e| e.path.len() - 1)
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
self.entries.len()
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.entries.is_empty()
|
||||
}
|
||||
|
||||
/// A number unique to this build: it differs between two builds, so equal serials mean the
|
||||
/// same index (tests count rebuilds with it).
|
||||
pub fn serial(&self) -> u64 {
|
||||
self.serial
|
||||
}
|
||||
}
|
||||
|
||||
/// The layer stack, bottom-to-top, with an index from layer id to position built on the first
|
||||
/// lookup.
|
||||
///
|
||||
/// The stack is a public vector that code edits in place, nested groups included, so no mutator
|
||||
/// method can be the place that drops the index. Every route to a `&mut Layer` or `&mut Vec`
|
||||
/// goes through `DerefMut`, so the reset lives there: any write drops the index, and the next
|
||||
/// lookup rebuilds it once. `Clone` starts without an index.
|
||||
#[derive(Default)]
|
||||
pub struct LayerTree {
|
||||
layers: Vec<Layer>,
|
||||
index: OnceLock<LayerIndex>,
|
||||
}
|
||||
|
||||
impl LayerTree {
|
||||
/// The id index, built on first use after the last write.
|
||||
pub fn index(&self) -> &LayerIndex {
|
||||
self.index.get_or_init(|| LayerIndex::build(&self.layers))
|
||||
}
|
||||
}
|
||||
|
||||
/// `Vec` methods that callers pass `&document` into (`doc.layers.push(make(&doc))`): as methods
|
||||
/// on the tree the receiver borrow is two-phase, which it is not through `DerefMut`.
|
||||
impl LayerTree {
|
||||
pub fn push(&mut self, layer: Layer) {
|
||||
self.deref_mut().push(layer);
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, at: usize, layer: Layer) {
|
||||
self.deref_mut().insert(at, layer);
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for LayerTree {
|
||||
type Target = Vec<Layer>;
|
||||
fn deref(&self) -> &Vec<Layer> {
|
||||
&self.layers
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for LayerTree {
|
||||
fn deref_mut(&mut self) -> &mut Vec<Layer> {
|
||||
self.index = OnceLock::new();
|
||||
&mut self.layers
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for LayerTree {
|
||||
fn clone(&self) -> Self {
|
||||
Self { layers: self.layers.clone(), index: OnceLock::new() }
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for LayerTree {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.layers == other.layers
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for LayerTree {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.layers.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<Layer>> for LayerTree {
|
||||
fn from(layers: Vec<Layer>) -> Self {
|
||||
Self { layers, index: OnceLock::new() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoIterator for &'a LayerTree {
|
||||
type Item = &'a Layer;
|
||||
type IntoIter = std::slice::Iter<'a, Layer>;
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.layers.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoIterator for &'a mut LayerTree {
|
||||
type Item = &'a mut Layer;
|
||||
type IntoIter = std::slice::IterMut<'a, Layer>;
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.deref_mut().iter_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl FromIterator<Layer> for LayerTree {
|
||||
fn from_iter<I: IntoIterator<Item = Layer>>(iter: I) -> Self {
|
||||
iter.into_iter().collect::<Vec<_>>().into()
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoIterator for LayerTree {
|
||||
type Item = Layer;
|
||||
type IntoIter = std::vec::IntoIter<Layer>;
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.layers.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::PixelFormat;
|
||||
|
||||
fn layers(n: usize) -> LayerTree {
|
||||
(0..n).map(|i| Layer::raster(format!("l{i}"), PixelFormat::RGBA8)).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn index_builds_once_per_edit() {
|
||||
let mut t = layers(200);
|
||||
let id = t[150].id;
|
||||
let first = t.index().serial();
|
||||
for _ in 0..100 {
|
||||
assert_eq!(t.index().path(id), Some(&[150][..]));
|
||||
}
|
||||
assert_eq!(t.index().serial(), first, "lookups reuse the index");
|
||||
t.push(Layer::raster("new", PixelFormat::RGBA8));
|
||||
let second = t.index().serial();
|
||||
assert_ne!(second, first, "an edit rebuilds it");
|
||||
assert_eq!(t.index().serial(), second);
|
||||
let _ = &mut t[3];
|
||||
assert_ne!(t.index().serial(), second, "any mutable access drops it");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clone_after_edit_does_not_reuse_the_index() {
|
||||
let mut t = layers(5);
|
||||
let old = t.index().serial();
|
||||
let new_id = {
|
||||
t.insert(0, Layer::raster("below", PixelFormat::RGBA8));
|
||||
t[0].id
|
||||
};
|
||||
let c = t.clone();
|
||||
assert_ne!(c.index().serial(), old);
|
||||
assert_eq!(c.index().path(new_id), Some(&[0][..]));
|
||||
assert_eq!(t.index().path(new_id), Some(&[0][..]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nested_edits_reset_and_paths_follow_walk_order() {
|
||||
let inner = Layer::raster("in", PixelFormat::RGBA8);
|
||||
let inner_id = inner.id;
|
||||
let group = Layer::group("g", vec![inner]);
|
||||
let group_id = group.id;
|
||||
let mut t: LayerTree = vec![Layer::raster("a", PixelFormat::RGBA8), group].into();
|
||||
assert_eq!(t.index().path(inner_id), Some(&[1, 0][..]));
|
||||
assert_eq!(t.index().parent(inner_id), Some(group_id));
|
||||
assert_eq!(t.index().depth(inner_id), Some(1));
|
||||
let before = t.index().serial();
|
||||
t[1].children_mut().unwrap().insert(0, Layer::raster("x", PixelFormat::RGBA8));
|
||||
assert_eq!(t.index().path(inner_id), Some(&[1, 1][..]));
|
||||
assert_ne!(t.index().serial(), before);
|
||||
}
|
||||
}
|
||||
+31
-18
@@ -16,6 +16,7 @@ pub mod comps;
|
||||
pub mod effects;
|
||||
pub mod frame;
|
||||
pub mod import_conversion;
|
||||
pub mod layer_tree;
|
||||
pub mod mode;
|
||||
pub mod pattern;
|
||||
pub mod slices;
|
||||
@@ -901,7 +902,7 @@ pub struct Document {
|
||||
pub depth: SampleType,
|
||||
pub icc_profile: Option<Arc<Vec<u8>>>,
|
||||
/// Bottom-to-top.
|
||||
pub layers: Vec<Layer>,
|
||||
pub layers: layer_tree::LayerTree,
|
||||
pub channels: Vec<AlphaChannel>,
|
||||
pub guides: Guides,
|
||||
/// The rulers' zero point in document pixels (`[x, y]`), dragged from the ruler corner. The
|
||||
@@ -1004,7 +1005,7 @@ impl Document {
|
||||
mode,
|
||||
depth,
|
||||
icc_profile: None,
|
||||
layers: Vec::new(),
|
||||
layers: Default::default(),
|
||||
channels: Vec::new(),
|
||||
guides: Guides::default(),
|
||||
ruler_origin: [0.0, 0.0],
|
||||
@@ -1161,18 +1162,7 @@ impl Document {
|
||||
}
|
||||
|
||||
pub fn path_of(&self, id: LayerId) -> Option<LayerPath> {
|
||||
fn rec(layers: &[Layer], id: LayerId, path: &mut LayerPath) -> bool {
|
||||
for (i, l) in layers.iter().enumerate() {
|
||||
path.push(i);
|
||||
if l.id == id || l.children().is_some_and(|ch| rec(ch, id, path)) {
|
||||
return true;
|
||||
}
|
||||
path.pop();
|
||||
}
|
||||
false
|
||||
}
|
||||
let mut path = Vec::new();
|
||||
rec(&self.layers, id, &mut path).then_some(path)
|
||||
self.layers.index().path(id).map(<[usize]>::to_vec)
|
||||
}
|
||||
|
||||
/// The locks in force on the layer at `path`: its own and those of every group around it,
|
||||
@@ -1211,10 +1201,7 @@ impl Document {
|
||||
}
|
||||
|
||||
pub fn layer(&self, id: LayerId) -> Option<&Layer> {
|
||||
fn rec(layers: &[Layer], id: LayerId) -> Option<&Layer> {
|
||||
layers.iter().find_map(|l| if l.id == id { Some(l) } else { l.children().and_then(|ch| rec(ch, id)) })
|
||||
}
|
||||
rec(&self.layers, id)
|
||||
self.layer_at(self.layers.index().path(id)?)
|
||||
}
|
||||
|
||||
pub fn layer_mut(&mut self, id: LayerId) -> Option<&mut Layer> {
|
||||
@@ -1394,6 +1381,32 @@ mod tests {
|
||||
assert_eq!(d.unused_link_group(), Some(3));
|
||||
}
|
||||
|
||||
/// Id lookups share one index per document state: 100 lookups on 200 layers build it once,
|
||||
/// an edit builds it once more, and a clone built after the edit has its own.
|
||||
#[test]
|
||||
fn layer_lookups_share_one_index_per_state() {
|
||||
let mut d = doc();
|
||||
for i in 0..199 {
|
||||
d.layers.push(Layer::raster(format!("l{i}"), PixelFormat::RGBA8));
|
||||
}
|
||||
let ids: Vec<LayerId> = d.layers.iter().map(|l| l.id).collect();
|
||||
let first = d.layers.index().serial();
|
||||
for i in 0..100 {
|
||||
let id = ids[i * 2];
|
||||
assert_eq!(d.layer(id).unwrap().id, id);
|
||||
assert_eq!(d.path_of(id), Some(vec![i * 2]));
|
||||
}
|
||||
assert_eq!(d.layers.index().serial(), first);
|
||||
assert!(d.shift(ids[10], 1));
|
||||
assert_eq!(d.path_of(ids[10]), Some(vec![11]));
|
||||
let second = d.layers.index().serial();
|
||||
assert_ne!(second, first);
|
||||
d.layer_mut(ids[3]).unwrap().name = "x".into();
|
||||
let copy = d.clone();
|
||||
assert_ne!(copy.layers.index().serial(), d.layers.index().serial());
|
||||
assert_eq!(copy.layer(ids[3]).unwrap().name, "x");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_document_has_locked_background() {
|
||||
let d = doc();
|
||||
|
||||
@@ -16,7 +16,7 @@ photocraft-geom = { workspace = true }
|
||||
photocraft-color = { workspace = true }
|
||||
craft-cms = { workspace = true }
|
||||
# PCTIP codec from craft-libs#1564; isolated pin until the shared revision is adopted workspace-wide.
|
||||
craft-pcraft-tip = { package = "craft-pcraft-format", git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
|
||||
craft-pcraft-tip = { package = "craft-pcraft-format", git = "https://github.com/storytold/craft-libs", rev = "04ba41419b99967e4d2b990cdfe5d80184be64ee" }
|
||||
photocraft-raster = { workspace = true }
|
||||
photocraft-doc = { workspace = true }
|
||||
photocraft-ops = { workspace = true }
|
||||
|
||||
@@ -52,7 +52,7 @@ fn library_tip_bytes(s: &Session) -> (usize, u64, u64) {
|
||||
previews += g.data.len() as u64 * 2;
|
||||
}
|
||||
};
|
||||
for p in &s.tools.presets {
|
||||
for p in s.tools.presets.iter() {
|
||||
let b = &p.brush;
|
||||
for t in [&b.tip, &b.dual_brush.tip] {
|
||||
match t {
|
||||
|
||||
+146
-1223
File diff suppressed because it is too large.
Load diff
@@ -403,7 +403,7 @@ pub(crate) fn adjust_as_filter(kind: &str, p: &Value, surf: &Surface, histogram_
|
||||
})?;
|
||||
} else if kind == "desaturate" {
|
||||
let mode = surf.format().mode;
|
||||
if crate::pixels::adjust_surface(&mut out, &crate::commands::desaturate_adjustment(), None, mode).is_err() {
|
||||
if crate::pixels::adjust_surface(&mut out, &super::table::image::image_menu::desaturate_adjustment(), None, mode).is_err() {
|
||||
return Ok(None);
|
||||
}
|
||||
} else if kind == "equalize" {
|
||||
@@ -652,7 +652,7 @@ fn hdr_toning(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
bg.locks.position = true;
|
||||
crate::pixels_mut(&mut bg)?.write_region(doc.bounds(), &data);
|
||||
*active = Some(bg.id);
|
||||
doc.layers = vec![bg];
|
||||
doc.layers = vec![bg].into();
|
||||
doc.selection = None;
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
@@ -24,7 +24,7 @@ pub(super) fn new_adjustment(s: &mut Session, adj: Adjustment, p: &Value, cmd: &
|
||||
None | Some(Value::Null) => BlendMode::Normal,
|
||||
Some(v) => {
|
||||
let m = v.as_str().ok_or_else(|| bad("`mode` must be a blend mode name".into()))?;
|
||||
crate::commands::blend_from_str(m).filter(|b| *b != BlendMode::PassThrough).ok_or_else(|| bad(format!("unknown layer blend mode `{m}`")))?
|
||||
crate::commands::parse_blend(m).filter(|b| *b != BlendMode::PassThrough).ok_or_else(|| bad(format!("unknown layer blend mode `{m}`")))?
|
||||
}
|
||||
};
|
||||
let clip = match p.get("clipToPrevious") {
|
||||
|
||||
@@ -643,7 +643,7 @@ pub fn artboard_document(doc: &Document, id: LayerId) -> Result<Option<Document>
|
||||
let mut one = doc.clone();
|
||||
one.name = l.name.clone();
|
||||
one.size = Size::new(r.width(), r.height());
|
||||
one.layers = vec![group];
|
||||
one.layers = vec![group].into();
|
||||
one.channels.clear();
|
||||
one.selection = None;
|
||||
one.quick_mask = None;
|
||||
@@ -659,10 +659,126 @@ pub fn artboard_document(doc: &Document, id: LayerId) -> Result<Option<Document>
|
||||
Ok(Some(one))
|
||||
}
|
||||
|
||||
/// Include Overlapping Areas: each visible artboard stacked above board `id` that overlaps it, as
|
||||
/// the reference application writes it into the board's file: a plain group (no longer an
|
||||
/// artboard) holding its layers over a new pixel layer "Background for <board>" filled with the
|
||||
/// board's background where the two boards overlap, in source coordinates and bottom to top. A
|
||||
/// group whose layers reach past its own board (effects, pixels outside the board, adjustments)
|
||||
/// gets a hard mask to its board, which the artboard clipped them to.
|
||||
///
|
||||
/// The artboard painted its background beneath the group and then composited the group (its
|
||||
/// blend mode, opacity, effects and masks) over it. A board with any of those keeps them on a
|
||||
/// group of its own inside the plain group, above the background, so they still apply to its
|
||||
/// layers only and its own mask keeps its feather and Layer Mask Hides Effects setting; the plain
|
||||
/// group then carries nothing but the board clip.
|
||||
fn overlapping_boards(doc: &Document, id: LayerId, rect: Rect) -> Vec<Layer> {
|
||||
let above = doc.layers.iter().skip_while(|l| l.id != id).skip(1);
|
||||
let mut out = Vec::new();
|
||||
for l in above.filter(|l| l.visible) {
|
||||
let Some(ab) = l.artboard().cloned() else { continue };
|
||||
let overlap = ab.rect.intersect(&rect);
|
||||
if overlap.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let mut board = l.clone();
|
||||
if let LayerContent::Group(g) = &mut board.content {
|
||||
g.artboard = None;
|
||||
cut_pixels(&mut g.children, overlap, 0);
|
||||
}
|
||||
let bg = ab.background.rgba();
|
||||
let mut group = if stacks_like_its_layers(&board) {
|
||||
board
|
||||
} else {
|
||||
board.clipped = false;
|
||||
let mut plain = Layer::group(l.name.clone(), vec![board]);
|
||||
plain.label = l.label;
|
||||
plain
|
||||
};
|
||||
if let (Some(bg), Some(children)) = (bg, group.children_mut()) {
|
||||
let fmt = doc.pixel_format();
|
||||
let mut surf = Surface::new(fmt);
|
||||
surf.fill_rect(overlap, &photocraft_raster::from_rgba(&fmt, bg));
|
||||
children.insert(0, Layer::new(format!("Background for {}", l.name), LayerContent::Raster(surf)));
|
||||
}
|
||||
// With the background in place: its pixels widen what the group's layers can reach.
|
||||
let reach = photocraft_compose::change_bounds(&group, doc.bounds());
|
||||
if reach.is_none_or(|r| !ab.rect.contains_rect(&r)) {
|
||||
let mut mask = photocraft_doc::LayerMask::reveal_all();
|
||||
mask.surface = Surface::with_default(PixelFormat::GRAY8, &[0.0]);
|
||||
mask.surface.fill_rect(ab.rect, &[1.0]);
|
||||
group.mask = Some(mask);
|
||||
}
|
||||
out.push(group);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Whether artboard `board` (already a plain group) composites over its background exactly as
|
||||
/// its layers stacked over that background in one pass-through group do: pass-through (a Normal
|
||||
/// group renders its layers on their own first, so a Multiply or Screen layer in it never blends
|
||||
/// with the background), and no effects, masks, opacity, Blend If or other blending options of
|
||||
/// its own, nor a mask the board clip would replace.
|
||||
fn stacks_like_its_layers(board: &Layer) -> bool {
|
||||
board.blend == photocraft_color::BlendMode::PassThrough
|
||||
&& board.opacity >= 1.0
|
||||
&& board.fill_opacity >= 1.0
|
||||
&& board.mask.is_none()
|
||||
&& board.vector_mask.is_none()
|
||||
&& board.frame.is_none()
|
||||
&& board.excluded_channels == 0
|
||||
&& board.blend_if == photocraft_doc::BlendIf::default()
|
||||
&& board.advanced == photocraft_doc::AdvancedBlending::default()
|
||||
&& !photocraft_compose::effects::has_effects(board)
|
||||
}
|
||||
|
||||
/// Cuts the pixel layers in `layers` (and in groups inside them, `depth` levels down so far) to
|
||||
/// `keep`, as the reference application cuts an overlapping board's layers to the file. Layers
|
||||
/// whose pixels can't be cut stay whole; the group's mask still hides what lies past its board.
|
||||
/// A layer with effects, or inside a group with effects, stays whole too: pixels outside `keep`
|
||||
/// can cast a shadow or glow into it.
|
||||
fn cut_pixels(layers: &mut [Layer], keep: Rect, depth: usize) {
|
||||
const MAX_DEPTH: usize = 64;
|
||||
for l in layers {
|
||||
if photocraft_compose::effects::has_effects(l) {
|
||||
continue;
|
||||
}
|
||||
match &mut l.content {
|
||||
LayerContent::Group(g) if depth < MAX_DEPTH => cut_pixels(&mut g.children, keep, depth + 1),
|
||||
LayerContent::Raster(surf) => {
|
||||
let r = surf.content_bounds().intersect(&keep);
|
||||
let mut cut = Surface::with_default(surf.format(), &surf.default_pixel());
|
||||
if !r.is_empty() {
|
||||
let Ok(px) = surf.try_read_region(r) else { continue };
|
||||
if cut.try_write_region(r, &px).is_err() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
*surf = cut;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// [`artboard_document`] for each chosen board, all built before any file is written so a
|
||||
/// board that can't be exported fails the export without leaving a partial set behind.
|
||||
fn chosen_documents(doc: &Document, p: &Value) -> Result<Vec<Document>> {
|
||||
chosen_artboards(doc, p).into_iter().filter_map(|id| artboard_document(doc, id).transpose()).collect()
|
||||
/// board that can't be exported fails the export without leaving a partial set behind. With
|
||||
/// `overlapping`, each file also holds the boards above that overlap it ([`overlapping_boards`]).
|
||||
fn chosen_documents(doc: &Document, p: &Value, overlapping: bool) -> Result<Vec<Document>> {
|
||||
let mut out = Vec::new();
|
||||
for id in chosen_artboards(doc, p) {
|
||||
let Some(mut one) = artboard_document(doc, id)? else { continue };
|
||||
if overlapping && let Some(r) = doc.layer(id).and_then(|l| l.artboard()).map(|a| a.rect) {
|
||||
// `artboard_document` has checked that the board's origin negates.
|
||||
let (dx, dy) = (r.x0.saturating_neg(), r.y0.saturating_neg());
|
||||
for mut group in overlapping_boards(doc, id, r) {
|
||||
crate::commands::translate_layer(doc, &mut group, dx, dy);
|
||||
crate::vector_cmds::translate_vectors(doc, &mut group, f64::from(dx), f64::from(dy));
|
||||
one.layers.push(group);
|
||||
}
|
||||
}
|
||||
out.push(one);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// The artboards an export covers: `"artboards": [ids]`, else all, top of the Layers panel first.
|
||||
@@ -735,8 +851,16 @@ fn artboards_to_files(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let save = SaveOpts::from_params(s, p, cmd)?;
|
||||
let d = s.active().ok_or(EngineError::NoDocument)?;
|
||||
let prefix = p.get("prefix").and_then(Value::as_str).map(str::to_string).unwrap_or_else(|| stem(&d.doc.name));
|
||||
let overlapping = match p.get("content") {
|
||||
None | Some(Value::Null) => true,
|
||||
Some(v) => match v.as_str() {
|
||||
Some("overlapping") => true,
|
||||
Some("artboard") => false,
|
||||
_ => return Err(bad(cmd, format!("`content` must be \"overlapping\" or \"artboard\", not {v}"))),
|
||||
},
|
||||
};
|
||||
let doc = d.doc.clone();
|
||||
let boards = chosen_documents(&doc, p)?;
|
||||
let boards = chosen_documents(&doc, p, overlapping)?;
|
||||
let names: Vec<&str> = boards.iter().map(|one| one.name.as_str()).collect();
|
||||
let mut files = Vec::new();
|
||||
for (one, name) in boards.iter().zip(artboard_file_stems(&prefix, &names, HYPHENATED_FORMATS.contains(&format.as_str()))) {
|
||||
@@ -806,7 +930,7 @@ fn artboards_to_pdf(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let mut pages = Vec::new();
|
||||
// Pages go bottom artboard of the Layers panel first, as in the reference application (#13643);
|
||||
// `chosen_documents` lists them top first, the order Artboards to Files keeps.
|
||||
for one in chosen_documents(&doc, p)?.into_iter().rev() {
|
||||
for one in chosen_documents(&doc, p, false)?.into_iter().rev() {
|
||||
let buf = photocraft_compose::flatten(&one).over_background([1.0, 1.0, 1.0]);
|
||||
let fmt = PixelFormat::new(ColorMode::Rgb, SampleType::U8, true);
|
||||
let mut flat = Document::new(&one.name, one.size, ColorMode::Rgb, SampleType::U8);
|
||||
@@ -883,7 +1007,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"file.export.artboardsToFiles",
|
||||
"Artboards to Files…",
|
||||
&["File", "Export"],
|
||||
r##"{"dir":folder,"format":"png|jpg|psd|tiff|…"="png","prefix":str=document name ("" = none),"artboards":[id]? (default all),"quality":0..12?} → {files} (one "<prefix><artboard name>.<format>" per board, no separator or index added: spaces become "-" in PNG, JPEG, BMP, Targa and TIFF and stay in PSD and other formats, characters a file name can't hold become "_", and a name an earlier board already took, ignoring case, gets "-2", "-3"…)"##,
|
||||
r##"{"dir":folder,"format":"png|jpg|psd|tiff|…"="png","prefix":str=document name ("" = none),"content":"overlapping|artboard"="overlapping" (Include Overlapping Areas: a board's file also shows the visible boards above it where they overlap it, each as a plain group with a \"Background for <board>\" layer; artboard: Artboard Content Only),"artboards":[id]? (default all),"quality":0..12?} → {files} (one "<prefix><artboard name>.<format>" per board, no separator or index added: spaces become "-" in PNG, JPEG, BMP, Targa and TIFF and stay in PSD and other formats, characters a file name can't hold become "_", and a name an earlier board already took, ignoring case, gets "-2", "-3"…)"##,
|
||||
export_artboards,
|
||||
artboards_to_files
|
||||
),
|
||||
@@ -905,6 +1029,9 @@ mod file_names_tests;
|
||||
#[path = "artboard_cmds/first_board_background_tests.rs"]
|
||||
mod first_board_background_tests;
|
||||
#[cfg(test)]
|
||||
#[path = "artboard_cmds/overlapping_areas_tests.rs"]
|
||||
mod overlapping_areas_tests;
|
||||
#[cfg(test)]
|
||||
#[path = "artboard_cmds/pdf_page_order_tests.rs"]
|
||||
mod pdf_page_order_tests;
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -0,0 +1,340 @@
|
||||
//! Artboards to Files › Include Overlapping Areas / Artboard Content Only (#13629): the boards
|
||||
//! stacked above an exported board that overlap it show in its file (PNG pixels, PSD structure),
|
||||
//! boards below never do, and the source document is left alone.
|
||||
|
||||
use super::*;
|
||||
use photocraft_geom::Rect;
|
||||
|
||||
const RED: [u8; 3] = [220, 30, 30];
|
||||
const BLUE: [u8; 3] = [30, 30, 220];
|
||||
const WHITE: [u8; 3] = [255, 255, 255];
|
||||
|
||||
/// The measured test document: 800 x 400, transparent, bottom to top `Red Board` 0,0-200,150
|
||||
/// (pixel layer `Red` at 20,20-120,100), `Blue Board` 120,30-320,230 (pixel layer `Blue` at
|
||||
/// 130,40-230,140) and `Empty Board` 600,0-700,100, all with white backgrounds.
|
||||
fn session(depth: u32) -> (Session, [u64; 3]) {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 800, "height": 400, "depth": depth, "background": "transparent"})).unwrap();
|
||||
let board =
|
||||
|s: &mut Session, name: &str, rect: [i64; 4]| s.execute("layer.new.artboard", json!({"rect": rect, "name": name})).unwrap()["layer"].as_u64().unwrap();
|
||||
let red = board(&mut s, "Red Board", [0, 0, 200, 150]);
|
||||
let blue = board(&mut s, "Blue Board", [120, 30, 200, 200]);
|
||||
let empty = board(&mut s, "Empty Board", [600, 0, 100, 100]);
|
||||
paint(&mut s, red, "Red", Rect::new(20, 20, 120, 100), RED);
|
||||
paint(&mut s, blue, "Blue", Rect::new(130, 40, 230, 140), BLUE);
|
||||
(s, [red, blue, empty])
|
||||
}
|
||||
|
||||
/// A pixel layer `name` of `color` over `rect`, on top of board `board`'s layers.
|
||||
fn paint(s: &mut Session, board: u64, name: &str, rect: Rect, color: [u8; 3]) {
|
||||
s.edit(name, |doc, _| {
|
||||
let fmt = doc.pixel_format();
|
||||
let mut l = Layer::raster(name, fmt);
|
||||
let [r, g, b] = color.map(|c| f32::from(c) / 255.0);
|
||||
l.surface_mut().unwrap().fill_rect(rect, &photocraft_raster::from_rgba(&fmt, [r, g, b, 1.0]));
|
||||
doc.layer_mut(LayerId(board)).unwrap().children_mut().unwrap().push(l);
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
struct Out(std::path::PathBuf);
|
||||
|
||||
impl Out {
|
||||
fn new(tag: &str) -> Self {
|
||||
let dir = std::env::temp_dir().join(format!("photocraft-overlap-{tag}-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
Out(dir)
|
||||
}
|
||||
fn dir(&self) -> String {
|
||||
self.0.to_string_lossy().into_owned()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Out {
|
||||
fn drop(&mut self) {
|
||||
let _ = std::fs::remove_dir_all(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
/// Exports board `board` with `extra` params and reads the one file back.
|
||||
fn export(s: &mut Session, out: &Out, board: u64, extra: Value) -> Document {
|
||||
let mut p = json!({"dir": out.dir(), "prefix": "", "artboards": [board]});
|
||||
for (k, v) in extra.as_object().unwrap() {
|
||||
p[k] = v.clone();
|
||||
}
|
||||
let format = p.get("format").and_then(Value::as_str).unwrap_or("png").to_string();
|
||||
let r = s.execute("file.export.artboardsToFiles", p).unwrap();
|
||||
let files = r["files"].as_array().unwrap();
|
||||
assert_eq!(files.len(), 1, "{r}");
|
||||
let path = files[0].as_str().unwrap();
|
||||
photocraft_io::import(&format!("x.{format}"), &std::fs::read(path).unwrap()).unwrap().document
|
||||
}
|
||||
|
||||
/// The file's composite pixel at (x, y) as 8-bit RGBA.
|
||||
fn px(d: &Document, x: i32, y: i32) -> [u8; 4] {
|
||||
let flat = photocraft_compose::flatten(d);
|
||||
let w = d.size.width as usize;
|
||||
flat.px[y as usize * w + x as usize].map(|v| (v.clamp(0.0, 1.0) * 255.0).round() as u8)
|
||||
}
|
||||
|
||||
fn rgb(p: [u8; 4]) -> [u8; 3] {
|
||||
[p[0], p[1], p[2]]
|
||||
}
|
||||
|
||||
fn names(layers: &[Layer]) -> Vec<&str> {
|
||||
layers.iter().map(|l| l.name.as_str()).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn include_overlapping_areas_is_the_default_and_shows_the_board_above() {
|
||||
for depth in [8, 16] {
|
||||
let (mut s, [red, _, _]) = session(depth);
|
||||
let out = Out::new(&format!("default-{depth}"));
|
||||
for extra in [json!({}), json!({"content": "overlapping"})] {
|
||||
let f = export(&mut s, &out, red, extra.clone());
|
||||
assert_eq!((f.size.width, f.size.height), (200, 150), "{depth} bit {extra}");
|
||||
assert_eq!(rgb(px(&f, 150, 60)), BLUE, "{depth} bit {extra}: Blue's pixels");
|
||||
assert_eq!(rgb(px(&f, 125, 35)), WHITE, "{depth} bit {extra}: Blue Board's background");
|
||||
assert_eq!(rgb(px(&f, 125, 50)), WHITE, "{depth} bit {extra}: Blue Board's background");
|
||||
assert_eq!(rgb(px(&f, 110, 50)), RED, "{depth} bit {extra}: Red stays red");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn artboard_content_only_keeps_the_board_on_its_own() {
|
||||
let (mut s, [red, _, _]) = session(8);
|
||||
let out = Out::new("content-only");
|
||||
let f = export(&mut s, &out, red, json!({"content": "artboard"}));
|
||||
assert_eq!(rgb(px(&f, 150, 60)), WHITE, "nothing of Blue Board");
|
||||
assert_eq!(rgb(px(&f, 110, 50)), RED);
|
||||
let psd = export(&mut s, &out, red, json!({"content": "artboard", "format": "psd"}));
|
||||
assert_eq!(names(&psd.layers), ["Red Board"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_overlapping_psd_holds_the_board_above_as_a_plain_group_with_its_background() {
|
||||
let (mut s, [red, _, _]) = session(8);
|
||||
let out = Out::new("psd");
|
||||
let psd = export(&mut s, &out, red, json!({"format": "psd"}));
|
||||
assert_eq!((psd.size.width, psd.size.height), (200, 150));
|
||||
// Bottom to top: the exported artboard, then the overlapping board as a plain group.
|
||||
assert_eq!(names(&psd.layers), ["Red Board", "Blue Board"]);
|
||||
let [board, group] = [&psd.layers[0], &psd.layers[1]];
|
||||
assert_eq!(board.artboard().map(|a| a.rect), Some(Rect::new(0, 0, 200, 150)));
|
||||
assert_eq!(names(board.children().unwrap()), ["Red"]);
|
||||
assert!(matches!(&group.content, LayerContent::Group(g) if g.artboard.is_none()), "no longer an artboard");
|
||||
let kids = group.children().unwrap();
|
||||
assert_eq!(names(kids), ["Background for Blue Board", "Blue"]);
|
||||
// Blue (130,40-230,140 in the source) is cut to the file: 130,40-200,140.
|
||||
let blue = photocraft_compose::bounds::content_bounds(kids[1].surface().unwrap());
|
||||
assert_eq!(blue, Rect::new(130, 40, 200, 140));
|
||||
// The background covers where the boards overlap: 120..200 x 30..150.
|
||||
let bg = photocraft_compose::bounds::content_bounds(kids[0].surface().unwrap());
|
||||
assert_eq!(bg, Rect::new(120, 30, 200, 150));
|
||||
assert_eq!(rgb(px(&psd, 150, 60)), BLUE);
|
||||
assert_eq!(rgb(px(&psd, 125, 35)), WHITE);
|
||||
assert_eq!(rgb(px(&psd, 110, 50)), RED);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn boards_below_do_not_show_in_either_mode() {
|
||||
let (mut s, [_, blue, _]) = session(8);
|
||||
// A transparent Blue Board shows whatever leaks in from Red Board's white background below.
|
||||
s.execute("layer.artboard.set", json!({"layer": blue, "background": "transparent"})).unwrap();
|
||||
let out = Out::new("below");
|
||||
for content in ["overlapping", "artboard"] {
|
||||
let f = export(&mut s, &out, blue, json!({"content": content}));
|
||||
assert_eq!((f.size.width, f.size.height), (200, 200), "{content}");
|
||||
// Source (125,35): Red Board's background, outside Blue's pixels.
|
||||
assert_eq!(px(&f, 5, 5)[3], 0, "{content}: nothing of Red Board");
|
||||
assert_eq!(rgb(px(&f, 30, 30)), BLUE, "{content}");
|
||||
let psd = export(&mut s, &out, blue, json!({"content": content, "format": "psd"}));
|
||||
assert_eq!(names(&psd.layers), ["Blue Board"], "{content}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_source_document_is_unchanged_and_gets_no_history_entry() {
|
||||
let (mut s, [red, blue, _]) = session(8);
|
||||
let out = Out::new("source");
|
||||
for content in ["overlapping", "artboard"] {
|
||||
for board in [red, blue] {
|
||||
let d = s.active().unwrap();
|
||||
let (before, rev, past) = (d.doc.clone(), d.revision, d.history.past_len());
|
||||
export(&mut s, &out, board, json!({"content": content, "format": "psd"}));
|
||||
let d = s.active().unwrap();
|
||||
assert!(d.doc == before, "{content} changed the document");
|
||||
assert_eq!((d.revision, d.history.past_len()), (rev, past), "{content}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The artboard clipped its layers to the board; as a plain group in the file they still stop
|
||||
/// at the board's edge, so Blue pixels outside Blue Board never cover Red Board.
|
||||
#[test]
|
||||
fn the_layers_of_the_board_above_stay_inside_their_board() {
|
||||
let (mut s, [red, blue, _]) = session(8);
|
||||
paint(&mut s, blue, "Spill", Rect::new(100, 45, 125, 55), BLUE);
|
||||
let out = Out::new("spill");
|
||||
for format in ["png", "psd"] {
|
||||
let f = export(&mut s, &out, red, json!({"format": format}));
|
||||
assert_eq!(rgb(px(&f, 110, 50)), RED, "{format}: outside Blue Board");
|
||||
assert_eq!(rgb(px(&f, 122, 50)), BLUE, "{format}: inside Blue Board");
|
||||
assert_eq!(rgb(px(&f, 150, 60)), BLUE, "{format}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A layer that covers the whole canvas (a solid colour fill) in the board above is clipped to
|
||||
/// that board by a mask on the group, so it can't paint over the rest of the exported board.
|
||||
#[test]
|
||||
fn a_fill_layer_in_the_board_above_stays_inside_its_board() {
|
||||
let (mut s, [red, blue, _]) = session(8);
|
||||
s.edit("Fill", |doc, _| {
|
||||
let fill = Layer::new("Green", LayerContent::Fill(photocraft_doc::Fill::Solid(Color::rgb(0.0, 1.0, 0.0))));
|
||||
doc.layer_mut(LayerId(blue)).unwrap().children_mut().unwrap().push(fill);
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let out = Out::new("fill");
|
||||
for format in ["png", "psd"] {
|
||||
let f = export(&mut s, &out, red, json!({"format": format}));
|
||||
assert_eq!(rgb(px(&f, 110, 50)), RED, "{format}: outside Blue Board");
|
||||
assert_eq!(rgb(px(&f, 10, 140)), WHITE, "{format}: outside Blue Board");
|
||||
assert_eq!(rgb(px(&f, 150, 60)), [0, 255, 0], "{format}: inside Blue Board");
|
||||
}
|
||||
}
|
||||
|
||||
/// A layer of the board above that lies outside the exported board still casts its drop shadow
|
||||
/// into it, as it does in the document: its pixels are not cut away before the effect is built.
|
||||
#[test]
|
||||
fn a_shadow_cast_into_the_exported_board_from_outside_it_still_shows() {
|
||||
use photocraft_doc::effects::{Contour, FxCommon, Shadow};
|
||||
let (mut s, [red, blue, _]) = session(8);
|
||||
// Caster at 210..240 x 160..180 (in Blue Board, outside Red Board); its shadow, 40 px up and
|
||||
// to the left, falls on 170..200 x 120..140, inside Red Board.
|
||||
paint(&mut s, blue, "Caster", Rect::new(210, 160, 240, 180), [0, 160, 0]);
|
||||
s.edit("Shadow", |doc, _| {
|
||||
let caster = doc.layer_mut(LayerId(blue)).unwrap().children_mut().unwrap().last_mut().unwrap();
|
||||
caster.effects.items.push(photocraft_doc::Effect::DropShadow(Shadow {
|
||||
common: FxCommon::new(photocraft_color::BlendMode::Normal, 1.0),
|
||||
color: Color::rgb(0.0, 0.0, 0.0),
|
||||
angle: -45.0,
|
||||
use_global_light: false,
|
||||
distance: 40.0_f32.hypot(40.0),
|
||||
spread: 0.0,
|
||||
size: 0.0,
|
||||
contour: Contour::Linear,
|
||||
anti_alias: false,
|
||||
noise: 0.0,
|
||||
knocks_out: true,
|
||||
}));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let source = px(&s.active().unwrap().doc, 185, 130);
|
||||
assert_eq!(rgb(source), [0, 0, 0], "the shadow lands there in the document");
|
||||
let out = Out::new("shadow");
|
||||
for format in ["png", "psd"] {
|
||||
let f = export(&mut s, &out, red, json!({"format": format}));
|
||||
assert_eq!(px(&f, 185, 130), source, "{format}");
|
||||
assert_eq!(rgb(px(&f, 110, 50)), RED, "{format}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Not measured (keeps today's behaviour): a hidden board above shows nothing.
|
||||
#[test]
|
||||
fn a_hidden_board_above_does_not_show() {
|
||||
let (mut s, [red, blue, _]) = session(8);
|
||||
s.edit("Hide", |doc, _| {
|
||||
doc.layer_mut(LayerId(blue)).unwrap().visible = false;
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let out = Out::new("hidden");
|
||||
let f = export(&mut s, &out, red, json!({}));
|
||||
assert_eq!(rgb(px(&f, 150, 60)), WHITE);
|
||||
let psd = export(&mut s, &out, red, json!({"format": "psd"}));
|
||||
assert_eq!(names(&psd.layers), ["Red Board"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_bad_content_value_is_rejected_without_writing_anything() {
|
||||
let (mut s, _) = session(8);
|
||||
let out = Out::new("bad");
|
||||
for bad in [json!("both"), json!(""), json!(1), json!(true), json!(["overlapping"])] {
|
||||
let d = s.active().unwrap();
|
||||
let (before, past) = (d.doc.clone(), d.history.past_len());
|
||||
let err = s.execute("file.export.artboardsToFiles", json!({"dir": out.dir(), "content": bad})).unwrap_err();
|
||||
assert!(matches!(err, EngineError::BadParams { .. }), "{bad}: {err}");
|
||||
let d = s.active().unwrap();
|
||||
assert!(d.doc == before && d.history.past_len() == past, "{bad}");
|
||||
assert_eq!(std::fs::read_dir(&out.0).unwrap().count(), 0, "{bad}: nothing written");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_params_doc_names_the_option() {
|
||||
let spec = specs().into_iter().find(|c| c.id == "file.export.artboardsToFiles").unwrap();
|
||||
assert!(spec.params.contains(r#""content":"overlapping|artboard"="overlapping""#), "{}", spec.params);
|
||||
}
|
||||
|
||||
/// The source document's composite pixel at (x, y); Red Board sits at the canvas origin, so its
|
||||
/// file pixels line up with these.
|
||||
fn source_px(s: &Session, x: i32, y: i32) -> [u8; 4] {
|
||||
px(&s.active().unwrap().doc, x, y)
|
||||
}
|
||||
|
||||
/// A mask on the board above keeps hiding what it hid when the export clips that board to its
|
||||
/// rect: the board clip is added beside it instead of replacing it.
|
||||
#[test]
|
||||
fn a_mask_on_the_board_above_still_hides_its_part() {
|
||||
let (mut s, [red, blue, _]) = session(8);
|
||||
s.edit("Mask", |doc, _| {
|
||||
let board = doc.layer_mut(LayerId(blue)).unwrap();
|
||||
// A canvas-wide fill reaches past the board, so the export clips the board to its rect.
|
||||
let fill = Layer::new("Green", LayerContent::Fill(photocraft_doc::Fill::Solid(Color::rgb(0.0, 1.0, 0.0))));
|
||||
board.children_mut().unwrap().insert(0, fill);
|
||||
let mut mask = photocraft_doc::LayerMask::reveal_all();
|
||||
mask.surface.fill_rect(Rect::new(140, 50, 160, 70), &[0.0]);
|
||||
board.mask = Some(mask);
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(rgb(source_px(&s, 150, 60)), WHITE, "the mask shows Blue Board's background there");
|
||||
let out = Out::new("board-mask");
|
||||
for format in ["png", "psd"] {
|
||||
let f = export(&mut s, &out, red, json!({"format": format}));
|
||||
for (x, y) in [(150, 60), (145, 55), (170, 60), (125, 140), (110, 50), (10, 140)] {
|
||||
assert_eq!(px(&f, x, y), source_px(&s, x, y), "{format} at ({x},{y})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A Normal board renders its layers on their own before they go over its background, so a
|
||||
/// Multiply layer in it does not blend with that background; the export keeps the board as a
|
||||
/// group of its own above the background layer instead of stacking its layers on it.
|
||||
#[test]
|
||||
fn a_multiply_layer_in_a_normal_board_above_does_not_blend_with_its_background() {
|
||||
let (mut s, [red, blue, _]) = session(8);
|
||||
s.edit("Normal", |doc, _| {
|
||||
let board = doc.layer_mut(LayerId(blue)).unwrap();
|
||||
board.blend = photocraft_color::BlendMode::Normal;
|
||||
if let LayerContent::Group(g) = &mut board.content {
|
||||
g.artboard.as_mut().unwrap().background = photocraft_doc::ArtboardBackground::Custom(Color::rgb(0.0, 1.0, 0.0));
|
||||
}
|
||||
board.children_mut().unwrap().last_mut().unwrap().blend = photocraft_color::BlendMode::Multiply;
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(rgb(source_px(&s, 150, 60)), BLUE, "Blue, rendered on its own, covers the green background");
|
||||
let out = Out::new("normal-multiply");
|
||||
for format in ["png", "psd"] {
|
||||
let f = export(&mut s, &out, red, json!({"format": format}));
|
||||
for (x, y) in [(150, 60), (125, 35), (110, 50)] {
|
||||
assert_eq!(px(&f, x, y), source_px(&s, x, y), "{format} at ({x},{y})");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -892,7 +892,7 @@ fn adjustment_layer_to(id: &str, p: &Value) -> Option<Descriptor> {
|
||||
None | Some(Value::Null) => None,
|
||||
Some(v) => {
|
||||
let label = v.as_str()?;
|
||||
if crate::commands::blend_from_str(label)? == photocraft_doc::BlendMode::PassThrough {
|
||||
if crate::commands::parse_blend(label)? == photocraft_doc::BlendMode::PassThrough {
|
||||
return None;
|
||||
}
|
||||
Some(blend_ps(label)?)
|
||||
|
||||
@@ -56,7 +56,7 @@ pub(super) fn blend_label(ps: &str) -> Option<&'static str> {
|
||||
}
|
||||
|
||||
pub(super) fn blend_ps(label: &str) -> Option<&'static str> {
|
||||
crate::commands::blend_from_str(label).and_then(|m| BLEND_MODES.iter().find(|(_, v)| crate::commands::blend_from_str(v) == Some(m))).map(|(k, _)| *k)
|
||||
crate::commands::parse_blend(label).and_then(|m| BLEND_MODES.iter().find(|(_, v)| crate::commands::parse_blend(v) == Some(m))).map(|(k, _)| *k)
|
||||
}
|
||||
|
||||
/// Photoshop ↔ PhotoCraft value tables; Photoshop codes compare without their space padding.
|
||||
|
||||
@@ -69,7 +69,7 @@ fn background_from_layer(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
only.clipped = false;
|
||||
let visible = l.visible;
|
||||
let fmt = doc.pixel_format();
|
||||
let rest = std::mem::replace(&mut doc.layers, vec![only]);
|
||||
let rest = std::mem::replace(&mut doc.layers, vec![only].into());
|
||||
let pixels = photocraft_compose::flatten_to_surface(doc, fmt, Some([bg[0], bg[1], bg[2]]));
|
||||
doc.layers = rest;
|
||||
let mut out = Layer::raster("Background", fmt);
|
||||
|
||||
@@ -448,7 +448,7 @@ fn with_blend_mode(mut b: BrushSettings, p: &Value) -> BrushSettings {
|
||||
} else if p.get("mode").and_then(Value::as_str).is_some_and(|m| m.eq_ignore_ascii_case("behind")) {
|
||||
b.mode = photocraft_color::BlendMode::Normal;
|
||||
b.behind = true;
|
||||
} else if let Some(m) = p.get("mode").and_then(Value::as_str).and_then(crate::commands::blend_from_str) {
|
||||
} else if let Some(m) = p.get("mode").and_then(Value::as_str).and_then(crate::commands::parse_blend) {
|
||||
b.mode = m;
|
||||
b.behind = false;
|
||||
}
|
||||
@@ -980,9 +980,9 @@ fn name_param(p: &Value, cmd: &str) -> Result<String> {
|
||||
|
||||
/// Replace the preset of that name, or append it at the end of the list.
|
||||
fn upsert(s: &mut Session, preset: BrushPreset) {
|
||||
match s.tools.presets.iter_mut().find(|x| x.name.eq_ignore_ascii_case(&preset.name)) {
|
||||
match std::sync::Arc::make_mut(&mut s.tools.presets).iter_mut().find(|x| x.name.eq_ignore_ascii_case(&preset.name)) {
|
||||
Some(x) => *x = preset,
|
||||
None => s.tools.presets.push(preset),
|
||||
None => std::sync::Arc::make_mut(&mut s.tools.presets).push(preset),
|
||||
}
|
||||
s.brush_presets_changed();
|
||||
}
|
||||
@@ -1010,7 +1010,7 @@ fn presets_delete(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let cmd = "brush.presets.delete";
|
||||
let name = name_param(p, cmd)?;
|
||||
let before = s.tools.presets.len();
|
||||
s.tools.presets.retain(|x| !x.name.eq_ignore_ascii_case(&name));
|
||||
std::sync::Arc::make_mut(&mut s.tools.presets).retain(|x| !x.name.eq_ignore_ascii_case(&name));
|
||||
if s.tools.presets.len() == before {
|
||||
return Err(bad(cmd, format!("no brush preset named `{name}`")));
|
||||
}
|
||||
@@ -1043,7 +1043,10 @@ fn presets_update(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Some(patch) => merge_brush(&s.tools.brush, patch, cmd)?,
|
||||
None => s.tools.brush.clone(),
|
||||
};
|
||||
let pr = s.tools.presets.iter_mut().find(|x| x.name.eq_ignore_ascii_case(&name)).ok_or_else(|| bad(cmd, format!("no brush preset named `{name}`")))?;
|
||||
let pr = std::sync::Arc::make_mut(&mut s.tools.presets)
|
||||
.iter_mut()
|
||||
.find(|x| x.name.eq_ignore_ascii_case(&name))
|
||||
.ok_or_else(|| bad(cmd, format!("no brush preset named `{name}`")))?;
|
||||
pr.brush = brush;
|
||||
pr.builtin = false;
|
||||
let (name, group) = (pr.name.clone(), pr.group.clone());
|
||||
|
||||
@@ -263,7 +263,7 @@ mod tests {
|
||||
#[test]
|
||||
fn previous_and_next_brush_walk_the_presets_and_wrap() {
|
||||
let mut s = Session::new();
|
||||
s.tools.presets = vec![preset("One", "", &[], 11.0), preset("Two", "", &[], 22.0), preset("Three", "", &[], 33.0)];
|
||||
s.tools.presets = std::sync::Arc::new(vec![preset("One", "", &[], 11.0), preset("Two", "", &[], 22.0), preset("Three", "", &[], 33.0)]);
|
||||
s.tools.current_preset = None;
|
||||
let picked = |s: &Session| (s.tools.current_preset.clone().unwrap_or_default(), s.tools.brush.size);
|
||||
s.execute("tools.nextBrush", Value::Null).unwrap();
|
||||
@@ -284,7 +284,7 @@ mod tests {
|
||||
[Some(","), Some("."), Some("Shift+,"), Some("Shift+.")]
|
||||
);
|
||||
// No presets: an error, and the brush and the current preset stay as they were.
|
||||
s.tools.presets.clear();
|
||||
std::sync::Arc::make_mut(&mut s.tools.presets).clear();
|
||||
let (brush, current) = (s.tools.brush.clone(), s.tools.current_preset.clone());
|
||||
for id in ["tools.previousBrush", "tools.nextBrush", "tools.firstBrush", "tools.lastBrush"] {
|
||||
assert!(s.execute(id, Value::Null).is_err(), "{id}");
|
||||
|
||||
@@ -120,7 +120,7 @@ pub(crate) fn rename_at(s: &mut Session, i: usize, new: &str, cmd: &str) -> Resu
|
||||
if index_of(&s.tools.presets, new).is_some_and(|j| j != i) {
|
||||
return Err(bad(cmd, format!("a brush preset named `{new}` already exists")));
|
||||
}
|
||||
let pr = s.tools.presets.get_mut(i).ok_or_else(|| bad(cmd, "no such preset"))?;
|
||||
let pr = std::sync::Arc::make_mut(&mut s.tools.presets).get_mut(i).ok_or_else(|| bad(cmd, "no such preset"))?;
|
||||
if pr.name != new {
|
||||
let was_current = s.tools.current_preset.as_ref().is_some_and(|c| c.eq_ignore_ascii_case(&pr.name));
|
||||
pr.name = new.to_string();
|
||||
@@ -153,7 +153,7 @@ fn move_preset(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
};
|
||||
let folder = folder_param(p, cmd)?;
|
||||
let group = group_param(p, "group", cmd)?;
|
||||
let lib = &mut s.tools.presets;
|
||||
let lib = std::sync::Arc::make_mut(&mut s.tools.presets);
|
||||
let (Some(moving), before_pr) = (lib.get(i), before.and_then(|b| lib.get(b))) else {
|
||||
return Err(bad(cmd, "no such preset"));
|
||||
};
|
||||
@@ -233,7 +233,7 @@ fn move_folder(s: &mut Session, p: &Value, g: String, f: Vec<String>, cmd: &str)
|
||||
None | Some(Value::Null) => None,
|
||||
Some(v) => Some(v.as_u64().ok_or_else(|| bad(cmd, "`index` must be a non-negative integer"))?),
|
||||
};
|
||||
let lib = std::mem::take(&mut s.tools.presets);
|
||||
let lib = std::sync::Arc::unwrap_or_clone(std::mem::take(&mut s.tools.presets));
|
||||
// Where the block sits among the other presets (its place when nothing else is in the parent).
|
||||
let start = lib.iter().position(|x| in_folder(x, &g, &f)).unwrap_or(0);
|
||||
let (block, mut rest): (Vec<BrushPreset>, Vec<BrushPreset>) = lib.into_iter().partition(|x| in_folder(x, &g, &f));
|
||||
@@ -252,7 +252,7 @@ fn move_folder(s: &mut Session, p: &Value, g: String, f: Vec<String>, cmd: &str)
|
||||
let tail = rest.split_off(pos.min(rest.len()));
|
||||
rest.extend(block);
|
||||
rest.extend(tail);
|
||||
s.tools.presets = rest;
|
||||
s.tools.presets = std::sync::Arc::new(rest);
|
||||
s.brush_presets_changed();
|
||||
let at = subfolder_order(&s.tools.presets, &g, parent).iter().position(|x| x == leaf).unwrap_or(0);
|
||||
Ok(json!({ "group": g, "folder": f, "index": at }))
|
||||
@@ -332,7 +332,7 @@ fn move_into(s: &mut Session, p: &Value, g: String, f: Vec<String>, dest: Dest,
|
||||
if deepest > MAX_FOLDER_DEPTH {
|
||||
return Err(bad(cmd, format!("folders can be nested at most {MAX_FOLDER_DEPTH} deep")));
|
||||
}
|
||||
let lib = std::mem::take(&mut s.tools.presets);
|
||||
let lib = std::sync::Arc::unwrap_or_clone(std::mem::take(&mut s.tools.presets));
|
||||
let (mut block, mut rest): (Vec<BrushPreset>, Vec<BrushPreset>) = lib.into_iter().partition(|x| in_folder(x, &g, &f));
|
||||
for x in &mut block {
|
||||
let tail = rest_of(x);
|
||||
@@ -352,7 +352,7 @@ fn move_into(s: &mut Session, p: &Value, g: String, f: Vec<String>, dest: Dest,
|
||||
let tail = rest.split_off(pos.unwrap_or(rest.len()).min(rest.len()));
|
||||
rest.extend(block);
|
||||
rest.extend(tail);
|
||||
s.tools.presets = rest;
|
||||
s.tools.presets = std::sync::Arc::new(rest);
|
||||
s.brush_presets_changed();
|
||||
let folder = new_prefix.get(..new_prefix.len().saturating_sub(1)).unwrap_or_default();
|
||||
let at = match &dest {
|
||||
@@ -382,7 +382,7 @@ fn move_group(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
None | Some(Value::Null) => None,
|
||||
Some(v) => Some(v.as_u64().ok_or_else(|| bad(cmd, "`index` must be a non-negative integer"))?),
|
||||
};
|
||||
let lib = std::mem::take(&mut s.tools.presets);
|
||||
let lib = std::sync::Arc::unwrap_or_clone(std::mem::take(&mut s.tools.presets));
|
||||
let (block, mut rest): (Vec<BrushPreset>, Vec<BrushPreset>) = lib.into_iter().partition(|x| x.group == g);
|
||||
let order = group_order(&rest);
|
||||
let first = |name: &str, rest: &[BrushPreset]| rest.iter().position(|x| x.group == name).unwrap_or(rest.len());
|
||||
@@ -394,7 +394,7 @@ fn move_group(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let tail = rest.split_off(pos.min(rest.len()));
|
||||
rest.extend(block);
|
||||
rest.extend(tail);
|
||||
s.tools.presets = rest;
|
||||
s.tools.presets = std::sync::Arc::new(rest);
|
||||
s.brush_presets_changed();
|
||||
let at = group_order(&s.tools.presets).iter().position(|x| *x == g).unwrap_or(0);
|
||||
Ok(json!({ "group": g, "index": at }))
|
||||
@@ -410,7 +410,7 @@ fn rename_group(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
return Err(bad(cmd, format!("a folder named `{new}` already exists there")));
|
||||
}
|
||||
let depth = parent.len();
|
||||
for x in s.tools.presets.iter_mut().filter(|x| in_folder(x, &g, &f)) {
|
||||
for x in std::sync::Arc::make_mut(&mut s.tools.presets).iter_mut().filter(|x| in_folder(x, &g, &f)) {
|
||||
if let Some(n) = x.folder.get_mut(depth) {
|
||||
n.clone_from(&new);
|
||||
}
|
||||
@@ -426,7 +426,7 @@ fn rename_group(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
return Err(bad(cmd, format!("a group named `{new}` already exists")));
|
||||
}
|
||||
if new != g {
|
||||
for x in s.tools.presets.iter_mut().filter(|x| x.group == g) {
|
||||
for x in std::sync::Arc::make_mut(&mut s.tools.presets).iter_mut().filter(|x| x.group == g) {
|
||||
x.group = new.clone();
|
||||
x.builtin = false;
|
||||
}
|
||||
@@ -439,7 +439,7 @@ fn delete_group(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let cmd = "brush.presets.deleteGroup";
|
||||
let (g, f) = target_folder(s, p, cmd)?;
|
||||
let before = s.tools.presets.len();
|
||||
s.tools.presets.retain(|x| !in_folder(x, &g, &f));
|
||||
std::sync::Arc::make_mut(&mut s.tools.presets).retain(|x| !in_folder(x, &g, &f));
|
||||
if s.tools.current_preset.as_ref().is_some_and(|c| !s.tools.presets.iter().any(|x| x.name.eq_ignore_ascii_case(c))) {
|
||||
s.tools.current_preset = None;
|
||||
s.tools.brush_changed();
|
||||
|
||||
@@ -7,7 +7,7 @@ fn names(s: &Session, g: &str) -> Vec<String> {
|
||||
fn with_groups() -> Session {
|
||||
let mut s = Session::new();
|
||||
for (n, g) in [("A1", "Alpha"), ("A2", "Alpha"), ("A3", "Alpha"), ("B1", "Beta"), ("B2", "Beta")] {
|
||||
s.tools.presets.push(BrushPreset {
|
||||
std::sync::Arc::make_mut(&mut s.tools.presets).push(BrushPreset {
|
||||
name: n.into(),
|
||||
brush: Default::default(),
|
||||
builtin: false,
|
||||
@@ -119,7 +119,7 @@ fn with_folders() -> Session {
|
||||
let mut s = Session::new();
|
||||
for (n, f) in [("S0", &[][..]), ("I1", &["Ink"][..]), ("F1", &["Ink", "Fine"][..]), ("I2", &["Ink"][..]), ("D1", &["Dry"][..])] {
|
||||
let folder = f.iter().map(|x| x.to_string()).collect();
|
||||
s.tools.presets.push(BrushPreset {
|
||||
std::sync::Arc::make_mut(&mut s.tools.presets).push(BrushPreset {
|
||||
name: n.into(),
|
||||
brush: Default::default(),
|
||||
builtin: false,
|
||||
@@ -226,7 +226,7 @@ fn with_two_groups() -> Session {
|
||||
let mut s = with_folders();
|
||||
for (n, f) in [("O1", &[][..]), ("B1", &["Box"][..])] {
|
||||
let folder = f.iter().map(|x| x.to_string()).collect();
|
||||
s.tools.presets.push(BrushPreset {
|
||||
std::sync::Arc::make_mut(&mut s.tools.presets).push(BrushPreset {
|
||||
name: n.into(),
|
||||
brush: Default::default(),
|
||||
builtin: false,
|
||||
@@ -266,7 +266,7 @@ fn bad_moves_into_folders_fail_without_changes() {
|
||||
let mut s = with_two_groups();
|
||||
// A chain 31 deep under Set/Deep.
|
||||
let deep: Vec<String> = std::iter::once("Deep".to_string()).chain((0..30).map(|i| format!("d{i}"))).collect();
|
||||
s.tools.presets.push(BrushPreset {
|
||||
std::sync::Arc::make_mut(&mut s.tools.presets).push(BrushPreset {
|
||||
name: "Z".into(),
|
||||
brush: Default::default(),
|
||||
builtin: false,
|
||||
@@ -274,7 +274,7 @@ fn bad_moves_into_folders_fail_without_changes() {
|
||||
folder: deep.clone(),
|
||||
captures: Default::default(),
|
||||
});
|
||||
s.tools.presets.push(BrushPreset {
|
||||
std::sync::Arc::make_mut(&mut s.tools.presets).push(BrushPreset {
|
||||
name: "Y".into(),
|
||||
brush: Default::default(),
|
||||
builtin: false,
|
||||
@@ -314,7 +314,7 @@ fn bad_moves_into_folders_fail_without_changes() {
|
||||
s.execute("brush.presets.moveGroup", json!({"group": "Set", "folder": ["Ink", "Fine"], "into": {"group": "Set"}})).unwrap();
|
||||
assert_eq!(folder_of(&s, "F1"), ["Fine"]);
|
||||
// An ungrouped preset's group can't move.
|
||||
s.tools.presets.push(BrushPreset {
|
||||
std::sync::Arc::make_mut(&mut s.tools.presets).push(BrushPreset {
|
||||
name: "U".into(),
|
||||
brush: Default::default(),
|
||||
builtin: false,
|
||||
|
||||
@@ -23,6 +23,8 @@ use serde_json::{Value, json};
|
||||
use crate::commands::CommandSpec;
|
||||
use crate::{DocState, EngineError, Result, Session};
|
||||
|
||||
#[cfg(test)]
|
||||
mod apply_image_lock_transparency_tests;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
@@ -119,6 +121,9 @@ mod targeting;
|
||||
mod tone_target;
|
||||
mod view;
|
||||
|
||||
#[cfg(test)]
|
||||
mod apply_image_locked_layer_tests;
|
||||
|
||||
use calc::{apply_image, calculations};
|
||||
use manage::{delete_channel, duplicate_channel, move_channel, new_channel, new_spot, options, rename_channel, set_visible};
|
||||
use planes::edit_mode;
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
//! Apply Image on a layer with Lock Transparent Pixels: the lock acts as Preserve Transparency.
|
||||
|
||||
use super::*;
|
||||
|
||||
/// A 40 x 20 document whose layer "Top" is empty except a half-transparent green 10 x 10 square
|
||||
/// at (10,5), and a second document "source" filled with 50% gray.
|
||||
fn session(depth: u32) -> Session {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 40, "height": 20, "depth": depth})).unwrap();
|
||||
s.execute("layer.new.layer", json!({"name": "Top"})).unwrap();
|
||||
s.execute("select.rect", json!({"x": 10, "y": 5, "width": 10, "height": 10, "mode": "replace"})).unwrap();
|
||||
s.execute("edit.fill", json!({"contents": "color", "color": "#00ff00", "opacity": 50})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
s.execute("file.new", json!({"width": 40, "height": 20, "depth": depth, "name": "source"})).unwrap();
|
||||
s.execute("edit.fill", json!({"contents": "color", "color": "#808080"})).unwrap();
|
||||
s.set_active(0);
|
||||
s
|
||||
}
|
||||
|
||||
fn layer(s: &Session) -> &Layer {
|
||||
let d = s.active().unwrap();
|
||||
d.doc.layer(d.active_layer.unwrap()).unwrap()
|
||||
}
|
||||
|
||||
fn pixels(s: &Session) -> Vec<f32> {
|
||||
let d = s.active().unwrap();
|
||||
layer(s).surface().unwrap().read_region(d.doc.bounds())
|
||||
}
|
||||
|
||||
fn px(s: &Session, x: i32, y: i32) -> Vec<f32> {
|
||||
layer(s).surface().unwrap().pixel(x, y)
|
||||
}
|
||||
|
||||
fn close(a: &[f32], b: &[f32]) -> bool {
|
||||
a.len() == b.len() && a.iter().zip(b).all(|(x, y)| (x - y).abs() < 1e-5)
|
||||
}
|
||||
|
||||
/// The layer's pixels after Apply Image with `extra` params, unlocked and with Preserve transparency.
|
||||
fn preserved(depth: u32, extra: &Value) -> Vec<f32> {
|
||||
let mut s = session(depth);
|
||||
let mut p = json!({"source": {"document": 1}, "blending": "normal", "preserveTransparency": true});
|
||||
for (k, v) in extra.as_object().unwrap() {
|
||||
p[k] = v.clone();
|
||||
}
|
||||
s.execute("image.applyImage", p).unwrap();
|
||||
pixels(&s)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transparency_lock_acts_as_preserve_transparency() {
|
||||
for depth in [8, 16, 32] {
|
||||
for extra in [json!({}), json!({"blending": "multiply"}), json!({"opacity": 50})] {
|
||||
let want = preserved(depth, &extra);
|
||||
let mut s = session(depth);
|
||||
s.execute("layer.lockLayers", json!({"transparency": true})).unwrap();
|
||||
let mut p = json!({"source": {"document": 1}, "blending": "normal"});
|
||||
for (k, v) in extra.as_object().unwrap() {
|
||||
p[k] = v.clone();
|
||||
}
|
||||
s.execute("image.applyImage", p).unwrap();
|
||||
assert!(close(&pixels(&s), &want), "{depth} bit {extra}: the lock must keep the layer's transparency");
|
||||
assert_eq!(px(&s, 30, 2), vec![0.0; 4], "{depth} bit {extra}: a transparent pixel stays transparent");
|
||||
assert!((px(&s, 15, 10)[3] - px(&session(depth), 15, 10)[3]).abs() < 1e-5, "{depth} bit {extra}: the square keeps its alpha");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transparency_lock_inside_a_selection_acts_as_preserve_transparency() {
|
||||
let sel = |s: &mut Session| s.execute("select.rect", json!({"x": 0, "y": 0, "width": 15, "height": 20, "mode": "replace"})).unwrap();
|
||||
let mut want = session(8);
|
||||
sel(&mut want);
|
||||
want.execute("image.applyImage", json!({"source": {"document": 1}, "preserveTransparency": true})).unwrap();
|
||||
let mut s = session(8);
|
||||
s.execute("layer.lockLayers", json!({"transparency": true})).unwrap();
|
||||
sel(&mut s);
|
||||
s.execute("image.applyImage", json!({"source": {"document": 1}})).unwrap();
|
||||
assert!(close(&pixels(&s), &pixels(&want)));
|
||||
assert_eq!(px(&s, 2, 2), vec![0.0; 4]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lock_stays_on_and_one_history_step_is_added() {
|
||||
let mut s = session(8);
|
||||
s.execute("layer.lockLayers", json!({"transparency": true})).unwrap();
|
||||
let steps = s.active().unwrap().history.past_len();
|
||||
s.execute("image.applyImage", json!({"source": {"document": 1}})).unwrap();
|
||||
assert!(layer(&s).locks.transparency, "the lock stays on");
|
||||
assert_eq!(s.active().unwrap().history.past_len(), steps + 1, "one Apply Image step");
|
||||
s.undo();
|
||||
assert!(close(&pixels(&s), &pixels(&session(8))), "undo restores the layer");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unlocked_layer_keeps_source_over() {
|
||||
for depth in [8, 16, 32] {
|
||||
let mut s = session(depth);
|
||||
s.execute("image.applyImage", json!({"source": {"document": 1}, "blending": "normal"})).unwrap();
|
||||
let g = 128.0 / 255.0;
|
||||
let p = px(&s, 30, 2);
|
||||
assert!(p[..3].iter().all(|v| (v - g).abs() < 0.003) && (p[3] - 1.0).abs() < 1e-5, "{depth} bit: {p:?}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
//! Apply Image on a fully locked or pixel-locked layer: it applies, and the layer keeps its
|
||||
//! transparency as with Preserve transparency (#14476).
|
||||
|
||||
use super::*;
|
||||
|
||||
/// The spec's test document "target" (400 x 300): layer "Top" is empty except a 100 x 100 square
|
||||
/// at (150,100) of 0/255/0 at alpha 128. Document "source" is 128/128/128 on the left half and
|
||||
/// white on the right half.
|
||||
fn session(depth: u32) -> Session {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 400, "height": 300, "depth": depth, "name": "target"})).unwrap();
|
||||
s.execute("layer.new.layer", json!({"name": "Top"})).unwrap();
|
||||
s.execute("select.rect", json!({"x": 150, "y": 100, "width": 100, "height": 100, "mode": "replace"})).unwrap();
|
||||
s.execute("edit.fill", json!({"contents": "color", "color": "#00ff00", "opacity": 128.0 / 255.0 * 100.0})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
s.execute("file.new", json!({"width": 400, "height": 300, "depth": depth, "name": "source"})).unwrap();
|
||||
s.execute("edit.fill", json!({"contents": "color", "color": "#ffffff"})).unwrap();
|
||||
s.execute("select.rect", json!({"x": 0, "y": 0, "width": 200, "height": 300, "mode": "replace"})).unwrap();
|
||||
s.execute("edit.fill", json!({"contents": "color", "color": "#808080"})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
s.set_active(0);
|
||||
s
|
||||
}
|
||||
|
||||
fn apply() -> Value {
|
||||
json!({"source": {"document": 1}, "blending": "normal", "opacity": 100})
|
||||
}
|
||||
|
||||
fn layer(s: &Session) -> &Layer {
|
||||
let d = s.active().unwrap();
|
||||
d.doc.layer(d.active_layer.unwrap()).unwrap()
|
||||
}
|
||||
|
||||
fn pixels(s: &Session) -> Vec<f32> {
|
||||
let d = s.active().unwrap();
|
||||
layer(s).surface().unwrap().read_region(d.doc.bounds())
|
||||
}
|
||||
|
||||
fn px(s: &Session, x: i32, y: i32) -> Vec<f32> {
|
||||
layer(s).surface().unwrap().pixel(x, y)
|
||||
}
|
||||
|
||||
fn close(a: &[f32], b: &[f32]) -> bool {
|
||||
a.len() == b.len() && a.iter().zip(b).all(|(x, y)| (x - y).abs() < 1e-5)
|
||||
}
|
||||
|
||||
fn lock(s: &mut Session, locks: &Value) {
|
||||
s.execute("layer.setProps", json!({"locks": locks})).unwrap();
|
||||
}
|
||||
|
||||
const LOCKS: [&str; 2] = [r#"{"all": true}"#, r#"{"pixels": true}"#];
|
||||
|
||||
fn locks() -> impl Iterator<Item = Value> {
|
||||
LOCKS.iter().map(|l| serde_json::from_str(l).unwrap())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_locked_layer_takes_the_image_in_one_step_and_keeps_its_transparency() {
|
||||
for depth in [8, 16, 32] {
|
||||
for locks in locks() {
|
||||
let mut s = session(depth);
|
||||
lock(&mut s, &locks);
|
||||
let before = px(&s, 175, 125);
|
||||
let steps = s.active().unwrap().history.past_len();
|
||||
s.execute("image.applyImage", apply()).unwrap();
|
||||
let d = s.active().unwrap();
|
||||
assert_eq!(d.history.past_len(), steps + 1, "{depth} bit {locks}: one history step");
|
||||
assert_eq!(d.history.undo_label(), Some("Apply Image"), "{depth} bit {locks}");
|
||||
assert!(!close(&px(&s, 175, 125), &before), "{depth} bit {locks}: (175,125) changes");
|
||||
assert_eq!(px(&s, 50, 50), vec![0.0; 4], "{depth} bit {locks}: (50,50) stays transparent");
|
||||
assert!((px(&s, 175, 125)[3] - before[3]).abs() < 1e-5, "{depth} bit {locks}: the square keeps its alpha");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_locked_layer_gets_the_preserve_transparency_result() {
|
||||
for depth in [8, 16, 32] {
|
||||
for extra in [json!({}), json!({"blending": "multiply"}), json!({"opacity": 50})] {
|
||||
let with = |p: Value| {
|
||||
let mut p = p;
|
||||
for (k, v) in extra.as_object().unwrap() {
|
||||
p[k] = v.clone();
|
||||
}
|
||||
p
|
||||
};
|
||||
let mut want = session(depth);
|
||||
let mut p = with(apply());
|
||||
p["preserveTransparency"] = json!(true);
|
||||
want.execute("image.applyImage", p).unwrap();
|
||||
for locks in locks() {
|
||||
let mut s = session(depth);
|
||||
lock(&mut s, &locks);
|
||||
s.execute("image.applyImage", with(apply())).unwrap();
|
||||
assert!(close(&pixels(&s), &pixels(&want)), "{depth} bit {locks} {extra}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_locks_stay_and_other_commands_keep_refusing() {
|
||||
for locks in locks() {
|
||||
let mut s = session(8);
|
||||
lock(&mut s, &locks);
|
||||
let set = layer(&s).locks;
|
||||
s.execute("image.applyImage", apply()).unwrap();
|
||||
assert_eq!(layer(&s).locks, set, "{locks}: the lock flags are unchanged");
|
||||
let after = pixels(&s);
|
||||
let steps = s.active().unwrap().history.past_len();
|
||||
let fill = s.execute("edit.fill", json!({"contents": "color", "color": "#ff0000"})).unwrap_err().to_string();
|
||||
assert!(fill.contains("is locked"), "{locks}: Fill refuses: {fill}");
|
||||
let stroke = s.execute("paint.stroke", json!({"points": [[160, 110], [240, 190]], "size": 20})).unwrap_err().to_string();
|
||||
assert!(stroke.contains("is locked"), "{locks}: a brush stroke refuses: {stroke}");
|
||||
assert!(close(&pixels(&s), &after), "{locks}: nothing else painted");
|
||||
assert_eq!(s.active().unwrap().history.past_len(), steps, "{locks}: no more steps");
|
||||
s.undo();
|
||||
assert!(close(&pixels(&s), &pixels(&session(8))), "{locks}: undo restores the layer");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_lock_from_a_group_still_refuses() {
|
||||
// Not measured in the reference application: keeps today's refusal, also when the layer is
|
||||
// locked itself as well.
|
||||
for own in [None, Some(json!({"pixels": true})), Some(json!({"all": true}))] {
|
||||
let mut s = session(8);
|
||||
let top = s.active().unwrap().active_layer.unwrap();
|
||||
if let Some(own) = &own {
|
||||
lock(&mut s, own);
|
||||
}
|
||||
s.execute("layer.new.groupFromLayers", json!({})).unwrap();
|
||||
lock(&mut s, &json!({"all": true}));
|
||||
s.set_active_layer(Some(top));
|
||||
let before = pixels(&s);
|
||||
let err = s.execute("image.applyImage", apply()).unwrap_err().to_string();
|
||||
assert!(err.contains("is locked"), "{own:?}: {err}");
|
||||
assert!(close(&pixels(&s), &before), "{own:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unlocked_layer_keeps_source_over() {
|
||||
let mut s = session(8);
|
||||
s.execute("image.applyImage", apply()).unwrap();
|
||||
let p = px(&s, 50, 50);
|
||||
let g = 128.0 / 255.0;
|
||||
assert!(p[..3].iter().all(|v| (v - g).abs() < 0.003) && (p[3] - 1.0).abs() < 1e-5, "{p:?}");
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
//! #14473: Apply Image with Preserve Transparency gives a semi-transparent pixel the full blend
|
||||
//! result and keeps its alpha, as the reference application does.
|
||||
|
||||
use crate::Session;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
/// Target "target" (document 0): white Background, layer "Top" transparent except a 0/255/0
|
||||
/// square at alpha 128 over (10,4)-(19,13). Source "source" (document 1): 128/128/128.
|
||||
fn session(depth: u32) -> Session {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 40, "height": 20, "depth": depth, "name": "target"})).unwrap();
|
||||
s.execute("file.new", json!({"width": 40, "height": 20, "depth": depth, "name": "source"})).unwrap();
|
||||
s.execute("edit.fill", json!({"color": "#808080"})).unwrap();
|
||||
s.set_active(0);
|
||||
s.execute("layer.new.layer", json!({"name": "Top"})).unwrap();
|
||||
s.execute("select.rect", json!({"x": 10, "y": 4, "width": 10, "height": 10, "mode": "replace"})).unwrap();
|
||||
s.execute("edit.fill", json!({"color": "#00ff00", "opacity": 50})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
s
|
||||
}
|
||||
|
||||
fn px(s: &Session, x: i32, y: i32) -> Vec<f32> {
|
||||
let d = s.active().unwrap();
|
||||
d.doc.layer(d.active_layer.unwrap()).unwrap().surface().unwrap().pixel(x, y)
|
||||
}
|
||||
|
||||
fn apply(s: &mut Session, extra: Value) {
|
||||
let mut p = json!({"source": {"document": 1, "layer": "merged", "channel": "composite"}});
|
||||
if let (Some(p), Some(extra)) = (p.as_object_mut(), extra.as_object()) {
|
||||
p.extend(extra.clone());
|
||||
}
|
||||
s.execute("image.applyImage", p).unwrap();
|
||||
}
|
||||
|
||||
/// Checks RGBA in 0..=255 levels, one level of slack (the fill's 50% alpha is 127.5).
|
||||
fn assert_rgba(got: &[f32], want: [f32; 4], what: &str) {
|
||||
let got: Vec<f32> = got.iter().map(|v| v * 255.0).collect();
|
||||
assert!(got.iter().zip(want).all(|(g, w)| (g - w).abs() <= 1.01), "{what}: {got:?}, want {want:?}");
|
||||
}
|
||||
|
||||
const GRAY: f32 = 128.0;
|
||||
const HALF: f32 = 127.5;
|
||||
|
||||
#[test]
|
||||
fn normal_with_preserve_transparency_takes_the_source_and_keeps_alpha() {
|
||||
for depth in [8, 16, 32] {
|
||||
let mut s = session(depth);
|
||||
apply(&mut s, json!({"blending": "normal", "preserveTransparency": true}));
|
||||
assert_rgba(&px(&s, 15, 8), [GRAY, GRAY, GRAY, HALF], &format!("depth {depth}: green pixel"));
|
||||
assert_rgba(&px(&s, 2, 2), [0.0; 4], &format!("depth {depth}: transparent pixel"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiply_with_preserve_transparency_blends_fully_and_keeps_alpha() {
|
||||
for depth in [8, 16, 32] {
|
||||
let mut s = session(depth);
|
||||
apply(&mut s, json!({"blending": "multiply", "preserveTransparency": true}));
|
||||
assert_rgba(&px(&s, 15, 8), [0.0, GRAY, 0.0, HALF], &format!("depth {depth}: green pixel"));
|
||||
assert_rgba(&px(&s, 2, 2), [0.0; 4], &format!("depth {depth}: transparent pixel"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opacity_and_selection_still_scale_the_preserved_blend() {
|
||||
let mut s = session(8);
|
||||
// 50% Normal: the colour moves half way to the source, the alpha stays.
|
||||
apply(&mut s, json!({"blending": "normal", "opacity": 50, "preserveTransparency": true}));
|
||||
assert_rgba(&px(&s, 15, 8), [64.0, 191.5, 64.0, HALF], "opacity 50");
|
||||
s.undo();
|
||||
// Outside the selection nothing changes.
|
||||
s.execute("select.rect", json!({"x": 10, "y": 4, "width": 5, "height": 10, "mode": "replace"})).unwrap();
|
||||
apply(&mut s, json!({"blending": "normal", "preserveTransparency": true}));
|
||||
assert_rgba(&px(&s, 12, 8), [GRAY, GRAY, GRAY, HALF], "inside the selection");
|
||||
assert_rgba(&px(&s, 17, 8), [0.0, 255.0, 0.0, HALF], "outside the selection");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_mask_still_scales_the_preserved_blend() {
|
||||
let mut s = session(8);
|
||||
// A 50% gray alpha channel as the mask halves the effect, like 50% opacity.
|
||||
s.execute("channel.new", json!({"fill": "white"})).unwrap();
|
||||
s.execute("channel.target", json!({"channel": 0})).unwrap();
|
||||
s.execute("edit.fill", json!({"color": "#808080"})).unwrap();
|
||||
s.execute("channel.target", json!({"channel": "composite"})).unwrap();
|
||||
apply(&mut s, json!({"blending": "normal", "preserveTransparency": true, "mask": {"document": 0, "channel": 0}}));
|
||||
assert_rgba(&px(&s, 15, 8), [64.0, 191.5, 64.0, HALF], "mask at 50%");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn without_preserve_transparency_the_results_stay() {
|
||||
let mut s = session(8);
|
||||
apply(&mut s, json!({"blending": "normal"}));
|
||||
assert_rgba(&px(&s, 15, 8), [GRAY, GRAY, GRAY, 255.0], "normal, green pixel");
|
||||
assert_rgba(&px(&s, 2, 2), [GRAY, GRAY, GRAY, 255.0], "normal, transparent pixel");
|
||||
s.undo();
|
||||
apply(&mut s, json!({"blending": "multiply"}));
|
||||
assert_rgba(&px(&s, 15, 8), [64.0, GRAY, 64.0, 255.0], "multiply, green pixel");
|
||||
assert_rgba(&px(&s, 2, 2), [GRAY, GRAY, GRAY, 255.0], "multiply, transparent pixel");
|
||||
s.undo();
|
||||
apply(&mut s, json!({"blending": "normal", "opacity": 50}));
|
||||
assert_rgba(&px(&s, 15, 8), [85.0, 170.0, 85.0, 191.5], "normal 50%, green pixel");
|
||||
assert_rgba(&px(&s, 2, 2), [GRAY, GRAY, GRAY, HALF], "normal 50%, transparent pixel");
|
||||
}
|
||||
@@ -4,6 +4,10 @@ use super::refs::{Blending, bad, doc_index, mask_plane, source, source_spec};
|
||||
use super::targeting::{Target, is_channel_target, is_spot_target, target_of, target_surface};
|
||||
use super::{AlphaChannel, ColorMode, EngineError, Result, SelectionMode, Session, Value, json, sel};
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "apply_image_preserve_tests.rs"]
|
||||
mod apply_image_preserve_tests;
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Apply Image / Calculations
|
||||
|
||||
@@ -55,8 +59,21 @@ pub(super) fn apply_image(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
return Ok(());
|
||||
}
|
||||
let id = layer.ok_or_else(|| EngineError::Other("no active layer".into()))?;
|
||||
// Lock Transparent Pixels works as Preserve Transparency, ticked or not.
|
||||
let preserve = preserve || doc.effective_locks(id).transparency;
|
||||
let fmt = doc.pixel_format();
|
||||
let surf = crate::commands::paint_surface(doc, id, &Value::Null)?;
|
||||
// A fully locked or pixel-locked layer still takes the image, as in the reference
|
||||
// application, and keeps its transparency as with Preserve transparency. A lock that comes
|
||||
// from a group around it still refuses, through `paint_surface`.
|
||||
let own = doc.layer(id).map(|l| l.locks).unwrap_or_default();
|
||||
let groups = doc.path_of(id).map_or_else(Default::default, |p| doc.locks_at(p.get(..p.len().saturating_sub(1)).unwrap_or_default()));
|
||||
let locked = (own.pixels || own.all) && !(groups.pixels || groups.all);
|
||||
let preserve = preserve || locked;
|
||||
let surf = if locked {
|
||||
doc.layer_mut(id).ok_or(EngineError::NoLayer(id))?.surface_mut().ok_or_else(|| EngineError::Other("not a pixel layer".into()))?
|
||||
} else {
|
||||
crate::commands::paint_surface(doc, id, &Value::Null)?
|
||||
};
|
||||
let sf = surf.format();
|
||||
if sf != fmt {
|
||||
return Err(EngineError::Other("the target layer's format doesn't match the document".into()));
|
||||
@@ -66,11 +83,9 @@ pub(super) fn apply_image(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let mut v = surf.read_region(area);
|
||||
for (i, px) in v.chunks_exact_mut(n).enumerate() {
|
||||
let base_a = if sf.alpha { px[colors].clamp(0.0, 1.0) } else { 1.0 };
|
||||
let mut w = weight(i);
|
||||
if preserve {
|
||||
w *= base_a;
|
||||
}
|
||||
if w <= 0.0 {
|
||||
let w = weight(i);
|
||||
// Preserve Transparency leaves transparent pixels as they are.
|
||||
if w <= 0.0 || (preserve && base_a <= 0.0) {
|
||||
continue;
|
||||
}
|
||||
// Painted over the layer like a brush: the blend only acts where the layer has
|
||||
@@ -85,8 +100,17 @@ pub(super) fn apply_image(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let k = if src_mode == ColorMode::Cmyk && sf.mode != ColorMode::Cmyk { src.get(3).map_or(1.0, |pl| tone(src_mode, pl[i])) } else { 1.0 };
|
||||
let top = if src.len() > 1 { tone(src_mode, src.get(c).unwrap_or(&src[0])[i]) * k } else { src[0][i] };
|
||||
let base = tone(sf.mode, *b);
|
||||
let blended = top + (blending.apply(base, top) - top) * base_a;
|
||||
*b = tone(sf.mode, if preserve { base + (blended - base) * w } else { (w * blended + base_a * (1.0 - w) * base) / out_a });
|
||||
// With Preserve Transparency the colour takes the full blend and only the alpha
|
||||
// stays the layer's (a pixel at 50% alpha turns fully to the source in Normal).
|
||||
*b = tone(
|
||||
sf.mode,
|
||||
if preserve {
|
||||
base + (blending.apply(base, top) - base) * w
|
||||
} else {
|
||||
let blended = top + (blending.apply(base, top) - top) * base_a;
|
||||
(w * blended + base_a * (1.0 - w) * base) / out_a
|
||||
},
|
||||
);
|
||||
}
|
||||
if sf.alpha {
|
||||
px[colors] = out_a;
|
||||
|
||||
@@ -314,7 +314,7 @@ impl Blending {
|
||||
match name.to_ascii_lowercase().as_str() {
|
||||
"add" => Ok(Blending::Add { scale, offset }),
|
||||
"subtract" => Ok(Blending::Subtract { scale, offset }),
|
||||
other => match crate::commands::blend_from_str(other) {
|
||||
other => match crate::commands::parse_blend(other) {
|
||||
Some(m) if m.is_separable() && !matches!(m, BlendMode::Dissolve | BlendMode::PassThrough) => Ok(Blending::Mode(m)),
|
||||
_ => Err(format!("unsupported blending `{other}`")),
|
||||
},
|
||||
|
||||
@@ -43,7 +43,7 @@ pub(super) fn merge_spot(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
sf.prune();
|
||||
}
|
||||
let id = bg.id;
|
||||
doc.layers = vec![bg];
|
||||
doc.layers = vec![bg].into();
|
||||
doc.channels.remove(i);
|
||||
*active = Some(id);
|
||||
Ok(())
|
||||
|
||||
@@ -1259,7 +1259,7 @@ fn split_refuses_an_image_with_more_than_one_layer() {
|
||||
assert_eq!(s.execute("channel.split", json!({})).unwrap()["documents"].as_array().unwrap().len(), 3);
|
||||
// A lone group is a layer the split would lose.
|
||||
let mut s = session();
|
||||
std::sync::Arc::make_mut(&mut s.active_mut().unwrap().doc).layers = vec![Layer::group("Group 1", vec![])];
|
||||
std::sync::Arc::make_mut(&mut s.active_mut().unwrap().doc).layers = vec![Layer::group("Group 1", vec![])].into();
|
||||
assert!(!s.is_enabled("channel.split"));
|
||||
assert!(s.execute("channel.split", json!({})).is_err());
|
||||
assert_eq!(s.documents().len(), 1);
|
||||
|
||||
@@ -1116,7 +1116,7 @@ fn flatten_for_profile(doc: &mut Document, active: &mut Option<photocraft_doc::L
|
||||
background.locks.position = true;
|
||||
*crate::pixels_mut(&mut background)? = surface;
|
||||
*active = Some(background.id);
|
||||
doc.layers = vec![background];
|
||||
doc.layers = vec![background].into();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,35 @@
|
||||
use super::{SPECS, command_specs};
|
||||
|
||||
/// Menus, the Command Palette and the automation docs list commands in registry order, so the
|
||||
/// order is part of the behaviour. `command_ids.txt` pins it; regenerate the file from main when
|
||||
/// rebasing, adding each new command's id after its predecessor. With `PHOTOCRAFT_WRITE_COMMAND_IDS`
|
||||
/// set, the test writes the file from the registry instead; review the diff before committing it.
|
||||
const HINT: &str = "\nadd the id to src/cmd/command_ids.txt, or run this test with PHOTOCRAFT_WRITE_COMMAND_IDS=1 and review the diff";
|
||||
|
||||
#[test]
|
||||
fn registered_command_ids_keep_their_order() {
|
||||
let ids: Vec<&str> = command_specs().iter().map(|c| c.id).collect();
|
||||
if std::env::var_os("PHOTOCRAFT_WRITE_COMMAND_IDS").is_some() {
|
||||
let path = concat!(env!("CARGO_MANIFEST_DIR"), "/src/cmd/command_ids.txt");
|
||||
std::fs::write(path, ids.iter().map(|id| format!("{id}\n")).collect::<String>()).expect("write command_ids.txt");
|
||||
return;
|
||||
}
|
||||
let expected: Vec<&str> = include_str!("command_ids.txt").lines().collect();
|
||||
if let Some(i) = ids.iter().zip(&expected).position(|(a, b)| a != b) {
|
||||
panic!("command {i} is {} where {} was registered{}{HINT}", ids[i], expected[i], fragment_of(i));
|
||||
}
|
||||
assert_eq!(ids.len(), expected.len(), "the number of registered commands changed{}{HINT}", fragment_of(ids.len().min(expected.len())));
|
||||
}
|
||||
|
||||
/// Names the fragment that registers command `index`, for the failure message.
|
||||
fn fragment_of(index: usize) -> String {
|
||||
let mut first = 0;
|
||||
for (name, specs) in SPECS {
|
||||
let len = specs().len();
|
||||
if index < first + len {
|
||||
return format!(" (fragment `{name}`, commands {first}..{})", first + len);
|
||||
}
|
||||
first += len;
|
||||
}
|
||||
String::new()
|
||||
}
|
||||
@@ -789,7 +789,7 @@ fn merge_visible(s: &mut Session) -> Result<Value> {
|
||||
out.push(l);
|
||||
}
|
||||
}
|
||||
doc.layers = out;
|
||||
doc.layers = out.into();
|
||||
*active = Some(mid);
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
@@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::channel_cmds::Target;
|
||||
use crate::commands::{CommandSpec, blend_from_str, int, layer_param};
|
||||
use crate::commands::{CommandSpec, int, layer_param, parse_blend};
|
||||
use crate::{EngineError, Result, Session};
|
||||
|
||||
// ------------------------------------------------------------------ state
|
||||
@@ -314,9 +314,9 @@ fn export_import(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// absurd tree).
|
||||
b.folder.retain(|f| !f.trim().is_empty());
|
||||
b.folder.truncate(crate::brush_preset_cmds::MAX_FOLDER_DEPTH);
|
||||
match s.tools.presets.iter_mut().find(|x| x.name == b.name) {
|
||||
match std::sync::Arc::make_mut(&mut s.tools.presets).iter_mut().find(|x| x.name == b.name) {
|
||||
Some(x) => *x = b,
|
||||
None => s.tools.presets.push(b),
|
||||
None => std::sync::Arc::make_mut(&mut s.tools.presets).push(b),
|
||||
}
|
||||
nb += 1;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::{
|
||||
BlendMode, Document, EngineError, FadeSource, FadeTarget, Rect, Result, Session, Surface, Value, bad, blend_from_str, f32_or, from_rgba_into, json, str_or,
|
||||
BlendMode, Document, EngineError, FadeSource, FadeTarget, Rect, Result, Session, Surface, Value, bad, f32_or, from_rgba_into, json, parse_blend, str_or,
|
||||
surface_of, surface_of_mut, to_rgba,
|
||||
};
|
||||
|
||||
@@ -103,7 +103,7 @@ fn fade_job(s: &Session, p: &Value) -> Result<FadeJob> {
|
||||
let cmd = "edit.fade";
|
||||
let src = s.edit_state.fade.clone().ok_or_else(|| bad(cmd, "nothing to fade"))?;
|
||||
let opacity = f32_or(p, "opacity", 100.0).clamp(0.0, 100.0) / 100.0;
|
||||
let mode = blend_from_str(str_or(p, "mode", "normal")).ok_or_else(|| bad(cmd, "unknown blend mode"))?;
|
||||
let mode = parse_blend(str_or(p, "mode", "normal")).ok_or_else(|| bad(cmd, "unknown blend mode"))?;
|
||||
let st = s.active().ok_or(EngineError::NoDocument)?;
|
||||
let prev = before_state(st, &src).ok_or_else(|| bad(cmd, "no previous state"))?;
|
||||
let before = surface_of(&prev, src.target).cloned().ok_or_else(|| EngineError::Other("the layer or channel did not exist before this step".into()))?;
|
||||
|
||||
@@ -114,7 +114,7 @@ pub(super) fn preset_manager(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
"delete" => match kind.as_str() {
|
||||
"brushes" => {
|
||||
let gone = s.tools.presets.remove(i);
|
||||
let gone = std::sync::Arc::make_mut(&mut s.tools.presets).remove(i);
|
||||
crate::brush_cmds::forget_deleted_preset(s, &gone.name);
|
||||
}
|
||||
"patterns" => drop(s.patterns.items.remove(i)),
|
||||
@@ -123,7 +123,7 @@ pub(super) fn preset_manager(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
"move" => {
|
||||
let to = p.get("to").and_then(Value::as_u64).ok_or_else(|| bad(cmd, "missing `to`"))? as usize;
|
||||
match kind.as_str() {
|
||||
"brushes" => crate::move_item(&mut s.tools.presets, i, to),
|
||||
"brushes" => crate::move_item(std::sync::Arc::make_mut(&mut s.tools.presets), i, to),
|
||||
"patterns" => crate::move_item(&mut s.patterns.items, i, to),
|
||||
_ => crate::move_item(&mut s.edit_state.custom_shapes, i, to),
|
||||
};
|
||||
|
||||
@@ -147,7 +147,7 @@ fn stroke(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let picked = s.tools.picked_cmyk([color[0], color[1], color[2]]);
|
||||
let mode = match p.get("mode") {
|
||||
None | Some(Value::Null) => photocraft_color::BlendMode::Normal,
|
||||
Some(Value::String(m)) => crate::commands::blend_from_str(m)
|
||||
Some(Value::String(m)) => crate::commands::parse_blend(m)
|
||||
.filter(|m| *m != photocraft_color::BlendMode::PassThrough)
|
||||
.ok_or_else(|| EngineError::BadParams { cmd: "edit.stroke".into(), msg: format!("unknown blend mode `{m}`") })?,
|
||||
Some(v) => return Err(EngineError::BadParams { cmd: "edit.stroke".into(), msg: format!("mode must be a blend mode name, not {v}") }),
|
||||
|
||||
@@ -77,7 +77,7 @@ pub fn export_layers_report_with(s: &Session, p: &Value, mut write: impl FnMut(&
|
||||
let mut only = l.clone();
|
||||
only.visible = true;
|
||||
only.clipped = false;
|
||||
one.layers = vec![only];
|
||||
one.layers = vec![only].into();
|
||||
if trim {
|
||||
let mut bounds = Rect::EMPTY;
|
||||
let _ = photocraft_compose::render_bands(&one, one.bounds(), 0, |band| -> std::result::Result<(), ()> {
|
||||
|
||||
@@ -304,9 +304,9 @@ pub(super) fn load_files_into_stack(s: &mut Session, p: &Value) -> Result<Value>
|
||||
// "Create Smart Object after Loading Layers": the layers go inside one smart object, ready
|
||||
// for Layer › Smart Objects › Stack Mode. Like Photoshop, they sit at the top level of the
|
||||
// contents, with no wrapper group.
|
||||
let layers = std::mem::take(&mut stack.layers);
|
||||
let layers = std::mem::take(&mut *stack.layers);
|
||||
let smart = crate::smart_cmds::layers_to_smart(&stack, &smart_name, layers)?;
|
||||
stack.layers = vec![smart];
|
||||
stack.layers = vec![smart].into();
|
||||
}
|
||||
let i = s.add_document(stack, None);
|
||||
if align {
|
||||
@@ -314,10 +314,10 @@ pub(super) fn load_files_into_stack(s: &mut Session, p: &Value) -> Result<Value>
|
||||
s.execute("edit.autoAlignLayers", json!({"projection": "auto"}))?;
|
||||
if smart {
|
||||
s.edit("Convert to Smart Object", |doc, active| {
|
||||
let layers = std::mem::take(&mut doc.layers);
|
||||
let layers = std::mem::take(&mut *doc.layers);
|
||||
let smart = crate::smart_cmds::layers_to_smart(doc, &smart_name, layers)?;
|
||||
*active = Some(smart.id);
|
||||
doc.layers = vec![smart];
|
||||
doc.layers = vec![smart].into();
|
||||
Ok(())
|
||||
})?;
|
||||
if let Some(st) = s.active_mut() {
|
||||
|
||||
@@ -312,7 +312,7 @@ pub(super) fn save_a_copy(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// "Layers" unchecked in Save a Copy: write the flattened image.
|
||||
let fmt = doc.pixel_format();
|
||||
let px = flattened_checked(&doc, fmt, "file.saveACopy")?;
|
||||
doc.layers = vec![Layer::new("Background", LayerContent::Raster(px))];
|
||||
doc.layers = vec![Layer::new("Background", LayerContent::Raster(px))].into();
|
||||
}
|
||||
let warnings = save_doc(&doc, &path, SaveOpts::from_params(s, p, "file.saveACopy")?)?;
|
||||
Ok(json!({"path": path, "warnings": warnings}))
|
||||
|
||||
@@ -11,7 +11,7 @@ use photocraft_geom::{Rect, TILE_SIZE};
|
||||
use photocraft_raster::{Surface, from_rgba_into, to_rgba};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::commands::{blend_from_str, color_param, layer_param};
|
||||
use crate::commands::{color_param, layer_param, parse_blend};
|
||||
use crate::{EngineError, Result, Session};
|
||||
|
||||
const CMD: &str = "edit.fill";
|
||||
@@ -66,7 +66,7 @@ fn contents(p: &Value) -> Result<&str> {
|
||||
fn mode(p: &Value) -> Result<BlendMode> {
|
||||
match p.get("mode") {
|
||||
None | Some(Value::Null) => Ok(BlendMode::Normal),
|
||||
Some(Value::String(m)) => blend_from_str(m).filter(|m| *m != BlendMode::PassThrough).ok_or_else(|| bad(format!("unknown blend mode `{m}`"))),
|
||||
Some(Value::String(m)) => parse_blend(m).filter(|m| *m != BlendMode::PassThrough).ok_or_else(|| bad(format!("unknown blend mode `{m}`"))),
|
||||
Some(v) => Err(bad(format!("`mode` must be a blend mode name, not {v}"))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ use photocraft_doc::{Document, Fill, GradientStyle, Layer, LayerContent, LayerId
|
||||
use photocraft_geom::Rect;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::commands::{CommandSpec, blend_from_str, check_pixels_unlocked, layer_param};
|
||||
use crate::commands::{CommandSpec, check_pixels_unlocked, layer_param, parse_blend};
|
||||
use crate::presets::gradients::{GradientPreset, transparency_param};
|
||||
use crate::{EngineError, Result, Session};
|
||||
|
||||
@@ -300,7 +300,7 @@ pub fn new_layer(s: &Session, doc: &Document, p: &Value) -> Result<Layer> {
|
||||
let opacity = num(p, "opacity").unwrap_or(100.0).clamp(0.0, 100.0) / 100.0;
|
||||
let blend = match p.get("mode").and_then(Value::as_str) {
|
||||
None | Some("") => photocraft_color::BlendMode::Normal,
|
||||
Some(m) => blend_from_str(m).ok_or_else(|| bad(CMD, format!("unknown blend mode `{m}`")))?,
|
||||
Some(m) => parse_blend(m).ok_or_else(|| bad(CMD, format!("unknown blend mode `{m}`")))?,
|
||||
};
|
||||
let canvas = doc.bounds();
|
||||
if canvas.is_empty() {
|
||||
|
||||
@@ -145,7 +145,7 @@ fn new_snapshot(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let one_layer = |doc: &Document, layer: Layer| {
|
||||
let mut doc = doc.clone();
|
||||
let id = layer.id;
|
||||
doc.layers = vec![layer];
|
||||
doc.layers = vec![layer].into();
|
||||
(Arc::new(doc), LayerTarget { active: Some(id), selected: vec![id] })
|
||||
};
|
||||
let (doc, layers) = match from {
|
||||
@@ -525,7 +525,7 @@ mod tests {
|
||||
assert_eq!(st.memory_bytes(), base + flat);
|
||||
// Room for the document's tiles and four fill tiles.
|
||||
let cur = tile_bytes(&st.doc);
|
||||
let fill = tile_bytes(&Document { layers: st.doc.layers[1..].to_vec(), ..(*st.doc).clone() });
|
||||
let fill = tile_bytes(&Document { layers: st.doc.layers[1..].to_vec().into(), ..(*st.doc).clone() });
|
||||
assert!(flat <= fill, "the flattened tile is no bigger than a fill's");
|
||||
let budget = cur + 4 * fill;
|
||||
for s in [&mut with, &mut without] {
|
||||
@@ -549,7 +549,7 @@ mod tests {
|
||||
s.execute("edit.fill", json!({"color": "#0000ff"})).unwrap();
|
||||
let st = s.active().unwrap();
|
||||
// The snapshot's green layer tile, now only in it and the last state.
|
||||
let shared = tile_bytes(&Document { layers: st.snapshots.last().unwrap().doc.layers[1..].to_vec(), ..(*st.doc).clone() });
|
||||
let shared = tile_bytes(&Document { layers: st.snapshots.last().unwrap().doc.layers[1..].to_vec().into(), ..(*st.doc).clone() });
|
||||
let all = st.history.unique_bytes(&st.doc);
|
||||
let r = s.execute("edit.purge.histories", json!({})).unwrap();
|
||||
assert_eq!(r["bytes"], json!(all - shared), "the green tile stays with the snapshot");
|
||||
|
||||
@@ -86,19 +86,40 @@ fn parse(st: &DocState, p: &Value, cmd: &str) -> Result<Option<HistorySource>> {
|
||||
/// Photoshop refuses too, "the current canvas size does not match that of the history state"
|
||||
/// (its message as users report it; Adobe's help doesn't document the case).
|
||||
pub(crate) fn paint_source(st: &DocState, p: &Value, cmd: &str) -> Result<Arc<Document>> {
|
||||
checked_source(st, p, cmd)?.map_err(|why| {
|
||||
EngineError::Other(match why {
|
||||
SourceRefusal::NoSource => "the History Brush source was deleted: set a new source in the History panel".into(),
|
||||
SourceRefusal::CanvasSize { source } => format!(
|
||||
"the current canvas size ({}×{}) does not match that of the History Brush source ({}×{}): set a source of this size in the History panel",
|
||||
st.doc.size.width, st.doc.size.height, source.width, source.height
|
||||
),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Why [`checked_source`] found no source to paint from, so each tool can word it (#12638).
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum SourceRefusal {
|
||||
/// No `state` or `snapshot` passed, and the History panel's source was deleted.
|
||||
NoSource,
|
||||
/// The source has another canvas size than the document.
|
||||
CanvasSize { source: photocraft_geom::Size },
|
||||
}
|
||||
|
||||
/// [`paint_source`] with the refusal left to the caller: bad params and a `state` or `snapshot`
|
||||
/// that is gone are errors, the two refusals the tools word themselves are the inner `Err`.
|
||||
pub(crate) fn checked_source(st: &DocState, p: &Value, cmd: &str) -> Result<std::result::Result<Arc<Document>, SourceRefusal>> {
|
||||
let doc = match parse(st, p, cmd)? {
|
||||
Some(src) => source_of(st, src).ok_or_else(|| EngineError::Other("that history state or snapshot is gone".into()))?,
|
||||
None => source(st)
|
||||
.and_then(|src| source_of(st, src))
|
||||
.ok_or_else(|| EngineError::Other("the History Brush source was deleted: set a new source in the History panel".into()))?,
|
||||
None => match source(st).and_then(|src| source_of(st, src)) {
|
||||
Some(doc) => doc,
|
||||
None => return Ok(Err(SourceRefusal::NoSource)),
|
||||
},
|
||||
};
|
||||
if doc.size != st.doc.size {
|
||||
return Err(EngineError::Other(format!(
|
||||
"the current canvas size ({}×{}) does not match that of the History Brush source ({}×{}): set a source of this size in the History panel",
|
||||
st.doc.size.width, st.doc.size.height, doc.size.width, doc.size.height
|
||||
)));
|
||||
return Ok(Err(SourceRefusal::CanvasSize { source: doc.size }));
|
||||
}
|
||||
Ok(doc)
|
||||
Ok(Ok(doc))
|
||||
}
|
||||
|
||||
/// The History Brush's refusals after Image › Mode, with Photoshop's alert texts (#12842): only
|
||||
|
||||
@@ -1213,7 +1213,7 @@ fn duplicate(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let mut merged = Layer::new(if has_background { "Background" } else { "Layer 1" }, LayerContent::Raster(surf));
|
||||
merged.locks.transparency = has_background;
|
||||
merged.locks.position = has_background;
|
||||
doc.layers = vec![merged];
|
||||
doc.layers = vec![merged].into();
|
||||
// A merged-only copy has no original layers for saved comps to restore.
|
||||
// Don't carry dangling comp state into a single-layer flattened document.
|
||||
doc.layer_comps.clear();
|
||||
|
||||
@@ -798,16 +798,18 @@ fn crop_at_a_small_angle_keeps_the_frame_size_in_every_mode() {
|
||||
#[test]
|
||||
fn turned_crop_deleting_pixels_matches_turning_the_whole_canvas() {
|
||||
use photocraft_color::PixelFormat;
|
||||
let pixels = || (0..500).flat_map(|y| (0..700).map(move |x| (x, y)));
|
||||
for depth in [8, 16, 32] {
|
||||
for angle in [3.0, -7.5, 33.0, 181.0] {
|
||||
let (w, h) = if depth == 8 && angle == 33.0 { (700, 500) } else { (140, 100) };
|
||||
let scale = w / 140;
|
||||
let pixels = || (0..h).flat_map(|y| (0..w).map(move |x| (x, y)));
|
||||
let mut sessions = [true, false].map(|delete| {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 700, "height": 500, "depth": depth, "background": "white"})).unwrap();
|
||||
s.execute("file.new", json!({"width": w, "height": h, "depth": depth, "background": "white"})).unwrap();
|
||||
s.execute("layer.new.layer", json!({})).unwrap();
|
||||
s.edit("paint", |doc, active| {
|
||||
let wave = |x: i32, y: i32, k: i32| ((x * 7 + y * 13 + k * 31) % 97) as f32 / 96.0;
|
||||
let all = Rect::new(0, 0, 700, 500);
|
||||
let all = Rect::new(0, 0, w, h);
|
||||
let rgba: Vec<f32> = pixels().flat_map(|(x, y)| [wave(x, y, 0), wave(x, y, 1), wave(x, y, 2), wave(y, x, 3)]).collect();
|
||||
let gray: Vec<f32> = pixels().map(|(x, y)| wave(y, x, 4)).collect();
|
||||
let l = doc.layer_mut(active.unwrap()).unwrap();
|
||||
@@ -824,7 +826,7 @@ fn turned_crop_deleting_pixels_matches_turning_the_whole_canvas() {
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let p = json!({"x": 150, "y": 120, "width": 330, "height": 290, "angle": angle, "deleteCroppedPixels": delete});
|
||||
let p = json!({"x": 30 * scale, "y": 24 * scale, "width": 66 * scale, "height": 58 * scale, "angle": angle, "deleteCroppedPixels": delete});
|
||||
s.execute("image.crop", p).unwrap();
|
||||
s
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ fn fixture(depth: u8) -> (Session, [LayerId; 4]) {
|
||||
let outer_id = outer.id;
|
||||
let other = Layer::raster("Other", doc.pixel_format());
|
||||
let other_id = other.id;
|
||||
doc.layers = vec![outer, other];
|
||||
doc.layers = vec![outer, other].into();
|
||||
Ok([outer_id, inner_id, leaf_id, other_id])
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
@@ -525,7 +525,7 @@ fn blending_options(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const CMD: &str = "layer.layerStyle.blendingOptions";
|
||||
let id = layer_param(s, p)?;
|
||||
let blend = match p.get("blend").and_then(Value::as_str) {
|
||||
Some(b) => Some(crate::commands::blend_from_str(b).ok_or_else(|| bad(CMD, format!("unknown blend mode `{b}`")))?),
|
||||
Some(b) => Some(crate::commands::parse_blend(b).ok_or_else(|| bad(CMD, format!("unknown blend mode `{b}`")))?),
|
||||
None => None,
|
||||
};
|
||||
let opacity = p.get("opacity").and_then(Value::as_f64).map(|v| (v as f32 / 100.0).clamp(0.0, 1.0));
|
||||
@@ -876,7 +876,7 @@ fn create_layer(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let mut tmp = Document::new("fx", doc.size, doc.mode, doc.depth);
|
||||
tmp.global_light = light;
|
||||
tmp.patterns = doc.patterns.clone();
|
||||
tmp.layers = vec![alone];
|
||||
tmp.layers = vec![alone].into();
|
||||
let buf = photocraft_compose::render(&tmp, area);
|
||||
let mut surf = Surface::new(fmt);
|
||||
let data: Vec<f32> = buf.px.iter().flat_map(|q| photocraft_raster::from_rgba(&fmt, *q)).collect();
|
||||
@@ -952,7 +952,7 @@ pub fn layer_document(doc: &Document, id: LayerId) -> Result<Document> {
|
||||
alone.blend = if alone.is_group() { BlendMode::PassThrough } else { BlendMode::Normal };
|
||||
alone.clipped = false;
|
||||
let mut tmp = doc.clone();
|
||||
tmp.layers = vec![alone];
|
||||
tmp.layers = vec![alone].into();
|
||||
tmp.selection = None;
|
||||
let area = doc.bounds();
|
||||
let buf = photocraft_compose::render(&tmp, area);
|
||||
|
||||
@@ -548,7 +548,7 @@ fn stack_modes_render_from_the_nested_layers() {
|
||||
let g = Layer::new("stack", LayerContent::Group(photocraft_doc::Group { children: kids, expanded: true, artboard: None, frame_stroke: None }));
|
||||
let smart = crate::smart_cmds::layer_to_smart(doc, &g)?;
|
||||
let id = smart.id;
|
||||
doc.layers = vec![smart];
|
||||
doc.layers = vec![smart].into();
|
||||
*active = Some(id);
|
||||
Ok(())
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::params::bad;
|
||||
use super::{BlendMode, Document, EngineError, Layer, LayerId, LayerMask, Result, SampleType, Session, Value};
|
||||
use super::{Document, EngineError, Layer, LayerId, LayerMask, Result, SampleType, Session, Value};
|
||||
|
||||
/// The layer a command's `"layer"` param names: an id, or a name (the topmost layer of that
|
||||
/// name, as Photoshop's "select layer by name" action step finds it, so a loaded action replays
|
||||
@@ -72,12 +72,6 @@ pub(crate) fn layer_param(s: &Session, p: &Value) -> Result<LayerId> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn blend_from_str(s: &str) -> Option<BlendMode> {
|
||||
let norm = |x: &str| x.to_ascii_lowercase().replace([' ', '_', '-', '(', ')'], "");
|
||||
let want = norm(s);
|
||||
std::iter::once(BlendMode::PassThrough).chain(BlendMode::layer_modes()).find(|m| norm(m.label()) == want || norm(&format!("{m:?}")) == want)
|
||||
}
|
||||
|
||||
/// The active selection as the mask of a layer being created, or None without a selection.
|
||||
/// Photoshop masks a new adjustment or fill layer with the selection, so the adjustment acts on
|
||||
/// the selected area only (#1250). [`mask_new_layer`] then drops the selection (#8801).
|
||||
|
||||
@@ -11,7 +11,7 @@ fn fixture(depth: u8) -> (Session, LayerId, LayerId) {
|
||||
let a = Layer::raster("A", doc.pixel_format());
|
||||
let b = Layer::group("B", vec![Layer::raster("Child", doc.pixel_format())]);
|
||||
let ids = (a.id, b.id);
|
||||
doc.layers = vec![a, b];
|
||||
doc.layers = vec![a, b].into();
|
||||
Ok(ids)
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
@@ -241,7 +241,7 @@ fn single_layer_surface(doc: &mut Document, active: &mut Option<LayerId>, mode:
|
||||
*surf = pixels;
|
||||
}
|
||||
*active = Some(l.id);
|
||||
doc.layers = vec![l];
|
||||
doc.layers = vec![l].into();
|
||||
for ch in doc.channels.iter_mut() {
|
||||
let f = PixelFormat::new(ColorMode::Grayscale, SampleType::U8, false);
|
||||
ch.surface = ch.surface.convert(PixelFormat { alpha: ch.surface.format().alpha, ..f });
|
||||
@@ -600,6 +600,11 @@ fn custom_pattern_map(s: &Session, cmd: &str, p: &Value) -> Result<(Vec<f32>, us
|
||||
}
|
||||
|
||||
fn bitmap(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
bitmap_in_bands(s, p, 0)
|
||||
}
|
||||
|
||||
/// Convert with the requested compositor band height (zero chooses its normal budget).
|
||||
fn bitmap_in_bands(s: &mut Session, p: &Value, band_rows: i32) -> Result<Value> {
|
||||
const CMD: &str = "image.mode.bitmap";
|
||||
let d = s.active().ok_or(EngineError::NoDocument)?;
|
||||
let input = f64::from(d.doc.resolution_dpi.max(1.0));
|
||||
@@ -674,7 +679,7 @@ fn bitmap(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let n = fmt.channels();
|
||||
let mut out = Surface::new(fmt);
|
||||
let (mut gray, mut data) = (Vec::new(), Vec::new());
|
||||
let _ = photocraft_compose::render_bands(doc, doc.bounds(), 0, |band| -> std::result::Result<(), std::convert::Infallible> {
|
||||
let _ = photocraft_compose::render_bands(doc, doc.bounds(), band_rows, |band| -> std::result::Result<(), std::convert::Infallible> {
|
||||
gray.clear();
|
||||
gray.extend(band.px.iter().map(|q| {
|
||||
// Over white, as the flattened image.
|
||||
|
||||
@@ -860,13 +860,13 @@ fn bitmap_pixels(d: &Document) -> Vec<f32> {
|
||||
|
||||
#[test]
|
||||
fn bitmap_in_bands_matches_one_full_canvas_conversion() {
|
||||
// #8477: the composite is converted in bands (32768 px wide: 256 rows each, so 300 rows are
|
||||
// two). Diffusion carries its error across the band edge, and pattern, halftone and custom
|
||||
// #8477: 300 rows cross a 256-row compositor band. Diffusion carries its error across the
|
||||
// band edge, and pattern, halftone and custom
|
||||
// pattern stay anchored to the image's rows: the result equals one full-canvas conversion.
|
||||
let (w, h) = (32_768u32, 300u32);
|
||||
let (w, h) = (64u32, 300u32);
|
||||
let mut s = session(w, h, 8, "grayscale");
|
||||
paint(&mut s, |x, y| {
|
||||
let v = ((x % 509) as f32 / 509.0 * 0.6 + (y as f32 / 300.0) * 0.4).fract();
|
||||
let v = ((x % 61) as f32 / 61.0 * 0.6 + (y as f32 / 300.0) * 0.4).fract();
|
||||
[v, v, v, 1.0]
|
||||
});
|
||||
add_pattern(&mut s, "Cells", 3, 2, &[10, 200, 90, 250, 150, 40]);
|
||||
@@ -888,7 +888,7 @@ fn bitmap_in_bands_matches_one_full_canvas_conversion() {
|
||||
if method == "customPattern" {
|
||||
p["pattern"] = json!("Cells");
|
||||
}
|
||||
s.execute("image.mode.bitmap", p.clone()).unwrap();
|
||||
bitmap_in_bands(&mut s, &p, 256).unwrap();
|
||||
let want = match method {
|
||||
"halftone" => {
|
||||
let cell = (before.resolution_dpi / 53.0).max(2.0);
|
||||
@@ -902,6 +902,9 @@ fn bitmap_in_bands_matches_one_full_canvas_conversion() {
|
||||
};
|
||||
// Grayscale stores 0/1 the way `from_rgba` turns the old RGBA output into gray.
|
||||
let want: Vec<f32> = want.iter().map(|g| photocraft_raster::from_rgba(&storage_format(ColorMode::Bitmap), [*g, *g, *g, 1.0])[0]).collect();
|
||||
if method == "threshold" {
|
||||
assert!(want.contains(&0.0) && want.contains(&1.0), "the gradient crosses the threshold");
|
||||
}
|
||||
let got = bitmap_pixels(doc(&s));
|
||||
let diff = got.iter().zip(&want).filter(|(a, b)| (**a - **b).abs() > 1e-6).count();
|
||||
assert_eq!(diff, 0, "{method}: {diff} of {} pixels differ", got.len());
|
||||
|
||||
@@ -246,7 +246,7 @@ pub(crate) fn convert_from(s: &mut Session, mode: ColorMode, _p: &Value) -> Resu
|
||||
bg.locks.transparency = true;
|
||||
bg.locks.position = true;
|
||||
*active = Some(bg.id);
|
||||
doc.layers = vec![bg];
|
||||
doc.layers = vec![bg].into();
|
||||
doc.channels = others;
|
||||
Ok(if reinterpret { "channels" } else { "appearance" })
|
||||
})?;
|
||||
|
||||
@@ -246,7 +246,7 @@ pub(super) fn merge_group(s: &mut Session, id: LayerId) -> Result<Value> {
|
||||
solo.blend = photocraft_doc::BlendMode::Normal;
|
||||
solo.clipped = false;
|
||||
let mut tmp = doc.clone();
|
||||
tmp.layers = vec![solo];
|
||||
tmp.layers = vec![solo].into();
|
||||
let mut merged = Layer::new(group.name.clone(), LayerContent::Raster(pixels::composite_layers_uncropped(&tmp, fmt)));
|
||||
merged.id = group.id;
|
||||
merged.opacity = group.opacity;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
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};
|
||||
use crate::commands::{CommandSpec, parse_blend};
|
||||
use crate::presets::gradients;
|
||||
use crate::{EngineError, Result, Session};
|
||||
|
||||
@@ -47,7 +47,7 @@ fn fill_mode(p: &Value) -> Result<FillMode> {
|
||||
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)
|
||||
Some(Value::String(m)) => parse_blend(m)
|
||||
.filter(|m| *m != photocraft_color::BlendMode::PassThrough)
|
||||
.map(FillMode::Blend)
|
||||
.ok_or_else(|| bad(format!("unknown blend mode `{m}`"))),
|
||||
@@ -186,7 +186,7 @@ fn gradient(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
};
|
||||
let reverse = b(p, "reverse", false);
|
||||
let opacity = opacity(p, "paint.gradient")?;
|
||||
let blend = p.get("mode").and_then(Value::as_str).and_then(blend_from_str).unwrap_or(photocraft_color::BlendMode::Normal);
|
||||
let blend = p.get("mode").and_then(Value::as_str).and_then(parse_blend).unwrap_or(photocraft_color::BlendMode::Normal);
|
||||
let dither = b(p, "dither", true); // Photoshop dithers gradients by default (reduces banding).
|
||||
let layer = if p.get("layer").is_some() { Some(crate::commands::layer_param(s, p)?) } else { s.active().and_then(|st| st.active_layer) };
|
||||
s.edit("Gradient", |doc, _| {
|
||||
|
||||
@@ -325,6 +325,12 @@ pub fn default_name(s: &Session) -> String {
|
||||
const MAX_DEFINE_EDGE: u32 = 8000;
|
||||
|
||||
fn define(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let sample = s.active().ok_or(EngineError::NoDocument)?.doc.pixel_format().sample;
|
||||
define_with_max_pixels(s, p, photocraft_doc::pattern::max_paint_pixels(sample))
|
||||
}
|
||||
|
||||
/// Define a pattern with a bound on its pixel count.
|
||||
fn define_with_max_pixels(s: &mut Session, p: &Value, max_px: u64) -> Result<Value> {
|
||||
let cmd = "edit.definePattern";
|
||||
let st = s.active().ok_or(EngineError::NoDocument)?;
|
||||
let doc = &st.doc;
|
||||
@@ -345,7 +351,6 @@ fn define(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// A pattern the compositor could not hold would define but paint nothing: 8 bits go to the
|
||||
// edge limit, 16-bit documents to 33,554,432 px in all, float to 16,777,216 (4096 × 4096).
|
||||
let sample = doc.pixel_format().sample;
|
||||
let max_px = photocraft_doc::pattern::max_paint_pixels(sample);
|
||||
if u64::from(r.width()) * u64::from(r.height()) > max_px {
|
||||
return Err(bad(cmd, format!("patterns in a {}-bit document are limited to {max_px} px in all", sample.bytes() * 8)));
|
||||
}
|
||||
@@ -762,17 +767,22 @@ mod tests {
|
||||
assert!(e.contains("16-bit") && e.contains("33554432"), "{e}");
|
||||
}
|
||||
|
||||
/// A pattern of the largest area Define Pattern accepts at 8 bits is paintable: held at 4
|
||||
/// bytes a pixel, 256 MB, as the compositor's cap allows, and it renders.
|
||||
/// A pattern at the area limit is paintable and renders; production permits 8000×8000 at 8 bits.
|
||||
#[test]
|
||||
fn an_8000_by_8000_pattern_is_defined_and_paints() {
|
||||
fn a_pattern_at_the_area_limit_is_defined_and_paints() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 8000, "height": 8000, "depth": 8})).unwrap();
|
||||
assert_eq!(MAX_DEFINE_EDGE, 8000);
|
||||
assert!(photocraft_doc::pattern::max_paint_pixels(SampleType::U8) >= 8000 * 8000);
|
||||
assert_eq!(photocraft_doc::pattern::working_bytes_for(8000 * 8000, SampleType::U8), 8000 * 8000 * 4);
|
||||
let (side, max_px) = (80, 80 * 80);
|
||||
s.execute("file.new", json!({"width": side, "height": side, "depth": 8})).unwrap();
|
||||
s.execute("edit.fill", json!({"color": "#336699"})).unwrap();
|
||||
s.execute("edit.definePattern", json!({"name": "Largest"})).unwrap();
|
||||
assert!(define_with_max_pixels(&mut s, &json!({"name": "Too large"}), max_px - 1).is_err());
|
||||
define_with_max_pixels(&mut s, &json!({"name": "Largest"}), max_px).unwrap();
|
||||
let p = s.patterns.items.iter().find(|p| p.name == "Largest").unwrap();
|
||||
assert_eq!((p.width, p.height), (8000, 8000));
|
||||
assert!(p.is_paintable() && p.working_bytes() == 256_000_000);
|
||||
assert_eq!((p.width, p.height), (side, side));
|
||||
// A small pattern uses the expanded float representation, unlike the largest 8-bit one.
|
||||
assert!(p.is_paintable() && p.working_bytes() == max_px * 16);
|
||||
s.execute("file.new", json!({"width": 40, "height": 30, "depth": 8})).unwrap();
|
||||
s.execute("layer.newFillLayer.pattern", json!({"pattern": "Largest"})).unwrap();
|
||||
let [r, g, b, a] = pixel(&s, 5, 5);
|
||||
|
||||
@@ -8,12 +8,15 @@
|
||||
//! Background over the background colour where the quad reaches past the image, and pixels outside
|
||||
//! the quad are deleted (Photoshop's Perspective Crop has no Delete Cropped Pixels option).
|
||||
//!
|
||||
//! Type, shape, fill and smart object layers are rasterized first: a projective map has no
|
||||
//! editable equivalent for them. Vector masks, paths, notes, slices and guides follow the affine
|
||||
//! map closest to the homography (exact when the quad is a parallelogram).
|
||||
//! A document holding a type layer or a smart object anywhere, and a Bitmap mode document, are
|
||||
//! refused with the tool's alerts ([`UNSUPPORTED_LAYERS_ERROR`] and [`BITMAP_MODE_ERROR`], #11799)
|
||||
//! before anything is rasterized or warped, so the document stays exactly as it was. Shape and fill
|
||||
//! layers are rasterized first: a projective map has no editable equivalent for them (keeping them
|
||||
//! live is #11800). Vector masks, paths, notes, slices and guides follow the affine map closest to
|
||||
//! the homography (exact when the quad is a parallelogram).
|
||||
|
||||
use photocraft_algo::transform::{Homography, Interp, convex_quad_any_winding, quad_free_size, quad_size, quad_to_rect, warp_surface_clipped};
|
||||
use photocraft_color::PixelFormat;
|
||||
use photocraft_color::{ColorMode, PixelFormat};
|
||||
use photocraft_doc::{Document, Layer, LayerContent, LayerId, Size};
|
||||
use photocraft_geom::{Affine, Rect};
|
||||
use photocraft_raster::Surface;
|
||||
@@ -31,6 +34,34 @@ const MAX_COORD: f64 = 1e7;
|
||||
/// (#11977).
|
||||
const MAX_RESOLUTION: f64 = 29_999.999;
|
||||
|
||||
/// The reference's alert when the document holds a layer the tool can't map (#11799): an alert with
|
||||
/// only an OK button on the tool's first press. The UI shows this text through `tl!` (English is
|
||||
/// the catalog source); the command returns it as its error.
|
||||
pub const UNSUPPORTED_LAYERS_ERROR: &str = "Could not use the perspective crop tool because the image contains unsupported layers types.";
|
||||
/// The reference's alert for a Bitmap mode document (#11799), shown the same way.
|
||||
pub const BITMAP_MODE_ERROR: &str =
|
||||
"Could not use the perspective crop tool because it does not work with Bitmap images (convert image to Grayscale mode to edit).";
|
||||
|
||||
/// Does `doc` hold a layer the perspective crop can't map: a type layer or a smart object, anywhere
|
||||
/// in it - visible or hidden, active or not, also inside a group (#11799)? The alert is about the
|
||||
/// document, not the targeted layer. Shape, fill, adjustment, pixel and group layers do not refuse
|
||||
/// it (measured); keeping shape and fill layers live is #11800.
|
||||
pub fn has_unsupported_layers(doc: &Document) -> bool {
|
||||
doc.walk().iter().any(|(_, _, l)| matches!(l.content, LayerContent::Text(_) | LayerContent::Smart(_)))
|
||||
}
|
||||
|
||||
/// The alert `doc` gets instead of a perspective crop, or `None` when the crop can go through
|
||||
/// (#11799). The text is exactly what `image.perspectiveCrop` answers with, so the tool can refuse
|
||||
/// the press with what the command would later refuse. Bitmap is checked first: converting to
|
||||
/// Bitmap flattens the document (`mode_cmds`), so a Bitmap document never holds a type layer or a
|
||||
/// smart object and the order is not observable.
|
||||
pub fn refusal(doc: &Document) -> Option<&'static str> {
|
||||
if doc.mode == ColorMode::Bitmap {
|
||||
return Some(BITMAP_MODE_ERROR);
|
||||
}
|
||||
has_unsupported_layers(doc).then_some(UNSUPPORTED_LAYERS_ERROR)
|
||||
}
|
||||
|
||||
fn bad(msg: impl Into<String>) -> EngineError {
|
||||
EngineError::BadParams { cmd: CMD.into(), msg: msg.into() }
|
||||
}
|
||||
@@ -224,12 +255,15 @@ fn perspective_crop(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let res = resolution(p)?;
|
||||
let interp = interpolation(p)?;
|
||||
let d = s.active().ok_or(EngineError::NoDocument)?;
|
||||
// #11799: what the reference answers with an alert, it answers before it touches anything: no
|
||||
// rasterization, no warp, no history step. The tool shows the same text on the press.
|
||||
if let Some(msg) = refusal(&d.doc) {
|
||||
return Err(EngineError::Other(msg.into()));
|
||||
}
|
||||
crate::image_cmds::check_resample_budget(CMD, &d.doc, w, h, "")?;
|
||||
let rasterize = d
|
||||
.doc
|
||||
.walk()
|
||||
.iter()
|
||||
.any(|(_, _, l)| matches!(l.content, LayerContent::Text(_) | LayerContent::Shape(_) | LayerContent::Fill(_) | LayerContent::Smart(_)));
|
||||
// A type layer or a smart object can't get here (they are refused above), so only shape and
|
||||
// fill layers are ever rasterized (#11800 is about keeping those live).
|
||||
let rasterize = d.doc.walk().iter().any(|(_, _, l)| matches!(l.content, LayerContent::Shape(_) | LayerContent::Fill(_)));
|
||||
let map = quad_to_rect(&q, f64::from(w), f64::from(h)).ok_or_else(|| bad("the corners don't define a perspective"))?;
|
||||
let bg = s.tools.background;
|
||||
// The Color Sampler points follow their pixels through the homography, which the edit's
|
||||
@@ -263,7 +297,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
label: "Perspective Crop",
|
||||
menu: &[],
|
||||
shortcut: None,
|
||||
params: r##"{"corners":[[x,y],[x,y],[x,y],[x,y]] (top-left, top-right, bottom-right, bottom-left; a convex quad, document px),"width":px,"height":px,"resolution":ppi,"interpolation":"bicubic|bilinear|nearest"="bicubic"} → {width,height,resolution,corners} (the quad is mapped onto an upright width x height canvas, all layers, one undo step; no width/height: the rectangle the quad shows in perspective, one alone keeps its proportions; type, shape, fill and smart object layers are rasterized)"##,
|
||||
params: r##"{"corners":[[x,y],[x,y],[x,y],[x,y]] (top-left, top-right, bottom-right, bottom-left; a convex quad, document px),"width":px,"height":px,"resolution":ppi,"interpolation":"bicubic|bilinear|nearest"="bicubic"} → {width,height,resolution,corners} (the quad is mapped onto an upright width x height canvas, all layers, one undo step; no width/height: the rectangle the quad shows in perspective, one alone keeps its proportions; shape and fill layers are rasterized; refused with the tool's alert, and nothing changes: a document holding a type layer or a smart object anywhere, hidden or inside a group included, answers "Could not use the perspective crop tool because the image contains unsupported layers types.", a Bitmap mode document "Could not use the perspective crop tool because it does not work with Bitmap images (convert image to Grayscale mode to edit).")"##,
|
||||
enabled: has_doc,
|
||||
run: perspective_crop,
|
||||
journal: true,
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
//! #11799: the Perspective Crop refuses a document that holds a type layer or a smart object, and
|
||||
//! a Bitmap mode document, with the reference application's alerts, before anything is rasterized
|
||||
//! or warped. Nothing about the document changes on a refusal: no history step, no warped pixels,
|
||||
//! and the other layers keep their kind.
|
||||
//!
|
||||
//! Measured (issue #11799): the alert fires for the *document*, not the active layer, so a type
|
||||
//! layer or a smart object counts wherever it sits - visible or hidden, active or not, also inside
|
||||
//! a group. A Levels adjustment layer, a Color Fill layer, a rectangle shape layer, a group, a
|
||||
//! mask, a style, a locked and a hidden layer do not trigger it: those documents still crop.
|
||||
//! Keeping shape and fill layers live instead of rasterizing them is #11800, so this file pins
|
||||
//! only that they still crop.
|
||||
|
||||
use photocraft_doc::{Color, ColorMode, Document, Fill, Group, Layer, LayerContent, SampleType, ShapeLayer, Size, SmartObject, SmartSource, TextLayer};
|
||||
use photocraft_geom::{Affine, Rect};
|
||||
use photocraft_raster::Surface;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::Session;
|
||||
|
||||
/// What the reference shows (an alert with one OK button) for a type layer or a smart object.
|
||||
const UNSUPPORTED: &str = "Could not use the perspective crop tool because the image contains unsupported layers types.";
|
||||
/// What it shows for a Bitmap mode document.
|
||||
const NOT_BITMAP: &str = "Could not use the perspective crop tool because it does not work with Bitmap images (convert image to Grayscale mode to edit).";
|
||||
|
||||
const CMD: &str = "image.perspectiveCrop";
|
||||
/// A skewed quad on the 160 x 120 fixture, and the upright output it is mapped onto.
|
||||
const QUAD: [[f64; 2]; 4] = [[30.0, 12.0], [140.0, 25.0], [128.0, 110.0], [14.0, 95.0]];
|
||||
|
||||
fn crop_params() -> Value {
|
||||
json!({"corners": QUAD, "width": 100, "height": 80})
|
||||
}
|
||||
|
||||
fn rgb_format() -> photocraft_color::PixelFormat {
|
||||
Document::with_background("f", Size::new(2, 2), ColorMode::Rgb, SampleType::U8, Color::WHITE).pixel_format()
|
||||
}
|
||||
|
||||
/// 160 x 120 RGB/8 with a white Background and `extra` on top, in a fresh session: nothing has
|
||||
/// been edited yet, so any history step the crop records shows up as `past_len() > 0`.
|
||||
fn session(extra: Vec<Layer>) -> Session {
|
||||
let mut doc = Document::with_background("refuse", Size::new(160, 120), ColorMode::Rgb, SampleType::U8, Color::WHITE);
|
||||
for l in extra {
|
||||
doc.insert_above(None, l);
|
||||
}
|
||||
let mut s = Session::new();
|
||||
s.add_document(doc, None);
|
||||
s
|
||||
}
|
||||
|
||||
/// A type layer reading "Hello", visible or hidden.
|
||||
fn type_layer(visible: bool) -> Layer {
|
||||
let mut l = Layer::new("Hello", LayerContent::Text(TextLayer { text: "Hello".into(), ..Default::default() }));
|
||||
l.visible = visible;
|
||||
l
|
||||
}
|
||||
|
||||
/// A smart object with a red cache and a linked source, visible or hidden.
|
||||
fn smart_layer(visible: bool) -> Layer {
|
||||
let mut cache = Surface::new(rgb_format());
|
||||
cache.fill_rect(Rect::from_xywh(20, 20, 60, 40), &[1.0, 0.0, 0.0, 1.0]);
|
||||
let mut l = Layer::new("Photo", LayerContent::Smart(SmartObject::new(SmartSource::Linked { path: "photo.psd".into() }, Affine::IDENTITY, Some(cache))));
|
||||
l.visible = visible;
|
||||
l
|
||||
}
|
||||
|
||||
/// A red rectangle shape layer: what the crop rasterizes today alongside a type layer, so a
|
||||
/// refusal that comes before the rasterize leaves it a shape.
|
||||
fn shape_layer() -> Layer {
|
||||
let path = photocraft_vector::shapes::rect(20.0, 20.0, 40.0, 30.0);
|
||||
Layer::new("Rectangle 1", LayerContent::Shape(ShapeLayer { path, fill: Some(Fill::Solid(Color::rgb(0.8, 0.2, 0.1))), ..Default::default() }))
|
||||
}
|
||||
|
||||
/// A group holding `children`, visible or hidden.
|
||||
fn group_of(children: Vec<Layer>, visible: bool) -> Layer {
|
||||
let mut l = Layer::new("Group 1", LayerContent::Group(Group { children, expanded: true, artboard: None, frame_stroke: None }));
|
||||
l.visible = visible;
|
||||
l
|
||||
}
|
||||
|
||||
/// Every layer as a refusal must leave it: name, kind, visibility and, for a type layer, its text.
|
||||
type LayerRecord = (String, &'static str, bool, String);
|
||||
|
||||
/// What a refusal must leave alone: the layers, the canvas size, the document revision, the steps.
|
||||
type Snapshot = (Vec<LayerRecord>, Size, u64, usize);
|
||||
|
||||
/// Every layer in `doc`, bottom to top. A refusal leaves this list exactly as it was, so it is both
|
||||
/// the layer-kind and the text check.
|
||||
fn fingerprint(doc: &Document) -> Vec<LayerRecord> {
|
||||
doc.walk()
|
||||
.iter()
|
||||
.map(|(_, _, l)| {
|
||||
let text = match &l.content {
|
||||
LayerContent::Text(t) => t.text.clone(),
|
||||
_ => String::new(),
|
||||
};
|
||||
(l.name.clone(), l.content.kind_name(), l.visible, text)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// What a refusal must leave alone.
|
||||
fn snapshot(s: &Session) -> Snapshot {
|
||||
let d = s.active().unwrap();
|
||||
(fingerprint(&d.doc), d.doc.size, d.revision, d.history.past_len())
|
||||
}
|
||||
|
||||
/// The document holds a type layer or a smart object, wherever it sits; every other layer keeps
|
||||
/// its kind, because the refusal comes before `rasterize_all`.
|
||||
fn assert_refused(s: &mut Session, want: &str, case: &str) {
|
||||
let before = snapshot(s);
|
||||
let err = s.execute(CMD, crop_params()).unwrap_err().to_string();
|
||||
assert_eq!(err, want, "{case}");
|
||||
let d = s.active().unwrap();
|
||||
assert_eq!(fingerprint(&d.doc), before.0, "{case}: layers unchanged");
|
||||
assert_eq!(d.doc.size, before.1, "{case}: canvas unchanged");
|
||||
assert_eq!(d.revision, before.2, "{case}: document unchanged");
|
||||
assert_eq!(d.history.past_len(), 0, "{case}: no history step");
|
||||
}
|
||||
|
||||
/// A type layer anywhere in the document - visible, hidden, or inside a group - is the reference's
|
||||
/// unsupported-layers alert, not a rasterization (#11799).
|
||||
#[test]
|
||||
fn a_type_layer_anywhere_refuses_the_perspective_crop() {
|
||||
for (case, extra) in [
|
||||
("visible", vec![type_layer(true), shape_layer()]),
|
||||
("hidden", vec![type_layer(false), shape_layer()]),
|
||||
("in a group", vec![group_of(vec![type_layer(true), shape_layer()], true), shape_layer()]),
|
||||
("in a hidden group", vec![group_of(vec![type_layer(true)], false), shape_layer()]),
|
||||
] {
|
||||
let mut s = session(extra);
|
||||
assert_refused(&mut s, UNSUPPORTED, &format!("{case} type layer"));
|
||||
let d = s.active().unwrap();
|
||||
let text: Vec<&str> = d
|
||||
.doc
|
||||
.walk()
|
||||
.iter()
|
||||
.filter_map(|(_, _, l)| match &l.content {
|
||||
LayerContent::Text(t) => Some(t.text.as_str()),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(text, ["Hello"], "{case}: the type layer is still a type layer with its text");
|
||||
assert!(d.doc.walk().iter().any(|(_, _, l)| l.content.kind_name() == "Shape"), "{case}: nothing was rasterized");
|
||||
}
|
||||
}
|
||||
|
||||
/// The same for a smart object: visible, hidden, or inside a group.
|
||||
#[test]
|
||||
fn a_smart_object_anywhere_refuses_the_perspective_crop() {
|
||||
for (case, extra) in [
|
||||
("visible", vec![smart_layer(true), shape_layer()]),
|
||||
("hidden", vec![smart_layer(false), shape_layer()]),
|
||||
("in a group", vec![group_of(vec![smart_layer(false)], true), shape_layer()]),
|
||||
] {
|
||||
let mut s = session(extra);
|
||||
assert_refused(&mut s, UNSUPPORTED, &format!("{case} smart object"));
|
||||
}
|
||||
}
|
||||
|
||||
/// Both at once is still one refusal with the same message, and still changes nothing.
|
||||
#[test]
|
||||
fn a_type_layer_and_a_smart_object_refuse_once() {
|
||||
let mut s = session(vec![type_layer(false), smart_layer(true), shape_layer()]);
|
||||
assert_refused(&mut s, UNSUPPORTED, "type layer and smart object");
|
||||
}
|
||||
|
||||
/// A Bitmap mode document is the reference's Bitmap alert (#11799).
|
||||
#[test]
|
||||
fn a_bitmap_document_refuses_the_perspective_crop() {
|
||||
let doc = Document::with_background("bitmap", Size::new(160, 120), ColorMode::Bitmap, SampleType::U8, Color::WHITE);
|
||||
let mut s = Session::new();
|
||||
s.add_document(doc, None);
|
||||
assert_refused(&mut s, NOT_BITMAP, "Bitmap document");
|
||||
}
|
||||
|
||||
/// The measured rows that keep working: a document of only pixel, adjustment, Color Fill, shape
|
||||
/// and group layers still crops, in one undo step (#11799). Whether the shape and the fill stay
|
||||
/// live is #11800, so this pins the crop, not their kind.
|
||||
#[test]
|
||||
fn pixel_adjustment_fill_shape_and_group_layers_still_crop() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 800, "height": 500})).unwrap();
|
||||
s.execute("layer.newAdjustmentLayer.levels", json!({})).unwrap();
|
||||
s.execute("layer.newFillLayer.solidColor", json!({"color": "#3366cc"})).unwrap();
|
||||
s.execute("shape.create", json!({"kind": "rect", "rect": [200, 300, 150, 100], "fill": "#cc3333"})).unwrap();
|
||||
s.execute("layer.groupLayers", json!({"name": "G"})).unwrap();
|
||||
let before = s.active().unwrap().history.past_len();
|
||||
let r = s.execute(CMD, json!({"corners": [[100.0, 50.0], [700.0, 60.0], [690.0, 450.0], [110.0, 440.0]], "width": 600, "height": 400})).unwrap();
|
||||
assert_eq!((r["width"].as_u64(), r["height"].as_u64()), (Some(600), Some(400)));
|
||||
assert_eq!(s.active().unwrap().doc.size, Size::new(600, 400), "the crop went through");
|
||||
assert_eq!(s.active().unwrap().history.past_len(), before + 1, "one undo step");
|
||||
s.execute("edit.undo", json!({})).unwrap();
|
||||
assert_eq!(s.active().unwrap().doc.size, Size::new(800, 500), "one undo restores it");
|
||||
}
|
||||
|
||||
/// Only Bitmap refuses on the mode: RGB, Grayscale and CMYK documents are unaffected (#11799).
|
||||
#[test]
|
||||
fn rgb_grayscale_and_cmyk_documents_are_not_refused() {
|
||||
for mode in [ColorMode::Rgb, ColorMode::Grayscale, ColorMode::Cmyk] {
|
||||
let doc = Document::with_background("m", Size::new(160, 120), mode, SampleType::U8, Color::WHITE);
|
||||
let mut s = Session::new();
|
||||
s.add_document(doc, None);
|
||||
s.execute(CMD, crop_params()).unwrap();
|
||||
assert_eq!(s.active().unwrap().doc.size, Size::new(100, 80), "{mode:?} cropped");
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ fn add_abr_presets(s: &mut Session, p: &Value, group: String, imp: photocraft_io
|
||||
// in Photoshop, unless `replace` asks to drop that group's own presets first: the group name
|
||||
// is only the file name, and the library is outside document history (#10640).
|
||||
let group = if p.get("replace").and_then(Value::as_bool).unwrap_or(false) {
|
||||
s.tools.presets.retain(|x| x.builtin || x.group != group);
|
||||
std::sync::Arc::make_mut(&mut s.tools.presets).retain(|x| x.builtin || x.group != group);
|
||||
group
|
||||
} else {
|
||||
// One pass over the library, not one per numbered candidate.
|
||||
@@ -168,7 +168,7 @@ fn add_abr_presets(s: &mut Session, p: &Value, group: String, imp: photocraft_io
|
||||
preset.group.clone_from(&group);
|
||||
preset.name = taken.unique(&preset.name);
|
||||
names.push(preset.name.clone());
|
||||
s.tools.presets.push(preset);
|
||||
std::sync::Arc::make_mut(&mut s.tools.presets).push(preset);
|
||||
}
|
||||
s.brush_presets_changed();
|
||||
if p.get("select").and_then(Value::as_bool).unwrap_or(false)
|
||||
@@ -262,7 +262,7 @@ fn import_image(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let (v, w, h) = image_paint(&doc, cmd)?;
|
||||
let (brush, tw, th) = crate::brush_cmds::sampled_brush(cmd, &v, w, h)?;
|
||||
let name = UniqueNames::new(s.tools.presets.iter().map(|x| x.name.as_str())).unique(&name);
|
||||
s.tools.presets.push(photocraft_paint::BrushPreset {
|
||||
std::sync::Arc::make_mut(&mut s.tools.presets).push(photocraft_paint::BrushPreset {
|
||||
name: name.clone(),
|
||||
brush: brush.clone(),
|
||||
builtin: false,
|
||||
@@ -541,7 +541,7 @@ mod tests {
|
||||
// The user's own brush moved into the group.
|
||||
let mut own = s.tools.presets.iter().find(|p| p.group == "Kit").unwrap().clone();
|
||||
own.name = "My Ink".into();
|
||||
s.tools.presets.push(own);
|
||||
std::sync::Arc::make_mut(&mut s.tools.presets).push(own);
|
||||
let r = s.execute("brush.presets.importAbr", json!({"data": data, "group": "Kit"})).unwrap();
|
||||
assert_eq!(r["group"], "Kit (2)");
|
||||
let in_group = |s: &Session, g: &str| s.tools.presets.iter().filter(|p| p.group == g).count();
|
||||
|
||||
@@ -64,7 +64,7 @@ fn bake_one(s: &mut Session, id: LayerId, key: &str) -> Result<bool> {
|
||||
if !area.is_empty() {
|
||||
// Render the layer on its own with the document's settings (mode, depth, global
|
||||
// light, patterns), then put the real stack back.
|
||||
let stack = std::mem::replace(&mut doc.layers, vec![alone]);
|
||||
let stack = std::mem::replace(&mut doc.layers, vec![alone].into());
|
||||
let buf = photocraft_compose::render(doc, area);
|
||||
doc.layers = stack;
|
||||
let n = fmt.channels();
|
||||
|
||||
@@ -22,7 +22,7 @@ use photocraft_raster::{Surface, from_rgba_into, to_rgba};
|
||||
use rayon::prelude::*;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::commands::{CommandSpec, blend_from_str};
|
||||
use crate::commands::{CommandSpec, parse_blend};
|
||||
use crate::{EngineError, Result, Session};
|
||||
|
||||
mod art_history;
|
||||
@@ -411,9 +411,9 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
menu: &[],
|
||||
shortcut: None,
|
||||
params: brush_params!(
|
||||
r#","state":row (a History panel row, as history.setSource),"snapshot":id (a history.newSnapshot id; default: the History panel's source, as paint.historyBrush; a source of another canvas size or colour mode is an error),"style":"tightShort|tightMedium|tightLong|looseMedium|looseLong|dab|tightCurl|looseCurl"="tightShort","area":0..100=50,"tolerance":0..100=0,"opacity":0..100=100 (overrides the common 1..100: how strongly the history state is painted; 0 changes nothing; no flow, mode is Normal)"#
|
||||
r#","state":row (a History panel row, as history.setSource),"snapshot":id (a history.newSnapshot id; default: the History panel's source, as paint.historyBrush; a source of another canvas size or colour mode is an error),"style":"tightShort|tightMedium|tightLong|looseMedium|looseLong|dab|tightCurl|looseCurl"="tightShort","area":0..500=50,"tolerance":0..100=0,"opacity":0..100=100 (overrides the common 1..100: how strongly the history state is painted; 0 changes nothing; no flow, mode is Normal)"#
|
||||
),
|
||||
enabled: has_pixel_layer,
|
||||
enabled: art_history::enabled,
|
||||
run: art_history::run,
|
||||
journal: true,
|
||||
},
|
||||
|
||||
@@ -163,6 +163,64 @@ fn stamp_region(
|
||||
}
|
||||
}
|
||||
|
||||
/// The reference application's alerts for the refusals below (#12638); a hidden target is
|
||||
/// [`crate::hidden_target::ART_HISTORY_HIDDEN`].
|
||||
pub const LOCKED: &str = "Could not use the art history brush because the layer is locked.";
|
||||
pub const GROUP: &str = "Could not use the art history brush because the pixels in a group cannot be edited without merging the group.";
|
||||
pub const LACKS_LAYER: &str = "Could not use the art history brush because the history state lacks a corresponding layer.";
|
||||
pub const CANVAS_SIZE: &str = "Could not use the art history brush because the current canvas size does not match that of the history state.";
|
||||
pub const NO_SOURCE: &str = "Could not use the art history brush because no history state has been designated as the source for painting.";
|
||||
|
||||
/// The command's precondition: a pixel layer, as the other retouching tools, with the alert text
|
||||
/// when a group is active.
|
||||
pub(super) fn enabled(s: &Session) -> std::result::Result<(), String> {
|
||||
super::has_pixel_layer(s).map_err(|why| if crate::active_layer_of(s).is_ok_and(|l| l.is_group()) { GROUP.into() } else { why })
|
||||
}
|
||||
|
||||
/// The targeted layer's pixels can't be painted: a group's (also one with a mask, which the
|
||||
/// precondition lets through for its mask), or Lock All or Lock Image Pixels, refused with the
|
||||
/// alert texts. A mask or channel target keeps the shared checks (not measured).
|
||||
fn refuse_layer(s: &Session, id: Option<photocraft_doc::LayerId>, p: &Value) -> Result<()> {
|
||||
let (Some(id), Some(st)) = (id, s.active()) else { return Ok(()) };
|
||||
let Some(layer) = st.doc.layer(id).filter(|_| pixel_target(p)) else { return Ok(()) };
|
||||
if layer.is_group() {
|
||||
return Err(EngineError::Other(GROUP.into()));
|
||||
}
|
||||
let locks = st.doc.effective_locks(id);
|
||||
if locks.all || locks.pixels { Err(EngineError::Other(LOCKED.into())) } else { Ok(()) }
|
||||
}
|
||||
|
||||
fn pixel_target(p: &Value) -> bool {
|
||||
crate::channel_cmds::target_of(p) == crate::channel_cmds::Target::Pixels
|
||||
}
|
||||
|
||||
/// The source the stroke paints from, the History Brush's (the `state` or `snapshot` passed, else
|
||||
/// the History panel's source, through the shared [`super::history_source`]), refused with the
|
||||
/// alert texts: no source, then another canvas size, then another colour mode or a depth but 8
|
||||
/// bits ([`refuse_format`]), then a target layer the source state lacks. A mask or channel target
|
||||
/// keeps the History Brush's texts for the source refusals (not measured).
|
||||
fn source_surface(s: &Session, id: Option<photocraft_doc::LayerId>, p: &Value) -> Result<photocraft_raster::Surface> {
|
||||
use crate::history_source_cmds::{SourceRefusal, checked_source, paint_source};
|
||||
let st = s.active().ok_or(EngineError::NoDocument)?;
|
||||
let pixels = pixel_target(p);
|
||||
let doc = if pixels {
|
||||
checked_source(st, p, CMD)?.map_err(|why| {
|
||||
EngineError::Other(
|
||||
match why {
|
||||
SourceRefusal::NoSource => NO_SOURCE,
|
||||
SourceRefusal::CanvasSize { .. } => CANVAS_SIZE,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
})?
|
||||
} else {
|
||||
paint_source(st, p, CMD)?
|
||||
};
|
||||
refuse_format(&st.doc, &doc)?;
|
||||
super::history_source(s, id, p, CMD)
|
||||
.map_err(|e| if pixels && crate::channel_cmds::read_target_surface(&doc, id, p).is_err() { EngineError::Other(LACKS_LAYER.into()) } else { e })
|
||||
}
|
||||
|
||||
/// A source of another colour mode, then any document but an 8-bit one, refused with the reference
|
||||
/// application's alert texts (#12637). The 16-bit text was seen with one layer only; two layers,
|
||||
/// or a depth change after the source, showed "not directly editable", so that text covers every
|
||||
@@ -204,7 +262,8 @@ pub fn run(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let hardness = ranged(p, "hardness", s.tools.brush.hardness * 100.0, 0.0, 100.0)? / 100.0;
|
||||
let opacity = ranged(p, "opacity", 100.0, 0.0, 100.0)? / 100.0;
|
||||
let flow = ranged(p, "flow", 100.0, 0.0, 100.0)? / 100.0;
|
||||
let area = ranged(p, "area", 50.0, 0.0, 100.0)?;
|
||||
// Area takes 0..500 px, as the reference's field does (#12630).
|
||||
let area = ranged(p, "area", 50.0, 0.0, 500.0)?;
|
||||
// Percent of the channel range; 0 (paint everywhere) is the default, as in Photoshop.
|
||||
let tolerance = ranged(p, "tolerance", 0.0, 0.0, 100.0)? / 100.0;
|
||||
let style = style_of(p)?;
|
||||
@@ -215,13 +274,9 @@ pub fn run(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
let (stroke, id) = parse_brush(s, p, CMD)?;
|
||||
let _ = stroke;
|
||||
// The same source as the History Brush: the `state` or `snapshot` passed, else the History
|
||||
// panel's source, refused after a canvas size change, then after a colour mode change (#12826)
|
||||
// or at a depth other than 8 bits, as Photoshop does, before a layer missing from it. Compare
|
||||
// document modes: the pixel format reads Indexed and Multichannel as RGB.
|
||||
let st = s.active().ok_or(EngineError::NoDocument)?;
|
||||
refuse_format(&st.doc, &*crate::history_source_cmds::paint_source(st, p, CMD)?)?;
|
||||
let src_surface = super::history_source(s, id, p, CMD)?;
|
||||
refuse_layer(s, id, p)?;
|
||||
// Compare document modes: the pixel format reads Indexed and Multichannel as RGB (#12826).
|
||||
let src_surface = source_surface(s, id, p)?;
|
||||
// Truncating a huge row index only changes the seed.
|
||||
let seed = RNG_SEED ^ p.get("state").and_then(Value::as_u64).map_or(0, |i| i as u32);
|
||||
let dabs = art_history::place_dabs(&pts, size, area, style, seed).map_err(|e| match e {
|
||||
@@ -567,3 +622,7 @@ mod art_history_mode_mismatch_tests;
|
||||
#[cfg(test)]
|
||||
#[path = "art_history_depth_tests.rs"]
|
||||
mod art_history_depth_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "art_history_refusal_tests.rs"]
|
||||
mod refusal_tests;
|
||||
@@ -0,0 +1,172 @@
|
||||
//! The Art History Brush's refusals use the reference application's alert texts (#12638): a
|
||||
//! hidden target, Lock All or Lock Image Pixels, a group, a target layer the source state lacks,
|
||||
//! another canvas size and no source. Each adds no history state and changes no pixel, and the
|
||||
//! History Brush keeps its own texts.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::{CANVAS_SIZE, GROUP, LACKS_LAYER, LOCKED, NO_SOURCE};
|
||||
use crate::Session;
|
||||
use crate::hidden_target::{ART_HISTORY_HIDDEN, HIDDEN};
|
||||
|
||||
/// An RGB document with a red "Layer 1" above the white Background, the layer active. History
|
||||
/// rows: 0 Open, 1 New Layer, 2 Fill.
|
||||
fn session() -> (Session, u64) {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 48, "height": 32, "background": "white"})).unwrap();
|
||||
let id = s.execute("layer.new.layer", json!({})).unwrap()["layer"].as_u64().unwrap();
|
||||
s.execute("edit.fill", json!({"color": "#ff0000"})).unwrap();
|
||||
(s, id)
|
||||
}
|
||||
|
||||
fn stroke(cmd: &str) -> Value {
|
||||
let mut p = json!({"points": [[8, 16], [40, 16]], "size": 12, "hardness": 100});
|
||||
if cmd == "paint.artHistoryBrush" {
|
||||
p["style"] = json!("tightMedium");
|
||||
}
|
||||
p
|
||||
}
|
||||
|
||||
/// Runs `cmd` with `extra` params, expects a refusal and returns its text, checking that the
|
||||
/// document and its history are unchanged.
|
||||
fn refused(s: &mut Session, cmd: &str, extra: Value) -> String {
|
||||
let mut p = stroke(cmd);
|
||||
if let Some(map) = extra.as_object() {
|
||||
for (k, v) in map {
|
||||
p[k] = v.clone();
|
||||
}
|
||||
}
|
||||
let (doc, steps) = (s.active().unwrap().doc.clone(), s.active().unwrap().history.entries().len());
|
||||
let e = s.execute(cmd, p).unwrap_err().to_string();
|
||||
let st = s.active().unwrap();
|
||||
assert_eq!(st.history.entries().len(), steps, "{cmd}: no history state for {e}");
|
||||
for l in &doc.layers {
|
||||
assert_eq!(st.doc.layer(l.id).and_then(|n| n.surface()), l.surface(), "{cmd}: no pixel changes for {e}");
|
||||
}
|
||||
e
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_hidden_target_layer() {
|
||||
let (mut s, id) = session();
|
||||
s.execute("layer.setProps", json!({"layer": id, "visible": false})).unwrap();
|
||||
assert_eq!(refused(&mut s, "paint.artHistoryBrush", json!({})), ART_HISTORY_HIDDEN);
|
||||
assert_eq!(refused(&mut s, "paint.historyBrush", json!({})), HIDDEN);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lock_all_or_lock_image_pixels() {
|
||||
for key in ["all", "pixels"] {
|
||||
let (mut s, id) = session();
|
||||
s.execute("layer.setProps", json!({"layer": id, "locks": {key: true}})).unwrap();
|
||||
assert_eq!(refused(&mut s, "paint.artHistoryBrush", json!({})), LOCKED, "{key}");
|
||||
// Row 1 holds Layer 1, so the History Brush gets as far as the lock.
|
||||
let e = refused(&mut s, "paint.historyBrush", json!({"state": 1}));
|
||||
assert!(e.contains("Could not complete your request because the layer \"Layer 1\" is locked"), "{key}: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Lock Transparent Pixels was not measured: it still paints, as before.
|
||||
#[test]
|
||||
fn lock_transparent_pixels_still_paints() {
|
||||
let (mut s, id) = session();
|
||||
s.execute("edit.fill", json!({"color": "#0000ff"})).unwrap();
|
||||
s.execute("layer.setProps", json!({"layer": id, "locks": {"transparency": true}})).unwrap();
|
||||
s.execute("paint.artHistoryBrush", json!({"points": [[8, 16], [40, 16]], "size": 12, "hardness": 100, "state": 2})).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_group_is_active() {
|
||||
let (mut s, _) = session();
|
||||
s.execute("layer.groupLayers", json!({})).unwrap();
|
||||
let e = refused(&mut s, "paint.artHistoryBrush", json!({}));
|
||||
assert!(e.contains(GROUP), "{e}");
|
||||
assert!(!s.is_enabled("paint.artHistoryBrush"));
|
||||
assert_eq!(s.disabled_reason("paint.artHistoryBrush").as_deref(), Some(GROUP));
|
||||
let e = refused(&mut s, "paint.historyBrush", json!({}));
|
||||
assert!(e.contains("not a pixel layer") && !e.contains("art history"), "{e}");
|
||||
}
|
||||
|
||||
/// Row 1 (New Layer) holds the Background and Layer 1; a second layer added after it is missing.
|
||||
#[test]
|
||||
fn the_source_state_lacks_the_target_layer() {
|
||||
let (mut s, _) = session();
|
||||
s.execute("layer.new.layer", json!({})).unwrap();
|
||||
assert_eq!(refused(&mut s, "paint.artHistoryBrush", json!({"state": 1})), LACKS_LAYER);
|
||||
// The History panel's source too.
|
||||
s.execute("history.setSource", json!({"state": 1})).unwrap();
|
||||
assert_eq!(refused(&mut s, "paint.artHistoryBrush", json!({})), LACKS_LAYER);
|
||||
let e = refused(&mut s, "paint.historyBrush", json!({}));
|
||||
assert!(e.contains("the target did not exist"), "{e}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_canvas_size_changed() {
|
||||
let (mut s, _) = session();
|
||||
s.execute("image.canvasSize", json!({"width": 60, "height": 32, "anchor": "topLeft"})).unwrap();
|
||||
assert_eq!(refused(&mut s, "paint.artHistoryBrush", json!({})), CANVAS_SIZE);
|
||||
assert_eq!(refused(&mut s, "paint.artHistoryBrush", json!({"state": 1})), CANVAS_SIZE);
|
||||
let e = refused(&mut s, "paint.historyBrush", json!({}));
|
||||
assert!(e.contains("does not match that of the History Brush source (48×32)"), "{e}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_source_is_set() {
|
||||
let (mut s, _) = session();
|
||||
let snap = s.execute("history.newSnapshot", json!({})).unwrap()["snapshot"].clone();
|
||||
s.execute("history.setSource", json!({"snapshot": snap})).unwrap();
|
||||
s.execute("history.deleteSnapshot", json!({"snapshot": snap})).unwrap();
|
||||
assert_eq!(refused(&mut s, "paint.artHistoryBrush", json!({})), NO_SOURCE);
|
||||
let e = refused(&mut s, "paint.historyBrush", json!({}));
|
||||
assert!(e.contains("the History Brush source was deleted"), "{e}");
|
||||
}
|
||||
|
||||
/// No source and another canvas size: the missing source is reported, as before.
|
||||
#[test]
|
||||
fn no_source_comes_before_the_canvas_size() {
|
||||
let (mut s, _) = session();
|
||||
let snap = s.execute("history.newSnapshot", json!({})).unwrap()["snapshot"].clone();
|
||||
s.execute("history.setSource", json!({"snapshot": snap})).unwrap();
|
||||
s.execute("history.deleteSnapshot", json!({"snapshot": snap})).unwrap();
|
||||
s.execute("image.canvasSize", json!({"width": 60, "height": 32, "anchor": "topLeft"})).unwrap();
|
||||
assert_eq!(refused(&mut s, "paint.artHistoryBrush", json!({})), NO_SOURCE);
|
||||
}
|
||||
|
||||
/// The checks don't stop a stroke that may paint: row 2 is the red layer, now blue.
|
||||
#[test]
|
||||
fn a_valid_stroke_still_paints() {
|
||||
let (mut s, _) = session();
|
||||
s.execute("edit.fill", json!({"color": "#0000ff"})).unwrap();
|
||||
let steps = s.active().unwrap().history.entries().len();
|
||||
s.execute("paint.artHistoryBrush", json!({"points": [[8, 16], [40, 16]], "size": 12, "hardness": 100, "state": 2})).unwrap();
|
||||
assert_eq!(s.active().unwrap().history.entries().len(), steps + 1);
|
||||
}
|
||||
|
||||
/// A group with a mask passes the precondition (for its mask), but its pixels are still refused.
|
||||
#[test]
|
||||
fn a_group_with_a_mask_and_its_pixels_targeted() {
|
||||
let (mut s, _) = session();
|
||||
s.execute("layer.groupLayers", json!({})).unwrap();
|
||||
s.execute("layer.layerMask.revealAll", json!({})).unwrap();
|
||||
assert_eq!(refused(&mut s, "paint.artHistoryBrush", json!({"target": "pixels"})), GROUP);
|
||||
}
|
||||
|
||||
/// A mask target was not measured: a hidden layer, no source and another canvas size keep the
|
||||
/// History Brush's texts.
|
||||
#[test]
|
||||
fn a_mask_target_keeps_todays_texts() {
|
||||
let (mut s, id) = session();
|
||||
s.execute("layer.layerMask.revealAll", json!({})).unwrap();
|
||||
let mask = json!({"target": "mask"});
|
||||
s.execute("layer.setProps", json!({"layer": id, "visible": false})).unwrap();
|
||||
assert_eq!(refused(&mut s, "paint.artHistoryBrush", mask.clone()), HIDDEN);
|
||||
s.execute("layer.setProps", json!({"layer": id, "visible": true})).unwrap();
|
||||
s.execute("image.canvasSize", json!({"width": 60, "height": 32, "anchor": "topLeft"})).unwrap();
|
||||
let e = refused(&mut s, "paint.artHistoryBrush", mask.clone());
|
||||
assert!(e.contains("does not match that of the History Brush source"), "{e}");
|
||||
let snap = s.execute("history.newSnapshot", json!({})).unwrap()["snapshot"].clone();
|
||||
s.execute("history.setSource", json!({"snapshot": snap})).unwrap();
|
||||
s.execute("history.deleteSnapshot", json!({"snapshot": snap})).unwrap();
|
||||
let e = refused(&mut s, "paint.artHistoryBrush", mask);
|
||||
assert!(e.contains("the History Brush source was deleted"), "{e}");
|
||||
}
|
||||
@@ -3,7 +3,7 @@ use super::heal::history_source;
|
||||
use super::sampling::{SampleLayers, sample_layers};
|
||||
use super::{
|
||||
BlendMode, BrushSettings, Document, EngineError, LayerId, PixelFormat, Rect, Region, Result, SampleType, Session, Stroke, StrokePoint, Surface, Value,
|
||||
alpha_index, apply_coverage, bad, blend_from_str, coverage, damage_json, flag, has_pixel_layer, json, parse_brush, pattern_stamp, periodic, point,
|
||||
alpha_index, apply_coverage, bad, coverage, damage_json, flag, has_pixel_layer, json, parse_blend, parse_brush, pattern_stamp, periodic, point,
|
||||
reject_huge_stroke, run_stroke, to_rgba,
|
||||
};
|
||||
|
||||
@@ -212,7 +212,7 @@ pub(super) fn clone_result(dmg: Rect, off: (i32, i32), aligned: bool, p: &Value,
|
||||
pub(super) fn blend_param(p: &Value, cmd: &str) -> Result<BlendMode> {
|
||||
match p.get("mode").and_then(Value::as_str) {
|
||||
None => Ok(BlendMode::Normal),
|
||||
Some(m) => blend_from_str(m).ok_or_else(|| bad(cmd, format!("unknown blend mode `{m}`"))),
|
||||
Some(m) => parse_blend(m).ok_or_else(|| bad(cmd, format!("unknown blend mode `{m}`"))),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -696,12 +696,18 @@ impl ContentAwarePreview {
|
||||
/// Prepare the preview of `paint.contentAwareMove` with params `p` on the active document. Errors
|
||||
/// as the command does (bad params, nothing to move, a selection larger than the command takes).
|
||||
pub fn preview(s: &Session, p: &Value) -> Result<ContentAwarePreview> {
|
||||
preview_with_pixel_budget(s, p, PREVIEW_MAX_PIXELS)
|
||||
}
|
||||
|
||||
/// Prepare a preview with a bound on the number of pixels solved at full resolution.
|
||||
pub(crate) fn preview_with_pixel_budget(s: &Session, p: &Value, max_pixels: u64) -> Result<ContentAwarePreview> {
|
||||
let captured = crate::channel_cmds::inject_target(s, CMD, p.clone());
|
||||
let p = &captured;
|
||||
let plan = plan(s, p, PREVIEW_MARGIN)?;
|
||||
let px = |r: Rect| u64::from(r.width()) * u64::from(r.height());
|
||||
let pixels = px(plan.area).max(px(plan.dest));
|
||||
let scale = if pixels > PREVIEW_MAX_PIXELS { (PREVIEW_MAX_PIXELS as f64 / pixels as f64).sqrt() } else { 1.0 };
|
||||
let max_pixels = max_pixels.max(1);
|
||||
let scale = if pixels > max_pixels { (max_pixels as f64 / pixels as f64).sqrt() } else { 1.0 };
|
||||
let d = s.active().ok_or(EngineError::NoDocument)?;
|
||||
Ok(ContentAwarePreview { colors: crate::color_channels::target(s, p)?, doc: d.doc.clone(), plan, params: p.clone(), scale })
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::sampling::{AllLayers, sample_all_layers};
|
||||
use super::{
|
||||
BlendMode, BrushSettings, Document, EngineError, Footprint, IndexedParallelIterator, LayerId, ParallelIterator, ParallelSliceMut, PixelFormat, Rect,
|
||||
Region, Result, Session, Smudge, Stroke, StrokePoint, Surface, ToneRange, Value, alpha_index, apply_dab_stroke, bad, blend_from_str, damage_json,
|
||||
dodge_burn, flag, from_rgba_into, has_pixel_layer, json, local_blur, local_sharpen, num, parse_brush, run_stroke, sponge, string, to_rgba,
|
||||
Region, Result, Session, Smudge, Stroke, StrokePoint, Surface, ToneRange, Value, alpha_index, apply_dab_stroke, bad, damage_json, dodge_burn, flag,
|
||||
from_rgba_into, has_pixel_layer, json, local_blur, local_sharpen, num, parse_blend, parse_brush, run_stroke, sponge, string, to_rgba,
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
@@ -206,7 +206,7 @@ pub(super) enum DabTool {
|
||||
fn smudge_mode(p: &Value, cmd: &str) -> Result<BlendMode> {
|
||||
use BlendMode::{Color, Darken, Hue, Lighten, Luminosity, Normal, Saturation};
|
||||
let Some(v) = p.get("mode") else { return Ok(Normal) };
|
||||
let named = v.as_str().and_then(blend_from_str).filter(|m| matches!(m, Normal | Darken | Lighten | Hue | Saturation | Color | Luminosity));
|
||||
let named = v.as_str().and_then(parse_blend).filter(|m| matches!(m, Normal | Darken | Lighten | Hue | Saturation | Color | Luminosity));
|
||||
named.ok_or_else(|| {
|
||||
let given = v.as_str().map_or_else(|| v.to_string(), str::to_owned);
|
||||
bad(cmd, format!("unknown mode `{given}` (normal|darken|lighten|hue|saturation|color|luminosity)"))
|
||||
|
||||
@@ -1650,10 +1650,11 @@ fn large_move(depth: u64) -> Session {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn content_aware_move_previews_large_selections_coarse_then_exact_at_all_depths() {
|
||||
fn content_aware_move_previews_large_selections_coarse_then_exact() {
|
||||
use crate::jobs::JobCtx;
|
||||
let p = json!({"offset": [250, 60]});
|
||||
for depth in DEPTHS {
|
||||
// The small move test covers all depths; the preview sequence needs one.
|
||||
for depth in [8] {
|
||||
let mut s = large_move(depth);
|
||||
let before = s.active().unwrap().revision;
|
||||
let job = content_aware_move_preview(&s, &p).unwrap();
|
||||
@@ -1684,9 +1685,6 @@ fn content_aware_move_previews_large_selections_coarse_then_exact_at_all_depths(
|
||||
let fine = job.refine().unwrap();
|
||||
assert!(!fine.is_coarse() && fine.refine().is_none());
|
||||
assert!(matches!(fine.run(&ctx), Err(EngineError::Cancelled)), "depth {depth}");
|
||||
if depth != 8 {
|
||||
continue;
|
||||
}
|
||||
// The refined preview is the command's result, bit for bit.
|
||||
let (exact, _) = fine.run(&JobCtx::new()).unwrap();
|
||||
assert_eq!(s.active().unwrap().revision, before);
|
||||
@@ -1700,15 +1698,21 @@ fn content_aware_move_previews_large_selections_coarse_then_exact_at_all_depths(
|
||||
#[test]
|
||||
fn content_aware_move_coarse_preview_handles_transform_extend_and_limits() {
|
||||
use crate::jobs::JobCtx;
|
||||
let s = large_move(8);
|
||||
let mut s = session(128, 64, 8, "rgb");
|
||||
paint_layer(&mut s, with_object(20, 26));
|
||||
s.execute("select.rect", json!({"x": 16, "y": 22, "width": 20, "height": 20})).unwrap();
|
||||
let px = |d: &Document, x, y| d.layers[0].surface().unwrap().rgba(x, y);
|
||||
// Transform On Drop: turned 90° about the selection's centre (210, 160), then moved; the
|
||||
// object sits at the centre, so it lands at (460, 220) either way.
|
||||
let (turned, _) = content_aware_move_preview(&s, &json!({"offset": [250, 60], "rotate": 90})).unwrap().run(&JobCtx::new()).unwrap();
|
||||
assert!(is_object(px(&turned, 460, 220)) && !is_object(px(&turned, 210, 160)));
|
||||
// A 400-pixel selection is just over the preview budget. It turns about its centre and moves.
|
||||
let preview = |p: &Value| content_aware_move::preview_with_pixel_budget(&s, p, 399);
|
||||
let job = preview(&json!({"offset": [70, 0], "rotate": 90})).unwrap();
|
||||
assert!(job.is_coarse());
|
||||
let (turned, _) = job.run(&JobCtx::new()).unwrap();
|
||||
assert!(is_object(px(&turned, 96, 32)) && !is_object(px(&turned, 26, 32)));
|
||||
// Extend keeps the original.
|
||||
let (extended, _) = content_aware_move_preview(&s, &json!({"offset": [250, 60], "mode": "extend"})).unwrap().run(&JobCtx::new()).unwrap();
|
||||
assert!(is_object(px(&extended, 460, 220)) && is_object(px(&extended, 210, 160)));
|
||||
let job = preview(&json!({"offset": [70, 0], "mode": "extend"})).unwrap();
|
||||
assert!(job.is_coarse());
|
||||
let (extended, _) = job.run(&JobCtx::new()).unwrap();
|
||||
assert!(is_object(px(&extended, 96, 32)) && is_object(px(&extended, 26, 32)));
|
||||
// Off the canvas, or past the command's own limit, is still an error.
|
||||
assert!(content_aware_move_preview(&s, &json!({"offset": [400, 0]})).is_err());
|
||||
let mut big = session(5000, 4000, 8, "rgb");
|
||||
@@ -2183,6 +2187,11 @@ live_coordinate_regression!(
|
||||
fn live_dodge_matches_the_commit_across_cells() {
|
||||
let mut s = session(200, 90, 32, "rgb");
|
||||
paint_layer(&mut s, texture);
|
||||
// About the cells' summation order, not smoothing: the live stroke is compared before its
|
||||
// release, and with the brush's default smoothing lag (#11888) the commit's end catch-up runs
|
||||
// from the trailing brush along most of the last segment. Live against commit with smoothing
|
||||
// is the hand-off tests' "smoothing" case.
|
||||
s.tools.brush.smoothing.enabled = false;
|
||||
let all = [[10.0, 40.0], [100.0, 60.0], [180.0, 40.0], [60.0, 30.0], [150.0, 70.0]];
|
||||
let pts = |v: &[[f64; 2]]| v.iter().map(|q| StrokePoint::new(q[0], q[1], 1.0)).collect::<Vec<_>>();
|
||||
let opts = |p: &[[f64; 2]]| json!({"points": p, "size": 40, "hardness": 30, "exposure": 60, "range": "midtones"});
|
||||
@@ -2314,7 +2323,7 @@ fn live_dab_batches_match_the_accumulating_renderer() {
|
||||
});
|
||||
let id = s.active().unwrap().active_layer.unwrap();
|
||||
let pre = s.active().unwrap().doc.layer(id).unwrap().surface().unwrap().clone();
|
||||
for case in ["soft", "hard", "sampled", "dynamics", "smoothing"] {
|
||||
for case in ["soft", "hard", "sampled", "dynamics", "smoothing", "smoothing_catch_up"] {
|
||||
s.tools.brush = BrushSettings::default();
|
||||
match case {
|
||||
"sampled" => s.tools.brush.tip = TipShape::Sampled(GrayTile::from_fn(9, 7, |x, y| ((x * 3 + y) % 11) as f32 / 10.0)),
|
||||
@@ -2335,6 +2344,10 @@ fn live_dab_batches_match_the_accumulating_renderer() {
|
||||
b.texture.pattern = photocraft_paint::Pattern::Tile(GrayTile::from_fn(3, 3, |x, y| (x + y) as f32 / 4.0));
|
||||
}
|
||||
"smoothing" => s.tools.brush.smoothing.amount = 0.65,
|
||||
"smoothing_catch_up" => {
|
||||
s.tools.brush.smoothing.amount = 0.65;
|
||||
s.tools.brush.smoothing.catch_up_on_end = true;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
let points = [
|
||||
|
||||
@@ -158,7 +158,7 @@ fn sampled_document(doc: &Document, active: Option<LayerId>, which: SampleLayers
|
||||
layer.fill_opacity = 1.0;
|
||||
layer.blend = photocraft_color::BlendMode::Normal;
|
||||
let mut solo = doc.clone();
|
||||
solo.layers = vec![layer];
|
||||
solo.layers = vec![layer].into();
|
||||
return Some(Cow::Owned(solo));
|
||||
}
|
||||
_ => {}
|
||||
|
||||
@@ -34,7 +34,7 @@ use photocraft_raster::Surface;
|
||||
use serde_json::{Value, json};
|
||||
use stack_cache::{Stage, StageKey};
|
||||
|
||||
use crate::commands::{CommandSpec, blend_from_str, layer_param};
|
||||
use crate::commands::{CommandSpec, layer_param, parse_blend};
|
||||
use crate::jobs::JobCtx;
|
||||
use crate::{EngineError, Result, Session};
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::rendering::{refresh_or_fail, refresh_or_fail_in};
|
||||
use super::source::source_bytes;
|
||||
use super::{
|
||||
BlendMode, Document, EngineError, Layer, LayerContent, LayerId, LayerMask, Result, Session, SmartObject, Surface, Value, bad, blend_from_str, json,
|
||||
layer_param, other,
|
||||
BlendMode, Document, EngineError, Layer, LayerContent, LayerId, LayerMask, Result, Session, SmartObject, Surface, Value, bad, json, layer_param, other,
|
||||
parse_blend,
|
||||
};
|
||||
|
||||
pub(super) fn smart(doc: &Document, id: LayerId) -> Result<&SmartObject> {
|
||||
@@ -241,7 +241,7 @@ pub(super) fn set_filter_params(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
pub(super) fn blending_options(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const CMD: &str = "layer.smartFilter.blendingOptions";
|
||||
let blend = match p.get("blend").and_then(Value::as_str) {
|
||||
Some(b) => Some(blend_from_str(b).filter(|m| *m != BlendMode::PassThrough).ok_or_else(|| bad(CMD, format!("unknown blend mode `{b}`")))?),
|
||||
Some(b) => Some(parse_blend(b).filter(|m| *m != BlendMode::PassThrough).ok_or_else(|| bad(CMD, format!("unknown blend mode `{b}`")))?),
|
||||
None => None,
|
||||
};
|
||||
let opacity = p.get("opacity").and_then(Value::as_f64).map(|o| if o > 1.0 { o / 100.0 } else { o } as f32);
|
||||
|
||||
@@ -236,7 +236,7 @@ pub fn layers_to_smart(doc: &Document, name: &str, layers: Vec<Layer>) -> Result
|
||||
}
|
||||
let has_fx = layers.iter().any(|l| any_layer(l, &|x| x.effects.enabled && !x.effects.items.is_empty()));
|
||||
let region = layers.iter().map(|l| subtree_bounds(l, canvas)).fold(canvas, |a, b| a.union(&b)).inflate(if has_fx { 256 } else { 0 });
|
||||
sub.layers = layers;
|
||||
sub.layers = layers.into();
|
||||
|
||||
let buf = photocraft_compose::render(&sub, region);
|
||||
let w = region.width() as usize;
|
||||
|
||||
@@ -285,7 +285,7 @@ fn convert_source(src: &Document, fmt: PixelFormat, raster: impl FnOnce(PixelFor
|
||||
}
|
||||
let mut doc = Document::new(src.name.clone(), src.size, src.mode, src.depth);
|
||||
doc.icc_profile = src.icc_profile.clone();
|
||||
doc.layers = vec![Layer::new("source", LayerContent::Raster(raster(src.pixel_format())))];
|
||||
doc.layers = vec![Layer::new("source", LayerContent::Raster(raster(src.pixel_format())))].into();
|
||||
if gray {
|
||||
let gray_profile = crate::color_cmds::working_profile(ColorMode::Grayscale);
|
||||
crate::color_cmds::convert_document(&mut doc, &gray_profile, craft_cms::Intent::RelativeColorimetric, true)?;
|
||||
|
||||
@@ -45,7 +45,7 @@ fn selected_pixels_become_one_editable_smart_object_in_every_mode_and_depth() {
|
||||
let mut hidden = pixel(&doc, "Hidden", Rect::new(50, 40, 58, 44), [0.2, 0.9, 0.3, 1.0]);
|
||||
hidden.visible = false;
|
||||
let ids = [a.id, b.id, hidden.id];
|
||||
doc.layers = vec![a, b, hidden];
|
||||
doc.layers = vec![a, b, hidden].into();
|
||||
let mut selection = Surface::new(PixelFormat::GRAY8);
|
||||
selection.fill_rect(Rect::new(0, 0, 12, 12), &[0.5]);
|
||||
doc.selection = Some(selection);
|
||||
@@ -99,7 +99,7 @@ fn selected_group_and_descendant_are_embedded_once() {
|
||||
let group_id = group.id;
|
||||
let b = pixel(&doc, "Outside", Rect::new(16, 0, 32, 16), [0.0, 0.0, 1.0, 1.0]);
|
||||
let b_id = b.id;
|
||||
doc.layers = vec![group, b];
|
||||
doc.layers = vec![group, b].into();
|
||||
let mut s = selected_session(doc, &[group_id, a_id, b_id]);
|
||||
convert(&mut s);
|
||||
assert_eq!(s.active().unwrap().doc.layers.len(), 1);
|
||||
@@ -120,7 +120,7 @@ fn mixed_parent_selection_keeps_unselected_siblings_and_uses_the_top_selected_pa
|
||||
let lower = Layer::group("Lower parent", vec![a, keep_a.clone()]);
|
||||
let upper = Layer::group("Upper parent", vec![b, keep_b.clone()]);
|
||||
let (lower_id, upper_id) = (lower.id, upper.id);
|
||||
doc.layers = vec![lower, upper];
|
||||
doc.layers = vec![lower, upper].into();
|
||||
let original = doc.clone();
|
||||
let mut s = selected_session(doc, &[b_id, a_id]);
|
||||
let before = flat(&s);
|
||||
@@ -144,7 +144,7 @@ fn explicit_layer_converts_only_that_layer_despite_multi_selection() {
|
||||
let a = pixel(&doc, "A", Rect::new(0, 0, 8, 8), [1.0, 0.0, 0.0, 1.0]);
|
||||
let b = pixel(&doc, "B", Rect::new(8, 0, 16, 8), [0.0, 0.0, 1.0, 1.0]);
|
||||
let (a_id, b_id) = (a.id, b.id);
|
||||
doc.layers = vec![a, b.clone()];
|
||||
doc.layers = vec![a, b.clone()].into();
|
||||
let mut s = selected_session(doc, &[a_id, b_id]);
|
||||
s.execute("layer.smartObjects.convertToSmartObject", json!({"layer": a_id.0})).unwrap();
|
||||
assert_eq!(s.active().unwrap().doc.layers.len(), 2);
|
||||
@@ -160,7 +160,7 @@ fn combined_contents_survive_native_and_psd_save_open() {
|
||||
let a = pixel(&doc, "Bottom", Rect::new(-2, 4, 20, 20), [1.0, 0.0, 0.0, 1.0]);
|
||||
let b = pixel(&doc, "Top", Rect::new(10, 8, 24, 24), [0.0, 0.0, 1.0, 1.0]);
|
||||
let ids = [a.id, b.id];
|
||||
doc.layers = vec![a, b];
|
||||
doc.layers = vec![a, b].into();
|
||||
let mut s = selected_session(doc, &ids);
|
||||
let id = LayerId(convert(&mut s));
|
||||
let original = s.active().unwrap().doc.clone();
|
||||
@@ -189,7 +189,7 @@ fn selected_ancestor_in_another_parent_cannot_remove_the_new_smart_object() {
|
||||
let lower = Layer::group("Selected parent", vec![a]);
|
||||
let upper = Layer::group("Unselected parent", vec![b, keep]);
|
||||
let (lower_id, upper_id) = (lower.id, upper.id);
|
||||
doc.layers = vec![lower, upper];
|
||||
doc.layers = vec![lower, upper].into();
|
||||
let mut s = selected_session(doc, &[lower_id, a_id, b_id]);
|
||||
let so = LayerId(convert(&mut s));
|
||||
let outer = &s.active().unwrap().doc;
|
||||
@@ -210,7 +210,7 @@ fn an_all_hidden_selection_is_rejected_without_changing_document_selection_or_hi
|
||||
a.visible = false;
|
||||
b.visible = false;
|
||||
let ids = [a.id, b.id];
|
||||
doc.layers = vec![a, b];
|
||||
doc.layers = vec![a, b].into();
|
||||
let original = doc.clone();
|
||||
let mut s = selected_session(doc, &ids);
|
||||
let err = s.execute("layer.smartObjects.convertToSmartObject", json!({})).unwrap_err();
|
||||
|
||||
Loaded 100 of 276 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user