Commit Graph
541 Commits
Author SHA1 Message Date
DingusMcRinkyDinkyandClaude 54ea149f2f Warp: working out a fold's order can't stall the thread pool
Tiles are drawn on the thread pool, and the first tile that meets a fold works
out the fold's order while the others that need it wait. The order's sort was
shared with the pool, so while the working thread waited for its halves the
pool could hand it another folded tile, which then waited for the order on the
same thread: the warp never finished. It needed some tiles folding and others
not, and showed about once in ten 24 MP warps on 16 threads.

The sort now runs on the working thread alone. It costs nothing measurable:
a 24 MP fold in stacking order takes 0.28 s, as before.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZbgszHyuEuWAzxaamteuU
2026-11-10 18:36:10 +01:00
DingusMcRinkyDinkyandClaude Opus 5.5 24c81eb486 Merge main into pr-fold-layers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZbgszHyuEuWAzxaamteuU
2026-11-09 21:43:36 +01:00
2999174c6b Liquify: Forward Warp and Push Left follow the pointer; stationary tools use real time (#10690)
* Liquify: Forward Warp and Push Left follow the pointer; stationary tools use real time

Forward Warp and Push Left only changed the image once every dab spacing (a twentieth of
the brush radius), so a slow drag moved in jumps. The stationary tools (Twirl, Pucker,
Bloat, ...) ticked at a fixed 30 per second and stalled while the brush crept.

Points may now carry a fourth number, the milliseconds since the previous point. A segment
ending on such a live point applies the motion left over after the last dab as a
provisional dab that is taken back before the next segment, so a slow and a fast pointer
give the same warp. The stationary tools apply the larger of elapsed time and distance
travelled. The dialog records every point live and feeds every pointer position reported
in a frame. Points without times replay exactly as before.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* cargo fmt

* Liquify: correct two comments to describe the provisional dab

* Liquify: keep a pointer detour that returns to its start; skip the provisional dab at zero strength

* Liquify: also cover a zero stroke pressure in the live-segment test

* Liquify: test that the next live segment takes back the provisional dab

* Liquify: tighten the take-back test (repaint area, continuation with strength)

* Liquify: check that the take-back covers the area the first segment repainted

* Liquify: a dab far off the field touches no nodes instead of panicking

node_span converted a far-off centre to an index before checking the overlap: the lower index saturated to usize::MAX, read back as -1 it passed the check, and the provisional dab's snapshot then subtracted past zero (debug) or sliced out of range (release). The overlap is now decided in f64 before any conversion, NaN included. Tests: a timed stroke far off the field, on both axes and every side, for every brush tool; node_span on and off the grid.

* Liquify: a frame's batched pointer moves share its time evenly

The dialog handles a frame's queued moves one after another, and each read the clock: the first got nearly the whole frame and the rest only processing time, so a stationary tool's strength and where it landed depended on how the platform batched the moves. The frame's time since the last point is now shared evenly by its moves, as if they had arrived one per frame; after a stall the frame counts for at most MAX_LIVE_MS in all, as one point would. Tests: batched and one-per-frame moves give the same field (Freeze at 10 %, Twirl, Bloat, Forward Warp); a stalled frame's moves total MAX_LIVE_MS.

---------

Co-authored-by: terminalgate <351039321+terminalgate@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 15:50:20 +01:00
David Mann 34c9662c6b Merge pull request #12421 from slafebre/fix/11798-perspective-crop-free-size
fix(engine): a free Perspective Crop takes the quad's perspective size (#11798)
2026-11-09 15:45:51 +01:00
David Mann 1372bae3ea Merge pull request #9077 from ArjenS-LA/fix/average-smart-filters
Execute Average on Smart Objects and imported PSD smart filters
2026-11-09 14:23:56 +01:00
DingusMcRinkyDinkyandClaude Opus 5.5 51760ec0be Warp: only tiles where the picture folds are drawn in the fold's order
A warp draws each tile in row order, as one that can't fold does, and notes
whether two parts of the picture meet at a pixel; only such a tile is drawn
again in the fold's order, with its layers composited, and the order is
worked out the first time a tile needs it. Without a fold the order makes no
difference, so such a warp costs what it did before folds stacked.

24 MP layer, release, best of three: main 0.22 s without a fold, 0.23 s with
one; now 0.20 s and 0.26 s (was 0.24 s and 0.29 s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZbgszHyuEuWAzxaamteuU
2026-11-09 11:32:15 +01:00
DingusMcRinkyDinkyandClaude Opus 5.5 6687b4514e Warp: a fold reads its source in parts, not one window across it
Timing a 24 MP Warp showed folds cost five times main's time (1.23 s
against 0.22 s): a tile where the dragged part lies over the rest samples
two distant parts of the source, and its one window spanned everything
between them (230 MP read per render against 31 MP). A tile's samples are
now grouped into connected regions of the source on a coarse grid, each
read as a window of its own; a tile whose samples lie close together stays
one window, without the grid. A fold's layers are kept in one linked list
per tile instead of a list per folded pixel, and the cells are sorted in
parallel.

24 MP layer, release, best of three: main 0.22 s without a fold and
0.23 s with one; before 0.28 s and 1.23 s; now 0.24 s and 0.29 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZbgszHyuEuWAzxaamteuU
2026-11-09 11:05:45 +01:00
Sven Lafebre 0a8eb9d6c8 fix(algo): keep the edges when a pixel of click error swings a free Perspective Crop (#11798)
A corner moved one pixel could take a quad across the parallel-sides limit and the output from 602 x 400 to 719 x 289. The estimate now has to survive one pixel of error on every corner, with its proportions moving by no more than 10 %. Also test the commit path with W and H empty, and a known rectangle seen by a camera model.
2026-11-09 10:22:12 +01:00
DingusMcRinkyDinky 5cb4856607 Merge remote-tracking branch 'upstream/main' into pr-fold-layers 2026-11-09 07:32:41 +01:00
Sven Lafebre 3e81a3bcc4 fix(engine): a free Perspective Crop takes the quad's perspective size (#11798)
With W and H empty the output is the rectangle the quad shows in
perspective: the width is the largest horizontal scale at a corner and
the height follows from the recovered aspect ratio. Quads whose sides
are nearly parallel, that no camera at the document centre can see as a
rectangle, or whose estimate is implausible take their longest edges.
A size set in W or H behaves as before.
2026-11-09 01:24:13 +01:00
Sven Lafebre 25d6041ab5 fix(algo): partly transparent colours keep the per-channel limit (#11995)
The spread was measured on opaque colours only, and the issue keeps
today's behaviour for partly transparent ones, in the match and in the
anti-alias fringe.
2026-11-08 22:53:30 +01:00
David Mann 0523777541 Merge origin/main into fix/average-smart-filters 2026-11-08 22:24:23 +01:00
Sven Lafebre e0ca582b97 fix(engine): the Magic Eraser measures Tolerance by colour spread (#11995)
On 8-bit RGB a pixel now matches the clicked colour when the spread of
{0, dR, dG, dB} is within the Tolerance, so opposite changes in two
channels count double and green and blue stay at Tolerance 255. The
anti-alias fringe uses the same distance. The Magic Wand, the Paint
Bucket and other modes and depths keep the per-channel limit.
2026-11-08 22:11:51 +01:00
David Mann 4e5f150eb4 Merge pull request #12146 from hectorviov/fix/wand-antialias-fringe
Magic Wand: Anti-alias keeps the region whole and softens only near-matching neighbours (#11776)
2026-11-08 19:49:41 +01:00
David Mann e5decd0b85 Merge remote-tracking branch 'origin/main' into pr-11848 2026-11-08 14:54:13 +01:00
David Mann d95faebaa3 Merge remote-tracking branch 'origin/main' into pr-9077
# Conflicts:
#	docs/gaps.md
#	docs/target-app-parity.md
2026-11-08 03:04:43 +01:00
5de6aa4e04 Merge origin/main into feat/psd-puppet-warp-2 (PR #8140)
Conflicts: psd_import.rs (main's vector_preview field kept, the SmartObject
still built as a binding so pin_puppet_meshes runs), smart_cmds/rendering.rs
(main's JobCtx argument kept next to the PR's placed_puppet_params).

Co-Authored-By: Tungtono <Tungtono@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 20:18:37 +01:00
Hector Villarreal e25be5e77b Magic Wand: Anti-alias keeps the region whole and softens only near-matching neighbours (#11776) 2026-11-07 12:00:07 -06:00
7f09b2013d Merge current main into #9077 (Average on Smart Objects)
Resolves the status-line conflicts in docs/gaps.md and
docs/target-app-parity.md (both sides kept) and the module list in
crates/engine/tests/it/main.rs.

Co-Authored-By: arjen <76012639+ArjenS-LA@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 18:48:12 +01:00
DuBearteandClaude Opus 5.5 0e0d99d0b2 fix(engine): Magic Wand Subtract and Intersect grow from the seed through the selection (#11779)
Alt-click (Subtract) and Shift+Alt-click (Intersect) with the Magic Wand
took the seed's whole region, wherever the seed was, so a click outside
the selection still cut into it. With Contiguous on, the region now
grows from the seed through selected pixels only: a seed outside the
selection subtracts nothing and intersects to nothing, and a seed
inside gives the same results as before. Contiguous off is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 01:29:32 -05:00
DingusMcRinkyDinkyandClaude Opus 5.5 d788adac8c Warp: the part a fold turns over lies on top
A fold's layers were stacked by how far the warp moved them, so the part
dragged furthest was on top. That's right for a corner, an edge or an
edge's handles dragged across the picture, but not for the middle pulled
out past an edge: there the edge row folds back over the middle and lies
on top of it. The cells a fold turns over (their outline mirrored from
where they'd be without the warp) now go on top, like a folded-back flap,
and the cells moved furthest still go on top within each kind.

cell_order takes the warped and rest positions so it can tell; the render
and Warp mode's preview both use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZbgszHyuEuWAzxaamteuU
2026-11-06 22:27:32 +01:00
Nikolai Nyegaard ec7e86b371 i18n: carry the renamed keys in the ar, bs, da, fi and sv catalogs
The five partial catalogs landed on main after this branch was cut and
still listed the renamed strings under their old keys. Rekey them the same
way as the full catalogs, point the two toolbar swatch tooltips at the
Photoshop labels, and drop the rows whose replacement key already existed.
The two selection colour-matching errors added since read color too.
2026-11-06 18:25:30 +01:00
FredApps aee46a2fc6 Merge remote-tracking branch 'origin/main' into fix/10164-final-prune-u2 2026-11-06 17:28:48 +01:00
FredApps 086c250d7c Keep final resize pruning cooperative
Visit at most four output tiles per closing work unit and honor the caller's deadline between batches. Sparse images with distant opaque corners otherwise make one final poll scan the whole resized surface.

Add a sparse-output regression at 8, 16 and 32-bit requiring multiple closing polls, identical pixels, and removal of the same empty tiles. Formatting and whitespace checks passed; compilation and test execution await hosted CI.
2026-11-06 17:28:13 +01:00
David Mann a9de7ebee8 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-06 14:03:38 +01:00
David Mann ec5eb1e2d0 Merge commit 'refs/fixprs/main' into HEAD 2026-11-06 10:21:59 +01:00
Khawar Zamman Wani 123b2032c4 Web build: Place runs a slice per frame, so a large PNG no longer freezes the page (#10164, rebased onto main)
The remaining commits of the stack, applied on top of the squash-merged #10147:

- PNG decodes in resumable steps of rows (PngDecodeRows, shared with decode_rows)
- PNG imports as a document in resumable steps (io PngImport, text metadata and
  document build in bounded steps)
- Jobs can run a slice at a time where there are no threads (StepWork,
  cooperative sessions, Session::poll_jobs)
- Place decodes, flattens and resizes in slices (PlaceSteps), reading a path
  and keeping the frame, memory gate and typed memory-budget errors main has
- The web build places dropped and picked files a slice per frame, with a
  bounded place inbox
- A measurement of the stepped place; docs for jobs without threads
2026-11-06 08:51:17 +05:30
Khawar Zamman Wani e66ca23a72 Resizing can run in resumable steps of 64 output rows 2026-11-06 08:36:46 +05:30
David Mann 4b61c8ef34 Merge commit '9bef3b2dc8b84c1b6cefc8ce0dc2b01d089cd9e8' into HEAD
# Conflicts:
#	crates/algo/src/resample/tests.rs
2026-11-06 01:58:38 +01:00
David Mann b1bd2da9d7 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/engine/src/cmd/layer_copy_cmds.rs
2026-11-06 01:33:39 +01:00
ArjenS-LA a6dc7bb86a Use the grayscale format in Average coverage regression 2026-11-05 15:59:05 -08:00
ArjenS-LA a38fc6ff5b Refresh Average Smart Filter stack and verify selection and channel values 2026-11-05 15:53:24 -08:00
David Mann 010e1a434d Merge PR #11461: Elliptical Marquee: the anti-aliased edge ramps across the pixel, matching the reference within 1 level (#11391) 2026-11-06 00:28:01 +01:00
e55e2f3577 Place decodes and fits in the background: dropping a large file no longer freezes the window (#10147)
* Place decodes, fits and renders in a background job

File > Place Embedded / Linked started with Session::start, and
Session::start_place_bytes for bytes with no path, now run the decode,
flatten, resize and SVG render on a worker (prepare_place) and insert the
layer when the job is applied (apply_place). Inline callers (execute, the
CLI, headless MCP, actions) behave and return exactly as before. Part of
#10031.

* Dropped and placed files no longer freeze the window on desktop

With background jobs on, File > Place and files dropped on the canvas start
the place as a job (JobsUi.place). Free Transform begins when the layer has
landed, a failed or cancelled place is reported and the drop queue goes on,
and a drop that arrives meanwhile waits for it. The place shows its progress
in the status bar instead of the modal dialog, so the view stays usable.
Part of #10031.

* Tests: compare place job results without the layer id

Layer ids come from a counter shared by every session, so a job and an inline place in two sessions never get the same one.

* Dropped files stay with the document they were dropped on

Each queued canvas drop now carries its document's id. A file is placed
only while that document is active: files dropped on a document in
another tab wait until it is back in view, and are discarded with a
message when it is closed. Web drops, read by the shell after the drop,
go to the document the drop landed on.

Before, the next queued file went into whichever document was active
when the previous place finished, failed or was cancelled, in the
background and inline paths alike.

* Remove the unused file_open import

* fix: address background placement review feedback

* fix: preserve drop targets and interrupt placement pixel stages

* fix: qualify placement inbox document identity

* test: wait for background placement in app drop regression

* fix: retain queued drops while external document jobs run

* test: clone rendered pixels from drop-managed buffers

* test: cover band rows channels and queued-drop resumption

* Place decodes and fits in the background: dropping a large file no longer freezes the window

Placing a file decoded, flattened and resized on the UI thread; a large PNG froze the
window for seconds (#10031). `place_bytes` is split into a session read, `prepare_place`
(decode, flatten, fit, translate, SVG render at placement scale) and `apply_place`, and
runs through `jobs::run`, so File › Place and canvas drops run on a worker with progress
and cancel. The window follows the job: status-bar progress, Free Transform when the layer
lands, and drops queued per target document.

Review fixes on the way:
- a path and byte drop queue entry records its target DocId, so files dropped on one
  document never land in another after a tab switch, and closed documents discard theirs;
- the closed-document notice stays up for a frame instead of being cleared by the next
  queued placement;
- the queue is bounded (32 files / 256 MiB) so drops waiting on another tab cannot grow it
  without limit;
- flatten and resize stop at the job's interrupt, and a place skips the modal progress
  dialog only when the status bar actually shows its progress;
- the placement's `doc` is kept only for SVG input, through the importer's `is_svg_input`;
- the interrupted-composite test uses an opaque fixture that varies by row and channel, and
  checks the composite against the layer's stored pixels.

* Place reads its file in the job, and refuses a huge canvas as before

file.placeEmbedded and file.placeLinked read the whole file in the
command before the job started, so a path dropped on the canvas or
picked in File > Place still blocked the window for the read. The place
now carries the path and reads it in prepare_place: on the job's worker
in the background, on the calling thread inline (wasm, background jobs
off), with the same read_file limit and error text. Whether the source
is a vector one is decided once it has been read.

The job's flatten check returned Other("the document canvas is too large
to flatten"), where the place used to give flattened_checked's
BadParams for file.place naming the canvas size. Both now share
check_flattenable, so the old error type and message are back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Path drops aren't capped, and a discarded drop wakes the queue

The 32-file cap on the drop queue counted path drops, which hold no
file contents while they wait, so dropping 40 files on the canvas
placed 32 and refused 8 where main placed them all. The count cap now
applies to browser drops only (each holds its whole file); the byte
budget still bounds those.

When place_next_dropped discarded a closed document's files it returned
without asking for another frame, so another document's queued files
waited for the next input event. It now requests a repaint when files
remain, keeping the one frame that shows the notice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 22:49:52 +01:00
a3c0b7258c Select Subject: keep parts that run off the image edge and detached parts near the subject (#10160)
* Select Subject: keep parts that run off the image edge and detached parts near the subject

The backdrop pass trained its colour model on the whole frame outside the first
result's box and fixed it as background, so a subject cut off by the edge (a
portrait's torso) taught the backdrop its own colour and was dropped. Frame
pixels of a side that the rest of the frame cannot explain are now left out of
the model and left to the cut; a floor or table running up the sides stays
backdrop.

The first pass also dropped every part under a fifth of the largest, losing a
head behind a thin neck or a tail. Non-speck parts next to the main one are kept.

* Select Subject: stray edge pixels stay backdrop; cache test checks the recompute

A lone odd pixel in the frame (noise, a dead pixel) is not the subject running
out of the picture: only patches of at least half a frame square are released.

The #2865 cache test asserted a bit-identical selection after painting a corner
pixel. One changed pixel can move the cut's edge slightly (the original
algorithm already did on other noise), so it now checks that the mask was
recomputed and still selects the subject.

* Test subject selection against edge and nearby clutter

* Keep narrow edge clutter out of subject selection

* Preserve cropped subject components at image edges

* Keep edge poles and diagonal streaks out of subject selection

A detached part counted as near the subject when its bounding box
overlapped the main part's margin box. A thin diagonal streak from a
corner (a cable, a rail) has a box that reaches the margin without any
of its pixels doing so, and was kept as part of the subject. A part is
now near only when some of its pixels lie inside the margin box.

A patch that runs along an image edge for two frame widths was released
from the backdrop model whatever its colour, so a pole or door frame
along a side edge next to the subject's shoulder was left to the cut,
which could grow the selection along it. A wide patch is now released
only where its extent along the edge overlaps the first-pass blob's
margin box. Beside the subject that box is cut out of the frame, so the
pole only remains above or below it and is not released, while a torso
cut off below a head (the case the release exists for) still lies under
the head's box. Requiring the subject's colour for wide patches too, or
requiring them to touch the box, would drop exactly that torso: its
colour is not in the head-only blob and it is far from the head's box.

The margin box computation moves into margin_box so subject_at_edge
and its tests share it. Tests pin the diagonal streak, the pole beside
the shoulder (on all four edges, with the cropped torso still
released) and clutter that is too far or too small.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 22:04:32 +01:00
f127459ca3 perf(algo): build Remove Tool target masks with a bounded separable dilation (#10179) (#10194)
* perf(algo): build Remove Tool target masks with a bounded separable dilation (#10179)

* docs(algo): remove::dilate no longer always runs two full-grid passes

* test(algo): shrink the square dilation tests

Exhaustive masks up to 3x3 instead of 4x4, drop the 300x200 named grid
(the smaller grids already clip at r = 200, so its oracle-cost guard goes
too), and run the path-choice tests on 600x400 and 240x240 grids.

* test(algo): a mask with more set cells than bounds keeps matches the oracle

Covers the branch where bounds drops its cell list (more than KEEP set
cells) and the direct path rescans the box.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 22:04:08 +01:00
fcb4f4e494 Grow and Similar: budget the colour index and report allocation failures (#9825)
* Select: Grow and Similar index colours under a byte budget and fail instead of aborting

ColorMatcher::new returns a Result, the colour tree is a flat node array reserved at its exact size, and Grow/Similar's mask and frontier stack use fallible allocation so a failure keeps the selection.

* Select: a 1 GiB colour index on 32-bit, and Sample All Layers reports a failed composite

The web build's 256 MiB index budget (about 4.2M colours) refused Grow and
Similar on a noisy 24 MP photo whose index fits easily; 1 GiB admits every
distinct colour of such a photo. The 64-byte charge per colour is an average,
not a worst case, so the comment now says so, and the point list the tree keeps
gives back its doubling slack once the dedupe set is gone.

Sample All Layers renders the composite inside compose, so the selection tools
now pass an allocation checkpoint before it, like the other commands that hand
big work to another crate, and a failure there keeps the selection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 22:03:48 +01:00
David MannandClaude Opus 5.5 7f151b6542 algo: filter admission counts no more workers than tiles
Since 42e92cb512 the Shape Blur admission also counts each worker's f64
prefix sums, but it charged every rayon thread even when the area has
fewer tiles. A 24 MP Shape Blur at radius 500 (24 tiles of 1024 px) was
charged for 32 workers and refused under the CLI's default 8 GiB policy,
which main still ran (5.4 GB peak measured). Workers are now capped at
the tile count, for every radius filter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 17:14:19 +01:00
David Mann a4a10166df Merge remote-tracking branch 'origin/main' into integration-batch-17
# Conflicts:
#	docs/gaps.md
2026-11-05 14:33:32 +01:00
Khawar Zamman WaniandFredApps a38e544faf Make Select and Mask refinement and previews tile-sparse (#10732)
* Make Select and Mask refinement and previews tile-sparse

* Preserve finite mask extent when copying sparse pixels

* Keep solid preview coverage shared during conversion

* Preserve alpha sharing and document sparse refinement limits

* Refine mixed tiles in bounded parallel batches

* Skip guide sampling for constant refinement halos

* Balance sparse refinement batches using measured queue size

* Preserve default alpha and cancel sparse refinement cooperatively

* Address review follow-ups: cancellation after completed flush, stroke assertions, and docstrings

* Fix merge: bind tile bytes to avoid temporary borrow in matting

---------

Co-authored-by: FredApps <fredapps@users.noreply.github.com>
2026-11-05 14:22:03 +01:00
Hamza a91aa7b888 Elliptical Marquee: anti-aliased edge ramps across the pixel as in Photoshop
An anti-aliased edge pixel held the fraction of its 4x4 sub-samples
inside (17 levels), which made the edge narrower than Photoshop's and
up to 36 levels off in the measured patch. It now ramps linearly over
the pixel's width across the edge: with F the normalised radius at the
pixel centre, coverage = clamp(0.5 - (F - 1) / (|dF/dx| + |dF/dy|)).
An axis-aligned edge gets the pixel's exact area, and a 45 degree edge
ramps over sqrt(2) px. The measured patch now matches within 1 level.

The hard edge is unchanged, and so are ellipses at most 3 px across,
which keep their sub-samples (not measured). The row-span fast path,
the shared full tiles and the run checks stay as they were.

Fixes #11391
2026-11-05 18:09:39 +05:00
David Mann 4e0d487568 Merge remote-tracking branch 'origin/main' into integration-batch-17
# Conflicts:
#	docs/gaps.md
2026-11-05 13:21:45 +01:00
David MannandClaude Opus 5.5 42e92cb512 Address review: Batch stops, rename targets, Shape Blur memory, sampler releases
- A direct Batch in a script or a CLI command list stops it when it is cancelled,
  cannot write its error log, or ran out of script steps; per-file errors alone
  still continue (CodeRabbit, outside-diff findings on automate_cmds.rs and
  photocraft-cli document.rs).
- Recorded Save steps count against the script's step budget, and a Batch whose
  files failed with the budget spent carries scriptLimitError, so Browse reports
  the failure instead of ok: true (yoriswind).
- actions.rename rewrites a named Batch, nested Play or Conditional call only if
  it resolved to the renamed action before the rename; a Batch with explicit
  steps is left alone (yoriswind: two same-named actions in different sets).
- Shape Blur's run admission counts each worker's f64 prefix sums and, for a
  custom shape, the kernel mask kept for the run plus its worst-case coverage
  runs (yoriswind).
- Every sampler that takes the primary release (Color Picker, Curves/Levels and
  Properties eyedroppers, Curves Cmd-click, Color Range) ends a transform handle
  drag and a Move drag begun before it, not only the Color Picker (#11210 review).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 13:20:01 +01:00
Khawar Zamman Wani 0350b5de16 Select sky beneath an obstructed top border (#9693)
* Select sky beneath an obstructed top border

* sky: enforce adjacent-pixel RGB constraint in obstructed fallback seeds
2026-11-05 13:16:37 +01:00
David Mann f162c19e81 Merge remote-tracking branch 'origin/main' into integration-batch-17
# Conflicts:
#	crates/ui-egui/src/control/dispatch.rs
#	crates/ui-egui/src/control/params.rs
2026-11-05 12:44:02 +01:00
Khawar Zamman Wani 66f1e8b8aa Selection: Grow and Similar match only selected colours, Grow starts from the frontier (#9673)
Thanks @wanikhawar — merging.

**Summary:** Grow and Similar now match selected colours via a BVH `ColorMatcher` (L∞ per channel) instead of one AABB that falsely included intermediate hues; only exact-zero alpha is the transparent wildcard. Contiguous Grow seeds from the selection frontier rather than every selected pixel. Tests + bench included.
2026-11-05 12:26:50 +01:00
David MannandClaude Opus 5.5 16000b01ef Address CodeRabbit review: batch 17 findings
Engine: droplet dependency capture skips disabled steps; a nested Batch
that was cancelled or could not write its error log fails the caller;
runDroplet forwards overrideOpen; actions.rename follows named Batch
steps; Batch steps inside a script count against MAX_SCRIPT_STEPS;
output claims compare destination identity; Save and Close never
replaces a read-only source. ATN: Md must be a BlnM enumeration,
adjustment-layer names must round-trip, Calculations exports a missing
blending as Multiply, Apply Image refuses unnamed-layer transparency.
Filters: Shape Blur records its resolved geometry, reserves its kernel
memory first, and reports a preparation failure as an error, not a
cancel; Crop keeps an artboard preset when the size is unchanged and
fits the board on a turned crop.

Codecs/cms/algo: zero-axis FITS image HDUs are empty; a GIF walk that
breaks off before the trailer fails closed; two-value .3dl shaper rows
are applied; fragmented custom kernels are refused and their work polls
cancellation.

UI: Conditional branches play through panel playback; paused actions
refuse to resume after being replaced; Playback Options OK validates
its fields; transform double-click ignores a hidden pivot; path boxes
snap to a stationary selection; modal blocking uses the effective tool;
a picker-consumed release clears snap lines and ends a Move drag; the
Crop preset control shows Selection and checks only it; Crop box undo
restores frame_from_selection; Bosnian fill labels.

Tests: timing asserts moved to an ignored test, plus the review's
coverage nitpicks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 11:37:38 +01:00
David Mann cf65810dda Merge remote-tracking branch 'origin/main' into integration-batch-17
# Conflicts:
#	crates/ui-egui/src/i18n/cs.tsv
#	crates/ui-egui/src/i18n/de.tsv
#	crates/ui-egui/src/i18n/el.tsv
#	crates/ui-egui/src/i18n/es.tsv
#	crates/ui-egui/src/i18n/fr.tsv
#	crates/ui-egui/src/i18n/hu.tsv
#	crates/ui-egui/src/i18n/id.tsv
#	crates/ui-egui/src/i18n/it.tsv
#	crates/ui-egui/src/i18n/ja.tsv
#	crates/ui-egui/src/i18n/ko.tsv
#	crates/ui-egui/src/i18n/nl.tsv
#	crates/ui-egui/src/i18n/pl.tsv
#	crates/ui-egui/src/i18n/pt-br.tsv
#	crates/ui-egui/src/i18n/ru.tsv
#	crates/ui-egui/src/i18n/sr.tsv
#	crates/ui-egui/src/i18n/tr.tsv
#	crates/ui-egui/src/i18n/uk.tsv
#	crates/ui-egui/src/i18n/vi.tsv
#	crates/ui-egui/src/i18n/zh-hans.tsv
#	crates/ui-egui/src/i18n/zh-hant.tsv
#	docs/gaps.md
2026-11-05 09:03:28 +01:00
Khawar Zamman WaniandFredApps 316e00a97e Bound Photomerge memory and safely reject out-of-budget jobs (#7851) (#10463)
* Reduce Photomerge input and fill memory

* Bounded working-memory budgeting and safe allocation for Photomerge

* Photomerge memory: estimate warped sizes, no RAM ceiling, shared RAM detection

- Budget is half of physical RAM (at least 1 GiB) with no 8 GiB ceiling.
- The pre-flight estimate uses each image's warped extent and the band
  grid's exact bound (band_bytes_bound), at the levels seam_blend uses.
- Auto-Blend keeps its old batching with no single-band cap.
- multiband returns a Result instead of a blank image on failure.
- Physical-memory detection moves to photocraft_engine::memory; the GPU
  budgets reuse it, so PHOTOCRAFT_RAM_MB means the same in both.
- Document memoryBudget; restore comments; tests for the band cap and the
  budget precedence.

* Photomerge: lower the blend's peak and estimate it by phase

- The band build makes its binary coverage straight from the alpha and
  writes each Laplacian level in place, so a band holds two fewer planes.
- The weight sums are freed before the collapse, which adds each level
  in place and frees it as it goes.
- The estimate is the largest phase (warp, ROIs, bands, collapse, output,
  fill) rather than the sum of all of them, and the bands get what is
  left of the budget after the ROIs and accumulators.

Every output pixel is unchanged: each change drops a plane or does the
same elementwise operation in place.

* Fix Photomerge band budget validation and fallible pyramid allocation

* Keep reference pyramid test helpers infallible

* Photomerge: bound source loading with the memory budget

Resolve the budget before any source is read, and admit each flattened
source before its surface is allocated. The accounting charges the
retained surface, the same-canvas temporary the flatten writes while the
source document is alive, and a file import's encoded bytes, with
saturating math so an overflow cannot wrap under a finite budget. Merge
to HDR Pro passes no budget and keeps its previous behaviour.

Tests cover the exact retained-plus-temporary charge, a refused source,
the within/over-budget command paths, the post-load estimate path, and
the unbudgeted HDR loader.

* Photomerge: bound source reads and imports by the remaining budget

Read each source file with what is left of the budget as its limit, lower the importer's own PSD/TIFF preflight or the flat decoders' pixel allowance to the remainder after the retained sources and encoded bytes, and refuse formats with no pre-decode estimate. Charge the decoded document's actual pixels (every layer) plus the flatten's working and output surfaces before flattening. Merge to HDR Pro keeps its unbudgeted read-and-import path.

* Remove redundant TIFF decode options update

* Clean up Photomerge budget Clippy findings

* Accept early decoder admission in source budget regression

* Photomerge: report unreadable sources as file errors; never reserve past a read limit

- A budgeted Photomerge reported a missing or unreadable source file as
  'not enough memory'. Only a file over the remaining budget, or one memory
  cannot hold, is a memory error now; others are file errors, as without a budget.
- read_all_with reserved a whole read chunk before checking the caller's limit
  for a file that grew after it was statted. It now refuses first and caps the
  reservation at the limit.

---------

Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
2026-11-05 06:23:56 +01:00
yoriswind 1720af269d Merge current main while preserving recorded Batch safeguards 2026-11-04 10:47:01 -08:00