Skip to content

Commit

Permalink
Dont panic on wrong mask size (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyMeilex authored Aug 15, 2023
1 parent a9b4450 commit a3df9ed
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,22 +540,28 @@ fn draw_headerbar(
if let Some(clip) =
Rect::from_xywh(text_canvas_start_x, 0., text_canvas_end_x, canvas_h)
{
let mut mask = Mask::new(canvas_w as u32, canvas_h as u32)
.expect("Invalid mask width and height");
mask.fill_path(
&PathBuilder::from_rect(clip),
FillRule::Winding,
false,
Transform::identity(),
);
pixmap.draw_pixmap(
x as i32,
y as i32,
text_pixmap.as_ref(),
&PixmapPaint::default(),
Transform::identity(),
Some(&mask),
);
if let Some(mut mask) = Mask::new(canvas_w as u32, canvas_h as u32) {
mask.fill_path(
&PathBuilder::from_rect(clip),
FillRule::Winding,
false,
Transform::identity(),
);
pixmap.draw_pixmap(
x as i32,
y as i32,
text_pixmap.as_ref(),
&PixmapPaint::default(),
Transform::identity(),
Some(&mask),
);
} else {
log::error!(
"Invalid mask width and height: w: {}, h: {}",
canvas_w as u32,
canvas_h as u32
);
}
}
}
}
Expand Down

0 comments on commit a3df9ed

Please sign in to comment.