mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-18 18:38:05 +08:00
Improve rendering efficiency and add caching (#95)
Fixes #84 *Reduce heap allocations * Add caching for rendering svgs * Deduplicate UpdateCanvas Responses
This commit is contained in:
committed by
Keavon Chambers
parent
457c465342
commit
fc10575dfa
@@ -2,6 +2,8 @@ use crate::{DocumentError, LayerId};
|
||||
|
||||
use super::{Layer, LayerData, LayerDataTypes};
|
||||
|
||||
use std::fmt::Write;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Folder {
|
||||
next_assignment_id: LayerId,
|
||||
@@ -10,12 +12,10 @@ pub struct Folder {
|
||||
}
|
||||
|
||||
impl LayerData for Folder {
|
||||
fn render(&self) -> String {
|
||||
self.layers
|
||||
.iter()
|
||||
.filter(|layer| layer.visible)
|
||||
.map(|layer| layer.data.render())
|
||||
.fold(String::with_capacity(self.layers.len() * 30), |s, n| s + "\n" + &n)
|
||||
fn render(&mut self, svg: &mut String) {
|
||||
self.layers.iter_mut().for_each(|layer| {
|
||||
let _ = writeln!(svg, "{}", layer.render());
|
||||
});
|
||||
}
|
||||
}
|
||||
impl Folder {
|
||||
|
||||
Reference in New Issue
Block a user