MapLibre Native C API
Public C ABI for the MapLibre Native wrapper.
Toggle main menu visibility
Loading...
Searching...
No Matches
include
maplibre_native_c
base.h
Go to the documentation of this file.
1
5
6
#ifndef MAPLIBRE_NATIVE_C_BASE_H
7
#define MAPLIBRE_NATIVE_C_BASE_H
8
9
#ifndef __cplusplus
10
#include <stdbool.h>
11
#endif
12
13
#include <stddef.h>
14
#include <stdint.h>
15
16
#include "
binding.h
"
17
18
#ifdef _WIN32
19
#if defined(MLN_STATIC)
20
#define MLN_API
21
#elif defined(MLN_BUILDING_C)
22
#define MLN_API __declspec(dllexport)
23
#else
24
#define MLN_API __declspec(dllimport)
25
#endif
26
#else
27
#define MLN_API __attribute__((visibility("default")))
28
#endif
29
30
#ifdef __cplusplus
31
#define MLN_NOEXCEPT noexcept
32
#else
33
#define MLN_NOEXCEPT
34
#endif
35
36
#ifdef __cplusplus
37
extern
"C"
{
38
#endif
39
41
typedef
enum
mln_status
: int32_t {
42
MLN_STATUS_OK
= 0,
44
MLN_STATUS_INVALID_ARGUMENT
= -1,
49
MLN_STATUS_INVALID_STATE
= -2,
51
MLN_STATUS_WRONG_THREAD
= -3,
53
MLN_STATUS_UNSUPPORTED
= -4,
58
MLN_STATUS_NATIVE_ERROR
= -5,
63
MLN_STATUS_CANCELLED
= -6,
65
MLN_STATUS_BUSY
= -7,
67
MLN_STATUS_TARGET_LOST
= -8,
69
MLN_STATUS_NOT_FOUND
= -10,
71
MLN_STATUS_ALREADY_EXISTS
= -11,
72
}
mln_status
;
73
75
#define MLN_DIAGNOSTIC_MESSAGE_CAPACITY 4096u
76
84
typedef
struct
mln_diagnostic
{
85
uint32_t
size
;
86
char
message
[
MLN_DIAGNOSTIC_MESSAGE_CAPACITY
];
87
}
mln_diagnostic
;
88
90
typedef
enum
MLN_BINDING(
"kind=bitmask"
)
mln_render_backend_flag
: uint32_t {
91
MLN_RENDER_BACKEND_FLAG_METAL
= 1u << 0u,
92
MLN_RENDER_BACKEND_FLAG_VULKAN
= 1u << 1u,
93
MLN_RENDER_BACKEND_FLAG_OPEN_GL
= 1u << 2u,
94
MLN_RENDER_BACKEND_FLAG_WEB_GPU
= 1u << 3u,
95
}
mln_render_backend_flag
;
96
98
typedef
uint32_t
mln_render_backend_flags
;
99
101
#define MLN_HANDLE_NULL ((uint64_t)0)
102
104
typedef
uint64_t
mln_runtime
MLN_BINDING(
105
"kind=handle;release=mln_runtime_release;"
106
"dispose=mln_runtime_dispose"
107
);
109
typedef
uint64_t
mln_map
MLN_BINDING(
110
"kind=handle;release=mln_map_release;parent=mln_runtime;"
111
"dispose=mln_map_dispose"
112
);
114
typedef
uint64_t
mln_style_expression
MLN_BINDING(
115
"kind=handle;release=mln_style_expression_release;"
116
"dispose=mln_style_expression_release"
117
);
119
typedef
uint64_t
mln_offscreen_device
MLN_BINDING(
120
"kind=handle;release=mln_offscreen_device_release;"
121
"dispose=mln_offscreen_device_release"
122
);
124
typedef
uint64_t
mln_vulkan_device
MLN_BINDING(
125
"kind=handle;release=mln_vulkan_device_release;"
126
"dispose=mln_vulkan_device_release"
127
);
129
typedef
uint64_t
mln_map_projection
MLN_BINDING(
130
"kind=handle;release=mln_map_projection_release;"
131
"dispose=mln_map_projection_release"
132
);
134
typedef
uint64_t
mln_resource_request
MLN_BINDING(
135
"kind=handle;release=mln_resource_request_release;"
136
"dispose=mln_resource_request_release"
137
);
139
typedef
uint64_t
mln_resource_transform_request
MLN_BINDING(
140
"kind=handle;release=mln_resource_transform_request_release;"
141
"dispose=mln_resource_transform_request_release"
142
);
144
typedef
uint64_t
mln_render_session
MLN_BINDING(
145
"kind=handle;release=mln_render_session_release;parent=mln_map;"
146
"abandon=mln_render_session_abandon;dispose=mln_render_session_dispose"
147
);
149
typedef
uint64_t
mln_acquired_frame
MLN_BINDING(
150
"kind=handle;release=mln_acquired_frame_release;parent=mln_render_session;"
151
"discard=mln_acquired_frame_discard;"
152
"view_begin=mln_acquired_frame_view_begin;"
153
"view_end=mln_acquired_frame_view_end"
154
);
156
typedef
uint64_t
mln_render_frame_batch
MLN_BINDING(
157
"kind=handle;release=mln_render_frame_batch_release;"
158
"dispose=mln_render_frame_batch_release"
159
);
161
typedef
uint64_t
mln_frame_pacer
MLN_BINDING(
162
"kind=handle;release=mln_frame_pacer_release;"
163
"dispose=mln_frame_pacer_release"
164
);
166
typedef
uint64_t
mln_delivery_queue
MLN_BINDING(
167
"kind=handle;release=mln_delivery_queue_release;"
168
"dispose=mln_delivery_queue_release"
169
);
170
178
typedef
struct
mln_buffer_view
{
179
const
void
*
data
;
180
size_t
size
MLN_BINDING(
"kind=count"
);
181
}
mln_buffer_view
;
182
191
typedef
void (*
mln_user_data_release
)(
void
* user_data);
192
194
#define MLN_C_VERSION 0u
195
202
MLN_API uint32_t
mln_c_version
(
void
) MLN_NOEXCEPT;
203
205
MLN_API
mln_render_backend_flags
206
mln_supported_render_backend_mask
(
void
) MLN_NOEXCEPT;
207
208
// Helpers for C callers. Each binding has its own, so the generator skips
209
// these.
210
#ifndef MLN_BINDGEN
211
217
static
inline
mln_buffer_view
mln_buffer_view_from_cstr(
const
char
* text) {
218
// Counts instead of calling strlen() so the headers stay freestanding.
219
size_t
size = 0;
220
if
(text != NULL) {
221
while
(text[size] !=
'\0'
) {
222
size++;
223
}
224
}
225
const
mln_buffer_view
view = {text, size};
226
return
view;
227
}
228
235
#define MLN_STRIDED_AT(type, items, stride, index) \
236
((const type*)((const unsigned char*)(items) + \
237
((size_t)(index) * (size_t)(stride))))
238
239
#endif
// MLN_BINDGEN
240
241
#ifdef __cplusplus
242
}
243
#endif
244
245
#endif
// MAPLIBRE_NATIVE_C_BASE_H
MLN_DIAGNOSTIC_MESSAGE_CAPACITY
#define MLN_DIAGNOSTIC_MESSAGE_CAPACITY
Definition
base.h:75
mln_render_session
uint64_t mln_render_session
Definition
base.h:147
mln_render_backend_flags
uint32_t mln_render_backend_flags
Definition
base.h:98
mln_resource_transform_request
uint64_t mln_resource_transform_request
Definition
base.h:142
mln_delivery_queue
uint64_t mln_delivery_queue
Definition
base.h:169
mln_render_frame_batch
uint64_t mln_render_frame_batch
Definition
base.h:159
mln_style_expression
uint64_t mln_style_expression
Definition
base.h:117
mln_map
uint64_t mln_map
Definition
base.h:112
mln_offscreen_device
uint64_t mln_offscreen_device
Definition
base.h:122
mln_vulkan_device
uint64_t mln_vulkan_device
Definition
base.h:127
mln_user_data_release
void(*) mln_user_data_release(void *user_data)
Definition
base.h:191
mln_acquired_frame
uint64_t mln_acquired_frame
Definition
base.h:154
mln_runtime
uint64_t mln_runtime
Definition
base.h:107
mln_resource_request
uint64_t mln_resource_request
Definition
base.h:137
mln_supported_render_backend_mask
mln_render_backend_flags mln_supported_render_backend_mask(void)
mln_map_projection
uint64_t mln_map_projection
Definition
base.h:132
mln_status
mln_status
Definition
base.h:41
MLN_STATUS_NATIVE_ERROR
@ MLN_STATUS_NATIVE_ERROR
Definition
base.h:58
MLN_STATUS_TARGET_LOST
@ MLN_STATUS_TARGET_LOST
Definition
base.h:67
MLN_STATUS_ALREADY_EXISTS
@ MLN_STATUS_ALREADY_EXISTS
Definition
base.h:71
MLN_STATUS_UNSUPPORTED
@ MLN_STATUS_UNSUPPORTED
Definition
base.h:53
MLN_STATUS_OK
@ MLN_STATUS_OK
Definition
base.h:42
MLN_STATUS_INVALID_STATE
@ MLN_STATUS_INVALID_STATE
Definition
base.h:49
MLN_STATUS_WRONG_THREAD
@ MLN_STATUS_WRONG_THREAD
Definition
base.h:51
MLN_STATUS_INVALID_ARGUMENT
@ MLN_STATUS_INVALID_ARGUMENT
Definition
base.h:44
MLN_STATUS_BUSY
@ MLN_STATUS_BUSY
Definition
base.h:65
MLN_STATUS_NOT_FOUND
@ MLN_STATUS_NOT_FOUND
Definition
base.h:69
MLN_STATUS_CANCELLED
@ MLN_STATUS_CANCELLED
Definition
base.h:63
mln_render_backend_flag
mln_render_backend_flag
Definition
base.h:90
MLN_RENDER_BACKEND_FLAG_WEB_GPU
@ MLN_RENDER_BACKEND_FLAG_WEB_GPU
Definition
base.h:94
MLN_RENDER_BACKEND_FLAG_VULKAN
@ MLN_RENDER_BACKEND_FLAG_VULKAN
Definition
base.h:92
MLN_RENDER_BACKEND_FLAG_OPEN_GL
@ MLN_RENDER_BACKEND_FLAG_OPEN_GL
Definition
base.h:93
MLN_RENDER_BACKEND_FLAG_METAL
@ MLN_RENDER_BACKEND_FLAG_METAL
Definition
base.h:91
mln_frame_pacer
uint64_t mln_frame_pacer
Definition
base.h:164
mln_c_version
uint32_t mln_c_version(void)
binding.h
mln_buffer_view
Definition
base.h:178
mln_buffer_view::data
const void * data
Definition
base.h:179
mln_buffer_view::size
size_t size
Definition
base.h:180
mln_diagnostic
Definition
base.h:84
mln_diagnostic::size
uint32_t size
Definition
base.h:85
mln_diagnostic::message
char message[MLN_DIAGNOSTIC_MESSAGE_CAPACITY]
Definition
base.h:86
Generated by
1.18.0