mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +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
|
@ -45,7 +45,7 @@ pub fn compute_rgba8_byte_length_if_within_limit(width: usize, height: usize) ->
|
|||
.filter(|v| *v <= MAX_IMAGE_BYTE_LENGTH)
|
||||
}
|
||||
|
||||
pub fn rgba8_get_rect(pixels: &[u8], size: Size2D<u64>, rect: Rect<u64>) -> Cow<[u8]> {
|
||||
pub fn rgba8_get_rect(pixels: &[u8], size: Size2D<u32>, rect: Rect<u32>) -> Cow<[u8]> {
|
||||
assert!(!rect.is_empty());
|
||||
assert!(Rect::from_size(size).contains_rect(&rect));
|
||||
assert_eq!(pixels.len() % 4, 0);
|
||||
|
@ -106,18 +106,18 @@ pub fn multiply_u8_color(a: u8, b: u8) -> u8 {
|
|||
|
||||
pub fn clip(
|
||||
mut origin: Point2D<i32>,
|
||||
mut size: Size2D<u64>,
|
||||
surface: Size2D<u64>,
|
||||
) -> Option<Rect<u64>> {
|
||||
mut size: Size2D<u32>,
|
||||
surface: Size2D<u32>,
|
||||
) -> Option<Rect<u32>> {
|
||||
if origin.x < 0 {
|
||||
size.width = size.width.saturating_sub(-origin.x as u64);
|
||||
size.width = size.width.saturating_sub(-origin.x as u32);
|
||||
origin.x = 0;
|
||||
}
|
||||
if origin.y < 0 {
|
||||
size.height = size.height.saturating_sub(-origin.y as u64);
|
||||
size.height = size.height.saturating_sub(-origin.y as u32);
|
||||
origin.y = 0;
|
||||
}
|
||||
let origin = Point2D::new(origin.x as u64, origin.y as u64);
|
||||
let origin = Point2D::new(origin.x as u32, origin.y as u32);
|
||||
Rect::new(origin, size)
|
||||
.intersection(&Rect::from_size(surface))
|
||||
.filter(|rect| !rect.is_empty())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue