🔧 Keep clear cached canvas

This commit is contained in:
Elena Torro
2026-01-22 08:51:58 +01:00
parent aab1d97c4c
commit 5d7d23a2c7
2 changed files with 7 additions and 6 deletions

View File

@@ -1770,7 +1770,9 @@ impl RenderState {
if !matches!(element.shape_type, Type::Bool(_)) {
// Nested shapes shadowing - apply black shadow to child shapes too
for shadow_shape_id in element.children.iter() {
let shadow_shape = tree.get(shadow_shape_id).unwrap();
let Some(shadow_shape) = tree.get(shadow_shape_id) else {
continue;
};
if shadow_shape.hidden {
continue;
}
@@ -2190,7 +2192,7 @@ impl RenderState {
}
// Invalidate changed tiles - old content stays visible until new tiles render
self.surfaces.remove_cached_tiles();
self.surfaces.remove_cached_tiles(self.background_color);
for tile in all_tiles {
self.remove_cached_tile(tile);
}
@@ -2237,7 +2239,7 @@ impl RenderState {
}
// Invalidate changed tiles - old content stays visible until new tiles render
self.surfaces.remove_cached_tiles();
self.surfaces.remove_cached_tiles(self.background_color);
for tile in all_tiles {
self.remove_cached_tile(tile);
}

View File

@@ -421,10 +421,9 @@ impl Surfaces {
.draw_image_rect(&image, None, rect, &skia::Paint::default());
}
pub fn remove_cached_tiles(&mut self) {
// New tiles will overwrite old content atomically when rendered,
// preventing flickering during bulk invalidation.
pub fn remove_cached_tiles(&mut self, color: skia::Color) {
self.tiles.clear();
self.cache.canvas().clear(color);
}
pub fn gc(&mut self) {