diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index cf26b7199c..baa51d1c6e 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -342,7 +342,6 @@ pub struct Device { } pub struct Surface { - view: Option>, render_layer: Mutex, swapchain_format: RwLock>, extent: RwLock, diff --git a/wgpu-hal/src/metal/surface.rs b/wgpu-hal/src/metal/surface.rs index e6e79812e8..864b821a07 100644 --- a/wgpu-hal/src/metal/surface.rs +++ b/wgpu-hal/src/metal/surface.rs @@ -64,9 +64,8 @@ impl HalManagedMetalLayerDelegate { } impl super::Surface { - fn new(view: Option>, layer: metal::MetalLayer) -> Self { + fn new(layer: metal::MetalLayer) -> Self { Self { - view, render_layer: Mutex::new(layer), swapchain_format: RwLock::new(None), extent: RwLock::new(wgt::Extent3d::default()), @@ -86,16 +85,14 @@ impl super::Surface { // SAFETY: The layer is an initialized instance of `CAMetalLayer`, and // we transfer the retain count to `MetalLayer` using `ManuallyDrop`. let layer = unsafe { metal::MetalLayer::from_ptr(layer.cast()) }; - let view: *mut Object = msg_send![view.as_ptr(), retain]; - let view = NonNull::new(view).expect("retain should return the same object"); - Self::new(Some(view), layer) + Self::new(layer) } pub unsafe fn from_layer(layer: &metal::MetalLayerRef) -> Self { let class = class!(CAMetalLayer); let proper_kind: BOOL = msg_send![layer, isKindOfClass: class]; assert_eq!(proper_kind, YES); - Self::new(None, layer.to_owned()) + Self::new(layer.to_owned()) } /// Get or create a new `CAMetalLayer` associated with the given `NSView` @@ -279,16 +276,6 @@ impl super::Surface { } } -impl Drop for super::Surface { - fn drop(&mut self) { - if let Some(view) = self.view { - unsafe { - let () = msg_send![view.as_ptr(), release]; - } - } - } -} - impl crate::Surface for super::Surface { type A = super::Api;