diff --git a/src/display.rs b/src/display.rs index f30da54..7031f27 100644 --- a/src/display.rs +++ b/src/display.rs @@ -229,12 +229,13 @@ fn packer_loop( continue; } - // Regenerate the permutation when the frame size changes. + // Rebuild index array only when frame size changes; otherwise + // re-shuffle the existing permutation in place. if frame.len() != last_frame_len { permutation = (0..frame.len()).collect(); - fisher_yates_shuffle(&mut permutation, &mut rng); last_frame_len = frame.len(); } + fisher_yates_shuffle(&mut permutation, &mut rng); // Walk the permutation, packing pixels into packets. let mut buf = grab_buf(&queue);