mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Return RenderResult from render()
This commit is contained in:
+11
-1
@@ -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),
|
||||
|
||||
+12
-4
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user