1 /**
2  * @file lv_vglite_path.h
3  *
4  */
5 
6 /**
7  * Copyright 2023 NXP
8  *
9  * SPDX-License-Identifier: MIT
10  */
11 
12 #ifndef LV_VGLITE_PATH_H
13 #define LV_VGLITE_PATH_H
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /*********************
20  *      INCLUDES
21  *********************/
22 #include "../../../lv_conf_internal.h"
23 
24 #if LV_USE_DRAW_VGLITE
25 #include "../../lv_draw.h"
26 #include "../../lv_draw_triangle.h"
27 
28 /*********************
29  *      DEFINES
30  *********************/
31 
32 /* The optimal Bezier control point offset for radial unit
33  * see: https://spencermortensen.com/articles/bezier-circle/
34  **/
35 #define BEZIER_OPTIM_CIRCLE 0.551915024494f
36 
37 /* Draw lines for control points of Bezier curves */
38 #define BEZIER_DBG_CONTROL_POINTS   0
39 
40 /* Path data sizes for different elements */
41 #define CUBIC_PATH_DATA_SIZE 7 /* 1 opcode, 6 arguments */
42 #define LINE_PATH_DATA_SIZE 3  /* 1 opcode, 2 arguments */
43 #define MOVE_PATH_DATA_SIZE 3  /* 1 opcode, 2 arguments */
44 #define END_PATH_DATA_SIZE 1   /* 1 opcode, 0 arguments */
45 /* Maximum possible rectangle path size
46  * is in the rounded rectangle case:
47  * - 1 move for the path start
48  * - 4 cubics for the corners
49  * - 4 lines for the sides
50  * - 1 end for the path end */
51 #define RECT_PATH_DATA_MAX_SIZE (1 * MOVE_PATH_DATA_SIZE + 4 * CUBIC_PATH_DATA_SIZE + 4 * LINE_PATH_DATA_SIZE + 1 * END_PATH_DATA_SIZE)
52 
53 /* Maximum possible arc path size
54  * is in the rounded arc case:
55  * - 1 move for the path start
56  * - 16 cubics for the arc (5 inner, 5 outer) and corners (3 per corner)
57  * - 1 end for the path end */
58 #define ARC_PATH_DATA_MAX_SIZE (1 * MOVE_PATH_DATA_SIZE + 16 * CUBIC_PATH_DATA_SIZE + 1 * END_PATH_DATA_SIZE)
59 /**********************
60  *      TYPEDEFS
61  **********************/
62 
63 /**********************
64  *  STATIC PROTOTYPES
65  **********************/
66 
67 /**********************
68  * GLOBAL PROTOTYPES
69  **********************/
70 
71 /**
72  * Generates path data for rectangle drawing.
73  *
74  * @param[in/out] path The path data to initialize
75  * @param[in/out] path_size The resulting size of the created path data
76  * @param[in] dsc The style descriptor for the rectangle to be drawn
77  * @param[in] coords The coordinates of the rectangle to be drawn
78  *
79  */
80 void vglite_create_rect_path_data(int32_t * path_data, uint32_t * path_data_size,
81                                   int32_t radius,
82                                   const lv_area_t * coords);
83 
84 /**********************
85  *      MACROS
86  **********************/
87 
88 /**********************
89  *   STATIC FUNCTIONS
90  **********************/
91 
92 #endif /*LV_USE_DRAW_VGLITE*/
93 
94 #ifdef __cplusplus
95 } /*extern "C"*/
96 #endif
97 
98 #endif /*LV_VGLITE_PATH_H*/
99