Limit whole-selection transform traces to a padded one-million-cell grid
while preserving normal viewport caching and thin boundary samples.
Use double-precision intermediates for clipping long perspective lines.
Add regressions for large/disconnected selections and viewport accuracy
near the projective horizon. Preserve the full-resolution selection and
the transform behavior already landed in #5337.
Related: #5297, #3402.
Co-authored-by: LabDennis <341377186+LabDennis@users.noreply.github.com>
Adjustments and filters on a smart object add a smart filter, so their live
preview re-renders the smart object from its source through its placement.
The preview runs on a proxy document scaled down by k (large documents), and
proxy_document scaled the smart object's cache but left its transform (and
perspective and filter mask) in full-size document coordinates. The re-render
then came out k times too large on the proxy canvas, so the object looked
zoomed in until OK committed the full-size result.
proxy_document now scales the placement and the filter mask with the proxy.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A 16/32-bit document saved as PSD has its layers in a global Lr16/Lr32 block, which the writer put first among the global blocks. A Mtrn/Mt16/Mt32 marker kept from the opened file then followed it, and Photoshop refuses such a file (verified in Photoshop 2026 with psd-tools' transparentbg.psd re-saved both ways: Mt32 first opens, Lr32 first doesn't). The layer block now goes right after the last kept marker, as Photoshop orders them. Fixes#5068.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The Width/Height fields in Properties > Document and in the New Document
dialog clamped their shown value to at least 0.01 of the unit. A 1 x 1 px
document at 300 ppi is 0.0033 in, so showing it in inches clamped it to
0.01 in, the field reported a change and the document became 3 x 3 px
(two history steps, no user edit). The fields now accept down to 0; the
pixel conversion afterwards already clamps to at least 1 px.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
AppImageLauncher exports DESKTOPINTEGRATION even after
X-AppImage-Integrate=false makes it skip the AppImage. AppRun treated that
variable as "already integrated" and wrote no .desktop file, so the menu
stayed empty. Skip our entry only when another .desktop file's Exec already
points at this AppImage.
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: nrq6993-a11y <nrq6993-a11y@users.noreply.github.com>
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
* fix(doc): variable definitions follow layer id remapping on copy and load
A duplicated document (image.duplicate, history.newDocument) or a .pcraft
loaded with remapped ids assigned fresh layer ids but cloned VariableDef.layer
unchanged, so datasets silently drove no layer (or, after remap, a colliding
one). Remap variable targets through the same id map as layer comps and
slices; a dangling target keeps a non-colliding placeholder. A merged-only
duplicate drops the whole variable binding set, matching how it drops comps.
Closes#4969
* style: cargo fmt duplicate_variables test
---------
Co-authored-by: highperfocused <highperfocused@pm.me>
* Vector: bound flattening memory, keep over-budget dashes, cheaper edge build (#5195)
- flatten: a path's flattened points are capped at 1 << 20; past it every
curve keeps a proportional share of its pieces (at least one), so hostile
handles from files (vmsk, SVG, effect outlines) cannot exhaust memory.
fill_rasterizer flattens the whole path under one budget.
- stroke: past the dash step budget (or below coordinate precision),
dash_polyline keeps the dashes made so far and draws the rest solid
instead of dropping the stroke. Open polylines are no longer copied.
- raster: coordinates are clamped to +-1e15 and edges with a non-finite
slope (vanishingly short) are skipped, so huge finite coordinates no
longer produce NaN coverage. fill_rasterizer sorts edges once instead of
after every component (stable sort, identical order).
- Cleanups: dead miter `half`, dead loop-length check in trace_mask,
shared mask render body, map_knots helper, shared straight-segment test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Vector: bound stroke outline points (#5211)
- stroke_polygons dashes all lines first, then counts round caps and
joins. When their full-resolution tessellation would exceed 1 << 20
outline points, every round cap and join gets the same smaller segment
count (down to 4 per circle, 1 per join; area-exact radius kept).
Strokes under the budget are unchanged; no piece is dropped.
- The dash step budget (100000) is now shared by all lines of a stroke
instead of per polyline, so many subpaths cannot multiply the dash
(and cap) count. Past it the rest is drawn solid, as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Session::edit has reported a new layer's bounds as damage since #3847, so
Duplicate Layer, Duplicate Layers and Paste no longer need to keep the
document from before the edit and work the damage out again with
note_insert. Paste Into still does: it is three edits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Panorama seams skipped an image lying wholly inside the composite, so after
Auto-Align moved the second photo partly off the canvas it got an all-black
mask and nothing changed. Such an image now takes the side of the seam it
lies towards; blending covers the layers past the canvas; Seamless Tones and
Colors evens out exposure; the Background becomes a layer to take its mask.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Multichannel PSD stores ink planes as tone (0 = solid ink), but the
planes DisplayInfo (1077) marks as alpha-type (kind 0/1) are stored as-is,
like alpha channels in every other mode. Import inverted every plane and
export wrote every channel inverted, so a white (selected) alpha imported
as 0 and RGB -> Multichannel -> save wrote alpha channels black.
Measured with a file Photoshop saved itself: a new 8x4 8-bit white RGB
document plus a "selected areas" alpha channel, white left half / black
right half, converted to Multichannel and saved as PSD. Merged planes:
Cyan, Magenta, Yellow = 255 everywhere (ink-inverted: no ink on white
paper); alpha = 255 255 255 255 0 0 0 0 per row (as-is, 255 = selected).
DisplayInfo kinds: 2, 2, 2, 0.
- io: after DisplayInfo, flip alpha-type channels back; on export invert
only spot channels.
- compose: an alpha-type channel prints as black ink of 1 - value, so the
composite of a Multichannel file is unchanged.
Tests: a kind-0 alpha imports as stored (white = 1.0) with the spot plane
still read as ink, the composite and the byte-for-byte round trip hold
(8 and 16 bit); a full alpha exports as a max plane next to a solid ink
stored 0. The #4031 composite check now compares against a black ink of
the inverted alpha, within f32 rounding; the compose unit test uses the
as-is polarity for its alpha channel.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
With alpha kept (Lock Transparent Pixels, Fill's Preserve Transparency),
the brush, mixer, Fill, Gradient and Paint Bucket composited source-over
and then restored the old alpha, so a half-transparent pixel took the new
colour by as / ao instead of as. They now blend source-atop, as Photoshop
does: Co = (1-as)*Cb + as*B(Cb,Cs), alpha unchanged. New shared helper
blend::composite_atop; over_native's lock branch lerps by the source alpha.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
CMYK pixels are stored as ink (1 = full ink), but the Channels panel and
Photoshop show a CMYK channel as its tone (white = no ink). The engine
copied raw ink, so on a white CMYK document Duplicate Channel of Cyan made
a black alpha, Load Selection from Cyan selected nothing, Split Channels
made black grayscale documents, Merge Channels of white documents made a
black CMYK image, and channel copy/paste was inverted.
A small `tone(mode, v)` helper (1 - v for CMYK, its own inverse) now reads
a CMYK colour channel as tone in ref_planes (Duplicate, Load Selection,
Calculations, Apply Image sources), Split Channels and channel copy, and
writes tone back as ink in Merge Channels, channel paste and Apply Image of
a single plane onto a CMYK layer.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
CharStyle had no superscript/subscript attribute, so PSD import ignored FontBaseline and the first re-render (entering text editing) drew the run as plain text. Model it as CharStyle::baseline, read and write FontBaseline in EngineData, draw such runs at 58.3% of their size shifted by 33.3% of it (Photoshop defaults), and accept "baseline" in the character params.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Smart-guide targets were built even when the master snap switch was off; gate them on snap_on like other targets.
Co-authored-by: Cursor <cursoragent@cursor.com>
Main landed Clip Thumbnails to Layer Bounds (#4281, #4312), the same
setting as this PR's Panel Options › Thumbnail Contents, and the Layers
panel filter-type dropdown (#5048, #5268):
- Thumbnails use main's frame and cache (layer_thumb, thumb_image); this
PR's own Layer Bounds region code is gone. The Panel Options dialog's
Layer Bounds / Entire Document now shows and sets
interface.clipThumbnailsToLayerBounds, which the panel menu's checkbox
toggles too, so the two can't disagree; it is no longer saved with the
panel options.
- Filter Options › Show hides main's new filter bar.
- Catalogs keep main's hu/sr/tr/vi rows and this PR's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- `edit.transform.warp` / `layer.smartObjects.warp`: `style: "cylinder"`
with its seven `values` (document px; depths in half axes), or a full
`warp` object whose mesh is rebuilt from its values. Anything that
isn't a horizontal cylinder without distortion is refused, never a
silent no-op; on type it is refused like a custom mesh.
- On a smart object the cylinder is stored in source space: still a
cylinder (so it goes to PSD as one) when the placement only scales and
moves, its mesh as a custom warp otherwise.
- docs: file-format-parity (PSD row, history) and gaps G1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EuC9R3K5QeMBrDkixa1jnt
Resolve smart_ui.rs: a Filter Gallery smart filter opens main's gallery
window (#3426) before this PR's editor routing; catalogs keep main's
hu/sr/tr/vi rows and this PR's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Photoshop's 32-bit Hue/Saturation raises the saturation by 1 / (1 - s)
like 8/16 bits, but doesn't clip it at 1: saturated colours leave 0..1
(the photoshop corpus's rgb32 hue-saturation.psd, Hue +40, Saturation
+25, Lightness -10, takes red to (1.0477, 0.649, -0.1477), where 8 bits
clip it to (0.9, 0.6, 0)). Its slider is cut to whole 8-bit levels: 25 %
raises by 1 / (1 - 63/255) = 1.328, not 1/0.75; in-gamut colours show
the same factor. The file becomes exact (0.1477 -> 0.0002).
hue_saturation_in carries the depth; the GPU kernel does the same under
F_HDR. Photoshop oracles 186 -> 187 (with the Colorize change, 185 ->
187), floor 187.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Photoshop's 32-bit Colorize builds its colour with less chroma than the
8/16-bit one: in the photoshop corpus's rgb32 hue-saturation-colorize
(hue -160, saturation 40, lightness +5) every output has the same hue
and lightness as ours but exactly 0.95 of the chroma, at every input
lightness from black to white. Scaling the saturation by 1 - |Lightness|
at 32 bits makes the file exact; 8 and 16 bits keep the full saturation
(their oracles are exact without it, and scaling there breaks them).
Only a raised Lightness is measured; a lowered one is taken to scale
the same way.
CPU (adjust::colorize_saturation) and the GPU planner alike. Photoshop
oracles 185 -> 186, floor 186.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A `warpCylinder` placed layer was read as having no warp: it showed
Photoshop's cached pixels on open, but Replace Contents, Relink and Edit
Contents drew the contents flat, and a regenerated SoLd wrote warpNone.
- Import reads the seven `warpValues` (a list of doubles or unit floats)
of a horizontal cylinder without perspective into Warp::cylinder.
Vertical cylinders and ones with perspective, never measured, stay
unreadable as before, as do broken values.
- Like a custom warp's (#3677), the cylinder's control-point box is what
the placement quad frames, for affine corners and, new for this style,
projective ones (`nonAffineTransform`): perspective_frame and
corners_perspective_in. Custom warps keep the source rect there.
- Export writes `warpCylinder` with its values back and frames the same
box, so a moved or replaced layer reopens where it was. An unchanged
layer is still written verbatim.
Tests: synthetic SoLd parsing (both value encodings, the refused
variants), the quad framing the control box (affine and projective),
SoLd and PlLd round trips, and a PSD export/import whose re-render
hides the contents wrapped round the back (fails before the change).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EuC9R3K5QeMBrDkixa1jnt
Keep both sides in commands.rs, lib.rs and the workspace sandbox list. Drop stale duplicate ja/hu rows left by the tsv union, add the contour strings to the new sr.tsv catalog, regenerate docs/scorecard.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve UI_SET_FIELDS (filterMaskTarget + upstream's layerFilter = 38). Name layerFilter in the MCP ui_set description, which upstream's mcp test requires. Regenerate docs/scorecard.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve docs/file-format-parity.md: keep main's corpus floors and Filter
Gallery note next to this PR's 22 mapped smart filters and history row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The native Lab path (compose::native_lab) worked a stack out on the
stored L, a and b but kept each adjustment layer's result unrounded, so
the screen showed values between two samples where Photoshop, which
stores every result at the document's depth, has whole bytes (or
1/32768 steps). On saturated colours half a byte of L is a couple of
RGB levels. Each adjustment's result is now rounded to the depth's
samples (adjustment_quantum: 8 and 16 bits; 32-bit stays unrounded),
as the RGB compositor already does.
photoshop lab8 curves.psd goes from 0.0084 to exact (PASS); Photoshop
oracles 185 -> 186, floor 186. lab8 brightness-contrast (modern) stays
DIFF: our modern curve is within half a byte of Photoshop's on L, not
exact, so rounding now shows its misses (0.02 % -> 1.05 % of pixels).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
layer.newFillLayer.gradient and gradient.presets.apply cast `angle` to f32
unchecked, so 1e39 stored an infinite angle (NaN render, .pcraft save
refused) and 450 stayed 450. They now share gradient.fill.set's parsing:
non-finite is BadParams, the angle is normalised to (-180, 180].
Pattern placement (Pattern Fill layer, Edit > Fill, Paint Bucket) does the
same for its angle and rejects a phase outside +/-1e7 like pattern.fill.set.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Transform Warp's Cylinder (`warpCylinder`) stores seven `warpValues`
instead of a bend. WarpStyle gains Cylinder (parsed, named, not one of
the fifteen bend presets and not listed in the Warp menus yet), and
Warp::cylinder builds its mesh: four patches across (back, front left,
front right, back) and one down, in the warp's value space like a
custom mesh, so map, to_mesh and is_identity treat it as one. Warp keeps
the values for writing them back (serde: omitted when empty).
The model and its table of shape factors were measured against
Photoshop 2026's renders by the reporter of #4112 (not from Adobe's
code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EuC9R3K5QeMBrDkixa1jnt
Add an `ar.tsv` catalog (~1,020 rows covering menus, Camera Raw, brush
and LUT strings, 24 six-form plurals per CLDR `ar`), a `bidi` module on
`unicode-bidi` that puts catalog text into display order at load time
(`map_translations`) and reorders user-authored names at paint sites
(document tabs, recent files, preset/gradient/style/composition names,
custom channel labels). Chrome already mirrors via `dir_for_code("ar")`;
the language resolves from prefs and `ar-*` locales.
Every edit clones the document and history keeps one per state. Metadata.xmp (String), Duotone.psd_raw (Vec<u8>) and Adjustment::Unsupported.raw (Vec<u8>) were owned, so each copy duplicated them, uncounted; their siblings (EXIF, PSD resources and blocks, a layer's psd_raw) were already Arc. They are now Arc<str> and Arc<[u8]>. Reads are unchanged (Arc<str> derefs to str); the boundaries to the codecs, the .pcraft manifest and the PSD model convert once per file operation. The architecture's snapshot principle now states the rule for every large payload, and a test checks that a history state shares all three. Fixes#4535.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>