mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-27 20:06:53 -06:00
A glass layer's coverage, distance field and normals depend only on its outline and the zoom. A shape asked for again in a later render (the next frame of a drag, a slider drag, a canvas patch, an export of the same view) is now worked out whole, in its own pixel frame (translation reduced to its fraction, in 1/65536 px with carry), and kept: renders reuse it instead of redoing the distance transform and normals for their crop. A shape asked for only once (each step of a zoom, a pane dragged by fractions of a pixel, a resize) is still worked out for just the part shown, so those don't get slower: working out the whole pane when only a corner is in view cost 1.8x before this rule. The cache is bounded in bytes (128 MB, 32 MB on the web), keeps the least recently used last, skips shapes over 4M px (1M on the web), and parallel bands share one computation (OnceLock slot). Renders count once per render_view / render_view_single; bands don't. Output: digests of 30 renders (5 looks, square and rounded, scales 1, 1.37, 2) are identical to main; a cut through a rounded pane now equals the whole render exactly. Release timings (glass_render_timings, 2400 × 1600 px, min of 5): canvas drag under the glass 49.5 → 26.5 ms, glass slider drag 104.8 → 61.6 ms, same view again 94.8 → 54.0 ms; zoom 105.0 → 93.7 ms (no reuse: each zoom is new). Refs #256 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>