video: add udmabuf allocator
This commit is contained in:
parent
2579834a60
commit
62cd29056a
33 changed files with 883 additions and 256 deletions
|
|
@ -9,13 +9,14 @@ use {
|
|||
testrun::ParseFull,
|
||||
},
|
||||
utils::{buffd::MsgParser, cell_ext::CellExt},
|
||||
video::dmabuf::DmaBuf,
|
||||
wire::{
|
||||
jay_compositor::{self, *},
|
||||
jay_screenshot::Dmabuf,
|
||||
JayCompositorId,
|
||||
},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
uapi::OwnedFd,
|
||||
};
|
||||
|
||||
pub struct TestJayCompositor {
|
||||
|
|
@ -49,10 +50,16 @@ impl TestJayCompositor {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn take_screenshot(&self, include_cursor: bool) -> Result<Dmabuf, TestError> {
|
||||
pub async fn take_screenshot(
|
||||
&self,
|
||||
include_cursor: bool,
|
||||
) -> Result<(DmaBuf, Option<Rc<OwnedFd>>), TestError> {
|
||||
let js = Rc::new(TestJayScreenshot {
|
||||
id: self.tran.id(),
|
||||
result: Cell::new(None),
|
||||
state: self.tran.run.state.clone(),
|
||||
drm_dev: Default::default(),
|
||||
planes: Default::default(),
|
||||
result: Default::default(),
|
||||
});
|
||||
self.tran.send(TakeScreenshot2 {
|
||||
self_id: self.id,
|
||||
|
|
@ -62,7 +69,7 @@ impl TestJayCompositor {
|
|||
self.tran.add_obj(js.clone())?;
|
||||
self.tran.sync().await;
|
||||
match js.result.take() {
|
||||
Some(Ok(res)) => Ok(res),
|
||||
Some(Ok(res)) => Ok((res, js.drm_dev.take())),
|
||||
Some(Err(res)) => bail!("Compositor could not take a screenshot: {}", res),
|
||||
None => bail!("Compositor did not send a screenshot"),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ impl TestRegistry {
|
|||
get_jay_compositor,
|
||||
jay_compositor,
|
||||
jay_compositor,
|
||||
1,
|
||||
6,
|
||||
TestJayCompositor
|
||||
);
|
||||
create_singleton!(get_compositor, compositor, wl_compositor, 6, TestCompositor);
|
||||
|
|
|
|||
|
|
@ -1,21 +1,44 @@
|
|||
use {
|
||||
crate::{
|
||||
format::XRGB8888,
|
||||
it::{test_error::TestError, test_object::TestObject, testrun::ParseFull},
|
||||
state::State,
|
||||
utils::buffd::MsgParser,
|
||||
video::dmabuf::{DmaBuf, DmaBufPlane, PlaneVec},
|
||||
wire::{jay_screenshot::*, JayScreenshotId},
|
||||
},
|
||||
std::cell::Cell,
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
rc::Rc,
|
||||
},
|
||||
uapi::OwnedFd,
|
||||
};
|
||||
|
||||
pub struct TestJayScreenshot {
|
||||
pub id: JayScreenshotId,
|
||||
pub result: Cell<Option<Result<Dmabuf, String>>>,
|
||||
pub state: Rc<State>,
|
||||
pub drm_dev: Cell<Option<Rc<OwnedFd>>>,
|
||||
pub planes: RefCell<PlaneVec<DmaBufPlane>>,
|
||||
pub result: Cell<Option<Result<DmaBuf, String>>>,
|
||||
}
|
||||
|
||||
impl TestJayScreenshot {
|
||||
fn handle_dmabuf(&self, parser: MsgParser<'_, '_>) -> Result<(), TestError> {
|
||||
let ev = Dmabuf::parse_full(parser)?;
|
||||
self.result.set(Some(Ok(ev)));
|
||||
let mut planes = PlaneVec::new();
|
||||
planes.push(DmaBufPlane {
|
||||
offset: ev.offset,
|
||||
stride: ev.stride,
|
||||
fd: ev.fd,
|
||||
});
|
||||
self.result.set(Some(Ok(DmaBuf {
|
||||
id: self.state.dma_buf_ids.next(),
|
||||
width: ev.width as _,
|
||||
height: ev.height as _,
|
||||
format: XRGB8888,
|
||||
modifier: ((ev.modifier_hi as u64) << 32) | (ev.modifier_lo as u64),
|
||||
planes,
|
||||
})));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -24,6 +47,35 @@ impl TestJayScreenshot {
|
|||
self.result.set(Some(Err(ev.msg.to_string())));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_drm_dev(&self, parser: MsgParser<'_, '_>) -> Result<(), TestError> {
|
||||
let ev = DrmDev::parse_full(parser)?;
|
||||
self.drm_dev.set(Some(ev.drm_dev));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_plane(&self, parser: MsgParser<'_, '_>) -> Result<(), TestError> {
|
||||
let ev = Plane::parse_full(parser)?;
|
||||
self.planes.borrow_mut().push(DmaBufPlane {
|
||||
offset: ev.offset,
|
||||
stride: ev.stride,
|
||||
fd: ev.fd,
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_dmabuf2(&self, parser: MsgParser<'_, '_>) -> Result<(), TestError> {
|
||||
let ev = Dmabuf2::parse_full(parser)?;
|
||||
self.result.set(Some(Ok(DmaBuf {
|
||||
id: self.state.dma_buf_ids.next(),
|
||||
width: ev.width as _,
|
||||
height: ev.height as _,
|
||||
format: XRGB8888,
|
||||
modifier: ev.modifier,
|
||||
planes: self.planes.take(),
|
||||
})));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
|
|
@ -31,6 +83,9 @@ test_object! {
|
|||
|
||||
DMABUF => handle_dmabuf,
|
||||
ERROR => handle_error,
|
||||
DRM_DEV => handle_drm_dev,
|
||||
PLANE => handle_plane,
|
||||
DMABUF2 => handle_dmabuf2,
|
||||
}
|
||||
|
||||
impl TestObject for TestJayScreenshot {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue