wayland: implement commit-timing-v1
This commit is contained in:
parent
d45aaffdb3
commit
fac5445f2e
19 changed files with 434 additions and 15 deletions
|
|
@ -53,7 +53,7 @@ use {
|
|||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
fmt::{Debug, Formatter},
|
||||
ops::Deref,
|
||||
ops::{BitOrAssign, Deref},
|
||||
rc::Rc,
|
||||
},
|
||||
};
|
||||
|
|
@ -89,9 +89,29 @@ pub struct OutputNode {
|
|||
pub latch_event: EventSource<dyn LatchListener>,
|
||||
pub vblank_event: EventSource<dyn VblankListener>,
|
||||
pub presentation_event: EventSource<dyn PresentationListener>,
|
||||
pub render_margin_ns: Cell<u64>,
|
||||
pub flip_margin_ns: Cell<Option<u64>>,
|
||||
pub ext_copy_sessions:
|
||||
CopyHashMap<(ClientId, ExtImageCopyCaptureSessionV1Id), Rc<ExtImageCopyCaptureSessionV1>>,
|
||||
pub before_latch_event: EventSource<dyn BeforeLatchListener>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub enum BeforeLatchResult {
|
||||
None,
|
||||
Yield,
|
||||
}
|
||||
|
||||
impl BitOrAssign for BeforeLatchResult {
|
||||
fn bitor_assign(&mut self, rhs: Self) {
|
||||
if rhs == BeforeLatchResult::Yield {
|
||||
*self = rhs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BeforeLatchListener {
|
||||
fn before_latch(self: Rc<Self>, present: u64) -> BeforeLatchResult;
|
||||
}
|
||||
|
||||
pub trait LatchListener {
|
||||
|
|
@ -135,6 +155,16 @@ pub async fn output_render_data(state: Rc<State>) {
|
|||
}
|
||||
|
||||
impl OutputNode {
|
||||
pub async fn before_latch(&self, present: u64) {
|
||||
let mut res = BeforeLatchResult::None;
|
||||
for listener in self.before_latch_event.iter() {
|
||||
res |= listener.before_latch(present);
|
||||
}
|
||||
if res == BeforeLatchResult::Yield {
|
||||
self.state.eng.yield_now().await;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn latched(&self, tearing: bool) {
|
||||
self.schedule.latched();
|
||||
for listener in self.latch_event.iter() {
|
||||
|
|
@ -703,6 +733,7 @@ impl OutputNode {
|
|||
}
|
||||
let (old_width, old_height) = self.global.pixel_size();
|
||||
self.global.mode.set(mode);
|
||||
self.global.refresh_nsec.set(mode.refresh_nsec());
|
||||
self.global.persistent.transform.set(transform);
|
||||
let (new_width, new_height) = self.global.pixel_size();
|
||||
self.change_extents_(&self.calculate_extents());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue