1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 22:38:08 +00:00

fix(core): ensure circles with radius zero are not rendered

[no changelog]
This commit is contained in:
tychovrahe 2024-05-08 14:53:21 +02:00 committed by TychoVrahe
parent 67fe334dc2
commit 3a8595b43a

View File

@ -375,6 +375,10 @@ pub trait Canvas: BasicCanvas {
// Draws circle with the specified center and the radius.
#[cfg(not(feature = "ui_antialiasing"))]
fn draw_circle(&mut self, center: Point, radius: i16, color: Color, alpha: u8) {
if radius == 0 {
return;
}
let split = unwrap!(circle_points(radius).last()).v;
let r = Rect::new(
@ -437,6 +441,10 @@ pub trait Canvas: BasicCanvas {
/// Draws filled circle with the specified center and the radius.
#[cfg(not(feature = "ui_antialiasing"))]
fn fill_circle(&mut self, center: Point, radius: i16, color: Color, alpha: u8) {
if radius == 0 {
return;
}
let split = unwrap!(circle_points(radius).last()).v;
let r = Rect::new(
@ -500,6 +508,10 @@ pub trait Canvas: BasicCanvas {
/// radius.
#[cfg(feature = "ui_antialiasing")]
fn fill_circle(&mut self, center: Point, radius: i16, color: Color, alpha: u8) {
if radius == 0 {
return;
}
let split = unwrap!(circle_points(radius).last()).v;
let alpha_mul = |a: u8| -> u8 { ((a as u16 * alpha as u16) / 255) as u8 };
@ -590,6 +602,10 @@ pub trait Canvas: BasicCanvas {
mut end: f32,
color: Color,
) {
if radius == 0 {
return;
}
start = (360.0 + start % 360.0) % 360.0;
end = (360.0 + end % 360.0) % 360.0;
@ -715,6 +731,10 @@ fn fill_octant(
mut u2: i16,
fill: &mut impl FnMut(Option<Point>, u8, Point, u8),
) {
if radius == 0 {
return;
}
// Starting end ending points on
if u1 > u2 {
(u1, u2) = (u2, u1);