Struct gbm_rs::Device
[−]
[src]
pub struct Device { /* fields omitted */ }
Analogous to gbm_device.
Used to perform memory allocations for a DRM device.
Methods
impl Device
[src]
fn from_fd(fd: RawFd) -> Option<Device>
Creates a Device for allocating Buffers
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
Arguments
fd: The file descriptor for a backend specific device
Returns
The newly created struct gbm_device. If the creation of the device failed None will be returned.
Example
extern crate gbm_rs as gbm; use std::fs::OpenOptions; use std::os::unix::prelude::*; let file = OpenOptions::new().read(true).write(true).open("/dev/dri/card0").unwrap(); let device = gbm::Device::from_fd(file.as_raw_fd()).unwrap();
fn is_format_supported(&self, format: u32, usage: u32) -> bool
Test if a format is supported for a given set of usage flags
Arguments
format: The fourcc code to test
usage: A bitmask of the usages to test the format against
Returns
true if the format is supported otherwise false
fn fd(&self) -> RawFd
Returns the file descriptor for the Device
Returns
The Fd that the Device was created with
Example
let fd = device.fd(); assert_eq!(fd, file.as_raw_fd());
fn c_struct(&self) -> *const gbm_device
Returns the gbm_device for the Device
Returns
A pointer to the gbm_device used to create the Device.