Skip to content

Commit 8903cb7

Browse files
committed
Optimize display clearing
1 parent 80599a5 commit 8903cb7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/mode/buffered_graphics.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@ where
7171
/// Clear the display buffer. You need to call `disp.flush()` for any effect on the screen
7272
#[cfg(not(feature = "graphics"))]
7373
pub fn clear(&mut self) {
74+
self.clear_impl(false);
75+
}
76+
77+
fn clear_impl(&mut self, value: bool) {
7478
for b in self.mode.buffer.as_mut() {
75-
*b = 0;
79+
*b = value as u8;
7680
}
7781

7882
let (width, height) = self.dimensions();
@@ -226,6 +230,11 @@ where
226230

227231
Ok(())
228232
}
233+
234+
fn clear(&mut self, color: Self::Color) -> Result<(), Self::Error> {
235+
self.clear_impl(color.is_on());
236+
Ok(())
237+
}
229238
}
230239

231240
#[cfg(feature = "graphics")]

0 commit comments

Comments
 (0)