mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-14 19:26:56 -04:00
The renderer drew each symbol instance by copying its symbol's art, staining the copy for a stained instance and moving every object in it by the instance's transform, in every frame. The copies were new nodes, so the caches the renderer keys by a node's address (cull bounds, path geometry, glyph layouts, live-effect geometry) missed for every object of every instance, and the copies stayed in those caches until they were pruned. Stroke outlines missed as well, because their cache uses an entry only when the entry holds the node being drawn. The renderer copied and moved the art of inline graphics in type the same way. The renderer now keeps the art it places in a frame cache with a 64 MiB budget, under the address of the symbol's art, the transform, whether strokes scale with it, and the instance's stain. When the art is a group or a layer without an appearance of its own, the renderer copies none of it in a frame whose instances and symbols did not change, and the objects in it hit the caches keyed by their own address (cull bounds and paths, glyph layouts, live-effect geometry). The stroke-outline cache keys a stroke by its address in the appearance. In the art placed for an unstained instance, each object without a gradient fill or stroke shares its appearance with the same object in the symbol's art. When a symbol has two or more unstained instances, the renderer therefore still outlines the strokes of those objects again for each instance in every frame. Moving or restaining an instance, or editing its symbol's art, places that art again, and the other instances keep theirs. Other art is placed again in every frame, as before, and so is art that holds a symbol instance, type with an inline graphic, an image, a placed document, a blend, an envelope, a repeat or a raster effect. Art that holds type is placed again when the fonts change. vectorcraft-cli bench of a symbol of eight paths (three filled and stroked, two only filled, three only stroked) shown by 2,000 unstained instances took 51.6 ms a frame on main and 32.3 ms with this change, at 2880x1800 on 8 threads; the same paths in 2,000 groups took 26.0 ms. The peak working set of a bench run at that size went from 150 MiB to 83 MiB. In the tests, a renderer that keeps placed art draws the same pixels as a new renderer, and instances draw the same pixels as groups of their placed art.