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:
TrueDoctor
2021-05-02 21:21:39 +02:00
committed by Keavon Chambers
parent 457c465342
commit fc10575dfa
14 changed files with 123 additions and 73 deletions

View File

@@ -3,6 +3,8 @@ use crate::shape_points;
use super::style;
use super::LayerData;
use std::fmt::Write;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Shape {
shape: shape_points::ShapePoints,
@@ -19,7 +21,7 @@ impl Shape {
}
impl LayerData for Shape {
fn render(&self) -> String {
format!(r#"<polygon points="{}" {} />"#, self.shape, self.style.render(),)
fn render(&mut self, svg: &mut String) {
let _ = write!(svg, r#"<polygon points="{}" {} />"#, self.shape, self.style.render(),);
}
}