mirror of
https://github.com/penpot/penpot.git
synced 2026-08-07 21:38:48 +00:00
⚡ Skip unused Cache surface blit on tile complete
render_from_cache composites DocAtlas and tile-atlas textures, not the Cache surface. Stop clearing and filling Cache per completed tile to avoid wasted full-tile GPU copies during progressive render.
This commit is contained in:
parent
53e048bbae
commit
1edc982bc3
@ -1091,16 +1091,10 @@ impl RenderState {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let fast_mode = self.options.is_fast_mode();
|
||||
// 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),
|
||||
// while still preventing stale pixels from surviving across full-quality renders.
|
||||
if !fast_mode && !self.cache_cleared_this_render {
|
||||
self.surfaces.clear_cache(self.background_color);
|
||||
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.
|
||||
// Track that this render painted tiles (drives cached_viewbox). The
|
||||
// Cache surface itself is unused by `render_from_cache` (DocAtlas +
|
||||
// tile atlas), so skip clearing/filling it here.
|
||||
self.cache_cleared_this_render = true;
|
||||
let tile_rect = self.get_current_aligned_tile_bounds()?;
|
||||
|
||||
let current_tile = *self
|
||||
@ -1112,11 +1106,14 @@ impl RenderState {
|
||||
crate::get_gpu_state().context.flush_and_submit();
|
||||
}
|
||||
|
||||
// Always skip the Cache surface blit: pan/zoom preview reads DocAtlas
|
||||
// and tile-atlas textures, not Cache. Avoids a full-tile GPU copy per
|
||||
// completed tile during progressive renders.
|
||||
self.surfaces.draw_current_tile_into_tile_atlas(
|
||||
&self.tile_viewbox,
|
||||
¤t_tile,
|
||||
&tile_rect,
|
||||
fast_mode,
|
||||
true,
|
||||
self.render_area,
|
||||
);
|
||||
|
||||
@ -3709,7 +3706,7 @@ impl RenderState {
|
||||
self.surfaces.draw_current_tile_into_backbuffer(
|
||||
&tile_rect,
|
||||
self.background_color,
|
||||
surfaces::DrawOnCache::Yes,
|
||||
surfaces::DrawOnCache::No,
|
||||
);
|
||||
} else {
|
||||
self.apply_render_to_final_canvas()?;
|
||||
|
||||
@ -1199,7 +1199,8 @@ impl Surfaces {
|
||||
let tile_image_opt = self.current.image_snapshot_with_bounds(rect);
|
||||
if let Some(tile_image) = tile_image_opt {
|
||||
if !skip_cache_surface {
|
||||
// Draw to cache surface for render_from_cache
|
||||
// Optional legacy Cache surface fill (debug). Pan/zoom preview
|
||||
// uses DocAtlas + tile-atlas textures via render_from_cache.
|
||||
self.cache.canvas().draw_image_rect(
|
||||
&tile_image,
|
||||
None,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user