Closes #27414 `ImageCache` is independent of the original image loader and can actively release its cached images to solve the problem of images loaded from the network or files not being released. It has two constructors: - `ImageCache::new`: Manually manage the cache. - `ImageCache::max_items`: Remove the least recently used items when the cache reaches the specified number. When creating an `img` element, you can specify the cache object with `Img::cache`, and the image cache will be managed by `ImageCache`. In the example `crates\gpui\examples\image-gallery.rs`, the `ImageCache::clear` method is actively called when switching a set of images, and the memory will no longer continuously increase. Release Notes: - N/A --------- Co-authored-by: Ben Kunkle <ben@zed.dev>
28 lines
416 B
Rust
28 lines
416 B
Rust
mod anchored;
|
|
mod animation;
|
|
mod canvas;
|
|
mod common;
|
|
mod deferred;
|
|
mod div;
|
|
mod image_cache;
|
|
mod img;
|
|
mod list;
|
|
mod surface;
|
|
mod svg;
|
|
mod text;
|
|
mod uniform_list;
|
|
|
|
pub use anchored::*;
|
|
pub use animation::*;
|
|
pub use canvas::*;
|
|
pub use common::*;
|
|
pub use deferred::*;
|
|
pub use div::*;
|
|
pub use image_cache::*;
|
|
pub use img::*;
|
|
pub use list::*;
|
|
pub use surface::*;
|
|
pub use svg::*;
|
|
pub use text::*;
|
|
pub use uniform_list::*;
|