🐛 Skip atlas writes during pan/zoom fast mode

During view gestures, fast mode renders tiles without shadows or
blur. Writing those tiles into the doc/tile atlas left shadowless
patches when render_from_cache overlayed them on the scaled
preview. Keep the last HQ atlas tiles until the post-gesture
full-quality render completes.
This commit is contained in:
Alejandro Alonso 2026-08-20 10:52:36 +02:00 committed by Elena Torró
parent 5dab689a6e
commit 4cb9f951d2

View File

@ -1109,15 +1109,20 @@ impl RenderState {
} }
let fast_mode = self.options.is_fast_mode(); let fast_mode = self.options.is_fast_mode();
// During pan/zoom (fast mode) tiles are rendered without shadows/blur.
// Do not write them into the doc/tile atlases: render_from_cache overlays
// HQ tile textures on the scaled doc-atlas backdrop, and shadowless tiles
// would leave permanent holes until the post-gesture full render.
if fast_mode {
return Ok(());
}
// Decide *now* (at the first real cache blit) whether we need to clear Cache. // Decide *now* (at the first real cache blit) whether we need to clear Cache.
// This avoids clearing Cache on renders that don't actually paint tiles (e.g. hover/UI), // This avoids clearing Cache on renders that don't actually paint tiles (e.g. hover/UI),
// while still preventing stale pixels from surviving across full-quality renders. // while still preventing stale pixels from surviving across full-quality renders.
if !fast_mode && !self.cache_cleared_this_render { if !self.cache_cleared_this_render {
self.surfaces.clear_cache(self.background_color); self.surfaces.clear_cache(self.background_color);
self.cache_cleared_this_render = true; self.cache_cleared_this_render = true;
} }
// In fast mode the viewport is moving (pan/zoom) so Cache surface
// positions would be wrong — only save to the tile HashMap.
let tile_rect = self.get_current_aligned_tile_bounds()?; let tile_rect = self.get_current_aligned_tile_bounds()?;
let current_tile = *self let current_tile = *self
@ -1133,7 +1138,7 @@ impl RenderState {
&self.tile_viewbox, &self.tile_viewbox,
&current_tile, &current_tile,
&tile_rect, &tile_rect,
fast_mode, false,
self.render_area, self.render_area,
); );
@ -4198,8 +4203,9 @@ impl RenderState {
} }
/// Rebuild the tile index (shape→tile mapping) for all top-level shapes. /// Rebuild the tile index (shape→tile mapping) for all top-level shapes.
/// This does NOT invalidate the tile texture cache — cached tile images /// This does NOT invalidate the tile texture cache — existing HQ tiles
/// survive so that fast-mode renders during pan still show shadows/blur. /// survive across pan so `render_from_cache` keeps showing shadows/blur
/// until the post-gesture full render replaces them.
pub fn rebuild_tile_index(&mut self, tree: ShapesPoolRef) { pub fn rebuild_tile_index(&mut self, tree: ShapesPoolRef) {
let zoom_changed = self.zoom_changed(); let zoom_changed = self.zoom_changed();
performance::begin_measure!("rebuild_tile_index"); performance::begin_measure!("rebuild_tile_index");