mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 20:51:29 +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.
|
//! Requires the [cargo-apk] tool.
|
||||||
//! [cargo-apk]: https://crates.io/crates/cargo-apk
|
//! [cargo-apk]: https://crates.io/crates/cargo-apk
|
||||||
|
|
||||||
use raw_window_handle::android::AndroidHandle;
|
use raw_window_handle::{
|
||||||
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
|
AndroidDisplayHandle, AndroidNdkWindowHandle, RawDisplayHandle, RawWindowHandle,
|
||||||
|
};
|
||||||
|
|
||||||
use ndk::native_window::NativeWindow;
|
|
||||||
use ndk_glue::Event;
|
use ndk_glue::Event;
|
||||||
|
|
||||||
use piet_gpu_hal::{
|
use piet_gpu_hal::{
|
||||||
CmdBuf, Error, ImageLayout, Instance, InstanceFlags, QueryPool, Semaphore, Session,
|
Error, ImageLayout, Instance, InstanceFlags, Semaphore, Session, Surface, Swapchain,
|
||||||
SubmittedCmdBuf, Surface, Swapchain,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use piet::kurbo::Point;
|
use piet::kurbo::Point;
|
||||||
|
@ -27,10 +26,6 @@ fn main() {
|
||||||
my_main().unwrap();
|
my_main().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MyHandle {
|
|
||||||
handle: AndroidHandle,
|
|
||||||
}
|
|
||||||
|
|
||||||
// State required to render and present the contents
|
// State required to render and present the contents
|
||||||
struct GfxState {
|
struct GfxState {
|
||||||
session: Session,
|
session: Session,
|
||||||
|
@ -53,9 +48,13 @@ fn my_main() -> Result<(), Error> {
|
||||||
if let Some(window) = &*window {
|
if let Some(window) = &*window {
|
||||||
let width = window.width() as usize;
|
let width = window.width() as usize;
|
||||||
let height = window.height() as usize;
|
let height = window.height() as usize;
|
||||||
let handle = get_handle(window);
|
|
||||||
let instance = Instance::new(InstanceFlags::default())?;
|
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)?);
|
gfx_state = Some(GfxState::new(&instance, Some(&surface), width, height)?);
|
||||||
} else {
|
} else {
|
||||||
println!("native window is sadly none");
|
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 {
|
impl GfxState {
|
||||||
fn new(
|
fn new(
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
|
|
Loading…
Reference in a new issue