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;
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,
120 MLN_RUNTIME_EVENT_SOURCE_RUNTIME = 0,
121 MLN_RUNTIME_EVENT_SOURCE_MAP = 1,
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,
139 MLN_RENDER_MODE_PARTIAL = 0,
140 MLN_RENDER_MODE_FULL = 1,
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,
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,
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;
173typedef enum mln_resource_priority : uint32_t {
174 MLN_RESOURCE_PRIORITY_REGULAR = 0,
175 MLN_RESOURCE_PRIORITY_LOW = 1,
176} mln_resource_priority;
178typedef enum mln_resource_usage : uint32_t {
179 MLN_RESOURCE_USAGE_ONLINE = 0,
180 MLN_RESOURCE_USAGE_OFFLINE = 1,
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;
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;
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;
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;
236typedef struct mln_runtime_options {
240 const char* asset_path;
242 const char* cache_path;
244 uint64_t maximum_cache_size;
245} mln_runtime_options;
295 uint32_t overscaled_z;
297 uint32_t canonical_z;
298 uint32_t canonical_x;
299 uint32_t canonical_y;
320 mln_offline_region_id region_id;
327 mln_offline_region_id region_id;
335 mln_offline_region_id region_id;
378typedef struct mln_resource_transform_response {
386} mln_resource_transform_response;
402 mln_resource_transform_response* response,
const char* url,
size_t url_size
428 void* user_data, uint32_t kind,
const char* url,
429 mln_resource_transform_response* out_response
432typedef struct mln_resource_transform {
436} mln_resource_transform;
438typedef struct mln_resource_request {
442 uint32_t loading_method;
445 uint32_t storage_policy;
447 uint64_t range_start;
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;
458typedef struct mln_resource_response {
461 uint32_t error_reason;
463 const uint8_t* bytes;
465 const char* error_message;
466 bool must_revalidate;
468 int64_t modified_unix_ms;
470 int64_t expires_unix_ms;
472 bool has_retry_after;
473 int64_t retry_after_unix_ms;
474} mln_resource_response;
504 void* user_data,
const mln_resource_request* request,
505 mln_resource_request_handle* handle
508typedef struct mln_resource_provider {
512} mln_resource_provider;
534 const mln_runtime_options* options, mln_runtime** out_runtime
557 mln_runtime* runtime,
const mln_resource_provider* provider
579 mln_resource_request_handle* handle,
const mln_resource_response* response
594 const mln_resource_request_handle* handle,
bool* out_cancelled
606 mln_resource_request_handle* handle
629 mln_runtime* runtime,
const mln_resource_transform* transform
665 mln_runtime* runtime, uint32_t operation,
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
uint32_t download_state
Definition runtime.h:81
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
bool found
Definition runtime.h:350
uint32_t reason
Definition runtime.h:329
bool needs_repaint
Definition runtime.h:268
uint32_t mode
Definition runtime.h:266
bool placement_changed
Definition runtime.h:270
uint32_t mode
Definition runtime.h:278
size_t image_id_size
Definition runtime.h:290
const char * image_id
Definition runtime.h:288
size_t source_id_size
Definition runtime.h:314
const char * source_id
Definition runtime.h:312
uint32_t operation
Definition runtime.h:306
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