Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Mar 1, 2024
1 parent c94f789 commit a45c045
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
37 changes: 21 additions & 16 deletions src/wayland/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,17 @@ impl AppData {
);

Buffer {
backing: Arc::new(Shmbuf {
fd,
offset: 0,
width: buffer_info.width as i32,
height: buffer_info.height as i32,
stride: buffer_info.stride as i32,
format,
}
.into()),
backing: Arc::new(
Shmbuf {
fd,
offset: 0,
width: buffer_info.width as i32,
height: buffer_info.height as i32,
stride: buffer_info.stride as i32,
format,
}
.into(),
),
buffer,
buffer_info: buffer_info.clone(),
node: None,
Expand Down Expand Up @@ -203,13 +205,16 @@ impl AppData {
.0;

Ok(Some(Buffer {
backing: Arc::new(Dmabuf {
width: buffer_info.width as i32,
height: buffer_info.height as i32,
planes,
format: buffer_info.format,
modifier: modifier.into(),
}.into()),
backing: Arc::new(
Dmabuf {
width: buffer_info.width as i32,
height: buffer_info.height as i32,
planes,
format: buffer_info.format,
modifier: modifier.into(),
}
.into(),
),
buffer,
buffer_info: buffer_info.clone(),
node: Some(node.clone()),
Expand Down
5 changes: 4 additions & 1 deletion src/wayland/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ fn start(conn: Connection) -> mpsc::Receiver<Event> {
dmabuf_feedback: None,
gbm: None,
scheduler,
executor: futures::executor::ThreadPool::builder().pool_size(1).create().unwrap(),
executor: futures::executor::ThreadPool::builder()
.pool_size(1)
.create()
.unwrap(),
};

app_data.send_event(Event::Seats(app_data.seat_state.seats().collect()));
Expand Down
15 changes: 5 additions & 10 deletions src/wayland/screencopy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct ScreencopySession {
first_frame: bool,
// Future signaled when buffer is signaled.
// if triple buffer is used, will need more than one.
release: Option<SubsurfaceBufferRelease>
release: Option<SubsurfaceBufferRelease>,
}

impl ScreencopySession {
Expand Down Expand Up @@ -159,23 +159,18 @@ impl ScreencopyHandler for AppData {
let capture_clone = capture.clone();
let conn = conn.clone();
let release = session.release.take();
//dbg!("schedule");
self.scheduler.schedule(async move {
//self.executor.spawn_ok(async move {
let time = std::time::Instant::now();
//dbg!(release.is_some());
//self.scheduler.schedule(async move {
self.executor.spawn_ok(async move {
if let Some(release) = release {
// Wait for buffer to be released by server
// Wait for buffer to be released by server
release.await;
}
// futures_timer::Delay::new(std::time::Duration::from_secs_f64(1. / 60.).saturating_sub(time.elapsed())).await;
futures_timer::Delay::new(std::time::Duration::from_secs_f64(1. / 60.).saturating_sub(time.elapsed())).await;
let mut session = capture_clone.session.lock().unwrap();
let Some(session) = session.as_mut() else {
return;
};
session.attach_buffer_and_commit(&capture_clone, &conn);
});//.unwrap();
}); //.unwrap();

let front = session.buffers.as_mut().unwrap().first_mut().unwrap();
let (buffer, release) = SubsurfaceBuffer::new(front.backing.clone());
Expand Down

0 comments on commit a45c045

Please sign in to comment.