mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
🔧 Improve tile invalidation to prevent visual flickering
When tiles are invalidated (during shape updates or page loading), the old tile content is now kept visible until new content is rendered to replace it. This provides a smoother visual experience during updates.
This commit is contained in:
parent
962d7839a2
commit
499aac31a4
@ -2168,9 +2168,7 @@ impl RenderState {
|
||||
}
|
||||
|
||||
pub fn remove_cached_tile(&mut self, tile: tiles::Tile) {
|
||||
let rect = self.get_aligned_tile_bounds(tile);
|
||||
self.surfaces
|
||||
.remove_cached_tile_surface(tile, rect, self.background_color);
|
||||
self.surfaces.remove_cached_tile_surface(tile);
|
||||
}
|
||||
|
||||
pub fn rebuild_tiles_shallow(&mut self, tree: ShapesPoolRef) {
|
||||
@ -2191,8 +2189,8 @@ impl RenderState {
|
||||
}
|
||||
}
|
||||
|
||||
// Update the changed tiles
|
||||
self.surfaces.remove_cached_tiles(self.background_color);
|
||||
// Invalidate changed tiles - old content stays visible until new tiles render
|
||||
self.surfaces.remove_cached_tiles();
|
||||
for tile in all_tiles {
|
||||
self.remove_cached_tile(tile);
|
||||
}
|
||||
@ -2238,8 +2236,8 @@ impl RenderState {
|
||||
}
|
||||
}
|
||||
|
||||
// Update the changed tiles
|
||||
self.surfaces.remove_cached_tiles(self.background_color);
|
||||
// Invalidate changed tiles - old content stays visible until new tiles render
|
||||
self.surfaces.remove_cached_tiles();
|
||||
for tile in all_tiles {
|
||||
self.remove_cached_tile(tile);
|
||||
}
|
||||
|
||||
@ -401,11 +401,10 @@ impl Surfaces {
|
||||
self.tiles.has(tile)
|
||||
}
|
||||
|
||||
pub fn remove_cached_tile_surface(&mut self, tile: Tile, rect: skia::Rect, color: skia::Color) {
|
||||
// Clear the specific tile area in the cache surface with color
|
||||
let mut paint = skia::Paint::default();
|
||||
paint.set_color(color);
|
||||
self.cache.canvas().draw_rect(rect, &paint);
|
||||
pub fn remove_cached_tile_surface(&mut self, tile: Tile) {
|
||||
// Mark tile as invalid
|
||||
// Old content stays visible until new tile overwrites it atomically,
|
||||
// preventing flickering during tile re-renders.
|
||||
self.tiles.remove(tile);
|
||||
}
|
||||
|
||||
@ -422,9 +421,10 @@ impl Surfaces {
|
||||
.draw_image_rect(&image, None, rect, &skia::Paint::default());
|
||||
}
|
||||
|
||||
pub fn remove_cached_tiles(&mut self, color: skia::Color) {
|
||||
pub fn remove_cached_tiles(&mut self) {
|
||||
// New tiles will overwrite old content atomically when rendered,
|
||||
// preventing flickering during bulk invalidation.
|
||||
self.tiles.clear();
|
||||
self.cache.canvas().clear(color);
|
||||
}
|
||||
|
||||
pub fn gc(&mut self) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user