1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use crate::adapter::adapter1::Adapter1;
use com_wrapper::ComWrapper;
use winapi::shared::dxgi::IDXGIFactory1;
use winapi::shared::winerror::{DXGI_ERROR_NOT_FOUND, S_OK};
use wio::com::ComPtr;
pub use self::iter::AdapterIter1;
mod iter;
#[derive(Clone, PartialEq, ComWrapper)]
#[com(send, sync, debug)]
#[repr(transparent)]
pub struct Factory1 {
ptr: ComPtr<IDXGIFactory1>,
}
impl Factory1 {
pub fn is_current(&self) -> bool {
unsafe { self.ptr.IsCurrent() != 0 }
}
pub fn adapters(&self) -> AdapterIter1 {
AdapterIter1 {
factory: self,
adapter: 0,
}
}
pub fn enum_adapter(&self, n: u32) -> Option<Adapter1> {
unsafe {
let mut ptr = std::ptr::null_mut();
let hr = self.ptr.EnumAdapters1(n, &mut ptr);
match hr {
S_OK => Some(Adapter1::from_raw(ptr)),
DXGI_ERROR_NOT_FOUND => None,
result => unreachable!("{} should not be returned from EnumAdapters1", result),
}
}
}
}
impl super::FactoryType for Factory1 {}
impl std::ops::Deref for Factory1 {
type Target = super::Factory;
fn deref(&self) -> &Self::Target {
unsafe { crate::helpers::deref_com_wrapper(self) }
}
}
impl std::ops::DerefMut for Factory1 {
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { crate::helpers::deref_com_wrapper_mut(self) }
}
}