Skip to content

Commit

Permalink
Update raw-window-handle to v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kchibisov committed Jul 15, 2022
1 parent 6acbe17 commit c7ed502
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions ndk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion ndk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
17 changes: 8 additions & 9 deletions ndk/src/native_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
///
Expand Down Expand Up @@ -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)
}
}

0 comments on commit c7ed502

Please sign in to comment.