From ed1d76aaee193a2e5cec558930a25302bda35713 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Sat, 19 Dec 2015 14:36:49 +0100 Subject: Remove now unneeded function --- src/lib.rs | 104 ------------------------------------------------------------- 1 file changed, 104 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 794dcb0..5b1aa03 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -448,110 +448,6 @@ pub struct PixelFormatRequirements { pub release_behavior: ReleaseBehavior, } -impl PixelFormatRequirements { - #[cfg(not(target_os = "macos"))] - fn choose_pixel_format(&self, iter: I) -> Result<(T, PixelFormat), CreationError> - where I: IntoIterator, T: Clone - { - if self.release_behavior != ReleaseBehavior::Flush { return Err(CreationError::NoAvailablePixelFormat); } - if self.double_buffer == Some(false) { return Err(CreationError::NoAvailablePixelFormat); } - if self.float_color_buffer { return Err(CreationError::NoAvailablePixelFormat); } - - // filtering formats that don't match the requirements - let iter = iter.into_iter().filter(|&(_, ref format)| { - if format.color_bits < self.color_bits.unwrap_or(0) { - return false; - } - - if format.alpha_bits < self.alpha_bits.unwrap_or(0) { - return false; - } - - if format.depth_bits < self.depth_bits.unwrap_or(0) { - return false; - } - - if format.stencil_bits < self.stencil_bits.unwrap_or(0) { - return false; - } - - if !format.stereoscopy && self.stereoscopy { - return false; - } - - if let Some(req_ms) = self.multisampling { - match format.multisampling { - Some(val) if val >= req_ms => (), - _ => return false - } - } else { - if format.multisampling.is_some() { - return false; - } - } - - if self.srgb && !format.srgb { - return false; - } - - true - }); - - // sorting so that the preferred format comes first - let mut formats = iter.collect::>(); - formats.sort_by(|&(_, ref left), &(_, ref right)| { - // prefer hardware-accelerated formats - if left.hardware_accelerated && !right.hardware_accelerated { - return Ordering::Less; - } else if right.hardware_accelerated && !left.hardware_accelerated { - return Ordering::Greater; - } - - // prefer sRGB formats - if left.srgb && !right.srgb { - return Ordering::Less; - } else if right.srgb && !left.srgb { - return Ordering::Greater; - } - - // prefer formats with the highest color+alpha bits - if left.color_bits + left.alpha_bits != right.color_bits + right.alpha_bits { - return (right.color_bits + right.alpha_bits) - .cmp(&(left.color_bits + left.alpha_bits)); - } - - // prefer double-buffering formats - if left.double_buffer && !right.double_buffer { - return Ordering::Less; - } else if right.double_buffer && !left.double_buffer { - return Ordering::Greater; - } - - // prefer formats with the highest depth bits - if left.depth_bits != right.depth_bits { - return (right.depth_bits).cmp(&left.depth_bits); - } - - // prefer formats with the highest stencil bits - if left.stencil_bits != right.stencil_bits { - return (right.stencil_bits).cmp(&left.stencil_bits); - } - - // prefer formats with multisampling - if left.multisampling.is_some() && right.multisampling.is_none() { - return Ordering::Less; - } else if right.multisampling.is_some() && left.multisampling.is_none() { - return Ordering::Greater; - } - - // default - return Ordering::Equal; - }); - - formats.into_iter().next().ok_or(CreationError::NoAvailablePixelFormat) - } -} - impl Default for PixelFormatRequirements { #[inline] fn default() -> PixelFormatRequirements { -- cgit v1.2.3