mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 06:41:31 +11:00
Allow using non-hardware-accelerated pixel formats
This commit is contained in:
parent
7ba8fdf3f3
commit
42d38e66ab
15
src/lib.rs
15
src/lib.rs
|
@ -195,7 +195,7 @@ pub enum MouseCursor {
|
|||
|
||||
/// Describes a possible format. Unused.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PixelFormat {
|
||||
pub hardware_accelerated: bool,
|
||||
pub red_bits: u8,
|
||||
|
@ -284,13 +284,10 @@ impl<'a> BuilderAttribs<'a> {
|
|||
where I: Iterator<Item=(T, PixelFormat)>, T: Clone
|
||||
{
|
||||
let mut current_result = None;
|
||||
let mut current_software_result = None;
|
||||
|
||||
// TODO: do this more properly
|
||||
for (id, format) in iter {
|
||||
if !format.hardware_accelerated {
|
||||
continue;
|
||||
}
|
||||
|
||||
if format.red_bits + format.green_bits + format.blue_bits < self.color_bits.unwrap_or(0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -315,9 +312,13 @@ impl<'a> BuilderAttribs<'a> {
|
|||
continue;
|
||||
}
|
||||
|
||||
current_result = Some((id, format));
|
||||
current_software_result = Some((id.clone(), format.clone()));
|
||||
if format.hardware_accelerated {
|
||||
current_result = Some((id, format));
|
||||
}
|
||||
}
|
||||
|
||||
current_result.expect("Could not find compliant pixel format")
|
||||
current_result.or(current_software_result)
|
||||
.expect("Could not find compliant pixel format")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue