// SPDX-License-Identifier: LGPL-2.1-only // Copyright (C) 2026 Liberux Labs, S. L. use std::cell::RefCell; use std::collections::HashMap; use crate::types::Color; use crate::wallpaper::ImageData; /// Rasterised at twice the drawn size so icons stay sharp at scale 2. const RASTER_PX: u32 = 48; thread_local! { static CACHE: RefCell>> = RefCell::new( HashMap::new() ); } /// The theme's symbolic icon `name` in `tint`, kept so the same pixels are handed out every frame. pub( crate ) fn tinted( name: &str, tint: Color ) -> Option { let key = ( name.to_string(), [ channel( tint.r ), channel( tint.g ), channel( tint.b ), channel( tint.a ) ] ); CACHE.with( |cache| { cache.borrow_mut() .entry( key ) .or_insert_with( || crate::chassis::theme_icon_tinted( name, RASTER_PX, tint ) ) .clone() } ) } fn channel( v: f32 ) -> u8 { ( v.clamp( 0.0, 1.0 ) * 255.0 ) as u8 }