Module image_store
Expand description
Async image loading, decode and cache — keyed by URL. Displaying remote
thumbnails on the UI thread would jank every frame, so loads run off the
UI thread — fetched through a caller-supplied Fetcher and decoded as
crate::background::Background jobs, or fetched by the host through a
HostImageLoader — and the decoded peniko::ImageData is cached and
handed back on a later frame; until then the caller paints a placeholder.
No networking here — the toolkit stays HTTP-free, and a no-op fetcher
keeps tests and hermetic offline builds deterministic. Decoding uses the
toolkit’s decoders (crate::image_decoders); cloning a returned
ImageData only bumps an Arc.
Structs§
- Decoded
Image - Straight-alpha, eight-bit RGBA pixels, ready for host validation.
- Host
Image Loader - The loading half of a host-driven
ImageStore. - Image
Completion Ticket - Opaque custody for one admitted asynchronous image decode.
- Image
Store - A cheap-to-clone handle to a shared image cache whose loads run off the
UI thread — on the toolkit’s
BackgroundforImageStore::new, or in the host forImageStore::host_driven. - Served
Window - A window a host serves (
ImageStore::serve_window), as the host’s factory sees it: what the stores it builds draw for.
Functions§
- loads_
in_ flight - Loads in flight (queued or decoding) across every
ImageStorein the process. A screenshot capture waits, within a bound, until this is zero. - paint_
image_ contain - Paint
imgintorectwith acontainfit (the whole picture, aspect kept, centred; whatever it leaves shows what is under it), clipped to a rounded rectangle: a shared screen, of which nothing may be cut off. - paint_
image_ cover - Paint
imgintorectwith acoverfit (fill the rect, preserve aspect, crop the overflow) clipped to a rounded rectangle, matching the shape a procedural placeholder occupied.
Type Aliases§
- Fetcher
- Fetches the raw encoded bytes for a URL, or
Noneon failure. Invoked as background work, so it may block on I/O. - Host
Image Factory - How a host builds one window’s image stores: a store whose loading the host drives, for the decoded-image bound the store asked for, drawing for the window it is built in.