Repository navigation
Editor: much faster drawing and dragging of shapes (shadows, background, canvas texture) - #2
Merged
Conversation
…eap to redraw The editor re-renders the canvas tile on every frame of a drag, and most of that time went into work proportional to the whole tile rather than to the objects: - Objects with a drop shadow, opacity or rotation allocated a full-tile layer, cloned the whole tile as a backdrop, then tinted, blurred and composited the full tile for the shadow and the layer. Now the backdrop is only cloned for Blur/Magnify (the only objects that read it), and the shadow and the composite work on the painted part of the layer (padded by the blur's reach). - Shadows blur only the alpha channel (a shadow is one colour), with lookup tables for the tint and fill, a reciprocal multiply instead of a per-pixel divide and a blocked transpose. - The layer and shadow are blended with a direct loop that uses the same float arithmetic as the highp pipeline behind draw_pixmap (load, scale_1_float, source_over, round half to even). - The background caches returned a full clone of the decoded (and the downscaled) capture on every lookup. They now hand out Arc references, record whether the bitmap is opaque, and an opaque background at a whole-pixel offset is copied row by row; when it covers the tile, the checkerboard and canvas fill under it are skipped. Image/stamp objects share the same way. A 2176x1224 canvas tile with four large shadowed shapes, an arrow, a 50% opacity shape and a Blur region went from 1483 ms to 49 ms per render, with byte-identical output to the previous renderer; clipped tiles match the old renderer too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…le dragging - tiny-skia pixmaps are premultiplied RGBA, which is what egui's ColorImage stores, so the canvas texture is built straight from the pixmap instead of unpremultiplying it (pixmap_to_image) and premultiplying it again (from_rgba_unmultiplied) on every re-render. - bump() (called on every frame of a drag, resize, pen stroke) now updates changed_at, so the tray thumbnail waits until the edit pauses as intended instead of re-rendering the page every frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Editor re-renders the canvas tile on every frame of a drag, resize or pen stroke. Most of that time went into work proportional to the whole tile rather than to the objects being drawn, so drawing and moving shapes felt slow, especially with drop shadows. This PR removes that work without changing the rendered output.
Results
I measured with a 2176×1224 canvas tile: a 1440p capture at fit zoom, four large shapes with drop shadows (one is an arrow), a 50% opacity shape and a Blur region.
Renderer (
linkshot-render)painted_bounds. The shadow area is padded by 3.5σ, past the reach of the three box passes.blur::shadow):blend_overuses the same float arithmetic as the highp pipeline behinddraw_pixmap(load_8888→scale_1_float→source_over→store_8888, round half to even). The results match exactly, without the per-pixel pipeline overhead.bg_cache,bg_scaledandimg_cachereturned a full clone of the decoded capture on every lookup, about 15 MB per frame for a 1440p capture and far more for scrolling captures. They now hand outArcs.Editor (
linkshot-app)ColorImage::from_rgba_premultiplied). It no longer goes through two conversion passes per re-render: unpremultiply inpixmap_to_image, then premultiply again infrom_rgba_unmultiplied.bump()now updateschanged_at. The tray thumbnail therefore waits until a drag pauses, as its comment intends, instead of re-rendering the whole page on every frame.Testing
cargo test -p linkshot-render -p linkshot-corepasses, including a new exactness test for the reciprocal division.🤖 Generated with Claude Code