1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* |
4 |
|
|
* This program and the accompanying materials are made available under the |
5 |
|
|
* terms of the MIT License which is available at |
6 |
|
|
* https://opensource.org/licenses/MIT. |
7 |
|
|
* |
8 |
|
|
* SPDX-License-Identifier: MIT |
9 |
|
|
**************************************************************************/ |
10 |
|
|
|
11 |
|
|
|
12 |
|
|
/**************************************************************************/ |
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/** */ |
15 |
|
|
/** GUIX Component */ |
16 |
|
|
/** */ |
17 |
|
|
/** Display Management (Display) */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
|
21 |
|
|
#define GX_SOURCE_CODE |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
/* Include necessary system files. */ |
25 |
|
|
|
26 |
|
|
#include "gx_api.h" |
27 |
|
|
#include "gx_system.h" |
28 |
|
|
#include "gx_utility.h" |
29 |
|
|
#include "gx_display.h" |
30 |
|
|
#include "gx_canvas.h" |
31 |
|
|
|
32 |
|
|
#if defined(GX_ARC_DRAWING_SUPPORT) |
33 |
|
|
/**************************************************************************/ |
34 |
|
|
/* */ |
35 |
|
|
/* FUNCTION RELEASE */ |
36 |
|
|
/* */ |
37 |
|
|
/* _gx_display_driver_generic_simple_wide_arc_draw PORTABLE C */ |
38 |
|
|
/* 6.1 */ |
39 |
|
|
/* AUTHOR */ |
40 |
|
|
/* */ |
41 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
42 |
|
|
/* */ |
43 |
|
|
/* DESCRIPTION */ |
44 |
|
|
/* */ |
45 |
|
|
/* Innner help function that draw a wide arc between [90, 180] or */ |
46 |
|
|
/* [270, 540]. */ |
47 |
|
|
/* */ |
48 |
|
|
/* INPUT */ |
49 |
|
|
/* */ |
50 |
|
|
/* context Drawing context */ |
51 |
|
|
/* xcenter x-coord of center of circle */ |
52 |
|
|
/* ycenter y-coord of center of circle */ |
53 |
|
|
/* r Radius of circle */ |
54 |
|
|
/* */ |
55 |
|
|
/* OUTPUT */ |
56 |
|
|
/* */ |
57 |
|
|
/* None */ |
58 |
|
|
/* */ |
59 |
|
|
/* CALLS */ |
60 |
|
|
/* */ |
61 |
|
|
/* _gx_display_driver_arc_clipping_get Get an arc clipping. */ |
62 |
|
|
/* _gx_utility_rectangle_point_detect Detect whether a pixel is */ |
63 |
|
|
/* inside rectangle */ |
64 |
|
|
/* [gx_display_driver_line_draw] The generic display driver */ |
65 |
|
|
/* line drawing routine */ |
66 |
|
|
/* _gx_utility_circle_point_get Get point coord on a circle */ |
67 |
|
|
/* */ |
68 |
|
|
/* CALLED BY */ |
69 |
|
|
/* */ |
70 |
|
|
/* _gx_display_driver_generic_wide_arc_draw */ |
71 |
|
|
/* */ |
72 |
|
|
/* RELEASE HISTORY */ |
73 |
|
|
/* */ |
74 |
|
|
/* DATE NAME DESCRIPTION */ |
75 |
|
|
/* */ |
76 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
77 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
78 |
|
|
/* resulting in version 6.1 */ |
79 |
|
|
/* */ |
80 |
|
|
/**************************************************************************/ |
81 |
|
2656 |
static VOID _gx_display_driver_generic_simple_wide_arc_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle) |
82 |
|
|
{ |
83 |
|
|
/* The function draw a wide arc between 90 and 270 or beween 270 and 450.*/ |
84 |
|
|
GX_DISPLAY *display; |
85 |
|
|
GX_BRUSH *brush; |
86 |
|
|
GX_RECTANGLE *clip; |
87 |
|
|
GX_RECTANGLE arc_clip[4]; |
88 |
|
|
GX_POINT point; |
89 |
|
|
GX_POINT inner_start; |
90 |
|
|
GX_POINT inner_end; |
91 |
|
|
GX_POINT outer_start; |
92 |
|
|
GX_POINT outer_end; |
93 |
|
2656 |
INT sign[4][2] = {{1, 1}, {-1, 1}, {1, -1}, {-1, -1}}; |
94 |
|
|
INT *pLineEnds; |
95 |
|
|
INT ymin; |
96 |
|
|
INT ymax; |
97 |
|
|
INT xstart; |
98 |
|
|
INT xend; |
99 |
|
|
INT ystart; |
100 |
|
|
INT yend; |
101 |
|
|
INT curx; |
102 |
|
|
INT cury; |
103 |
|
|
INT nextx; |
104 |
|
|
INT nexty; |
105 |
|
|
INT dx; |
106 |
|
|
INT dy; |
107 |
|
|
INT Index; |
108 |
|
|
INT Index1; |
109 |
|
|
INT loop; |
110 |
|
|
INT height; |
111 |
|
|
INT xsign; |
112 |
|
|
INT ysign; |
113 |
|
|
INT decision; |
114 |
|
|
INT brush_width; |
115 |
|
|
VOID (*line_draw)(GX_DRAW_CONTEXT *context, INT x1, INT x2, INT ypos, INT width, GX_COLOR color); |
116 |
|
|
|
117 |
|
|
|
118 |
|
2656 |
display = context -> gx_draw_context_display; |
119 |
|
2656 |
brush = &context -> gx_draw_context_brush; |
120 |
|
2656 |
brush_width = brush -> gx_brush_width; |
121 |
|
2656 |
line_draw = display -> gx_display_driver_horizontal_line_draw; |
122 |
|
|
|
123 |
✓✓ |
2656 |
if (r <= (UINT)((brush_width - 1) >> 1)) |
124 |
|
|
{ |
125 |
|
546 |
return; |
126 |
|
|
} |
127 |
|
|
|
128 |
|
2110 |
clip = context -> gx_draw_context_clip; |
129 |
|
2110 |
pLineEnds = _gx_system_scratchpad; |
130 |
|
|
|
131 |
|
2110 |
ymin = ycenter - (INT)r - (brush_width >> 1); |
132 |
|
2110 |
ymax = ycenter + (INT)r + (brush_width >> 1); |
133 |
|
|
|
134 |
|
|
/* Get end points. */ |
135 |
|
2110 |
_gx_utility_circle_point_get(xcenter, ycenter, r - (UINT)((brush_width - 1) >> 1), start_angle, &inner_start); |
136 |
|
2110 |
_gx_utility_circle_point_get(xcenter, ycenter, r - (UINT)((brush_width - 1) >> 1), end_angle, &inner_end); |
137 |
|
2110 |
_gx_utility_circle_point_get(xcenter, ycenter, r + (UINT)(brush_width >> 1), start_angle, &outer_start); |
138 |
|
2110 |
_gx_utility_circle_point_get(xcenter, ycenter, r + (UINT)(brush_width >> 1), end_angle, &outer_end); |
139 |
|
|
|
140 |
✓✓✓✓ ✓✓ |
2110 |
if (((start_angle < 90) && (end_angle < 90)) || |
141 |
✓✓ |
1092 |
((start_angle > 90) && (end_angle < 450))) |
142 |
|
|
{ |
143 |
✓✓ |
918 |
if (outer_start.gx_point_y < outer_end.gx_point_y) |
144 |
|
|
{ |
145 |
|
283 |
ymin = outer_start.gx_point_y; |
146 |
|
|
} |
147 |
|
|
else |
148 |
|
|
{ |
149 |
|
635 |
ymin = outer_end.gx_point_y; |
150 |
|
|
} |
151 |
|
|
|
152 |
✓✓ |
918 |
if (inner_start.gx_point_y < ymin) |
153 |
|
|
{ |
154 |
|
325 |
ymin = inner_start.gx_point_y; |
155 |
|
|
} |
156 |
|
|
|
157 |
✓✓ |
918 |
if (inner_end.gx_point_y < ymin) |
158 |
|
|
{ |
159 |
|
227 |
ymin = inner_end.gx_point_y; |
160 |
|
|
} |
161 |
|
|
} |
162 |
|
|
|
163 |
✓✓ |
2110 |
if (clip -> gx_rectangle_top > ymin) |
164 |
|
|
{ |
165 |
|
72 |
ymin = clip -> gx_rectangle_top; |
166 |
|
|
} |
167 |
|
|
|
168 |
|
|
/* Calculate maximum y line. */ |
169 |
✓✓✓✓ ✓✓ |
2110 |
if (((start_angle < 270) && (end_angle < 270)) || (start_angle > 270)) |
170 |
|
|
{ |
171 |
✓✓ |
1277 |
if (outer_start.gx_point_y > outer_end.gx_point_y) |
172 |
|
|
{ |
173 |
|
936 |
ymax = outer_start.gx_point_y; |
174 |
|
|
} |
175 |
|
|
else |
176 |
|
|
{ |
177 |
|
341 |
ymax = outer_end.gx_point_y; |
178 |
|
|
} |
179 |
|
|
|
180 |
✓✓ |
1277 |
if (inner_start.gx_point_y > ymax) |
181 |
|
|
{ |
182 |
|
528 |
ymax = inner_start.gx_point_y; |
183 |
|
|
} |
184 |
|
|
|
185 |
✓✓ |
1277 |
if (inner_end.gx_point_y > ymax) |
186 |
|
|
{ |
187 |
|
107 |
ymax = inner_end.gx_point_y; |
188 |
|
|
} |
189 |
|
|
} |
190 |
|
|
|
191 |
✓✓ |
2110 |
if (clip -> gx_rectangle_bottom < ymax) |
192 |
|
|
{ |
193 |
|
141 |
ymax = clip -> gx_rectangle_bottom; |
194 |
|
|
} |
195 |
|
|
|
196 |
|
2110 |
height = ymax - ymin + 1; |
197 |
|
|
|
198 |
|
|
/* default the point array to being off the screen on both sides: */ |
199 |
|
|
|
200 |
✓✓ |
246375 |
for (loop = 0; loop < height * 2; loop += 2) |
201 |
|
|
{ |
202 |
|
244265 |
pLineEnds[loop] = 2000; |
203 |
|
244265 |
pLineEnds[loop + 1] = 0; |
204 |
|
|
} |
205 |
|
|
|
206 |
|
2110 |
r = (UINT)(r - (UINT)((brush_width - 1) >> 1)); |
207 |
|
|
|
208 |
|
|
/* Get point array of inner arc and outer arc. */ |
209 |
✓✓ |
6330 |
for (Index1 = 0; Index1 < 2; Index1++) |
210 |
|
|
{ |
211 |
✓✓ |
4220 |
if (Index1 == 1) |
212 |
|
|
{ |
213 |
|
2110 |
r += (UINT)(brush_width - 1); |
214 |
|
|
} |
215 |
|
|
|
216 |
|
4220 |
_gx_display_driver_arc_clipping_get(xcenter, ycenter, r, start_angle, end_angle, |
217 |
|
|
&arc_clip[0], &arc_clip[1], &arc_clip[2], &arc_clip[3]); |
218 |
|
|
|
219 |
|
4220 |
curx = 0; |
220 |
|
4220 |
cury = (INT)r; |
221 |
|
4220 |
decision = 5 - (INT)(4 * r); |
222 |
|
|
|
223 |
✓✓ |
403432 |
while (curx <= cury) |
224 |
|
|
{ |
225 |
✓✓ |
1996060 |
for (loop = 0; loop < 4; loop++) |
226 |
|
|
{ |
227 |
|
1596848 |
point.gx_point_x = (GX_VALUE)(curx * sign[loop][0] + xcenter); |
228 |
|
1596848 |
point.gx_point_y = (GX_VALUE)(cury * sign[loop][1] + ycenter); |
229 |
|
|
|
230 |
✓✓✓✓
|
1596848 |
if ((point.gx_point_y >= ymin) && (point.gx_point_y <= ymax)) |
231 |
|
|
{ |
232 |
✓✓✓✓
|
1097094 |
if (_gx_utility_rectangle_point_detect(&arc_clip[0], point) || |
233 |
|
434294 |
_gx_utility_rectangle_point_detect(&arc_clip[1], point)) |
234 |
|
|
{ |
235 |
|
315756 |
Index = (point.gx_point_y - ymin) << 1; |
236 |
✓✓ |
315756 |
if (point.gx_point_x < pLineEnds[Index]) |
237 |
|
|
{ |
238 |
|
188485 |
pLineEnds[Index] = point.gx_point_x; |
239 |
|
|
} |
240 |
|
|
|
241 |
✓✓ |
315756 |
if (point.gx_point_x > pLineEnds[Index + 1]) |
242 |
|
|
{ |
243 |
|
206488 |
pLineEnds[Index + 1] = point.gx_point_x; |
244 |
|
|
} |
245 |
|
|
} |
246 |
|
|
} |
247 |
|
|
|
248 |
|
1596848 |
point.gx_point_x = (GX_VALUE)(cury * sign[loop][0] + xcenter); |
249 |
|
1596848 |
point.gx_point_y = (GX_VALUE)(curx * sign[loop][1] + ycenter); |
250 |
|
|
|
251 |
✓✓✓✓
|
1596848 |
if ((point.gx_point_y >= ymin) && (point.gx_point_y <= ymax)) |
252 |
|
|
{ |
253 |
✓✓✓✓
|
1133181 |
if (_gx_utility_rectangle_point_detect(&arc_clip[0], point) || |
254 |
|
461901 |
_gx_utility_rectangle_point_detect(&arc_clip[1], point)) |
255 |
|
|
{ |
256 |
|
332384 |
Index = (point.gx_point_y - ymin) << 1; |
257 |
✓✓ |
332384 |
if (point.gx_point_x < pLineEnds[Index]) |
258 |
|
|
{ |
259 |
|
231464 |
pLineEnds[Index] = point.gx_point_x; |
260 |
|
|
} |
261 |
|
|
|
262 |
✓✓ |
332384 |
if (point.gx_point_x > pLineEnds[Index + 1]) |
263 |
|
|
{ |
264 |
|
251383 |
pLineEnds[Index + 1] = point.gx_point_x; |
265 |
|
|
} |
266 |
|
|
} |
267 |
|
|
} |
268 |
|
|
} |
269 |
|
|
|
270 |
✓✓ |
399212 |
if (decision < 0) |
271 |
|
|
{ |
272 |
|
231828 |
decision += 8 * curx + 12; |
273 |
|
|
} |
274 |
|
|
else |
275 |
|
|
{ |
276 |
|
167384 |
decision += 8 * (curx - cury) + 20; |
277 |
|
167384 |
cury--; |
278 |
|
|
} |
279 |
|
399212 |
curx++; |
280 |
|
|
} |
281 |
|
|
} |
282 |
|
|
|
283 |
|
|
/* Fill in the point array by using Breshenhams line for |
284 |
|
|
2 lines of the arc end. |
285 |
|
|
*/ |
286 |
|
|
|
287 |
✓✓ |
6330 |
for (loop = 0; loop < 2; loop++) |
288 |
|
|
{ |
289 |
✓✓ |
4220 |
if (loop == 0) |
290 |
|
|
{ |
291 |
|
2110 |
xstart = inner_start.gx_point_x; |
292 |
|
2110 |
ystart = inner_start.gx_point_y; |
293 |
|
2110 |
xend = outer_start.gx_point_x; |
294 |
|
2110 |
yend = outer_start.gx_point_y; |
295 |
|
|
} |
296 |
|
|
else |
297 |
|
|
{ |
298 |
|
2110 |
xstart = inner_end.gx_point_x; |
299 |
|
2110 |
ystart = inner_end.gx_point_y; |
300 |
|
2110 |
xend = outer_end.gx_point_x; |
301 |
|
2110 |
yend = outer_end.gx_point_y; |
302 |
|
|
} |
303 |
|
|
|
304 |
|
4220 |
dx = GX_ABS(xend - xstart); |
305 |
|
4220 |
dy = GX_ABS(yend - ystart); |
306 |
|
|
|
307 |
|
|
/* Horizontal Line. */ |
308 |
✓✓ |
4220 |
if (ystart == yend) |
309 |
|
|
{ |
310 |
|
156 |
continue; |
311 |
|
|
} |
312 |
|
|
|
313 |
|
|
/* Vertical Line. */ |
314 |
✓✓ |
4064 |
if (xstart == xend) |
315 |
|
|
{ |
316 |
✓✓ |
2247 |
if (ystart > yend) |
317 |
|
|
{ |
318 |
|
1245 |
GX_SWAP_VALS(xstart, xend); |
319 |
|
1245 |
GX_SWAP_VALS(ystart, yend); |
320 |
|
|
} |
321 |
|
|
|
322 |
✓✓ |
23543 |
for (cury = ystart; cury <= yend; cury++) |
323 |
|
|
{ |
324 |
✓✓✓✓
|
21296 |
if ((cury >= ymin) && (cury <= ymax)) |
325 |
|
|
{ |
326 |
|
20760 |
Index = (cury - ymin) << 1; |
327 |
✓✓ |
20760 |
if (xstart <= pLineEnds[Index]) |
328 |
|
|
{ |
329 |
|
11493 |
pLineEnds[Index] = xstart; |
330 |
|
|
} |
331 |
|
|
|
332 |
✓✓ |
20760 |
if (xstart > pLineEnds[Index + 1]) |
333 |
|
|
{ |
334 |
|
8419 |
pLineEnds[Index + 1] = xstart; |
335 |
|
|
} |
336 |
|
|
} |
337 |
|
|
} |
338 |
|
2247 |
continue; |
339 |
|
|
} |
340 |
|
|
|
341 |
|
|
/* Simple Line. */ |
342 |
|
|
|
343 |
✓✓✓✓ ✓✓ |
1817 |
if (((dx >= dy && (xstart > xend)) || |
344 |
✓✓ |
654 |
((dy > dx) && ystart > yend))) |
345 |
|
|
{ |
346 |
|
429 |
GX_SWAP_VALS(xend, xstart); |
347 |
|
429 |
GX_SWAP_VALS(yend, ystart); |
348 |
|
|
} |
349 |
|
|
|
350 |
|
1817 |
xsign = (xend - xstart) / dx; |
351 |
|
1817 |
ysign = (yend - ystart) / dy; |
352 |
|
|
|
353 |
✓✓ |
1817 |
if (dx >= dy) |
354 |
|
|
{ |
355 |
|
1163 |
for (curx = xstart, cury = ystart, nextx = xend, nexty = yend, |
356 |
✓✓ |
7170 |
decision = (dx >> 1); curx <= nextx; curx++, nextx--, |
357 |
|
6007 |
decision += dy) |
358 |
|
|
{ |
359 |
✓✓ |
6007 |
if (decision >= dx) |
360 |
|
|
{ |
361 |
|
1699 |
decision -= dx; |
362 |
|
1699 |
cury += ysign; |
363 |
|
1699 |
nexty -= ysign; |
364 |
|
|
} |
365 |
|
|
|
366 |
✓✓✓✓
|
6007 |
if ((cury >= ymin) && (cury <= ymax)) |
367 |
|
|
{ |
368 |
|
5971 |
Index = (cury - ymin) << 1; |
369 |
|
|
|
370 |
✓✓ |
5971 |
if (curx < pLineEnds[Index]) |
371 |
|
|
{ |
372 |
|
1026 |
pLineEnds[Index] = curx; |
373 |
|
|
} |
374 |
|
|
|
375 |
✓✓ |
5971 |
if (curx > pLineEnds[Index + 1]) |
376 |
|
|
{ |
377 |
|
2106 |
pLineEnds[Index + 1] = curx; |
378 |
|
|
} |
379 |
|
|
} |
380 |
|
|
|
381 |
✓✓✓✓
|
6007 |
if ((nexty >= ymin) && (nexty <= ymax)) |
382 |
|
|
{ |
383 |
|
5971 |
Index = (nexty - ymin) << 1; |
384 |
|
|
|
385 |
✓✓ |
5971 |
if (nextx < pLineEnds[Index]) |
386 |
|
|
{ |
387 |
|
1620 |
pLineEnds[Index] = nextx; |
388 |
|
|
} |
389 |
|
|
|
390 |
✓✓ |
5971 |
if (nextx > pLineEnds[Index + 1]) |
391 |
|
|
{ |
392 |
|
646 |
pLineEnds[Index + 1] = nextx; |
393 |
|
|
} |
394 |
|
|
} |
395 |
|
|
} |
396 |
|
|
} |
397 |
|
|
else |
398 |
|
|
{ |
399 |
|
654 |
for (curx = xstart, cury = ystart, nextx = xend, nexty = yend, |
400 |
✓✓ |
4519 |
decision = (dy >> 1); cury <= nexty; cury++, nexty--, |
401 |
|
3865 |
decision += dx) |
402 |
|
|
{ |
403 |
✓✓ |
3865 |
if (decision >= dy) |
404 |
|
|
{ |
405 |
|
1096 |
decision -= dy; |
406 |
|
1096 |
curx += xsign; |
407 |
|
1096 |
nextx -= xsign; |
408 |
|
|
} |
409 |
|
|
|
410 |
✓✓✓✓
|
3865 |
if ((cury >= ymin) && (cury <= ymax)) |
411 |
|
|
{ |
412 |
|
3844 |
Index = (cury - ymin) << 1; |
413 |
✓✓ |
3844 |
if (curx < pLineEnds[Index]) |
414 |
|
|
{ |
415 |
|
2001 |
pLineEnds[Index] = curx; |
416 |
|
|
} |
417 |
|
|
|
418 |
✓✓ |
3844 |
if (curx > pLineEnds[Index + 1]) |
419 |
|
|
{ |
420 |
|
1529 |
pLineEnds[Index + 1] = curx; |
421 |
|
|
} |
422 |
|
|
} |
423 |
|
|
|
424 |
|
|
|
425 |
✓✓✓✓
|
3865 |
if ((nexty >= ymin) && (nexty <= ymax)) |
426 |
|
|
{ |
427 |
|
3684 |
Index = (nexty - ymin) << 1; |
428 |
|
|
|
429 |
✓✓ |
3684 |
if (nextx < pLineEnds[Index]) |
430 |
|
|
{ |
431 |
|
1757 |
pLineEnds[Index] = nextx; |
432 |
|
|
} |
433 |
|
|
|
434 |
✓✓ |
3684 |
if (nextx > pLineEnds[Index + 1]) |
435 |
|
|
{ |
436 |
|
1450 |
pLineEnds[Index + 1] = nextx; |
437 |
|
|
} |
438 |
|
|
} |
439 |
|
|
} |
440 |
|
|
} |
441 |
|
|
} |
442 |
|
|
|
443 |
|
|
/* Filling the outline area with horizontal line. */ |
444 |
|
2110 |
Index = 0; |
445 |
✓✓ |
246375 |
for (cury = ymin; cury <= ymax; cury++) |
446 |
|
|
{ |
447 |
✓✓ |
244265 |
if (pLineEnds[Index] < pLineEnds[Index + 1]) |
448 |
|
|
{ |
449 |
✓✓ |
243637 |
if (pLineEnds[Index] < clip -> gx_rectangle_left) |
450 |
|
|
{ |
451 |
|
13451 |
pLineEnds[Index] = clip -> gx_rectangle_left; |
452 |
|
|
} |
453 |
|
|
|
454 |
✓✓ |
243637 |
if (pLineEnds[Index + 1] > clip -> gx_rectangle_right) |
455 |
|
|
{ |
456 |
|
20981 |
pLineEnds[Index + 1] = clip -> gx_rectangle_right; |
457 |
|
|
} |
458 |
|
|
|
459 |
|
243637 |
line_draw(context, pLineEnds[Index], pLineEnds[Index + 1], cury, 1, |
460 |
|
|
brush -> gx_brush_line_color); |
461 |
|
|
} |
462 |
|
|
|
463 |
|
244265 |
Index += 2; |
464 |
|
|
} |
465 |
|
|
} |
466 |
|
|
|
467 |
|
|
/**************************************************************************/ |
468 |
|
|
/* */ |
469 |
|
|
/* FUNCTION RELEASE */ |
470 |
|
|
/* */ |
471 |
|
|
/* _gx_display_driver_generic_wide_arc_draw PORTABLE C */ |
472 |
|
|
/* 6.1 */ |
473 |
|
|
/* AUTHOR */ |
474 |
|
|
/* */ |
475 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
476 |
|
|
/* */ |
477 |
|
|
/* DESCRIPTION */ |
478 |
|
|
/* */ |
479 |
|
|
/* Display driver function to draw simple circular arcle with wide */ |
480 |
|
|
/* outline. */ |
481 |
|
|
/* */ |
482 |
|
|
/* INPUT */ |
483 |
|
|
/* */ |
484 |
|
|
/* context Drawing context */ |
485 |
|
|
/* xcenter x-coord of center of circle */ |
486 |
|
|
/* ycenter y-coord of center of circle */ |
487 |
|
|
/* r Radius of circle */ |
488 |
|
|
/* */ |
489 |
|
|
/* OUTPUT */ |
490 |
|
|
/* */ |
491 |
|
|
/* None */ |
492 |
|
|
/* */ |
493 |
|
|
/* CALLS */ |
494 |
|
|
/* */ |
495 |
|
|
/* [_gx_display_driver_generic_simple_wide_arc_draw] */ |
496 |
|
|
/* Real arc draw function */ |
497 |
|
|
/* */ |
498 |
|
|
/* CALLED BY */ |
499 |
|
|
/* */ |
500 |
|
|
/* GUIX Internal Code */ |
501 |
|
|
/* */ |
502 |
|
|
/* RELEASE HISTORY */ |
503 |
|
|
/* */ |
504 |
|
|
/* DATE NAME DESCRIPTION */ |
505 |
|
|
/* */ |
506 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
507 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
508 |
|
|
/* resulting in version 6.1 */ |
509 |
|
|
/* */ |
510 |
|
|
/**************************************************************************/ |
511 |
|
1612 |
VOID _gx_display_driver_generic_wide_arc_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle) |
512 |
|
|
{ |
513 |
|
|
GX_BRUSH *brush; |
514 |
|
|
INT brush_width; |
515 |
|
|
GX_POINT startp; |
516 |
|
|
GX_POINT endp; |
517 |
|
|
GX_COLOR old_fill; |
518 |
|
|
UINT old_style; |
519 |
|
|
|
520 |
|
|
#if defined(GX_BRUSH_ALPHA_SUPPORT) |
521 |
|
|
GX_UBYTE old_alpha; |
522 |
|
1612 |
old_alpha = context -> gx_draw_context_brush.gx_brush_alpha; |
523 |
|
1612 |
context -> gx_draw_context_brush.gx_brush_alpha = GX_ALPHA_VALUE_OPAQUE; |
524 |
|
|
#endif |
525 |
|
|
|
526 |
✓✓ |
1612 |
if (start_angle < 90) |
527 |
|
|
{ |
528 |
✓✓ |
765 |
if (end_angle <= 90) |
529 |
|
|
{ |
530 |
|
502 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, start_angle, end_angle); |
531 |
|
|
} |
532 |
✓✓ |
263 |
else if (end_angle <= 270) |
533 |
|
|
{ |
534 |
|
129 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, start_angle, 90); |
535 |
|
129 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, 90, end_angle); |
536 |
|
|
} |
537 |
|
|
else |
538 |
|
|
{ |
539 |
|
134 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, start_angle, 90); |
540 |
|
134 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, 90, 270); |
541 |
|
134 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, 270, end_angle); |
542 |
|
|
} |
543 |
|
|
} |
544 |
✓✓ |
847 |
else if (start_angle < 270) |
545 |
|
|
{ |
546 |
✓✓ |
291 |
if (end_angle <= 270) |
547 |
|
|
{ |
548 |
|
75 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, start_angle, end_angle); |
549 |
|
|
} |
550 |
✓✓ |
216 |
else if (end_angle <= 450) |
551 |
|
|
{ |
552 |
|
92 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, start_angle, 270); |
553 |
|
92 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, 270, end_angle); |
554 |
|
|
} |
555 |
|
|
else |
556 |
|
|
{ |
557 |
|
124 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, start_angle, 270); |
558 |
|
124 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, 270, 450); |
559 |
|
124 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, 90, end_angle - 360); |
560 |
|
|
} |
561 |
|
|
} |
562 |
|
|
else |
563 |
|
|
{ |
564 |
✓✓ |
556 |
if (end_angle <= 450) |
565 |
|
|
{ |
566 |
|
376 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, start_angle, end_angle); |
567 |
|
|
} |
568 |
✓✓ |
180 |
else if (end_angle <= 630) |
569 |
|
|
{ |
570 |
|
53 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, start_angle, 450); |
571 |
|
53 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, 90, end_angle - 360); |
572 |
|
|
} |
573 |
|
|
else |
574 |
|
|
{ |
575 |
|
127 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, start_angle, 450); |
576 |
|
127 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, 90, 270); |
577 |
|
127 |
_gx_display_driver_generic_simple_wide_arc_draw(context, xcenter, ycenter, r, 270, end_angle - 360); |
578 |
|
|
} |
579 |
|
|
} |
580 |
|
|
|
581 |
|
1612 |
brush = &context -> gx_draw_context_brush; |
582 |
|
1612 |
brush_width = brush -> gx_brush_width; |
583 |
|
1612 |
old_fill = brush -> gx_brush_fill_color; |
584 |
|
1612 |
old_style = brush -> gx_brush_style; |
585 |
|
|
|
586 |
|
1612 |
brush -> gx_brush_width = 1; |
587 |
|
1612 |
brush -> gx_brush_fill_color = brush -> gx_brush_line_color; |
588 |
|
1612 |
brush -> gx_brush_style |= GX_BRUSH_SOLID_FILL; |
589 |
|
|
|
590 |
|
1612 |
r = (UINT)(r - (UINT)((brush_width - 1) >> 1)); |
591 |
|
1612 |
_gx_utility_circle_point_get(xcenter, ycenter, r, start_angle, &startp); |
592 |
|
1612 |
_gx_utility_circle_point_get(xcenter, ycenter, r + (UINT)(brush_width - 1), start_angle, &endp); |
593 |
|
|
|
594 |
✓✓ |
1612 |
if (brush -> gx_brush_style & GX_BRUSH_ROUND) |
595 |
|
|
{ |
596 |
|
714 |
brush -> gx_brush_style &= (ULONG)(~GX_BRUSH_PIXELMAP_FILL); |
597 |
|
714 |
_gx_display_driver_generic_filled_circle_draw(context, |
598 |
|
714 |
GX_FIXED_VAL_MAKE(startp.gx_point_x + endp.gx_point_x) >> 1, |
599 |
|
714 |
GX_FIXED_VAL_MAKE(startp.gx_point_y + endp.gx_point_y) >> 1, |
600 |
|
714 |
GX_FIXED_VAL_MAKE(brush_width) >> 1); |
601 |
|
|
} |
602 |
|
|
|
603 |
|
1612 |
_gx_utility_circle_point_get(xcenter, ycenter, r, end_angle, &startp); |
604 |
|
1612 |
_gx_utility_circle_point_get(xcenter, ycenter, r + (UINT)(brush_width - 1), end_angle, &endp); |
605 |
|
|
|
606 |
✓✓ |
1612 |
if (brush -> gx_brush_style & GX_BRUSH_ROUND) |
607 |
|
|
{ |
608 |
|
714 |
brush -> gx_brush_style &= (ULONG)(~GX_BRUSH_PIXELMAP_FILL); |
609 |
|
714 |
_gx_display_driver_generic_filled_circle_draw(context, |
610 |
|
714 |
GX_FIXED_VAL_MAKE(startp.gx_point_x + endp.gx_point_x) >> 1, |
611 |
|
714 |
GX_FIXED_VAL_MAKE(startp.gx_point_y + endp.gx_point_y) >> 1, |
612 |
|
714 |
GX_FIXED_VAL_MAKE(brush_width) >> 1); |
613 |
|
|
} |
614 |
|
|
|
615 |
|
1612 |
brush -> gx_brush_width = (GX_VALUE)brush_width; |
616 |
|
1612 |
brush -> gx_brush_fill_color = old_fill; |
617 |
|
1612 |
brush -> gx_brush_style = old_style; |
618 |
|
|
#if defined(GX_BRUSH_ALPHA_SUPPORT) |
619 |
|
1612 |
context -> gx_draw_context_brush.gx_brush_alpha = old_alpha; |
620 |
|
|
#endif |
621 |
|
1612 |
} |
622 |
|
|
#endif |
623 |
|
|
|