6#ifndef MAPLIBRE_NATIVE_C_RUNTIME_H
7#define MAPLIBRE_NATIVE_C_RUNTIME_H
22typedef enum mln_network_status : uint32_t {
23 MLN_NETWORK_STATUS_ONLINE = 1,
24 MLN_NETWORK_STATUS_OFFLINE = 2,
27typedef enum mln_runtime_option_flag : uint32_t {
28 MLN_RUNTIME_OPTION_MAXIMUM_CACHE_SIZE = 1U << 0U,
29} mln_runtime_option_flag;
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;
38typedef int64_t mln_offline_region_id;
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;
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;
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,
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,
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;
134 MLN_RUNTIME_EVENT_MAP_CAMERA_WILL_CHANGE = 1,
135 MLN_RUNTIME_EVENT_MAP_CAMERA_IS_CHANGING = 2,
136 MLN_RUNTIME_EVENT_MAP_CAMERA_DID_CHANGE = 3,
137 MLN_RUNTIME_EVENT_MAP_STYLE_LOADED = 4,
138 MLN_RUNTIME_EVENT_MAP_LOADING_STARTED = 5,
139 MLN_RUNTIME_EVENT_MAP_LOADING_FINISHED = 6,
140 MLN_RUNTIME_EVENT_MAP_LOADING_FAILED = 7,
141 MLN_RUNTIME_EVENT_MAP_IDLE = 8,
142 MLN_RUNTIME_EVENT_MAP_RENDER_UPDATE_AVAILABLE = 9,
143 MLN_RUNTIME_EVENT_MAP_RENDER_ERROR = 10,
144 MLN_RUNTIME_EVENT_MAP_STILL_IMAGE_FINISHED = 11,
145 MLN_RUNTIME_EVENT_MAP_STILL_IMAGE_FAILED = 12,
146 MLN_RUNTIME_EVENT_MAP_RENDER_FRAME_STARTED = 13,
147 MLN_RUNTIME_EVENT_MAP_RENDER_FRAME_FINISHED = 14,
148 MLN_RUNTIME_EVENT_MAP_RENDER_MAP_STARTED = 15,
149 MLN_RUNTIME_EVENT_MAP_RENDER_MAP_FINISHED = 16,
150 MLN_RUNTIME_EVENT_MAP_STYLE_IMAGE_MISSING = 17,
151 MLN_RUNTIME_EVENT_MAP_TILE_ACTION = 18,
152 MLN_RUNTIME_EVENT_OFFLINE_REGION_STATUS_CHANGED = 19,
153 MLN_RUNTIME_EVENT_OFFLINE_REGION_RESPONSE_ERROR = 20,
154 MLN_RUNTIME_EVENT_OFFLINE_REGION_TILE_COUNT_LIMIT_EXCEEDED = 21,
155 MLN_RUNTIME_EVENT_OFFLINE_OPERATION_COMPLETED = 22,
156 MLN_RUNTIME_EVENT_MAP_CAMERA_TRANSITION_FINISHED = 23,
161 MLN_RUNTIME_EVENT_SOURCE_RUNTIME = 0,
162 MLN_RUNTIME_EVENT_SOURCE_MAP = 1,
167 MLN_RUNTIME_EVENT_PAYLOAD_NONE = 0,
168 MLN_RUNTIME_EVENT_PAYLOAD_RENDER_FRAME = 1,
169 MLN_RUNTIME_EVENT_PAYLOAD_RENDER_MAP = 2,
170 MLN_RUNTIME_EVENT_PAYLOAD_STYLE_IMAGE_MISSING = 3,
171 MLN_RUNTIME_EVENT_PAYLOAD_TILE_ACTION = 4,
172 MLN_RUNTIME_EVENT_PAYLOAD_OFFLINE_REGION_STATUS = 5,
173 MLN_RUNTIME_EVENT_PAYLOAD_OFFLINE_REGION_RESPONSE_ERROR = 6,
174 MLN_RUNTIME_EVENT_PAYLOAD_OFFLINE_REGION_TILE_COUNT_LIMIT = 7,
175 MLN_RUNTIME_EVENT_PAYLOAD_OFFLINE_OPERATION_COMPLETED = 8,
176 MLN_RUNTIME_EVENT_PAYLOAD_CAMERA_TRANSITION_FINISHED = 9,
189 MLN_RENDER_MODE_PARTIAL = 0,
190 MLN_RENDER_MODE_FULL = 1,
195 MLN_TILE_OPERATION_REQUESTED_FROM_CACHE = 0,
196 MLN_TILE_OPERATION_REQUESTED_FROM_NETWORK = 1,
197 MLN_TILE_OPERATION_LOAD_FROM_NETWORK = 2,
198 MLN_TILE_OPERATION_LOAD_FROM_CACHE = 3,
199 MLN_TILE_OPERATION_START_PARSE = 4,
200 MLN_TILE_OPERATION_END_PARSE = 5,
201 MLN_TILE_OPERATION_ERROR = 6,
202 MLN_TILE_OPERATION_CANCELLED = 7,
203 MLN_TILE_OPERATION_NULL = 8,
206typedef enum mln_resource_kind : uint32_t {
207 MLN_RESOURCE_KIND_UNKNOWN = 0,
208 MLN_RESOURCE_KIND_STYLE = 1,
209 MLN_RESOURCE_KIND_SOURCE = 2,
210 MLN_RESOURCE_KIND_TILE = 3,
211 MLN_RESOURCE_KIND_GLYPHS = 4,
212 MLN_RESOURCE_KIND_SPRITE_IMAGE = 5,
213 MLN_RESOURCE_KIND_SPRITE_JSON = 6,
214 MLN_RESOURCE_KIND_IMAGE = 7,
217typedef enum mln_resource_loading_method : uint32_t {
218 MLN_RESOURCE_LOADING_METHOD_ALL = 0,
219 MLN_RESOURCE_LOADING_METHOD_CACHE_ONLY = 1,
220 MLN_RESOURCE_LOADING_METHOD_NETWORK_ONLY = 2,
221} mln_resource_loading_method;
223typedef enum mln_resource_priority : uint32_t {
224 MLN_RESOURCE_PRIORITY_REGULAR = 0,
225 MLN_RESOURCE_PRIORITY_LOW = 1,
226} mln_resource_priority;
228typedef enum mln_resource_usage : uint32_t {
229 MLN_RESOURCE_USAGE_ONLINE = 0,
230 MLN_RESOURCE_USAGE_OFFLINE = 1,
233typedef enum mln_resource_storage_policy : uint32_t {
234 MLN_RESOURCE_STORAGE_POLICY_PERMANENT = 0,
235 MLN_RESOURCE_STORAGE_POLICY_VOLATILE = 1,
236} mln_resource_storage_policy;
238typedef enum mln_resource_response_status : uint32_t {
239 MLN_RESOURCE_RESPONSE_STATUS_OK = 0,
240 MLN_RESOURCE_RESPONSE_STATUS_ERROR = 1,
241 MLN_RESOURCE_RESPONSE_STATUS_NO_CONTENT = 2,
242 MLN_RESOURCE_RESPONSE_STATUS_NOT_MODIFIED = 3,
243} mln_resource_response_status;
245typedef enum mln_resource_error_reason : uint32_t {
246 MLN_RESOURCE_ERROR_REASON_NONE = 0,
247 MLN_RESOURCE_ERROR_REASON_NOT_FOUND = 1,
248 MLN_RESOURCE_ERROR_REASON_SERVER = 2,
249 MLN_RESOURCE_ERROR_REASON_CONNECTION = 3,
250 MLN_RESOURCE_ERROR_REASON_RATE_LIMIT = 4,
251 MLN_RESOURCE_ERROR_REASON_OTHER = 5,
252} mln_resource_error_reason;
254typedef enum mln_resource_provider_decision : uint32_t {
255 MLN_RESOURCE_PROVIDER_DECISION_PASS_THROUGH = 0,
256 MLN_RESOURCE_PROVIDER_DECISION_HANDLE = 1,
257} mln_resource_provider_decision;
286typedef struct mln_runtime_options {
290 const char* asset_path;
292 const char* cache_path;
294 uint64_t maximum_cache_size;
295} mln_runtime_options;
345 uint32_t overscaled_z;
347 uint32_t canonical_z;
348 uint32_t canonical_x;
349 uint32_t canonical_y;
385 mln_offline_region_id region_id;
392 mln_offline_region_id region_id;
400 mln_offline_region_id region_id;
448typedef struct mln_resource_transform_response {
456} mln_resource_transform_response;
472 mln_resource_transform_response* response,
const char* url,
size_t url_size
498 void* user_data, uint32_t kind,
const char* url,
499 mln_resource_transform_response* out_response
502typedef struct mln_resource_transform {
506} mln_resource_transform;
508typedef struct mln_resource_request {
512 uint32_t loading_method;
515 uint32_t storage_policy;
517 uint64_t range_start;
519 bool has_prior_modified;
520 int64_t prior_modified_unix_ms;
521 bool has_prior_expires;
522 int64_t prior_expires_unix_ms;
523 const char* prior_etag;
524 const uint8_t* prior_data;
525 size_t prior_data_size;
526} mln_resource_request;
528typedef struct mln_resource_response {
531 uint32_t error_reason;
533 const uint8_t* bytes;
535 const char* error_message;
536 bool must_revalidate;
538 int64_t modified_unix_ms;
540 int64_t expires_unix_ms;
542 bool has_retry_after;
543 int64_t retry_after_unix_ms;
544} mln_resource_response;
576 void* user_data,
const mln_resource_request* request,
577 mln_resource_request_handle* handle
580typedef struct mln_resource_provider {
584} mln_resource_provider;
606 const mln_runtime_options* options, mln_runtime** out_runtime
637 mln_runtime* runtime,
const mln_resource_provider* provider
679 mln_resource_request_handle* handle,
const mln_resource_response* response
694 const mln_resource_request_handle* handle,
bool* out_cancelled
707 mln_resource_request_handle* handle
730 mln_runtime* runtime,
const mln_resource_transform* transform
766 mln_runtime* runtime, uint32_t operation,
898 mln_runtime* runtime, mln_wake_source** out_source
mln_status
Definition base.h:39
mln_status mln_runtime_offline_operation_discard(mln_runtime *runtime, mln_offline_operation_id operation_id)
mln_tile_operation
Definition runtime.h:194
mln_status mln_network_status_get(uint32_t *out_status)
mln_runtime_event_payload_type
Definition runtime.h:166
mln_status mln_runtime_clear_resource_transform(mln_runtime *runtime)
mln_status mln_runtime_create(const mln_runtime_options *options, mln_runtime **out_runtime)
void mln_wake_source_destroy(mln_wake_source *source)
mln_status mln_runtime_set_resource_provider(mln_runtime *runtime, const mln_resource_provider *provider)
mln_runtime_event_type
Definition runtime.h:133
mln_status mln_resource_request_complete(mln_resource_request_handle *handle, const mln_resource_response *response)
mln_status mln_wake_source_signal(mln_wake_source *source)
mln_status mln_runtime_pump(mln_runtime *runtime, int64_t timeout_ms)
uint32_t(* mln_resource_provider_callback)(void *user_data, const mln_resource_request *request, mln_resource_request_handle *handle)
Definition runtime.h:575
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:160
mln_status mln_resource_request_cancelled(const mln_resource_request_handle *handle, bool *out_cancelled)
mln_camera_change_mode
Definition runtime.h:180
@ MLN_CAMERA_CHANGE_MODE_IMMEDIATE
Definition runtime.h:182
@ MLN_CAMERA_CHANGE_MODE_ANIMATED
Definition runtime.h:184
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:497
void mln_resource_request_release(mln_resource_request_handle *handle)
mln_status mln_runtime_wake_source_acquire(mln_runtime *runtime, mln_wake_source **out_source)
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:188
mln_status mln_runtime_clear_resource_provider(mln_runtime *runtime)
uint32_t download_state
Definition runtime.h:81
int64_t draw_call_count
Definition runtime.h:307
double encoding_time
Definition runtime.h:301
int64_t total_draw_call_count
Definition runtime.h:309
double rendering_time
Definition runtime.h:303
int64_t frame_count
Definition runtime.h:305
uint64_t transition_id
Definition runtime.h:379
uint32_t result_kind
Definition runtime.h:411
uint32_t operation_kind
Definition runtime.h:409
int32_t result_status
Definition runtime.h:413
bool found
Definition runtime.h:415
uint32_t reason
Definition runtime.h:394
bool needs_repaint
Definition runtime.h:318
uint32_t mode
Definition runtime.h:316
bool placement_changed
Definition runtime.h:320
uint32_t mode
Definition runtime.h:328
size_t image_id_size
Definition runtime.h:340
const char * image_id
Definition runtime.h:338
size_t source_id_size
Definition runtime.h:364
const char * source_id
Definition runtime.h:362
uint32_t operation
Definition runtime.h:356
uint32_t payload_type
Definition runtime.h:437
const void * payload
Definition runtime.h:439
void * source
Definition runtime.h:429
int32_t code
Definition runtime.h:435
size_t message_size
Definition runtime.h:445
uint32_t source_type
Definition runtime.h:423
const char * message
Definition runtime.h:443
size_t payload_size
Definition runtime.h:441