mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-10 12:22:22 +00:00
fix(gpu): saturate effect band edges at the coordinate ceiling (#11057)
This commit is contained in:
1 parent
d5bd171810
commit
e47dee26d0
2 files changed
+13
-2
No files matched your search
@@ -336,8 +336,10 @@ fn bands(r: Rect, rows: i32) -> Vec<Rect> {
|
||||
let mut out = Vec::new();
|
||||
let mut y = r.y0;
|
||||
while y < r.y1 {
|
||||
out.push(Rect::new(r.x0, y, r.x1, (y + rows).min(r.y1)));
|
||||
y += rows;
|
||||
// Saturating near the coordinate ceiling: a wrapped edge would never reach `y1`.
|
||||
let end = y.saturating_add(rows.max(1)).min(r.y1);
|
||||
out.push(Rect::new(r.x0, y, r.x1, end));
|
||||
y = end;
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
@@ -308,3 +308,12 @@ fn shape_tiles_and_group_pins_hold_addresses_not_pixels() {
|
||||
drop(group);
|
||||
assert!(pins.iter().all(|w| w.strong_count() == 0), "a group's pins keep none of its pixels");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bands_end_at_the_coordinate_ceiling() {
|
||||
let r = Rect::new(0, i32::MAX - 100, 8, i32::MAX);
|
||||
let bands = super::bands(r, 64);
|
||||
assert_eq!(bands.len(), 2, "{bands:?}");
|
||||
assert_eq!((bands[0].y0, bands[0].y1, bands[1].y1), (i32::MAX - 100, i32::MAX - 36, i32::MAX));
|
||||
assert_eq!(super::bands(Rect::new(0, 0, 8, 10), 0).len(), 10, "a zero step still makes progress");
|
||||
}
|
||||
Reference in new issue
Block a user