Phase 3b: bound resident raster pixels with an eviction LRU

Scrubbing a large paint project no longer accumulates every visited frame in RAM.
A fault-in-recency LRU keeps the most-recently-paged-in RASTER_RESIDENT_MAX (12)
keyframes resident and drops the pixels of older *clean* ones (re-arming their
fault-in so they re-page on revisit). The shown frame is always the most-recent
fault-in, so it's never evicted.

Data-loss safety: a new `dirty` flag marks any keyframe whose `raw_pixels` were
mutated by editing (stroke/fill/paint-bucket/floating-lift + their undo/redo) and
is NOT yet in the container. Dirty keyframes are NEVER evicted — they're only
unpinned from the LRU. The flag is cleared on a successful save, which also re-arms
the LRU for the now-clean resident frames so the bound still applies to frames
edited this session.

Also: the save loop now walks all layers (incl. nested) to match the load path's
recursive fault-in arming — evicted frames keep their existing container row
(media_exists), and nested raster keyframes are persisted + covered by live_media.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Skyler Lehmkuhl
2026-06-19 17:56:37 -04:00
co-authored by Claude Opus 4.8
parent 2e07a88905
commit 39dc402ba3
6 changed files with 90 additions and 1 deletions
@@ -44,6 +44,7 @@ impl Action for RasterFillAction {
let kf = raster.ensure_keyframe_at(self.time, self.width, self.height);
kf.raw_pixels = self.buffer_after.clone();
kf.texture_dirty = true;
kf.dirty = true;
Ok(())
}
@@ -57,6 +58,7 @@ impl Action for RasterFillAction {
let kf = raster.ensure_keyframe_at(self.time, self.width, self.height);
kf.raw_pixels = self.buffer_before.clone();
kf.texture_dirty = true;
kf.dirty = true;
Ok(())
}
@@ -50,6 +50,7 @@ impl Action for RasterStrokeAction {
let kf = get_keyframe_mut(document, &self.layer_id, self.time, self.width, self.height)?;
kf.raw_pixels = self.buffer_after.clone();
kf.texture_dirty = true;
kf.dirty = true;
Ok(())
}
@@ -57,6 +58,7 @@ impl Action for RasterStrokeAction {
let kf = get_keyframe_mut(document, &self.layer_id, self.time, self.width, self.height)?;
kf.raw_pixels = self.buffer_before.clone();
kf.texture_dirty = true;
kf.dirty = true;
Ok(())
}