pub unsafe fn create_android_surface(
instance: &Instance,
window_ptr: *mut c_void,
) -> Result<Surface<'static>>Expand description
Builds a wgpu::Surface from a raw ANativeWindow pointer.
This is one of the framework’s sanctioned unsafe boundaries: turning a
caller-owned raw pointer into a GPU surface. It is deliberately isolated in
one function so the safety contract lives in exactly one place. See also
[create_metal_surface] (the iOS/macOS counterpart) and
frust-shell-android’s jni_glue module.
§Safety
window_ptr must be a valid, non-null ANativeWindow* that the caller has
acquired (e.g. via ndk::NativeWindow / ANativeWindow_acquire, which
the Android shell owns) and that outlives the returned wgpu::Surface
and every SurfaceTexture acquired from it. The caller must drop the
surface (and any outstanding textures) before releasing the window, i.e.
before returning from the surfaceDestroyed callback.
Compiled unconditionally (the raw-handle types are host-available) so a host
cargo check --target aarch64-linux-android exercises it.