mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 12:41:30 +11:00
Fix android example
Updates the android example to use latest ash plumbing.
This commit is contained in:
parent
69d16ac209
commit
b63df8e9b8
|
@ -6,15 +6,14 @@
|
|||
//! Requires the [cargo-apk] tool.
|
||||
//! [cargo-apk]: https://crates.io/crates/cargo-apk
|
||||
|
||||
use raw_window_handle::android::AndroidHandle;
|
||||
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
|
||||
use raw_window_handle::{
|
||||
AndroidDisplayHandle, AndroidNdkWindowHandle, RawDisplayHandle, RawWindowHandle,
|
||||
};
|
||||
|
||||
use ndk::native_window::NativeWindow;
|
||||
use ndk_glue::Event;
|
||||
|
||||
use piet_gpu_hal::{
|
||||
CmdBuf, Error, ImageLayout, Instance, InstanceFlags, QueryPool, Semaphore, Session,
|
||||
SubmittedCmdBuf, Surface, Swapchain,
|
||||
Error, ImageLayout, Instance, InstanceFlags, Semaphore, Session, Surface, Swapchain,
|
||||
};
|
||||
|
||||
use piet::kurbo::Point;
|
||||
|
@ -27,10 +26,6 @@ fn main() {
|
|||
my_main().unwrap();
|
||||
}
|
||||
|
||||
struct MyHandle {
|
||||
handle: AndroidHandle,
|
||||
}
|
||||
|
||||
// State required to render and present the contents
|
||||
struct GfxState {
|
||||
session: Session,
|
||||
|
@ -53,9 +48,13 @@ fn my_main() -> Result<(), Error> {
|
|||
if let Some(window) = &*window {
|
||||
let width = window.width() as usize;
|
||||
let height = window.height() as usize;
|
||||
let handle = get_handle(window);
|
||||
let instance = Instance::new(InstanceFlags::default())?;
|
||||
let surface = unsafe { instance.surface(&handle)? };
|
||||
let mut android_handle = AndroidNdkWindowHandle::empty();
|
||||
android_handle.a_native_window = window.ptr().as_ptr() as *mut _;
|
||||
let window_handle = RawWindowHandle::AndroidNdk(android_handle);
|
||||
let display_handle =
|
||||
RawDisplayHandle::Android(AndroidDisplayHandle::empty());
|
||||
let surface = unsafe { instance.surface(display_handle, window_handle)? };
|
||||
gfx_state = Some(GfxState::new(&instance, Some(&surface), width, height)?);
|
||||
} else {
|
||||
println!("native window is sadly none");
|
||||
|
@ -74,24 +73,6 @@ fn my_main() -> Result<(), Error> {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_handle(window: &NativeWindow) -> MyHandle {
|
||||
println!(
|
||||
"window = {:?}, {}x{}",
|
||||
window.ptr(),
|
||||
window.width(),
|
||||
window.height()
|
||||
);
|
||||
let mut handle = AndroidHandle::empty();
|
||||
handle.a_native_window = window.ptr().as_ptr() as *mut std::ffi::c_void;
|
||||
MyHandle { handle }
|
||||
}
|
||||
|
||||
unsafe impl HasRawWindowHandle for MyHandle {
|
||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||
RawWindowHandle::Android(self.handle)
|
||||
}
|
||||
}
|
||||
|
||||
impl GfxState {
|
||||
fn new(
|
||||
instance: &Instance,
|
||||
|
|
Loading…
Reference in a new issue