Commit Graph
17 Commits
Author SHA1 Message Date
Sven Lafebre a9360731cc Merge remote-tracking branch 'origin/main' into fix/12938-sharpen-protect-detail
# Conflicts:
#	contributors/people.toml
2026-11-11 13:09:02 +01:00
Sven Lafebre 0f205f030b Sharpen tool: Protect Detail sharpens gently instead of doing nothing (#12938)
With Protect Detail on (the default), local_sharpen clamped each result to
the range of the pixel and its 8 neighbours, which always contains the
original value, so a step or a lone pixel did not change at all.

Protect Detail is now an unsharp mask against a wider Gaussian (sigma
2.5 px) whose differences are soft-limited to 6 levels per pass:
v + amount*d*L/(L + |d|). Uniform areas stay as they are, and Protect
Detail off is unchanged. With Protect Detail on, Strength applies once per
dab instead of being spread over the overlapping dabs, so a click at 50 %
does half of what 100 % does, as in the reference application.
2026-11-10 19:20:13 +01:00
jayzed80andClaude 165cab50ad Liquify test: document the stroke helper and the replay test
Co-Authored-By: Claude <[email protected]>
2026-11-09 20:38:58 +00:00
jayzed80andClaude 7d5f68ddc6 Liquify test: require the far-off Freeze dab to change the field
Review on #11013: the check on the reported area no longer depends on a condition.

Co-Authored-By: Claude <[email protected]>
2026-11-09 20:30:58 +00:00
jayzed80andClaude 200f38f7b6 Liquify: a huge far-off dab writes no NaN and reports the area it changed
Review on #11013. A dab whose centre and size are both huge gave infinity
over infinity for a node's distance, and the NaN slipped past the falloff
check. The changed rectangle is now worked out in f64 before the cast, so
a far-off centre with a radius reaching the image no longer reports empty.

Co-Authored-By: Claude <[email protected]>
2026-11-09 20:19:40 +00:00
jayzed80andClaude Sonnet 5.5 9fae55ae04 Merge upstream main into fix/liquify-extreme-stroke
crates/algo/tests/it/main.rs conflicted on the module list: main added
gallery_reach_extreme (the merged Filter Gallery fix, #10850) and this branch adds
liquify_extreme_stroke. Kept both, in alphabetical order. photocraft-algo: 758 unit
and 17 integration tests pass; fmt and clippy clean.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-04 00:55:20 +00:00
jayzed80andClaude Sonnet 5.5 ff0f1ba0c5 fix(algo): Liquify replays a stroke with an absurd brush size or position without overflowing
A stroke in a project file may name any f64 for its size and points. The dab turned them into
grid indexes and a snapshot margin with bare casts: a position past the grid saturated to
usize::MAX, wrapped negative as an isize, slipped past the emptiness check and underflowed the
snapshot bounds; the margin and the dirty-rect padding overflowed too. The indexes are now
clamped to the grid before the casts and the margins saturate. The new test fails without the
change (attempt to subtract with overflow at liquify.rs:496).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-03 09:27:55 +00:00
jayzed80andClaude Sonnet 5.5 4777b390c9 fix(algo): Filter Gallery draws pixels from the same clamped values as its reach
The tile halo was sized from the clamped effect values, but the pixel code still read the raw
stored ones, so a stored value past its range could have a kernel larger than its halo and show
seams where tiles meet. `run` and `Prepared::new` now clamp the stack once at the entry, so the
reach and the pixels use the same values. The new test renders every gallery filter with its
range values at three times the maximum and requires the same pixels as at the maximum; it fails
without the change (ColoredPencil first).

Addresses the CodeRabbit review on this PR.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-03 09:16:51 +00:00
jayzed80 7f5e103ff1 fix(algo): Filter Gallery reach no longer overflows on out-of-range stored effect values 2026-11-02 12:49:55 +00:00
Khawar Zamman Wani 539f5bd58f perf(algo): row-parallel local_sharpen with fast-path protect_detail (#5426) (#9651)
* perf(algo): row-parallel local_sharpen with fast-path protect_detail (#5426)

Refs #5426. Follow-up to #5499.

Cause:
While #5499 parallelized local_blur and the per-dab mix in DabTool::Focus,
local_sharpen in crates/algo/src/retouch.rs remained single-threaded.
In addition, protect_detail redundantly evaluated coordinate clamping
and strided memory lookups across 8 neighbors inside the per-channel
inner loop for every pixel in the dab. On large brush sizes (e.g. 1000–2500 px),
strokes took seconds and stalled the application.

Change:
- Process local_sharpen window rows in parallel with Rayon across threads,
  with wasm32 serial fallback matching local_blur.
- Hoist protect_detail 3x3 neighborhood offset calculations outside the
  channel loop.
- Fast-path interior pixels (x > 0 && x + 1 < w && y > 0 && y + 1 < h)
  with direct stride offsets, skipping boundary clamping entirely for >99.9%
  of pixels in large brush dabs.
- Add retouch_sharpen_exact integration test verifying bit-for-bit parity
  against the frozen scalar implementation across layouts, edges, and channels.

* bench(engine): add bench_sharpen_tool example
2026-10-29 12:11:22 -04:00
Yongjip Kim cd2b4aca0c test(liquify): expand freeze-boundary regression coverage (#8082) 2026-10-23 17:40:45 -04:00
aiongg a6428d3dfb Build each crate's integration tests as one binary
Every tests/*.rs file is its own executable that links the whole crate
graph. Move each crate's test files into tests/it/ as modules of one
tests/it/main.rs; helper modules under tests/common move with them.

These keep their own binary (own process):
- engine panic_hunt: a process-wide panic hook counts every panic.
- engine text_gamma: changes the process-wide text gamma.
- engine smart_filter_stages, mask_cache_purge: assert on global caches.
- codecs pnm_peak_memory: reads the process's peak RSS.
- photocraft mac_menu_appkit: harness = false.
2026-10-22 16:55:34 +00:00
aiongg 322a29a744 Integration: #8087 liquify source footprint test uses as_chunks_mut 2026-10-22 15:38:54 +00:00
yongjip 48fdaf7279 test(liquify): document source footprint fixtures 2026-10-21 10:01:05 +09:00
yongjip aaf3492b81 fix(liquify): include cubic overshoot in source reads 2026-10-21 08:18:18 +09:00
Skyfuller 9cc8be4392 fix(algo): keep clipped warp bounds from overflowing (#5451)
warp() computed the source-centre fallback as (x0 + x1) in i32 and the
inverse-mapped tile footprint as `floor() as i32 - 3` / `ceil() as i32 + 3`.
With a strongly skewed finite affine (for example Homography
[1, 1e12, 0, 0, 1, 0, 0, 0, 1] on a 32x32 clip) the float-to-int cast
saturates at i32::MIN/MAX and the following -3/+3 overflows, panicking in
debug builds and wrapping in release. A source rect with coordinates near
1.5e9 would overflow the centre sum the same way.

Widen the centre sum to f64 and use saturating_sub/saturating_add for the
footprint, which is intersected with src_rect afterwards anyway.

Add crates/algo/tests/warp_clipped.rs covering clipped-vs-full equivalence,
huge scale allocation, the extreme-affine footprint, and the far-origin
source centre.

Refs #3446
2026-10-14 15:03:24 -07:00
jonathanwxh-cellandjonathnwxh 5f8733c74d Speed up retouch blur convolution with exact-output coverage (#4511)
Co-authored-by: jonathnwxh <[email protected]>
2026-10-13 12:56:28 -04:00