From 277ca546f2ddf8f12f6bea29690bf95695b69d88 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 24 Nov 2026 12:12:39 +0100 Subject: [PATCH] :zap: Re-present the frame when the grid overlay changes (#13248) Hovering a grid frame requested a full render. That clears the canvas and walks every visible tile even though the overlay is only UI. show_grid and hide_grid now re-present the last frame. --- frontend/src/app/main/ui/workspace/viewport_wasm.cljs | 2 +- frontend/src/app/render_wasm/api.cljs | 8 ++++---- render-wasm/src/wasm/layouts/grid.rs | 11 +++++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/viewport_wasm.cljs b/frontend/src/app/main/ui/workspace/viewport_wasm.cljs index 68535d6895..8fc23e4109 100644 --- a/frontend/src/app/main/ui/workspace/viewport_wasm.cljs +++ b/frontend/src/app/main/ui/workspace/viewport_wasm.cljs @@ -260,7 +260,7 @@ last-vern-ref (mf/use-ref nil) ;; WASM grid overlay was visible last run (`hover-grid?` true). Used so `clear-grid` - ;; (expensive: `_hide_grid` + full `request-render`) runs only when hiding the overlay. + ;; runs only when hiding the overlay. prev-hover-grid-shown?-ref (mf/use-ref false) ;; STATE REFS diff --git a/frontend/src/app/render_wasm/api.cljs b/frontend/src/app/render_wasm/api.cljs index 3cb9938df9..b2225b07a8 100644 --- a/frontend/src/app/render_wasm/api.cljs +++ b/frontend/src/app/render_wasm/api.cljs @@ -2669,6 +2669,7 @@ (p/rejected cause)))))) (defn show-grid + "Show the grid overlay for `id`. The WASM call re-presents the last frame." [id] (when (initialized?) (let [buffer (uuid/get-u32 id)] @@ -2676,8 +2677,7 @@ (aget buffer 0) (aget buffer 1) (aget buffer 2) - (aget buffer 3))) - (request-render "show-grid"))) + (aget buffer 3))))) (defn set-rulers-visible! [visible?] @@ -2716,10 +2716,10 @@ (sr-clr/hex->u32argb accent-hex 1)))) (defn clear-grid + "Hide the hover grid overlay. The WASM call re-presents the last frame." [] (when (initialized?) - (h/call wasm/internal-module "_hide_grid") - (request-render "clear-grid"))) + (h/call wasm/internal-module "_hide_grid"))) ;; Ruler guides ---------------------------------------------------------------- diff --git a/render-wasm/src/wasm/layouts/grid.rs b/render-wasm/src/wasm/layouts/grid.rs index 573b99a5da..8bed182deb 100644 --- a/render-wasm/src/wasm/layouts/grid.rs +++ b/render-wasm/src/wasm/layouts/grid.rs @@ -240,15 +240,26 @@ pub extern "C" fn set_grid_cells() -> Result<()> { Ok(()) } +/// Hover only changes the grid overlay on the UI surface. Re-present the last +/// frame so the lines update without a tile pass. A full render clears the +/// canvas and walks every visible tile. +fn present_grid_overlay() { + with_state!(state, { + state.present_frame(); + }); +} + #[no_mangle] pub extern "C" fn show_grid(a: u32, b: u32, c: u32, d: u32) { let id = uuid_from_u32_quartet(a, b, c, d); get_render_state().show_grid = Some(id); + present_grid_overlay(); } #[no_mangle] pub extern "C" fn hide_grid() { get_render_state().show_grid = None; + present_grid_overlay(); } #[no_mangle]