update dock

This commit is contained in:
2026-08-23 10:03:10 +07:00
parent 7fb7275233
commit 8da48bdc4a
25 changed files with 1583 additions and 5471 deletions
+25 -5
View File
@@ -91,17 +91,37 @@ impl LruImageCache {
}
}
/// Drop a cache entry from the sprite atlas and remove its resource from the
/// asset system, so both the decoded image and the raw fetched bytes are
/// freed. `window` restricts the atlas removal to the current window; `None`
/// removes it from all windows.
/// Drop a cache entry's decoded data and remove its resource from the asset
/// system, so both the decoded image and the raw fetched bytes are freed.
///
/// The atlas texture is freed **on the next frame, before it paints**, never
/// in the middle of one: the release that empties the cache can run at the
/// end of a frame's draw — after the scene was built, before it is presented
/// — and eviction runs while a frame is painting (`load` is called from
/// paint). The next frame also has to repaint every view instead of replaying
/// their recorded paint commands: `cached()` views reuse recorded commands
/// across frames, and those commands reference the atlas tiles being freed,
/// so a replay would hand the renderer a scene full of freed texture ids.
/// `window.refresh()` disables that reuse for exactly one frame.
///
/// `window` restricts the atlas removal to the current window; `None` removes
/// it from all windows (the cache entity is being released at shutdown, when
/// no scene is in flight).
fn unload(
(mut item, resource): (ImageCacheItem, Resource),
window: Option<&mut Window>,
cx: &mut App,
) {
if let Some(Ok(image)) = item.get() {
cx.drop_image(image, window);
match window {
Some(window) => {
window.on_next_frame(move |window, cx| {
window.refresh();
cx.drop_image(image, Some(window));
});
}
None => cx.drop_image(image, None),
}
}
ImageSource::Resource(resource).remove_asset(cx);
}