element/surface: Simplify surface feedback selection using the frame_time_filter
This commit is contained in:
parent
d17a4ead68
commit
dc5a9fac66
2 changed files with 26 additions and 27 deletions
|
|
@ -1,5 +1,8 @@
|
|||
use crate::{
|
||||
shell::focus::target::PointerFocusTarget, wayland::protocols::corner_radius::CacheableCorners,
|
||||
shell::focus::target::PointerFocusTarget,
|
||||
wayland::{
|
||||
handlers::compositor::frame_time_filter_fn, protocols::corner_radius::CacheableCorners,
|
||||
},
|
||||
};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
|
|
@ -16,7 +19,6 @@ use smithay::{
|
|||
element::{
|
||||
AsRenderElements, Kind, RenderElementStates,
|
||||
surface::{WaylandSurfaceRenderElement, render_elements_from_surface_tree},
|
||||
utils::select_dmabuf_feedback,
|
||||
},
|
||||
},
|
||||
desktop::{
|
||||
|
|
@ -674,7 +676,7 @@ impl CosmicSurface {
|
|||
&self,
|
||||
output: &Output,
|
||||
feedback: &SurfaceDmabufFeedback,
|
||||
render_element_states: &RenderElementStates,
|
||||
_render_element_states: &RenderElementStates,
|
||||
primary_scan_out_output: F1,
|
||||
) where
|
||||
F1: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy,
|
||||
|
|
@ -682,23 +684,22 @@ impl CosmicSurface {
|
|||
let is_fullscreen = self.is_fullscreen(false);
|
||||
|
||||
self.0
|
||||
.send_dmabuf_feedback(output, primary_scan_out_output, |surface, _| {
|
||||
select_dmabuf_feedback(
|
||||
surface,
|
||||
render_element_states,
|
||||
&feedback.render_feedback,
|
||||
if is_fullscreen {
|
||||
feedback
|
||||
.primary_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback)
|
||||
} else {
|
||||
.send_dmabuf_feedback(output, primary_scan_out_output, |_, data| {
|
||||
if is_fullscreen {
|
||||
feedback
|
||||
.primary_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback)
|
||||
} else {
|
||||
if frame_time_filter_fn(data) == Kind::ScanoutCandidate {
|
||||
feedback
|
||||
.overlay_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback)
|
||||
},
|
||||
)
|
||||
} else {
|
||||
&feedback.render_feedback
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -151,20 +151,18 @@ pub fn recursive_frame_time_estimation(
|
|||
overall_estimate
|
||||
}
|
||||
|
||||
pub const FRAME_TIME_FILTER: KindEvaluation = KindEvaluation::Dynamic({
|
||||
fn frame_time_filter_fn(states: &SurfaceData) -> Kind {
|
||||
let clock = Clock::<Monotonic>::new();
|
||||
const _20_FPS: Duration = Duration::from_nanos(1_000_000_000 / 20);
|
||||
pub fn frame_time_filter_fn(states: &SurfaceData) -> Kind {
|
||||
let clock = Clock::<Monotonic>::new();
|
||||
const _20_FPS: Duration = Duration::from_nanos(1_000_000_000 / 20);
|
||||
|
||||
if frame_time_estimation(&clock, states).is_some_and(|dur| dur <= _20_FPS) {
|
||||
Kind::ScanoutCandidate
|
||||
} else {
|
||||
Kind::Unspecified
|
||||
}
|
||||
if frame_time_estimation(&clock, states).is_some_and(|dur| dur <= _20_FPS) {
|
||||
Kind::ScanoutCandidate
|
||||
} else {
|
||||
Kind::Unspecified
|
||||
}
|
||||
}
|
||||
|
||||
frame_time_filter_fn
|
||||
});
|
||||
pub const FRAME_TIME_FILTER: KindEvaluation = KindEvaluation::Dynamic(frame_time_filter_fn);
|
||||
|
||||
impl CompositorHandler for State {
|
||||
fn compositor_state(&mut self) -> &mut CompositorState {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue