From 5d88cb3bb7394436c7e5fd891547e3a58f39c7c4 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Mon, 16 Nov 2026 21:47:27 +0800 Subject: [PATCH] :bug: Don't copy margins past tile in draw_current_tile_into_backbuffer (#13066) When dragging a shape each tile that needs repainted is repainted via draw_current_tile_into_backbuffer in fast mode. So if you drag over a tile it ends up dropping drop shadows etc. IIUC, each tile is 512x512px but drawn on a 1024px surface with 256px margins so that the background blur has something to read. In a regular render we render the 1024px surface but only copy the center 512px of the tile into the backbuffer. But in draw_current_tile_into_backbuffer we were copying the whole 1024px surface. This draws over the other tiles with a fast mode render, even though those other tiles don't need repainted. This fixes it by reusing draw_surface_src_rect_to_dst which clips the canvas properly so we only draw the 512x512px of the tile. AI-assisted-by: claude-fable-5-2 --- render-wasm/src/render/surfaces.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/render-wasm/src/render/surfaces.rs b/render-wasm/src/render/surfaces.rs index 47a89c8521..387f0ba856 100644 --- a/render-wasm/src/render/surfaces.rs +++ b/render-wasm/src/render/surfaces.rs @@ -1516,27 +1516,30 @@ impl Surfaces { // paint.set_color(color); // backbuffer_canvas.draw_rect(tile_rect, &paint); + let dst = skia::Rect::from_xywh( + tile_rect.left, + tile_rect.top, + src_rect_f.width(), + src_rect_f.height(), + ); + // Draw current surface directly to target (no snapshot) - self.current.draw( + draw_surface_src_rect_to_dst( + &mut self.current, backbuffer_canvas, - ( - tile_rect.left - src_rect_f.left, - tile_rect.top - src_rect_f.top, - ), + src_rect_f, + dst, sampling_options, - None, ); // Also draw to cache for render_from_cache if draw_on_cache == DrawOnCache::Yes { - self.current.draw( + draw_surface_src_rect_to_dst( + &mut self.current, self.cache.canvas(), - ( - tile_rect.left - src_rect_f.left, - tile_rect.top - src_rect_f.top, - ), + src_rect_f, + dst, sampling_options, - None, ); } }