Size2D<f64> -> Size2D<u32> in canvas_traits::canvas::Canvas2dMsg

Changed the variants `canvas_traits::canvas::Canvas2dMsg::DrawEmptyImage` and
`canvas_traits::canvas::Canvas2dMsg::DrawImageInOther` to use
`euclid::default::Size2D<u32>` instead of `euclid::default::Size2D<f64>`. Every
other change made in this commit is either:
 - of similar nature, and is the minimum that would allow compilation
 - resolving lints triggered by the former

This commit includes changes to the following components:
 - canvas
 - script
 - shared/canvas

Signed-off-by: hashcatHitman <155700084+hashcatHitman@users.noreply.github.com>
This commit is contained in:
hashcatHitman 2025-06-01 16:08:17 -04:00
parent 326a2e9ab6
commit 892edc0048
No known key found for this signature in database
3 changed files with 18 additions and 18 deletions

View file

@ -187,7 +187,7 @@ impl<'a> CanvasPaintThread<'a> {
Canvas2dMsg::DrawEmptyImage(image_size, dest_rect, source_rect) => {
self.canvas(canvas_id).draw_image(
&vec![0; image_size.area() as usize * 4],
image_size.to_u32(),
image_size,
dest_rect,
source_rect,
false,
@ -203,7 +203,7 @@ impl<'a> CanvasPaintThread<'a> {
) => {
let image_data = self
.canvas(canvas_id)
.read_pixels(Some(source_rect.to_u32()), Some(image_size.to_u32()));
.read_pixels(Some(source_rect.to_u32()), Some(image_size));
self.canvas(other_canvas_id).draw_image(
image_data.data(),
source_rect.size.to_u32(),

View file

@ -531,11 +531,11 @@ impl CanvasState {
};
// Step 4. Establish the source and destination rectangles.
let video_size = snapshot.size().to_f64();
let dw = dw.unwrap_or(video_size.width);
let dh = dh.unwrap_or(video_size.height);
let sw = sw.unwrap_or(video_size.width);
let sh = sh.unwrap_or(video_size.height);
let video_size = snapshot.size();
let dw = dw.unwrap_or(video_size.width as f64);
let dh = dh.unwrap_or(video_size.height as f64);
let sw = sw.unwrap_or(video_size.width as f64);
let sh = sh.unwrap_or(video_size.height as f64);
let (source_rect, dest_rect) =
self.adjust_source_dest_rects(video_size, sx, sy, sw, sh, dx, dy, dw, dh);
@ -577,7 +577,7 @@ impl CanvasState {
let sw = sw.unwrap_or(canvas_size.width as f64);
let sh = sh.unwrap_or(canvas_size.height as f64);
let image_size = Size2D::new(canvas_size.width as f64, canvas_size.height as f64);
let image_size = Size2D::new(canvas_size.width, canvas_size.height);
// 2. Establish the source and destination rectangles
let (source_rect, dest_rect) =
self.adjust_source_dest_rects(image_size, sx, sy, sw, sh, dx, dy, dw, dh);
@ -632,7 +632,7 @@ impl CanvasState {
let sw = sw.unwrap_or(canvas_size.width as f64);
let sh = sh.unwrap_or(canvas_size.height as f64);
let image_size = Size2D::new(canvas_size.width as f64, canvas_size.height as f64);
let image_size = Size2D::new(canvas_size.width, canvas_size.height);
// 2. Establish the source and destination rectangles
let (source_rect, dest_rect) =
self.adjust_source_dest_rects(image_size, sx, sy, sw, sh, dx, dy, dw, dh);
@ -702,12 +702,12 @@ impl CanvasState {
let snapshot = self
.fetch_image_data(url, cors_setting)
.ok_or(Error::InvalidState)?;
let image_size = snapshot.size().to_f64();
let image_size = snapshot.size();
let dw = dw.unwrap_or(image_size.width);
let dh = dh.unwrap_or(image_size.height);
let sw = sw.unwrap_or(image_size.width);
let sh = sh.unwrap_or(image_size.height);
let dw = dw.unwrap_or(image_size.width as f64);
let dh = dh.unwrap_or(image_size.height as f64);
let sw = sw.unwrap_or(image_size.width as f64);
let sh = sh.unwrap_or(image_size.height as f64);
// Establish the source and destination rectangles
let (source_rect, dest_rect) =
@ -741,7 +741,7 @@ impl CanvasState {
#[allow(clippy::too_many_arguments)]
fn adjust_source_dest_rects(
&self,
image_size: Size2D<f64>,
image_size: Size2D<u32>,
sx: f64,
sy: f64,
sw: f64,
@ -766,7 +766,7 @@ impl CanvasState {
// When the source rectangle is outside the source image,
// the source rectangle must be clipped to the source image
let source_rect_clipped = source_rect
.intersection(&image_rect)
.intersection(&image_rect.to_f64())
.unwrap_or(Rect::zero());
// Width and height ratios between the non clipped and clipped source rectangles

View file

@ -89,8 +89,8 @@ pub enum Canvas2dMsg {
Arc(Point2D<f32>, f32, f32, f32, bool),
ArcTo(Point2D<f32>, Point2D<f32>, f32),
DrawImage(IpcSnapshot, Rect<f64>, Rect<f64>, bool),
DrawEmptyImage(Size2D<f64>, Rect<f64>, Rect<f64>),
DrawImageInOther(CanvasId, Size2D<f64>, Rect<f64>, Rect<f64>, bool),
DrawEmptyImage(Size2D<u32>, Rect<f64>, Rect<f64>),
DrawImageInOther(CanvasId, Size2D<u32>, Rect<f64>, Rect<f64>, bool),
BeginPath,
BezierCurveTo(Point2D<f32>, Point2D<f32>, Point2D<f32>),
ClearRect(Rect<f32>),