Merge pull request #6137 from penpot/superalex-rendering-wasm-performance

🎉 Avoid rendering too small shapes
This commit is contained in:
Aitor Moreno
2025-03-27 10:22:02 +01:00
committed by GitHub
8 changed files with 128 additions and 65 deletions

View File

@@ -42,6 +42,9 @@ pub use transform::*;
use crate::math;
use crate::math::{Bounds, Matrix, Point};
const MIN_VISIBLE_SIZE: f32 = 2.0;
const ANTIALIAS_THRESHOLD: f32 = 15.0;
#[derive(Debug, Clone, PartialEq)]
pub enum Type {
Frame(Frame),
@@ -572,6 +575,16 @@ impl Shape {
self.hidden
}
pub fn visually_insignificant(&self, scale: f32) -> bool {
self.selrect.width() * scale < MIN_VISIBLE_SIZE
|| self.selrect.height() * scale < MIN_VISIBLE_SIZE
}
pub fn should_use_antialias(&self, scale: f32) -> bool {
self.selrect.width() * scale > ANTIALIAS_THRESHOLD
|| self.selrect.height() * scale > ANTIALIAS_THRESHOLD
}
// TODO: Maybe store this inside the shape
pub fn bounds(&self) -> Bounds {
let mut bounds = Bounds::new(