microvg  7.0.2
microvg
vg_trace.h
1 /*
2  * C
3  *
4  * Copyright 2023-2025 MicroEJ Corp. All rights reserved.
5  * MicroEJ Corp. PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */
7 
8 #if !defined VG_TRACE_H
9 #define VG_TRACE_H
10 
11 #if defined __cplusplus
12 extern "C" {
13 #endif
14 
15 /*
16  * @file
17  * @brief Provides the logs of the CCO MicroVG.
18  * @author MicroEJ Developer Team
19  * @version 7.0.2
20  */
21 
22 // -----------------------------------------------------------------------------
23 // Includes
24 // -----------------------------------------------------------------------------
25 
26 /*
27  * @brief Includes right header file according the Architecture.
28  * - Architecture 7: include "LLTRACE_impl.h" (LLTRACE.h is not available)
29  * - Architecture 8: include "LLTRACE.h"
30  */
31 #if !defined UI_LOG_LLTRACE
32 #if !defined __has_include
33 #error "Set manually UI_LOG_LLTRACE: 0 for MicroEJ Architecture 7.x or 1 for MicroEJ Architecture 8.x"
34 #else
35 #define UI_LOG_LLTRACE __has_include("LLTRACE.h")
36 #endif // #if !defined __has_include
37 #endif // #if !defined UI_LOG_LLTRACE
38 #if UI_LOG_LLTRACE == (0u)
39 #include <LLTRACE_impl.h>
40 #else
41 #include <LLTRACE.h>
42 #endif
43 
44 // -----------------------------------------------------------------------------
45 // Defines
46 // -----------------------------------------------------------------------------
47 
48 /*
49  * @brief Available number of events: IMAGE, FONT and DRAWING
50  */
51 #define LOG_MICROVG_EVENTS 3
52 
53 /*
54  * Events identifiers
55  */
56 #define LOG_MICROVG_IMAGE_ID 0
57 #define LOG_MICROVG_FONT_ID 1
58 #define LOG_MICROVG_DRAWING_ID 2
59 
60 /*
61  * @brief Types of Image events
62  */
63 #define LOG_MICROVG_IMAGE_load 0
64 #define LOG_MICROVG_IMAGE_create 1
65 #define LOG_MICROVG_IMAGE_close 2
66 
67 /*
68  * @brief Types of Font events
69  */
70 #define LOG_MICROVG_FONT_load 0
71 #define LOG_MICROVG_FONT_baseline 1
72 #define LOG_MICROVG_FONT_height 2
73 #define LOG_MICROVG_FONT_stringWidth 3
74 #define LOG_MICROVG_FONT_stringHeight 4
75 
76 /*
77  * @brief Types of Drawing events
78  */
79 #define LOG_MICROVG_DRAW_path 0
80 #define LOG_MICROVG_DRAW_pathGradient 1
81 #define LOG_MICROVG_DRAW_string 2
82 #define LOG_MICROVG_DRAW_stringGradient 3
83 #define LOG_MICROVG_DRAW_stringOnCircle 4
84 #define LOG_MICROVG_DRAW_stringOnCircleGradient 5
85 #define LOG_MICROVG_DRAW_image 6
86 
87 /*
88  * @brief Useful macros to concatenate easily some strings and defines.
89  */
90 #define CONCAT_STRINGS(p, s) p ## s
91 #define CONCAT_DEFINES(p, s) CONCAT_STRINGS(p, s)
92 
93 /*
94  * @brief Compatibility of Architecture 7 with Architecture 8: use the prototypes
95  * of LLTRACE.h (Architecture 8).
96  */
97 #if UI_LOG_LLTRACE == (0u)
98 #define LLTRACE_declare_event_group LLTRACE_IMPL_declare_event_group
99 #define LLTRACE_record_event_void LLTRACE_IMPL_record_event_void
100 #define LLTRACE_record_event_u32 LLTRACE_IMPL_record_event_u32
101 #define LLTRACE_record_event_u32x2 LLTRACE_IMPL_record_event_u32x2
102 #define LLTRACE_record_event_u32x3 LLTRACE_IMPL_record_event_u32x3
103 #define LLTRACE_record_event_u32x4 LLTRACE_IMPL_record_event_u32x4
104 #define LLTRACE_record_event_u32x5 LLTRACE_IMPL_record_event_u32x5
105 #define LLTRACE_record_event_u32x6 LLTRACE_IMPL_record_event_u32x6
106 #define LLTRACE_record_event_u32x7 LLTRACE_IMPL_record_event_u32x7
107 #define LLTRACE_record_event_u32x8 LLTRACE_IMPL_record_event_u32x8
108 #define LLTRACE_record_event_u32x9 LLTRACE_IMPL_record_event_u32x9
109 #define LLTRACE_record_event_u32x10 LLTRACE_IMPL_record_event_u32x10
110 #define LLTRACE_record_event_end LLTRACE_IMPL_record_event_end
111 #define LLTRACE_record_event_end_u32 LLTRACE_IMPL_record_event_end_u32
112 #endif // if UI_LOG_LLTRACE == (0u)
113 
114 /*
115  * @brief Macro to add an event and its type.
116  */
117 #define LOG_MICROVG_START(event, type) LLTRACE_record_event_u32(VG_TRACE_group_id, event, type);
118 
119 /*
120  * @brief Macro to notify the end of an event and its type.
121  */
122 #define LOG_MICROVG_END(event, type) LLTRACE_record_event_end_u32(VG_TRACE_group_id, event, type);
123 
124 /* The following lines must be added to a SYSVIEW_MicroVG.txt file
125  * in the <SYSTEMVIEW instalation dir>/Description folder
126  *
127  * NamedType VGImage 0=LOAD_IMAGE
128  * NamedType VGImage 1=CREATE_IMAGE
129  * NamedType VGImage 2=CLOSE_IMAGE
130  *
131  * NamedType VGFont 0=LOAD_FONT
132  * NamedType VGFont 1=FONT_BASELINE
133  * NamedType VGFont 2=FONT_HEIGHT
134  * NamedType VGFont 3=STRING_WIDTH
135  * NamedType VGFont 4=STRING_HEIGHT
136  *
137  * NamedType VGDraw 0=DRAW_PATH
138  * NamedType VGDraw 1=DRAW_PATH_GRADIENT
139  * NamedType VGDraw 2=DRAW_STRING
140  * NamedType VGDraw 3=DRAW_STRING_GRADIENT
141  * NamedType VGDraw 4=DRAW_STRING_ON_CIRCLE
142  * NamedType VGDraw 5=DRAW_STRING_ON_CIRCLE_GRADIENT
143  * NamedType VGDraw 6=DRAW_IMAGE
144  *
145  * 0 VG_ImageEvent (MicroVG) Execute image event %VGImage | (MicroVG) Image event %VGImage done
146  * 1 VG_FontEvent (MicroVG) Execute font event %VGFont | (MicroVG) Font event %VGFont done
147  * 2 VG_DrawingEvent (MicroVG) Execute drawing event %VGDraw | (MicroVG) Drawing event %VGDraw done
148  *
149  */
150 
151 // -----------------------------------------------------------------------------
152 // Extern symbols
153 // -----------------------------------------------------------------------------
154 
155 /*
156  * @brief External variable that contains the id for each trace group.
157  */
158 extern int32_t VG_TRACE_group_id;
159 
160 // -----------------------------------------------------------------------------
161 // EOF
162 // -----------------------------------------------------------------------------
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif // !defined VG_TRACE_H