Skip to content

Commit

Permalink
Update raw-window-handle to 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon-F committed Dec 1, 2021
1 parent 4f63962 commit 03eecb6
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 299 deletions.
312 changes: 65 additions & 247 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions player/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ publish = false
[dependencies]
env_logger = "0.8"
log = "0.4"
raw-window-handle = "0.3"
raw-window-handle = "0.4"
ron = "0.7"
winit = { version = "0.25", optional = true }
winit = { version = "0.26", optional = true }

[dependencies.wgt]
path = "../wgpu-types"
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fxhash = "0.2"
log = "0.4"
parking_lot = "0.11"
profiling = { version = "1", default-features = false }
raw-window-handle = { version = "0.3", optional = true }
raw-window-handle = { version = "0.4", optional = true }
ron = { version = "0.7", optional = true }
serde = { version = "1.0", features = ["serde_derive"], optional = true }
smallvec = "1"
Expand Down
4 changes: 2 additions & 2 deletions wgpu-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ renderdoc = ["libloading", "renderdoc-sys"]
bitflags = "1.0"
parking_lot = "0.11"
profiling = { version = "1", default-features = false }
raw-window-handle = "0.3"
raw-window-handle = "0.4"
thiserror = "1"

# backends common
Expand Down Expand Up @@ -86,4 +86,4 @@ features = ["wgsl-in"]

[dev-dependencies]
env_logger = "0.8"
winit = "0.25"
winit = "0.26"
2 changes: 1 addition & 1 deletion wgpu-hal/src/dx12/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl crate::Instance<super::Api> for super::Instance {
has_handle: &impl raw_window_handle::HasRawWindowHandle,
) -> Result<super::Surface, crate::InstanceError> {
match has_handle.raw_window_handle() {
raw_window_handle::RawWindowHandle::Windows(handle) => Ok(super::Surface {
raw_window_handle::RawWindowHandle::Win32(handle) => Ok(super::Surface {
factory: self.factory,
wnd_handle: handle.hwnd as *mut _,
swap_chain: None,
Expand Down
19 changes: 2 additions & 17 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ type WlDisplayConnectFun =

type WlDisplayDisconnectFun = unsafe extern "system" fn(display: *const raw::c_void);

#[cfg(not(any(target_os = "android", target_os = "macos")))]
type WlEglWindowCreateFun = unsafe extern "system" fn(
surface: *const raw::c_void,
width: raw::c_int,
height: raw::c_int,
) -> *mut raw::c_void;

#[cfg(not(any(target_os = "android", target_os = "macos")))]
type WlEglWindowResizeFun = unsafe extern "system" fn(
window: *const raw::c_void,
width: raw::c_int,
Expand Down Expand Up @@ -597,12 +595,10 @@ impl crate::Instance<super::Api> for Instance {
let mut inner = self.inner.lock();

match raw_window_handle {
#[cfg(not(any(target_os = "android", target_os = "macos")))]
Rwh::Xlib(_) => {}
#[cfg(not(any(target_os = "android", target_os = "macos")))]
Rwh::Xcb(_) => {}
#[cfg(target_os = "android")]
Rwh::Android(handle) => {
Rwh::AndroidNdk(handle) => {
let format = inner
.egl
.get_config_attrib(inner.display, inner.config, egl::NATIVE_VISUAL_ID)
Expand All @@ -615,7 +611,6 @@ impl crate::Instance<super::Api> for Instance {
return Err(crate::InstanceError);
}
}
#[cfg(not(any(target_os = "android", target_os = "macos", target_os = "solaris")))]
Rwh::Wayland(handle) => {
/* Wayland displays are not sharable between surfaces so if the
* surface we receive from this handle is from a different
Expand Down Expand Up @@ -849,29 +844,19 @@ impl crate::Surface<super::Api> for Surface {
let (surface, wl_window) = match self.unconfigure_impl(device) {
Some(pair) => pair,
None => {
#[cfg_attr(any(target_os = "android", target_os = "macos"), allow(unused_mut))]
let mut wl_window = None;
#[cfg(not(any(target_os = "android", target_os = "macos")))]
let (mut temp_xlib_handle, mut temp_xcb_handle);
#[allow(trivial_casts)]
let native_window_ptr = match self.raw_window_handle {
#[cfg(not(any(target_os = "android", target_os = "macos")))]
Rwh::Xlib(handle) => {
temp_xlib_handle = handle.window;
&mut temp_xlib_handle as *mut _ as *mut std::ffi::c_void
}
#[cfg(not(any(target_os = "android", target_os = "macos")))]
Rwh::Xcb(handle) => {
temp_xcb_handle = handle.window;
&mut temp_xcb_handle as *mut _ as *mut std::ffi::c_void
}
#[cfg(target_os = "android")]
Rwh::Android(handle) => handle.a_native_window,
#[cfg(not(any(
target_os = "android",
target_os = "macos",
target_os = "solaris"
)))]
Rwh::AndroidNdk(handle) => handle.a_native_window,
Rwh::Wayland(handle) => {
let library = self.wsi_library.as_ref().expect("unsupported window");
let wl_egl_window_create: libloading::Symbol<WlEglWindowCreateFun> =
Expand Down
4 changes: 2 additions & 2 deletions wgpu-hal/src/metal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ impl crate::Instance<Api> for Instance {
) -> Result<Surface, crate::InstanceError> {
match has_handle.raw_window_handle() {
#[cfg(target_os = "ios")]
raw_window_handle::RawWindowHandle::IOS(handle) => {
raw_window_handle::RawWindowHandle::UiKit(handle) => {
let _ = &self.managed_metal_layer_delegate;
Ok(Surface::from_uiview(handle.ui_view))
}
#[cfg(target_os = "macos")]
raw_window_handle::RawWindowHandle::MacOS(handle) => Ok(Surface::from_nsview(
raw_window_handle::RawWindowHandle::AppKit(handle) => Ok(Surface::from_nsview(
handle.ns_view,
&self.managed_metal_layer_delegate,
)),
Expand Down
33 changes: 9 additions & 24 deletions wgpu-hal/src/vulkan/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,56 +547,41 @@ impl crate::Instance<super::Api> for super::Instance {
use raw_window_handle::RawWindowHandle;

match has_handle.raw_window_handle() {
#[cfg(all(
unix,
not(target_os = "android"),
not(target_os = "macos"),
not(target_os = "ios"),
not(target_os = "solaris")
))]
RawWindowHandle::Wayland(handle)
if self.extensions.contains(&khr::WaylandSurface::name()) =>
{
Ok(self.create_surface_from_wayland(handle.display, handle.surface))
}
#[cfg(all(
unix,
not(target_os = "android"),
not(target_os = "macos"),
not(target_os = "ios"),
not(target_os = "solaris")
))]
RawWindowHandle::Xlib(handle)
if self.extensions.contains(&khr::XlibSurface::name()) =>
{
Ok(self.create_surface_from_xlib(handle.display as *mut _, handle.window))
}
#[cfg(all(
unix,
not(target_os = "android"),
not(target_os = "macos"),
not(target_os = "ios")
))]
RawWindowHandle::Xcb(handle) if self.extensions.contains(&khr::XcbSurface::name()) => {
Ok(self.create_surface_from_xcb(handle.connection, handle.window))
}
#[cfg(target_os = "android")]
RawWindowHandle::Android(handle) => {
RawWindowHandle::AndroidNdk(handle) => {
Ok(self.create_surface_android(handle.a_native_window))
}
#[cfg(windows)]
RawWindowHandle::Windows(handle) => {
RawWindowHandle::Win32(handle) => {
use winapi::um::libloaderapi::GetModuleHandleW;

let hinstance = GetModuleHandleW(std::ptr::null());
Ok(self.create_surface_from_hwnd(hinstance as *mut _, handle.hwnd))
}
#[cfg(target_os = "macos")]
RawWindowHandle::MacOS(handle)
RawWindowHandle::AppKit(handle)
if self.extensions.contains(&ext::MetalSurface::name()) =>
{
Ok(self.create_surface_from_ns_view(handle.ns_view))
}
#[cfg(target_os = "ios")]
RawWindowHandle::UiKit(handle)
if self.extensions.contains(&ext::MetalSurface::name()) =>
{
Ok(self.create_surface_from_ns_view(handle.ui_view))
}
_ => Err(crate::InstanceError),
}
}
Expand Down
5 changes: 2 additions & 3 deletions wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ version = "0.11"
arrayvec = "0.7"
log = "0.4"
parking_lot = "0.11"
raw-window-handle = "0.3"
raw-window-handle = "0.4"
serde = { version = "1", features = ["derive"], optional = true }
smallvec = "1"

Expand All @@ -126,7 +126,7 @@ noise = { version = "0.7", default-features = false }
obj = "0.10"
png = "0.16"
rand = "0.7.2"
winit = "0.25"
winit = "0.26"

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
async-executor = "1.0"
Expand Down Expand Up @@ -289,4 +289,3 @@ console_log = "0.1.2"
# We need the Location feature in the framework examples
web-sys = { version = "0.3.53", features = ["Location"] }
rand = { version = "0.7", features = ["wasm-bindgen"] }
winit = { version = "0.25", features = ["web-sys"] }

0 comments on commit 03eecb6

Please sign in to comment.