Skip to content

Commit

Permalink
device: Add wrapper for gbm_device_get_format_modifier_plane_count
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Nov 21, 2024
1 parent d137d3a commit 11e8c10
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ impl<T: AsFd> Device<T> {
unsafe { ffi::gbm_device_is_format_supported(*self.ffi, format as u32, usage.bits()) != 0 }
}

/// Get the required number of planes for a given format and modifier
///
/// Some combination (e.g. when using a `Modifier::Invalid`) might not
/// have a defined/fixed number of planes. In these cases the function
/// might return `Option::None`.
pub fn format_modifier_plane_count(&self, format: Format, modifier: Modifier) -> Option<u32> {
unsafe {
ffi::gbm_device_get_format_modifier_plane_count(
*self.ffi,
format as u32,
modifier.into(),
)
.try_into()
.ok()
}
}

/// Allocate a new surface object
pub fn create_surface<U: 'static>(
&self,
Expand Down

0 comments on commit 11e8c10

Please sign in to comment.