WIP - drawlib - clippy fixes

cepetr/drawlib-integration
cepetr 2 months ago
parent ef54be2ef4
commit 1b72542259

@ -51,6 +51,8 @@ test = [
"micropython",
"protobuf",
"ui",
"ui_jpeg_decoder",
"ui_blurring",
"dma2d",
"touch",
"backlight",

@ -11,7 +11,7 @@ pub const PI4: i16 = 45;
/// Angle must be in range <0..PI4>.
/// This function provides an error within +-1 for multiplier up to 500
pub fn sin_i16(angle: i16, mult: i16) -> i16 {
assert!(angle >= 0 && angle <= PI4);
assert!((0..=PI4).contains(&angle));
assert!(mult <= 2500);
type T = i32;

@ -129,7 +129,7 @@ impl<'a> Bitmap<'a> {
) -> Option<Self> {
let mut bitmap = Self::new(format, stride, size, min_height, buff)?;
bitmap.mutable = true;
return Some(bitmap);
Some(bitmap)
}
/// Returns bitmap width in pixels.
@ -158,7 +158,7 @@ impl<'a> Bitmap<'a> {
}
pub fn view(&self) -> BitmapView {
BitmapView::new(&self)
BitmapView::new(self)
}
/// Returns the specified row as an immutable slice.
@ -221,6 +221,8 @@ impl<'a> Bitmap<'a> {
/// Return raw mut pointer to the specified bitmap row.
///
/// # Safety
///
/// `y` must be in range <0; self.height() - 1>.
pub unsafe fn row_ptr(&self, y: u16) -> *mut cty::c_void {
unsafe { self.ptr.add(self.stride() * y as usize) as *mut cty::c_void }
@ -267,25 +269,19 @@ impl<'a> BitmapView<'a> {
/// Builds a new structure with offset set to the specified value
pub fn with_offset(self, offset: Offset) -> Self {
Self {
offset: (offset + self.offset.into()).into(),
offset: offset + self.offset,
..self
}
}
/// Builds a new structure with foreground color set to the specified value
pub fn with_fg(self, fg_color: Color) -> Self {
Self {
fg_color: fg_color.into(),
..self
}
Self { fg_color, ..self }
}
/// Builds a new structure with background color set to the specified value
pub fn with_bg(self, bg_color: Color) -> Self {
Self {
bg_color: bg_color.into(),
..self
}
Self { bg_color, ..self }
}
/// Returns the bitmap width and height in pixels

@ -1,6 +1,6 @@
pub mod bitmap;
pub mod bitmap_base;
pub mod mono8;
pub mod rgb565;
pub mod rgba8888;
pub use bitmap::{Bitmap, BitmapFormat, BitmapView};
pub use bitmap_base::{Bitmap, BitmapFormat, BitmapView};

@ -778,15 +778,11 @@ fn fill_octant(
// Intersection of the p1 line and the circle
let mut p2_start = p1_start;
loop {
if let Some(p) = iter.next() {
if p.u > u2 {
break;
}
p2_start = p;
} else {
for p in iter.by_ref() {
if p.u > u2 {
break;
}
p2_start = p;
}
// Flag if we draw section up to 45degs

@ -28,7 +28,7 @@ where
let fb = unsafe {
core::slice::from_raw_parts_mut(
display::get_frame_addr() as *mut u8,
width as usize * height as usize * core::mem::size_of::<u8>(),
width as usize * height as usize,
)
};

@ -137,7 +137,7 @@ impl<'a> Shape<'a> for JpegImage<'a> {
None,
Offset::new(jpeg_size.x, 1),
None,
&mut buff[..]
&buff[..]
),
"Too small buffer"
);

Loading…
Cancel
Save