microvg  8.0.3
microvg
vg_helper.h
Go to the documentation of this file.
1 /*
2  * C
3  *
4  * Copyright 2020-2026 MicroEJ Corp. All rights reserved.
5  * MicroEJ Corp. PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  *
7  * Build: 7E4D1F7C
8  */
9 
18 #if !defined VG_HELPER_H
19 #define VG_HELPER_H
20 
21 #if defined __cplusplus
22 extern "C" {
23 #endif
24 
25 // -----------------------------------------------------------------------------
26 // Includes
27 // -----------------------------------------------------------------------------
28 
29 #include <sni.h>
30 
31 #include "vg_configuration.h"
32 
33 // -----------------------------------------------------------------------------
34 // Macros and Defines
35 // -----------------------------------------------------------------------------
36 
42 #define VG_LOG_ERROR(fmt, ...) VG_LOG_ERROR_PRINT(fmt, ## __VA_ARGS__)
43 
50 #if defined VG_LOG_INFO_ENABLED && (VG_LOG_INFO_ENABLED == 1)
51 #define VG_LOG_INFO(fmt, ...) VG_LOG_INFO_PRINT(fmt, ## __VA_ARGS__)
52 #else
53 #define VG_LOG_INFO(fmt, ...)
54 #endif
55 
59 #define MEJ_LOG_ERROR_MICROVG(fmt, ...) VG_LOG_ERROR(fmt, ## __VA_ARGS__)
60 
64 #define MEJ_LOG_INFO_MICROVG(fmt, ...) VG_LOG_INFO(fmt, ## __VA_ARGS__)
65 
70 //#define MICROVG_MONITOR_HEAP
71 
75 #define VG_HELPER_NULL_GRADIENT 0
76 
84 #define FT_FACE_FLAG_COMPLEX_LAYOUT (((uint32_t)1) << 31)
85 
86 #ifndef M_PI
87 #define M_PI 3.1415926535
88 #endif
89 
90 #define RAD_TO_DEG(r) ((r) * (180.0f / M_PI))
91 #define DEG_TO_RAD(d) (((d) * M_PI) / 180.0f)
92 
93 #define JFLOAT_TO_UINT32_t(f) (*(uint32_t *)&(f))
94 #define UINT32_t_TO_JFLOAT(i) (*(float *)&(i))
95 
99 #define REGISTERDESC(desc, buf, buf_len) if ((buf_len) >= sizeof(desc)) { (void)memcpy((buf), (desc), sizeof(desc)); }
100 
101 // --------------------------------------------------------------------------------
102 // UI Pack > 14.5.1 function
103 // --------------------------------------------------------------------------------
104 
118 
119 // -----------------------------------------------------------------------------
120 // API
121 // -----------------------------------------------------------------------------
122 
142 int VG_HELPER_get_utf(const unsigned short *text, int length, int *offset);
143 
155 void VG_HELPER_layout_configure(int faceHandle, const unsigned short *text, int length);
156 
167 void VG_HELPER_layout_dispose(int faceHandle);
168 
180 bool VG_HELPER_layout_load_glyph(uint32_t *glyph_idx, int *x_advance, int *y_advance, int *x_offset, int *y_offset);
181 
192 
204 const jfloat * VG_HELPER_check_matrix(const jfloat *matrix);
205 
214 uint32_t VG_HELPER_apply_alpha(uint32_t color, uint32_t alpha);
215 
224 void VG_HELPER_prepare_matrix(jfloat *dest, jfloat x, jfloat y, const jfloat *matrix);
225 
226 // -----------------------------------------------------------------------------
227 // EOF
228 // -----------------------------------------------------------------------------
229 
230 #ifdef __cplusplus
231 }
232 #endif
233 
234 #endif // !defined VG_HELPER_H
MicroEJ MicroVG library low level API: enable some features according to the hardware capacities.
uint32_t VG_HELPER_apply_alpha(uint32_t color, uint32_t alpha)
Applies the global opacity on given color.
Definition: vg_helper.c:352
void VG_HELPER_layout_dispose(int faceHandle)
Releases the font layouter's state built from a font face, when that face is about to be freed....
void LLUI_DISPLAY_waitAsynchronousDrawingEnd(void)
Waits until the end of current asynchronous drawing.
Definition: vg_helper.c:157
void VG_HELPER_layout_stop(void)
Releases what the layouter still holds for the current iteration. Does nothing when there is nothing ...
void VG_HELPER_prepare_matrix(jfloat *dest, jfloat x, jfloat y, const jfloat *matrix)
Converts a MicroVG matrix in another MicroVG matrix applying a translation.
Definition: vg_helper.c:358
void VG_HELPER_layout_configure(int faceHandle, const unsigned short *text, int length)
Configures the font layouter with a font and a text.
const jfloat * VG_HELPER_check_matrix(const jfloat *matrix)
Checks if the matrix is null. In that case, returns an identity matrix. This allows to prevent to mak...
Definition: vg_helper.c:347
int VG_HELPER_get_utf(const unsigned short *text, int length, int *offset)
Gets the UTF character from a text buffer at the given offset and updates the offset to point to the ...
Definition: vg_helper.c:166
bool VG_HELPER_layout_load_glyph(uint32_t *glyph_idx, int *x_advance, int *y_advance, int *x_offset, int *y_offset)
Loads the next layouted glyph and gets index and positions.