aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-04-25 05:44:41 +0100
committerAkshay <[email protected]>2021-04-25 05:44:41 +0100
commit092e187304c596f35b8ef9d7ca71850418d8a05d (patch)
tree85d9c1937f480b0c36902a9492d1c854b279a8a0
parentc322b0ffd7a0baa31b200cec82aa386c26188b53 (diff)
cache entire brush info
-rw-r--r--src/app.rs7
-rw-r--r--src/cache.rs4
2 files changed, 7 insertions, 4 deletions
diff --git a/src/app.rs b/src/app.rs
index 66a27e3..23458f4 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -86,7 +86,7 @@ impl<'ctx> AppState<'ctx> {
86 pub fn cache(&self) { 86 pub fn cache(&self) {
87 let mut cache = self.cache.borrow_mut(); 87 let mut cache = self.cache.borrow_mut();
88 *cache = Some(Cache { 88 *cache = Some(Cache {
89 last_brush_size: self.brush.size().unwrap_or(0), 89 last_brush: self.brush,
90 }); 90 });
91 } 91 }
92 92
@@ -228,6 +228,7 @@ impl<'ctx> AppState<'ctx> {
228 } 228 }
229 } 229 }
230 ModifyRecord::Invert => self.pixmap.invert(), 230 ModifyRecord::Invert => self.pixmap.invert(),
231 // TODO: use this kind of modify record on brush change
231 ModifyRecord::Brush { old, new } => { 232 ModifyRecord::Brush { old, new } => {
232 match op_kind { 233 match op_kind {
233 OpKind::Undo => self.brush = old, 234 OpKind::Undo => self.brush = old,
@@ -765,7 +766,7 @@ impl<'ctx> AppState<'ctx> {
765 self.cache 766 self.cache
766 .borrow() 767 .borrow()
767 .as_ref() 768 .as_ref()
768 .map(|c| c.last_brush_size) 769 .map(|c| c.last_brush.size().unwrap_or(0))
769 .unwrap_or(0), 770 .unwrap_or(0),
770 true, 771 true,
771 ); 772 );
@@ -780,7 +781,7 @@ impl<'ctx> AppState<'ctx> {
780 self.cache 781 self.cache
781 .borrow() 782 .borrow()
782 .as_ref() 783 .as_ref()
783 .map(|c| c.last_brush_size) 784 .map(|c| c.last_brush.size().unwrap_or(0))
784 .unwrap_or(0), 785 .unwrap_or(0),
785 ); 786 );
786 } 787 }
diff --git a/src/cache.rs b/src/cache.rs
index 249eca9..f25d274 100644
--- a/src/cache.rs
+++ b/src/cache.rs
@@ -1,3 +1,5 @@
1use crate::brush::Brush;
2
1pub struct Cache { 3pub struct Cache {
2 pub last_brush_size: u8, 4 pub last_brush: Brush,
3} 5}