diff --git a/src/renderer/cursor_renderer/mod.rs b/src/renderer/cursor_renderer/mod.rs index 2367af6..db52bef 100644 --- a/src/renderer/cursor_renderer/mod.rs +++ b/src/renderer/cursor_renderer/mod.rs @@ -230,7 +230,8 @@ impl CursorRenderer { pub fn draw(&mut self, cursor: Cursor, default_colors: &Colors, font_width: f32, font_height: f32, - shaper: &mut CachingShaper, canvas: &mut Canvas) { + shaper: &mut CachingShaper, canvas: &mut Canvas, + dt: f32) { let render = self.blink_status.update_status(&cursor); let mut paint = Paint::new(skulpin::skia_safe::colors::WHITE, None); @@ -287,8 +288,6 @@ impl CursorRenderer { self.cursor_vfx.restart(center_destination); } - let dt = 1.0 / (SETTINGS.get("refresh_rate").read_u16() as f32); - let mut animating = false; if !center_destination.is_zero() { for corner in self.corners.iter_mut() { diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index 6d38f1d..8c82191 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -13,6 +13,7 @@ pub use caching_shaper::CachingShaper; use cursor_renderer::CursorRenderer; use crate::editor::{EDITOR, Style}; + pub struct Renderer { surface: Option, paint: Paint, @@ -107,7 +108,9 @@ impl Renderer { canvas.restore(); } - pub fn draw(&mut self, gpu_canvas: &mut Canvas, coordinate_system_helper: &CoordinateSystemHelper) -> bool { + pub fn draw(&mut self, gpu_canvas: &mut Canvas, + coordinate_system_helper: &CoordinateSystemHelper, + dt: f32) -> bool { trace!("Rendering"); let ((draw_commands, should_clear), default_style, cursor, font_name, font_size) = { let mut editor = EDITOR.lock(); @@ -162,7 +165,7 @@ impl Renderer { self.cursor_renderer.draw( cursor, &default_style.colors, self.font_width, self.font_height, - &mut self.shaper, gpu_canvas); + &mut self.shaper, gpu_canvas, dt); font_changed } diff --git a/src/window.rs b/src/window.rs index b6c87e9..329fe49 100644 --- a/src/window.rs +++ b/src/window.rs @@ -239,7 +239,10 @@ impl WindowWrapper { if REDRAW_SCHEDULER.should_draw() || SETTINGS.get::().no_idle { let renderer = &mut self.renderer; if self.skulpin_renderer.draw(&self.window, |canvas, coordinate_system_helper| { - if renderer.draw(canvas, coordinate_system_helper) { + + let dt = 1.0 / (SETTINGS.get::().refresh_rate as f32); + + if renderer.draw(canvas, coordinate_system_helper, dt) { handle_new_grid_size(new_size, &renderer) } }).is_err() {