Struct BufferObject

Source
pub struct BufferObject { /* private fields */ }
Expand description

Analogous to gbm_bo

Implementations§

Source§

impl BufferObject

Source

pub fn new( dev: &Device, width: u32, height: u32, format: u32, flags: u32, ) -> Option<BufferObject>

Allocate a buffer object for the given dimensions

§Arguments

dev: The Device returned from Device::from_fd()

width: The width for the buffer

height: The height for the buffer

format: The fourcc code for the surface

usage: The union of the usage flags for this buffer

§Returns

A newly allocated buffer. If an error occurs during allocation None will be returned and errno set.

§Example
let buffer = BufferObject::new(&device, 1920, 1080,
                               gbm::format::XRGB8888, // GBM_FORMAT_XRGB8888
                               gbm::USE_SCANOUT | gbm::USE_RENDERING);
Source

pub fn width(&self) -> u32

Get the width of the BufferObject

§Returns

The width of the allocated BufferObject

Source

pub fn height(&self) -> u32

Get the height of the BufferObject

§Returns

The height of the allocated BufferObject

Source

pub fn stride(&self) -> u32

Get the stride of the BufferObject

This is calculated by the backend when it does the allocation in BufferObject::new()

§Returns

The stride of the allocated BufferObject in bytes

Source

pub fn format(&self) -> u32

Get the format of the buffer object

The format of the pixels in the buffer.

§Returns

The format of buffer object, as a fourcc code

Source

pub fn device(&self) -> Device

Get the gbm device used to create the buffer object

§Returns

Returns the gbm device with which the buffer object was created

Source

pub fn handle_u32(&self) -> u32

Get the handle of the buffer object

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

§Returns

Returns the handle of the allocated BufferObject as a u32

Source

pub fn handle_u64(&self) -> u64

Get the handle of the buffer object

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

§Returns

Returns the handle of the allocated BufferObject as a u64

Source

pub fn handle_i32(&self) -> i32

Get the handle of the buffer object

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

§Returns

Returns the handle of the allocated BufferObject as a i32

Source

pub fn handle_i64(&self) -> i64

Get the handle of the buffer object

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

§Returns

Returns the handle of the allocated BufferObject as a i64

Source

pub fn handle_ptr(&self) -> *const c_void

Get the handle of the buffer object

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

§Returns

Returns the handle of the allocated BufferObject as a void *

Source

pub fn fd(&self) -> RawFd

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 gbm_bo_get_fd() returns a new file descriptor and the caller is responsible for closing the file descriptor.

§Returns

Returns a file descriptor referring to the underlying buffer

Source

pub fn write<T>(&self, buf: *const T, count: usize) -> bool

Write data into the buffer object

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

§Arguments

buf: The data to write

count: The number of bytes to write

§Returns

Returns true on success, otherwise false is returned an errno set

Source

pub fn c_struct(&self) -> *const gbm_bo

Returns the gbm_bo for the BufferObject

§Returns

A pointer to the gbm_bo used to create the BufferObject.

Trait Implementations§

Source§

impl Drop for BufferObject

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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> 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>,

Source§

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>,

Source§

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.