pub struct WlShmPool {
pub id: u32,
pub client_id: u32,
pub size: usize,
/* private fields */
}Expand description
A shared memory pool that backs one or more buffers.
In a real Wayland compositor the pool would reference a client-provided file descriptor pointing to an mmap’d region. Here we allocate from the kernel heap as a stand-in, since user-space shared memory is not yet wired for graphics.
Fields§
§id: u32Pool object ID (Wayland protocol ID)
client_id: u32Owning client ID
size: usizeTotal size in bytes
Implementations§
Source§impl WlShmPool
impl WlShmPool
Sourcepub fn new(id: u32, client_id: u32, size: usize) -> Self
pub fn new(id: u32, client_id: u32, size: usize) -> Self
Create a new pool with size bytes of zeroed backing memory.
Sourcepub fn create_buffer(
&mut self,
offset: u32,
width: u32,
height: u32,
stride: u32,
format: PixelFormat,
) -> Result<u32, KernelError>
pub fn create_buffer( &mut self, offset: u32, width: u32, height: u32, stride: u32, format: PixelFormat, ) -> Result<u32, KernelError>
Create a buffer that references a region within this pool.
Arguments mirror wl_shm_pool.create_buffer: offset – byte offset into the pool width, height – dimensions in pixels stride – bytes per row format – pixel format code
Sourcepub fn get_buffer(&self, buffer_id: u32) -> Option<&WlBuffer>
pub fn get_buffer(&self, buffer_id: u32) -> Option<&WlBuffer>
Get an immutable reference to a buffer.
Sourcepub fn destroy_buffer(&mut self, buffer_id: u32) -> bool
pub fn destroy_buffer(&mut self, buffer_id: u32) -> bool
Remove a buffer from this pool.
Sourcepub fn read_buffer_pixels(&self, buffer_id: u32) -> Option<&[u8]>
pub fn read_buffer_pixels(&self, buffer_id: u32) -> Option<&[u8]>
Read pixel data for a buffer from the pool backing store.
Returns a slice of the pool data corresponding to the buffer’s region.
Sourcepub fn write_buffer_pixels(&mut self, buffer_id: u32, pixels: &[u8]) -> bool
pub fn write_buffer_pixels(&mut self, buffer_id: u32, pixels: &[u8]) -> bool
Write pixel data into the pool backing store at the buffer’s offset.
Used for testing and by kernel-side rendering that needs to fill a buffer (e.g. a cursor image).
Sourcepub fn data(&self) -> &[u8]
pub fn data(&self) -> &[u8]
Get raw access to the pool’s backing memory (for direct pixel reads by the compositor).
Sourcepub fn write_data(&mut self, offset: usize, data: &[u8])
pub fn write_data(&mut self, offset: usize, data: &[u8])
Write raw bytes into the pool at a given offset.
Used by the desktop renderer to populate background/window pixel data.
Sourcepub fn resize(&mut self, new_size: usize) -> Result<(), KernelError>
pub fn resize(&mut self, new_size: usize) -> Result<(), KernelError>
Resize the pool (wl_shm_pool.resize). Only growing is allowed.