Skip to content

Commit f9b56f5

Browse files
committed
fix(windows): global multithreaded d2d1 factory
1 parent b5bca41 commit f9b56f5

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

winio-ui-windows-common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "winio-ui-windows-common"
3-
version = "0.7.0-rc.1"
3+
version = "0.7.0-rc.2"
44
description = "Windows common methods for winio."
55
edition = { workspace = true }
66
readme = { workspace = true }
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
#[cfg(feature = "once_cell_try")]
2-
use std::cell::OnceCell;
2+
use std::sync::OnceLock;
33

44
#[cfg(not(feature = "once_cell_try"))]
5-
use once_cell::sync::OnceCell;
5+
use once_cell::sync::OnceCell as OnceLock;
66
use windows::Win32::Graphics::Direct2D::{
7-
D2D1_FACTORY_TYPE_SINGLE_THREADED, D2D1CreateFactory, ID2D1Factory2,
7+
D2D1_FACTORY_TYPE_MULTI_THREADED, D2D1CreateFactory, ID2D1Factory2,
88
};
99

10-
thread_local! {
11-
static D2D1_FACTORY: OnceCell<ID2D1Factory2> = const { OnceCell::new() };
12-
}
10+
static D2D1_FACTORY: OnceLock<ID2D1Factory2> = const { OnceLock::new() };
1311

1412
pub fn d2d1_factory() -> crate::Result<ID2D1Factory2> {
15-
D2D1_FACTORY.with(|d2d1| {
16-
d2d1.get_or_try_init(|| unsafe {
17-
D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, None)
18-
})
13+
D2D1_FACTORY
14+
.get_or_try_init(|| unsafe { D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED, None) })
1915
.cloned()
20-
})
2116
}

0 commit comments

Comments
 (0)