mirror of
https://github.com/penpot/penpot.git
synced 2026-08-18 02:39:02 +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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let fast_mode = self.options.is_fast_mode();
|
// Track that this render painted tiles (drives cached_viewbox). The
|
||||||
// Decide *now* (at the first real cache blit) whether we need to clear Cache.
|
// Cache surface itself is unused by `render_from_cache` (DocAtlas +
|
||||||
// This avoids clearing Cache on renders that don't actually paint tiles (e.g. hover/UI),
|
// tile atlas), so skip clearing/filling it here.
|
||||||
// while still preventing stale pixels from surviving across full-quality renders.
|
self.cache_cleared_this_render = true;
|
||||||
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.
|
|
||||||
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
|
||||||
@ -1112,11 +1106,14 @@ impl RenderState {
|
|||||||
crate::get_gpu_state().context.flush_and_submit();
|
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.surfaces.draw_current_tile_into_tile_atlas(
|
||||||
&self.tile_viewbox,
|
&self.tile_viewbox,
|
||||||
¤t_tile,
|
¤t_tile,
|
||||||
&tile_rect,
|
&tile_rect,
|
||||||
fast_mode,
|
true,
|
||||||
self.render_area,
|
self.render_area,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -3709,7 +3706,7 @@ impl RenderState {
|
|||||||
self.surfaces.draw_current_tile_into_backbuffer(
|
self.surfaces.draw_current_tile_into_backbuffer(
|
||||||
&tile_rect,
|
&tile_rect,
|
||||||
self.background_color,
|
self.background_color,
|
||||||
surfaces::DrawOnCache::Yes,
|
surfaces::DrawOnCache::No,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
self.apply_render_to_final_canvas()?;
|
self.apply_render_to_final_canvas()?;
|
||||||
|
|||||||
@ -1199,7 +1199,8 @@ impl Surfaces {
|
|||||||
let tile_image_opt = self.current.image_snapshot_with_bounds(rect);
|
let tile_image_opt = self.current.image_snapshot_with_bounds(rect);
|
||||||
if let Some(tile_image) = tile_image_opt {
|
if let Some(tile_image) = tile_image_opt {
|
||||||
if !skip_cache_surface {
|
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(
|
self.cache.canvas().draw_image_rect(
|
||||||
&tile_image,
|
&tile_image,
|
||||||
None,
|
None,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user