amap_map_sdk 2.1.2
高德地图RTOS地图SDK
载入中...
搜索中...
未找到
awk_adapter.h
浏览该文件的文档.
1/*
2 * @brief 系统适配接口
3 */
4
5#ifndef _AWK_ADAPATER_H
6#define _AWK_ADAPATER_H
7
8#include <stdbool.h>
9#include <stddef.h>
10#include <stdint.h>
11#include "awk_defines.h"
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17/*********************
18 * 绘制相关适配层
19*********************/
29
38
42typedef struct _awk_text_style_t {
44 uint32_t font_size;
47
51typedef enum {
52 AWK_FILL_STYLE_DRAWING_ONLY, // 仅填充几何图形
53 AWK_FILL_STYLE_DRAWING_AND_STROKE, // 填充几何图形和描边
54 AWK_FILL_STYLE_STROKE_ONLY // 仅填充描边
56
60typedef struct _awk_dash_style_t {
63 int32_t offset;
65
69typedef struct _awk_paint_style_t {
70 uint32_t width;
71 uint32_t color;
72 float angle;
77
81typedef struct _awk_render_context_t {
82 int32_t width;
83 int32_t height;
85
89typedef struct _awk_render_adapter_t awk_render_adapter_t;
97 void (*begin_drawing) (uint32_t map_id, awk_render_context_t status);
98
104 void (*commit_drawing)(uint32_t map_id);
105
114 void (*draw_point)(uint32_t map_id, awk_point_t *point, uint32_t point_size, const awk_paint_style_t *style);
115
124 void (*draw_polyline)(uint32_t map_id, awk_point_t *points, uint32_t point_size, const awk_paint_style_t *style);
125
134 void (*draw_polygon)(uint32_t map_id, awk_point_t *points, uint32_t point_size, const awk_paint_style_t *style);
135
144 void (*draw_bitmap)(uint32_t map_id, awk_rect_area_t area, awk_bitmap_t bitmap, const awk_paint_style_t *style);
145
154 void (*draw_text)(uint32_t map_id, awk_point_t center, const char *text, const awk_paint_style_t *style);
155
163 void (*draw_color)(uint32_t map_id, awk_rect_area_t area, const awk_paint_style_t *style);
164
174 bool (*measure_text)(uint32_t map_id, const char *text, const awk_paint_style_t *style, int32_t *width, int32_t *ascender, int32_t *descender);
175};
176
177/*********************
178 * 文件系统相关适配层
179*********************/
180
184typedef struct _awk_file_node {
185 char file_name[128];
186 size_t file_size;
188
192typedef struct _awk_readdir_result {
194 size_t size;
196
200typedef struct _awk_file_adapter_t awk_file_adapter_t;
206 void* (*file_open) (const char *filename, const char *mode);
212 int (*file_close) (void* handler);
221 size_t (*file_read) (void *ptr, size_t size, void* handler);
230 size_t (*file_write) (void *ptr, size_t size, void* handler);
238 int (*file_seek) (void *handler, long offset, int where);
244 int (*file_flush) (void *handler);
250 bool (*file_exists) (const char *path);
256 int (*file_remove) (const char *path);
262 bool (*file_dir_exists) (const char *path);
269 int (*file_mkdir) (const char *path, uint16_t model);
275 int (*file_rmdir) (const char *path);
281 void* (*file_opendir)(const char *path);
287 int (*file_closedir)(void *dir);
294 bool (*file_readdir)(void *dir, awk_readdir_result *result);
300 size_t (*file_get_size) (const char *path);
306 long (*file_get_last_access) (const char *path);
313 int (*file_rename) (const char *old_name, const char *new_name);
320 bool (*file_unzip)(const char *zip_file, const char *out_dir);
321};
322
323
324/*********************
325 * 内存相关适配层
326*********************/
327
331typedef struct _awk_memory_adapter_t awk_memory_adapter_t;
338 void (*mem_free)(void* ptr);
343 void* (*mem_malloc) (size_t size);
348 void* (*mem_calloc) (size_t count, size_t size);
353 void* (*mem_realloc) (void* ptr, size_t size);
354};
355
359typedef struct _awk_fast_memory_adapter_t awk_fast_memory_adapter_t;
366 void (*mem_free)(void* ptr);
372 void* (*mem_malloc) (size_t size, int type);
373};
374
375/*********************
376 * 网络相关适配层
377*********************/
378
379AWK_DATA_MAP_DEFINE(http_header_t, char*, char*);
380#define awk_http_header_t awk_map_http_header_t
381
382/*
383 * @brief 网络请求类型
384 */
389
390/*
391 * @brief 网络请求优先级
392 */
398
402typedef struct _awk_http_buffer_t awk_http_buffer_t;
404 uint8_t *buffer;
405 size_t length;
406};
407
411typedef struct _awk_http_request_t {
412 char *url;
415 awk_http_buffer_t *body;
418
422typedef struct _awk_http_response_t {
423 uint64_t request_id;
424 char* url;
425 uint32_t status_code;
426 awk_http_buffer_t *body;
429
433typedef struct _awk_http_response_callback_t awk_http_response_callback_t;
438 void (*on_receive_header) (awk_http_response_callback_t *callback, const awk_http_response_t *response);
442 void (*on_receive_body) (awk_http_response_callback_t *callback, const awk_http_response_t *response);
446 void (*on_fail) (awk_http_response_callback_t *callback, const awk_http_response_t *response, int32_t error);
450 void (*on_success) (awk_http_response_callback_t *callback, const awk_http_response_t *response);
454 void (*on_canceled) (awk_http_response_callback_t *callback, const awk_http_response_t *response);
455};
456
460typedef struct _awk_network_adapter_t awk_network_adapter_t;
468 uint64_t (*send) (awk_http_request_t *request, awk_http_response_callback_t *callback);
473 void (*cancel) (uint64_t request_id);
474};
475
476
477/*********************
478 * 其他系统相关适配层
479*********************/
480
484typedef struct _awk_system_adapter_t awk_system_adapter_t;
490 uint64_t (*get_system_time)(void);
491
497 int (*log_printf)(const char* __fmt, ...);
498};
499
500/*********************
501 * 线程相关适配层
502*********************/
503
507typedef struct _awk_thread_adapter_t {
512 uint64_t (*get_thread_id)(void);
514
515/*********************
516 * 瓦片文件
517*********************/
518
523typedef struct _awk_map_tile_file_adapter_t {
528 bool (*on_tile_file)(const char* tile_file_key, char *file_path, size_t *file_offset, size_t *file_size);
530
531
532/*********************
533 * 定制
534*********************/
535
540typedef struct _awk_map_custom_adapter_t {
545 int (*custom_sscanf)(const char *s, const char *format, ...);
546
551 void (*custom_assert)(int expression);
553#ifdef __cplusplus
554}
555#endif
556
557#endif
558
awk_fill_style_t
填充类型
Definition awk_adapter.h:51
@ AWK_FILL_STYLE_DRAWING_AND_STROKE
Definition awk_adapter.h:53
@ AWK_FILL_STYLE_DRAWING_ONLY
Definition awk_adapter.h:52
@ AWK_FILL_STYLE_STROKE_ONLY
Definition awk_adapter.h:54
awk_align_style_t
文字排布的对齐样式
Definition awk_adapter.h:23
@ AWK_ALIGN_STYLE_RIGHT
Definition awk_adapter.h:27
@ AWK_ALIGN_STYLE_CENTER
Definition awk_adapter.h:25
@ AWK_ALIGN_STYLE_LEFT
Definition awk_adapter.h:26
@ AWK_ALIGN_STYLE_NONE
Definition awk_adapter.h:24
awk_font_weight_t
字体粗细样式
Definition awk_adapter.h:33
@ AWK_FONT_WEIGHT_NORMAL
Definition awk_adapter.h:34
@ AWK_FONT_WEIGHT_BOLD
Definition awk_adapter.h:36
@ AWK_FONT_WEIGHT_THIN
Definition awk_adapter.h:35
awk_http_method
@ AWK_HTTP_METHOD_POST
@ AWK_HTTP_METHOD_GET
awk_http_priority
@ AWK_HTTP_PRIORITY_MEDIUM
普通优先级
@ AWK_HTTP_PRIORITY_HIGH
高优先级
@ AWK_HTTP_PRIORITY_LOW
低优先级
#define awk_http_header_t
#define AWK_DATA_MAP_DEFINE(name, K, V)
Definition awk_defines.h:18
内存相关适配接口(针对大内存优化)
void(* mem_free)(void *ptr)
释放内存时回调,参考free
文件相关适配接口
size_t(* file_get_size)(const char *path)
获取文件大小时的回调
int(* file_flush)(void *handler)
参考fflush
int(* file_rmdir)(const char *path)
删除文件夹时回调,参考rmdir
int(* file_close)(void *handler)
关闭文件的回调,参考fclose
bool(* file_readdir)(void *dir, awk_readdir_result *result)
读文件夹的内容
int(* file_remove)(const char *path)
移除文件,参考remove
long(* file_get_last_access)(const char *path)
获取文件最后访问的回调
int(* file_closedir)(void *dir)
关闭文件夹时的回调
bool(* file_dir_exists)(const char *path)
文件夹是否存在
size_t(* file_write)(void *ptr, size_t size, void *handler)
写文件时回调,参考fwrite
bool(* file_unzip)(const char *zip_file, const char *out_dir)
解压适配接口
int(* file_mkdir)(const char *path, uint16_t model)
创建文件夹时回调,参考mkdir
bool(* file_exists)(const char *path)
文件是否存在
int(* file_seek)(void *handler, long offset, int where)
参考fseek
int(* file_rename)(const char *old_name, const char *new_name)
重命名文件,参考rename
size_t(* file_read)(void *ptr, size_t size, void *handler)
读文件的回调,参考fread
aos缓冲区接口
uint8_t * buffer
buffer内容
size_t length
buffer长度
aos返回结果回调接口,网络代理方法的回调时需要在主流程线程中进行回调
void(* on_receive_body)(awk_http_response_callback_t *callback, const awk_http_response_t *response)
接收到body后回调,根据body大小,可回调多次,body为必填
void(* on_success)(awk_http_response_callback_t *callback, const awk_http_response_t *response)
所有数据返回成功后回调,最多只回调一次,可以不携带body,header数据
void(* on_receive_header)(awk_http_response_callback_t *callback, const awk_http_response_t *response)
接收到header后回调,最多只需回调一次,需要包含响应的头信息,header为必填
void(* on_canceled)(awk_http_response_callback_t *callback, const awk_http_response_t *response)
取消请求后,如果请求仍然在队列中,则回调该方法,最多只会回调一次
void(* on_fail)(awk_http_response_callback_t *callback, const awk_http_response_t *response, int32_t error)
请求数据失败后回调
内存相关适配接口
void(* mem_free)(void *ptr)
释放内存时回调,参考free
网络相关适配接口
uint64_t(* send)(awk_http_request_t *request, awk_http_response_callback_t *callback)
发送请求,请求的处理可以在异步线程中发起
void(* cancel)(uint64_t request_id)
取消请求,需要在主流程线程中处理
绘制相关适配接口
Definition awk_adapter.h:90
void(* begin_drawing)(uint32_t map_id, awk_render_context_t status)
开始绘制时回调方法
Definition awk_adapter.h:97
void(* draw_text)(uint32_t map_id, awk_point_t center, const char *text, const awk_paint_style_t *style)
需要绘制文字时回调
void(* draw_polyline)(uint32_t map_id, awk_point_t *points, uint32_t point_size, const awk_paint_style_t *style)
需要绘制线时回调
bool(* measure_text)(uint32_t map_id, const char *text, const awk_paint_style_t *style, int32_t *width, int32_t *ascender, int32_t *descender)
测量文字宽度
void(* draw_point)(uint32_t map_id, awk_point_t *point, uint32_t point_size, const awk_paint_style_t *style)
需要绘制点时回调
void(* draw_color)(uint32_t map_id, awk_rect_area_t area, const awk_paint_style_t *style)
需要绘制颜色时回调
void(* draw_bitmap)(uint32_t map_id, awk_rect_area_t area, awk_bitmap_t bitmap, const awk_paint_style_t *style)
需要绘制bitmap时回调
void(* commit_drawing)(uint32_t map_id)
绘制结束时回调方方法
void(* draw_polygon)(uint32_t map_id, awk_point_t *points, uint32_t point_size, const awk_paint_style_t *style)
需要绘制面时回调
系统相关适配接口
int(* log_printf)(const char *__fmt,...)
print回调,参考printf
uint64_t(* get_system_time)(void)
获取系统时间回调
位图定义
Definition awk_defines.h:72
虚线定义,单位:像素
Definition awk_adapter.h:60
int32_t unpainted_length
空白长度
Definition awk_adapter.h:62
int32_t painted_length
绘制长度
Definition awk_adapter.h:61
int32_t offset
起始位置
Definition awk_adapter.h:63
读文件夹时的文件节点信息
size_t file_size
文件大小
awk_http_priority priority
请求优先级
char * url
访问的url地址
awk_http_buffer_t * body
body内容
awk_http_header_t headers
header项
awk_http_method method
请求访问方式,默认值为get请求
aos返回的数据结构
uint32_t status_code
请求返回的状态码,如200、404
uint64_t request_id
reqId
char * url
请求的url地址
awk_http_header_t headers
header项
awk_http_buffer_t * body
body内容
笔刷样式
Definition awk_adapter.h:69
awk_text_style_t text_style
文字样式
Definition awk_adapter.h:73
uint32_t width
画笔宽度, 单位:像素
Definition awk_adapter.h:70
awk_dash_style_t dash_style
虚线样式
Definition awk_adapter.h:75
uint32_t color
画笔颜色, ARGB
Definition awk_adapter.h:71
awk_fill_style_t fill_ttyle
Definition awk_adapter.h:74
float angle
旋转角度,[0-360),正东为0,逆时针为正
Definition awk_adapter.h:72
画布点坐标,原点是以左上角为(0,0)
Definition awk_defines.h:54
读文件夹的结果
awk_file_node * nodes
文件节点信息
size_t size
文件节点数量
矩形区域定义
Definition awk_defines.h:62
绘制上下文
Definition awk_adapter.h:81
int32_t width
画布宽度, 单位:像素
Definition awk_adapter.h:82
int32_t height
画布高度, 单位:像素
Definition awk_adapter.h:83
文字样式
Definition awk_adapter.h:42
awk_font_weight_t font_weight
Definition awk_adapter.h:45
uint32_t font_size
Definition awk_adapter.h:44
awk_align_style_t align
Definition awk_adapter.h:43
线程相关适配接口