Render: objects that share an appearance keep their own stroke outlines between frames

The renderer kept the outline of a stroke under the address of the
stroke in the object's appearance, the bits of the width and the
tolerance level, and used an entry only when the entry held the object
being drawn. The slices of a gradient along or across a stroke were
kept the same way. Objects can share one appearance until one of them
changes it. Copies made by Duplicate Selection share the original's
appearance, gradients included. For objects without a gradient fill or
stroke, so do the art the renderer places for unstained symbol
instances, the copies a live repeat draws and copies made by
edit.duplicate. In each frame, the objects that share an appearance
replaced each other's entries. The renderer therefore outlined their
strokes again in every frame.

The two caches now key each entry by the address of the object as
well, and each object keeps its own outlines from frame to frame. Art
that the renderer makes again in every frame keeps the old key: symbol
art that placed_art does not keep, and the evaluations of live objects
and the art of objects with effects that their caches do not keep. The
copies in such art replace each other's entries as before.

vectorcraft-cli bench of 2,000 unstained instances of a symbol of
eight paths took 45.7 ms a frame on main and 31.1 ms with this change,
at 2880x1800 on 8 threads, and a grid repeat of the same paths, which
draws 2,000 groups, took 45.0 ms on main and 27.2 ms with this change.
The peak working set of a bench run on the instances went from 88 MiB
to 122 MiB. In the tests, each frame draws what a new renderer draws.
This commit is contained in:
dotCooCoo
2026-10-14 04:56:29 +07:00
committed by bflatastic
parent cd89392ac9
commit 9f0a9a362b
4 changed files with 244 additions and 29 deletions
+11
View File
@@ -42,6 +42,12 @@ impl LiveCache {
self.expanded.sweep(stamp);
self.meshes.sweep(stamp);
}
/// A cache whose evaluations take at most `budget` bytes.
#[cfg(test)]
pub(crate) fn with_budget(budget: usize) -> Self {
Self { expanded: FrameCache::new(budget, 256), ..Default::default() }
}
}
/// One level of evaluation of a live node (blend steps, envelope result with type outlined run by
@@ -146,6 +152,10 @@ impl Renderer {
NodeKind::Mesh(m) => self.draw_mesh(ctx, f, a, m, cache),
NodeKind::Blend { .. } | NodeKind::Envelope { .. } | NodeKind::Repeat(_) | NodeKind::Group { .. } | NodeKind::Layer { .. } => {
let items = self.live_expanded(f.doc, a, cache);
// An evaluation the cache did not keep is made again in the next frame.
let kept = cache && self.live.expanded.get(&(Arc::as_ptr(a) as usize), self.stamp).is_some_and(|e| Arc::ptr_eq(&e.1, &items));
let outer = self.made_again;
self.made_again = outer || !kept;
// The flag holds while this blend is drawn (see `draw_live`).
if self.knockout && matches!(a.kind, NodeKind::Blend { .. }) {
self.draw_knockout(ctx, f, &items);
@@ -154,6 +164,7 @@ impl Renderer {
self.draw_arc(ctx, f, c);
}
}
self.made_again = outer;
}
_ => {}
}