Skip to main content

icon_cache_key

Function icon_cache_key 

Source
pub fn icon_cache_key(
    icon: &str,
    color: &str,
    target_w: u32,
    target_h: u32,
) -> (u32, u32, String)
Expand description

Single source of truth for both the oversampled rasterization size and the asset_cache key used for a given icon at a given target (layout) size. Returns (render_width, render_height, cache_key).

§Issue #166

Before this function existed, icon.rs’s painter and preload.rs’s prefetcher each built the cache key from their own inlined format!. The painter multiplied the target size by ICON_OVERSAMPLE before building the key; the preloader did not. For a 40×40 icon the painter looked up "icon:...:80x80" while the preloader could only ever have written "icon:...:40x40" — the two keys could never collide, so prefetch_icons never once avoided a duplicate network fetch, and (had its rasterization size matched the key by coincidence) would have cached a bitmap at half the resolution the painter actually samples.

Both call sites now go through this one function, so they cannot drift apart again — fixing the key without also fixing the raster size (or vice versa) is no longer expressible.