Skip to content

Commit

Permalink
bo: Add device fd method
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Feb 15, 2024
1 parent 4c07f80 commit d1b5967
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/buffer_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{AsRaw, Device, DeviceDestroyedError, Format, Modifier, Ptr, WeakPtr}

#[cfg(feature = "drm-support")]
use drm::buffer::{Buffer as DrmBuffer, Handle, PlanarBuffer as DrmPlanarBuffer};
use std::os::unix::io::{AsFd, FromRawFd, OwnedFd};
use std::os::unix::io::{AsFd, BorrowedFd, FromRawFd, OwnedFd};

use std::error;
use std::fmt;
Expand Down Expand Up @@ -256,6 +256,12 @@ impl<T: 'static> BufferObject<T> {
}
}

/// Get the file descriptor of the gbm device of this buffer object
pub fn device_fd(&self) -> Result<BorrowedFd, DeviceDestroyedError> {
let device_ptr = self._device.upgrade().ok_or(DeviceDestroyedError)?;
Ok(unsafe { BorrowedFd::borrow_raw(ffi::gbm_device_get_fd(*device_ptr)) })
}

/// Get the handle of the buffer object
///
/// This is stored in the platform generic union [`BufferObjectHandle`] type. However
Expand Down

0 comments on commit d1b5967

Please sign in to comment.