Merge pull request #10243 from penpot/elenatorro-fix-docatlas-cap

🐛 Fix DocAtlas cap
This commit is contained in:
Alejandro Alonso 2026-06-17 10:42:48 +02:00 committed by GitHub
commit 585d6944fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -9,7 +9,7 @@ const SHOW_WASM_INFO: u32 = 0x08;
// Higher values pre-render more tiles, reducing empty squares during pan but using more memory.
const VIEWPORT_INTEREST_AREA_THRESHOLD: i32 = 1;
const MIN_DPR_VIEWPORT_INTEREST_AREA_THRESHOLD: i32 = 2;
const MAX_BLOCKING_TIME_MS: i32 = 32;
const MAX_BLOCKING_TIME_MS: i32 = 8;
const NODE_BATCH_THRESHOLD: i32 = 3;
const BLUR_DOWNSCALE_THRESHOLD: f32 = 8.0;
const ANTIALIAS_THRESHOLD: f32 = 7.0;

View File

@ -25,6 +25,7 @@ const TILE_DRAWABLE_RECT: IRect = IRect {
right: TILE_MARGIN_SIZE + TILE_SIZE,
bottom: TILE_MARGIN_SIZE + TILE_SIZE,
};
const DOC_ATLAS_MAX_DIM: i32 = 4096;
pub fn get_cache_size(viewbox: &Viewbox, interest: i32) -> skia::ISize {
// First we retrieve the extended area of the viewport that we could render.
@ -178,7 +179,10 @@ impl DocAtlas {
// Compute atlas scale needed to fit within the fixed texture cap.
// Keep the highest possible scale (closest to 1.0) that still fits.
let cap = gpu_state.max_texture_size().max(TILE_SIZE) as f32;
let cap = gpu_state
.max_texture_size()
.clamp(TILE_SIZE, DOC_ATLAS_MAX_DIM) as f32;
let required_scale = (cap / doc_w).min(cap / doc_h).clamp(0.01, 1.0);
// Never upscale the atlas (it would add blur and churn).