diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-08-09 14:20:59 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-08-10 14:50:51 +0400 |
| commit | 7527cad20035c87255826ee276658b0b89d58f7f (patch) | |
| tree | ba8cdf5877ea5ff7bab12dec0c97bf7d2c00a1b3 /src | |
| parent | c50e22d415f09dd15e164cff06c76e95102f3cf6 (diff) | |
| download | niri-7527cad20035c87255826ee276658b0b89d58f7f.tar.gz niri-7527cad20035c87255826ee276658b0b89d58f7f.tar.bz2 niri-7527cad20035c87255826ee276658b0b89d58f7f.zip | |
tty: Improve reselience to rendering errors
Diffstat (limited to 'src')
| -rw-r--r-- | src/tty.rs | 53 |
1 files changed, 33 insertions, 20 deletions
@@ -33,6 +33,7 @@ use smithay_drm_extras::edid::EdidInfo; use crate::backend::Backend; use crate::{LoopData, Niri}; +const BACKGROUND_COLOR: [f32; 4] = [0.1, 0.1, 0.1, 1.]; const SUPPORTED_COLOR_FORMATS: &[Fourcc] = &[Fourcc::Argb8888, Fourcc::Abgr8888]; pub struct Tty { @@ -68,28 +69,40 @@ impl Backend for Tty { elements: &[SpaceRenderElements<GlesRenderer, WaylandSurfaceRenderElement<GlesRenderer>>], ) { let output_device = self.output_device.as_mut().unwrap(); - let res = output_device - .drm_compositor - .render_frame::<_, _, GlesRenderbuffer>( - &mut output_device.gles, - elements, - [0.1, 0.1, 0.1, 1.], + let drm_compositor = &mut output_device.drm_compositor; + + match drm_compositor.render_frame::<_, _, GlesRenderbuffer>( + &mut output_device.gles, + elements, + BACKGROUND_COLOR, + ) { + Ok(res) => { + assert!(!res.needs_sync()); + if res.damage.is_some() { + match output_device.drm_compositor.queue_frame(()) { + Ok(()) => return, + Err(err) => { + error!("error queueing frame: {err}"); + } + } + } + } + Err(err) => { + // Can fail if we switched to a different TTY. + error!("error rendering frame: {err}"); + } + } + + // FIXME: render on demand instead of busy looping. + niri.event_loop + .insert_source( + Timer::from_duration(Duration::from_millis(6)), + |_, _, data| { + data.niri.redraw(data.tty.as_mut().unwrap()); + TimeoutAction::Drop + }, ) .unwrap(); - assert!(!res.needs_sync()); - if res.damage.is_some() { - output_device.drm_compositor.queue_frame(()).unwrap(); - } else { - niri.event_loop - .insert_source( - Timer::from_duration(Duration::from_millis(6)), - |_, _, data| { - data.niri.redraw(data.tty.as_mut().unwrap()); - TimeoutAction::Drop - }, - ) - .unwrap(); - } } } |
