mirror of https://github.com/penpot/penpot.git
🔧 Update rendering settings to smooth render
This commit is contained in:
parent
a38f425dd3
commit
9216d965ef
|
|
@ -59,6 +59,9 @@
|
||||||
|
|
||||||
(def ^:const MAX_BUFFER_CHUNK_SIZE (* 256 1024))
|
(def ^:const MAX_BUFFER_CHUNK_SIZE (* 256 1024))
|
||||||
|
|
||||||
|
(def ^:const DEBOUNCE_DELAY_MS 100)
|
||||||
|
(def ^:const THROTTLE_DELAY_MS 10)
|
||||||
|
|
||||||
(def dpr
|
(def dpr
|
||||||
(if use-dpr? (if (exists? js/window) js/window.devicePixelRatio 1.0) 1.0))
|
(if use-dpr? (if (exists? js/window) js/window.devicePixelRatio 1.0) 1.0))
|
||||||
|
|
||||||
|
|
@ -873,10 +876,10 @@
|
||||||
(letfn [(do-render [ts]
|
(letfn [(do-render [ts]
|
||||||
(h/call wasm/internal-module "_set_view_end")
|
(h/call wasm/internal-module "_set_view_end")
|
||||||
(render ts))]
|
(render ts))]
|
||||||
(fns/debounce do-render 100)))
|
(fns/debounce do-render DEBOUNCE_DELAY_MS)))
|
||||||
|
|
||||||
(def render-pan
|
(def render-pan
|
||||||
(fns/throttle render 10))
|
(fns/throttle render THROTTLE_DELAY_MS))
|
||||||
|
|
||||||
(defn set-view-box
|
(defn set-view-box
|
||||||
[prev-zoom zoom vbox]
|
[prev-zoom zoom vbox]
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,9 @@ pub use fonts::*;
|
||||||
pub use images::*;
|
pub use images::*;
|
||||||
|
|
||||||
// This is the extra are used for tile rendering.
|
// This is the extra are used for tile rendering.
|
||||||
const VIEWPORT_INTEREST_AREA_THRESHOLD: i32 = 1;
|
const VIEWPORT_INTEREST_AREA_THRESHOLD: i32 = 2;
|
||||||
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 = 3;
|
||||||
|
|
||||||
type ClipStack = Vec<(Rect, Option<Corners>, Matrix)>;
|
type ClipStack = Vec<(Rect, Option<Corners>, Matrix)>;
|
||||||
|
|
||||||
|
|
@ -1734,6 +1734,7 @@ impl RenderState {
|
||||||
allow_stop: bool,
|
allow_stop: bool,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
let mut should_stop = false;
|
let mut should_stop = false;
|
||||||
|
|
||||||
while !should_stop {
|
while !should_stop {
|
||||||
if let Some(current_tile) = self.current_tile {
|
if let Some(current_tile) = self.current_tile {
|
||||||
if self.surfaces.has_cached_tile_surface(current_tile) {
|
if self.surfaces.has_cached_tile_surface(current_tile) {
|
||||||
|
|
@ -1807,17 +1808,21 @@ impl RenderState {
|
||||||
|
|
||||||
if !self.surfaces.has_cached_tile_surface(next_tile) {
|
if !self.surfaces.has_cached_tile_surface(next_tile) {
|
||||||
if let Some(ids) = self.tiles.get_shapes_at(next_tile) {
|
if let Some(ids) = self.tiles.get_shapes_at(next_tile) {
|
||||||
|
let root_ids_map: std::collections::HashMap<Uuid, usize> = root_ids
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(i, id)| (*id, i))
|
||||||
|
.collect();
|
||||||
|
|
||||||
// We only need first level shapes
|
// We only need first level shapes
|
||||||
let mut valid_ids: Vec<Uuid> = ids
|
let mut valid_ids: Vec<Uuid> = ids
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|id| root_ids.contains(id))
|
.filter(|id| root_ids_map.contains_key(id))
|
||||||
.copied()
|
.copied()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// These shapes for the tile should be ordered as they are in the parent node
|
// These shapes for the tile should be ordered as they are in the parent node
|
||||||
valid_ids.sort_by_key(|id| {
|
valid_ids.sort_by_key(|id| root_ids_map.get(id).unwrap_or(&usize::MAX));
|
||||||
root_ids.iter().position(|x| x == id).unwrap_or(usize::MAX)
|
|
||||||
});
|
|
||||||
|
|
||||||
self.pending_nodes.extend(valid_ids.into_iter().map(|id| {
|
self.pending_nodes.extend(valid_ids.into_iter().map(|id| {
|
||||||
NodeRenderState {
|
NodeRenderState {
|
||||||
|
|
@ -1834,6 +1839,7 @@ impl RenderState {
|
||||||
should_stop = true;
|
should_stop = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.render_in_progress = false;
|
self.render_in_progress = false;
|
||||||
|
|
||||||
self.surfaces.gc();
|
self.surfaces.gc();
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ use super::{gpu_state::GpuState, tiles::Tile, tiles::TileViewbox, tiles::TILE_SI
|
||||||
use base64::{engine::general_purpose, Engine as _};
|
use base64::{engine::general_purpose, Engine as _};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
const TEXTURES_CACHE_CAPACITY: usize = 512;
|
const TEXTURES_CACHE_CAPACITY: usize = 1024;
|
||||||
const TEXTURES_BATCH_DELETE: usize = 32;
|
const TEXTURES_BATCH_DELETE: usize = 256;
|
||||||
// This is the amount of extra space we're going to give to all the surfaces to render shapes.
|
// This is the amount of extra space we're going to give to all the surfaces to render shapes.
|
||||||
// If it's too big it could affect performance.
|
// If it's too big it could affect performance.
|
||||||
const TILE_SIZE_MULTIPLIER: i32 = 2;
|
const TILE_SIZE_MULTIPLIER: i32 = 2;
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ impl TileViewbox {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_visible(&self, tile: &Tile) -> bool {
|
pub fn is_visible(&self, tile: &Tile) -> bool {
|
||||||
|
// TO CHECK self.interest_rect.contains(tile)
|
||||||
self.visible_rect.contains(tile)
|
self.visible_rect.contains(tile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue