diff --git a/Cargo.toml b/Cargo.toml index cdd844fb6820..e25a727850c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -141,3 +141,6 @@ harness = false [profile.release-with-debug] inherits = "release" debug = true + +[patch.crates-io] +gbm = { git = "https://github.com/ids1024/gbm.rs", branch = "strong-ref" } diff --git a/src/backend/allocator/gbm.rs b/src/backend/allocator/gbm.rs index fe10ff7e059a..2a360f192e65 100644 --- a/src/backend/allocator/gbm.rs +++ b/src/backend/allocator/gbm.rs @@ -94,13 +94,13 @@ impl GbmBuffer { /// Gbm might otherwise give us the underlying or a non-sensical modifier, /// which can fail in various other apis. pub fn from_bo(bo: BufferObject<()>, implicit: bool) -> Self { - let size = (bo.width().unwrap_or(0) as i32, bo.height().unwrap_or(0) as i32).into(); + let size = (bo.width() as i32, bo.height() as i32).into(); let format = Format { - code: bo.format().unwrap_or(Fourcc::Argb8888), // we got to return something, but this should never happen anyway + code: bo.format(), modifier: if implicit { Modifier::Invalid } else { - bo.modifier().unwrap_or(Modifier::Invalid) + bo.modifier() }, }; Self { bo, size, format } @@ -242,9 +242,6 @@ impl Buffer for GbmBuffer { /// Errors during conversion to a dmabuf handle from a gbm buffer object #[derive(thiserror::Error, Debug)] pub enum GbmConvertError { - /// The gbm device was destroyed - #[error("The gbm device was destroyed")] - DeviceDestroyed(#[from] gbm::DeviceDestroyedError), /// The buffer consists out of multiple file descriptions, which is currently unsupported #[error("Buffer consists out of multiple file descriptors, which is currently unsupported")] UnsupportedBuffer, @@ -257,7 +254,6 @@ impl From for GbmConvertError { #[inline] fn from(err: gbm::FdError) -> Self { match err { - gbm::FdError::DeviceDestroyed(err) => err.into(), gbm::FdError::InvalidFd(err) => err.into(), } } @@ -269,7 +265,7 @@ impl AsDmabuf for GbmBuffer { #[cfg(feature = "backend_gbm_has_fd_for_plane")] #[profiling::function] fn export(&self) -> Result { - let planes = self.plane_count()? as i32; + let planes = self.plane_count() as i32; let mut builder = Dmabuf::builder_from_buffer(self, DmabufFlags::empty()); for idx in 0..planes { @@ -279,13 +275,13 @@ impl AsDmabuf for GbmBuffer { // SAFETY: `gbm_bo_get_fd_for_plane` returns a new fd owned by the caller. fd, idx as u32, - self.offset(idx)?, - self.stride_for_plane(idx)?, + self.offset(idx), + self.stride_for_plane(idx), ); } #[cfg(feature = "backend_drm")] - if let Some(node) = self.device_fd().ok().and_then(|fd| DrmNode::from_file(fd).ok()) { + if let Ok(node) = DrmNode::from_file(self.device_fd()) { builder.set_node(node); } diff --git a/src/backend/drm/compositor/mod.rs b/src/backend/drm/compositor/mod.rs index 2e7e99fb61e9..bd34499cc5ec 100644 --- a/src/backend/drm/compositor/mod.rs +++ b/src/backend/drm/compositor/mod.rs @@ -4365,13 +4365,11 @@ where } let bo_format = bo.format().code; - let Ok(bo_stride) = bo.stride() else { - return false; - }; + let bo_stride = bo.stride(); let mut copy_to_bo = |src, src_stride, src_height| { if src_stride == bo_stride as i32 { - matches!(bo.write(src), Ok(Ok(_))) + matches!(bo.write(src), Ok(_)) } else { let res = bo.map_mut(device, 0, 0, cursor_size.w as u32, cursor_size.h as u32, |mbo| { let dst = mbo.buffer_mut(); diff --git a/src/backend/drm/gbm.rs b/src/backend/drm/gbm.rs index 6badd649c2b6..4adfecfbfc01 100644 --- a/src/backend/drm/gbm.rs +++ b/src/backend/drm/gbm.rs @@ -344,7 +344,7 @@ where // We only support this as a fallback of last resort like xf86-video-modesetting does. warn_legacy_fb_export(); - if bo.plane_count().unwrap() > 1 { + if bo.plane_count() > 1 { return Err(AccessError { errmsg: "Failed to add framebuffer", dev: drm.dev_path(), diff --git a/src/backend/drm/surface/gbm.rs b/src/backend/drm/surface/gbm.rs index 8233e1fc554c..36161ea41464 100644 --- a/src/backend/drm/surface/gbm.rs +++ b/src/backend/drm/surface/gbm.rs @@ -197,10 +197,10 @@ where }; let format = Format { code, - modifier: buffer.modifier().unwrap(), // no guarantee - // that this is stable across allocations, but - // we want to print that here for debugging proposes. - // It has no further use. + modifier: buffer.modifier(), // no guarantee + // that this is stable across allocations, but + // we want to print that here for debugging proposes. + // It has no further use. }; let use_opaque = !plane_formats.iter().any(|f| f.code == code);