Skip to main content

Module image_store

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§

DecodedImage
Straight-alpha, eight-bit RGBA pixels, ready for host validation.
HostImageLoader
The loading half of a host-driven ImageStore.
ImageCompletionTicket
Opaque custody for one admitted asynchronous image decode.
ImageStore
A cheap-to-clone handle to a shared image cache whose loads run off the UI thread — on the toolkit’s Background for ImageStore::new, or in the host for ImageStore::host_driven.
ServedWindow
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 ImageStore in the process. A screenshot capture waits, within a bound, until this is zero.
paint_image_contain
Paint img into rect with a contain fit (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 img into rect with a cover fit (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 None on failure. Invoked as background work, so it may block on I/O.
HostImageFactory
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.