attachAndroidSurface method
- AndroidSurfaceDescriptor descriptor,
- RenderSessionAttachOptions options, {
- VulkanDeviceHandle? device,
Creates a session that presents the map to an Android window, with a graphics context that the library creates.
A Vulkan build presents with device, or, when device is null, with a
device that the library creates. An OpenGL build uses an EGL context on
the default display, and device must be null. Attach with
RenderDriverKind.coreWorker.
When the platform destroys the window, such as in
SurfaceHolder.Callback.surfaceDestroyed, release the target with
RenderSessionHandle.releaseTarget(), or give the session a new window
with RenderSessionHandle.setAndroidSurfaceTarget(), without waiting for
that to complete. The session keeps its own reference to the window and
stays usable for the next window. A frame to the destroyed window finishes
with RenderResult.targetNotReady, or with RenderResult.rendered if the
window went away while the frame was presenting.
See mln_map_attach_android_surface in the
C API reference.
Errors:
Status.invalidArgumentwhensurfacehas no window, such as after the platform destroyed it.Status.unsupportedwhen you createddevicewithoutVulkanDeviceOptions.presentation.Status.unsupportedwhen the GPU or the Vulkan loader can't present.Status.nativeErrorwhen the library can't create the graphics context or the window's surface.
Implementation
RenderSessionHandle attachAndroidSurface(
AndroidSurfaceDescriptor descriptor,
RenderSessionAttachOptions options, {
VulkanDeviceHandle? device,
}) {
final registrations = _NativeRegistrations(_CallbackRoots());
return _attach(
(arena, completion, outSession) => registrations.run(
() => raw.mln_map_attach_android_surface(
_handle.raw,
_writeAndroidSurfaceDescriptor(descriptor, arena),
(device?._handle.raw ?? 0),
_writeRenderSessionAttachOptions(options, arena, registrations),
outSession,
completion,
nativeDiagnostic,
),
),
(handle, ready) => _adoptOwned(
handle,
() =>
(RenderSessionHandle._(this, _NativeRenderSession(handle), ready)
.._state.retain(registrations)),
(handle) {
_check(raw.mln_render_session_dispose(handle, nativeDiagnostic));
},
),
);
}