screencopy: Accumulate buffer damage
This commit is contained in:
parent
7670bfb9ff
commit
85436fa9d6
2 changed files with 26 additions and 12 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use cctk::{
|
||||
screencopy::Formats,
|
||||
screencopy::{Formats, Rect},
|
||||
wayland_client::{
|
||||
Connection, Dispatch, QueueHandle,
|
||||
protocol::{wl_buffer, wl_shm, wl_shm_pool},
|
||||
|
|
@ -20,6 +20,7 @@ use crate::utils;
|
|||
pub struct Buffer {
|
||||
pub backing: Arc<BufferSource>,
|
||||
pub buffer: wl_buffer::WlBuffer,
|
||||
pub buffer_damage: Vec<Rect>,
|
||||
pub size: (u32, u32),
|
||||
#[cfg(feature = "no-subsurfaces")]
|
||||
pub mmap: memmap2::Mmap,
|
||||
|
|
@ -52,6 +53,13 @@ impl AppData {
|
|||
#[cfg(feature = "no-subsurfaces")]
|
||||
let mmap = unsafe { memmap2::Mmap::map(&fd).unwrap() };
|
||||
|
||||
let full_damage = vec![Rect {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: width as i32,
|
||||
height: height as i32,
|
||||
}];
|
||||
|
||||
Buffer {
|
||||
backing: Arc::new(
|
||||
Shmbuf {
|
||||
|
|
@ -65,6 +73,7 @@ impl AppData {
|
|||
.into(),
|
||||
),
|
||||
buffer,
|
||||
buffer_damage: full_damage,
|
||||
#[cfg(feature = "no-subsurfaces")]
|
||||
mmap,
|
||||
size: (width, height),
|
||||
|
|
@ -148,6 +157,13 @@ impl AppData {
|
|||
)
|
||||
.0;
|
||||
|
||||
let full_damage = vec![Rect {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: width as i32,
|
||||
height: height as i32,
|
||||
}];
|
||||
|
||||
Ok(Some(Buffer {
|
||||
backing: Arc::new(
|
||||
Dmabuf {
|
||||
|
|
@ -160,6 +176,7 @@ impl AppData {
|
|||
.into(),
|
||||
),
|
||||
buffer,
|
||||
buffer_damage: full_damage,
|
||||
size: (width, height),
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,18 +69,9 @@ impl ScreencopySession {
|
|||
// TODO
|
||||
// let node = back.node().and_then(|x| x.to_str().map(|x| x.to_string()));
|
||||
|
||||
// TODO: accumulate damage
|
||||
let (width, height) = back.size;
|
||||
let full_damage = &[Rect {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: width as i32,
|
||||
height: height as i32,
|
||||
}];
|
||||
|
||||
self.session.capture(
|
||||
&back.buffer,
|
||||
full_damage,
|
||||
&back.buffer_damage,
|
||||
qh,
|
||||
FrameData {
|
||||
frame_data: Default::default(),
|
||||
|
|
@ -185,7 +176,13 @@ impl ScreencopyHandler for AppData {
|
|||
session.attach_buffer_and_commit(&capture_clone, &conn, &qh);
|
||||
});
|
||||
|
||||
let front = session.buffers.as_mut().unwrap().first_mut().unwrap();
|
||||
// Clear `buffer_damage` for front buffer; accumulate for other buffers.
|
||||
session.buffers.as_mut().unwrap()[0].buffer_damage.clear();
|
||||
for buffer in &mut session.buffers.as_mut().unwrap()[1..] {
|
||||
buffer.buffer_damage.extend_from_slice(&frame.damage);
|
||||
}
|
||||
|
||||
let front = &session.buffers.as_ref().unwrap()[0];
|
||||
let (buffer, release) = SubsurfaceBuffer::new(front.backing.clone());
|
||||
session.release = Some(release);
|
||||
let image = CaptureImage {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue