MapLibre Native C API
Public C ABI for the MapLibre Native wrapper.
Loading...
Searching...
No Matches
runtime.h
Go to the documentation of this file.
1
5
6#ifndef MAPLIBRE_NATIVE_C_RUNTIME_H
7#define MAPLIBRE_NATIVE_C_RUNTIME_H
8
9#ifndef __cplusplus
10#include <stdbool.h>
11#endif
12
13#include <stddef.h>
14#include <stdint.h>
15
16#include "base.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22typedef enum mln_network_status : uint32_t {
23 MLN_NETWORK_STATUS_ONLINE = 1,
24 MLN_NETWORK_STATUS_OFFLINE = 2,
25} mln_network_status;
26
27typedef enum mln_runtime_option_flag : uint32_t {
28 MLN_RUNTIME_OPTION_MAXIMUM_CACHE_SIZE = 1U << 0U,
29} mln_runtime_option_flag;
30
31typedef enum mln_ambient_cache_operation : uint32_t {
32 MLN_AMBIENT_CACHE_OPERATION_RESET_DATABASE = 1,
33 MLN_AMBIENT_CACHE_OPERATION_PACK_DATABASE = 2,
34 MLN_AMBIENT_CACHE_OPERATION_INVALIDATE = 3,
35 MLN_AMBIENT_CACHE_OPERATION_CLEAR = 4,
36} mln_ambient_cache_operation;
37
38typedef int64_t mln_offline_region_id;
39
40typedef enum mln_offline_region_definition_type : uint32_t {
41 MLN_OFFLINE_REGION_DEFINITION_TILE_PYRAMID = 1,
42 MLN_OFFLINE_REGION_DEFINITION_GEOMETRY = 2,
43} mln_offline_region_definition_type;
44
45typedef enum mln_offline_region_download_state : uint32_t {
46 MLN_OFFLINE_REGION_DOWNLOAD_INACTIVE = 0,
47 MLN_OFFLINE_REGION_DOWNLOAD_ACTIVE = 1,
48} mln_offline_region_download_state;
49
51typedef uint64_t mln_offline_operation_id;
52
54typedef enum mln_offline_operation_kind : uint32_t {
55 MLN_OFFLINE_OPERATION_AMBIENT_CACHE = 1,
56 MLN_OFFLINE_OPERATION_REGION_CREATE = 2,
57 MLN_OFFLINE_OPERATION_REGION_GET = 3,
58 MLN_OFFLINE_OPERATION_REGIONS_LIST = 4,
59 MLN_OFFLINE_OPERATION_REGIONS_MERGE_DATABASE = 5,
60 MLN_OFFLINE_OPERATION_REGION_UPDATE_METADATA = 6,
61 MLN_OFFLINE_OPERATION_REGION_GET_STATUS = 7,
62 MLN_OFFLINE_OPERATION_REGION_SET_OBSERVED = 8,
63 MLN_OFFLINE_OPERATION_REGION_SET_DOWNLOAD_STATE = 9,
64 MLN_OFFLINE_OPERATION_REGION_INVALIDATE = 10,
65 MLN_OFFLINE_OPERATION_REGION_DELETE = 11,
67
69typedef enum mln_offline_operation_result_kind : uint32_t {
70 MLN_OFFLINE_OPERATION_RESULT_NONE = 0,
71 MLN_OFFLINE_OPERATION_RESULT_REGION = 1,
72 MLN_OFFLINE_OPERATION_RESULT_OPTIONAL_REGION = 2,
73 MLN_OFFLINE_OPERATION_RESULT_REGION_LIST = 3,
74 MLN_OFFLINE_OPERATION_RESULT_REGION_STATUS = 4,
76
79 uint32_t size;
82 uint64_t completed_resource_count;
83 uint64_t completed_resource_size;
84 uint64_t completed_tile_count;
85 uint64_t required_tile_count;
86 uint64_t completed_tile_size;
87 uint64_t required_resource_count;
88 bool required_resource_count_is_precise;
89 bool complete;
91
93typedef enum mln_runtime_event_type : uint32_t {
94 MLN_RUNTIME_EVENT_MAP_CAMERA_WILL_CHANGE = 1,
95 MLN_RUNTIME_EVENT_MAP_CAMERA_IS_CHANGING = 2,
96 MLN_RUNTIME_EVENT_MAP_CAMERA_DID_CHANGE = 3,
97 MLN_RUNTIME_EVENT_MAP_STYLE_LOADED = 4,
98 MLN_RUNTIME_EVENT_MAP_LOADING_STARTED = 5,
99 MLN_RUNTIME_EVENT_MAP_LOADING_FINISHED = 6,
100 MLN_RUNTIME_EVENT_MAP_LOADING_FAILED = 7,
101 MLN_RUNTIME_EVENT_MAP_IDLE = 8,
102 MLN_RUNTIME_EVENT_MAP_RENDER_UPDATE_AVAILABLE = 9,
103 MLN_RUNTIME_EVENT_MAP_RENDER_ERROR = 10,
104 MLN_RUNTIME_EVENT_MAP_STILL_IMAGE_FINISHED = 11,
105 MLN_RUNTIME_EVENT_MAP_STILL_IMAGE_FAILED = 12,
106 MLN_RUNTIME_EVENT_MAP_RENDER_FRAME_STARTED = 13,
107 MLN_RUNTIME_EVENT_MAP_RENDER_FRAME_FINISHED = 14,
108 MLN_RUNTIME_EVENT_MAP_RENDER_MAP_STARTED = 15,
109 MLN_RUNTIME_EVENT_MAP_RENDER_MAP_FINISHED = 16,
110 MLN_RUNTIME_EVENT_MAP_STYLE_IMAGE_MISSING = 17,
111 MLN_RUNTIME_EVENT_MAP_TILE_ACTION = 18,
112 MLN_RUNTIME_EVENT_OFFLINE_REGION_STATUS_CHANGED = 19,
113 MLN_RUNTIME_EVENT_OFFLINE_REGION_RESPONSE_ERROR = 20,
114 MLN_RUNTIME_EVENT_OFFLINE_REGION_TILE_COUNT_LIMIT_EXCEEDED = 21,
115 MLN_RUNTIME_EVENT_OFFLINE_OPERATION_COMPLETED = 22,
117
119typedef enum mln_runtime_event_source_type : uint32_t {
120 MLN_RUNTIME_EVENT_SOURCE_RUNTIME = 0,
121 MLN_RUNTIME_EVENT_SOURCE_MAP = 1,
123
125typedef enum mln_runtime_event_payload_type : uint32_t {
126 MLN_RUNTIME_EVENT_PAYLOAD_NONE = 0,
127 MLN_RUNTIME_EVENT_PAYLOAD_RENDER_FRAME = 1,
128 MLN_RUNTIME_EVENT_PAYLOAD_RENDER_MAP = 2,
129 MLN_RUNTIME_EVENT_PAYLOAD_STYLE_IMAGE_MISSING = 3,
130 MLN_RUNTIME_EVENT_PAYLOAD_TILE_ACTION = 4,
131 MLN_RUNTIME_EVENT_PAYLOAD_OFFLINE_REGION_STATUS = 5,
132 MLN_RUNTIME_EVENT_PAYLOAD_OFFLINE_REGION_RESPONSE_ERROR = 6,
133 MLN_RUNTIME_EVENT_PAYLOAD_OFFLINE_REGION_TILE_COUNT_LIMIT = 7,
134 MLN_RUNTIME_EVENT_PAYLOAD_OFFLINE_OPERATION_COMPLETED = 8,
136
138typedef enum mln_render_mode : uint32_t {
139 MLN_RENDER_MODE_PARTIAL = 0,
140 MLN_RENDER_MODE_FULL = 1,
142
144typedef enum mln_tile_operation : uint32_t {
145 MLN_TILE_OPERATION_REQUESTED_FROM_CACHE = 0,
146 MLN_TILE_OPERATION_REQUESTED_FROM_NETWORK = 1,
147 MLN_TILE_OPERATION_LOAD_FROM_NETWORK = 2,
148 MLN_TILE_OPERATION_LOAD_FROM_CACHE = 3,
149 MLN_TILE_OPERATION_START_PARSE = 4,
150 MLN_TILE_OPERATION_END_PARSE = 5,
151 MLN_TILE_OPERATION_ERROR = 6,
152 MLN_TILE_OPERATION_CANCELLED = 7,
153 MLN_TILE_OPERATION_NULL = 8,
155
156typedef enum mln_resource_kind : uint32_t {
157 MLN_RESOURCE_KIND_UNKNOWN = 0,
158 MLN_RESOURCE_KIND_STYLE = 1,
159 MLN_RESOURCE_KIND_SOURCE = 2,
160 MLN_RESOURCE_KIND_TILE = 3,
161 MLN_RESOURCE_KIND_GLYPHS = 4,
162 MLN_RESOURCE_KIND_SPRITE_IMAGE = 5,
163 MLN_RESOURCE_KIND_SPRITE_JSON = 6,
164 MLN_RESOURCE_KIND_IMAGE = 7,
165} mln_resource_kind;
166
167typedef enum mln_resource_loading_method : uint32_t {
168 MLN_RESOURCE_LOADING_METHOD_ALL = 0,
169 MLN_RESOURCE_LOADING_METHOD_CACHE_ONLY = 1,
170 MLN_RESOURCE_LOADING_METHOD_NETWORK_ONLY = 2,
171} mln_resource_loading_method;
172
173typedef enum mln_resource_priority : uint32_t {
174 MLN_RESOURCE_PRIORITY_REGULAR = 0,
175 MLN_RESOURCE_PRIORITY_LOW = 1,
176} mln_resource_priority;
177
178typedef enum mln_resource_usage : uint32_t {
179 MLN_RESOURCE_USAGE_ONLINE = 0,
180 MLN_RESOURCE_USAGE_OFFLINE = 1,
181} mln_resource_usage;
182
183typedef enum mln_resource_storage_policy : uint32_t {
184 MLN_RESOURCE_STORAGE_POLICY_PERMANENT = 0,
185 MLN_RESOURCE_STORAGE_POLICY_VOLATILE = 1,
186} mln_resource_storage_policy;
187
188typedef enum mln_resource_response_status : uint32_t {
189 MLN_RESOURCE_RESPONSE_STATUS_OK = 0,
190 MLN_RESOURCE_RESPONSE_STATUS_ERROR = 1,
191 MLN_RESOURCE_RESPONSE_STATUS_NO_CONTENT = 2,
192 MLN_RESOURCE_RESPONSE_STATUS_NOT_MODIFIED = 3,
193} mln_resource_response_status;
194
195typedef enum mln_resource_error_reason : uint32_t {
196 MLN_RESOURCE_ERROR_REASON_NONE = 0,
197 MLN_RESOURCE_ERROR_REASON_NOT_FOUND = 1,
198 MLN_RESOURCE_ERROR_REASON_SERVER = 2,
199 MLN_RESOURCE_ERROR_REASON_CONNECTION = 3,
200 MLN_RESOURCE_ERROR_REASON_RATE_LIMIT = 4,
201 MLN_RESOURCE_ERROR_REASON_OTHER = 5,
202} mln_resource_error_reason;
203
204typedef enum mln_resource_provider_decision : uint32_t {
205 MLN_RESOURCE_PROVIDER_DECISION_PASS_THROUGH = 0,
206 MLN_RESOURCE_PROVIDER_DECISION_HANDLE = 1,
207} mln_resource_provider_decision;
208
219MLN_API mln_status mln_network_status_get(uint32_t* out_status) MLN_NOEXCEPT;
220
234MLN_API mln_status mln_network_status_set(uint32_t status) MLN_NOEXCEPT;
235
236typedef struct mln_runtime_options {
237 uint32_t size;
238 uint32_t flags;
240 const char* asset_path;
242 const char* cache_path;
244 uint64_t maximum_cache_size;
245} mln_runtime_options;
246
248typedef struct mln_rendering_stats {
249 uint32_t size;
255 int64_t frame_count;
261
273
276 uint32_t size;
278 uint32_t mode;
280
292
294typedef struct mln_tile_id {
295 uint32_t overscaled_z;
296 int32_t wrap;
297 uint32_t canonical_z;
298 uint32_t canonical_x;
299 uint32_t canonical_y;
301
304 uint32_t size;
306 uint32_t operation;
307 mln_tile_id tile_id;
312 const char* source_id;
316
319 uint32_t size;
320 mln_offline_region_id region_id;
323
326 uint32_t size;
327 mln_offline_region_id region_id;
329 uint32_t reason;
331
334 uint32_t size;
335 mln_offline_region_id region_id;
336 uint64_t limit;
338
352
354typedef struct mln_runtime_event {
355 uint32_t size;
356 uint32_t type;
358 uint32_t source_type;
364 void* source;
365 int32_t code;
367 uint32_t payload_type;
369 const void* payload;
373 const char* message;
377
378typedef struct mln_resource_transform_response {
379 uint32_t size;
382 const char* url;
385 void* context;
386} mln_resource_transform_response;
387
402 mln_resource_transform_response* response, const char* url, size_t url_size
403) MLN_NOEXCEPT;
404
428 void* user_data, uint32_t kind, const char* url,
429 mln_resource_transform_response* out_response
430);
431
432typedef struct mln_resource_transform {
433 uint32_t size;
435 void* user_data;
436} mln_resource_transform;
437
438typedef struct mln_resource_request {
439 uint32_t size;
440 const char* url;
441 uint32_t kind;
442 uint32_t loading_method;
443 uint32_t priority;
444 uint32_t usage;
445 uint32_t storage_policy;
446 bool has_range;
447 uint64_t range_start;
448 uint64_t range_end;
449 bool has_prior_modified;
450 int64_t prior_modified_unix_ms;
451 bool has_prior_expires;
452 int64_t prior_expires_unix_ms;
453 const char* prior_etag;
454 const uint8_t* prior_data;
455 size_t prior_data_size;
456} mln_resource_request;
457
458typedef struct mln_resource_response {
459 uint32_t size;
460 uint32_t status;
461 uint32_t error_reason;
463 const uint8_t* bytes;
464 size_t byte_count;
465 const char* error_message;
466 bool must_revalidate;
467 bool has_modified;
468 int64_t modified_unix_ms;
469 bool has_expires;
470 int64_t expires_unix_ms;
471 const char* etag;
472 bool has_retry_after;
473 int64_t retry_after_unix_ms;
474} mln_resource_response;
475
504 void* user_data, const mln_resource_request* request,
505 mln_resource_request_handle* handle
506);
507
508typedef struct mln_resource_provider {
509 uint32_t size;
511 void* user_data;
512} mln_resource_provider;
513
517MLN_API mln_runtime_options mln_runtime_options_default(void) MLN_NOEXCEPT;
518
534 const mln_runtime_options* options, mln_runtime** out_runtime
535) MLN_NOEXCEPT;
536
557 mln_runtime* runtime, const mln_resource_provider* provider
558) MLN_NOEXCEPT;
559
579 mln_resource_request_handle* handle, const mln_resource_response* response
580) MLN_NOEXCEPT;
581
594 const mln_resource_request_handle* handle, bool* out_cancelled
595) MLN_NOEXCEPT;
596
606 mln_resource_request_handle* handle
607) MLN_NOEXCEPT;
608
629 mln_runtime* runtime, const mln_resource_transform* transform
630) MLN_NOEXCEPT;
631
645MLN_API mln_status
646mln_runtime_clear_resource_transform(mln_runtime* runtime) MLN_NOEXCEPT;
647
665 mln_runtime* runtime, uint32_t operation,
666 mln_offline_operation_id* out_operation_id
667) MLN_NOEXCEPT;
668
685 mln_runtime* runtime, mln_offline_operation_id operation_id
686) MLN_NOEXCEPT;
687
702MLN_API mln_status mln_runtime_destroy(mln_runtime* runtime) MLN_NOEXCEPT;
703
717MLN_API mln_status mln_runtime_run_once(mln_runtime* runtime) MLN_NOEXCEPT;
718
748 mln_runtime* runtime, mln_runtime_event* out_event, bool* out_has_event
749) MLN_NOEXCEPT;
750
751#ifdef __cplusplus
752}
753#endif
754
755#endif // MAPLIBRE_NATIVE_C_RUNTIME_H
mln_status
Definition base.h:37
mln_status mln_runtime_offline_operation_discard(mln_runtime *runtime, mln_offline_operation_id operation_id)
mln_tile_operation
Definition runtime.h:144
mln_status mln_network_status_get(uint32_t *out_status)
mln_runtime_event_payload_type
Definition runtime.h:125
mln_status mln_runtime_clear_resource_transform(mln_runtime *runtime)
mln_status mln_runtime_create(const mln_runtime_options *options, mln_runtime **out_runtime)
mln_status mln_runtime_set_resource_provider(mln_runtime *runtime, const mln_resource_provider *provider)
mln_runtime_event_type
Definition runtime.h:93
mln_status mln_resource_request_complete(mln_resource_request_handle *handle, const mln_resource_response *response)
uint32_t(* mln_resource_provider_callback)(void *user_data, const mln_resource_request *request, mln_resource_request_handle *handle)
Definition runtime.h:503
mln_status mln_runtime_poll_event(mln_runtime *runtime, mln_runtime_event *out_event, bool *out_has_event)
mln_status mln_runtime_run_ambient_cache_operation_start(mln_runtime *runtime, uint32_t operation, mln_offline_operation_id *out_operation_id)
mln_offline_operation_result_kind
Definition runtime.h:69
mln_runtime_event_source_type
Definition runtime.h:119
mln_status mln_resource_request_cancelled(const mln_resource_request_handle *handle, bool *out_cancelled)
mln_status mln_runtime_run_once(mln_runtime *runtime)
mln_status mln_resource_transform_response_set_url(mln_resource_transform_response *response, const char *url, size_t url_size)
mln_runtime_options mln_runtime_options_default(void)
mln_status mln_runtime_set_resource_transform(mln_runtime *runtime, const mln_resource_transform *transform)
mln_status(* mln_resource_transform_callback)(void *user_data, uint32_t kind, const char *url, mln_resource_transform_response *out_response)
Definition runtime.h:427
void mln_resource_request_release(mln_resource_request_handle *handle)
uint64_t mln_offline_operation_id
Definition runtime.h:51
mln_offline_operation_kind
Definition runtime.h:54
mln_status mln_network_status_set(uint32_t status)
mln_status mln_runtime_destroy(mln_runtime *runtime)
mln_render_mode
Definition runtime.h:138
Definition runtime.h:78
uint32_t download_state
Definition runtime.h:81
Definition runtime.h:248
int64_t draw_call_count
Definition runtime.h:257
double encoding_time
Definition runtime.h:251
int64_t total_draw_call_count
Definition runtime.h:259
double rendering_time
Definition runtime.h:253
int64_t frame_count
Definition runtime.h:255
uint32_t result_kind
Definition runtime.h:346
uint32_t operation_kind
Definition runtime.h:344
int32_t result_status
Definition runtime.h:348
uint32_t reason
Definition runtime.h:329
Definition runtime.h:263
bool needs_repaint
Definition runtime.h:268
uint32_t mode
Definition runtime.h:266
bool placement_changed
Definition runtime.h:270
Definition runtime.h:275
uint32_t mode
Definition runtime.h:278
size_t image_id_size
Definition runtime.h:290
const char * image_id
Definition runtime.h:288
Definition runtime.h:303
size_t source_id_size
Definition runtime.h:314
const char * source_id
Definition runtime.h:312
uint32_t operation
Definition runtime.h:306
Definition runtime.h:354
uint32_t payload_type
Definition runtime.h:367
const void * payload
Definition runtime.h:369
void * source
Definition runtime.h:364
size_t message_size
Definition runtime.h:375
uint32_t source_type
Definition runtime.h:358
const char * message
Definition runtime.h:373
size_t payload_size
Definition runtime.h:371
Definition runtime.h:294