mirror of
https://github.com/storytold/AniCraft.git
synced 2026-11-21 01:52:49 +01:00
fix(gpu): as_chunks instead of chunks_exact with constant sizes (newer clippy) (M3)
This commit is contained in:
1 parent
3bc51e4016
commit
3fc4063446
3 files changed
+6
-6
No files matched your search
@@ -296,7 +296,7 @@ fn bin_fill(f: &Fill, op: u32, tiles_x: u32, tiles_y: u32, out: &mut Local, piec
|
||||
Some((k, w)) if w == wind => k,
|
||||
_ => {
|
||||
let k = out.backdrops.len() as u32;
|
||||
out.backdrops.extend(wind.chunks_exact(4).map(|q| [q[0], q[1], q[2], q[3]]));
|
||||
out.backdrops.extend_from_slice(wind.as_chunks::<4>().0);
|
||||
last_bd = Some((k, wind));
|
||||
k
|
||||
}
|
||||
|
||||
@@ -313,9 +313,9 @@ impl GpuRenderer {
|
||||
Output::Premul8 => (bytes.to_vec(), None),
|
||||
Output::Float => {
|
||||
let mut pm = Pixmap::new(w, h).map_err(|e| GpuError::TooLarge(e.to_string()))?;
|
||||
for (p, q) in pm.data.iter_mut().zip(bytes.chunks_exact(16)) {
|
||||
for (c, v) in p.iter_mut().zip(q.chunks_exact(4)) {
|
||||
*c = f32::from_le_bytes([v[0], v[1], v[2], v[3]]);
|
||||
for (p, q) in pm.data.iter_mut().zip(bytes.as_chunks::<16>().0) {
|
||||
for (c, v) in p.iter_mut().zip(q.as_chunks::<4>().0) {
|
||||
*c = f32::from_le_bytes(*v);
|
||||
}
|
||||
}
|
||||
(Vec::new(), Some(pm))
|
||||
@@ -336,7 +336,7 @@ pub fn compare_premul8(a: &[u8], b: &[u8]) -> Option<Diff> {
|
||||
let mut sum = 0u64;
|
||||
let mut max = 0u8;
|
||||
let mut differing = 0usize;
|
||||
for (p, q) in a.chunks_exact(4).zip(b.chunks_exact(4)) {
|
||||
for (p, q) in a.as_chunks::<4>().0.iter().zip(b.as_chunks::<4>().0) {
|
||||
let mut any = false;
|
||||
for (x, y) in p.iter().zip(q) {
|
||||
let d = x.abs_diff(*y);
|
||||
|
||||
@@ -282,7 +282,7 @@ fn gpu_hands_back_what_it_does_not_draw_and_stays_usable() {
|
||||
assert!(matches!(g.render(&list(vec![]), &view(100_000, 100_000, None), Output::Premul8), Err(GpuError::TooLarge(_))));
|
||||
// An empty list is just the background; and the device is still fine afterwards.
|
||||
let f = g.render(&list(vec![]), &view(20, 3, Some(Rgba::new(0.0, 1.0, 0.0, 1.0))), Output::Premul8).unwrap();
|
||||
assert!(f.premul8.chunks_exact(4).all(|p| p == [0, 255, 0, 255]));
|
||||
assert!(f.premul8.as_chunks::<4>().0.iter().all(|p| *p == [0, 255, 0, 255]));
|
||||
assert!(g.broken().is_none());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user