microvg  6.0.1
microvg
ui_drawing_bvi.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 UI_DRAWING_BVI_H
7 #define UI_DRAWING_BVI_H
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 /*
13  * @file
14  * @brief Implementation of a set of ui_drawing.h drawing functions (MicroUI and
15  * Drawing libraries). These are implementations over a BufferedVectorImage and
16  * the destination buffer format is the BufferedVectorImage format. When the drawing
17  * cannot be performed for any reason, the stub implementation is used instead.
18  * @author MicroEJ Developer Team
19  * @version 6.0.1
20  */
21 
22 #include "vg_configuration.h"
23 #if defined VG_FEATURE_BUFFERED_VECTOR_IMAGE
24 
25 // --------------------------------------------------------------------------------
26 // Includes
27 // --------------------------------------------------------------------------------
28 
29 #include <LLVG_BVI_impl.h>
30 
31 #include "ui_drawing.h"
32 
33 // --------------------------------------------------------------------------------
34 // Defines
35 // --------------------------------------------------------------------------------
36 
37 /*
38  * @brief Redirects all ui_drawing.h functions to the BufferedVectorImage functions
39  */
40 
41 #define UI_DRAWING_BVI_is_drawer CONCAT(UI_DRAWING_is_drawer_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
42 #define UI_DRAWING_BVI_adjustNewImageCharacteristics CONCAT(UI_DRAWING_adjustNewImageCharacteristics_, \
43  UI_DRAWING_IDENTIFIER_BVI_FORMAT)
44 #define UI_DRAWING_BVI_initializeNewImage CONCAT(UI_DRAWING_initializeNewImage_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
45 #define UI_DRAWING_BVI_freeImageResources CONCAT(UI_DRAWING_freeImageResources_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
46 
47 #define UI_DRAWING_BVI_drawLine CONCAT(UI_DRAWING_drawLine_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
48 #define UI_DRAWING_BVI_drawHorizontalLine CONCAT(UI_DRAWING_drawHorizontalLine_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
49 #define UI_DRAWING_BVI_drawVerticalLine CONCAT(UI_DRAWING_drawVerticalLine_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
50 #define UI_DRAWING_BVI_fillRectangle CONCAT(UI_DRAWING_fillRectangle_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
51 #define UI_DRAWING_BVI_drawRoundedRectangle CONCAT(UI_DRAWING_drawRoundedRectangle_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
52 #define UI_DRAWING_BVI_fillRoundedRectangle CONCAT(UI_DRAWING_fillRoundedRectangle_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
53 #define UI_DRAWING_BVI_drawCircleArc CONCAT(UI_DRAWING_drawCircleArc_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
54 #define UI_DRAWING_BVI_drawEllipseArc CONCAT(UI_DRAWING_drawEllipseArc_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
55 #define UI_DRAWING_BVI_fillCircleArc CONCAT(UI_DRAWING_fillCircleArc_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
56 #define UI_DRAWING_BVI_fillEllipseArc CONCAT(UI_DRAWING_fillEllipseArc_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
57 #define UI_DRAWING_BVI_drawEllipse CONCAT(UI_DRAWING_drawEllipse_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
58 #define UI_DRAWING_BVI_fillEllipse CONCAT(UI_DRAWING_fillEllipse_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
59 #define UI_DRAWING_BVI_drawCircle CONCAT(UI_DRAWING_drawCircle_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
60 #define UI_DRAWING_BVI_fillCircle CONCAT(UI_DRAWING_fillCircle_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
61 #define UI_DRAWING_BVI_drawImage CONCAT(UI_DRAWING_drawImage_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
62 #define UI_DRAWING_BVI_drawThickFadedPoint CONCAT(UI_DRAWING_drawThickFadedPoint_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
63 #define UI_DRAWING_BVI_drawThickFadedLine CONCAT(UI_DRAWING_drawThickFadedLine_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
64 #define UI_DRAWING_BVI_drawThickFadedCircle CONCAT(UI_DRAWING_drawThickFadedCircle_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
65 #define UI_DRAWING_BVI_drawThickFadedCircleArc CONCAT(UI_DRAWING_drawThickFadedCircleArc_, \
66  UI_DRAWING_IDENTIFIER_BVI_FORMAT)
67 #define UI_DRAWING_BVI_drawThickFadedEllipse CONCAT(UI_DRAWING_drawThickFadedEllipse_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
68 #define UI_DRAWING_BVI_drawThickLine CONCAT(UI_DRAWING_drawThickLine_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
69 #define UI_DRAWING_BVI_drawThickCircle CONCAT(UI_DRAWING_drawThickCircle_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
70 #define UI_DRAWING_BVI_drawThickEllipse CONCAT(UI_DRAWING_drawThickEllipse_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
71 #define UI_DRAWING_BVI_drawThickCircleArc CONCAT(UI_DRAWING_drawThickCircleArc_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
72 #define UI_DRAWING_BVI_drawFlippedImage CONCAT(UI_DRAWING_drawFlippedImage_, UI_DRAWING_IDENTIFIER_BVI_FORMAT)
73 #define UI_DRAWING_BVI_drawRotatedImageNearestNeighbor CONCAT(UI_DRAWING_drawRotatedImageNearestNeighbor_, \
74  UI_DRAWING_IDENTIFIER_BVI_FORMAT)
75 #define UI_DRAWING_BVI_drawRotatedImageBilinear CONCAT(UI_DRAWING_drawRotatedImageBilinear_, \
76  UI_DRAWING_IDENTIFIER_BVI_FORMAT)
77 #define UI_DRAWING_BVI_drawScaledImageNearestNeighbor CONCAT(UI_DRAWING_drawScaledImageNearestNeighbor_, \
78  UI_DRAWING_IDENTIFIER_BVI_FORMAT)
79 #define UI_DRAWING_BVI_drawScaledImageBilinear CONCAT(UI_DRAWING_drawScaledImageBilinear_, \
80  UI_DRAWING_IDENTIFIER_BVI_FORMAT)
81 
82 // --------------------------------------------------------------------------------
83 // ui_drawing.h API
84 // (the function names differ according to the available number of destination formats)
85 // --------------------------------------------------------------------------------
86 
87 /*
88  * @brief Implementation of adjustNewImageCharacteristics for a BufferedVectorImage. See ui_drawing.h
89  */
90 void UI_DRAWING_BVI_adjustNewImageCharacteristics(jbyte image_format, uint32_t width, uint32_t height,
91  uint32_t *data_size, uint32_t *data_alignment);
92 
93 /*
94  * @brief Implementation of initializeNewImage for a BufferedVectorImage. See ui_drawing.h
95  */
96 void UI_DRAWING_BVI_initializeNewImage(MICROUI_Image *image);
97 
98 /*
99  * @brief Implementation of freeImageResources for a BufferedVectorImage. See ui_drawing.h
100  */
101 void UI_DRAWING_BVI_freeImageResources(MICROUI_Image *image);
102 
103 /*
104  * @brief Implementation of drawLine over a BufferedVectorImage. See ui_drawing.h
105  */
106 DRAWING_Status UI_DRAWING_BVI_drawLine(MICROUI_GraphicsContext *gc, jint startX, jint startY, jint endX, jint endY);
107 
108 /*
109  * @brief Implementation of drawHorizontalLine over a BufferedVectorImage. See ui_drawing.h
110  */
111 DRAWING_Status UI_DRAWING_BVI_drawHorizontalLine(MICROUI_GraphicsContext *gc, jint x1, jint x2, jint y);
112 
113 /*
114  * @brief Implementation of drawVerticalLine over a BufferedVectorImage. See ui_drawing.h
115  */
116 DRAWING_Status UI_DRAWING_BVI_drawVerticalLine(MICROUI_GraphicsContext *gc, jint x, jint y1, jint y2);
117 
118 /*
119  * @brief Implementation of fillRectangle over a BufferedVectorImage. See ui_drawing.h
120  */
121 DRAWING_Status UI_DRAWING_BVI_fillRectangle(MICROUI_GraphicsContext *gc, jint x1, jint y1, jint x2, jint y2);
122 
123 /*
124  * @brief Implementation of drawRoundedRectangle over a BufferedVectorImage. See ui_drawing.h
125  */
126 DRAWING_Status UI_DRAWING_BVI_drawRoundedRectangle(MICROUI_GraphicsContext *gc, jint x, jint y, jint width, jint height,
127  jint cornerEllipseWidth, jint cornerEllipseHeight);
128 
129 /*
130  * @brief Implementation of fillRoundedRectangle over a BufferedVectorImage. See ui_drawing.h
131  */
132 DRAWING_Status UI_DRAWING_BVI_fillRoundedRectangle(MICROUI_GraphicsContext *gc, jint x, jint y, jint width, jint height,
133  jint cornerEllipseWidth, jint cornerEllipseHeight);
134 
135 /*
136  * @brief Implementation of drawCircleArc over a BufferedVectorImage. See ui_drawing.h
137  */
138 DRAWING_Status UI_DRAWING_BVI_drawCircleArc(MICROUI_GraphicsContext *gc, jint x, jint y, jint diameter,
139  jfloat startAngle, jfloat arcAngle);
140 
141 /*
142  * @brief Implementation of drawEllipseArc over a BufferedVectorImage. See ui_drawing.h
143  */
144 DRAWING_Status UI_DRAWING_BVI_drawEllipseArc(MICROUI_GraphicsContext *gc, jint x, jint y, jint width, jint height,
145  jfloat startAngle, jfloat arcAngle);
146 
147 /*
148  * @brief Implementation of fillCircleArc over a BufferedVectorImage. See ui_drawing.h
149  */
150 DRAWING_Status UI_DRAWING_BVI_fillCircleArc(MICROUI_GraphicsContext *gc, jint x, jint y, jint diameter,
151  jfloat startAngle, jfloat arcAngle);
152 
153 /*
154  * @brief Implementation of fillEllipseArc over a BufferedVectorImage. See ui_drawing.h
155  */
156 DRAWING_Status UI_DRAWING_BVI_fillEllipseArc(MICROUI_GraphicsContext *gc, jint x, jint y, jint width, jint height,
157  jfloat startAngle, jfloat arcAngle);
158 
159 /*
160  * @brief Implementation of drawEllipse over a BufferedVectorImage. See ui_drawing.h
161  */
162 DRAWING_Status UI_DRAWING_BVI_drawEllipse(MICROUI_GraphicsContext *gc, jint x, jint y, jint width, jint height);
163 
164 /*
165  * @brief Implementation of fillEllipse over a BufferedVectorImage. See ui_drawing.h
166  */
167 DRAWING_Status UI_DRAWING_BVI_fillEllipse(MICROUI_GraphicsContext *gc, jint x, jint y, jint width, jint height);
168 
169 /*
170  * @brief Implementation of drawCircle over a BufferedVectorImage. See ui_drawing.h
171  */
172 DRAWING_Status UI_DRAWING_BVI_drawCircle(MICROUI_GraphicsContext *gc, jint x, jint y, jint diameter);
173 
174 /*
175  * @brief Implementation of fillCircle over a BufferedVectorImage. See ui_drawing.h
176  */
177 DRAWING_Status UI_DRAWING_BVI_fillCircle(MICROUI_GraphicsContext *gc, jint x, jint y, jint diameter);
178 
179 /*
180  * @brief Implementation of drawImage over a BufferedVectorImage. See ui_drawing.h
181  */
182 DRAWING_Status UI_DRAWING_BVI_drawImage(MICROUI_GraphicsContext *gc, MICROUI_Image *img, jint regionX, jint regionY,
183  jint width, jint height, jint x, jint y, jint alpha);
184 
185 /*
186  * @brief Implementation of copyImage over a BufferedVectorImage. See ui_drawing.h
187  */
188 DRAWING_Status UI_DRAWING_BVI_copyImage(MICROUI_GraphicsContext *gc, MICROUI_Image *img, jint regionX, jint regionY,
189  jint width, jint height, jint x, jint y);
190 
191 /*
192  * @brief Implementation of drawRegion over a BufferedVectorImage. See ui_drawing.h
193  */
194 DRAWING_Status UI_DRAWING_BVI_drawRegion(MICROUI_GraphicsContext *gc, jint regionX, jint regionY, jint width,
195  jint height, jint x, jint y, jint alpha);
196 
197 /*
198  * @brief Implementation of drawThickFadedPoint over a BufferedVectorImage. See ui_drawing.h
199  */
200 DRAWING_Status UI_DRAWING_BVI_drawThickFadedPoint(MICROUI_GraphicsContext *gc, jint x, jint y, jint thickness,
201  jint fade);
202 
203 /*
204  * @brief Implementation of drawThickFadedLine over a BufferedVectorImage. See ui_drawing.h
205  */
206 DRAWING_Status UI_DRAWING_BVI_drawThickFadedLine(MICROUI_GraphicsContext *gc, jint startX, jint startY, jint endX,
207  jint endY, jint thickness, jint fade, DRAWING_Cap startCap,
208  DRAWING_Cap endCap);
209 
210 /*
211  * @brief Implementation of drawThickFadedCircle over a BufferedVectorImage. See ui_drawing.h
212  */
213 DRAWING_Status UI_DRAWING_BVI_drawThickFadedCircle(MICROUI_GraphicsContext *gc, jint x, jint y, jint diameter,
214  jint thickness, jint fade);
215 
216 /*
217  * @brief Implementation of drawThickFadedCircleArc over a BufferedVectorImage. See ui_drawing.h
218  */
219 DRAWING_Status UI_DRAWING_BVI_drawThickFadedCircleArc(MICROUI_GraphicsContext *gc, jint x, jint y, jint diameter,
220  jfloat startAngle, jfloat arcAngle, jint thickness, jint fade,
221  DRAWING_Cap start, DRAWING_Cap end);
222 
223 /*
224  * @brief Implementation of drawThickFadedEllipse over a BufferedVectorImage. See ui_drawing.h
225  */
226 DRAWING_Status UI_DRAWING_BVI_drawThickFadedEllipse(MICROUI_GraphicsContext *gc, jint x, jint y, jint width,
227  jint height, jint thickness, jint fade);
228 
229 /*
230  * @brief Implementation of drawThickLine over a BufferedVectorImage. See ui_drawing.h
231  */
232 DRAWING_Status UI_DRAWING_BVI_drawThickLine(MICROUI_GraphicsContext *gc, jint startX, jint startY, jint endX, jint endY,
233  jint thickness);
234 
235 /*
236  * @brief Implementation of drawThickCircle over a BufferedVectorImage. See ui_drawing.h
237  */
238 DRAWING_Status UI_DRAWING_BVI_drawThickCircle(MICROUI_GraphicsContext *gc, jint x, jint y, jint diameter,
239  jint thickness);
240 
241 /*
242  * @brief Implementation of drawThickEllipse over a BufferedVectorImage. See ui_drawing.h
243  */
244 DRAWING_Status UI_DRAWING_BVI_drawThickEllipse(MICROUI_GraphicsContext *gc, jint x, jint y, jint width, jint height,
245  jint thickness);
246 
247 /*
248  * @brief Implementation of drawThickCircleArc over a BufferedVectorImage. See ui_drawing.h
249  */
250 DRAWING_Status UI_DRAWING_BVI_drawThickCircleArc(MICROUI_GraphicsContext *gc, jint x, jint y, jint diameter,
251  jfloat startAngle, jfloat arcAngle, jint thickness);
252 
253 /*
254  * @brief Implementation of drawFlippedImage over a BufferedVectorImage. See ui_drawing.h
255  */
256 DRAWING_Status UI_DRAWING_BVI_drawFlippedImage(MICROUI_GraphicsContext *gc, MICROUI_Image *img, jint regionX,
257  jint regionY, jint width, jint height, jint x, jint y,
258  DRAWING_Flip transformation, jint alpha);
259 
260 /*
261  * @brief Implementation of drawRotatedImageNearestNeighbor over a BufferedVectorImage. See ui_drawing.h
262  */
263 DRAWING_Status UI_DRAWING_BVI_drawRotatedImageNearestNeighbor(MICROUI_GraphicsContext *gc, MICROUI_Image *img, jint x,
264  jint y, jint rotationX, jint rotationY, jfloat angle,
265  jint alpha);
266 
267 /*
268  * @brief Implementation of drawRotatedImageBilinear over a BufferedVectorImage. See ui_drawing.h
269  */
270 DRAWING_Status UI_DRAWING_BVI_drawRotatedImageBilinear(MICROUI_GraphicsContext *gc, MICROUI_Image *img, jint x, jint y,
271  jint rotationX, jint rotationY, jfloat angle, jint alpha);
272 
273 /*
274  * @brief Implementation of drawScaledImageNearestNeighbor over a BufferedVectorImage. See ui_drawing.h
275  */
276 DRAWING_Status UI_DRAWING_BVI_drawScaledImageNearestNeighbor(MICROUI_GraphicsContext *gc, MICROUI_Image *img, jint x,
277  jint y, jfloat factorX, jfloat factorY, jint alpha);
278 
279 /*
280  * @brief Implementation of drawScaledImageBilinear over a BufferedVectorImage. See ui_drawing.h
281  */
282 DRAWING_Status UI_DRAWING_BVI_drawScaledImageBilinear(MICROUI_GraphicsContext *gc, MICROUI_Image *img, jint x, jint y,
283  jfloat factorX, jfloat factorY, jint alpha);
284 
285 // --------------------------------------------------------------------------------
286 // EOF
287 // --------------------------------------------------------------------------------
288 
289 #endif // #if defined VG_FEATURE_BUFFERED_VECTOR_IMAGE
290 
291 #ifdef __cplusplus
292 }
293 #endif
294 #endif // UI_DRAWING_BVI_H
MicroEJ MicroVG library low level API: enable some features according to the hardware capacities.