Phase 4 Tier 1: lazy image-asset bytes paged from the container
Project load no longer eager-reads all image bytes — `ImageAsset.data` stays empty and the renderer's ImageCache pages compressed bytes from the `.beam` on a decode miss (read_packed_media_readonly by asset id), decoding into the byte-bounded Tier-2 cache. Result: instant load, and compressed bytes don't accumulate on the heap. - ImageCache: `container_path` + `resolve_bytes` (asset.data if resident — fresh import or old base64 project — else page from the container); decoders take `&[u8]` and use the decoded dimensions. - Container path threaded App.current_file_path → SharedPaneState → VelloRenderContext, set on the cache each prepare. - load_beam_sqlite drops the 3.5b eager read. (Refinement: a persistent read connection instead of open-per-miss.)
This commit is contained in:
@@ -175,6 +175,9 @@ impl OnionSkinSettings {
|
||||
}
|
||||
|
||||
pub struct SharedPaneState<'a> {
|
||||
/// Current `.beam` container path (for lazily paging image-asset bytes in the
|
||||
/// renderer's ImageCache). `None` before the project is first saved/loaded.
|
||||
pub container_path: Option<std::path::PathBuf>,
|
||||
/// Effective onion-skin settings (already gated to off during playback by main.rs).
|
||||
pub onion: OnionSkinSettings,
|
||||
/// The raw onion-skin settings, mutable — edited by the Info Panel's controls.
|
||||
|
||||
@@ -437,6 +437,8 @@ struct VelloRenderContext {
|
||||
tool_state: lightningbeam_core::tool::ToolState,
|
||||
/// Onion-skinning settings (already gated off during playback).
|
||||
onion: crate::panes::OnionSkinSettings,
|
||||
/// `.beam` container path for lazily paging image-asset bytes in the ImageCache.
|
||||
container_path: Option<std::path::PathBuf>,
|
||||
/// Active layer for tool operations
|
||||
active_layer_id: Option<uuid::Uuid>,
|
||||
/// Delta for drag preview (world space)
|
||||
@@ -975,6 +977,8 @@ impl egui_wgpu::CallbackTrait for VelloCallback {
|
||||
let _t_after_gpu_dispatches = std::time::Instant::now();
|
||||
|
||||
let mut image_cache = shared.image_cache.lock().unwrap();
|
||||
// Let the cache page image bytes from the project container on a decode miss.
|
||||
image_cache.set_container_path(self.ctx.container_path.clone());
|
||||
|
||||
let composite_result = if shared.is_cpu_renderer {
|
||||
lightningbeam_core::renderer::render_document_for_compositing_cpu(
|
||||
@@ -12073,6 +12077,7 @@ impl PaneRenderer for StagePane {
|
||||
document: shared.action_executor.document_arc(),
|
||||
tool_state: shared.tool_state.clone(),
|
||||
onion: shared.onion,
|
||||
container_path: shared.container_path.clone(),
|
||||
active_layer_id: *shared.active_layer_id,
|
||||
drag_delta,
|
||||
selection: shared.selection.clone(),
|
||||
|
||||
Reference in New Issue
Block a user