1
0
Fork 0
forked from wry/wry

render: support shm screencopy from direct scanout

This commit is contained in:
Julian Orth 2024-02-28 15:59:20 +01:00
parent 9de63bddf3
commit 9fba5f9b45
13 changed files with 203 additions and 62 deletions

View file

@ -176,7 +176,6 @@ impl JayScreencast {
self.client.state.perform_screencopy(
texture,
&buffer.fb,
on.global.preferred_scale.get(),
on.global.pos.get(),
render_hardware_cursors,
x_off,

View file

@ -18,7 +18,6 @@ use {
buffd::{MsgParser, MsgParserError},
clonecell::CloneCell,
copyhashmap::CopyHashMap,
errorfmt::ErrorFmt,
linkedlist::LinkedList,
},
wire::{wl_output::*, WlOutputId, ZxdgOutputV1Id},
@ -201,10 +200,6 @@ impl WlOutputGlobal {
Ok(())
}
pub fn have_shm_screencopies(&self) -> bool {
self.pending_captures.iter().any(|c| c.is_shm.get())
}
pub fn perform_screencopies(
&self,
tex: &Rc<dyn GfxTexture>,
@ -235,30 +230,17 @@ impl WlOutputGlobal {
if let Some(WlBufferStorage::Shm { mem, stride }) =
wl_buffer.storage.borrow_mut().deref()
{
let acc = mem.access(|mem| {
tex.clone().read_pixels(
capture.rect.x1(),
capture.rect.y1(),
capture.rect.width(),
capture.rect.height(),
*stride,
wl_buffer.format,
mem,
)
});
let res = match acc {
Ok(res) => res,
Err(e) => {
capture.client.error(e);
continue;
}
};
if let Err(e) = res {
log::warn!("Could not read texture to memory: {}", ErrorFmt(e));
capture.send_failed();
continue;
}
// capture.send_flags(FLAGS_Y_INVERT);
self.state.perform_shm_screencopy(
tex,
self.pos.get(),
x_off,
y_off,
size,
&capture,
mem,
*stride,
wl_buffer.format,
);
} else {
let fb = match wl_buffer.famebuffer.get() {
Some(fb) => fb,
@ -271,7 +253,6 @@ impl WlOutputGlobal {
self.state.perform_screencopy(
tex,
&fb,
self.preferred_scale.get(),
self.pos.get(),
render_hardware_cursors,
x_off - capture.rect.x1(),

View file

@ -33,7 +33,6 @@ pub struct ZwlrScreencopyFrameV1 {
pub with_damage: Cell<bool>,
pub output_link: Cell<Option<LinkedNode<Rc<Self>>>>,
pub buffer: Cell<Option<Rc<WlBuffer>>>,
pub is_shm: Cell<bool>,
pub version: u32,
}
@ -121,14 +120,6 @@ impl ZwlrScreencopyFrameV1 {
return Err(ZwlrScreencopyFrameV1Error::InvalidBufferStride);
}
}
let is_shm = match &*buffer.storage.borrow() {
None => false,
Some(s) => match s {
WlBufferStorage::Shm { .. } => true,
WlBufferStorage::Dmabuf(_) => false,
},
};
self.is_shm.set(is_shm);
self.buffer.set(Some(buffer));
if !with_damage {
self.output.connector.connector.damage();

View file

@ -119,7 +119,6 @@ impl ZwlrScreencopyManagerV1 {
with_damage: Cell::new(false),
output_link: Cell::new(None),
buffer: Cell::new(None),
is_shm: Cell::new(false),
version: self.version,
});
track!(self.client, frame);