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_display.h"
28
29
30 /**************************************************************************/
31 /* */
32 /* FUNCTION RELEASE */
33 /* */
34 /* _gx_display_driver_32bpp_rotated_pixelmap_raw_write */
35 /* PORTABLE C */
36 /* 6.1.4 */
37 /* AUTHOR */
38 /* */
39 /* Kenneth Maxwell, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* Internal helper function that handles writing of rotated */
44 /* uncompressed pixlemap data without alpha channel. */
45 /* */
46 /* INPUT */
47 /* */
48 /* context Drawing context */
49 /* xpos x-coord of top-left draw point*/
50 /* ypos y-coord of top-left draw point*/
51 /* pixelmap Pointer to GX_PIXELMAP struct */
52 /* */
53 /* OUTPUT */
54 /* */
55 /* None */
56 /* */
57 /* CALLS */
58 /* */
59 /* None */
60 /* */
61 /* CALLED BY */
62 /* */
63 /* GUIX Internal Code */
64 /* */
65 /* RELEASE HISTORY */
66 /* */
67 /* DATE NAME DESCRIPTION */
68 /* */
69 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
70 /* */
71 /**************************************************************************/
_gx_display_driver_32bpp_rotated_pixelmap_raw_write(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)72 static VOID _gx_display_driver_32bpp_rotated_pixelmap_raw_write(GX_DRAW_CONTEXT *context,
73 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
74 {
75 INT xval;
76 INT yval;
77 GX_COLOR *putrow;
78 GX_COLOR *getrow;
79 GX_COLOR *put;
80 GX_COLOR *get;
81
82 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
83 GX_RECTANGLE rotated_clip;
84
85 GX_SWAP_VALS(xpos, ypos);
86
87 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
88 {
89 rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
90 rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
91 rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
92 rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
93 ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
94 }
95 else
96 {
97 rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
98 rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
99 rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
100 rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
101 xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
102 }
103
104 getrow = (GX_COLOR *)(pixelmap -> gx_pixelmap_data);
105 getrow += pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos);
106 getrow += (rotated_clip.gx_rectangle_left - xpos);
107
108 /* Brush alpha is 0xff means draw pixelmap to memory directly. */
109 putrow = context -> gx_draw_context_memory;
110 putrow += rotated_clip.gx_rectangle_top * context -> gx_draw_context_pitch;
111 putrow += rotated_clip.gx_rectangle_left;
112
113 for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
114 {
115 put = putrow;
116 get = getrow;
117
118 for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
119 {
120 *put++ = *get++;
121 }
122 putrow += context -> gx_draw_context_pitch;
123 getrow += pixelmap -> gx_pixelmap_height;
124 }
125 }
126
127 /**************************************************************************/
128 /* */
129 /* FUNCTION RELEASE */
130 /* */
131 /* _gx_display_driver_32bpp_rotated_pixelmap_alpha_write */
132 /* PORTABLE C */
133 /* 6.1.5 */
134 /* AUTHOR */
135 /* */
136 /* Kenneth Maxwell, Microsoft Corporation */
137 /* */
138 /* DESCRIPTION */
139 /* */
140 /* Internal helper function that handles writing of rotated */
141 /* uncompressed pixlemap data with alpha channel. */
142 /* */
143 /* INPUT */
144 /* */
145 /* context Drawing context */
146 /* xpos x-coord of top-left draw point*/
147 /* ypos y-coord of top-left draw point*/
148 /* pixelmap Pointer to GX_PIXELMAP struct */
149 /* */
150 /* OUTPUT */
151 /* */
152 /* None */
153 /* */
154 /* CALLS */
155 /* */
156 /* _gx_display_driver_24xrgb_pixel_blend */
157 /* _gx_display_driver_32bpp_pixel_write */
158 /* */
159 /* CALLED BY */
160 /* */
161 /* _gx_display_driver_32bpp_rotated_pixelmap_draw */
162 /* */
163 /* RELEASE HISTORY */
164 /* */
165 /* DATE NAME DESCRIPTION */
166 /* */
167 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
168 /* 03-02-2021 Ting Zhu Modified comment(s), changed */
169 /* blend function set macro, */
170 /* resulting in version 6.1.5 */
171 /* */
172 /**************************************************************************/
_gx_display_driver_32bpp_rotated_pixelmap_alpha_write(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)173 static VOID _gx_display_driver_32bpp_rotated_pixelmap_alpha_write(GX_DRAW_CONTEXT *context,
174 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
175 {
176 INT xval;
177 INT yval;
178 GX_COLOR color;
179 ULONG *getrow;
180 ULONG *get;
181 UCHAR alpha_value;
182 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
183 GX_RECTANGLE rotated_clip;
184 VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
185
186 GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
187
188 GX_SWAP_VALS(xpos, ypos);
189
190 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
191 {
192 rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
193 rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
194 rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
195 rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
196 ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
197 }
198 else
199 {
200 rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
201 rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
202 rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
203 rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
204 xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
205 }
206
207 getrow = (ULONG *)(pixelmap -> gx_pixelmap_data);
208 getrow += pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos);
209 getrow += (rotated_clip.gx_rectangle_left - xpos);
210
211 for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
212 {
213 get = getrow;
214 for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
215 {
216 alpha_value = ALPHAVAL_32BPP(*get);
217 if (alpha_value)
218 {
219 color = *get;
220 if (alpha_value == 255)
221 {
222 _gx_display_driver_32bpp_pixel_write(context, xval, yval, color);
223 }
224 else
225 {
226 color |= 0xff000000;
227 blend_func(context, xval, yval, color, alpha_value);
228 }
229 }
230 get++;
231 }
232 getrow += pixelmap -> gx_pixelmap_height;
233 }
234 }
235
236 /**************************************************************************/
237 /* */
238 /* FUNCTION RELEASE */
239 /* */
240 /* _gx_display_driver_32bpp_rotated_pixelmap_compressed_write */
241 /* */
242 /* PORTABLE C */
243 /* 6.1.5 */
244 /* AUTHOR */
245 /* */
246 /* Kenneth Maxwell, Microsoft Corporation */
247 /* */
248 /* DESCRIPTION */
249 /* */
250 /* Internal helper function that handles writing of rotated compressed */
251 /* pixlemap data without alpha channel. */
252 /* */
253 /* INPUT */
254 /* */
255 /* context Drawing context */
256 /* xpos x-coord of top-left draw point*/
257 /* ypos y-coord of top-left draw point*/
258 /* pixelmap Pointer to GX_PIXELMAP struct */
259 /* */
260 /* OUTPUT */
261 /* */
262 /* None */
263 /* */
264 /* CALLS */
265 /* */
266 /* _gx_display_driver_24xrgb_pixel_blend */
267 /* _gx_display_driver_32argb_pixel_blend */
268 /* */
269 /* CALLED BY */
270 /* */
271 /* _gx_display_driver_32bpp_rotated_pixelmap_draw */
272 /* */
273 /* RELEASE HISTORY */
274 /* */
275 /* DATE NAME DESCRIPTION */
276 /* */
277 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
278 /* 03-02-2021 Ting Zhu Modified comment(s), changed */
279 /* blend function set macro, */
280 /* resulting in version 6.1.5 */
281 /* */
282 /**************************************************************************/
_gx_display_driver_32bpp_rotated_pixelmap_compressed_write(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)283 static VOID _gx_display_driver_32bpp_rotated_pixelmap_compressed_write(GX_DRAW_CONTEXT *context,
284 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
285 {
286 INT yval;
287 INT xval;
288 GX_CONST GX_COLOR *get;
289 GX_COLOR *put;
290 GX_COLOR *putrow;
291 GX_UBYTE count;
292 GX_COLOR pixel;
293 GX_CONST GX_UBYTE *get_count;
294 GX_UBYTE brush_alpha;
295 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
296 GX_RECTANGLE rotated_clip;
297 VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
298
299 GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
300
301 GX_SWAP_VALS(xpos, ypos);
302
303 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
304 {
305 rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
306 rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
307 rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
308 rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
309 ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
310 }
311 else
312 {
313 rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
314 rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
315 rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
316 rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
317 xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
318 }
319 brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
320
321 get = (GX_CONST GX_COLOR *)pixelmap -> gx_pixelmap_data;
322 get_count = (GX_CONST GX_UBYTE *)pixelmap -> gx_pixelmap_aux_data;
323
324 /* First, skip to the starting row. */
325 for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++)
326 {
327 xval = 0;
328 while (xval < pixelmap -> gx_pixelmap_height)
329 {
330 count = *get_count++;
331
332 if (count & 0x80)
333 {
334 count = (GX_UBYTE)((count & 0x7f) + 1u);
335
336 /* Skip repeated pixel value. */
337 get++;
338 }
339 else
340 {
341 count++;
342
343 /* Skip raw pixel values. */
344 get += count;
345 }
346 xval += count;
347 }
348 }
349
350 /* Now we are on the first visible row, copy pixels until we get
351 to the enf of the last visible row. */
352 putrow = (GX_COLOR *)context -> gx_draw_context_memory;
353 putrow += yval * context -> gx_draw_context_pitch;
354 putrow += xpos;
355
356 while (yval <= rotated_clip.gx_rectangle_bottom)
357 {
358 put = putrow;
359 xval = xpos;
360
361 while (xval < xpos + pixelmap -> gx_pixelmap_height)
362 {
363 count = *get_count++;
364
365 if (count & 0x80)
366 {
367
368 /* Repeated value. */
369 count = (GX_UBYTE)((count & 0x7f) + 1u);
370 pixel = (*get++);
371
372 if (brush_alpha == 0xff)
373 {
374 while (count--)
375 {
376 if (xval >= rotated_clip.gx_rectangle_left &&
377 xval <= rotated_clip.gx_rectangle_right)
378 {
379 *put = pixel;
380 }
381 put++;
382 xval++;
383 }
384 }
385 else
386 {
387 while (count--)
388 {
389 if (xval >= rotated_clip.gx_rectangle_left &&
390 xval <= rotated_clip.gx_rectangle_right)
391 {
392 blend_func(context, xval, yval, pixel, brush_alpha);
393 }
394 xval++;
395 }
396 }
397 }
398 else
399 {
400
401 /* String of non-repeated values. */
402 count++;
403
404 if (brush_alpha == 0xff)
405 {
406 while (count--)
407 {
408 if (xval >= rotated_clip.gx_rectangle_left &&
409 xval <= rotated_clip.gx_rectangle_right)
410 {
411 *put = (*get);
412 }
413 put++;
414 get++;
415 xval++;
416 }
417 }
418 else
419 {
420 while (count--)
421 {
422 if (xval >= rotated_clip.gx_rectangle_left &&
423 xval <= rotated_clip.gx_rectangle_right)
424 {
425 blend_func(context, xval, yval, *get, brush_alpha);
426 }
427 get++;
428 xval++;
429 }
430 }
431 }
432 }
433 putrow += context -> gx_draw_context_pitch;
434 yval++;
435 }
436 }
437
438 /**************************************************************************/
439 /* */
440 /* FUNCTION RELEASE */
441 /* */
442 /* _gx_display_driver_32bpp_rotated_pixelmap_compressed_alpha_write */
443 /* */
444 /* PORTABLE C */
445 /* 6.1.5 */
446 /* AUTHOR */
447 /* */
448 /* Kenneth Maxwell, Microsoft Corporation */
449 /* */
450 /* DESCRIPTION */
451 /* */
452 /* Internal helper function that handles writing of compressed */
453 /* pixlemap file with alpha channel. */
454 /* */
455 /* INPUT */
456 /* */
457 /* context Drawing context */
458 /* xpos x-coord of top-left draw point*/
459 /* ypos y-coord of top-left draw point*/
460 /* pixelmap Pointer to GX_PIXELMAP struct */
461 /* */
462 /* OUTPUT */
463 /* */
464 /* None */
465 /* */
466 /* CALLS */
467 /* */
468 /* _gx_display_driver_24xrgb_pixel_blend */
469 /* _gx_display_driver_32argb_pixel_blend */
470 /* */
471 /* CALLED BY */
472 /* */
473 /* _gx_display_driver_32bpp_rotated_pixelmap_draw */
474 /* */
475 /* RELEASE HISTORY */
476 /* */
477 /* DATE NAME DESCRIPTION */
478 /* */
479 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
480 /* 03-02-2021 Ting Zhu Modified comment(s), changed */
481 /* blend function set macro, */
482 /* resulting in version 6.1.5 */
483 /* */
484 /**************************************************************************/
_gx_display_driver_32bpp_rotated_pixelmap_compressed_alpha_write(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)485 static VOID _gx_display_driver_32bpp_rotated_pixelmap_compressed_alpha_write(GX_DRAW_CONTEXT *context,
486 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
487 {
488 INT yval;
489 INT xval;
490 GX_CONST GX_COLOR *get;
491 GX_UBYTE count;
492 GX_COLOR pixel;
493 GX_CONST GX_UBYTE *get_count;
494 GX_UBYTE brush_alpha;
495 GX_UBYTE alpha;
496 GX_UBYTE combined_alpha;
497 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
498 GX_RECTANGLE rotated_clip;
499 VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
500
501 GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
502
503 GX_SWAP_VALS(xpos, ypos);
504
505 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
506 {
507 rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
508 rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
509 rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
510 rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
511 ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
512 }
513 else
514 {
515 rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
516 rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
517 rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
518 rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
519 xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
520 }
521
522 brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
523
524 get = (GX_CONST GX_COLOR *)pixelmap -> gx_pixelmap_data;
525 get_count = (GX_CONST GX_UBYTE *)pixelmap -> gx_pixelmap_aux_data;
526
527 /* First, skip to the starting row. */
528 for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++)
529 {
530 xval = 0;
531 while (xval < pixelmap -> gx_pixelmap_height)
532 {
533 count = *get_count++;
534
535 if (count & 0x80)
536 {
537 count = (GX_UBYTE)((count & 0x7f) + 1u);
538
539 /* Skip repeated pixel value. */
540 get++;
541 }
542 else
543 {
544 count++;
545
546 /* Skip raw pixel values. */
547 get += count;
548 }
549 xval += count;
550 }
551 }
552
553 /* Now we are on the first visible row, copy pixels until we get
554 to the enf of the last visible row. */
555
556 while (yval <= rotated_clip.gx_rectangle_bottom)
557 {
558 xval = xpos;
559
560 while (xval < xpos + pixelmap -> gx_pixelmap_height)
561 {
562 count = *get_count++;
563
564 if (count & 0x80)
565 {
566
567 /* Repeated value. */
568 count = (GX_UBYTE)((count & 0x7f) + 1u);
569 alpha = (GX_UBYTE)((*get) >> 24);
570 pixel = (*get++) | 0xff000000;
571
572 combined_alpha = (GX_UBYTE)(alpha * brush_alpha / 255);
573
574 if (combined_alpha)
575 {
576 while (count--)
577 {
578 if (xval >= rotated_clip.gx_rectangle_left &&
579 xval <= rotated_clip.gx_rectangle_right)
580 {
581 blend_func(context, xval, yval, pixel, combined_alpha);
582 }
583 xval++;
584 }
585 }
586 else
587 {
588 xval += count;
589 }
590 }
591 else
592 {
593
594 /* String of non-repeated values. */
595 count++;
596
597 while (count--)
598 {
599 if (xval >= rotated_clip.gx_rectangle_left &&
600 xval <= rotated_clip.gx_rectangle_right)
601 {
602 alpha = (GX_UBYTE)((*get) >> 24);
603 pixel = (*get) | 0xff000000;
604 combined_alpha = (GX_UBYTE)(alpha * brush_alpha / 255);
605 blend_func(context, xval, yval, pixel, combined_alpha);
606 }
607 get++;
608 xval++;
609 }
610 }
611 }
612 yval++;
613 }
614 }
615
616 /**************************************************************************/
617 /* */
618 /* FUNCTION RELEASE */
619 /* */
620 /* _gx_display_driver_32bpp_rotated_palette_pixelmap_compressed_write */
621 /* */
622 /* PORTABLE C */
623 /* 6.1.5 */
624 /* AUTHOR */
625 /* */
626 /* Kenneth Maxwell, Microsoft Corporation */
627 /* */
628 /* DESCRIPTION */
629 /* */
630 /* Internal helper function that handles writing of rotated compressed */
631 /* pixlemap file without transparent of palette pixelmap. */
632 /* */
633 /* INPUT */
634 /* */
635 /* context Drawing context */
636 /* xpos x-coord of top-left draw point*/
637 /* ypos y-coord of top-left draw point*/
638 /* pixelmap Pointer to GX_PIXELMAP struct */
639 /* */
640 /* OUTPUT */
641 /* */
642 /* None */
643 /* */
644 /* CALLS */
645 /* */
646 /* _gx_display_driver_24xrgb_pixel_blend */
647 /* */
648 /* CALLED BY */
649 /* */
650 /* _gx_display_driver_32bpp_rotated_pixelmap_draw */
651 /* */
652 /* RELEASE HISTORY */
653 /* */
654 /* DATE NAME DESCRIPTION */
655 /* */
656 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
657 /* 03-02-2021 Ting Zhu Modified comment(s), changed */
658 /* blend function set macro, */
659 /* moved NULL pointer check to */
660 /* caller function, */
661 /* resulting in version 6.1.5 */
662 /* */
663 /**************************************************************************/
_gx_display_driver_32bpp_rotated_palette_pixelmap_compressed_write(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)664 static VOID _gx_display_driver_32bpp_rotated_palette_pixelmap_compressed_write(GX_DRAW_CONTEXT *context,
665 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
666 {
667 INT yval;
668 INT xval;
669 GX_CONST UCHAR *get;
670 UCHAR count;
671 GX_COLOR *put;
672 GX_COLOR *putrow;
673 GX_COLOR pixel;
674 GX_COLOR *palette;
675 GX_UBYTE brush_alpha;
676 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
677 GX_RECTANGLE rotated_clip;
678 VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
679
680 GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
681
682 GX_SWAP_VALS(xpos, ypos);
683
684 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
685 {
686 rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
687 rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
688 rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
689 rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
690 ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
691 }
692 else
693 {
694 rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
695 rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
696 rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
697 rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
698 xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
699 }
700 get = (GX_CONST UCHAR *)pixelmap -> gx_pixelmap_data;
701 brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
702
703 /* Compressed with alpha is a one-byte count and one-byte pixel index,
704 first, skip to the starting row. */
705 for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++)
706 {
707 xval = 0;
708 while (xval < pixelmap -> gx_pixelmap_height)
709 {
710 count = *get++;
711
712 if (count & 0x80)
713 {
714 count = (UCHAR)((count & 0x7f) + 1);
715
716 /* Skip repeated pixel value. */
717 get++;
718 }
719 else
720 {
721 count++;
722
723 /* Skip raw pixel values. */
724 get += count;
725 }
726 xval += count;
727 }
728 }
729
730 /* Now we are on the first visible row, copy pixels until we get
731 to the enf of the last visible row. */
732 putrow = (GX_COLOR *)context -> gx_draw_context_memory;
733 putrow += yval * context -> gx_draw_context_pitch;
734 putrow += xpos;
735
736 /* Now we are on the first visible row, copy pixels until we get
737 to the end of the last visible row. */
738 palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
739
740 while (yval <= rotated_clip.gx_rectangle_bottom)
741 {
742 xval = xpos;
743 put = putrow;
744
745 while (xval < xpos + pixelmap -> gx_pixelmap_height)
746 {
747 count = *get++;
748
749 if (count & 0x80)
750 {
751 /* Repeated value. */
752 count = (UCHAR)((count & 0x7f) + 1);
753
754 pixel = palette[*get++];
755
756 if (brush_alpha == 0xff)
757 {
758 while (count--)
759 {
760 if (xval >= rotated_clip.gx_rectangle_left &&
761 xval <= rotated_clip.gx_rectangle_right)
762 {
763 *put = pixel;
764 }
765 put++;
766 xval++;
767 }
768 }
769 else
770 {
771 while (count--)
772 {
773 if (xval >= rotated_clip.gx_rectangle_left &&
774 xval <= rotated_clip.gx_rectangle_right)
775 {
776 blend_func(context, xval, yval, pixel, brush_alpha);
777 }
778 xval++;
779 }
780 }
781 }
782 else
783 {
784 /* String of non-repeated values. */
785 count++;
786 if (brush_alpha == 0xff)
787 {
788 while (count--)
789 {
790 if (xval >= rotated_clip.gx_rectangle_left &&
791 xval <= rotated_clip.gx_rectangle_right)
792 {
793 pixel = palette[*get];
794 *put = pixel;
795 }
796 get++;
797 put++;
798 xval++;
799 }
800 }
801 else
802 {
803 while (count--)
804 {
805 if (xval >= rotated_clip.gx_rectangle_left &&
806 xval <= rotated_clip.gx_rectangle_right)
807 {
808 pixel = palette[*get];
809 blend_func(context, xval, yval, pixel, brush_alpha);
810 }
811 get++;
812 xval++;
813 }
814 }
815 }
816 }
817 putrow += context -> gx_draw_context_pitch;
818 yval++;
819 }
820 }
821
822 /**************************************************************************/
823 /* */
824 /* FUNCTION RELEASE */
825 /* */
826 /* _gx_display_driver_32bpp_rotated_palette_pixelmap_write */
827 /* */
828 /* PORTABLE C */
829 /* 6.1.4 */
830 /* AUTHOR */
831 /* */
832 /* Kenneth Maxwell, Microsoft Corporation */
833 /* */
834 /* DESCRIPTION */
835 /* */
836 /* Internal helper function that handles writing of rotated */
837 /* uncompressed pixlemap file without transparent of palette pixelmap. */
838 /* */
839 /* INPUT */
840 /* */
841 /* context Drawing context */
842 /* xpos x-coord of top-left draw point*/
843 /* ypos y-coord of top-left draw point*/
844 /* pixelmap Pointer to GX_PIXELMAP struct */
845 /* */
846 /* OUTPUT */
847 /* */
848 /* None */
849 /* */
850 /* CALLS */
851 /* */
852 /* None */
853 /* */
854 /* CALLED BY */
855 /* */
856 /* _gx_display_driver_32bpp_rotated_pixelmap_draw */
857 /* */
858 /* RELEASE HISTORY */
859 /* */
860 /* DATE NAME DESCRIPTION */
861 /* */
862 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
863 /* */
864 /**************************************************************************/
_gx_display_driver_32bpp_rotated_palette_pixelmap_write(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)865 static VOID _gx_display_driver_32bpp_rotated_palette_pixelmap_write(GX_DRAW_CONTEXT *context,
866 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
867 {
868 INT xval;
869 INT yval;
870 GX_UBYTE *getrow;
871 GX_UBYTE *get;
872 GX_COLOR *palette;
873 GX_COLOR *put;
874 GX_COLOR *putrow;
875 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
876 GX_RECTANGLE rotated_clip;
877
878 GX_SWAP_VALS(xpos, ypos);
879
880 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
881 {
882 rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
883 rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
884 rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
885 rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
886 ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
887 }
888 else
889 {
890 rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
891 rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
892 rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
893 rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
894 xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
895 }
896
897 getrow = (GX_UBYTE *)(pixelmap -> gx_pixelmap_data);
898 getrow += (pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos));
899 getrow += (rotated_clip.gx_rectangle_left - xpos);
900
901 palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
902
903 /* Now we are on the first visible row, copy pixels until we get
904 to the enf of the last visible row. */
905 putrow = (GX_COLOR *)context -> gx_draw_context_memory;
906 putrow += rotated_clip.gx_rectangle_top * context -> gx_draw_context_pitch;
907 putrow += rotated_clip.gx_rectangle_left;
908
909 for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
910 {
911 put = putrow;
912 get = getrow;
913
914 for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
915 {
916 *put++ = palette[*get++];
917 }
918 putrow += context -> gx_draw_context_pitch;
919 getrow += pixelmap -> gx_pixelmap_height;
920 }
921 }
922
923 /**************************************************************************/
924 /* */
925 /* FUNCTION RELEASE */
926 /* */
927 /* _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_write */
928 /* */
929 /* PORTABLE C */
930 /* 6.1.4 */
931 /* AUTHOR */
932 /* */
933 /* Kenneth Maxwell, Microsoft Corporation */
934 /* */
935 /* DESCRIPTION */
936 /* */
937 /* Internal helper function that handles writing of uncompressed */
938 /* pixlemap file with transparent of palette pixelmap. */
939 /* */
940 /* INPUT */
941 /* */
942 /* context Drawing context */
943 /* xpos x-coord of top-left draw point*/
944 /* ypos y-coord of top-left draw point*/
945 /* pixelmap Pointer to GX_PIXELMAP struct */
946 /* */
947 /* OUTPUT */
948 /* */
949 /* None */
950 /* */
951 /* CALLS */
952 /* */
953 /* _gx_display_driver_32bpp_pixel_write */
954 /* */
955 /* CALLED BY */
956 /* */
957 /* _gx_display_driver_32bpp_rotated_pixelmap_draw */
958 /* */
959 /* RELEASE HISTORY */
960 /* */
961 /* DATE NAME DESCRIPTION */
962 /* */
963 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
964 /* */
965 /**************************************************************************/
_gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_write(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)966 static VOID _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_write(GX_DRAW_CONTEXT *context,
967 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
968 {
969 INT xval;
970 INT yval;
971 GX_UBYTE *getrow;
972 GX_UBYTE *get;
973 GX_COLOR *palette;
974
975 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
976 GX_RECTANGLE rotated_clip;
977
978 GX_SWAP_VALS(xpos, ypos);
979
980 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
981 {
982 rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
983 rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
984 rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
985 rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
986 ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
987 }
988 else
989 {
990 rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
991 rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
992 rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
993 rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
994 xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
995 }
996
997 palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
998 getrow = (GX_UBYTE *)(pixelmap -> gx_pixelmap_data);
999 getrow += (pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos));
1000 getrow += (rotated_clip.gx_rectangle_left - xpos);
1001
1002 for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
1003 {
1004 get = getrow;
1005 for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
1006 {
1007 if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
1008 {
1009 _gx_display_driver_32bpp_pixel_write(context, xval, yval, palette[*get]);
1010 }
1011 get++;
1012 }
1013
1014 getrow += pixelmap -> gx_pixelmap_height;
1015 }
1016 }
1017
1018 /**************************************************************************/
1019 /* */
1020 /* FUNCTION RELEASE */
1021 /* */
1022 /* _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_ */
1023 /* compressed_write */
1024 /* */
1025 /* PORTABLE C */
1026 /* 6.1.5 */
1027 /* AUTHOR */
1028 /* */
1029 /* Kenneth Maxwell, Microsoft Corporation */
1030 /* */
1031 /* DESCRIPTION */
1032 /* */
1033 /* Internal helper function that handles writing of rotated compressed */
1034 /* pixlemap file with transparent of palette pixelmap. */
1035 /* */
1036 /* INPUT */
1037 /* */
1038 /* context Drawing context */
1039 /* xpos x-coord of top-left draw point*/
1040 /* ypos y-coord of top-left draw point*/
1041 /* pixelmap Pointer to GX_PIXELMAP struct */
1042 /* */
1043 /* OUTPUT */
1044 /* */
1045 /* None */
1046 /* */
1047 /* CALLS */
1048 /* */
1049 /* _gx_display_driver_24xrgb_pixel_blend */
1050 /* _gx_display_driver_32argb_pixel_blend */
1051 /* */
1052 /* CALLED BY */
1053 /* */
1054 /* _gx_display_driver_32bpp_rotated_pixelmap_draw */
1055 /* */
1056 /* RELEASE HISTORY */
1057 /* */
1058 /* DATE NAME DESCRIPTION */
1059 /* */
1060 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
1061 /* 03-02-2021 Ting Zhu Modified comment(s), changed */
1062 /* blend function set macro, */
1063 /* resulting in version 6.1.5 */
1064 /* */
1065 /**************************************************************************/
_gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_compressed_write(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)1066 static VOID _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_compressed_write(GX_DRAW_CONTEXT *context,
1067 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1068 {
1069 INT yval;
1070 INT xval;
1071 GX_CONST UCHAR *get;
1072 UCHAR count;
1073 GX_COLOR pixel;
1074 GX_COLOR *palette;
1075 GX_COLOR *put;
1076 GX_COLOR *putrow;
1077 GX_UBYTE brush_alpha;
1078 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
1079 GX_RECTANGLE rotated_clip;
1080 VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
1081
1082 GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
1083
1084 GX_SWAP_VALS(xpos, ypos);
1085
1086 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
1087 {
1088 rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
1089 rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
1090 rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
1091 rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
1092 ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
1093 }
1094 else
1095 {
1096 rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
1097 rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
1098 rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
1099 rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
1100 xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
1101 }
1102 get = (GX_CONST UCHAR *)pixelmap -> gx_pixelmap_data;
1103 brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1104
1105 /* Compressed with alpha is a one-byte count and one-byte pixel index,
1106 first, skip to the starting row. */
1107 for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++)
1108 {
1109 xval = 0;
1110 while (xval < pixelmap -> gx_pixelmap_height)
1111 {
1112 count = *get++;
1113
1114 if (count & 0x80)
1115 {
1116 count = (UCHAR)((count & 0x7f) + 1);
1117
1118 /* Skip repeated pixel value. */
1119 get++;
1120 }
1121 else
1122 {
1123 count++;
1124
1125 /* Skip raw pixel values. */
1126 get += count;
1127 }
1128 xval += count;
1129 }
1130 }
1131
1132 /* Now we are on the first visible row, copy pixels until we get
1133 to the end of the last visible row. */
1134 palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
1135 putrow = (GX_COLOR *)context -> gx_draw_context_memory;
1136 putrow += yval * context -> gx_draw_context_pitch;
1137 putrow += xpos;
1138
1139 while (yval <= rotated_clip.gx_rectangle_bottom)
1140 {
1141 xval = xpos;
1142 put = putrow;
1143
1144 while (xval < xpos + pixelmap -> gx_pixelmap_height)
1145 {
1146 count = *get++;
1147 if (count & 0x80)
1148 {
1149 /* repeated value */
1150 count = (UCHAR)((count & 0x7f) + 1);
1151 if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
1152 {
1153 pixel = palette[*get];
1154 if (brush_alpha == 0xff)
1155 {
1156 while (count--)
1157 {
1158 if (xval >= rotated_clip.gx_rectangle_left &&
1159 xval <= rotated_clip.gx_rectangle_right)
1160 {
1161 *put = pixel;
1162 }
1163 xval++;
1164 put++;
1165 }
1166 }
1167 else
1168 {
1169 while (count--)
1170 {
1171 if (xval >= rotated_clip.gx_rectangle_left &&
1172 xval <= rotated_clip.gx_rectangle_right)
1173 {
1174 blend_func(context, xval, yval, pixel, brush_alpha);
1175 }
1176 xval++;
1177 }
1178 }
1179 }
1180 else
1181 {
1182 xval += count;
1183 put += count;
1184 }
1185
1186 get++;
1187 }
1188 else
1189 {
1190 /* string of non-repeated values */
1191 count++;
1192 if (brush_alpha == 0xff)
1193 {
1194 while (count--)
1195 {
1196 if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
1197 {
1198 if (xval >= rotated_clip.gx_rectangle_left &&
1199 xval <= rotated_clip.gx_rectangle_right)
1200 {
1201 pixel = palette[*get];
1202 *put = pixel;
1203 }
1204 }
1205 get++;
1206 xval++;
1207 put++;
1208 }
1209 }
1210 else
1211 {
1212 while (count--)
1213 {
1214 if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
1215 {
1216 if (xval >= rotated_clip.gx_rectangle_left &&
1217 xval <= rotated_clip.gx_rectangle_right)
1218 {
1219 pixel = palette[*get];
1220 blend_func(context, xval, yval, pixel, brush_alpha);
1221 }
1222 }
1223 get++;
1224 xval++;
1225 }
1226 }
1227 }
1228 }
1229 yval++;
1230 putrow += context -> gx_draw_context_pitch;
1231 }
1232 }
1233
1234 /**************************************************************************/
1235 /* */
1236 /* FUNCTION RELEASE */
1237 /* */
1238 /* _gx_display_driver_32bpp_rotated_565rgb_pixelmap_raw_write */
1239 /* */
1240 /* PORTABLE C */
1241 /* 6.1.4 */
1242 /* AUTHOR */
1243 /* */
1244 /* Kenneth Maxwell, Microsoft Corporation */
1245 /* */
1246 /* DESCRIPTION */
1247 /* */
1248 /* Internal helper function that handles writing of 565rgb format */
1249 /* uncompressed pixlemap file without alpha channel. */
1250 /* */
1251 /* INPUT */
1252 /* */
1253 /* context Drawing context */
1254 /* xpos x-coord of top-left draw point*/
1255 /* ypos y-coord of top-left draw point*/
1256 /* pixelmap Pointer to GX_PIXELMAP struct */
1257 /* */
1258 /* OUTPUT */
1259 /* */
1260 /* None */
1261 /* */
1262 /* CALLS */
1263 /* */
1264 /* None */
1265 /* */
1266 /* CALLED BY */
1267 /* */
1268 /* _gx_display_driver_32bpp_rotated_pixelmap_draw */
1269 /* */
1270 /* RELEASE HISTORY */
1271 /* */
1272 /* DATE NAME DESCRIPTION */
1273 /* */
1274 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
1275 /* */
1276 /**************************************************************************/
_gx_display_driver_32bpp_rotated_565rgb_pixelmap_raw_write(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)1277 static VOID _gx_display_driver_32bpp_rotated_565rgb_pixelmap_raw_write(GX_DRAW_CONTEXT *context,
1278 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1279 {
1280 INT xval;
1281 INT yval;
1282 GX_COLOR *putrow;
1283 USHORT *getrow;
1284 GX_COLOR *put;
1285 GX_CONST USHORT *get;
1286
1287 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
1288 GX_RECTANGLE rotated_clip;
1289
1290 GX_SWAP_VALS(xpos, ypos);
1291
1292 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
1293 {
1294 rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
1295 rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
1296 rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
1297 rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
1298 ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
1299 }
1300 else
1301 {
1302 rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
1303 rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
1304 rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
1305 rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
1306 xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
1307 }
1308
1309 putrow = (GX_COLOR *)context -> gx_draw_context_memory;
1310 putrow += rotated_clip.gx_rectangle_top * context -> gx_draw_context_pitch;
1311 putrow += rotated_clip.gx_rectangle_left;
1312
1313 getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
1314 getrow += pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos);
1315 getrow += (rotated_clip.gx_rectangle_left - xpos);
1316
1317 for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
1318 {
1319 put = putrow;
1320 get = getrow;
1321
1322 for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
1323 {
1324 *put++ = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff,
1325 REDVAL_16BPP(*get) << 3,
1326 GREENVAL_16BPP(*get) << 2,
1327 BLUEVAL_16BPP(*get) << 3);
1328 get++;
1329 }
1330 putrow += context -> gx_draw_context_pitch;
1331 getrow += pixelmap -> gx_pixelmap_height;
1332 }
1333 }
1334
1335 /**************************************************************************/
1336 /* */
1337 /* FUNCTION RELEASE */
1338 /* */
1339 /* _gx_display_driver_24xrgb_rotated_565rgb_pixelmap_compressed_write */
1340 /* */
1341 /* PORTABLE C */
1342 /* 6.1.5 */
1343 /* AUTHOR */
1344 /* */
1345 /* Kenneth Maxwell, Microsoft Corporation */
1346 /* */
1347 /* DESCRIPTION */
1348 /* */
1349 /* Internal helper function that handles writing of rotated compressed */
1350 /* pixelmap data of 565rgb format in 32bpp driver. */
1351 /* */
1352 /* INPUT */
1353 /* */
1354 /* context Drawing context */
1355 /* xpos x-coord of top-left draw point*/
1356 /* ypos y-coord of top-left draw point*/
1357 /* pixelmap Pointer to GX_PIXELMAP struct */
1358 /* */
1359 /* OUTPUT */
1360 /* */
1361 /* None */
1362 /* */
1363 /* CALLS */
1364 /* */
1365 /* _gx_display_driver_24xrgb_pixel_blend */
1366 /* */
1367 /* CALLED BY */
1368 /* */
1369 /* _gx_display_driver_32bpp_rotated_pixelmap_draw */
1370 /* */
1371 /* RELEASE HISTORY */
1372 /* */
1373 /* DATE NAME DESCRIPTION */
1374 /* */
1375 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
1376 /* 03-02-2021 Ting Zhu Modified comment(s), changed */
1377 /* blend function set macro, */
1378 /* resulting in version 6.1.5 */
1379 /* */
1380 /**************************************************************************/
_gx_display_driver_32bpp_rotated_565rgb_pixelmap_compressed_write(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)1381 static VOID _gx_display_driver_32bpp_rotated_565rgb_pixelmap_compressed_write(GX_DRAW_CONTEXT *context,
1382 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1383 {
1384 INT yval;
1385 INT xval;
1386 GX_CONST USHORT *get;
1387 USHORT count;
1388 GX_COLOR pixel;
1389 GX_UBYTE r;
1390 GX_UBYTE g;
1391 GX_UBYTE b;
1392 GX_UBYTE brush_alpha;
1393 GX_COLOR *put;
1394 GX_COLOR *putrow;
1395 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
1396 GX_RECTANGLE rotated_clip;
1397 VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
1398
1399 GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
1400
1401 GX_SWAP_VALS(xpos, ypos);
1402
1403 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
1404 {
1405 rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
1406 rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
1407 rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
1408 rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
1409 ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
1410 }
1411 else
1412 {
1413 rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
1414 rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
1415 rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
1416 rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
1417 xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
1418 }
1419 get = (GX_CONST USHORT *)pixelmap -> gx_pixelmap_data;
1420 brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1421
1422 /* First, skip to the starting row. */
1423 for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++)
1424 {
1425 xval = 0;
1426 while (xval < pixelmap -> gx_pixelmap_height)
1427 {
1428 count = *get++;
1429
1430 if (count & 0x8000)
1431 {
1432 count = (USHORT)((count & 0x7fff) + 1);
1433
1434 /* Skip repeated pixel value. */
1435 get++;
1436 }
1437 else
1438 {
1439 count++;
1440
1441 /* Skip raw pixel values. */
1442 get += count;
1443 }
1444 xval += count;
1445 }
1446 }
1447
1448 /* Now we are on the first visible row, copy pixels until we get
1449 to the enf of the last visible row. */
1450 putrow = (GX_COLOR *)context -> gx_draw_context_memory;
1451 putrow += yval * context -> gx_draw_context_pitch;
1452 putrow += xpos;
1453
1454 while (yval <= rotated_clip.gx_rectangle_bottom)
1455 {
1456 xval = xpos;
1457 put = putrow;
1458
1459 while (xval < xpos + pixelmap -> gx_pixelmap_height)
1460 {
1461 count = *get++;
1462
1463 if (count & 0x8000)
1464 {
1465
1466 /* Repeated value. */
1467 count = (USHORT)((count & 0x7fff) + 1);
1468 pixel = *get++;
1469 r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1470 g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1471 b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1472 pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1473
1474 if (brush_alpha == 0xff)
1475 {
1476 while (count--)
1477 {
1478 if (xval >= rotated_clip.gx_rectangle_left &&
1479 xval <= rotated_clip.gx_rectangle_right)
1480 {
1481 *put = pixel;
1482 }
1483 xval++;
1484 put++;
1485 }
1486 }
1487 else
1488 {
1489 while (count--)
1490 {
1491 if (xval >= rotated_clip.gx_rectangle_left &&
1492 xval <= rotated_clip.gx_rectangle_right)
1493 {
1494 blend_func(context, xval, yval, pixel, brush_alpha);
1495 }
1496 xval++;
1497 }
1498 }
1499 }
1500 else
1501 {
1502
1503 /* String of non-repeated values. */
1504 count++;
1505 if (brush_alpha == 0xff)
1506 {
1507 while (count--)
1508 {
1509 if (xval >= rotated_clip.gx_rectangle_left &&
1510 xval <= rotated_clip.gx_rectangle_right)
1511 {
1512 pixel = *get;
1513 r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1514 g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1515 b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1516 pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1517 *put = pixel;
1518 }
1519 get++;
1520 put++;
1521 xval++;
1522 }
1523 }
1524 else
1525 {
1526 while (count--)
1527 {
1528 if (xval >= rotated_clip.gx_rectangle_left &&
1529 xval <= rotated_clip.gx_rectangle_right)
1530 {
1531 pixel = *get;
1532 r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1533 g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1534 b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1535 pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1536 blend_func(context, xval, yval, pixel, brush_alpha);
1537 }
1538 get++;
1539 xval++;
1540 }
1541 }
1542 }
1543 }
1544 yval++;
1545 putrow += context -> gx_draw_context_pitch;
1546 }
1547 }
1548
1549 /**************************************************************************/
1550 /* */
1551 /* FUNCTION RELEASE */
1552 /* */
1553 /* _gx_display_driver_24xrgb_rotated_565rgb_pixelmap_compressed_alpha_ */
1554 /* write */
1555 /* */
1556 /* PORTABLE C */
1557 /* 6.1.5 */
1558 /* AUTHOR */
1559 /* */
1560 /* Kenneth Maxwell, Microsoft Corporation */
1561 /* */
1562 /* DESCRIPTION */
1563 /* */
1564 /* Internal helper function that handles writing of compressed-alpha */
1565 /* pixelmap data of 565rgb format with 32bpp driver. */
1566 /* */
1567 /* INPUT */
1568 /* */
1569 /* context Drawing context */
1570 /* xpos x-coord of top-left draw point*/
1571 /* ypos y-coord of top-left draw point*/
1572 /* pixelmap Pointer to GX_PIXELMAP struct */
1573 /* */
1574 /* OUTPUT */
1575 /* */
1576 /* None */
1577 /* */
1578 /* CALLS */
1579 /* */
1580 /* _gx_display_driver_24xrgb_pixel_blend */
1581 /* _gx_display_driver_32bpp_pixel_write */
1582 /* */
1583 /* CALLED BY */
1584 /* */
1585 /* _gx_display_driver_32bpp_rotated_pixelmap_draw */
1586 /* */
1587 /* RELEASE HISTORY */
1588 /* */
1589 /* DATE NAME DESCRIPTION */
1590 /* */
1591 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
1592 /* 03-02-2021 Ting Zhu Modified comment(s), changed */
1593 /* blend function set macro, */
1594 /* resulting in version 6.1.5 */
1595 /* */
1596 /**************************************************************************/
_gx_display_driver_32bpp_rotated_565rgb_pixelmap_compressed_alpha_write(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)1597 static VOID _gx_display_driver_32bpp_rotated_565rgb_pixelmap_compressed_alpha_write(GX_DRAW_CONTEXT *context,
1598 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1599 {
1600 INT yval;
1601 INT xval;
1602 GX_CONST GX_UBYTE *get;
1603 GX_UBYTE count;
1604 GX_COLOR pixel;
1605 GX_UBYTE alpha_value;
1606 GX_UBYTE r;
1607 GX_UBYTE g;
1608 GX_UBYTE b;
1609 GX_UBYTE brush_alpha;
1610 GX_UBYTE combined_alpha;
1611
1612 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
1613 GX_RECTANGLE rotated_clip;
1614 VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
1615
1616 GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
1617
1618 GX_SWAP_VALS(xpos, ypos);
1619
1620 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
1621 {
1622 rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
1623 rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
1624 rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
1625 rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
1626 ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
1627 }
1628 else
1629 {
1630 rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
1631 rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
1632 rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
1633 rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
1634 xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
1635 }
1636 get = (GX_CONST GX_UBYTE *)pixelmap -> gx_pixelmap_data;
1637 brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1638
1639 /* First, skip to the starting row. */
1640 for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++)
1641 {
1642 xval = 0;
1643 while (xval < pixelmap -> gx_pixelmap_height)
1644 {
1645 count = *get;
1646
1647 if (count & 0x80)
1648 {
1649 count = (GX_UBYTE)((count & 0x7f) + 1);
1650
1651 /* Skip repeated pixel value. */
1652 get += 4;
1653 }
1654 else
1655 {
1656 count++;
1657
1658 /* Skip raw pixel values. */
1659 get += (count * 4);
1660 }
1661 xval += count;
1662 }
1663 }
1664
1665 /* Now we are on the first visible row, copy pixels until we get
1666 to the enf of the last visible row. */
1667 while (yval <= rotated_clip.gx_rectangle_bottom)
1668 {
1669 xval = xpos;
1670
1671 while (xval < xpos + pixelmap -> gx_pixelmap_height)
1672 {
1673 count = *get;
1674
1675 if (count & 0x80)
1676 {
1677
1678 /* Repeated value. */
1679 count = (GX_UBYTE)((count & 0x7f) + 1);
1680 alpha_value = *(get + 1);
1681
1682 if (alpha_value)
1683 {
1684 if (brush_alpha == 0xff)
1685 {
1686 get += 2;
1687 pixel = *(USHORT *)get;
1688 r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1689 g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1690 b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1691 pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1692 get += 2;
1693 while (count--)
1694 {
1695 if (xval >= rotated_clip.gx_rectangle_left &&
1696 xval <= rotated_clip.gx_rectangle_right)
1697 {
1698 if (alpha_value == 0xff)
1699 {
1700 _gx_display_driver_32bpp_pixel_write(context, xval, yval, pixel);
1701 }
1702 else
1703 {
1704 blend_func(context, xval, yval, pixel, alpha_value);
1705 }
1706 }
1707 xval++;
1708 }
1709 }
1710 else
1711 {
1712 combined_alpha = (GX_UBYTE)(alpha_value * brush_alpha / 255);
1713 if (combined_alpha)
1714 {
1715 get += 2;
1716 pixel = *(USHORT *)get;
1717 r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1718 g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1719 b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1720 pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1721 get += 2;
1722 while (count--)
1723 {
1724 if (xval >= rotated_clip.gx_rectangle_left &&
1725 xval <= rotated_clip.gx_rectangle_right)
1726 {
1727 blend_func(context, xval, yval, pixel, combined_alpha);
1728 }
1729 xval++;
1730 }
1731 }
1732 else
1733 {
1734 get += 4;
1735 xval += count;
1736 }
1737 }
1738 }
1739 else
1740 {
1741 xval += count;
1742 get += 4;
1743 }
1744 }
1745 else
1746 {
1747
1748 /* String of non-repeated values. */
1749 count++;
1750 if (brush_alpha == 0xff)
1751 {
1752 while (count--)
1753 {
1754 if (xval >= rotated_clip.gx_rectangle_left &&
1755 xval <= rotated_clip.gx_rectangle_right)
1756 {
1757 alpha_value = *(get + 1);
1758 get += 2;
1759 if (alpha_value)
1760 {
1761 pixel = *(USHORT *)get;
1762 r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1763 g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1764 b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1765 pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1766 if (alpha_value == 0xff)
1767 {
1768 _gx_display_driver_32bpp_pixel_write(context, xval, yval, pixel);
1769 }
1770 else
1771 {
1772 blend_func(context, xval, yval, pixel, alpha_value);
1773 }
1774 }
1775 get += 2;
1776 }
1777 else
1778 {
1779 get += 4;
1780 }
1781 xval++;
1782 }
1783 }
1784 else
1785 {
1786 while (count--)
1787 {
1788 if (xval >= rotated_clip.gx_rectangle_left &&
1789 xval <= rotated_clip.gx_rectangle_right)
1790 {
1791 alpha_value = *(get + 1);
1792 get += 2;
1793 if (alpha_value)
1794 {
1795 pixel = *(USHORT *)get;
1796 r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1797 g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1798 b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1799 pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1800 combined_alpha = (GX_UBYTE)(brush_alpha * alpha_value / 255);
1801 blend_func(context, xval, yval, pixel, combined_alpha);
1802 }
1803 get += 2;
1804 }
1805 else
1806 {
1807 get += 4;
1808 }
1809 xval++;
1810 }
1811 }
1812 }
1813 }
1814 yval++;
1815 }
1816 }
1817
1818 /**************************************************************************/
1819 /* */
1820 /* FUNCTION RELEASE */
1821 /* */
1822 /* _gx_display_driver_24xrgb_rotated_565rgb_pixelmap_alpha_write */
1823 /* */
1824 /* PORTABLE C */
1825 /* 6.1.5 */
1826 /* AUTHOR */
1827 /* */
1828 /* Kenneth Maxwell, Microsoft Corporation */
1829 /* */
1830 /* DESCRIPTION */
1831 /* */
1832 /* Internal helper function that handles writing of non_compressed */
1833 /* but with alpha channel pixelmap data of 565rgb format with 32bpp */
1834 /* driver. */
1835 /* */
1836 /* INPUT */
1837 /* */
1838 /* context Drawing context */
1839 /* xpos x-coord of top-left draw point*/
1840 /* ypos y-coord of top-left draw point*/
1841 /* pixelmap Pointer to GX_PIXELMAP struct */
1842 /* */
1843 /* OUTPUT */
1844 /* */
1845 /* None */
1846 /* */
1847 /* CALLS */
1848 /* */
1849 /* _gx_display_driver_24xrgb_pixel_blend */
1850 /* _gx_display_driver_32bpp_pixel_write */
1851 /* */
1852 /* CALLED BY */
1853 /* */
1854 /* _gx_display_driver_32bpp_rotated_pixelmap_draw */
1855 /* */
1856 /* RELEASE HISTORY */
1857 /* */
1858 /* DATE NAME DESCRIPTION */
1859 /* */
1860 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
1861 /* 03-02-2021 Ting Zhu Modified comment(s), changed */
1862 /* blend function set macro, */
1863 /* resulting in version 6.1.5 */
1864 /* */
1865 /**************************************************************************/
_gx_display_driver_32bpp_rotated_565rgb_pixelmap_alpha_write(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)1866 static VOID _gx_display_driver_32bpp_rotated_565rgb_pixelmap_alpha_write(GX_DRAW_CONTEXT *context,
1867 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1868 {
1869 INT skipcount;
1870 INT xval;
1871 INT yval;
1872 GX_CONST GX_UBYTE *getalpha;
1873 GX_CONST USHORT *get;
1874 USHORT *getrow;
1875 GX_UBYTE *getrowalpha;
1876 GX_UBYTE r;
1877 GX_UBYTE g;
1878 GX_UBYTE b;
1879 GX_COLOR pixel;
1880 GX_UBYTE alpha_value;
1881
1882 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
1883 GX_RECTANGLE rotated_clip;
1884 VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
1885
1886 GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
1887
1888 GX_SWAP_VALS(xpos, ypos);
1889
1890 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
1891 {
1892 rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
1893 rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
1894 rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
1895 rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
1896 ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
1897 }
1898 else
1899 {
1900 rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
1901 rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
1902 rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
1903 rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
1904 xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
1905 }
1906 skipcount = (pixelmap -> gx_pixelmap_height) * (rotated_clip.gx_rectangle_top - ypos);
1907 skipcount += (rotated_clip.gx_rectangle_left - xpos);
1908 getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
1909 getrow += skipcount;
1910
1911 getrowalpha = (GX_UBYTE *)(pixelmap -> gx_pixelmap_aux_data);
1912 getrowalpha += skipcount;
1913
1914 for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
1915 {
1916 get = getrow;
1917 getalpha = getrowalpha;
1918
1919 for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
1920 {
1921 alpha_value = *getalpha++;
1922 pixel = *get++;
1923 if (alpha_value)
1924 {
1925 r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1926 g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1927 b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1928 pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1929 if (alpha_value == 0xff)
1930 {
1931 _gx_display_driver_32bpp_pixel_write(context, xval, yval, pixel);
1932 }
1933 else
1934 {
1935 blend_func(context, xval, yval, pixel, alpha_value);
1936 }
1937 }
1938 }
1939 getrow += pixelmap -> gx_pixelmap_height;
1940 getrowalpha += pixelmap -> gx_pixelmap_height;
1941 }
1942 }
1943
1944 /**************************************************************************/
1945 /* */
1946 /* FUNCTION RELEASE */
1947 /* */
1948 /* _gx_display_driver_32bpp_rotated_4444argb_pixelmap_alpha_write */
1949 /* */
1950 /* PORTABLE C */
1951 /* 6.1.5 */
1952 /* AUTHOR */
1953 /* */
1954 /* Kenneth Maxwell, Microsoft Corporation */
1955 /* */
1956 /* DESCRIPTION */
1957 /* */
1958 /* Internal helper function that handles writing of uncompressed */
1959 /* pixlemap file with alpha channel of 4444argb format. */
1960 /* */
1961 /* INPUT */
1962 /* */
1963 /* context Drawing context */
1964 /* xpos x-coord of top-left draw point*/
1965 /* ypos y-coord of top-left draw point*/
1966 /* pixelmap Pointer to GX_PIXELMAP struct */
1967 /* */
1968 /* OUTPUT */
1969 /* */
1970 /* None */
1971 /* */
1972 /* CALLS */
1973 /* */
1974 /* _gx_display_driver_24xrgb_pixel_blend */
1975 /* _gx_display_driver_32bpp_pixel_write */
1976 /* */
1977 /* CALLED BY */
1978 /* */
1979 /* _gx_display_driver_32bpp_rotated_pixelmap_draw */
1980 /* */
1981 /* RELEASE HISTORY */
1982 /* */
1983 /* DATE NAME DESCRIPTION */
1984 /* */
1985 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
1986 /* 03-02-2021 Ting Zhu Modified comment(s), changed */
1987 /* blend function set macro, */
1988 /* resulting in version 6.1.5 */
1989 /* */
1990 /**************************************************************************/
_gx_display_driver_32bpp_rotated_4444argb_pixelmap_alpha_write(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)1991 static VOID _gx_display_driver_32bpp_rotated_4444argb_pixelmap_alpha_write(GX_DRAW_CONTEXT *context,
1992 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1993 {
1994 INT skipcount;
1995 INT xval;
1996 INT yval;
1997 USHORT *getrow;
1998 GX_CONST USHORT *get;
1999 UCHAR alpha_value;
2000 ULONG pixel;
2001
2002 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
2003 GX_RECTANGLE rotated_clip;
2004 VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
2005
2006 GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
2007
2008 GX_SWAP_VALS(xpos, ypos);
2009
2010 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
2011 {
2012 rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
2013 rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
2014 rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
2015 rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
2016 ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
2017 }
2018 else
2019 {
2020 rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
2021 rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
2022 rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
2023 rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
2024 xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
2025 }
2026
2027 /* Calculate how many pixels to skip. */
2028 skipcount = (pixelmap -> gx_pixelmap_height) * (rotated_clip.gx_rectangle_top - ypos);
2029 skipcount += (rotated_clip.gx_rectangle_left - xpos);
2030 getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
2031 getrow += skipcount;
2032
2033 for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
2034 {
2035 get = getrow;
2036
2037 for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
2038 {
2039 alpha_value = (UCHAR)(((*get) & 0xf000) >> 8);
2040 if (alpha_value)
2041 {
2042
2043 /* Convert 4444argb pixel to 24xrgb pixel. */
2044 pixel = (GX_COLOR)((((*get) & 0x0f00) << 12) | (((*get) & 0x00f0) << 8) | (((*get) & 0x000f) << 4));
2045 pixel |= 0xff000000;
2046 if (alpha_value == 0xf0)
2047 {
2048 _gx_display_driver_32bpp_pixel_write(context, xval, yval, pixel);
2049 }
2050 else
2051 {
2052 blend_func(context, xval, yval, pixel, alpha_value);
2053 }
2054 }
2055 get++;
2056 }
2057 getrow += pixelmap -> gx_pixelmap_height;
2058 }
2059 }
2060
2061 /**************************************************************************/
2062 /* */
2063 /* FUNCTION RELEASE */
2064 /* */
2065 /* _gx_display_driver_24xrgb_4444argb_rotated_pixelmap_compressed_ */
2066 /* alpha_write */
2067 /* */
2068 /* PORTABLE C */
2069 /* 6.1.5 */
2070 /* AUTHOR */
2071 /* */
2072 /* Kenneth Maxwell, Microsoft Corporation */
2073 /* */
2074 /* DESCRIPTION */
2075 /* */
2076 /* Internal helper function that handles writing of rotated compressed */
2077 /* pixelmap data of 4444argb format. */
2078 /* */
2079 /* INPUT */
2080 /* */
2081 /* context Drawing context */
2082 /* xpos x-coord of top-left draw point*/
2083 /* ypos y-coord of top-left draw point*/
2084 /* pixelmap Pointer to GX_PIXELMAP struct */
2085 /* */
2086 /* OUTPUT */
2087 /* */
2088 /* None */
2089 /* */
2090 /* CALLS */
2091 /* */
2092 /* _gx_display_driver_24xrgb_pixel_blend */
2093 /* */
2094 /* CALLED BY */
2095 /* */
2096 /* _gx_display_driver_32bpp_rotated_pixelmap_draw */
2097 /* */
2098 /* RELEASE HISTORY */
2099 /* */
2100 /* DATE NAME DESCRIPTION */
2101 /* */
2102 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
2103 /* 03-02-2021 Ting Zhu Modified comment(s), changed */
2104 /* blend function set macro, */
2105 /* resulting in version 6.1.5 */
2106 /* */
2107 /**************************************************************************/
_gx_display_driver_32bpp_rotated_4444argb_pixelmap_compressed_alpha_write(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)2108 static VOID _gx_display_driver_32bpp_rotated_4444argb_pixelmap_compressed_alpha_write(GX_DRAW_CONTEXT *context,
2109 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
2110 {
2111 INT yval;
2112 INT xval;
2113 GX_CONST USHORT *get;
2114 USHORT count;
2115 GX_COLOR pixel;
2116 GX_UBYTE falpha;
2117 GX_UBYTE brush_alpha;
2118 GX_UBYTE combined_alpha;
2119 GX_UBYTE r;
2120 GX_UBYTE g;
2121 GX_UBYTE b;
2122 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
2123 GX_RECTANGLE rotated_clip;
2124 VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
2125
2126 GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
2127
2128 GX_SWAP_VALS(xpos, ypos);
2129
2130 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
2131 {
2132 rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
2133 rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
2134 rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
2135 rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
2136 ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
2137 }
2138 else
2139 {
2140 rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
2141 rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
2142 rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
2143 rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
2144 xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
2145 }
2146 get = (GX_CONST USHORT *)pixelmap -> gx_pixelmap_data;
2147 brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
2148
2149 /* First, skip to the starting row. */
2150 for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++)
2151 {
2152 xval = 0;
2153 while (xval < pixelmap -> gx_pixelmap_height)
2154 {
2155 count = *get++;
2156
2157 if (count & 0x8000)
2158 {
2159 count = (USHORT)((count & 0x7fff) + 1);
2160
2161 /* Skip repeated pixel value. */
2162 get++;
2163 }
2164 else
2165 {
2166 count++;
2167
2168 /* Skip raw pixel values. */
2169 get += count;
2170 }
2171 xval += count;
2172 }
2173 }
2174
2175 /* Now we are on the first visible row, copy pixels until we get
2176 to the enf of the last visible row. */
2177 while (yval <= rotated_clip.gx_rectangle_bottom)
2178 {
2179 xval = xpos;
2180
2181 while (xval < xpos + pixelmap -> gx_pixelmap_height)
2182 {
2183 count = *get++;
2184
2185 if (count & 0x8000)
2186 {
2187 /* Repeated value. */
2188 count = (USHORT)((count & 0x7fff) + 1);
2189 pixel = *get++;
2190 falpha = (GX_UBYTE)(((USHORT)pixel & 0xf000) >> 8);
2191 falpha = (falpha >> 4) | falpha;
2192 if (falpha)
2193 {
2194 r = (GX_UBYTE)(((USHORT)pixel & 0x0f00) >> 4);
2195 r = (GX_UBYTE)((r >> 4) | r);
2196 g = (GX_UBYTE)((USHORT)pixel & 0x00f0);
2197 g = (GX_UBYTE)((g >> 4) | g);
2198 b = (GX_UBYTE)((USHORT)pixel & 0x000f);
2199 b = (GX_UBYTE)((b << 4) | b);
2200 pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
2201 if (brush_alpha == 0xff)
2202 {
2203 combined_alpha = falpha;
2204 }
2205 else
2206 {
2207 combined_alpha = (GX_UBYTE)(brush_alpha * falpha / 255);
2208 }
2209
2210 while (count--)
2211 {
2212 if (xval >= rotated_clip.gx_rectangle_left &&
2213 xval <= rotated_clip.gx_rectangle_right)
2214 {
2215 blend_func(context, xval, yval, pixel, combined_alpha);
2216 }
2217 xval++;
2218 }
2219 }
2220 else
2221 {
2222 xval += count;
2223 }
2224 }
2225 else
2226 {
2227
2228 /* String of non-repeated values. */
2229 count++;
2230 if (brush_alpha == 0xff)
2231 {
2232 while (count--)
2233 {
2234 if (xval >= rotated_clip.gx_rectangle_left &&
2235 xval <= rotated_clip.gx_rectangle_right)
2236 {
2237 pixel = *get;
2238 falpha = (GX_UBYTE)(((USHORT)pixel & 0xf000) >> 8);
2239 falpha = (falpha >> 4) | falpha;
2240 r = (GX_UBYTE)(((USHORT)pixel & 0x0f00) >> 4);
2241 r = (GX_UBYTE)((r >> 4) | r);
2242 g = (GX_UBYTE)((USHORT)pixel & 0x00f0);
2243 g = (GX_UBYTE)((g >> 4) | g);
2244 b = (GX_UBYTE)((USHORT)pixel & 0x000f);
2245 b = (GX_UBYTE)((b << 4) | b);
2246 pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
2247 if (falpha)
2248 {
2249 blend_func(context, xval, yval, pixel, falpha);
2250 }
2251 }
2252 get++;
2253 xval++;
2254 }
2255 }
2256 else
2257 {
2258 while (count--)
2259 {
2260 if (xval >= rotated_clip.gx_rectangle_left &&
2261 xval <= rotated_clip.gx_rectangle_right)
2262 {
2263 pixel = *get;
2264 falpha = (GX_UBYTE)(((USHORT)pixel & 0xf000) >> 8);
2265 falpha = (falpha >> 4) | falpha;
2266 combined_alpha = (GX_UBYTE)(falpha * brush_alpha / 255);
2267 r = (GX_UBYTE)(((USHORT)pixel & 0x0f00) >> 4);
2268 r = (GX_UBYTE)((r >> 4) | r);
2269 g = (GX_UBYTE)((USHORT)pixel & 0x00f0);
2270 g = (GX_UBYTE)((g >> 4) | g);
2271 b = (GX_UBYTE)((USHORT)pixel & 0x000f);
2272 b = (GX_UBYTE)((b << 4) | b);
2273 pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
2274 blend_func(context, xval, yval, pixel, combined_alpha);
2275 }
2276 get++;
2277 xval++;
2278 }
2279 }
2280 }
2281 }
2282 yval++;
2283 }
2284 }
2285
2286 /**************************************************************************/
2287 /* */
2288 /* FUNCTION RELEASE */
2289 /* */
2290 /* _gx_display_driver_24xrgb_rotated_pixelmap_draw PORTABLE C */
2291 /* 6.1.5 */
2292 /* AUTHOR */
2293 /* */
2294 /* Kenneth Maxwell, Microsoft Corporation */
2295 /* */
2296 /* DESCRIPTION */
2297 /* */
2298 /* 32xrgb format screen driver pixelmap drawing function that handles */
2299 /* compressed or uncompress, with or without alpha channel. */
2300 /* */
2301 /* INPUT */
2302 /* */
2303 /* context Drawing context */
2304 /* xpos x-coord of top-left draw point*/
2305 /* ypos y-coord of top-left draw point*/
2306 /* pixelmap Pointer to GX_PIXELMAP struct */
2307 /* */
2308 /* OUTPUT */
2309 /* */
2310 /* None */
2311 /* */
2312 /* CALLS */
2313 /* */
2314 /* _gx_display_driver_24xrgb_rotated_palette_pixelmap_transparent_ */
2315 /* compressed_write */
2316 /* _gx_display_driver_24xrgb_rotated_palette_pixelmap_transparent_write*/
2317 /* _gx_display_driver_24xrgb_rotated_palette_pixelmap_compressed_write */
2318 /* _gx_display_driver_24xrgb_rotated_palette_pixelmap_write */
2319 /* _gx_display_driver_24xrgb_rotated_4444argb_pixelmap_compressed_ */
2320 /* alpha_write */
2321 /* _gx_display_driver_24xrgb_rotated_4444argb_pixelmap_alpha_write */
2322 /* _gx_display_driver_24xrgb_rotated_565rgb_pixelmap_compressed_alpha_ */
2323 /* write */
2324 /* _gx_display_driver_24xrgb_rotated_565rgb_pixelmap_alpha_write */
2325 /* _gx_display_driver_24xrgb_rotated_565rgb_pixelmap_compressed_write */
2326 /* _gx_display_driver_24xrgb_rotated_565rgb_pixelmap_raw_write */
2327 /* _gx_display_driver_24xrgb_rotated_pixelmap_compressed_alpha_write */
2328 /* _gx_display_driver_24xrgb_rotated_pixelmap_alpha_write */
2329 /* _gx_display_driver_24xrgb_rotated_pixelmap_compressed_write */
2330 /* _gx_display_driver_24xrgb_rotated_pixelmap_raw_write */
2331 /* _gx_display_driver_24xrgb_rotated_pixelmap_blend */
2332 /* */
2333 /* CALLED BY */
2334 /* */
2335 /* GUIX Internal Code */
2336 /* */
2337 /* RELEASE HISTORY */
2338 /* */
2339 /* DATE NAME DESCRIPTION */
2340 /* */
2341 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */
2342 /* 03-02-2021 Ting Zhu Modified comment(s), */
2343 /* added 8bit palette table */
2344 /* NULL pointer check, */
2345 /* resulting in version 6.1.5 */
2346 /* */
2347 /**************************************************************************/
_gx_display_driver_32bpp_rotated_pixelmap_draw(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap)2348 VOID _gx_display_driver_32bpp_rotated_pixelmap_draw(GX_DRAW_CONTEXT *context,
2349 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
2350 {
2351 GX_BOOL drawn = GX_FALSE;
2352 GX_UBYTE brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
2353
2354 if (brush_alpha == 0)
2355 {
2356 /* Draw nothing here. Just return. */
2357 return;
2358 }
2359
2360 switch (pixelmap -> gx_pixelmap_format)
2361 {
2362 case GX_COLOR_FORMAT_8BIT_PALETTE:
2363 if (pixelmap -> gx_pixelmap_aux_data == GX_NULL)
2364 {
2365
2366 /* Palette data is not availlable. */
2367 return;
2368 }
2369
2370 if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
2371 {
2372 if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2373 {
2374 /* Compressed with transparent. */
2375 _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_compressed_write(context, xpos, ypos, pixelmap);
2376 drawn = GX_TRUE;
2377 }
2378 else
2379 {
2380 /* No compression with transparent. */
2381 if (brush_alpha == 0xff)
2382 {
2383 _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_write(context, xpos, ypos, pixelmap);
2384 drawn = GX_TRUE;
2385 }
2386 }
2387 }
2388 else
2389 {
2390 if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2391 {
2392 /* Compressed with no alpha. */
2393 _gx_display_driver_32bpp_rotated_palette_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2394 drawn = GX_TRUE;
2395 }
2396 else
2397 {
2398 /* No compression or alpha. */
2399 if (brush_alpha == 0xff)
2400 {
2401 _gx_display_driver_32bpp_rotated_palette_pixelmap_write(context, xpos, ypos, pixelmap);
2402 drawn = GX_TRUE;
2403 }
2404 }
2405 }
2406 break;
2407
2408 case GX_COLOR_FORMAT_4444ARGB:
2409 if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2410 {
2411 /* Compressed. */
2412 _gx_display_driver_32bpp_rotated_4444argb_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2413 drawn = GX_TRUE;
2414 }
2415 else
2416 {
2417 /* No compression. */
2418 if (brush_alpha == 0xff)
2419 {
2420 _gx_display_driver_32bpp_rotated_4444argb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2421 drawn = GX_TRUE;
2422 }
2423 }
2424 break;
2425
2426 case GX_COLOR_FORMAT_565RGB:
2427 if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
2428 {
2429 if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2430 {
2431 /* Compressed with alpha. */
2432 _gx_display_driver_32bpp_rotated_565rgb_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2433 drawn = GX_TRUE;
2434 }
2435 else
2436 {
2437 /* Uncompressed with alpha. */
2438 if (brush_alpha == 0xff)
2439 {
2440 _gx_display_driver_32bpp_rotated_565rgb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2441 drawn = GX_TRUE;
2442 }
2443 }
2444 }
2445 else
2446 {
2447 if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2448 {
2449
2450 /* Compressed without alpha. */
2451 _gx_display_driver_32bpp_rotated_565rgb_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2452 drawn = GX_TRUE;
2453 }
2454 else
2455 {
2456
2457 /* Uncompressed withou alpha. */
2458 if (brush_alpha == 0xff)
2459 {
2460 _gx_display_driver_32bpp_rotated_565rgb_pixelmap_raw_write(context, xpos, ypos, pixelmap);
2461 drawn = GX_TRUE;
2462 }
2463 }
2464 }
2465 break;
2466
2467 case GX_COLOR_FORMAT_24XRGB:
2468 case GX_COLOR_FORMAT_32ARGB:
2469 if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
2470 {
2471 if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2472 {
2473
2474 /* Has both compression and alpha. */
2475 _gx_display_driver_32bpp_rotated_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2476 drawn = GX_TRUE;
2477 }
2478 else
2479 {
2480
2481 /* Alpha, no compression. */
2482 if (brush_alpha == 0xff)
2483 {
2484 _gx_display_driver_32bpp_rotated_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2485 drawn = GX_TRUE;
2486 }
2487 }
2488 }
2489 else
2490 {
2491 if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2492 {
2493
2494 /* Compressed with no alpha. */
2495 _gx_display_driver_32bpp_rotated_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2496 drawn = GX_TRUE;
2497 }
2498 else
2499 {
2500
2501 /* No compression or alpha. */
2502 if (brush_alpha == 0xff)
2503 {
2504 _gx_display_driver_32bpp_rotated_pixelmap_raw_write(context, xpos, ypos, pixelmap);
2505 drawn = GX_TRUE;
2506 }
2507 }
2508 }
2509 break;
2510
2511 default:
2512 break;
2513 }
2514
2515 if ((!drawn) && (brush_alpha != 0xff))
2516 {
2517 _gx_display_driver_32bpp_rotated_pixelmap_blend(context, xpos, ypos, pixelmap, brush_alpha);
2518 }
2519
2520 return;
2521 }
2522
2523