it: test direct-scanout feedback
This commit is contained in:
parent
6baa7ab07f
commit
b966a73682
9 changed files with 302 additions and 1 deletions
72
src/it/test_ifs/test_dmabuf.rs
Normal file
72
src/it/test_ifs/test_dmabuf.rs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestResult,
|
||||
test_ifs::{test_dmabuf_feedback::TestDmabufFeedback, test_surface::TestSurface},
|
||||
test_object::TestObject,
|
||||
test_transport::TestTransport,
|
||||
},
|
||||
wire::{zwp_linux_dmabuf_v1::*, ZwpLinuxDmabufV1Id},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestDmabuf {
|
||||
pub id: ZwpLinuxDmabufV1Id,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
}
|
||||
|
||||
impl TestDmabuf {
|
||||
pub fn new(tran: &Rc<TestTransport>) -> Self {
|
||||
Self {
|
||||
id: tran.id(),
|
||||
tran: tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn destroy(&self) -> TestResult {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn get_default_feedback(&self) -> TestResult<Rc<TestDmabufFeedback>> {
|
||||
let obj = Rc::new(TestDmabufFeedback::new(&self.tran));
|
||||
self.tran.add_obj(obj.clone())?;
|
||||
self.tran.send(GetDefaultFeedback {
|
||||
self_id: self.id,
|
||||
id: obj.id,
|
||||
})?;
|
||||
Ok(obj)
|
||||
}
|
||||
|
||||
pub fn get_surface_feedback(
|
||||
&self,
|
||||
surface: &TestSurface,
|
||||
) -> TestResult<Rc<TestDmabufFeedback>> {
|
||||
let obj = Rc::new(TestDmabufFeedback::new(&self.tran));
|
||||
self.tran.add_obj(obj.clone())?;
|
||||
self.tran.send(GetSurfaceFeedback {
|
||||
self_id: self.id,
|
||||
id: obj.id,
|
||||
surface: surface.id,
|
||||
})?;
|
||||
Ok(obj)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TestDmabuf {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestDmabuf, ZwpLinuxDmabufV1;
|
||||
}
|
||||
|
||||
impl TestObject for TestDmabuf {}
|
||||
147
src/it/test_ifs/test_dmabuf_feedback.rs
Normal file
147
src/it/test_ifs/test_dmabuf_feedback.rs
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestResult, test_object::TestObject, test_transport::TestTransport,
|
||||
test_utils::test_expected_event::TEEH, testrun::ParseFull,
|
||||
},
|
||||
utils::buffd::MsgParser,
|
||||
wire::{zwp_linux_dmabuf_feedback_v1::*, ZwpLinuxDmabufFeedbackV1Id},
|
||||
},
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
mem,
|
||||
ops::DerefMut,
|
||||
rc::Rc,
|
||||
},
|
||||
uapi::{c, OwnedFd},
|
||||
};
|
||||
|
||||
pub struct TestDmabufFeedback {
|
||||
pub id: ZwpLinuxDmabufFeedbackV1Id,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
pub feedback: TEEH<Feedback>,
|
||||
pub pending_feedback: RefCell<PendingFeedback>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct PendingFeedback {
|
||||
pub format_table: Option<Rc<OwnedFd>>,
|
||||
pub format_table_size: usize,
|
||||
pub main_device: c::dev_t,
|
||||
pub tranches: Vec<Tranche>,
|
||||
pub pending_tranche: Tranche,
|
||||
}
|
||||
|
||||
pub struct Feedback {
|
||||
pub format_table: Rc<OwnedFd>,
|
||||
pub format_table_size: usize,
|
||||
pub main_device: c::dev_t,
|
||||
pub tranches: Vec<Tranche>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Tranche {
|
||||
pub target_device: c::dev_t,
|
||||
pub formats: Vec<usize>,
|
||||
pub flags: u32,
|
||||
}
|
||||
|
||||
impl TestDmabufFeedback {
|
||||
pub fn new(tran: &Rc<TestTransport>) -> Self {
|
||||
Self {
|
||||
id: tran.id(),
|
||||
tran: tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
feedback: Rc::new(Default::default()),
|
||||
pending_feedback: RefCell::new(Default::default()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn destroy(&self) -> TestResult {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_done(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Done::parse_full(parser)?;
|
||||
let mut pending = mem::take(self.pending_feedback.borrow_mut().deref_mut());
|
||||
self.feedback.push(Feedback {
|
||||
format_table: match pending.format_table.take() {
|
||||
None => bail!("compositor did not send format table"),
|
||||
Some(ft) => ft,
|
||||
},
|
||||
format_table_size: pending.format_table_size,
|
||||
main_device: pending.main_device,
|
||||
tranches: pending.tranches,
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_format_table(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let ev = FormatTable::parse_full(parser)?;
|
||||
let pending = &mut *self.pending_feedback.borrow_mut();
|
||||
pending.format_table = Some(ev.fd);
|
||||
pending.format_table_size = ev.size as _;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_main_device(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let ev = MainDevice::parse_full(parser)?;
|
||||
let pending = &mut *self.pending_feedback.borrow_mut();
|
||||
pending.main_device = ev.device;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_tranche_done(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = TrancheDone::parse_full(parser)?;
|
||||
let pending = &mut *self.pending_feedback.borrow_mut();
|
||||
pending
|
||||
.tranches
|
||||
.push(mem::take(&mut pending.pending_tranche));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_tranche_target_device(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let ev = TrancheTargetDevice::parse_full(parser)?;
|
||||
let pending = &mut *self.pending_feedback.borrow_mut();
|
||||
pending.pending_tranche.target_device = ev.device;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_tranche_formats(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let ev = TrancheFormats::parse_full(parser)?;
|
||||
let pending = &mut *self.pending_feedback.borrow_mut();
|
||||
pending.pending_tranche.formats = ev.indices.iter().copied().map(|v| v as usize).collect();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_tranche_flags(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let ev = TrancheFlags::parse_full(parser)?;
|
||||
let pending = &mut *self.pending_feedback.borrow_mut();
|
||||
pending.pending_tranche.flags = ev.flags;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TestDmabufFeedback {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestDmabufFeedback, ZwpLinuxDmabufFeedbackV1;
|
||||
|
||||
DONE => handle_done,
|
||||
FORMAT_TABLE => handle_format_table,
|
||||
MAIN_DEVICE => handle_main_device,
|
||||
TRANCHE_DONE => handle_tranche_done,
|
||||
TRANCHE_TARGET_DEVICE => handle_tranche_target_device,
|
||||
TRANCHE_FORMATS => handle_tranche_formats,
|
||||
TRANCHE_FLAGS => handle_tranche_flags,
|
||||
}
|
||||
|
||||
impl TestObject for TestDmabufFeedback {}
|
||||
|
|
@ -8,7 +8,7 @@ use {
|
|||
test_compositor::TestCompositor, test_content_type_manager::TestContentTypeManager,
|
||||
test_cursor_shape_manager::TestCursorShapeManager,
|
||||
test_data_control_manager::TestDataControlManager,
|
||||
test_data_device_manager::TestDataDeviceManager,
|
||||
test_data_device_manager::TestDataDeviceManager, test_dmabuf::TestDmabuf,
|
||||
test_ext_foreign_toplevel_list::TestExtForeignToplevelList,
|
||||
test_jay_compositor::TestJayCompositor, test_shm::TestShm,
|
||||
test_single_pixel_buffer_manager::TestSinglePixelBufferManager,
|
||||
|
|
@ -47,6 +47,7 @@ pub struct TestRegistrySingletons {
|
|||
pub wp_linux_drm_syncobj_manager_v1: u32,
|
||||
pub wp_content_type_manager_v1: u32,
|
||||
pub zwlr_data_control_manager_v1: u32,
|
||||
pub zwp_linux_dmabuf_v1: u32,
|
||||
}
|
||||
|
||||
pub struct TestRegistry {
|
||||
|
|
@ -68,6 +69,7 @@ pub struct TestRegistry {
|
|||
pub syncobj_manager: CloneCell<Option<Rc<TestSyncobjManager>>>,
|
||||
pub content_type_manager: CloneCell<Option<Rc<TestContentTypeManager>>>,
|
||||
pub data_control_manager: CloneCell<Option<Rc<TestDataControlManager>>>,
|
||||
pub dmabuf: CloneCell<Option<Rc<TestDmabuf>>>,
|
||||
pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>,
|
||||
}
|
||||
|
||||
|
|
@ -133,6 +135,7 @@ impl TestRegistry {
|
|||
wp_linux_drm_syncobj_manager_v1,
|
||||
wp_content_type_manager_v1,
|
||||
zwlr_data_control_manager_v1,
|
||||
zwp_linux_dmabuf_v1,
|
||||
};
|
||||
self.singletons.set(Some(singletons.clone()));
|
||||
Ok(singletons)
|
||||
|
|
@ -212,6 +215,7 @@ impl TestRegistry {
|
|||
2,
|
||||
TestDataControlManager
|
||||
);
|
||||
create_singleton!(get_dmabuf, dmabuf, zwp_linux_dmabuf_v1, 5, TestDmabuf);
|
||||
|
||||
pub fn bind<O: TestObject>(
|
||||
&self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue