forge
Explore
Log in

Don't you dare go Hollow

Return RenderResult from render()

Browse files at this commit

29053a807b8969d3e2eb88c7065a087aaa137a31Ivan MolodetskikhParent: 0a32747
src/backend/mod.rsmodified+11 -1
@@ -20,6 +20,16 @@ pub enum Backend {
2020 Winit(Winit),
2121 }
2222
23+#[derive(PartialEq, Eq)]
24+pub enum RenderResult {
25+ /// The frame was submitted to the backend for presentation.
26+ Submitted,
27+ /// Rendering succeeded, but there was no damage.
28+ NoDamage,
29+ /// An error has occurred, the frame was not submitted.
30+ Error,
31+}
32+
2333 impl Backend {
2434 pub fn init(&mut self, niri: &mut Niri) {
2535 match self {
@@ -48,7 +58,7 @@ impl Backend {
4858 output: &Output,
4959 elements: &[OutputRenderElements<GlesRenderer>],
5060 target_presentation_time: Duration,
51- ) {
61+ ) -> RenderResult {
5262 match self {
5363 Backend::Tty(tty) => tty.render(niri, output, elements, target_presentation_time),
5464 Backend::Winit(winit) => winit.render(niri, output, elements),
src/backend/tty.rsmodified+12 -4
@@ -43,6 +43,8 @@ use crate::niri::{OutputRenderElements, State, RedrawState};
4343 use crate::utils::get_monotonic_time;
4444 use crate::Niri;
4545
46+use super::RenderResult;
47+
4648 const SUPPORTED_COLOR_FORMATS: &[Fourcc] = &[Fourcc::Argb8888, Fourcc::Abgr8888];
4749
4850 pub struct Tty {
@@ -837,18 +839,20 @@ impl Tty {
837839 output: &Output,
838840 elements: &[OutputRenderElements<GlesRenderer>],
839841 target_presentation_time: Duration,
840- ) {
842+ ) -> RenderResult {
841843 let span = tracy_client::span!("Tty::render");
842844
845+ let mut rv = RenderResult::Error;
846+
843847 let Some(device) = self.output_device.as_mut() else {
844848 error!("missing output device");
845- return;
849+ return rv;
846850 };
847851
848852 let tty_state: &TtyOutputState = output.user_data().get().unwrap();
849853 let Some(surface) = device.surfaces.get_mut(&tty_state.crtc) else {
850854 error!("missing surface");
851- return;
855+ return rv;
852856 };
853857
854858 span.emit_text(&surface.name);
@@ -896,12 +900,14 @@ impl Tty {
896900 }
897901 };
898902
899- return;
903+ return RenderResult::Submitted;
900904 }
901905 Err(err) => {
902906 error!("error queueing frame: {err}");
903907 }
904908 }
909+ } else {
910+ rv = RenderResult::NoDamage;
905911 }
906912 }
907913 Err(err) => {
@@ -915,6 +921,8 @@ impl Tty {
915921
916922 // Queue a timer to fire at the predicted vblank time.
917923 queue_estimated_vblank_timer(niri, output.clone(), target_presentation_time);
924+
925+ rv
918926 }
919927
920928 pub fn change_vt(&mut self, vt: i32) {
src/backend/winit.rsmodified+9 -1
@@ -17,6 +17,7 @@ use smithay::reexports::winit::dpi::LogicalSize;
1717 use smithay::reexports::winit::window::WindowBuilder;
1818 use smithay::utils::Transform;
1919
20+use super::RenderResult;
2021 use crate::config::Config;
2122 use crate::niri::{OutputRenderElements, RedrawState, State};
2223 use crate::utils::get_monotonic_time;
@@ -151,7 +152,7 @@ impl Winit {
151152 niri: &mut Niri,
152153 output: &Output,
153154 elements: &[OutputRenderElements<GlesRenderer>],
154- ) {
155+ ) -> RenderResult {
155156 let _span = tracy_client::span!("Winit::render");
156157
157158 self.backend.bind().unwrap();
@@ -164,6 +165,7 @@ impl Winit {
164165
165166 niri.update_primary_scanout_output(output, &res.states);
166167
168+ let rv;
167169 if let Some(damage) = res.damage {
168170 if self
169171 .config
@@ -186,6 +188,10 @@ impl Winit {
186188 0,
187189 wp_presentation_feedback::Kind::empty(),
188190 );
191+
192+ rv = RenderResult::Submitted;
193+ } else {
194+ rv = RenderResult::NoDamage;
189195 }
190196
191197 let output_state = niri.output_state.get_mut(output).unwrap();
@@ -200,6 +206,8 @@ impl Winit {
200206 if output_state.unfinished_animations_remain {
201207 self.backend.window().request_redraw();
202208 }
209+
210+ rv
203211 }
204212
205213 pub fn toggle_debug_tint(&mut self) {