From cd439986e1a6220792557ba17e9484eb2e3752df Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Tue, 24 Feb 2026 10:10:40 +0100 Subject: [PATCH 1/2] Fix ui scaling messing up render cache --- node-graph/nodes/gstd/src/render_cache.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/node-graph/nodes/gstd/src/render_cache.rs b/node-graph/nodes/gstd/src/render_cache.rs index 335285befc..6c528220b1 100644 --- a/node-graph/nodes/gstd/src/render_cache.rs +++ b/node-graph/nodes/gstd/src/render_cache.rs @@ -3,7 +3,7 @@ use core_types::math::bbox::AxisAlignedBbox; use core_types::transform::{Footprint, RenderQuality, Transform}; use core_types::{CloneVarArgs, Context, Ctx, ExtractAll, ExtractAnimationTime, ExtractPointerPosition, ExtractRealTime, OwnedContextImpl}; -use glam::{DVec2, IVec2, UVec2}; +use glam::{DAffine2, DVec2, IVec2, UVec2}; use graph_craft::document::value::RenderOutput; use graph_craft::wasm_application_io::WasmEditorApi; use graphene_application_io::{ApplicationIo, ImageTexture}; @@ -47,10 +47,11 @@ pub struct CacheKey { pub animation_time_ms: i64, pub real_time_ms: i64, pub pointer: [u8; 16], + pub scale: u64, } impl CacheKey { - pub fn new( + fn new( render_mode_hash: u64, hide_artboards: bool, for_export: bool, @@ -61,6 +62,7 @@ impl CacheKey { animation_time: f64, real_time: f64, pointer: Option, + scale: f64, ) -> Self { let pointer_bytes = pointer .map(|p| { @@ -81,6 +83,7 @@ impl CacheKey { animation_time_ms: (animation_time * 1000.0).round() as i64, real_time_ms: (real_time * 1000.0).round() as i64, pointer: pointer_bytes, + scale: scale.to_bits(), } } } @@ -98,6 +101,7 @@ impl Default for CacheKey { animation_time_ms: 0, real_time_ms: 0, pointer: [0u8; 16], + scale: 0, } } } @@ -390,7 +394,12 @@ pub async fn render_output_cache<'a: 'n>( let logical_scale = footprint.decompose_scale().x; let device_scale = render_params.scale; let physical_scale = logical_scale * device_scale; + 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( render_params.render_mode as u64, @@ -403,6 +412,7 @@ pub async fn render_output_cache<'a: 'n>( ctx.try_animation_time().unwrap_or(0.0), ctx.try_real_time().unwrap_or(0.0), ctx.try_pointer_position(), + render_params.scale, ); let max_region_area = editor_api.editor_preferences.max_render_region_area(); From 4fec69a84f29701768fbfb0790d7d1745bb715d1 Mon Sep 17 00:00:00 2001 From: Timon Date: Tue, 24 Feb 2026 09:45:31 +0000 Subject: [PATCH 2/2] Review --- node-graph/nodes/gstd/src/render_cache.rs | 31 +++++------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/node-graph/nodes/gstd/src/render_cache.rs b/node-graph/nodes/gstd/src/render_cache.rs index 6c528220b1..022f577ee4 100644 --- a/node-graph/nodes/gstd/src/render_cache.rs +++ b/node-graph/nodes/gstd/src/render_cache.rs @@ -3,7 +3,7 @@ use core_types::math::bbox::AxisAlignedBbox; use core_types::transform::{Footprint, RenderQuality, Transform}; use core_types::{CloneVarArgs, Context, Ctx, ExtractAll, ExtractAnimationTime, ExtractPointerPosition, ExtractRealTime, OwnedContextImpl}; -use glam::{DAffine2, DVec2, IVec2, UVec2}; +use glam::{DVec2, IVec2, UVec2}; use graph_craft::document::value::RenderOutput; use graph_craft::wasm_application_io::WasmEditorApi; use graphene_application_io::{ApplicationIo, ImageTexture}; @@ -35,9 +35,10 @@ pub struct CachedRegion { memory_size: usize, } -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] pub struct CacheKey { pub render_mode_hash: u64, + pub scale: u64, pub hide_artboards: bool, pub for_export: bool, pub for_mask: bool, @@ -47,12 +48,13 @@ pub struct CacheKey { pub animation_time_ms: i64, pub real_time_ms: i64, pub pointer: [u8; 16], - pub scale: u64, } impl CacheKey { + #[expect(clippy::too_many_arguments)] fn new( render_mode_hash: u64, + scale: f64, hide_artboards: bool, for_export: bool, for_mask: bool, @@ -62,7 +64,6 @@ impl CacheKey { animation_time: f64, real_time: f64, pointer: Option, - scale: f64, ) -> Self { let pointer_bytes = pointer .map(|p| { @@ -74,6 +75,7 @@ impl CacheKey { .unwrap_or([0u8; 16]); Self { render_mode_hash, + scale: scale.to_bits(), hide_artboards, for_export, for_mask, @@ -83,25 +85,6 @@ impl CacheKey { animation_time_ms: (animation_time * 1000.0).round() as i64, real_time_ms: (real_time * 1000.0).round() as i64, pointer: pointer_bytes, - scale: scale.to_bits(), - } - } -} - -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], - scale: 0, } } } @@ -403,6 +386,7 @@ pub async fn render_output_cache<'a: 'n>( let cache_key = CacheKey::new( render_params.render_mode as u64, + render_params.scale, render_params.hide_artboards, render_params.for_export, render_params.for_mask, @@ -412,7 +396,6 @@ pub async fn render_output_cache<'a: 'n>( ctx.try_animation_time().unwrap_or(0.0), ctx.try_real_time().unwrap_or(0.0), ctx.try_pointer_position(), - render_params.scale, ); let max_region_area = editor_api.editor_preferences.max_render_region_area();