Rect::tile_count counts a rect's tiles in u64; try_take_tiles uses it (no usize overflow on 32-bit). Surface::translated reuses one rebuilt tile for equal source-tile windows. auto_slices merges vertically adjacent runs through a hash index instead of searching the output.
Reject zero-width fixed-record arrays, borrow pixel state arrays instead of
collecting them per occurrence, charge FiEf slots, curve records and layer
name bytes across the document, bound mixed-text expansion before appending,
and cap distinct allocation-table ids (deletion records now hold no Entry).
A truncated JPEG scan under a large declared frame was filled out by the
backend to the full admitted size; reject it when the file cannot plausibly
account for the pixels. Animated WebP frames each keep a copy of the ICC
profile, so the aggregate admission now counts it.
The Ctrl+Alt / Alt+right-drag disc showed the hardness as a solid core to
`hardness × radius` and a linear fade to clear at the radius, not the brush
engine's round tip (a core, then a Gaussian shoulder). A soft tip, which
paints up to ~1.73 × its radius, faded out at the circle.
`tip_preview` now builds its rings from `photocraft_paint::tip_shape`,
`tip_falloff` and `tip_reach` in document pixels at the view's zoom: solid
to the core, the engine's falloff out to its reach.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Separable (an exact kernel, or box widths) is the blur Gaussian Blur
runs, taken from blur.rs's own functions; the CPU Gaussian is now built
from it, so a GPU operator running the same description can't drift.
OperatorRegion says which source pixels an output area reads, and
edge_extent is the edge-repeat extent the engine already used for layer
filters (now shared). Tests pin the reach to the CPU's real output and
check an output depends only on its input region.
Part of #5772 (Phase 1, step 1.1).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up (#8912): a Clone Source scaled below 100 % reads a larger
source area than the overlay covers, so a large brush's overlay overflowed
`clone_preview_periodic`'s 1024 px and vanished. The coverage window now
shrinks around the pointer until both its area and `Mapping::source_rect`
of it fit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Remove Tool's tint (while dragging, and for waiting strokes) was a hard
capsule at the brush's nominal radius, but the removal takes every pixel the
stroke's dabs touch (`remove::hole`: coverage > 0). A soft tip reaches about
1.73 × its radius, so an 80 px soft brush tinted 80 px and removed ~140 px.
The Mixer Brush, and tools whose live stroke didn't start, showed the same
hard capsule.
- `Trail::feed_reach` / `feed_stroke_reach`: the stroke's dabs (the brush
engine, as `feed_dabs`) where they reach at all, in full. Waiting strokes
keep the earlier ones' tint under them (`base`).
- Remove uses them; the Mixer Brush and the fallback trail use `feed_dabs`
(soft); Quick Selection keeps its capsule (`select.quick` reads the size).
- `Trail::feed_stroke` (the capsule for waiting strokes) is gone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review pointed out that the kept layers in the add_type_layer fixture
did not match their Txt2 objects: apply_txt2 copies kerning and the
OpenType features from the file, but photoshop_txt2 writes
MyriadPro-Regular at 12 pt while the layers were Inter at 24 pt. Since
this PR, build_txt2_at treats that as a style edit and rebuilds those
objects, so the fixture no longer exercised the unchanged-object path.
The kept layers now carry the object's font and size, and
add_type_layer asserts that each kept layer's Txt2 object is saved
unchanged. Without the font and size, that assertion fails in three of
the four tests that use the helper.
Review pointed out that READ_CHUNK bounds each read but not the total
that photocraft_format::read_file returns, so a regular linked file that
keeps growing could keep a PSD export from finishing, and growth past
the stat length grew the buffer with infallible allocations. #8601 asks
for a MAX_OPEN_BYTES limit on the shared reader, not only on the PSD
call site.
read_all_with, which backs both read_file and read_all, now:
- fails with FileTooLarge once a reader has given more than
MAX_OPEN_BYTES (256 GiB), or up front when the stat length is already
over it, so a file over the limit is never embedded truncated;
- grows the buffer past the stat length only after a probe read finds
more bytes, and with try_reserve, so a file that outgrows memory is an
OutOfMemory error and a file read exactly to its length is not
over-allocated.
The limit sits far above any document memory can hold, so opening large
PSB files is unchanged. The non-regular-file rejection is unchanged.
Tests: read::tests::reads_stop_at_the_total_limit (a file over the
limit, readers over it with any hint, a hint over it, an endless reader)
and read::tests::an_exact_hint_is_not_over_allocated.
A source replacement, a patch or a path override in either cargo config never shows up in
Cargo.lock, so the check refuses them. Both files are parsed as TOML, as Cargo reads them.
The overlay showed for the Clone Stamp only, although the Clone Source panel
drives the Healing Brush too (#8907). Clipped, it was a hard circle at the
brush radius, or a boolean mask for shaped tips, whatever the hardness, so a
soft brush previewed a hard disc while it painted a soft dab (#8908).
- `draw_clone_preview` runs for the Clone Stamp and the Healing Brush;
Pattern Preview's repeating source stays the Clone Stamp's (`wrap`).
- Clipped, the overlay's alpha is the coverage of the dab the tool paints
there (`retouch::stroke_coverage_within`): hardness, a soft tip's reach,
shaped and sampled tips. The cache keeps the brush and covered area.
A very large soft tip is cropped to the 1024 px source budget.
- `brush_cursor::tip_mask` is gone (its only user).
- snapshot example: `--hover-at X,Y` for what a tool shows under the pointer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
confirm changed the next shape's colour (and turned its stroke on) before
running shape.edit, so an edit refused for another reason than a lock,
such as a job running on the document, still changed the tool defaults.
The edit now runs first and the defaults follow only when it succeeds.
- Opening Select and Mask while it is open is an error, not a fresh workspace that
silently discards the open one's edits, strokes and settings.
- A tool edit or Refine Edge Brush stroke refused at the engine's limits no longer
stays drawn: the trail is cleared and the preview is rebuilt without it.
Addresses CodeRabbit review on #8896.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A filter run gives each band a fresh wasmi instance capped at 512 MiB of
linear memory, and ran one band per rayon worker. The cap was therefore
per instance times the thread count: one run on a 16-thread machine could
hold about 8 GiB, and a plug-in smart filter repeated that on every
re-render.
Limits gains max_total_memory_bytes (default 2 GiB), the budget for all
of one run's instances together, and Limits::parallel_bands(threads),
which allows only as many concurrent bands as max_memory_bytes fits into
that budget (at least one). Plugin::apply uses it to size its groups of
parallel bands, so with the defaults a run holds at most four instances
at the cap however many cores there are. Plug-ins configured with a
smaller per-instance cap keep every worker busy. The limit is listed in
docs/plugins.md.
Tests (crates/plugins/tests/abi.rs):
- parallel_bands_fit_the_total_memory_budget: 16 workers with the
default limits run 4 bands at once, not 16 (failed before: 16 != 4).
- one_band_at_a_time_matches_parallel_bands: a budget that holds one
instance still covers every band on an 8-thread pool, with the same
pixels as parallel bands.
Fixes#8603
Saving a PSD embeds the file a linked smart object names, and it read
that file with a bare std::fs::read. A link that names a FIFO blocked the
save forever (opening a FIFO for reading waits for a writer), and one
that names a device such as /dev/zero read until memory ran out. Every
other linked-file read already goes through photocraft_format::read_file,
which opens without blocking, refuses anything that is not a regular
file and reads in bounded chunks; the PSD exporter now uses it too. Such
a layer is written as pixels with a warning that says why, as for any
other unreadable link.
The new test psd_export::tests::a_linked_fifo_is_not_read exports a
document whose linked smart object points at a FIFO. Before the fix the
export never returned (the test times out after 30 s); now it finishes
and warns that the path is not a regular file.
Fixes#8601
display_name took precedence over sync_github_name, so the sync had no
effect. Without it, About shows the public GitHub profile name.
Raised by CodeRabbit on #8885.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Select > Select and Mask... opens a full-window workspace laid out as
Photoshop's, replacing the parameter dialog:
- options bar: tool, add/subtract, Size, Hardness (Brush), Sample All
Layers, Select Subject, Refine Hair (greyed: #2671)
- tools: Quick Selection W, Refine Edge Brush R, Brush B, Object
Selection W, Lasso and Polygonal Lasso L (one slot), Hand H, Zoom Z;
Shift+W / Shift+L cycle
- the document under its tab, shown in the chosen view
- Properties: Remember Settings, View Mode (view letters, Show Edge J,
Show Original P, Real-Time Refinement, High Quality Preview,
Transparency/Opacity, Overlay colour and Indicates), Refine Mode
(Object Aware greyed: #2788), Edge Detection, Global Refinements with
Clear Selection and Invert, Output Settings; Reset, OK, Cancel
The tools become select.refineEdge `edits` (the Refine Edge Brush its
`refineStrokes`): OK is one history step, Cancel drops everything,
Ctrl+Z undoes per edit. The preview runs in the background on a reduced
copy (full size with High Quality Preview), reusing the selection after
the edits it already applied; Real-Time Refinement previews the stroke
being drawn. A targeted layer mask is refined and output to the mask.
Closes#7069. Closes#8148.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Move tool Align buttons: 16 px glyph in the 24 px box (was 12 px)
- Document/panel overflow button: 16 px glyph in the normal text colour (was 12 px, dim)
- Save for Web: a failed preview no longer draws its error beside the pane, which
widened the dialog; the same message stays on the row above the panes
A layered TIFF stores at most MAX_EXTRA_SAMPLES (16) extra samples, but the
channel names (1006, 1045) and DisplayInfo (1077) still listed every
channel, and a Quick Mask past the cap kept its 1022 record pointing at a
sample that wasn't there. They now describe the first 16, and 1022 goes
when its channel wasn't stored. Raised by CodeRabbit on #8878.
Test: channels_past_sixteen_leave_no_resources_behind (18 alpha channels
and a Quick Mask); it fails without the fix (1006 lists 19 names).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
interleave_extras and the 16-bit and float sample copies used infallible
allocations sized by the image and its extra planes, so a save too large
for memory aborted the process. They now reserve with try_reserve_exact
and return an OutOfMemory error, which the encoder reports, as the
decoder already does through `zeroed`. Raised by CodeRabbit on #8885.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A recorded Camera Raw Filter value outside its slider's range (exposure
past +/-5, negative sharpening, ...) was imported and then clamped on
playback. It now leaves the step as a Photoshop step, using the PSD
mapping's ranges.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Photoshop reads a type layer's character style from the document's Txt2
block, not from the layer's TySh. build_txt2_at kept a Txt2 object as it
was whenever its text still matched the layer, and built new style runs
only for edited or new objects. So a type.setStyle with no text change
(font, faux bold, size, ...) was saved into the TySh but not into Txt2,
and Photoshop reopened the layer in its old style. The same setStyle
together with a type.edit did reach Photoshop, because the object then
took the edited-object path.
An object is now kept only while its style runs agree with the layer's
character runs on every key the writer regenerates: font (by name through
the block's font list), size, faux bold and italic, leading, scales,
tracking, fill colour and the OpenType keys. The auto-kern mode is still
refitted separately. A key the file's run lacks, or holds as another
type, is skipped, so an unedited save still returns the file's block byte
for byte (#2374). When a key disagrees, the object goes through the
edited-object path: the file's structure is kept, its style runs are
rebuilt from the layer, and the glyph pen positions laid out in the old
style are dropped.
Regression test: text::tests::style_only_edit_restyles_the_kept_txt2_object
builds a Photoshop-shaped Txt2 (Arial-Black, faux bold on) and checks that
an unedited layer gets the block back byte for byte, that turning faux
bold off writes /2 false, and that a font change plus faux bold off names
AppleSDGothicNeo-Heavy in the runs. It fails on main (faux bold stays
true) and passes with the fix.
The io helper add_type_layer in psd_kerning.rs now applies the file's
Txt2 to its kept layers, as opening the file does. Before, those layers
contradicted their own Txt2 objects (no salt where the object had it on),
which the old keep-whatever-the-file-had behaviour hid.
Fixes#8415
clippy::approx_constant read some measured profile values (0.4343, 1.5707, 0.318 ...) as
mistyped constants. They are measurements; allow the lint in the generated table.
A recorded Camera Raw Filter step now stays a Photoshop step when a
value it records is not a number, when its curve splits are outside
0..=100 or out of order, or when a point curve is one that
filter.cameraRaw refuses (validate_curve), instead of replaying a
different look or failing on playback.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The release playbook runs the slow platform checks nightly and on every
push to release, so a regression shows up before a release is published.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Photoshop's Properties panel records an edit of an existing Vibrance
layer with the class string id `vibrance`, not the `Vbrn` code the
adjustment table knows, so the whole Set imported as an unsupported
Photoshop step and stopped playback. Map the string class to the same
adjustment.
Fixes#8534
The generated droplet shim only needs to run as its creator, so 0700 keeps
other local accounts from reading the CLI path it invokes. The reversed
range in the arrow-key test is the case under test, not an accident.
🤖 Generated with Codebuff
Co-authored-by: Codebuff <noreply@codebuff.com>
* fix(vector): bound hostile geometry raster work
Guard geometry and tracing operations against malformed dimensions and degenerate inputs with bounded work and safe failures.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
* fix(vector): address review (knot cap on split, relative identity tol, non-vacuous test)
* revert(geom): splitting past the quilt limit is intentional (smart_map test)
* fix(geom): cap identity tolerance at 1e-6 px
---------
Co-authored-by: Codebuff <noreply@codebuff.com>
Profile::content_hash is a fixed-key 64-bit SipHash of the ICC bytes, so a
crafted profile can share another profile's hash (about 2^32 work). Two
places took an equal hash as proof of an identical profile:
- transform::cached keyed its process-wide cache on the two hashes and the
options, so a colliding profile was handed the other profile's cached
transform and converted with the wrong colours.
- Profile::same_colors returned true on equal hashes, so a colliding
profile was taken for the other one and a needed conversion was skipped.
Add Profile::same_bytes, which compares the ICC bytes (an Arc pointer check
first, then the hash, then the bytes). same_colors uses it instead of the
hash. Each transform cache entry now keeps the ICC bytes of its two
profiles; a hit counts only when they match, and a colliding pair gets its
own transform without replacing the cached entry. The transform is built
after the cache lock is released, as before.
The regression tests give Display P3 the content hash of sRGB (a stand-in
for a found collision): before the fix, same_colors called them the same
and the cache returned sRGB's transform for P3; now both see P3's colours.
Fixes#8613
Co-authored-by: John Turnbach <jturnbach@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>