microui  1.0.3
microui
LLDW_PAINTER_impl.c
Go to the documentation of this file.
1 
2 /*
3  * Copyright 2020 MicroEJ Corp. All rights reserved.
4  * This library is provided in source code for use, modification and test, subject to license terms.
5  * Any modification of the source code will break MicroEJ Corp. warranties on the whole library.
6  */
7 
17 // --------------------------------------------------------------------------------
18 // Includes
19 // --------------------------------------------------------------------------------
20 
21 // implements LLDW_PAINTER_impl functions
22 #include "LLDW_PAINTER_impl.h"
23 
24 // calls dw_drawing functions
25 #include "dw_drawing.h"
26 
27 // use graphical engine functions to synchronize drawings
28 #include "LLUI_DISPLAY.h"
29 
30 // --------------------------------------------------------------------------------
31 // Macros and Defines
32 // --------------------------------------------------------------------------------
33 
34 // macros to log a drawing
35 #define LOG_DRAW_START(fn) LLUI_DISPLAY_logDrawingStart(CONCAT_DEFINES(LOG_DRAW_, fn))
36 #define LOG_DRAW_END(fn) LLUI_DISPLAY_logDrawingEnd(CONCAT_DEFINES(LOG_DRAW_, fn))
37 
38 #define DRAWING_PAINTER_NATIVE_NAME(fn) (CONCAT_DEFINES(DRAWING_PAINTER_NATIVE_PREFIX, fn))
39 
40 /*
41  * LOG_DRAW_EVENT logs identifiers
42  */
43 #define LOG_DRAW_drawThickFadedPoint 100
44 #define LOG_DRAW_drawThickFadedLine 101
45 #define LOG_DRAW_drawThickFadedCircle 102
46 #define LOG_DRAW_drawThickFadedCircleArc 103
47 #define LOG_DRAW_drawThickFadedEllipse 104
48 #define LOG_DRAW_drawThickLine 105
49 #define LOG_DRAW_drawThickCircle 106
50 #define LOG_DRAW_drawThickEllipse 107
51 #define LOG_DRAW_drawThickCircleArc 108
52 
53 #define LOG_DRAW_drawFlippedImage 200
54 #define LOG_DRAW_drawRotatedImageNearestNeighbor 201
55 #define LOG_DRAW_drawRotatedImageBilinear 202
56 #define LOG_DRAW_drawScaledImageNearestNeighbor 203
57 #define LOG_DRAW_drawScaledImageBilinear 204
58 
59 // --------------------------------------------------------------------------------
60 // MicroUI Extended native functions
61 // --------------------------------------------------------------------------------
62 
63 void DRAWING_PAINTER_NATIVE(drawThickFadedPoint, MICROUI_GraphicsContext* gc, jint x, jint y, jint thickness, jint fade)
64 {
65  if (LLUI_DISPLAY_requestDrawing(gc, (SNI_callback)&DRAWING_PAINTER_NATIVE_NAME(drawThickFadedPoint)))
66  {
67  LOG_DRAW_START(drawThickFadedPoint);
68  LLUI_DISPLAY_setDrawingStatus(DW_DRAWING_drawThickFadedPoint(gc, x, y, thickness, fade));
69  LOG_DRAW_END(drawThickFadedPoint);
70  }
71 }
72 
73 void DRAWING_PAINTER_NATIVE(drawThickFadedLine, MICROUI_GraphicsContext* gc, jint startX, jint startY, jint endX, jint endY, jint thickness, jint fade, DRAWING_Cap startCap, DRAWING_Cap endCap)
74 {
75  if (LLUI_DISPLAY_requestDrawing(gc, (SNI_callback)&DRAWING_PAINTER_NATIVE_NAME(drawThickFadedLine)))
76  {
77  LOG_DRAW_START(drawThickFadedLine);
78  LLUI_DISPLAY_setDrawingStatus(DW_DRAWING_drawThickFadedLine(gc, startX, startY, endX, endY, thickness, fade, startCap, endCap));
79  LOG_DRAW_END(drawThickFadedLine);
80  }
81 }
82 
83 void DRAWING_PAINTER_NATIVE(drawThickFadedCircle, MICROUI_GraphicsContext* gc, jint x, jint y, jint diameter, jint thickness, jint fade)
84 {
85  if (diameter > 0 && LLUI_DISPLAY_requestDrawing(gc, (SNI_callback)&DRAWING_PAINTER_NATIVE_NAME(drawThickFadedCircle)))
86  {
87  LOG_DRAW_START(drawThickFadedCircle);
88  LLUI_DISPLAY_setDrawingStatus(DW_DRAWING_drawThickFadedCircle(gc, x, y, diameter, thickness, fade));
89  LOG_DRAW_END(drawThickFadedCircle);
90  }
91 }
92 
93 void DRAWING_PAINTER_NATIVE(drawThickFadedCircleArc, MICROUI_GraphicsContext* gc, jint x, jint y, jint diameter, jfloat startAngle, jfloat arcAngle, jint thickness, jint fade, DRAWING_Cap start, DRAWING_Cap end)
94 {
95  if (diameter > 0 && (int32_t)arcAngle != 0 && LLUI_DISPLAY_requestDrawing(gc, (SNI_callback)&DRAWING_PAINTER_NATIVE_NAME(drawThickFadedCircleArc)))
96  {
97  LOG_DRAW_START(drawThickFadedCircleArc);
98  LLUI_DISPLAY_setDrawingStatus(DW_DRAWING_drawThickFadedCircleArc(gc, x, y, diameter, startAngle, arcAngle, thickness, fade, start, end));
99  LOG_DRAW_END(drawThickFadedCircleArc);
100  }
101 }
102 
103 void DRAWING_PAINTER_NATIVE(drawThickFadedEllipse, MICROUI_GraphicsContext* gc, jint x, jint y, jint width, jint height, jint thickness, jint fade)
104 {
105  if (width > 0 && height > 0 && LLUI_DISPLAY_requestDrawing(gc, (SNI_callback)&DRAWING_PAINTER_NATIVE_NAME(drawThickFadedEllipse)))
106  {
107  LOG_DRAW_START(drawThickFadedEllipse);
108  LLUI_DISPLAY_setDrawingStatus(DW_DRAWING_drawThickFadedEllipse(gc, x, y, width, height, thickness, fade));
109  LOG_DRAW_END(drawThickFadedEllipse);
110  }
111 }
112 
113 void DRAWING_PAINTER_NATIVE(drawThickLine, MICROUI_GraphicsContext* gc, jint startX, jint startY, jint endX, jint endY, jint thickness)
114 {
115  if (LLUI_DISPLAY_requestDrawing(gc, (SNI_callback)&DRAWING_PAINTER_NATIVE_NAME(drawThickLine)))
116  {
117  LOG_DRAW_START(drawThickLine);
118  LLUI_DISPLAY_setDrawingStatus(DW_DRAWING_drawThickLine(gc, startX, startY, endX, endY, thickness));
119  LOG_DRAW_END(drawThickLine);
120  }
121 }
122 
123 void DRAWING_PAINTER_NATIVE(drawThickCircle, MICROUI_GraphicsContext* gc, jint x, jint y, jint diameter, jint thickness)
124 {
125  if (diameter > 0 && LLUI_DISPLAY_requestDrawing(gc, (SNI_callback)&DRAWING_PAINTER_NATIVE_NAME(drawThickCircle)))
126  {
127  LOG_DRAW_START(drawThickCircle);
128  LLUI_DISPLAY_setDrawingStatus(DW_DRAWING_drawThickCircle(gc, x, y, diameter, thickness));
129  LOG_DRAW_END(drawThickCircle);
130  }
131 }
132 
133 void DRAWING_PAINTER_NATIVE(drawThickEllipse, MICROUI_GraphicsContext* gc, jint x, jint y, jint width, jint height, jint thickness)
134 {
135  if (width > 0 && height > 0 && LLUI_DISPLAY_requestDrawing(gc, (SNI_callback)&DRAWING_PAINTER_NATIVE_NAME(drawThickEllipse)))
136  {
137  LOG_DRAW_START(drawThickEllipse);
138  LLUI_DISPLAY_setDrawingStatus(DW_DRAWING_drawThickEllipse(gc, x, y, width, height, thickness));
139  LOG_DRAW_END(drawThickEllipse);
140  }
141 }
142 
143 void DRAWING_PAINTER_NATIVE(drawThickCircleArc, MICROUI_GraphicsContext* gc, jint x, jint y, jint diameter, jfloat startAngle, jfloat arcAngle, jint thickness)
144 {
145  if (diameter > 0 && (int32_t)arcAngle != 0 && LLUI_DISPLAY_requestDrawing(gc, (SNI_callback)&DRAWING_PAINTER_NATIVE_NAME(drawThickCircleArc)))
146  {
147  LOG_DRAW_START(drawThickCircleArc);
148  LLUI_DISPLAY_setDrawingStatus(DW_DRAWING_drawThickCircleArc(gc, x, y, diameter, startAngle, arcAngle, thickness));
149  LOG_DRAW_END(drawThickCircleArc);
150  }
151 }
152 
153 void DRAWING_PAINTER_NATIVE(drawFlippedImage, MICROUI_GraphicsContext* gc, MICROUI_Image* img, jint regionX, jint regionY, jint width, jint height, jint x, jint y, DRAWING_Flip transformation, jint alpha)
154 {
155  if (!LLUI_DISPLAY_isClosed(img) && alpha > 0 && LLUI_DISPLAY_requestDrawing(gc, (SNI_callback)&DRAWING_PAINTER_NATIVE_NAME(drawFlippedImage)))
156  {
157  LOG_DRAW_START(drawFlippedImage);
158  LLUI_DISPLAY_setDrawingStatus(DW_DRAWING_drawFlippedImage(gc, img, regionX, regionY, width, height, x, y, transformation, alpha));
159  LOG_DRAW_END(drawFlippedImage);
160  }
161 }
162 
163 void DRAWING_PAINTER_NATIVE(drawRotatedImageNearestNeighbor, MICROUI_GraphicsContext* gc, MICROUI_Image* img, jint x, jint y, jint rotationX, jint rotationY, jfloat angle, jint alpha)
164 {
165  if (!LLUI_DISPLAY_isClosed(img) && alpha > 0 && LLUI_DISPLAY_requestDrawing(gc, (SNI_callback)&DRAWING_PAINTER_NATIVE_NAME(drawRotatedImageNearestNeighbor)))
166  {
167  LOG_DRAW_START(drawRotatedImageNearestNeighbor);
168  LLUI_DISPLAY_setDrawingStatus(DW_DRAWING_drawRotatedImageNearestNeighbor(gc, img, x, y, rotationX, rotationY, angle, alpha));
169  LOG_DRAW_END(drawRotatedImageNearestNeighbor);
170  }
171 }
172 
173 void DRAWING_PAINTER_NATIVE(drawRotatedImageBilinear, MICROUI_GraphicsContext* gc, MICROUI_Image* img, jint x, jint y, jint rotationX, jint rotationY, jfloat angle, jint alpha)
174 {
175  if (!LLUI_DISPLAY_isClosed(img) && alpha > 0 && LLUI_DISPLAY_requestDrawing(gc, (SNI_callback)&DRAWING_PAINTER_NATIVE_NAME(drawRotatedImageBilinear)))
176  {
177  LOG_DRAW_START(drawRotatedImageBilinear);
178  LLUI_DISPLAY_setDrawingStatus(DW_DRAWING_drawRotatedImageBilinear(gc, img, x, y, rotationX, rotationY, angle, alpha));
179  LOG_DRAW_END(drawRotatedImageBilinear);
180  }
181 }
182 
183 void DRAWING_PAINTER_NATIVE(drawScaledImageNearestNeighbor, MICROUI_GraphicsContext* gc, MICROUI_Image* img, jint x, jint y, jfloat factorX, jfloat factorY, jint alpha)
184 {
185  if (!LLUI_DISPLAY_isClosed(img) && alpha > 0 && LLUI_DISPLAY_requestDrawing(gc, (SNI_callback)&DRAWING_PAINTER_NATIVE_NAME(drawScaledImageNearestNeighbor)))
186  {
187  LOG_DRAW_START(drawScaledImageNearestNeighbor);
188  LLUI_DISPLAY_setDrawingStatus(DW_DRAWING_drawScaledImageNearestNeighbor(gc, img, x, y, factorX, factorY, alpha));
189  LOG_DRAW_END(drawScaledImageNearestNeighbor);
190  }
191 }
192 
193 void DRAWING_PAINTER_NATIVE(drawScaledImageBilinear, MICROUI_GraphicsContext* gc, MICROUI_Image* img, jint x, jint y, jfloat factorX, jfloat factorY, jint alpha)
194 {
195  if (!LLUI_DISPLAY_isClosed(img) && alpha > 0 && LLUI_DISPLAY_requestDrawing(gc, (SNI_callback)&DRAWING_PAINTER_NATIVE_NAME(drawScaledImageBilinear)))
196  {
197  LOG_DRAW_START(drawScaledImageBilinear);
198  LLUI_DISPLAY_setDrawingStatus(DW_DRAWING_drawScaledImageBilinear(gc, img, x, y, factorX, factorY, alpha));
199  LOG_DRAW_END(drawScaledImageBilinear);
200  }
201 }
202 
203 // --------------------------------------------------------------------------------
204 // EOF
205 // --------------------------------------------------------------------------------
206