mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Change canvas/context/snapshot size from u64 -> u32 (#36827)
Replaces uses of `euclid::default::Size2D<u64>` with
`euclid::default::Size2D<u32>` for the canvas/context/snapshot.
This PR includes changes to the following components:
- canvas
- pixels
- script
- script_bindings
- shared/canvas
- shared/snapshot
Testing: https://github.com/hashcatHitman/servo/actions/runs/15426115391
(as of 892edc0048
)
Fixes: #36706
---------
Signed-off-by: hashcatHitman <155700084+hashcatHitman@users.noreply.github.com>
This commit is contained in:
parent
87de9fdf8c
commit
a625420b23
14 changed files with 69 additions and 69 deletions
|
@ -470,7 +470,7 @@ impl<'a, B: Backend> CanvasData<'a, B> {
|
|||
pub(crate) fn draw_image(
|
||||
&mut self,
|
||||
image_data: &[u8],
|
||||
image_size: Size2D<u64>,
|
||||
image_size: Size2D<u32>,
|
||||
dest_rect: Rect<f64>,
|
||||
source_rect: Rect<f64>,
|
||||
smoothing_enabled: bool,
|
||||
|
@ -480,7 +480,7 @@ impl<'a, B: Backend> CanvasData<'a, B> {
|
|||
let source_rect = source_rect.ceil();
|
||||
// It discards the extra pixels (if any) that won't be painted
|
||||
let image_data = if Rect::from_size(image_size.to_f64()).contains_rect(&source_rect) {
|
||||
pixels::rgba8_get_rect(image_data, image_size, source_rect.to_u64()).into()
|
||||
pixels::rgba8_get_rect(image_data, image_size, source_rect.to_u32()).into()
|
||||
} else {
|
||||
image_data.into()
|
||||
};
|
||||
|
@ -1244,7 +1244,7 @@ impl<'a, B: Backend> CanvasData<'a, B> {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
|
||||
pub(crate) fn put_image_data(&mut self, mut imagedata: Vec<u8>, rect: Rect<u64>) {
|
||||
pub(crate) fn put_image_data(&mut self, mut imagedata: Vec<u8>, rect: Rect<u32>) {
|
||||
assert_eq!(imagedata.len() % 4, 0);
|
||||
assert_eq!(rect.size.area() as usize, imagedata.len() / 4);
|
||||
pixels::rgba8_byte_swap_and_premultiply_inplace(&mut imagedata);
|
||||
|
@ -1333,8 +1333,8 @@ impl<'a, B: Backend> CanvasData<'a, B> {
|
|||
#[allow(unsafe_code)]
|
||||
pub(crate) fn read_pixels(
|
||||
&self,
|
||||
read_rect: Option<Rect<u64>>,
|
||||
canvas_size: Option<Size2D<u64>>,
|
||||
read_rect: Option<Rect<u32>>,
|
||||
canvas_size: Option<Size2D<u32>>,
|
||||
) -> Snapshot {
|
||||
let canvas_size = canvas_size.unwrap_or(self.drawtarget.get_size().cast());
|
||||
|
||||
|
|
|
@ -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_u64(),
|
||||
image_size,
|
||||
dest_rect,
|
||||
source_rect,
|
||||
false,
|
||||
|
@ -203,10 +203,10 @@ impl<'a> CanvasPaintThread<'a> {
|
|||
) => {
|
||||
let image_data = self
|
||||
.canvas(canvas_id)
|
||||
.read_pixels(Some(source_rect.to_u64()), Some(image_size.to_u64()));
|
||||
.read_pixels(Some(source_rect.to_u32()), Some(image_size));
|
||||
self.canvas(other_canvas_id).draw_image(
|
||||
image_data.data(),
|
||||
source_rect.size.to_u64(),
|
||||
source_rect.size.to_u32(),
|
||||
dest_rect,
|
||||
source_rect,
|
||||
smoothing,
|
||||
|
@ -398,7 +398,7 @@ impl Canvas<'_> {
|
|||
fn draw_image(
|
||||
&mut self,
|
||||
data: &[u8],
|
||||
size: Size2D<u64>,
|
||||
size: Size2D<u32>,
|
||||
dest_rect: Rect<f64>,
|
||||
source_rect: Rect<f64>,
|
||||
smoothing_enabled: bool,
|
||||
|
@ -418,8 +418,8 @@ impl Canvas<'_> {
|
|||
|
||||
fn read_pixels(
|
||||
&mut self,
|
||||
read_rect: Option<Rect<u64>>,
|
||||
canvas_size: Option<Size2D<u64>>,
|
||||
read_rect: Option<Rect<u32>>,
|
||||
canvas_size: Option<Size2D<u32>>,
|
||||
) -> snapshot::Snapshot {
|
||||
match self {
|
||||
Canvas::Raqote(canvas_data) => canvas_data.read_pixels(read_rect, canvas_size),
|
||||
|
@ -612,7 +612,7 @@ impl Canvas<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
fn put_image_data(&mut self, unwrap: Vec<u8>, rect: Rect<u64>) {
|
||||
fn put_image_data(&mut self, unwrap: Vec<u8>, rect: Rect<u32>) {
|
||||
match self {
|
||||
Canvas::Raqote(canvas_data) => canvas_data.put_image_data(unwrap, rect),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue