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 |
|
|
|
31 |
|
|
/**************************************************************************/ |
32 |
|
|
/* */ |
33 |
|
|
/* FUNCTION RELEASE */ |
34 |
|
|
/* */ |
35 |
|
|
/* _gx_display_driver_arc_clipping_get PORTABLE C */ |
36 |
|
|
/* 6.1 */ |
37 |
|
|
/* AUTHOR */ |
38 |
|
|
/* */ |
39 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
40 |
|
|
/* */ |
41 |
|
|
/* DESCRIPTION */ |
42 |
|
|
/* */ |
43 |
|
|
/* This function returns the clipping area of a circle arc. */ |
44 |
|
|
/* */ |
45 |
|
|
/* INPUT */ |
46 |
|
|
/* */ |
47 |
|
|
/* xcenter x-coord of center of circle */ |
48 |
|
|
/* ycenter y-coord of center of circle */ |
49 |
|
|
/* r Radius of circle */ |
50 |
|
|
/* start_angle Start angle for clipping */ |
51 |
|
|
/* end_argle End angle for clipping */ |
52 |
|
|
/* clip_1 Clip result */ |
53 |
|
|
/* cllp_2 Clip result */ |
54 |
|
|
/* clip_3 Clip result */ |
55 |
|
|
/* clip_4 Clip result */ |
56 |
|
|
/* */ |
57 |
|
|
/* OUTPUT */ |
58 |
|
|
/* */ |
59 |
|
|
/* None */ |
60 |
|
|
/* */ |
61 |
|
|
/* CALLS */ |
62 |
|
|
/* */ |
63 |
|
|
/* _gx_utility_circle_point_get Get point coord on a circle */ |
64 |
|
|
/* */ |
65 |
|
|
/* CALLED BY */ |
66 |
|
|
/* */ |
67 |
|
|
/* GUIX Internal Code */ |
68 |
|
|
/* */ |
69 |
|
|
/* RELEASE HISTORY */ |
70 |
|
|
/* */ |
71 |
|
|
/* DATE NAME DESCRIPTION */ |
72 |
|
|
/* */ |
73 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
74 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
75 |
|
|
/* resulting in version 6.1 */ |
76 |
|
|
/* */ |
77 |
|
|
/**************************************************************************/ |
78 |
|
|
#if defined(GX_ARC_DRAWING_SUPPORT) |
79 |
|
29395 |
VOID _gx_display_driver_arc_clipping_get(INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle, |
80 |
|
|
GX_RECTANGLE *clip_1, GX_RECTANGLE *clip_2, GX_RECTANGLE *clip_3, GX_RECTANGLE *clip_4) |
81 |
|
|
{ |
82 |
|
|
|
83 |
|
|
GX_POINT start_point; |
84 |
|
|
GX_POINT end_point; |
85 |
|
29395 |
GX_VALUE ori_r = (GX_VALUE)r; |
86 |
|
29395 |
GX_VALUE neg_r = (GX_VALUE)(-ori_r); |
87 |
|
|
|
88 |
|
29395 |
memset(clip_1, 0, sizeof(GX_RECTANGLE)); |
89 |
|
29395 |
memset(clip_2, 0, sizeof(GX_RECTANGLE)); |
90 |
|
29395 |
memset(clip_3, 0, sizeof(GX_RECTANGLE)); |
91 |
|
29395 |
memset(clip_4, 0, sizeof(GX_RECTANGLE)); |
92 |
|
|
|
93 |
|
|
/* Get two endpoint of the arc. */ |
94 |
|
29395 |
_gx_utility_circle_point_get(0, 0, r, start_angle, &start_point); |
95 |
|
29395 |
_gx_utility_circle_point_get(0, 0, r, end_angle, &end_point); |
96 |
|
|
|
97 |
|
|
/* Calculate clipping. */ |
98 |
✓✓ |
29395 |
if (start_angle < 90) |
99 |
|
|
{ |
100 |
✓✓ |
8789 |
if (end_angle <= 90) |
101 |
|
|
{ |
102 |
|
7857 |
clip_1 -> gx_rectangle_left = end_point.gx_point_x; |
103 |
|
7857 |
clip_1 -> gx_rectangle_top = end_point.gx_point_y; |
104 |
|
7857 |
clip_1 -> gx_rectangle_right = start_point.gx_point_x; |
105 |
|
7857 |
clip_1 -> gx_rectangle_bottom = start_point.gx_point_y; |
106 |
|
|
} |
107 |
|
|
else |
108 |
|
|
{ |
109 |
|
932 |
clip_1 -> gx_rectangle_left = 0; |
110 |
|
932 |
clip_1 -> gx_rectangle_top = neg_r; |
111 |
|
932 |
clip_1 -> gx_rectangle_right = start_point.gx_point_x; |
112 |
|
932 |
clip_1 -> gx_rectangle_bottom = start_point.gx_point_y; |
113 |
|
|
|
114 |
✓✓ |
932 |
if (end_angle <= 180) |
115 |
|
|
{ |
116 |
|
653 |
clip_2 -> gx_rectangle_left = end_point.gx_point_x; |
117 |
|
653 |
clip_2 -> gx_rectangle_top = neg_r; |
118 |
|
653 |
clip_2 -> gx_rectangle_right = 0; |
119 |
|
653 |
clip_2 -> gx_rectangle_bottom = end_point.gx_point_y; |
120 |
|
|
} |
121 |
|
|
else |
122 |
|
|
{ |
123 |
|
279 |
clip_2 -> gx_rectangle_left = neg_r; |
124 |
|
279 |
clip_2 -> gx_rectangle_top = neg_r; |
125 |
|
279 |
clip_2 -> gx_rectangle_right = 0; |
126 |
|
279 |
clip_2 -> gx_rectangle_bottom = 0; |
127 |
|
|
|
128 |
✓✓ |
279 |
if (end_angle <= 270) |
129 |
|
|
{ |
130 |
|
91 |
clip_3 -> gx_rectangle_left = neg_r; |
131 |
|
91 |
clip_3 -> gx_rectangle_top = 0; |
132 |
|
91 |
clip_3 -> gx_rectangle_right = end_point.gx_point_x; |
133 |
|
91 |
clip_3 -> gx_rectangle_bottom = end_point.gx_point_y; |
134 |
|
|
} |
135 |
|
|
else |
136 |
|
|
{ |
137 |
|
188 |
clip_2 -> gx_rectangle_bottom = ori_r; |
138 |
|
|
|
139 |
✓✓ |
188 |
if (end_angle <= 360) |
140 |
|
|
{ |
141 |
|
176 |
clip_3 -> gx_rectangle_left = 0; |
142 |
|
176 |
clip_3 -> gx_rectangle_top = end_point.gx_point_y; |
143 |
|
176 |
clip_3 -> gx_rectangle_right = end_point.gx_point_x; |
144 |
|
176 |
clip_3 -> gx_rectangle_bottom = ori_r; |
145 |
|
|
} |
146 |
|
|
else |
147 |
|
|
{ |
148 |
|
12 |
clip_3 -> gx_rectangle_left = 0; |
149 |
|
12 |
clip_3 -> gx_rectangle_top = 0; |
150 |
|
12 |
clip_3 -> gx_rectangle_right = ori_r; |
151 |
|
12 |
clip_3 -> gx_rectangle_bottom = ori_r; |
152 |
|
|
|
153 |
|
12 |
clip_4 -> gx_rectangle_left = end_point.gx_point_x; |
154 |
|
12 |
clip_4 -> gx_rectangle_top = end_point.gx_point_y; |
155 |
|
12 |
clip_4 -> gx_rectangle_right = ori_r; |
156 |
|
12 |
clip_4 -> gx_rectangle_bottom = 0; |
157 |
|
|
} |
158 |
|
|
} |
159 |
|
|
} |
160 |
|
|
} |
161 |
|
|
} |
162 |
✓✓ |
20606 |
else if (start_angle < 180) |
163 |
|
|
{ |
164 |
✓✓ |
4181 |
if (end_angle <= 180) |
165 |
|
|
{ |
166 |
|
1777 |
clip_1 -> gx_rectangle_left = end_point.gx_point_x; |
167 |
|
1777 |
clip_1 -> gx_rectangle_top = start_point.gx_point_y; |
168 |
|
1777 |
clip_1 -> gx_rectangle_right = start_point.gx_point_x; |
169 |
|
1777 |
clip_1 -> gx_rectangle_bottom = end_point.gx_point_y; |
170 |
|
|
} |
171 |
|
|
else |
172 |
|
|
{ |
173 |
|
2404 |
clip_1 -> gx_rectangle_left = neg_r; |
174 |
|
2404 |
clip_1 -> gx_rectangle_top = start_point.gx_point_y; |
175 |
|
2404 |
clip_1 -> gx_rectangle_right = start_point.gx_point_x; |
176 |
|
2404 |
clip_1 -> gx_rectangle_bottom = 0; |
177 |
|
|
|
178 |
✓✓ |
2404 |
if (end_angle <= 270) |
179 |
|
|
{ |
180 |
|
2361 |
clip_2 -> gx_rectangle_left = neg_r; |
181 |
|
2361 |
clip_2 -> gx_rectangle_top = 0; |
182 |
|
2361 |
clip_2 -> gx_rectangle_right = end_point.gx_point_x; |
183 |
|
2361 |
clip_2 -> gx_rectangle_bottom = end_point.gx_point_y; |
184 |
|
|
} |
185 |
|
|
else |
186 |
|
|
{ |
187 |
|
43 |
clip_2 -> gx_rectangle_left = neg_r; |
188 |
|
43 |
clip_2 -> gx_rectangle_top = 0; |
189 |
|
43 |
clip_2 -> gx_rectangle_right = 0; |
190 |
|
43 |
clip_2 -> gx_rectangle_bottom = ori_r; |
191 |
|
|
|
192 |
✓✓ |
43 |
if (end_angle <= 360) |
193 |
|
|
{ |
194 |
|
37 |
clip_3 -> gx_rectangle_left = 0; |
195 |
|
37 |
clip_3 -> gx_rectangle_top = end_point.gx_point_y; |
196 |
|
37 |
clip_3 -> gx_rectangle_right = end_point.gx_point_x; |
197 |
|
37 |
clip_3 -> gx_rectangle_bottom = ori_r; |
198 |
|
|
} |
199 |
|
|
else |
200 |
|
|
{ |
201 |
|
6 |
clip_2 -> gx_rectangle_right = ori_r; |
202 |
|
|
|
203 |
✓✓ |
6 |
if (end_angle <= 450) |
204 |
|
|
{ |
205 |
|
1 |
clip_3 -> gx_rectangle_left = end_point.gx_point_x; |
206 |
|
1 |
clip_3 -> gx_rectangle_top = end_point.gx_point_y; |
207 |
|
1 |
clip_3 -> gx_rectangle_right = ori_r; |
208 |
|
1 |
clip_3 -> gx_rectangle_bottom = 0; |
209 |
|
|
} |
210 |
|
|
else |
211 |
|
|
{ |
212 |
|
5 |
clip_3 -> gx_rectangle_left = 0; |
213 |
|
5 |
clip_3 -> gx_rectangle_top = neg_r; |
214 |
|
5 |
clip_3 -> gx_rectangle_right = ori_r; |
215 |
|
5 |
clip_3 -> gx_rectangle_bottom = 0; |
216 |
|
|
|
217 |
|
5 |
clip_4 -> gx_rectangle_left = end_point.gx_point_x; |
218 |
|
5 |
clip_4 -> gx_rectangle_top = neg_r; |
219 |
|
5 |
clip_4 -> gx_rectangle_right = 0; |
220 |
|
5 |
clip_4 -> gx_rectangle_bottom = end_point.gx_point_y; |
221 |
|
|
} |
222 |
|
|
} |
223 |
|
|
} |
224 |
|
|
} |
225 |
|
|
} |
226 |
✓✓ |
16425 |
else if (start_angle < 270) |
227 |
|
|
{ |
228 |
✓✓ |
6591 |
if (end_angle <= 270) |
229 |
|
|
{ |
230 |
|
6030 |
clip_1 -> gx_rectangle_left = start_point.gx_point_x; |
231 |
|
6030 |
clip_1 -> gx_rectangle_top = start_point.gx_point_y; |
232 |
|
6030 |
clip_1 -> gx_rectangle_right = end_point.gx_point_x; |
233 |
|
6030 |
clip_1 -> gx_rectangle_bottom = end_point.gx_point_y; |
234 |
|
|
} |
235 |
|
|
else |
236 |
|
|
{ |
237 |
|
561 |
clip_1 -> gx_rectangle_left = start_point.gx_point_x; |
238 |
|
561 |
clip_1 -> gx_rectangle_top = start_point.gx_point_y; |
239 |
|
561 |
clip_1 -> gx_rectangle_right = 0; |
240 |
|
561 |
clip_1 -> gx_rectangle_bottom = ori_r; |
241 |
|
|
|
242 |
✓✓ |
561 |
if (end_angle <= 360) |
243 |
|
|
{ |
244 |
|
549 |
clip_2 -> gx_rectangle_left = 0; |
245 |
|
549 |
clip_2 -> gx_rectangle_top = end_point.gx_point_y; |
246 |
|
549 |
clip_2 -> gx_rectangle_right = end_point.gx_point_x; |
247 |
|
549 |
clip_2 -> gx_rectangle_bottom = ori_r; |
248 |
|
|
} |
249 |
|
|
else |
250 |
|
|
{ |
251 |
|
12 |
clip_2 -> gx_rectangle_left = 0; |
252 |
|
12 |
clip_2 -> gx_rectangle_top = 0; |
253 |
|
12 |
clip_2 -> gx_rectangle_right = ori_r; |
254 |
|
12 |
clip_2 -> gx_rectangle_bottom = ori_r; |
255 |
|
|
|
256 |
✓✓ |
12 |
if (end_angle <= 450) |
257 |
|
|
{ |
258 |
|
5 |
clip_3 -> gx_rectangle_left = end_point.gx_point_x; |
259 |
|
5 |
clip_3 -> gx_rectangle_top = end_point.gx_point_y; |
260 |
|
5 |
clip_3 -> gx_rectangle_right = ori_r; |
261 |
|
5 |
clip_3 -> gx_rectangle_bottom = ori_r; |
262 |
|
|
} |
263 |
|
|
else |
264 |
|
|
{ |
265 |
|
7 |
clip_2 -> gx_rectangle_top = neg_r; |
266 |
|
|
|
267 |
✓✓ |
7 |
if (end_angle <= 540) |
268 |
|
|
{ |
269 |
|
4 |
clip_3 -> gx_rectangle_left = end_point.gx_point_x; |
270 |
|
4 |
clip_3 -> gx_rectangle_top = neg_r; |
271 |
|
4 |
clip_3 -> gx_rectangle_right = 0; |
272 |
|
4 |
clip_3 -> gx_rectangle_bottom = end_point.gx_point_y; |
273 |
|
|
} |
274 |
|
|
else |
275 |
|
|
{ |
276 |
|
3 |
clip_3 -> gx_rectangle_left = neg_r; |
277 |
|
3 |
clip_3 -> gx_rectangle_top = neg_r; |
278 |
|
3 |
clip_3 -> gx_rectangle_right = 0; |
279 |
|
3 |
clip_3 -> gx_rectangle_bottom = 0; |
280 |
|
|
|
281 |
|
3 |
clip_4 -> gx_rectangle_left = neg_r; |
282 |
|
3 |
clip_4 -> gx_rectangle_top = 0; |
283 |
|
3 |
clip_4 -> gx_rectangle_right = end_point.gx_point_x; |
284 |
|
3 |
clip_4 -> gx_rectangle_bottom = end_point.gx_point_y; |
285 |
|
|
} |
286 |
|
|
} |
287 |
|
|
} |
288 |
|
|
} |
289 |
|
|
} |
290 |
|
|
else |
291 |
|
|
{ |
292 |
✓✓ |
9834 |
if (end_angle <= 360) |
293 |
|
|
{ |
294 |
|
2150 |
clip_1 -> gx_rectangle_left = start_point.gx_point_x; |
295 |
|
2150 |
clip_1 -> gx_rectangle_top = end_point.gx_point_y; |
296 |
|
2150 |
clip_1 -> gx_rectangle_right = end_point.gx_point_x; |
297 |
|
2150 |
clip_1 -> gx_rectangle_bottom = start_point.gx_point_y; |
298 |
|
|
} |
299 |
|
|
else |
300 |
|
|
{ |
301 |
|
7684 |
clip_1 -> gx_rectangle_left = start_point.gx_point_x; |
302 |
|
7684 |
clip_1 -> gx_rectangle_top = 0; |
303 |
|
7684 |
clip_1 -> gx_rectangle_right = ori_r; |
304 |
|
7684 |
clip_1 -> gx_rectangle_bottom = start_point.gx_point_y; |
305 |
|
|
|
306 |
✓✓ |
7684 |
if (end_angle <= 450) |
307 |
|
|
{ |
308 |
|
7615 |
clip_2 -> gx_rectangle_left = end_point.gx_point_x; |
309 |
|
7615 |
clip_2 -> gx_rectangle_top = end_point.gx_point_y; |
310 |
|
7615 |
clip_2 -> gx_rectangle_right = ori_r; |
311 |
|
7615 |
clip_2 -> gx_rectangle_bottom = 0; |
312 |
|
|
} |
313 |
|
|
else |
314 |
|
|
{ |
315 |
|
69 |
clip_2 -> gx_rectangle_left = 0; |
316 |
|
69 |
clip_2 -> gx_rectangle_top = neg_r; |
317 |
|
69 |
clip_2 -> gx_rectangle_right = ori_r; |
318 |
|
69 |
clip_2 -> gx_rectangle_bottom = 0; |
319 |
|
|
|
320 |
✓✓ |
69 |
if (end_angle <= 540) |
321 |
|
|
{ |
322 |
|
13 |
clip_3 -> gx_rectangle_left = end_point.gx_point_x; |
323 |
|
13 |
clip_3 -> gx_rectangle_top = neg_r; |
324 |
|
13 |
clip_3 -> gx_rectangle_right = 0; |
325 |
|
13 |
clip_3 -> gx_rectangle_bottom = end_point.gx_point_y; |
326 |
|
|
} |
327 |
|
|
else |
328 |
|
|
{ |
329 |
|
56 |
clip_2 -> gx_rectangle_left = neg_r; |
330 |
|
|
|
331 |
✓✓ |
56 |
if (end_angle <= 630) |
332 |
|
|
{ |
333 |
|
3 |
clip_3 -> gx_rectangle_left = neg_r; |
334 |
|
3 |
clip_3 -> gx_rectangle_top = 0; |
335 |
|
3 |
clip_3 -> gx_rectangle_right = end_point.gx_point_x; |
336 |
|
3 |
clip_3 -> gx_rectangle_bottom = end_point.gx_point_y; |
337 |
|
|
} |
338 |
|
|
else |
339 |
|
|
{ |
340 |
|
53 |
clip_3 -> gx_rectangle_left = neg_r; |
341 |
|
53 |
clip_3 -> gx_rectangle_top = 0; |
342 |
|
53 |
clip_3 -> gx_rectangle_right = 0; |
343 |
|
53 |
clip_3 -> gx_rectangle_bottom = ori_r; |
344 |
|
|
|
345 |
|
53 |
clip_4 -> gx_rectangle_left = 0; |
346 |
|
53 |
clip_4 -> gx_rectangle_top = end_point.gx_point_y; |
347 |
|
53 |
clip_4 -> gx_rectangle_right = end_point.gx_point_x; |
348 |
|
53 |
clip_4 -> gx_rectangle_bottom = ori_r; |
349 |
|
|
} |
350 |
|
|
} |
351 |
|
|
} |
352 |
|
|
} |
353 |
|
|
} |
354 |
|
|
|
355 |
|
29395 |
clip_1 -> gx_rectangle_left = (GX_VALUE)(clip_1 -> gx_rectangle_left + (GX_VALUE)xcenter); |
356 |
|
29395 |
clip_1 -> gx_rectangle_top = (GX_VALUE)(clip_1 -> gx_rectangle_top + (GX_VALUE)ycenter); |
357 |
|
29395 |
clip_1 -> gx_rectangle_right = (GX_VALUE)(clip_1 -> gx_rectangle_right + (GX_VALUE)xcenter); |
358 |
|
29395 |
clip_1 -> gx_rectangle_bottom = (GX_VALUE)(clip_1 -> gx_rectangle_bottom + (GX_VALUE)ycenter); |
359 |
|
|
|
360 |
|
29395 |
clip_2 -> gx_rectangle_left = (GX_VALUE)(clip_2 -> gx_rectangle_left + (GX_VALUE)xcenter); |
361 |
|
29395 |
clip_2 -> gx_rectangle_top = (GX_VALUE)(clip_2 -> gx_rectangle_top + (GX_VALUE)ycenter); |
362 |
|
29395 |
clip_2 -> gx_rectangle_right = (GX_VALUE)(clip_2 -> gx_rectangle_right + (GX_VALUE)xcenter); |
363 |
|
29395 |
clip_2 -> gx_rectangle_bottom = (GX_VALUE)(clip_2 -> gx_rectangle_bottom + (GX_VALUE)ycenter); |
364 |
|
|
|
365 |
|
29395 |
clip_3 -> gx_rectangle_left = (GX_VALUE)(clip_3 -> gx_rectangle_left + (GX_VALUE)xcenter); |
366 |
|
29395 |
clip_3 -> gx_rectangle_top = (GX_VALUE)(clip_3 -> gx_rectangle_top + (GX_VALUE)ycenter); |
367 |
|
29395 |
clip_3 -> gx_rectangle_right = (GX_VALUE)(clip_3 -> gx_rectangle_right + (GX_VALUE)xcenter); |
368 |
|
29395 |
clip_3 -> gx_rectangle_bottom = (GX_VALUE)(clip_3 -> gx_rectangle_bottom + (GX_VALUE)ycenter); |
369 |
|
|
|
370 |
|
29395 |
clip_4 -> gx_rectangle_left = (GX_VALUE)(clip_4 -> gx_rectangle_left + (GX_VALUE)xcenter); |
371 |
|
29395 |
clip_4 -> gx_rectangle_top = (GX_VALUE)(clip_4 -> gx_rectangle_top + (GX_VALUE)ycenter); |
372 |
|
29395 |
clip_4 -> gx_rectangle_right = (GX_VALUE)(clip_4 -> gx_rectangle_right + (GX_VALUE)xcenter); |
373 |
|
29395 |
clip_4 -> gx_rectangle_bottom = (GX_VALUE)(clip_4 -> gx_rectangle_bottom + (GX_VALUE)ycenter); |
374 |
|
29395 |
} |
375 |
|
|
#endif |
376 |
|
|
|