From c7ed5020a75b13463f2d8bea10c2543977459d61 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Fri, 15 Jul 2022 22:14:25 +0300 Subject: [PATCH] Update raw-window-handle to v0.5.0 --- ndk/CHANGELOG.md | 1 + ndk/Cargo.toml | 2 +- ndk/src/native_window.rs | 17 ++++++++--------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ndk/CHANGELOG.md b/ndk/CHANGELOG.md index 73411ee4..f2b6772b 100644 --- a/ndk/CHANGELOG.md +++ b/ndk/CHANGELOG.md @@ -19,6 +19,7 @@ - Fixed `HardwareBuffer` leak on buffers returned from `AndroidBitmap::get_hardware_buffer()`. (#296) - **Breaking:** Update `jni` crate (used in public API) from `0.18` to `0.19`. (#300) - hardware_buffer: Made `HardwareBufferDesc` fields `pub`. (#313) +- **Breaking:** Update `raw-window-handle` to `v0.5` removing `HasRawWindowHandle` methods. # 0.6.0 (2022-01-05) diff --git a/ndk/Cargo.toml b/ndk/Cargo.toml index a91dd3aa..d55f9134 100644 --- a/ndk/Cargo.toml +++ b/ndk/Cargo.toml @@ -35,7 +35,7 @@ test = ["ffi/test", "jni", "jni-glue", "all"] bitflags = "1.2.1" jni-sys = "0.3.0" num_enum = "0.5.1" -raw-window-handle = "0.4" +raw-window-handle = "0.5" thiserror = "1.0.23" [dependencies.jni] diff --git a/ndk/src/native_window.rs b/ndk/src/native_window.rs index 37047158..502d4679 100644 --- a/ndk/src/native_window.rs +++ b/ndk/src/native_window.rs @@ -6,7 +6,7 @@ use crate::utils::status_to_io_result; pub use super::hardware_buffer_format::HardwareBufferFormat; use jni_sys::{jobject, JNIEnv}; -use raw_window_handle::{AndroidNdkHandle, HasRawWindowHandle, RawWindowHandle}; +use raw_window_handle::{AndroidNdkWindowHandle, RawWindowHandle}; use std::{convert::TryFrom, ffi::c_void, io::Result, ptr::NonNull}; // [`NativeWindow`] represents the producer end of an image queue @@ -37,14 +37,6 @@ impl Clone for NativeWindow { } } -unsafe impl HasRawWindowHandle for NativeWindow { - fn raw_window_handle(&self) -> RawWindowHandle { - let mut handle = AndroidNdkHandle::empty(); - handle.a_native_window = self.ptr.as_ptr() as *mut c_void; - RawWindowHandle::AndroidNdk(handle) - } -} - impl NativeWindow { /// Assumes ownership of `ptr` /// @@ -126,4 +118,11 @@ impl NativeWindow { pub unsafe fn to_surface(&self, env: *mut JNIEnv) -> jobject { ffi::ANativeWindow_toSurface(env, self.ptr().as_ptr()) } + + #[inline] + pub fn raw_window_handle(&self) -> RawWindowHandle { + let mut window_handle = AndroidNdkWindowHandle::empty(); + window_handle.a_native_window = self.ptr.as_ptr() as *mut c_void; + RawWindowHandle::AndroidNdk(window_handle) + } }