it: use single-pixel buffer instead of shm
This commit is contained in:
parent
aaed003ec8
commit
f562f887f0
17 changed files with 280 additions and 76 deletions
|
|
@ -1,42 +1,36 @@
|
|||
use {
|
||||
crate::{
|
||||
format::ARGB8888,
|
||||
it::{
|
||||
test_error::{TestError, TestResult},
|
||||
test_ifs::{
|
||||
test_shm_buffer::TestShmBuffer, test_shm_pool::TestShmPool,
|
||||
test_surface::TestSurface, test_xdg_surface::TestXdgSurface,
|
||||
test_xdg_toplevel::TestXdgToplevel,
|
||||
test_single_pixel_buffer_manager::TestSinglePixelBufferManager,
|
||||
test_surface::TestSurface, test_viewport::TestViewport,
|
||||
test_xdg_surface::TestXdgSurface, test_xdg_toplevel::TestXdgToplevel,
|
||||
},
|
||||
},
|
||||
theme::Color,
|
||||
utils::clonecell::CloneCell,
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestWindow {
|
||||
pub surface: Rc<TestSurface>,
|
||||
pub spbm: Rc<TestSinglePixelBufferManager>,
|
||||
pub viewport: Rc<TestViewport>,
|
||||
pub xdg: Rc<TestXdgSurface>,
|
||||
pub tl: Rc<TestXdgToplevel>,
|
||||
pub shm: Rc<TestShmPool>,
|
||||
pub buffer: CloneCell<Rc<TestShmBuffer>>,
|
||||
pub color: Cell<Color>,
|
||||
}
|
||||
|
||||
impl TestWindow {
|
||||
pub async fn map(&self) -> Result<(), TestError> {
|
||||
let width = self.tl.width.get();
|
||||
let height = self.tl.height.get();
|
||||
let stride = width * 4;
|
||||
let size = (stride * height) as usize;
|
||||
self.shm.resize(size)?;
|
||||
let buffer = self.shm.create_buffer(0, width, height, stride, ARGB8888)?;
|
||||
buffer.fill(self.color.get());
|
||||
let buffer = self.spbm.create_buffer(self.color.get())?;
|
||||
self.surface.attach(buffer.id)?;
|
||||
self.viewport.set_source(0, 0, 1, 1)?;
|
||||
self.viewport
|
||||
.set_destination(self.tl.width.get(), self.tl.height.get())?;
|
||||
self.xdg.ack_configure(self.xdg.last_serial.get())?;
|
||||
self.surface.commit()?;
|
||||
self.buffer.set(buffer);
|
||||
self.surface.tran.sync().await;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue