From 98efb493f92fc37b527294c81b7e03b4e4fa2f91 Mon Sep 17 00:00:00 2001 From: Jet Spark Date: Thu, 2 Dec 2021 19:39:02 +0800 Subject: [PATCH 1/2] Add new_texture_with_io_surface_plane --- src/device.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/device.rs b/src/device.rs index 4b5c19bd..e34b91e5 100644 --- a/src/device.rs +++ b/src/device.rs @@ -1931,6 +1931,20 @@ impl DeviceRef { unsafe { msg_send![self, newTextureWithDescriptor: descriptor] } } + pub fn new_texture_with_io_surface_plane( + &self, + descriptor: &TextureDescriptorRef, + io_surface: *const std::ffi::c_void, + plane: NSUInteger, + ) -> Texture { + unsafe { + msg_send![self, newTextureWithDescriptor: descriptor + iosurface: io_surface + plane: plane + ] + } + } + pub fn new_sampler(&self, descriptor: &SamplerDescriptorRef) -> SamplerState { unsafe { msg_send![self, newSamplerStateWithDescriptor: descriptor] } } From 8e29a54d1b1c074396119e09af83fa1f096aa524 Mon Sep 17 00:00:00 2001 From: Jet Spark Date: Thu, 2 Dec 2021 21:27:05 +0800 Subject: [PATCH 2/2] Use io_surface crate --- Cargo.toml | 1 + src/device.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c4558cc6..f5f8d5d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ log = "0.4" block = "0.1.6" foreign-types = "0.3.2" dispatch = { version = "0.2", optional = true } +io-surface = "0.15.1" [dependencies.objc] version = "0.2.4" diff --git a/src/device.rs b/src/device.rs index e34b91e5..c178a8ca 100644 --- a/src/device.rs +++ b/src/device.rs @@ -1934,7 +1934,7 @@ impl DeviceRef { pub fn new_texture_with_io_surface_plane( &self, descriptor: &TextureDescriptorRef, - io_surface: *const std::ffi::c_void, + io_surface: io_surface::IOSurfaceRef, plane: NSUInteger, ) -> Texture { unsafe {