pub struct Device<T: AsRawFd + 'static> { /* private fields */ }
Expand description
An open GBM device
Implementations§
source§impl Device<FdWrapper>
impl Device<FdWrapper>
sourcepub unsafe fn new_from_fd(fd: RawFd) -> IoResult<Device<FdWrapper>>
pub unsafe fn new_from_fd(fd: RawFd) -> IoResult<Device<FdWrapper>>
Open a GBM device from a given unix file descriptor.
The file descriptor passed in is used by the backend to communicate with platform for allocating the memory. For allocations using DRI this would be the file descriptor returned when opening a device such as /dev/dri/card0.
Unsafety
The lifetime of the resulting device depends on the ownership of the file descriptor. Closing the file descriptor before dropping the Device will lead to undefined behavior.
source§impl<T: AsRawFd + 'static> Device<T>
impl<T: AsRawFd + 'static> Device<T>
sourcepub fn new(fd: T) -> IoResult<Device<T>>
pub fn new(fd: T) -> IoResult<Device<T>>
Open a GBM device from a given open DRM device.
The underlying file descriptor passed in is used by the backend to communicate with platform for allocating the memory. For allocations using DRI this would be the file descriptor returned when opening a device such as /dev/dri/card0.
sourcepub fn backend_name(&self) -> &str
pub fn backend_name(&self) -> &str
Get the backend name
sourcepub fn is_format_supported(
&self,
format: Format,
usage: BufferObjectFlags
) -> bool
pub fn is_format_supported(
&self,
format: Format,
usage: BufferObjectFlags
) -> bool
Test if a format is supported for a given set of usage flags
sourcepub fn create_surface<U: 'static>(
&self,
width: u32,
height: u32,
format: Format,
usage: BufferObjectFlags
) -> IoResult<Surface<U>>
pub fn create_surface<U: 'static>(
&self,
width: u32,
height: u32,
format: Format,
usage: BufferObjectFlags
) -> IoResult<Surface<U>>
Allocate a new surface object
sourcepub fn create_buffer_object<U: 'static>(
&self,
width: u32,
height: u32,
format: Format,
usage: BufferObjectFlags
) -> IoResult<BufferObject<U>>
pub fn create_buffer_object<U: 'static>(
&self,
width: u32,
height: u32,
format: Format,
usage: BufferObjectFlags
) -> IoResult<BufferObject<U>>
Allocate a buffer object for the given dimensions
sourcepub fn import_buffer_object_from_wayland<U: 'static>(
&self,
buffer: &WlBuffer,
usage: BufferObjectFlags
) -> IoResult<BufferObject<U>>
pub fn import_buffer_object_from_wayland<U: 'static>(
&self,
buffer: &WlBuffer,
usage: BufferObjectFlags
) -> IoResult<BufferObject<U>>
Create a gbm buffer object from a wayland buffer
This function imports a foreign WlBuffer
object and creates a new gbm
buffer object for it.
This enabled using the foreign object with a display API such as KMS.
The gbm bo shares the underlying pixels but its life-time is independent of the foreign object.
sourcepub unsafe fn import_buffer_object_from_egl<U: 'static>(
&self,
buffer: EGLImage,
usage: BufferObjectFlags
) -> IoResult<BufferObject<U>>
pub unsafe fn import_buffer_object_from_egl<U: 'static>(
&self,
buffer: EGLImage,
usage: BufferObjectFlags
) -> IoResult<BufferObject<U>>
Create a gbm buffer object from an egl buffer
This function imports a foreign EGLImage
object and creates a new gbm
buffer object for it.
This enabled using the foreign object with a display API such as KMS.
The gbm bo shares the underlying pixels but its life-time is independent of the foreign object.
Unsafety
The given EGLImage is a raw pointer. Passing null or an invalid EGLImage will cause undefined behavior.
sourcepub fn import_buffer_object_from_dma_buf<U: 'static>(
&self,
buffer: RawFd,
width: u32,
height: u32,
stride: u32,
format: Format,
usage: BufferObjectFlags
) -> IoResult<BufferObject<U>>
pub fn import_buffer_object_from_dma_buf<U: 'static>(
&self,
buffer: RawFd,
width: u32,
height: u32,
stride: u32,
format: Format,
usage: BufferObjectFlags
) -> IoResult<BufferObject<U>>
Create a gbm buffer object from an dma buffer
This function imports a foreign dma buffer from an open file descriptor and creates a new gbm buffer object for it. This enabled using the foreign object with a display API such as KMS.
The gbm bo shares the underlying pixels but its life-time is independent of the foreign object.