microvg  6.0.1
microvg
vg_drawing.h
1 /*
2  * Copyright 2023-2024 MicroEJ Corp. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be found with this software.
4  */
5 
6 #if !defined VG_DRAWING_H
7 #define VG_DRAWING_H
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 /*
13  * @file
14  * @brief Provides drawing functions called by MicroVG native drawing functions.
15  *
16  * This header file follows strictly the same concept as ui_drawing.h but for MicroVG
17  * library.
18  *
19  * @see ui_drawing.h
20  */
21 
22 // --------------------------------------------------------------------------------
23 // Includes
24 // --------------------------------------------------------------------------------
25 
26 #include <LLVG_PAINTER_impl.h>
27 
28 #include "ui_drawing.h"
29 
30 // --------------------------------------------------------------------------------
31 // API
32 // --------------------------------------------------------------------------------
33 
39 void VG_DRAWING_initialize(void);
40 
41 /*
42  * @brief Tells if the image is closed (closed just before calling the native
43  * function).
44  *
45  * @param[in] image: the image to check.
46  *
47  * @return true if the image is closed.
48  */
49 bool VG_DRAWING_image_is_closed(const MICROVG_Image *image);
50 
51 /*
52  * @brief Gets the image size. The image structure format is VEE Port specific.
53  *
54  * @param[in] image: the image
55  * @param[out] width: the image width
56  * @param[out] height: the image height
57  */
58 void VG_DRAWING_get_image_size(const MICROVG_Image *image, float *width, float *height);
59 
60 /*
61  * @brief Draws a path filled with the specified color (not the one of the Graphics Context).
62  *
63  * @param[in] gc: the destination
64  * @param[in] path: the path's data
65  * @param[in] matrix: the deformation to apply
66  * @param[in] fillRule: the fill type
67  * @param[in] blend: the blend mode
68  * @param[in] color: the color to apply (with an opacity)
69  *
70  * @return the drawing status.
71  */
72 DRAWING_Status VG_DRAWING_drawPath(MICROUI_GraphicsContext *gc, jbyte *path, jfloat *matrix, jint fillRule, jint blend,
73  jint color);
74 
75 /*
76  * @brief Draws a path filled with a linear gradient.
77  *
78  * @param[in] gc: the destination
79  * @param[in] path: the path's data
80  * @param[in] matrix: the deformation to apply
81  * @param[in] fillRule: the fill type
82  * @param[in] alpha: the global opacity to apply
83  * @param[in] blend: the blend mode
84  * @param[in] gradient: the gradient to apply
85  * @param[in] gradientMatrix: the gradient deformation, may be null (means identity)
86  *
87  * @return the drawing status.
88  */
89 DRAWING_Status VG_DRAWING_drawGradient(MICROUI_GraphicsContext *gc, jbyte *path, jfloat *matrix, jint fillRule,
90  jint alpha, jint blend, jint *gradient, jfloat *gradientMatrix);
91 
92 /*
93  * @brief Draws a string with the color of the Graphics Context.
94  *
95  * The top/left position of the first drawn character is placed at
96  * coordinate x/y.
97  *
98  * @param[in] gc the MicroUI GraphicsContext target.
99  * @param[in] text the array of characters to draw.
100  * @param[in] faceHandle the font reference handle.
101  * @param[in] size the height of the font in pixels.
102  * @param[in] matrix: deformation matrix, may be null (means identity)
103  * @param[in] alpha the opacity level to apply to the character.
104  * @param[in] blend the blend mode to use
105  * @param[in] letterSpacing the extra letter spacing to use
106  *
107  * @return the drawing status.
108  */
109 DRAWING_Status VG_DRAWING_drawString(MICROUI_GraphicsContext *gc, jchar *text, jint faceHandle, jfloat size,
110  jfloat *matrix, jint alpha, jint blend, jfloat letterSpacing);
111 
112 /*
113  * @brief Draws a string with a linear gradient.
114  *
115  * @param[in] gc the MicroUI GraphicsContext target.
116  * @param[in] text the array of characters to draw.
117  * @param[in] faceHandle the font reference handle.
118  * @param[in] size the height of the font in pixels.
119  * @param[in] matrix: deformation matrix, may be null (means identity)
120  * @param[in] alpha the opacity level to apply to the character.
121  * @param[in] blend the blend mode to use
122  * @param[in] letterSpacing the extra letter spacing to use
123  * @param[in] gradientData the gradient to apply
124  * @param[in] gradientMatrix the gradient deformation, may be null (means identity)
125  *
126  * @return the drawing status.
127  */
128 DRAWING_Status VG_DRAWING_drawStringGradient(MICROUI_GraphicsContext *gc, jchar *text, jint faceHandle, jfloat size,
129  jfloat *matrix, jint alpha, jint blend, jfloat letterSpacing,
130  jint *gradientData, jfloat *gradientMatrix);
131 
132 /*
133  * @brief Draws a string along a circle, with the color of the Graphics Context.
134  *
135  * @param[in] gc the MicroUI GraphicsContext target.
136  * @param[in] text the array of characters to draw.
137  * @param[in] faceHandle the font reference handle.
138  * @param[in] size the height of the font in pixels.
139  * @param[in] matrix: deformation matrix, may be null (means identity)
140  * @param[in] alpha the opacity level to apply to the character.
141  * @param[in] blend the blend mode to use
142  * @param[in] letterSpacing the extra letter spacing to use
143  * @param[in] radius the radius of the circle
144  * @param[in] direction the direction of the text along the circle
145  *
146  * @return the drawing status.
147  */
148 DRAWING_Status VG_DRAWING_drawStringOnCircle(MICROUI_GraphicsContext *gc, jchar *text, jint faceHandle, jfloat size,
149  jfloat *matrix, jint alpha, jint blend, jfloat letterSpacing,
150  jfloat radius, jint direction);
151 
152 /*
153  * @brief Draws a string along a circle, with a linear gradient.
154  *
155  * @param[in] gc the MicroUI GraphicsContext target.
156  * @param[in] text the array of characters to draw.
157  * @param[in] faceHandle the font reference handle.
158  * @param[in] size the height of the font in pixels.
159  * @param[in] matrix: deformation matrix, may be null (means identity)
160  * @param[in] alpha the opacity level to apply to the character.
161  * @param[in] blend the blend mode to use
162  * @param[in] letterSpacing the extra letter spacing to use
163  * @param[in] radius the radius of the circle
164  * @param[in] direction the direction of the text along the circle
165  * @param[in] gradientData the gradient to apply
166  * @param[in] gradientMatrix the gradient deformation, may be null (means identity)
167  *
168  * @return the drawing status.
169  */
170 DRAWING_Status VG_DRAWING_drawStringOnCircleGradient(MICROUI_GraphicsContext *gc, jchar *text, jint faceHandle,
171  jfloat size, jfloat *matrix, jint alpha, jint blend,
172  jfloat letterSpacing, jfloat radius, jint direction,
173  jint *gradientData, jfloat *gradientMatrix);
174 
175 /*
176  * @brief Draws an image with transformation and opacity. Optionally apply an animation and / or a color filtering.
177  *
178  * @param[in] gc the graphics context to draw on
179  * @param[in] image the image to draw
180  * @param[in] matrix the transformation matrix to apply
181  * @param[in] alpha the global opacity rendering value
182  * @param[in] elapsedTime the elapsed time since the beginning of the animation, in milliseconds
183  * @param[in] colorMatrix the color matrix used to transform colors, may be null (means no color deformation)
184  * @param[out] errno the error code to return to MicroVG.
185  *
186  * @return the drawing status.
187  */
188 DRAWING_Status VG_DRAWING_drawImage(MICROUI_GraphicsContext *gc, void *image, jfloat *matrix, jint alpha, jlong elapsed,
189  const float color_matrix[], jint *errno);
190 
191 // --------------------------------------------------------------------------------
192 // EOF
193 // --------------------------------------------------------------------------------
194 
195 #ifdef __cplusplus
196 }
197 #endif
198 #endif // VG_DRAWING_H