|
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 } |
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.
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_get_feature_state | ( | mln_render_session | session, |
| const mln_feature_state_selector * | selector, | ||
| mln_buffer * | out_state ) |
Copies per-feature state from a render source in this render session.
The session renderer must already exist. selector->source_id and selector->feature_id are borrowed for the duration of the call. On success, *out_state receives an owned buffer containing a UTF-8 JSON object. Destroy it with mln_buffer_destroy(). Missing native source or feature state is reported as an empty object.
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_remove_feature_state | ( | mln_render_session | session, |
| const mln_feature_state_selector * | selector ) |
Removes per-feature state from a render source in this render session.
The session renderer must already exist. selector->source_id is required. selector->feature_id and selector->state_key are optional. Passing both removes one state key from one feature. Passing only feature_id removes all state for that feature. Passing neither removes all feature state for the source/source-layer. The accepted command requests a map repaint.
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.
A surface session presents the frame. A texture session writes it into the target texture.
*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 whether the map asked for another frame while it rendered this one, as during an ongoing camera transition. It is set only when *out_result is MLN_RENDER_RESULT_RENDERED, and reads false for every other outcome. This is the same signal that MLN_RUNTIME_EVENT_MAP_RENDER_FRAME_FINISHED carries in its needs_repaint field, delivered here without the event round trip, so a host can re-arm its frame loop before it drains events.
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, symbol placement, and feature state set through mln_render_session_set_feature_state() 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 state starts empty on the next mln_render_session_render_update(). Map state such as camera, style, and sources survives either way.
Passing a scale_factor that differs from the map's mln_map_options scale_factor logs a warning; see mln_map_options.
Returns:
| mln_status mln_render_session_set_feature_state | ( | mln_render_session | session, |
| const mln_feature_state_selector * | selector, | ||
| mln_buffer_view | state ) |
Sets per-feature state on a render source for this render session.
The session renderer must already exist; call mln_render_session_render_update() once after loading style data before using feature state. selector->source_id and selector->feature_id are borrowed for the duration of the call. state must contain one UTF-8 JSON object and is parsed before return. The accepted command requests a map repaint.
Returns: