From a3aa5fca12b59df0c1ee421b482a51a425e25abd Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sat, 30 Sep 2023 17:13:56 +0400 Subject: Refactor frame scheduling Combine the redraw state variables into one enum, and refactor to get rid of the requirement that a VBlank must queue a subsequent redraw. Also fix the bug where ongoing animations that produced no damage could stall the redrawing. --- src/backend/winit.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/backend/winit.rs') diff --git a/src/backend/winit.rs b/src/backend/winit.rs index e0fbf272..7639b568 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -1,5 +1,6 @@ use std::cell::RefCell; use std::collections::HashMap; +use std::mem; use std::rc::Rc; use std::sync::{Arc, Mutex}; use std::time::Duration; @@ -18,7 +19,7 @@ use smithay::utils::Transform; use smithay::wayland::dmabuf::DmabufFeedback; use crate::config::Config; -use crate::niri::{OutputRenderElements, State}; +use crate::niri::{OutputRenderElements, RedrawState, State}; use crate::utils::get_monotonic_time; use crate::Niri; @@ -182,7 +183,18 @@ impl Winit { 0, wp_presentation_feedback::Kind::empty(), ); + } + + let output_state = niri.output_state.get_mut(output).unwrap(); + match mem::replace(&mut output_state.redraw_state, RedrawState::Idle) { + RedrawState::Idle => unreachable!(), + RedrawState::Queued(_) => (), + RedrawState::WaitingForVBlank { .. } => unreachable!(), + RedrawState::WaitingForEstimatedVBlank(_) => unreachable!(), + RedrawState::WaitingForEstimatedVBlankAndQueued(_) => unreachable!(), + } + if output_state.unfinished_animations_remain { self.backend.window().request_redraw(); } -- cgit