mirror of
https://github.com/penpot/penpot.git
synced 2025-05-22 22:26:11 +02:00
Merge pull request #6137 from penpot/superalex-rendering-wasm-performance
🎉 Avoid rendering too small shapes
This commit is contained in:
commit
3cf823ffb3
8 changed files with 128 additions and 65 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue