GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
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 REDVAL(_c) (GX_UBYTE)(((_c) >> 10) & 0x1f) |
||
22 |
#define GREENVAL(_c) (GX_UBYTE)(((_c) >> 5) & 0x1f) |
||
23 |
#define BLUEVAL(_c) (GX_UBYTE)(((_c)) & 0x1f) |
||
24 |
|||
25 |
#define ASSEMBLECOLOR(_r, _g, _b) \ |
||
26 |
((((_r) & 0x1f) << 10) | \ |
||
27 |
(((_g) & 0x1f) << 5) | \ |
||
28 |
(((_b) & 0x1f))) |
||
29 |
|||
30 |
#define GX_SOURCE_CODE |
||
31 |
|||
32 |
/* Include necessary system files. */ |
||
33 |
|||
34 |
#include "gx_api.h" |
||
35 |
#include "gx_display.h" |
||
36 |
#include "gx_context.h" |
||
37 |
#include "gx_utility.h" |
||
38 |
#include "gx_system.h" |
||
39 |
|||
40 |
/**************************************************************************/ |
||
41 |
/* */ |
||
42 |
/* FUNCTION RELEASE */ |
||
43 |
/* */ |
||
44 |
/* _gx_display_driver_1555xrgb_pixelmap_raw_rotate PORTABLE C */ |
||
45 |
/* 6.1.10 */ |
||
46 |
/* AUTHOR */ |
||
47 |
/* */ |
||
48 |
/* Kenneth Maxwell, Microsoft Corporation */ |
||
49 |
/* */ |
||
50 |
/* DESCRIPTION */ |
||
51 |
/* */ |
||
52 |
/* Internal helper function that rotate an 1555xrgb format pixelmap */ |
||
53 |
/* without compression, without alpha. */ |
||
54 |
/* */ |
||
55 |
/* INPUT */ |
||
56 |
/* */ |
||
57 |
/* context Drawing context */ |
||
58 |
/* xpos x-coord of top-left draw point*/ |
||
59 |
/* ypos y-coord of top-left draw point*/ |
||
60 |
/* pixelmap Pointer to GX_PIXELMAP struct */ |
||
61 |
/* angle The angle to rotate */ |
||
62 |
/* cx x-coord of rotate center */ |
||
63 |
/* cy y-coord of rotate center */ |
||
64 |
/* */ |
||
65 |
/* OUTPUT */ |
||
66 |
/* */ |
||
67 |
/* status Completion status */ |
||
68 |
/* */ |
||
69 |
/* CALLS */ |
||
70 |
/* */ |
||
71 |
/* _gx_utility_math_cos Compute the cosine value */ |
||
72 |
/* _gx_utility_math_sin Compute the sine value */ |
||
73 |
/* [gx_display_driver_pixel_blend] Display driver basic pixel */ |
||
74 |
/* blend function */ |
||
75 |
/* */ |
||
76 |
/* CALLED BY */ |
||
77 |
/* */ |
||
78 |
/* GUIX Internal Code */ |
||
79 |
/* */ |
||
80 |
/* RELEASE HISTORY */ |
||
81 |
/* */ |
||
82 |
/* DATE NAME DESCRIPTION */ |
||
83 |
/* */ |
||
84 |
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
||
85 |
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
||
86 |
/* resulting in version 6.1 */ |
||
87 |
/* 01-31-2022 Ting Zhu Modified comment(s), */ |
||
88 |
/* corrected logic, */ |
||
89 |
/* resulting in version 6.1.10 */ |
||
90 |
/* */ |
||
91 |
/**************************************************************************/ |
||
92 |
713 |
static VOID _gx_display_driver_1555xrgb_pixelmap_raw_rotate(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap, |
|
93 |
INT angle, INT cx, INT cy) |
||
94 |
{ |
||
95 |
USHORT *get; |
||
96 |
INT srcxres; |
||
97 |
INT srcyres; |
||
98 |
INT cosv; |
||
99 |
INT sinv; |
||
100 |
INT alpha; |
||
101 |
USHORT red; |
||
102 |
USHORT green; |
||
103 |
USHORT blue; |
||
104 |
INT idxminx; |
||
105 |
INT idxmaxx; |
||
106 |
INT idxmaxy; |
||
107 |
INT *mx; |
||
108 |
INT *my; |
||
109 |
INT xres; |
||
110 |
INT yres; |
||
111 |
INT x; |
||
112 |
INT y; |
||
113 |
INT xx; |
||
114 |
INT yy; |
||
115 |
USHORT a; |
||
116 |
USHORT b; |
||
117 |
USHORT c; |
||
118 |
USHORT d; |
||
119 |
INT xdiff; |
||
120 |
INT ydiff; |
||
121 |
INT newxpos; |
||
122 |
INT newypos; |
||
123 |
GX_DISPLAY *display; |
||
124 |
GX_RECTANGLE *clip; |
||
125 |
VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha); |
||
126 |
|||
127 |
713 |
clip = context -> gx_draw_context_clip; |
|
128 |
713 |
display = context -> gx_draw_context_display; |
|
129 |
713 |
blend_func = display -> gx_display_driver_pixel_blend; |
|
130 |
|||
131 |
✓✓ | 713 |
if (!blend_func) |
132 |
{ |
||
133 |
1 |
return; |
|
134 |
} |
||
135 |
|||
136 |
712 |
mx = _gx_system_scratchpad; |
|
137 |
712 |
my = mx + 4; |
|
138 |
|||
139 |
712 |
mx[0] = mx[3] = -1; |
|
140 |
712 |
mx[1] = mx[2] = 1; |
|
141 |
|||
142 |
712 |
my[0] = my[1] = 1; |
|
143 |
712 |
my[2] = my[3] = -1; |
|
144 |
|||
145 |
712 |
idxminx = (angle / 90) & 0x3; |
|
146 |
712 |
idxmaxx = (idxminx + 2) & 0x3; |
|
147 |
712 |
idxmaxy = (idxminx + 1) & 0x3; |
|
148 |
|||
149 |
/* Calculate the source x and y center. */ |
||
150 |
712 |
srcxres = pixelmap -> gx_pixelmap_width >> 1; |
|
151 |
712 |
srcyres = pixelmap -> gx_pixelmap_height >> 1; |
|
152 |
|||
153 |
712 |
cosv = _gx_utility_math_cos(GX_FIXED_VAL_MAKE(angle)); |
|
154 |
712 |
sinv = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(angle)); |
|
155 |
|||
156 |
712 |
xres = GX_FIXED_VAL_TO_INT(mx[idxmaxx] * (srcxres + 2) * cosv - my[idxmaxx] * (srcyres + 2) * sinv); |
|
157 |
712 |
yres = GX_FIXED_VAL_TO_INT(my[idxmaxy] * (srcyres + 2) * cosv + mx[idxmaxy] * (srcxres + 2) * sinv); |
|
158 |
|||
159 |
/* Calculate the new rotation axis. */ |
||
160 |
|||
161 |
712 |
xres = GX_FIXED_VAL_TO_INT((cx - srcxres) * cosv - (cy - srcyres) * sinv) + xres; |
|
162 |
712 |
yres = GX_FIXED_VAL_TO_INT((cy - srcyres) * cosv + (cx - srcxres) * sinv) + yres; |
|
163 |
|||
164 |
712 |
newxpos = xpos + cx - xres; |
|
165 |
712 |
newypos = ypos + cy - yres; |
|
166 |
|||
167 |
/* Loop through the destination's pixels. */ |
||
168 |
✓✓ | 149753 |
for (y = clip -> gx_rectangle_top - newypos; y <= clip -> gx_rectangle_bottom - newypos; y++) |
169 |
{ |
||
170 |
✓✓ | 33809071 |
for (x = clip -> gx_rectangle_left - newxpos; x <= clip -> gx_rectangle_right - newxpos; x++) |
171 |
{ |
||
172 |
33660030 |
xx = (x - xres) * cosv + (y - yres) * sinv; |
|
173 |
33660030 |
yy = (y - yres) * cosv - (x - xres) * sinv; |
|
174 |
|||
175 |
33660030 |
xdiff = GX_FIXED_VAL_TO_INT(xx << 8) & 0xff; |
|
176 |
33660030 |
ydiff = GX_FIXED_VAL_TO_INT(yy << 8) & 0xff; |
|
177 |
|||
178 |
33660030 |
xx = GX_FIXED_VAL_TO_INT(xx) + cx; |
|
179 |
33660030 |
yy = GX_FIXED_VAL_TO_INT(yy) + cy; |
|
180 |
|||
181 |
✓✓✓✓ ✓✓ |
33660030 |
if ((xx >= -1) && (xx < pixelmap -> gx_pixelmap_width) && |
182 |
✓✓ | 25337253 |
(yy >= -1) && (yy < pixelmap -> gx_pixelmap_height)) |
183 |
{ |
||
184 |
✓✓✓✓ ✓✓ |
19049704 |
if ((xx >= 0) && (xx < pixelmap -> gx_pixelmap_width - 1) && |
185 |
✓✓ | 18763787 |
(yy >= 0) && (yy < pixelmap -> gx_pixelmap_height - 1)) |
186 |
{ |
||
187 |
18609240 |
get = (USHORT *)pixelmap -> gx_pixelmap_data; |
|
188 |
18609240 |
get += yy * pixelmap -> gx_pixelmap_width; |
|
189 |
18609240 |
get += xx; |
|
190 |
|||
191 |
18609240 |
a = *get; |
|
192 |
18609240 |
b = *(get + 1); |
|
193 |
18609240 |
c = *(get + pixelmap -> gx_pixelmap_width); |
|
194 |
18609240 |
d = *(get + pixelmap -> gx_pixelmap_width + 1); |
|
195 |
|||
196 |
18609240 |
alpha = 0xff; |
|
197 |
} |
||
198 |
else |
||
199 |
{ |
||
200 |
440464 |
get = (USHORT *)pixelmap -> gx_pixelmap_data; |
|
201 |
|||
202 |
440464 |
a = 0; |
|
203 |
440464 |
b = 0; |
|
204 |
440464 |
c = 0; |
|
205 |
440464 |
d = 0; |
|
206 |
440464 |
alpha = 0; |
|
207 |
|||
208 |
✓✓ | 440464 |
if (xx == -1) |
209 |
{ |
||
210 |
/* handle left edge. */ |
||
211 |
✓✓ | 59074 |
if (yy >= 0) |
212 |
{ |
||
213 |
58700 |
b = *(get + yy * pixelmap -> gx_pixelmap_width); |
|
214 |
58700 |
alpha += xdiff * (256 - ydiff); |
|
215 |
} |
||
216 |
|||
217 |
✓✓ | 59074 |
if (yy < pixelmap -> gx_pixelmap_height - 1) |
218 |
{ |
||
219 |
58622 |
d = *(get + (yy + 1) * pixelmap -> gx_pixelmap_width); |
|
220 |
58622 |
alpha += xdiff * ydiff; |
|
221 |
} |
||
222 |
} |
||
223 |
✓✓ | 381390 |
else if (yy == -1) |
224 |
{ |
||
225 |
/* handle top edge. */ |
||
226 |
137355 |
c = *(get + xx); |
|
227 |
137355 |
alpha += ydiff * (256 - xdiff); |
|
228 |
|||
229 |
✓✓ | 137355 |
if (xx < pixelmap -> gx_pixelmap_width - 1) |
230 |
{ |
||
231 |
136708 |
d = *(get + xx + 1); |
|
232 |
136708 |
alpha += xdiff * ydiff; |
|
233 |
} |
||
234 |
} |
||
235 |
✓✓ | 244035 |
else if (xx == pixelmap -> gx_pixelmap_width - 1) |
236 |
{ |
||
237 |
/* handle right edget. */ |
||
238 |
89488 |
a = *(get + yy * pixelmap -> gx_pixelmap_width + xx); |
|
239 |
89488 |
alpha += (256 - xdiff) * (256 - ydiff); |
|
240 |
|||
241 |
✓✓ | 89488 |
if (yy < pixelmap -> gx_pixelmap_height - 1) |
242 |
{ |
||
243 |
88412 |
c = *(get + (yy + 1) * pixelmap -> gx_pixelmap_width + xx); |
|
244 |
88412 |
alpha += ydiff * (256 - xdiff); |
|
245 |
} |
||
246 |
} |
||
247 |
else |
||
248 |
{ |
||
249 |
/* handle bottom edge. */ |
||
250 |
154547 |
a = *(get + yy * pixelmap -> gx_pixelmap_width + xx); |
|
251 |
154547 |
alpha += (256 - xdiff) * (256 - ydiff); |
|
252 |
|||
253 |
154547 |
b = *(get + yy * pixelmap -> gx_pixelmap_width + xx + 1); |
|
254 |
154547 |
alpha += xdiff * (256 - ydiff); |
|
255 |
} |
||
256 |
|||
257 |
440464 |
alpha >>= 8; |
|
258 |
} |
||
259 |
|||
260 |
19049704 |
red = (USHORT)((REDVAL(a) * (256 - xdiff) * (256 - ydiff) + |
|
261 |
19049704 |
REDVAL(b) * xdiff * (256 - ydiff) + |
|
262 |
19049704 |
REDVAL(c) * ydiff * (256 - xdiff) + |
|
263 |
19049704 |
REDVAL(d) * xdiff * ydiff) >> 16); |
|
264 |
|||
265 |
19049704 |
green = (USHORT)((GREENVAL(a) * (256 - xdiff) * (256 - ydiff) + |
|
266 |
19049704 |
GREENVAL(b) * xdiff * (256 - ydiff) + |
|
267 |
19049704 |
GREENVAL(c) * ydiff * (256 - xdiff) + |
|
268 |
19049704 |
GREENVAL(d) * xdiff * ydiff) >> 16); |
|
269 |
|||
270 |
19049704 |
blue = (USHORT)((BLUEVAL(a) * (256 - xdiff) * (256 - ydiff) + |
|
271 |
19049704 |
BLUEVAL(b) * xdiff * (256 - ydiff) + |
|
272 |
19049704 |
BLUEVAL(c) * ydiff * (256 - xdiff) + |
|
273 |
19049704 |
BLUEVAL(d) * xdiff * ydiff) >> 16); |
|
274 |
|||
275 |
✓✓✓✓ |
19049704 |
if ((alpha > 0) && (alpha < 0xff)) |
276 |
{ |
||
277 |
435396 |
red = (USHORT)((red << 8) / alpha); |
|
278 |
435396 |
green = (USHORT)((green << 8) / alpha); |
|
279 |
435396 |
blue = (USHORT)((blue << 8) / alpha); |
|
280 |
} |
||
281 |
|||
282 |
19049704 |
red = red > 31 ? 31 : red; |
|
283 |
19049704 |
green = green > 63 ? 63 : green; |
|
284 |
19049704 |
blue = blue > 31 ? 31 : blue; |
|
285 |
19049704 |
alpha = alpha > 255 ? 255 : alpha; |
|
286 |
|||
287 |
19049704 |
blend_func(context, x + newxpos, y + newypos, (GX_COLOR)ASSEMBLECOLOR(red, green, blue), (GX_UBYTE)alpha); |
|
288 |
} |
||
289 |
} |
||
290 |
} |
||
291 |
} |
||
292 |
|||
293 |
/**************************************************************************/ |
||
294 |
/* */ |
||
295 |
/* FUNCTION RELEASE */ |
||
296 |
/* */ |
||
297 |
/* _gx_display_driver_1555xrgb_pixelmap_alpha_rotate PORTABLE C */ |
||
298 |
/* 6.1.10 */ |
||
299 |
/* AUTHOR */ |
||
300 |
/* */ |
||
301 |
/* Kenneth Maxwell, Microsoft Corporation */ |
||
302 |
/* */ |
||
303 |
/* DESCRIPTION */ |
||
304 |
/* */ |
||
305 |
/* Internal helper function that rotate an 1555xrgb format pixelmap */ |
||
306 |
/* without compression, with alpha. */ |
||
307 |
/* */ |
||
308 |
/* INPUT */ |
||
309 |
/* */ |
||
310 |
/* context Drawing context */ |
||
311 |
/* xpos x-coord of top-left draw point*/ |
||
312 |
/* ypos y-coord of top-left draw point*/ |
||
313 |
/* pixelmap Pointer to GX_PIXELMAP struct */ |
||
314 |
/* angle The angle to rotate */ |
||
315 |
/* cx x-coord of rotate center */ |
||
316 |
/* cy y-coord of rotate center */ |
||
317 |
/* */ |
||
318 |
/* OUTPUT */ |
||
319 |
/* */ |
||
320 |
/* status Completion status */ |
||
321 |
/* */ |
||
322 |
/* CALLS */ |
||
323 |
/* */ |
||
324 |
/* _gx_utility_math_cos Compute the cosine value */ |
||
325 |
/* _gx_utility_math_sin Compute the sine value */ |
||
326 |
/* [gx_display_driver_pixel_blend] Display driver basic pixel */ |
||
327 |
/* blend function */ |
||
328 |
/* */ |
||
329 |
/* CALLED BY */ |
||
330 |
/* */ |
||
331 |
/* GUIX Internal Code */ |
||
332 |
/* */ |
||
333 |
/* RELEASE HISTORY */ |
||
334 |
/* */ |
||
335 |
/* DATE NAME DESCRIPTION */ |
||
336 |
/* */ |
||
337 |
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
||
338 |
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
||
339 |
/* resulting in version 6.1 */ |
||
340 |
/* 01-31-2022 Ting Zhu Modified comment(s), */ |
||
341 |
/* corrected logic, */ |
||
342 |
/* resulting in version 6.1.10 */ |
||
343 |
/* */ |
||
344 |
/**************************************************************************/ |
||
345 |
713 |
static VOID _gx_display_driver_1555xrgb_pixelmap_alpha_rotate(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap, |
|
346 |
INT angle, INT cx, INT cy) |
||
347 |
{ |
||
348 |
USHORT *get; |
||
349 |
GX_UBYTE *getalpha; |
||
350 |
INT srcxres; |
||
351 |
INT srcyres; |
||
352 |
INT cosv; |
||
353 |
INT sinv; |
||
354 |
USHORT red; |
||
355 |
USHORT green; |
||
356 |
USHORT blue; |
||
357 |
INT idxminx; |
||
358 |
INT idxmaxx; |
||
359 |
INT idxmaxy; |
||
360 |
INT *mx; |
||
361 |
INT *my; |
||
362 |
INT xres; |
||
363 |
INT yres; |
||
364 |
INT x; |
||
365 |
INT y; |
||
366 |
INT xx; |
||
367 |
INT yy; |
||
368 |
USHORT a; |
||
369 |
USHORT b; |
||
370 |
USHORT c; |
||
371 |
USHORT d; |
||
372 |
USHORT alpha[4]; |
||
373 |
INT xdiff; |
||
374 |
INT ydiff; |
||
375 |
INT newxpos; |
||
376 |
INT newypos; |
||
377 |
GX_DISPLAY *display; |
||
378 |
GX_RECTANGLE *clip; |
||
379 |
VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha); |
||
380 |
|||
381 |
713 |
clip = context -> gx_draw_context_clip; |
|
382 |
713 |
display = context -> gx_draw_context_display; |
|
383 |
713 |
blend_func = display -> gx_display_driver_pixel_blend; |
|
384 |
|||
385 |
✓✓ | 713 |
if (!blend_func) |
386 |
{ |
||
387 |
1 |
return; |
|
388 |
} |
||
389 |
|||
390 |
712 |
mx = _gx_system_scratchpad; |
|
391 |
712 |
my = mx + 4; |
|
392 |
|||
393 |
712 |
mx[0] = mx[3] = -1; |
|
394 |
712 |
mx[1] = mx[2] = 1; |
|
395 |
|||
396 |
712 |
my[0] = my[1] = 1; |
|
397 |
712 |
my[2] = my[3] = -1; |
|
398 |
|||
399 |
712 |
idxminx = (angle / 90) & 0x3; |
|
400 |
712 |
idxmaxx = (idxminx + 2) & 0x3; |
|
401 |
712 |
idxmaxy = (idxminx + 1) & 0x3; |
|
402 |
|||
403 |
/* Calculate the source x and y center. */ |
||
404 |
712 |
srcxres = pixelmap -> gx_pixelmap_width >> 1; |
|
405 |
712 |
srcyres = pixelmap -> gx_pixelmap_height >> 1; |
|
406 |
|||
407 |
712 |
cosv = _gx_utility_math_cos(GX_FIXED_VAL_MAKE(angle)); |
|
408 |
712 |
sinv = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(angle)); |
|
409 |
|||
410 |
712 |
xres = GX_FIXED_VAL_TO_INT(mx[idxmaxx] * (srcxres + 2) * cosv - my[idxmaxx] * (srcyres + 2) * sinv); |
|
411 |
712 |
yres = GX_FIXED_VAL_TO_INT(my[idxmaxy] * (srcyres + 2) * cosv + mx[idxmaxy] * (srcxres + 2) * sinv); |
|
412 |
|||
413 |
712 |
xres = GX_FIXED_VAL_TO_INT((cx - srcxres) * cosv - (cy - srcyres) * sinv) + xres; |
|
414 |
712 |
yres = GX_FIXED_VAL_TO_INT((cy - srcyres) * cosv + (cx - srcxres) * sinv) + yres; |
|
415 |
|||
416 |
712 |
newxpos = xpos + cx - xres; |
|
417 |
712 |
newypos = ypos + cy - yres; |
|
418 |
|||
419 |
/* Loop through the source's pixels. */ |
||
420 |
✓✓ | 166287 |
for (y = clip -> gx_rectangle_top - newypos; y <= clip -> gx_rectangle_bottom - newypos; y++) |
421 |
{ |
||
422 |
✓✓ | 44269209 |
for (x = clip -> gx_rectangle_left - newxpos; x <= clip -> gx_rectangle_right - newxpos; x++) |
423 |
{ |
||
424 |
44103634 |
xx = (x - xres) * cosv + (y - yres) * sinv; |
|
425 |
44103634 |
yy = (y - yres) * cosv - (x - xres) * sinv; |
|
426 |
|||
427 |
44103634 |
xdiff = GX_FIXED_VAL_TO_INT(xx << 8) & 0xff; |
|
428 |
44103634 |
ydiff = GX_FIXED_VAL_TO_INT(yy << 8) & 0xff; |
|
429 |
|||
430 |
44103634 |
xx = GX_FIXED_VAL_TO_INT(xx) + cx; |
|
431 |
44103634 |
yy = GX_FIXED_VAL_TO_INT(yy) + cy; |
|
432 |
|||
433 |
✓✓✓✓ ✓✓ |
44103634 |
if ((xx >= -1) && (xx < pixelmap -> gx_pixelmap_width) && |
434 |
✓✓ | 30464829 |
(yy >= -1) && (yy < pixelmap -> gx_pixelmap_height)) |
435 |
{ |
||
436 |
✓✓✓✓ ✓✓ |
26534621 |
if ((xx >= 0) && (xx < pixelmap -> gx_pixelmap_width - 1) && \ |
437 |
✓✓ | 26151079 |
(yy >= 0) && (yy < pixelmap -> gx_pixelmap_height - 1)) |
438 |
{ |
||
439 |
26025235 |
get = (USHORT *)pixelmap -> gx_pixelmap_data; |
|
440 |
26025235 |
get += yy * pixelmap -> gx_pixelmap_width; |
|
441 |
26025235 |
get += xx; |
|
442 |
|||
443 |
26025235 |
getalpha = (GX_UBYTE *)pixelmap -> gx_pixelmap_aux_data; |
|
444 |
26025235 |
getalpha += yy * pixelmap -> gx_pixelmap_width; |
|
445 |
26025235 |
getalpha += xx; |
|
446 |
|||
447 |
26025235 |
a = *get; |
|
448 |
26025235 |
alpha[0] = *getalpha; |
|
449 |
|||
450 |
26025235 |
b = *(get + 1); |
|
451 |
26025235 |
alpha[1] = *(getalpha + 1); |
|
452 |
|||
453 |
26025235 |
c = *(get + pixelmap -> gx_pixelmap_width); |
|
454 |
26025235 |
alpha[2] = *(getalpha + pixelmap -> gx_pixelmap_width); |
|
455 |
|||
456 |
26025235 |
d = *(get + pixelmap -> gx_pixelmap_width + 1); |
|
457 |
26025235 |
alpha[3] = *(getalpha + pixelmap -> gx_pixelmap_width + 1); |
|
458 |
} |
||
459 |
else |
||
460 |
{ |
||
461 |
509386 |
get = (USHORT *)pixelmap -> gx_pixelmap_data; |
|
462 |
509386 |
getalpha = (GX_UBYTE *)pixelmap -> gx_pixelmap_aux_data; |
|
463 |
|||
464 |
509386 |
a = 0; |
|
465 |
509386 |
b = 0; |
|
466 |
509386 |
c = 0; |
|
467 |
509386 |
d = 0; |
|
468 |
|||
469 |
✓✓ | 509386 |
if (xx == -1) |
470 |
{ |
||
471 |
/* handle left edge. */ |
||
472 |
✓✓ | 127863 |
if (yy >= 0) |
473 |
{ |
||
474 |
127428 |
b = *(get + yy * pixelmap -> gx_pixelmap_width); |
|
475 |
127428 |
alpha[1] = *(getalpha + yy * pixelmap -> gx_pixelmap_width); |
|
476 |
} |
||
477 |
|||
478 |
✓✓ | 127863 |
if (yy < pixelmap -> gx_pixelmap_height - 1) |
479 |
{ |
||
480 |
127366 |
d = *(get + (yy + 1) * pixelmap -> gx_pixelmap_width); |
|
481 |
127366 |
alpha[3] = *(getalpha + (yy + 1) * pixelmap -> gx_pixelmap_width); |
|
482 |
} |
||
483 |
} |
||
484 |
✓✓ | 381523 |
else if (yy == -1) |
485 |
{ |
||
486 |
/* handle top edge. */ |
||
487 |
110949 |
c = *(get + xx); |
|
488 |
110949 |
alpha[2] = *(getalpha + xx); |
|
489 |
|||
490 |
✓✓ | 110949 |
if (xx < pixelmap -> gx_pixelmap_width - 1) |
491 |
{ |
||
492 |
110387 |
d = *(get + xx + 1); |
|
493 |
110387 |
alpha[3] = *(getalpha + xx + 1); |
|
494 |
} |
||
495 |
} |
||
496 |
✓✓ | 270574 |
else if (xx == pixelmap -> gx_pixelmap_width - 1) |
497 |
{ |
||
498 |
/* handle right edget. */ |
||
499 |
144730 |
a = *(get + yy * pixelmap -> gx_pixelmap_width + xx); |
|
500 |
144730 |
alpha[0] = *(getalpha + yy * pixelmap -> gx_pixelmap_width + xx); |
|
501 |
|||
502 |
✓✓ | 144730 |
if (yy < pixelmap -> gx_pixelmap_height - 1) |
503 |
{ |
||
504 |
143738 |
c = *(get + (yy + 1) * pixelmap -> gx_pixelmap_width + xx); |
|
505 |
143738 |
alpha[2] = *(getalpha + (yy + 1) * pixelmap -> gx_pixelmap_width + xx); |
|
506 |
} |
||
507 |
} |
||
508 |
else |
||
509 |
{ |
||
510 |
/* handle bottom edge. */ |
||
511 |
125844 |
a = *(get + yy * pixelmap -> gx_pixelmap_width + xx); |
|
512 |
125844 |
alpha[0] = *(getalpha + yy * pixelmap -> gx_pixelmap_width + xx); |
|
513 |
|||
514 |
125844 |
b = *(get + yy * pixelmap -> gx_pixelmap_width + xx + 1); |
|
515 |
125844 |
alpha[1] = *(getalpha + yy * pixelmap -> gx_pixelmap_width + xx + 1); |
|
516 |
} |
||
517 |
|||
518 |
✓✓ | 509386 |
if (!a) |
519 |
{ |
||
520 |
238812 |
alpha[0] = 0; |
|
521 |
} |
||
522 |
|||
523 |
✓✓ | 509386 |
if (!b) |
524 |
{ |
||
525 |
256114 |
alpha[1] = 0; |
|
526 |
} |
||
527 |
|||
528 |
✓✓ | 509386 |
if (!c) |
529 |
{ |
||
530 |
254699 |
alpha[2] = 0; |
|
531 |
} |
||
532 |
|||
533 |
✓✓ | 509386 |
if (!d) |
534 |
{ |
||
535 |
271633 |
alpha[3] = 0; |
|
536 |
} |
||
537 |
} |
||
538 |
|||
539 |
26534621 |
red = (USHORT)((REDVAL(a) * alpha[0] * (256 - xdiff) * (256 - ydiff) + |
|
540 |
26534621 |
REDVAL(b) * alpha[1] * xdiff * (256 - ydiff) + |
|
541 |
26534621 |
REDVAL(c) * alpha[2] * ydiff * (256 - xdiff) + |
|
542 |
26534621 |
REDVAL(d) * alpha[3] * xdiff * ydiff) >> 16); |
|
543 |
|||
544 |
26534621 |
green = (USHORT)((GREENVAL(a) * alpha[0] * (256 - xdiff) * (256 - ydiff) + |
|
545 |
26534621 |
GREENVAL(b) * alpha[1] * xdiff * (256 - ydiff) + |
|
546 |
26534621 |
GREENVAL(c) * alpha[2] * ydiff * (256 - xdiff) + |
|
547 |
26534621 |
GREENVAL(d) * alpha[3] * xdiff * ydiff) >> 16); |
|
548 |
|||
549 |
26534621 |
blue = (USHORT)((BLUEVAL(a) * alpha[0] * (256 - xdiff) * (256 - ydiff) + |
|
550 |
26534621 |
BLUEVAL(b) * alpha[1] * xdiff * (256 - ydiff) + |
|
551 |
26534621 |
BLUEVAL(c) * alpha[2] * ydiff * (256 - xdiff) + |
|
552 |
26534621 |
BLUEVAL(d) * alpha[3] * xdiff * ydiff) >> 16); |
|
553 |
|||
554 |
26534621 |
alpha[0] = (USHORT)((alpha[0] * (256 - xdiff) * (256 - ydiff) + |
|
555 |
26534621 |
alpha[1] * xdiff * (256 - ydiff) + |
|
556 |
26534621 |
alpha[2] * ydiff * (256 - xdiff) + |
|
557 |
26534621 |
alpha[3] * xdiff * ydiff) >> 16); |
|
558 |
|||
559 |
✓✓ | 26534621 |
if (alpha[0]) |
560 |
{ |
||
561 |
16803662 |
red /= alpha[0]; |
|
562 |
16803662 |
green /= alpha[0]; |
|
563 |
16803662 |
blue /= alpha[0]; |
|
564 |
} |
||
565 |
|||
566 |
26534621 |
red = red > 31 ? 31 : red; |
|
567 |
26534621 |
green = green > 63 ? 63 : green; |
|
568 |
26534621 |
blue = blue > 31 ? 31 : blue; |
|
569 |
26534621 |
alpha[0] = alpha[0] > 255 ? 255 : alpha[0]; |
|
570 |
|||
571 |
26534621 |
blend_func(context, x + newxpos, y + newypos, (GX_COLOR)ASSEMBLECOLOR(red, green, blue), (GX_UBYTE)alpha[0]); |
|
572 |
} |
||
573 |
} |
||
574 |
} |
||
575 |
} |
||
576 |
|||
577 |
/**************************************************************************/ |
||
578 |
/* */ |
||
579 |
/* FUNCTION RELEASE */ |
||
580 |
/* */ |
||
581 |
/* _gx_display_driver_1555xrgb_pixelmap_rotate PORTABLE C */ |
||
582 |
/* 6.1 */ |
||
583 |
/* AUTHOR */ |
||
584 |
/* */ |
||
585 |
/* Kenneth Maxwell, Microsoft Corporation */ |
||
586 |
/* */ |
||
587 |
/* DESCRIPTION */ |
||
588 |
/* */ |
||
589 |
/* This service rotate a pixelmap directly to canvas memory. */ |
||
590 |
/* */ |
||
591 |
/* INPUT */ |
||
592 |
/* */ |
||
593 |
/* context Drawing context */ |
||
594 |
/* xpos x-coord of top-left draw point*/ |
||
595 |
/* ypos y-coord of top-left draw point*/ |
||
596 |
/* pixelmap Pointer to GX_PIXELMAP struct */ |
||
597 |
/* angle The angle to rotate */ |
||
598 |
/* rot_cx x-coord of rotating center. */ |
||
599 |
/* rot_cy y-coord of rotationg center. */ |
||
600 |
/* */ |
||
601 |
/* OUTPUT */ |
||
602 |
/* */ |
||
603 |
/* status Completion status */ |
||
604 |
/* */ |
||
605 |
/* CALLS */ |
||
606 |
/* */ |
||
607 |
/* _gx_display_driver_16bpp_pixelmap_rotate */ |
||
608 |
/* Rotate 16bpp format pixelmap */ |
||
609 |
/* _gx_display_driver_1555xrgb_pixelmap_alpha_rotate */ |
||
610 |
/* Rotate 1555xrgb format */ |
||
611 |
/* pixelmap with alpha */ |
||
612 |
/* _gx_display_driver_1555xrgb_pixelmap_rotate */ |
||
613 |
/* Rotate 1555xrgb format */ |
||
614 |
/* pixelmap with alpha */ |
||
615 |
/* */ |
||
616 |
/* CALLED BY */ |
||
617 |
/* */ |
||
618 |
/* GUIX Internal Code */ |
||
619 |
/* */ |
||
620 |
/* RELEASE HISTORY */ |
||
621 |
/* */ |
||
622 |
/* DATE NAME DESCRIPTION */ |
||
623 |
/* */ |
||
624 |
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
||
625 |
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
||
626 |
/* resulting in version 6.1 */ |
||
627 |
/* */ |
||
628 |
/**************************************************************************/ |
||
629 |
1439 |
VOID _gx_display_driver_1555xrgb_pixelmap_rotate(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap, |
|
630 |
INT angle, INT rot_cx, INT rot_cy) |
||
631 |
{ |
||
632 |
✓✓ | 1439 |
switch (pixelmap -> gx_pixelmap_format) |
633 |
{ |
||
634 |
1438 |
case GX_COLOR_FORMAT_1555XRGB: |
|
635 |
✓✓ | 1438 |
if (angle % 90 == 0) |
636 |
{ |
||
637 |
/* Simple angle rotate: 90 degree, 180 degree and 270 degree. */ |
||
638 |
✓✓ | 12 |
if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA) |
639 |
{ |
||
640 |
6 |
_gx_display_driver_16bpp_pixelmap_simple_alpha_rotate(context, xpos, ypos, pixelmap, angle, rot_cx, rot_cy); |
|
641 |
} |
||
642 |
else |
||
643 |
{ |
||
644 |
6 |
_gx_display_driver_16bpp_pixelmap_simple_rotate(context, xpos, ypos, pixelmap, angle, rot_cx, rot_cy); |
|
645 |
} |
||
646 |
12 |
break; |
|
647 |
} |
||
648 |
else |
||
649 |
{ |
||
650 |
✓✓ | 1426 |
if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA) |
651 |
{ |
||
652 |
/* alpha, no compression */ |
||
653 |
713 |
_gx_display_driver_1555xrgb_pixelmap_alpha_rotate(context, xpos, ypos, pixelmap, angle, rot_cx, rot_cy); |
|
654 |
} |
||
655 |
else |
||
656 |
{ |
||
657 |
|||
658 |
/* no compression or alpha */ |
||
659 |
713 |
_gx_display_driver_1555xrgb_pixelmap_raw_rotate(context, xpos, ypos, pixelmap, angle, rot_cx, rot_cy); |
|
660 |
} |
||
661 |
} |
||
662 |
1426 |
break; |
|
663 |
} |
||
664 |
|||
665 |
1439 |
return; |
|
666 |
} |
||
667 |
Generated by: GCOVR (Version 4.1) |