⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

WlShmPool

Struct WlShmPool 

Source
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: u32

Pool object ID (Wayland protocol ID)

§client_id: u32

Owning client ID

§size: usize

Total size in bytes

Implementations§

Source§

impl WlShmPool

Source

pub fn new(id: u32, client_id: u32, size: usize) -> Self

Create a new pool with size bytes of zeroed backing memory.

Source

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

Source

pub fn get_buffer(&self, buffer_id: u32) -> Option<&WlBuffer>

Get an immutable reference to a buffer.

Source

pub fn destroy_buffer(&mut self, buffer_id: u32) -> bool

Remove a buffer from this pool.

Source

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.

Source

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).

Source

pub fn data(&self) -> &[u8]

Get raw access to the pool’s backing memory (for direct pixel reads by the compositor).

Source

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.

Source

pub fn resize(&mut self, new_size: usize) -> Result<(), KernelError>

Resize the pool (wl_shm_pool.resize). Only growing is allowed.

Auto Trait Implementations§

§

impl Freeze for WlShmPool

§

impl RefUnwindSafe for WlShmPool

§

impl Send for WlShmPool

§

impl Sync for WlShmPool

§

impl Unpin for WlShmPool

§

impl UnwindSafe for WlShmPool

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.