Skip to content

Commit 7250b09

Browse files
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>
1 parent 65ca861 commit 7250b09

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

node-graph/nodes/gstd/src/render_cache.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ pub struct CachedRegion {
3535
memory_size: usize,
3636
}
3737

38-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
38+
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
3939
pub struct CacheKey {
4040
pub render_mode_hash: u64,
41+
pub scale: u64,
4142
pub hide_artboards: bool,
4243
pub for_export: bool,
4344
pub for_mask: bool,
@@ -50,8 +51,10 @@ pub struct CacheKey {
5051
}
5152

5253
impl CacheKey {
53-
pub fn new(
54+
#[expect(clippy::too_many_arguments)]
55+
fn new(
5456
render_mode_hash: u64,
57+
scale: f64,
5558
hide_artboards: bool,
5659
for_export: bool,
5760
for_mask: bool,
@@ -72,6 +75,7 @@ impl CacheKey {
7275
.unwrap_or([0u8; 16]);
7376
Self {
7477
render_mode_hash,
78+
scale: scale.to_bits(),
7579
hide_artboards,
7680
for_export,
7781
for_mask,
@@ -85,23 +89,6 @@ impl CacheKey {
8589
}
8690
}
8791

88-
impl Default for CacheKey {
89-
fn default() -> Self {
90-
Self {
91-
render_mode_hash: 0,
92-
hide_artboards: false,
93-
for_export: false,
94-
for_mask: false,
95-
thumbnail: false,
96-
aligned_strokes: false,
97-
override_paint_order: false,
98-
animation_time_ms: 0,
99-
real_time_ms: 0,
100-
pointer: [0u8; 16],
101-
}
102-
}
103-
}
104-
10592
#[derive(Debug)]
10693
struct TileCacheImpl {
10794
regions: Vec<CachedRegion>,
@@ -390,10 +377,16 @@ pub async fn render_output_cache<'a: 'n>(
390377
let logical_scale = footprint.decompose_scale().x;
391378
let device_scale = render_params.scale;
392379
let physical_scale = logical_scale * device_scale;
380+
393381
let viewport_bounds = footprint.viewport_bounds_in_local_space();
382+
let viewport_bounds = AxisAlignedBbox {
383+
start: viewport_bounds.start,
384+
end: viewport_bounds.start + viewport_bounds.size() / device_scale,
385+
};
394386

395387
let cache_key = CacheKey::new(
396388
render_params.render_mode as u64,
389+
render_params.scale,
397390
render_params.hide_artboards,
398391
render_params.for_export,
399392
render_params.for_mask,

0 commit comments

Comments
 (0)