pub struct BufferObject<T: 'static> { /* private fields */ }
Expand description
A GBM buffer object
Implementations§
Source§impl<T: 'static> BufferObject<T>
impl<T: 'static> BufferObject<T>
Sourcepub fn stride_for_plane(&self, plane: i32) -> u32
pub fn stride_for_plane(&self, plane: i32) -> u32
Get the stride of the buffer object
Sourcepub fn plane_count(&self) -> u32
pub fn plane_count(&self) -> u32
Get the plane count of the buffer object
Sourcepub fn fd(&self) -> Result<OwnedFd, InvalidFdError>
pub fn fd(&self) -> Result<OwnedFd, InvalidFdError>
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.
Sourcepub fn device_fd(&self) -> BorrowedFd<'_>
pub fn device_fd(&self) -> BorrowedFd<'_>
Get the file descriptor of the gbm device of this buffer object
Sourcepub fn handle(&self) -> BufferObjectHandle
pub fn handle(&self) -> BufferObjectHandle
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.
Sourcepub fn fd_for_plane(&self, plane: i32) -> Result<OwnedFd, InvalidFdError>
pub fn fd_for_plane(&self, plane: i32) -> Result<OwnedFd, InvalidFdError>
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.
Sourcepub fn handle_for_plane(&self, plane: i32) -> BufferObjectHandle
pub fn handle_for_plane(&self, plane: i32) -> BufferObjectHandle
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.
Sourcepub fn map<'a, F, S>(
&'a self,
x: u32,
y: u32,
width: u32,
height: u32,
f: F,
) -> IoResult<S>where
F: FnOnce(&MappedBufferObject<'a, T>) -> S,
pub fn map<'a, F, S>(
&'a self,
x: u32,
y: u32,
width: u32,
height: u32,
f: F,
) -> IoResult<S>where
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.
Sourcepub fn map_mut<'a, F, S>(
&'a mut self,
x: u32,
y: u32,
width: u32,
height: u32,
f: F,
) -> IoResult<S>where
F: FnOnce(&mut MappedBufferObject<'a, T>) -> S,
pub fn map_mut<'a, F, S>(
&'a mut self,
x: u32,
y: u32,
width: u32,
height: u32,
f: F,
) -> IoResult<S>where
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.
Sourcepub fn write(&mut self, buffer: &[u8]) -> IoResult<()>
pub fn write(&mut self, buffer: &[u8]) -> IoResult<()>
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.
Sourcepub fn set_userdata(&mut self, userdata: T) -> Option<T>
pub fn set_userdata(&mut self, userdata: T) -> Option<T>
Sets the userdata of the buffer object.
If previously userdata was set, it is returned.
Sourcepub fn clear_userdata(&mut self)
pub fn clear_userdata(&mut self)
Clears the set userdata of the buffer object.
Sourcepub fn userdata_mut(&mut self) -> Option<&mut T>
pub fn userdata_mut(&mut self) -> Option<&mut T>
Returns a mutable reference to set userdata, if any.
Sourcepub fn take_userdata(&mut self) -> Option<T>
pub fn take_userdata(&mut self) -> Option<T>
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>
impl<T: 'static> AsRaw<gbm_bo> for BufferObject<T>
Source§impl<T: 'static> Buffer for BufferObject<T>
impl<T: 'static> Buffer for BufferObject<T>
Source§impl<T> Debug for BufferObject<T>
impl<T> Debug for BufferObject<T>
Source§impl<T: 'static> PlanarBuffer for BufferObject<T>
impl<T: 'static> PlanarBuffer for BufferObject<T>
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>where
T: Sync,
impl<T> Unpin for BufferObject<T>where
T: Unpin,
impl<T> !UnwindSafe for BufferObject<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.