Skip to content

Commit

Permalink
Update drm and nix dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Oct 13, 2023
1 parent 888a996 commit e667df2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ harness = false

[features]
default = ["kms", "x11", "x11-dlopen", "wayland", "wayland-dlopen"]
kms = ["bytemuck", "drm", "drm-sys", "nix"]
kms = ["bytemuck", "drm", "nix"]
wayland = ["wayland-backend", "wayland-client", "memmap2", "nix", "fastrand"]
wayland-dlopen = ["wayland-sys/dlopen"]
x11 = ["as-raw-xcb-connection", "bytemuck", "nix", "tiny-xlib", "x11rb"]
Expand All @@ -31,10 +31,9 @@ raw-window-handle = "0.5.0"
[target.'cfg(all(unix, not(any(target_vendor = "apple", target_os = "android", target_os = "redox"))))'.dependencies]
as-raw-xcb-connection = { version = "1.0.0", optional = true }
bytemuck = { version = "1.12.3", optional = true }
drm = { version = "0.9.0", default-features = false, optional = true }
drm-sys = { version = "0.4.0", default-features = false, optional = true }
drm = { version = "0.10.0", default-features = false, optional = true }
memmap2 = { version = "0.9.0", optional = true }
nix = { version = "0.26.1", optional = true }
nix = { version = "0.27.0", features = ["fs", "mman"], optional = true }
tiny-xlib = { version = "0.2.1", optional = true }
wayland-backend = { version = "0.3.0", features = ["client_system"], optional = true }
wayland-client = { version = "0.31.0", optional = true }
Expand Down
18 changes: 9 additions & 9 deletions src/kms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
use drm::buffer::{Buffer, DrmFourcc};
use drm::control::dumbbuffer::{DumbBuffer, DumbMapping};
use drm::control::{connector, crtc, framebuffer, plane, Device as CtrlDevice, PageFlipFlags};
use drm::control::{
connector, crtc, framebuffer, plane, ClipRect, Device as CtrlDevice, PageFlipFlags,
};
use drm::Device;

use raw_window_handle::{DrmDisplayHandle, DrmWindowHandle};
Expand Down Expand Up @@ -308,20 +310,18 @@ impl BufferImpl<'_> {
.iter()
.map(|&rect| {
let err = || SoftBufferError::DamageOutOfRange { rect };
Ok(drm_sys::drm_clip_rect {
x1: rect.x.try_into().map_err(|_| err())?,
y1: rect.y.try_into().map_err(|_| err())?,
x2: rect
.x
Ok(ClipRect::new(
rect.x.try_into().map_err(|_| err())?,
rect.y.try_into().map_err(|_| err())?,
rect.x
.checked_add(rect.width.get())
.and_then(|x| x.try_into().ok())
.ok_or_else(err)?,
y2: rect
.y
rect.y
.checked_add(rect.height.get())
.and_then(|y| y.try_into().ok())
.ok_or_else(err)?,
})
))
})
.collect::<Result<Vec<_>, _>>()?;

Expand Down
10 changes: 5 additions & 5 deletions src/wayland/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use memmap2::MmapMut;
use std::{
ffi::CStr,
fs::File,
os::unix::prelude::{AsFd, AsRawFd, FromRawFd},
os::unix::prelude::{AsFd, AsRawFd},
slice,
sync::{
atomic::{AtomicBool, Ordering},
Expand Down Expand Up @@ -30,11 +30,11 @@ fn create_memfile() -> File {
)
.expect("Failed to create memfd to store buffer.");
let _ = fcntl(
fd,
fd.as_raw_fd(),
FcntlArg::F_ADD_SEALS(SealFlag::F_SEAL_SHRINK | SealFlag::F_SEAL_SEAL),
)
.expect("Failed to seal memfd.");
unsafe { File::from_raw_fd(fd) }
File::from(fd)
}

#[cfg(not(any(target_os = "linux", target_os = "freebsd")))]
Expand Down Expand Up @@ -64,10 +64,10 @@ fn create_memfile() -> File {
OFlag::O_RDWR | OFlag::O_CREAT | OFlag::O_EXCL,
Mode::S_IRWXU,
);
if fd != Err(Errno::EEXIST) {
if !matches!(fd, Err(Errno::EEXIST)) {
let fd = fd.expect("Failed to create POSIX shm to store buffer.");
let _ = shm_unlink(name);
return unsafe { File::from_raw_fd(fd) };
return File::from(fd);
}
}

Expand Down

0 comments on commit e667df2

Please sign in to comment.