🐛 Fix performance regression

This commit is contained in:
Alejandro Alonso 2026-06-18 13:13:20 +02:00
parent 3d2a5a2957
commit f6f716de3a
2 changed files with 0 additions and 65 deletions

View File

@ -1026,10 +1026,6 @@ impl RenderState {
self.render_area,
);
let rect = self.get_current_tile_bounds()?;
self.surfaces
.draw_cached_tile_into_backbuffer(current_tile, &rect);
Ok(())
}
@ -2015,24 +2011,6 @@ impl RenderState {
self.surfaces
.draw_atlas_to_backbuffer(self.viewbox, bg_color);
// For pure pan (same zoom), overlay any cached per-tile textures on top of the atlas.
// This reduces the "rubbery"/distorted look of atlas-only previews while keeping
// fast-mode responsive. For zoom, the tile grid changes so cached tiles would be
// mispositioned — skip them.
if !self.zoom_changed() {
let visible_rect = tiles::get_tiles_for_viewbox(&self.viewbox);
let offset = self.viewbox.get_offset();
for tx in visible_rect.x1()..=visible_rect.x2() {
for ty in visible_rect.y1()..=visible_rect.y2() {
let tile = tiles::Tile::from(tx, ty);
if self.surfaces.has_cached_tile_surface(tile) {
let rect = tile.get_rect_with_offset(&offset);
self.surfaces.draw_cached_tile_into_backbuffer(tile, &rect);
}
}
}
}
self.present_frame(shapes);
performance::end_measure!("render_from_cache");
performance::end_timed_log!("render_from_cache", _start);
@ -2105,27 +2083,6 @@ impl RenderState {
// Draw directly from cache surface, avoiding snapshot overhead
self.surfaces.draw_cache_to_backbuffer();
// During pure pan (same zoom), draw tiles from the HashMap
// on top of the scaled Cache surface. Cached tile textures
// include full-quality effects (shadows, blur) from the last
// render, so blitting them avoids re-rendering and keeps pan
// smooth. During zoom the tile grid changes so HashMap tiles
// would be at wrong positions — skip them and let the full
// render after set_view_end handle it.
if !self.zoom_changed() {
let visible_rect = tiles::get_tiles_for_viewbox(&self.viewbox);
let offset = self.viewbox.get_offset();
for tx in visible_rect.x1()..=visible_rect.x2() {
for ty in visible_rect.y1()..=visible_rect.y2() {
let tile = tiles::Tile::from(tx, ty);
if self.surfaces.has_cached_tile_surface(tile) {
let rect = tile.get_rect_with_offset(&offset);
self.surfaces.draw_cached_tile_into_backbuffer(tile, &rect);
}
}
}
}
self.present_frame(shapes);
}

View File

@ -1323,28 +1323,6 @@ impl Surfaces {
let _ = self.atlas.clear_tile_in_atlas(gpu_state, tile);
}
pub fn get_tile_image_from_tile_atlas(&mut self, tile: Tile) -> Option<skia::Image> {
let Some(tile_ref) = self.tiles.get(tile) else {
panic!("Tile not found {}:{}", tile.0, tile.1);
};
let rect = IRect::from_ltrb(
tile_ref.rect.left as i32,
tile_ref.rect.top as i32,
tile_ref.rect.right as i32,
tile_ref.rect.bottom as i32,
);
self.tile_atlas.image_snapshot_with_bounds(rect)
}
pub fn draw_cached_tile_into_backbuffer(&mut self, tile: Tile, rect: &Rect) {
if let Some(image) = self.get_tile_image_from_tile_atlas(tile) {
// let rect = tile.get_rect_with_offset(&offset);
let backbuffer_canvas = self.backbuffer.canvas();
backbuffer_canvas.draw_image_rect(&image, None, rect, &skia::Paint::default());
}
}
/// Draws the current tile directly to the backbuffer and cache surfaces without
/// creating a snapshot. This avoids GPU stalls from ReadPixels but doesn't
/// populate the tile texture cache (suitable for one-shot renders like tests).