diff --git a/Cargo.toml b/Cargo.toml index 783335ada252..33f592e2c44b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ drm-fourcc = "^2.2.0" drm = { version = "0.14.0", optional = true } drm-ffi = { version = "0.9.0", optional = true } errno = "0.3.5" -gbm = { version = "0.16.0", optional = true, default-features = false, features = ["drm-support"] } +gbm = { version = "0.17.0", optional = true, default-features = false, features = ["drm-support"] } glow = { version = "0.14", optional = true } input = { version = "0.9.0", default-features = false, features=["libinput_1_19"], optional = true } indexmap = "2.0" diff --git a/src/backend/allocator/gbm.rs b/src/backend/allocator/gbm.rs index fe10ff7e059a..603bbc1994d4 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, @@ -253,23 +250,13 @@ pub enum GbmConvertError { InvalidFD(#[from] gbm::InvalidFdError), } -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(), - } - } -} - impl AsDmabuf for GbmBuffer { type Error = GbmConvertError; #[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 +266,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 96edfa1c329b..520f75b8a497 100644 --- a/src/backend/drm/compositor/mod.rs +++ b/src/backend/drm/compositor/mod.rs @@ -3425,13 +3425,12 @@ where let cursor_buffer_size = cursor_plane_size.to_logical(1).to_buffer(1, Transform::Normal); #[cfg(not(feature = "renderer_pixman"))] - if !copy_element_to_cursor_bo( + if !copy_element_to_cursor_bo::<_, _, G>( renderer, element, element_size, cursor_plane_size, output_transform, - &cursor_state.framebuffer_exporter, &mut cursor_buffer, ) { tracing::trace!("failed to copy element to cursor bo, skipping element on cursor plane"); @@ -3439,13 +3438,12 @@ where } #[cfg(feature = "renderer_pixman")] - if !copy_element_to_cursor_bo( + if !copy_element_to_cursor_bo::<_, _, G>( renderer, element, element_size, cursor_plane_size, output_transform, - &cursor_state.framebuffer_exporter, &mut cursor_buffer, ) { profiling::scope!("render cursor plane"); @@ -3493,8 +3491,7 @@ where }?; let ret = cursor_buffer - .map_mut::<_, _, Result<_, ::Error>>( - &cursor_state.framebuffer_exporter, + .map_mut::::Error>>( 0, 0, cursor_buffer_size.w as u32, @@ -3538,17 +3535,10 @@ where _ = pixman_renderer.unbind(); - match ret { - Err(err) => { - debug!("{err}"); - return None; - } - Ok(Err(err)) => { - debug!("{err}"); - return None; - } - Ok(Ok(_)) => (), - }; + if let Err(err) = ret { + debug!("{err}"); + return None; + } }; let src = Rectangle::from_loc_and_size(Point::default(), cursor_buffer_size).to_f64(); @@ -4381,7 +4371,6 @@ fn copy_element_to_cursor_bo( element_size: Size, cursor_size: Size, output_transform: Transform, - device: &GbmDevice, bo: &mut GbmBuffer, ) -> bool where @@ -4407,15 +4396,13 @@ 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 res = bo.map_mut::(0, 0, cursor_size.w as u32, cursor_size.h as u32, |mbo| { let dst = mbo.buffer_mut(); for row in 0..src_height { let src_row_start = (row * src_stride) as usize; @@ -4427,7 +4414,7 @@ where dst_row.copy_from_slice(src_row); } }); - matches!(res, Ok(Ok(_))) + matches!(res, Ok(_)) } }; 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 373e62351327..604d8f899f2f 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);