|
MapLibre Native C API
Public C ABI for the MapLibre Native wrapper.
|
Go to the source code of this file.
Typedefs | |
| typedef enum mln_render_result | mln_render_result |
Enumerations | |
| enum | mln_render_result : uint32_t { MLN_RENDER_RESULT_RENDERED = 0 , MLN_RENDER_RESULT_NO_UPDATE , MLN_RENDER_RESULT_SIZE_PENDING , MLN_RENDER_RESULT_TARGET_NOT_READY } |
Functions | |
| mln_status | mln_render_session_resize (mln_render_session session, uint32_t width, uint32_t height, double scale_factor) |
| mln_status | mln_render_session_render_update (mln_render_session session, mln_render_result *out_result, bool *out_needs_repaint) |
| mln_status | mln_render_session_projection_create (mln_render_session session, mln_map_projection *out_projection) |
| mln_status | mln_render_session_detach (mln_render_session session) |
| mln_status | mln_render_session_destroy (mln_render_session session) |
| mln_status | mln_render_session_reduce_memory_use (mln_render_session session) |
| mln_status | mln_render_session_clear_data (mln_render_session session) |
| mln_status | mln_render_session_dump_debug_logs (mln_render_session session) |
Public C API declarations for render sessions.
| typedef enum mln_render_result mln_render_result |
Outcome of a successful mln_render_session_render_update() call.
| enum mln_render_result : uint32_t |
Outcome of a successful mln_render_session_render_update() call.
| mln_status mln_render_session_clear_data | ( | mln_render_session | session | ) |
Clears renderer data for the session.
The next frame rebuilds renderer data and restores the map's feature state. Continuous maps publish a render update. Static and tile maps rebuild when the host requests a still image.
Returns:
| mln_status mln_render_session_destroy | ( | mln_render_session | session | ) |
Destroys a render session handle.
If the session is still attached, this function detaches it first.
Returns:
| mln_status mln_render_session_detach | ( | mln_render_session | session | ) |
Detaches backend-bound render resources from the map while keeping the session handle live for destruction.
After detach, resize, render, readback, acquire, and renderer maintenance operations return MLN_STATUS_INVALID_STATE.
Returns:
| mln_status mln_render_session_dump_debug_logs | ( | mln_render_session | session | ) |
Dumps renderer debug logs for the session through MapLibre Native logging.
Returns:
| mln_status mln_render_session_projection_create | ( | mln_render_session | session, |
| mln_map_projection * | out_projection ) |
Creates a standalone projection from the session's last rendered update.
Call on the session owner thread after mln_render_session_render_update() reports MLN_RENDER_RESULT_RENDERED, before rendering another frame or changing the target. Creation is also allowed while an owned texture frame is acquired. Pair the projection with that frame and its presentation extent. The snapshot describes render coordinates; GPU completion and presentation follow the render target's synchronization contract.
The session captures the full transform of the update passed to the renderer. Later live-map changes and render calls that produce no frame preserve this snapshot. Resize and target replacement invalidate it until a frame renders into the new target.
The returned helper owns a separate copy of the transform. It remains usable after later renders, target changes, detach, and destruction of the session or map. Its projection and camera operations are synchronous and serialized across threads, as for mln_map_projection_create(). Destroy it with mln_map_projection_destroy().
Returns:
| mln_status mln_render_session_reduce_memory_use | ( | mln_render_session | session | ) |
Asks the session renderer to release cached resources where possible.
Returns:
| mln_status mln_render_session_render_update | ( | mln_render_session | session, |
| mln_render_result * | out_result, | ||
| bool * | out_needs_repaint ) |
Renders the map's latest render update into the session's render target.
Drains queued render-thread work before deciding whether a frame is needed. A surface session presents the frame. A texture session writes it into the target texture. Each update renders once per target. Resize and target replacement allow the latest update to render again. For a surface expose on a continuous map, call mln_map_request_repaint() and pump the runtime; for a static map, request another still image.
*out_result reports which of these outcomes the call reached, and each one names the wake that a host waits for before it calls again:
In MLN_MAP_MODE_STATIC, pump a resize through the map before requesting the still image. The session applies its extent on the map's owner thread, and a still image requested before that lands reports MLN_RENDER_RESULT_SIZE_PENDING.
*out_needs_repaint reports the renderer's need for another frame, such as during a paint transition. It is true only when *out_result is MLN_RENDER_RESULT_RENDERED. It matches the needs_repaint field of MLN_RUNTIME_EVENT_MAP_RENDER_FRAME_FINISHED. Camera animations advance separately on the map's owner thread. Pump the runtime and gate rendering on MLN_RUNTIME_EVENT_MAP_RENDER_UPDATE_AVAILABLE to receive fresh updates for both camera animations and renderer transitions.
Returns:
| mln_status mln_render_session_resize | ( | mln_render_session | session, |
| uint32_t | width, | ||
| uint32_t | height, | ||
| double | scale_factor ) |
Resizes an attached render session.
Width and height are logical map dimensions. The scale_factor value maps them to physical backend pixels. Resizing sets the map size, so the map viewport and the render target extent stay the same value.
Surface and session-owned texture sessions resize in place. Caller-owned borrowed texture targets return MLN_STATUS_UNSUPPORTED because the texture is sized by its owner; hand a replacement over with the mln_*_borrowed_texture_set_target() function for the backend. See texture.h.
The session renderer survives a resize, carrying the tile pyramid, glyph and image atlases, and symbol placement across to the new size. A scale_factor that differs from the session's current value retires the renderer instead, because its shaders are compiled for a fixed pixel ratio, and renderer-held tile and atlas state starts empty on the next mln_render_session_render_update(). Map state such as camera, style, sources, and feature state survives either way. The session pushes map feature state into a replacement renderer on the next render update.
Passing a scale_factor that differs from the map's mln_map_options scale_factor logs a warning; see mln_map_options.
Returns: