Skip to main content

Module image_cache

Module image_cache 

Source
Expand description

Shared, cheaply-cloneable cache of decoded images for standalone-image rendering.

Mirrors validation::GitHubValidationCache: an Arc<Mutex<HashMap>> keyed by the raw URL string. Loads (local file reads or remote fetches) run on worker tasks that write their result here and wake the winit loop; the layout/draw path reads it.

Structs§

ImageCache
Thread-safe cache of image load states, shared across clones (like the GitHub caches). Cheap to clone: just bumps the inner Arc.
LoadedImage
A decoded image ready to paint, plus its raster pixel size and logical display size. For raster sources the two match; for SVG the raster size is supersampled while the display size is the SVG’s intrinsic logical size (see decode_svg). Arc-wrapped in the cache so a cache clone stays O(1) (the Blob is Arc-backed too, but the Arc<LoadedImage> keeps the whole entry a single refcount bump).

Enums§

ImageState
Load state for one image URL.

Functions§

decode
Decode encoded image bytes into a paintable LoadedImage. Tries the raster path (PNG/JPEG/GIF/WebP) first, then falls back to SVG. Returns None on any failure. The RGBA8 buffer from the image crate is straight (un-premultiplied) alpha, matching ImageAlphaType::Alpha.