|
MapLibre Native C API
Public C ABI for the MapLibre Native wrapper.
|
Go to the source code of this file.
Data Structures | |
| struct | mln_android_surface_descriptor |
| struct | mln_android_surface_replacement |
| struct | mln_android_hardware_buffer_ring_descriptor |
| struct | mln_android_hardware_buffer_frame |
Typedefs | |
| typedef struct mln_android_surface_descriptor | mln_android_surface_descriptor |
| typedef struct mln_android_surface_replacement | mln_android_surface_replacement |
| typedef struct mln_android_hardware_buffer_ring_descriptor | mln_android_hardware_buffer_ring_descriptor |
| typedef struct mln_android_hardware_buffer_frame | mln_android_hardware_buffer_frame |
Set up the library in an Android app, present to its windows, render into hardware buffers, and pace its frames to the display.
| typedef struct mln_android_hardware_buffer_frame mln_android_hardware_buffer_frame |
The Android hardware buffer of an acquired frame.
| typedef struct mln_android_hardware_buffer_ring_descriptor mln_android_hardware_buffer_ring_descriptor |
A ring of Android hardware buffers that the library allocates, for mln_map_attach_android_hardware_buffer_ring().
Each buffer has the map's size in pixels, logical_size times the map's scale factor, and the format AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM. Its usage is AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT, AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE, and the bits of usage.
| typedef struct mln_android_surface_descriptor mln_android_surface_descriptor |
An Android window to present to, for mln_map_attach_android_surface().
Name the window by window, or by jni_env and surface. The session takes its own reference to the window, so you can release yours once the call returns.
| typedef struct mln_android_surface_replacement mln_android_surface_replacement |
A new Android window for mln_render_session_set_android_surface_target().
Name the window by window, or by jni_env and surface. The session takes its own reference to the window, so you can release yours once the call returns.
| mln_status mln_acquired_frame_get_android_hardware_buffer | ( | mln_acquired_frame | frame, |
| mln_android_hardware_buffer_frame * | out_frame, | ||
| mln_diagnostic * | out_diagnostic ) |
Gets the Android hardware buffer of an acquired frame.
Wait for mln_acquired_frame_get_producer_sync() before you read the buffer. Once you release or discard the frame, the session may render into the buffer again. A reference that you take with AHardwareBuffer_acquire keeps the buffer's memory, but not its contents.
Returns:
Lifetimes: The buffer in out_frame stays valid until you release or discard the frame, or the session is abandoned or disposed. A view from mln_acquired_frame_view_begin() keeps it valid until mln_acquired_frame_view_end().
| mln_status mln_android_frame_pacer_create | ( | const mln_frame_pacer_options * | options, |
| mln_frame_pacer * | out_pacer, | ||
| mln_diagnostic * | out_diagnostic ) |
Creates a frame pacer that follows the display through the calling thread's AChoreographer.
Call it on a thread with an ALooper, such as the app's main thread, and keep that thread running its looper while sessions use the pacer.
Returns:
| mln_status mln_android_init | ( | void * | jni_env, |
| void * | context, | ||
| mln_diagnostic * | out_diagnostic ) |
Gives the library the Java VM and the app context that it needs on Android.
Call it before creating a runtime. jni_env is the calling thread's JNIEnv*, and context is an Android Context, such as the application.
| mln_status mln_map_attach_android_hardware_buffer_ring | ( | mln_map | map, |
| const mln_android_hardware_buffer_ring_descriptor * | descriptor, | ||
| mln_vulkan_device | device, | ||
| const mln_render_session_attach_options * | options, | ||
| mln_render_session * | out_session, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Creates a session that renders the map into a ring of Android hardware buffers that the library allocates.
Acquire each frame with mln_render_session_acquire_frame(), and get its buffer with mln_acquired_frame_get_android_hardware_buffer(). mln_render_session_resize() gives the ring new buffers of the new size.
A Vulkan build renders 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 MLN_RENDER_DRIVER_CORE_WORKER.
To show the buffers through Android's UI, such as with Bitmap.wrapHardwareBuffer, attach without MLN_GPU_SYNC_KIND_FLAG_SYNC_FD in mln_render_session_attach_options.producer_sync_kinds, so that each frame finishes before you acquire it. Keep each frame acquired until the next one replaces it on screen, then release it with MLN_GPU_SYNC_CPU_COMPLETE. Give the ring 3 buffers, so the session can render while you hold two frames.
Returns:
| mln_status mln_map_attach_android_surface | ( | mln_map | map, |
| const mln_android_surface_descriptor * | descriptor, | ||
| mln_vulkan_device | device, | ||
| const mln_render_session_attach_options * | options, | ||
| mln_render_session * | out_session, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
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 MLN_RENDER_DRIVER_CORE_WORKER.
When the platform destroys the window, such as in SurfaceHolder.Callback.surfaceDestroyed, release the target with mln_render_session_release_target(), or give the session a new window with mln_render_session_set_android_surface_target(), 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 MLN_RENDER_RESULT_TARGET_NOT_READY, or with MLN_RENDER_RESULT_RENDERED if the window went away while the frame was presenting.
Returns:
Completes with:
| mln_status mln_render_session_set_android_surface_target | ( | mln_render_session | session, |
| const mln_android_surface_replacement * | replacement, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Replaces the Android window that the session presents to.
Use it to give the session a window again after mln_render_session_release_target(), to move it to another window, or to resize it. Once the replacement completes, the session no longer uses the old window.
Returns:
Completes with: