Fix the UI scaling factor invalidating the render cache (#3818)

* Fix ui scaling messing up render cache

* Review

---------

Co-authored-by: Timon <me@timon.zip>
This commit is contained in:
Dennis Kobert 2026-02-24 13:41:42 +01:00 committed by GitHub
parent 65ca8610eb
commit 7250b091d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 19 deletions

View File

@ -35,9 +35,10 @@ pub struct CachedRegion {
memory_size: usize, memory_size: usize,
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
pub struct CacheKey { pub struct CacheKey {
pub render_mode_hash: u64, pub render_mode_hash: u64,
pub scale: u64,
pub hide_artboards: bool, pub hide_artboards: bool,
pub for_export: bool, pub for_export: bool,
pub for_mask: bool, pub for_mask: bool,
@ -50,8 +51,10 @@ pub struct CacheKey {
} }
impl CacheKey { impl CacheKey {
pub fn new( #[expect(clippy::too_many_arguments)]
fn new(
render_mode_hash: u64, render_mode_hash: u64,
scale: f64,
hide_artboards: bool, hide_artboards: bool,
for_export: bool, for_export: bool,
for_mask: bool, for_mask: bool,
@ -72,6 +75,7 @@ impl CacheKey {
.unwrap_or([0u8; 16]); .unwrap_or([0u8; 16]);
Self { Self {
render_mode_hash, render_mode_hash,
scale: scale.to_bits(),
hide_artboards, hide_artboards,
for_export, for_export,
for_mask, for_mask,
@ -85,23 +89,6 @@ impl CacheKey {
} }
} }
impl Default for CacheKey {
fn default() -> Self {
Self {
render_mode_hash: 0,
hide_artboards: false,
for_export: false,
for_mask: false,
thumbnail: false,
aligned_strokes: false,
override_paint_order: false,
animation_time_ms: 0,
real_time_ms: 0,
pointer: [0u8; 16],
}
}
}
#[derive(Debug)] #[derive(Debug)]
struct TileCacheImpl { struct TileCacheImpl {
regions: Vec<CachedRegion>, regions: Vec<CachedRegion>,
@ -390,10 +377,16 @@ pub async fn render_output_cache<'a: 'n>(
let logical_scale = footprint.decompose_scale().x; let logical_scale = footprint.decompose_scale().x;
let device_scale = render_params.scale; let device_scale = render_params.scale;
let physical_scale = logical_scale * device_scale; let physical_scale = logical_scale * device_scale;
let viewport_bounds = footprint.viewport_bounds_in_local_space(); let viewport_bounds = footprint.viewport_bounds_in_local_space();
let viewport_bounds = AxisAlignedBbox {
start: viewport_bounds.start,
end: viewport_bounds.start + viewport_bounds.size() / device_scale,
};
let cache_key = CacheKey::new( let cache_key = CacheKey::new(
render_params.render_mode as u64, render_params.render_mode as u64,
render_params.scale,
render_params.hide_artboards, render_params.hide_artboards,
render_params.for_export, render_params.for_export,
render_params.for_mask, render_params.for_mask,