Struct gbm::BufferObject

source ·
pub struct BufferObject<T: 'static> { /* private fields */ }
Expand description

A GBM buffer object

Implementations§

source§

impl<T: 'static> BufferObject<T>

source

pub fn width(&self) -> Result<u32, DeviceDestroyedError>

Get the width of the buffer object

source

pub fn height(&self) -> Result<u32, DeviceDestroyedError>

Get the height of the buffer object

source

pub fn stride(&self) -> Result<u32, DeviceDestroyedError>

Get the stride of the buffer object

source

pub fn stride_for_plane(&self, plane: i32) -> Result<u32, DeviceDestroyedError>

Get the stride of the buffer object

source

pub fn format(&self) -> Result<Format, DeviceDestroyedError>

Get the format of the buffer object

source

pub fn bpp(&self) -> Result<u32, DeviceDestroyedError>

Get the bits per pixel of the buffer object

source

pub fn offset(&self, plane: i32) -> Result<u32, DeviceDestroyedError>

Get the offset for a plane of the buffer object

source

pub fn plane_count(&self) -> Result<u32, DeviceDestroyedError>

Get the plane count of the buffer object

source

pub fn modifier(&self) -> Result<Modifier, DeviceDestroyedError>

Get the modifier of the buffer object

source

pub fn fd(&self) -> Result<OwnedFd, FdError>

Get a DMA-BUF file descriptor for the buffer object

This function creates a DMA-BUF (also known as PRIME) file descriptor handle for the buffer object. Each call to Self::fd() returns a new file descriptor and the caller is responsible for closing the file descriptor.

source

pub fn device_fd(&self) -> Result<BorrowedFd<'_>, DeviceDestroyedError>

Get the file descriptor of the gbm device of this buffer object

source

pub fn handle(&self) -> Result<BufferObjectHandle, DeviceDestroyedError>

Get the handle of the buffer object

This is stored in the platform generic union BufferObjectHandle type. However the format of this handle is platform specific.

source

pub fn fd_for_plane(&self, plane: i32) -> Result<OwnedFd, FdError>

Get a DMA-BUF file descriptor for a plane of the buffer object

This function creates a DMA-BUF (also known as PRIME) file descriptor handle for a plane of the buffer object. Each call to Self::fd_for_plane() returns a new file descriptor and the caller is responsible for closing the file descriptor.

source

pub fn handle_for_plane( &self, plane: i32 ) -> Result<BufferObjectHandle, DeviceDestroyedError>

Get the handle of a plane of the buffer object

This is stored in the platform generic union BufferObjectHandle type. However the format of this handle is platform specific.

source

pub fn map<'a, D, F, S>( &'a self, device: &Device<D>, x: u32, y: u32, width: u32, height: u32, f: F ) -> Result<IoResult<S>, WrongDeviceError>
where D: AsFd + 'static, F: FnOnce(&MappedBufferObject<'a, T>) -> S,

Map a region of a GBM buffer object for cpu access

This function maps a region of a GBM bo for cpu read access.

source

pub fn map_mut<'a, D, F, S>( &'a mut self, device: &Device<D>, x: u32, y: u32, width: u32, height: u32, f: F ) -> Result<IoResult<S>, WrongDeviceError>
where D: AsFd + 'static, F: FnOnce(&mut MappedBufferObject<'a, T>) -> S,

Map a region of a GBM buffer object for cpu access

This function maps a region of a GBM bo for cpu read/write access.

source

pub fn write( &mut self, buffer: &[u8] ) -> Result<IoResult<()>, DeviceDestroyedError>

Write data into the buffer object

If the buffer object was created with the BufferObjectFlags::WRITE flag, this function can be used to write data into the buffer object. The data is copied directly into the object and it’s the responsibility of the caller to make sure the data represents valid pixel data, according to the width, height, stride and format of the buffer object.

source

pub fn set_userdata( &mut self, userdata: T ) -> Result<Option<T>, DeviceDestroyedError>

Sets the userdata of the buffer object.

If previously userdata was set, it is returned.

source

pub fn clear_userdata(&mut self) -> Result<(), DeviceDestroyedError>

Clears the set userdata of the buffer object.

source

pub fn userdata(&self) -> Result<Option<&T>, DeviceDestroyedError>

Returns a reference to set userdata, if any.

source

pub fn userdata_mut(&mut self) -> Result<Option<&mut T>, DeviceDestroyedError>

Returns a mutable reference to set userdata, if any.

source

pub fn take_userdata(&mut self) -> Result<Option<T>, DeviceDestroyedError>

Takes ownership of previously set userdata, if any.

This removes the userdata from the buffer object.

Trait Implementations§

source§

impl<T: 'static> AsRaw<gbm_bo> for BufferObject<T>

source§

fn as_raw(&self) -> *const gbm_bo

Receive a raw pointer representing this type.
source§

impl<T: 'static> Buffer for BufferObject<T>

source§

fn size(&self) -> (u32, u32)

The width and height of the buffer.
source§

fn format(&self) -> Format

The format of the buffer.
source§

fn pitch(&self) -> u32

The pitch of the buffer.
source§

fn handle(&self) -> Handle

The handle to the buffer.
source§

impl<T> Debug for BufferObject<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: 'static> PlanarBuffer for BufferObject<T>

source§

fn size(&self) -> (u32, u32)

The width and height of the buffer.
source§

fn format(&self) -> Format

The format of the buffer.
source§

fn modifier(&self) -> Option<Modifier>

The modifier of the buffer.
source§

fn pitches(&self) -> [u32; 4]

The pitches of the buffer.
source§

fn handles(&self) -> [Option<Handle>; 4]

The handles to the buffer.
source§

fn offsets(&self) -> [u32; 4]

The offsets of the buffer.

Auto Trait Implementations§

§

impl<T> Freeze for BufferObject<T>

§

impl<T> !RefUnwindSafe for BufferObject<T>

§

impl<T> Send for BufferObject<T>
where T: Send,

§

impl<T> !Sync for BufferObject<T>

§

impl<T> Unpin for BufferObject<T>
where T: Unpin,

§

impl<T> !UnwindSafe for BufferObject<T>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

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

source§

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

§

type Error = Infallible

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

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

Performs the conversion.
source§

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.
source§

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

Performs the conversion.