diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-10-13 13:04:41 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-10-13 13:30:36 +0400 |
| commit | 29053a807b8969d3e2eb88c7065a087aaa137a31 (patch) | |
| tree | 34e0d75df75acdd25aa1aca4b5e7b49d85a789c6 /src/backend | |
| parent | 0a3274749563067b06af83f870ff39dc503a5355 (diff) | |
| download | niri-29053a807b8969d3e2eb88c7065a087aaa137a31.tar.gz niri-29053a807b8969d3e2eb88c7065a087aaa137a31.tar.bz2 niri-29053a807b8969d3e2eb88c7065a087aaa137a31.zip | |
Return RenderResult from render()
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/mod.rs | 12 | ||||
| -rw-r--r-- | src/backend/tty.rs | 16 | ||||
| -rw-r--r-- | src/backend/winit.rs | 10 |
3 files changed, 32 insertions, 6 deletions
diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 0fa7bf59..18c7ea10 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -20,6 +20,16 @@ pub enum Backend { Winit(Winit), } +#[derive(PartialEq, Eq)] +pub enum RenderResult { + /// The frame was submitted to the backend for presentation. + Submitted, + /// Rendering succeeded, but there was no damage. + NoDamage, + /// An error has occurred, the frame was not submitted. + Error, +} + impl Backend { pub fn init(&mut self, niri: &mut Niri) { match self { @@ -48,7 +58,7 @@ impl Backend { output: &Output, elements: &[OutputRenderElements<GlesRenderer>], target_presentation_time: Duration, - ) { + ) -> RenderResult { match self { Backend::Tty(tty) => tty.render(niri, output, elements, target_presentation_time), Backend::Winit(winit) => winit.render(niri, output, elements), diff --git a/src/backend/tty.rs b/src/backend/tty.rs index 74f3e9ed..75626898 100644 --- a/src/backend/tty.rs +++ b/src/backend/tty.rs @@ -43,6 +43,8 @@ use crate::niri::{OutputRenderElements, State, RedrawState}; use crate::utils::get_monotonic_time; use crate::Niri; +use super::RenderResult; + const SUPPORTED_COLOR_FORMATS: &[Fourcc] = &[Fourcc::Argb8888, Fourcc::Abgr8888]; pub struct Tty { @@ -837,18 +839,20 @@ impl Tty { output: &Output, elements: &[OutputRenderElements<GlesRenderer>], target_presentation_time: Duration, - ) { + ) -> RenderResult { let span = tracy_client::span!("Tty::render"); + let mut rv = RenderResult::Error; + let Some(device) = self.output_device.as_mut() else { error!("missing output device"); - return; + return rv; }; let tty_state: &TtyOutputState = output.user_data().get().unwrap(); let Some(surface) = device.surfaces.get_mut(&tty_state.crtc) else { error!("missing surface"); - return; + return rv; }; span.emit_text(&surface.name); @@ -896,12 +900,14 @@ impl Tty { } }; - return; + return RenderResult::Submitted; } Err(err) => { error!("error queueing frame: {err}"); } } + } else { + rv = RenderResult::NoDamage; } } Err(err) => { @@ -915,6 +921,8 @@ impl Tty { // Queue a timer to fire at the predicted vblank time. queue_estimated_vblank_timer(niri, output.clone(), target_presentation_time); + + rv } pub fn change_vt(&mut self, vt: i32) { diff --git a/src/backend/winit.rs b/src/backend/winit.rs index 508f4cf0..0188ea21 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -17,6 +17,7 @@ use smithay::reexports::winit::dpi::LogicalSize; use smithay::reexports::winit::window::WindowBuilder; use smithay::utils::Transform; +use super::RenderResult; use crate::config::Config; use crate::niri::{OutputRenderElements, RedrawState, State}; use crate::utils::get_monotonic_time; @@ -151,7 +152,7 @@ impl Winit { niri: &mut Niri, output: &Output, elements: &[OutputRenderElements<GlesRenderer>], - ) { + ) -> RenderResult { let _span = tracy_client::span!("Winit::render"); self.backend.bind().unwrap(); @@ -164,6 +165,7 @@ impl Winit { niri.update_primary_scanout_output(output, &res.states); + let rv; if let Some(damage) = res.damage { if self .config @@ -186,6 +188,10 @@ impl Winit { 0, wp_presentation_feedback::Kind::empty(), ); + + rv = RenderResult::Submitted; + } else { + rv = RenderResult::NoDamage; } let output_state = niri.output_state.get_mut(output).unwrap(); @@ -200,6 +206,8 @@ impl Winit { if output_state.unfinished_animations_remain { self.backend.window().request_redraw(); } + + rv } pub fn toggle_debug_tint(&mut self) { |
