Skip to main content

capped_job

Function capped_job 

Source
fn capped_job(
    cache: &mut HashMap<(u64, i32), CappedSprite>,
    hash: u64,
    cap: i32,
    hot_x: i32,
    hot_y: i32,
    decode: impl FnOnce() -> Option<RgbaImage>,
) -> (&'static str, Vec<u8>, i32, i32)
Expand description

Cache wrapper for sprite jobs, keyed by (sprite hash, cap) so a repeat of a sprite already delivered under the same cap is a plain clone of its PNG; a miss decodes the sprite, caps it, and encodes it once. Keying on the cap keeps a live SetSizeCap from serving stale sizes.