Skip to content

Commit

Permalink
Merge pull request #27 from ids1024/borrowedfd
Browse files Browse the repository at this point in the history
Accept `BorrowedFd` in public API methods instead of `RawFd`
  • Loading branch information
Drakulix authored Nov 14, 2023
2 parents 84088c7 + 080c735 commit 71e76f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::ffi::CStr;
use std::fmt;
use std::io::{Error as IoError, Result as IoResult};
use std::ops::{Deref, DerefMut};
use std::os::unix::io::RawFd;

#[cfg(feature = "import-wayland")]
use wayland_server::protocol::wl_buffer::WlBuffer;
Expand Down Expand Up @@ -333,15 +332,15 @@ impl<T: AsFd> Device<T> {
/// independent of the foreign object.
pub fn import_buffer_object_from_dma_buf<U: 'static>(
&self,
buffer: RawFd,
buffer: BorrowedFd<'_>,
width: u32,
height: u32,
stride: u32,
format: Format,
usage: BufferObjectFlags,
) -> IoResult<BufferObject<U>> {
let mut fd_data = ffi::gbm_import_fd_data {
fd: buffer,
fd: buffer.as_raw_fd(),
width,
height,
stride,
Expand Down Expand Up @@ -375,7 +374,7 @@ impl<T: AsFd> Device<T> {
pub fn import_buffer_object_from_dma_buf_with_modifiers<U: 'static>(
&self,
len: u32,
buffers: [RawFd; 4],
buffers: [Option<BorrowedFd<'_>>; 4],
width: u32,
height: u32,
format: Format,
Expand All @@ -384,8 +383,9 @@ impl<T: AsFd> Device<T> {
offsets: [i32; 4],
modifier: Modifier,
) -> IoResult<BufferObject<U>> {
let fds = buffers.map(|fd| fd.map_or(-1, |x| x.as_raw_fd()));
let mut fd_data = ffi::gbm_import_fd_modifier_data {
fds: buffers,
fds,
width,
height,
format: format as u32,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//! use gbm::{BufferObjectFlags, Device, Format};
//!
//! # use std::fs::{File, OpenOptions};
//! # use std::os::unix::io::{AsFd, BorrowedFd, RawFd};
//! # use std::os::unix::io::{AsFd, BorrowedFd};
//! #
//! # use drm::control::Device as ControlDevice;
//! # use drm::Device as BasicDevice;
Expand Down

0 comments on commit 71e76f5

Please sign in to comment.