microvg  7.0.0
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] length the length of the array
101  * @param[in] faceHandle the font reference handle.
102  * @param[in] size the height of the font in pixels.
103  * @param[in] matrix deformation matrix, may be null (means identity)
104  * @param[in] alpha the opacity level to apply to the character.
105  * @param[in] blend the blend mode to use
106  * @param[in] letterSpacing the extra letter spacing to use
107  *
108  * @return the drawing status.
109  */
110 DRAWING_Status VG_DRAWING_drawString(MICROUI_GraphicsContext *gc, jchar *text, jint length, jint faceHandle,
111  jfloat size, jfloat *matrix, jint alpha, jint blend, jfloat letterSpacing);
112 
113 /*
114  * @brief Draws a string with a linear gradient.
115  *
116  * @param[in] gc the MicroUI GraphicsContext target.
117  * @param[in] text the array of characters to draw.
118  * @param[in] length the length of the array
119  * @param[in] faceHandle the font reference handle.
120  * @param[in] size the height of the font in pixels.
121  * @param[in] matrix deformation matrix, may be null (means identity)
122  * @param[in] alpha the opacity level to apply to the character.
123  * @param[in] blend the blend mode to use
124  * @param[in] letterSpacing the extra letter spacing to use
125  * @param[in] gradientData the gradient to apply
126  * @param[in] gradientMatrix the gradient deformation, may be null (means identity)
127  *
128  * @return the drawing status.
129  */
130 DRAWING_Status VG_DRAWING_drawStringGradient(MICROUI_GraphicsContext *gc, jchar *text, jint length, jint faceHandle,
131  jfloat size, jfloat *matrix, jint alpha, jint blend, jfloat letterSpacing,
132  jint *gradientData, jfloat *gradientMatrix);
133 
134 /*
135  * @brief Draws a string along a circle, with the color of the Graphics Context.
136  *
137  * @param[in] gc the MicroUI GraphicsContext target.
138  * @param[in] text the array of characters to draw.
139  * @param[in] length the length of the array
140  * @param[in] faceHandle the font reference handle.
141  * @param[in] size the height of the font in pixels.
142  * @param[in] matrix deformation matrix, may be null (means identity)
143  * @param[in] alpha the opacity level to apply to the character.
144  * @param[in] blend the blend mode to use
145  * @param[in] letterSpacing the extra letter spacing to use
146  * @param[in] radius the radius of the circle
147  * @param[in] direction the direction of the text along the circle
148  *
149  * @return the drawing status.
150  */
151 DRAWING_Status VG_DRAWING_drawStringOnCircle(MICROUI_GraphicsContext *gc, jchar *text, jint length, jint faceHandle,
152  jfloat size, jfloat *matrix, jint alpha, jint blend, jfloat letterSpacing,
153  jfloat radius, jint direction);
154 
155 /*
156  * @brief Draws a string along a circle, with a linear gradient.
157  *
158  * @param[in] gc the MicroUI GraphicsContext target.
159  * @param[in] text the array of characters to draw.
160  * @param[in] length the length of the array
161  * @param[in] faceHandle the font reference handle.
162  * @param[in] size the height of the font in pixels.
163  * @param[in] matrix deformation matrix, may be null (means identity)
164  * @param[in] alpha the opacity level to apply to the character.
165  * @param[in] blend the blend mode to use
166  * @param[in] letterSpacing the extra letter spacing to use
167  * @param[in] radius the radius of the circle
168  * @param[in] direction the direction of the text along the circle
169  * @param[in] gradientData the gradient to apply
170  * @param[in] gradientMatrix the gradient deformation, may be null (means identity)
171  *
172  * @return the drawing status.
173  */
174 DRAWING_Status VG_DRAWING_drawStringOnCircleGradient(MICROUI_GraphicsContext *gc, jchar *text, jint length,
175  jint faceHandle, jfloat size, jfloat *matrix, jint alpha,
176  jint blend, jfloat letterSpacing, jfloat radius, jint direction,
177  jint *gradientData, jfloat *gradientMatrix);
178 
179 /*
180  * @brief Draws an image with transformation and opacity. Optionally apply an animation and / or a color filtering.
181  *
182  * @param[in] gc the graphics context to draw on
183  * @param[in] image the image to draw
184  * @param[in] matrix the transformation matrix to apply
185  * @param[in] alpha the global opacity rendering value
186  * @param[in] elapsedTime the elapsed time since the beginning of the animation, in milliseconds
187  * @param[in] colorMatrix the color matrix used to transform colors, may be null (means no color deformation)
188  * @param[out] errno the error code to return to MicroVG.
189  *
190  * @return the drawing status.
191  */
192 DRAWING_Status VG_DRAWING_drawImage(MICROUI_GraphicsContext *gc, void *image, jfloat *matrix, jint alpha, jlong elapsed,
193  const float color_matrix[], jint *errno);
194 
195 // --------------------------------------------------------------------------------
196 // EOF
197 // --------------------------------------------------------------------------------
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 #endif // VG_DRAWING_H