From 11e8c10a8c2073d3b244089cc821d80f4aa10156 Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Thu, 21 Nov 2024 14:21:48 +0100 Subject: [PATCH] device: Add wrapper for `gbm_device_get_format_modifier_plane_count` --- src/device.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/device.rs b/src/device.rs index ca39918..9399ed9 100644 --- a/src/device.rs +++ b/src/device.rs @@ -103,6 +103,23 @@ impl Device { 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 { + 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( &self,