1 /** 2 * @file lv_vg_lite_path.h 3 * 4 */ 5 6 #ifndef LV_VG_LITE_PATH_H 7 #define LV_VG_LITE_PATH_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 17 #include "lv_vg_lite_utils.h" 18 19 #if LV_USE_DRAW_VG_LITE 20 21 /********************* 22 * DEFINES 23 *********************/ 24 25 #if LV_USE_VG_LITE_THORVG 26 /** 27 * It is found that thorvg cannot handle large coordinates well. 28 * When the coordinates are larger than 4096, the calculation of tvgSwRle module will overflow in 32-bit system. 29 * So we use FLT_MAX and FLT_MIN to write the mark to bounding_box to tell vg_lite_tvg not to add clip path to the current path. 30 */ 31 #define PATH_COORD_MAX FLT_MAX 32 #define PATH_COORD_MIN FLT_MIN 33 #else 34 /* 18 bits is enough to represent the coordinates of path bounding box */ 35 #define PATH_COORD_MAX (1 << 18) 36 #define PATH_COORD_MIN (-PATH_COORD_MAX) 37 #endif 38 39 #define LV_VG_LITE_PATH_SET_OP_CODE(PTR, TYPE, OP_CODE) (*((TYPE*)PTR) = (OP_CODE)) 40 #define LV_VG_LITE_PATH_GET_OP_CODE(PTR) (*((uint8_t*)PTR)) 41 42 /********************** 43 * TYPEDEFS 44 **********************/ 45 46 typedef struct _lv_vg_lite_path_t lv_vg_lite_path_t; 47 typedef struct _lv_draw_vg_lite_unit_t lv_draw_vg_lite_unit_t; 48 49 typedef void (*lv_vg_lite_path_iter_cb_t)(void * user_data, uint8_t op_code, const float * data, uint32_t len); 50 51 /********************** 52 * GLOBAL PROTOTYPES 53 **********************/ 54 55 void lv_vg_lite_path_init(lv_draw_vg_lite_unit_t * unit); 56 57 void lv_vg_lite_path_deinit(lv_draw_vg_lite_unit_t * unit); 58 59 lv_vg_lite_path_t * lv_vg_lite_path_create(vg_lite_format_t data_format); 60 61 void lv_vg_lite_path_destroy(lv_vg_lite_path_t * path); 62 63 lv_vg_lite_path_t * lv_vg_lite_path_get(lv_draw_vg_lite_unit_t * unit, vg_lite_format_t data_format); 64 65 void lv_vg_lite_path_drop(lv_draw_vg_lite_unit_t * unit, lv_vg_lite_path_t * path); 66 67 void lv_vg_lite_path_reset(lv_vg_lite_path_t * path, vg_lite_format_t data_format); 68 69 void lv_vg_lite_path_set_bounding_box_area(lv_vg_lite_path_t * path, const lv_area_t * area); 70 71 void lv_vg_lite_path_set_bounding_box(lv_vg_lite_path_t * path, 72 float min_x, float min_y, 73 float max_x, float max_y); 74 75 void lv_vg_lite_path_get_bounding_box(lv_vg_lite_path_t * path, 76 float * min_x, float * min_y, 77 float * max_x, float * max_y); 78 79 bool lv_vg_lite_path_update_bounding_box(lv_vg_lite_path_t * path); 80 81 void lv_vg_lite_path_set_transform(lv_vg_lite_path_t * path, const vg_lite_matrix_t * matrix); 82 83 void lv_vg_lite_path_set_quality(lv_vg_lite_path_t * path, vg_lite_quality_t quality); 84 85 vg_lite_path_t * lv_vg_lite_path_get_path(lv_vg_lite_path_t * path); 86 87 void lv_vg_lite_path_reserve_space(lv_vg_lite_path_t * path, size_t len); 88 89 void lv_vg_lite_path_move_to(lv_vg_lite_path_t * path, 90 float x, float y); 91 92 void lv_vg_lite_path_line_to(lv_vg_lite_path_t * path, 93 float x, float y); 94 95 void lv_vg_lite_path_quad_to(lv_vg_lite_path_t * path, 96 float cx, float cy, 97 float x, float y); 98 99 void lv_vg_lite_path_cubic_to(lv_vg_lite_path_t * path, 100 float cx1, float cy1, 101 float cx2, float cy2, 102 float x, float y); 103 104 void lv_vg_lite_path_close(lv_vg_lite_path_t * path); 105 106 void lv_vg_lite_path_end(lv_vg_lite_path_t * path); 107 108 void lv_vg_lite_path_append_rect(lv_vg_lite_path_t * path, 109 float x, float y, 110 float w, float h, 111 float r); 112 113 void lv_vg_lite_path_append_circle(lv_vg_lite_path_t * path, 114 float cx, float cy, 115 float rx, float ry); 116 117 void lv_vg_lite_path_append_arc_right_angle(lv_vg_lite_path_t * path, 118 float start_x, float start_y, 119 float center_x, float center_y, 120 float end_x, float end_y); 121 122 void lv_vg_lite_path_append_arc(lv_vg_lite_path_t * path, 123 float cx, float cy, 124 float radius, 125 float start_angle, 126 float sweep, 127 bool pie); 128 129 void lv_vg_lite_path_append_path(lv_vg_lite_path_t * dest, const lv_vg_lite_path_t * src); 130 131 uint8_t lv_vg_lite_vlc_op_arg_len(uint8_t vlc_op); 132 133 uint8_t lv_vg_lite_path_format_len(vg_lite_format_t format); 134 135 void lv_vg_lite_path_for_each_data(const vg_lite_path_t * path, lv_vg_lite_path_iter_cb_t cb, void * user_data); 136 137 /********************** 138 * MACROS 139 **********************/ 140 141 #endif /*LV_USE_DRAW_VG_LITE*/ 142 143 #ifdef __cplusplus 144 } /*extern "C"*/ 145 #endif 146 147 #endif /*LV_VG_LITE_PATH_H*/ 148