mirror of
https://github.com/penpot/penpot.git
synced 2025-06-07 12:41:41 +02:00
🎉 Cache extra tiles
This commit is contained in:
parent
e8549ffb79
commit
08fc32cdc6
2 changed files with 15 additions and 10 deletions
|
@ -28,6 +28,8 @@ pub use blend::BlendMode;
|
||||||
pub use fonts::*;
|
pub use fonts::*;
|
||||||
pub use images::*;
|
pub use images::*;
|
||||||
|
|
||||||
|
// This is the extra are used for tile rendering.
|
||||||
|
const VIEWPORT_INTEREST_AREA_THRESHOLD: i32 = 1;
|
||||||
const MAX_BLOCKING_TIME_MS: i32 = 32;
|
const MAX_BLOCKING_TIME_MS: i32 = 32;
|
||||||
const NODE_BATCH_THRESHOLD: i32 = 10;
|
const NODE_BATCH_THRESHOLD: i32 = 10;
|
||||||
|
|
||||||
|
@ -449,17 +451,12 @@ impl RenderState {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
let (sx, sy, ex, ey) = tiles::get_tiles_for_viewbox(self.viewbox);
|
// TODO: Maybe we should calculate the interest area based on the actual viewport. See how.
|
||||||
|
let (sx, sy, ex, ey) = tiles::get_tiles_for_viewbox_with_interest(
|
||||||
|
self.viewbox,
|
||||||
|
VIEWPORT_INTEREST_AREA_THRESHOLD,
|
||||||
|
);
|
||||||
debug::render_debug_tiles_for_viewbox(self, sx, sy, ex, ey);
|
debug::render_debug_tiles_for_viewbox(self, sx, sy, ex, ey);
|
||||||
/*
|
|
||||||
// TODO: Instead of rendering only the visible area
|
|
||||||
// we could apply an offset to the viewbox to render
|
|
||||||
// more tiles.
|
|
||||||
sx - interest_delta
|
|
||||||
sy - interest_delta
|
|
||||||
ex + interest_delta
|
|
||||||
ey + interest_delta
|
|
||||||
*/
|
|
||||||
let tile_center = ((ex - sx) / 2, (ey - sy) / 2);
|
let tile_center = ((ex - sx) / 2, (ey - sy) / 2);
|
||||||
self.pending_tiles = vec![];
|
self.pending_tiles = vec![];
|
||||||
self.surfaces.cache_clear_visited();
|
self.surfaces.cache_clear_visited();
|
||||||
|
|
|
@ -33,6 +33,14 @@ pub fn get_tiles_for_viewbox(viewbox: Viewbox) -> (i32, i32, i32, i32) {
|
||||||
get_tiles_for_rect(viewbox.area, tile_size)
|
get_tiles_for_rect(viewbox.area, tile_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_tiles_for_viewbox_with_interest(
|
||||||
|
viewbox: Viewbox,
|
||||||
|
interest: i32,
|
||||||
|
) -> (i32, i32, i32, i32) {
|
||||||
|
let (sx, sy, ex, ey) = get_tiles_for_viewbox(viewbox);
|
||||||
|
(sx - interest, sy - interest, ex + interest, ey + interest)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_tile_pos(viewbox: Viewbox, (x, y): Tile) -> (f32, f32) {
|
pub fn get_tile_pos(viewbox: Viewbox, (x, y): Tile) -> (f32, f32) {
|
||||||
(
|
(
|
||||||
x as f32 * get_tile_size(viewbox),
|
x as f32 * get_tile_size(viewbox),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue