pub struct MappedBufferObject<'a, T: 'static> { /* private fields */ }
Expand description
A mapped buffer object
Implementations§
Source§impl<'a, T: 'static> MappedBufferObject<'a, T>
impl<'a, T: 'static> MappedBufferObject<'a, T>
Sourcepub fn stride(&self) -> u32
pub fn stride(&self) -> u32
Get the stride of the buffer object
This is calculated by the backend when it does the allocation of the buffer.
Sourcepub fn x(&self) -> u32
pub fn x(&self) -> u32
The X (top left origin) starting position of the mapped region for the buffer
Sourcepub fn y(&self) -> u32
pub fn y(&self) -> u32
The Y (top left origin) starting position of the mapped region for the buffer
Sourcepub fn buffer_mut(&mut self) -> &mut [u8] ⓘ
pub fn buffer_mut(&mut self) -> &mut [u8] ⓘ
Mutable access to the underlying image buffer
Methods from Deref<Target = 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<'a, T> Debug for MappedBufferObject<'a, T>
impl<'a, T> Debug for MappedBufferObject<'a, T>
Source§impl<'a, T: 'static> Deref for MappedBufferObject<'a, T>
impl<'a, T: 'static> Deref for MappedBufferObject<'a, T>
Source§type Target = BufferObject<T>
type Target = BufferObject<T>
Source§fn deref(&self) -> &BufferObject<T>
fn deref(&self) -> &BufferObject<T>
Source§impl<'a, T: 'static> DerefMut for MappedBufferObject<'a, T>
impl<'a, T: 'static> DerefMut for MappedBufferObject<'a, T>
Source§fn deref_mut(&mut self) -> &mut BufferObject<T>
fn deref_mut(&mut self) -> &mut BufferObject<T>
Auto Trait Implementations§
impl<'a, T> Freeze for MappedBufferObject<'a, T>
impl<'a, T> !RefUnwindSafe for MappedBufferObject<'a, T>
impl<'a, T> !Send for MappedBufferObject<'a, T>
impl<'a, T> !Sync for MappedBufferObject<'a, T>
impl<'a, T> Unpin for MappedBufferObject<'a, T>
impl<'a, T> !UnwindSafe for MappedBufferObject<'a, 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.