always use latest frame

This commit is contained in:
Alex Janka 2023-03-08 15:34:31 +11:00
parent e2f1f13ba2
commit 11dec11079

View file

@ -114,21 +114,17 @@ fn init_pixbuf(info: WindowInfo, window: &mut Window) -> (Pixels, usize) {
impl WindowHandler for EmulatorWindow {
fn on_frame(&mut self, _window: &mut Window) {
if let Some(ref mut receiver) = *self.frame_receiver.lock().expect("failed to lock mutex") {
match receiver.recv() {
Ok(buf) => {
let scaled_buf = if self.scale != 1 {
scale_buffer(&buf, WIDTH, HEIGHT, self.scale)
} else {
buf
};
for (pixel, source) in
self.pix.get_frame_mut().chunks_exact_mut(4).zip(scaled_buf)
{
pixel.copy_from_slice(&source);
}
self.pix.render().unwrap();
if let Some(buf) = receiver.try_iter().last() {
let scaled_buf = if self.scale != 1 {
scale_buffer(&buf, WIDTH, HEIGHT, self.scale)
} else {
buf
};
for (pixel, source) in self.pix.get_frame_mut().chunks_exact_mut(4).zip(scaled_buf)
{
pixel.copy_from_slice(&source);
}
Err(e) => nih_log!("recv error: {e}"),
self.pix.render().unwrap();
}
}
}