mirror of
https://github.com/yuri91/ili9341-rs.git
synced 2024-11-21 22:30:59 +00:00
Implement optimized DrawTarget::clear
This commit is contained in:
parent
7f678b7e9f
commit
8c45de7e90
1 changed files with 13 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::{Ili9341, Interface, OutputPin};
|
||||
|
||||
use core::fmt::Debug;
|
||||
use core::{fmt::Debug, iter};
|
||||
|
||||
use embedded_graphics::{
|
||||
drawable::Pixel,
|
||||
|
@ -26,6 +26,7 @@ where
|
|||
fn size(&self) -> Size {
|
||||
Size::new(self.width as u32, self.height as u32)
|
||||
}
|
||||
|
||||
fn draw_pixel(&mut self, pixel: Pixel<Rgb565>) -> Result<(), Self::Error> {
|
||||
let Pixel(pos, color) = pixel;
|
||||
|
||||
|
@ -41,6 +42,7 @@ where
|
|||
&[RawU16::from(color).into_inner()],
|
||||
)
|
||||
}
|
||||
|
||||
fn draw_rectangle(
|
||||
&mut self,
|
||||
item: &Styled<Rectangle, PrimitiveStyle<Rgb565>>,
|
||||
|
@ -78,4 +80,14 @@ where
|
|||
.map(|p| RawU16::from(p.1).into_inner()),
|
||||
)
|
||||
}
|
||||
|
||||
fn clear(&mut self, color: Rgb565) -> Result<(), Self::Error> {
|
||||
self.draw_iter(
|
||||
0,
|
||||
0,
|
||||
(self.width - 1) as u16,
|
||||
(self.height - 1) as u16,
|
||||
iter::repeat(RawU16::from(color).into_inner()).take(self.width * self.height),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue