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 /*  FUNCTION                                               RELEASE        */
32 /*                                                                        */
33 /*    _gx_display_driver_24xrgb_pixelmap_raw_blend        PORTABLE C      */
34 /*                                                           6.1.7        */
35 /*  AUTHOR                                                                */
36 /*                                                                        */
37 /*    Kenneth Maxwell, Microsoft Corporation                              */
38 /*                                                                        */
39 /*  DESCRIPTION                                                           */
40 /*                                                                        */
41 /*    Internal helper function that handles blending of uncompressed      */
42 /*    pixlemap file without alpha channel.                                */
43 /*                                                                        */
44 /*  INPUT                                                                 */
45 /*                                                                        */
46 /*    context                               Drawing context               */
47 /*    xpos                                  x-coord of top-left draw point*/
48 /*    ypos                                  y-coord of top-left draw point*/
49 /*    pixelmap                              Pointer to GX_PIXELMAP struct */
50 /*    alpha                                 blending value 0 to 255       */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    None                                                                */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    _gx_display_driver_24xrgb_pixel_blend Display driver basic function */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    _gx_display_driver_24xrgb_pixelmap_blend                            */
63 /*                                                                        */
64 /*  RELEASE HISTORY                                                       */
65 /*                                                                        */
66 /*    DATE              NAME                      DESCRIPTION             */
67 /*                                                                        */
68 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
69 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
70 /*                                            resulting in version 6.1    */
71 /*  06-02-2021     Kenneth Maxwell          Modified comment(s),          */
72 /*                                            removed unused variable     */
73 /*                                            assignment,                 */
74 /*                                            resulting in version 6.1.7  */
75 /*                                                                        */
76 /**************************************************************************/
_gx_display_driver_24xrgb_pixelmap_raw_blend(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap,GX_UBYTE alpha)77 static VOID _gx_display_driver_24xrgb_pixelmap_raw_blend(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
78 {
79 INT           yval;
80 INT           xval;
81 INT           draw_width;
82 GX_COLOR      color;
83 ULONG        *get;
84 
85 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
86 
87     get = (GX_COLOR *)pixelmap -> gx_pixelmap_data;
88     get +=  pixelmap -> gx_pixelmap_width * (clip -> gx_rectangle_top - ypos);
89     get += (clip -> gx_rectangle_left - xpos);
90 
91     draw_width = clip -> gx_rectangle_right - clip -> gx_rectangle_left + 1;
92 
93     for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
94     {
95         for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
96         {
97             color = *get & 0x00ffffff;
98             get++;
99             _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, color, alpha);
100         }
101         get += pixelmap -> gx_pixelmap_width - draw_width;
102     }
103 }
104 
105 /**************************************************************************/
106 /*                                                                        */
107 /*  FUNCTION                                               RELEASE        */
108 /*                                                                        */
109 /*    _gx_display_driver_24xrgb_pixelmap_alpha_blend      PORTABLE C      */
110 /*                                                           6.1.7        */
111 /*  AUTHOR                                                                */
112 /*                                                                        */
113 /*    Kenneth Maxwell, Microsoft Corporation                              */
114 /*                                                                        */
115 /*  DESCRIPTION                                                           */
116 /*                                                                        */
117 /*    Internal helper function that handles blending of uncompressed      */
118 /*    pixlemap file with alpha channel.                                   */
119 /*                                                                        */
120 /*  INPUT                                                                 */
121 /*                                                                        */
122 /*    context                               Drawing context               */
123 /*    xpos                                  x-coord of top-left draw point*/
124 /*    ypos                                  y-coord of top-left draw point*/
125 /*    pixelmap                              Pointer to GX_PIXELMAP struct */
126 /*    alpha                                 blending value 0 to 255       */
127 /*                                                                        */
128 /*  OUTPUT                                                                */
129 /*                                                                        */
130 /*    None                                                                */
131 /*                                                                        */
132 /*  CALLS                                                                 */
133 /*                                                                        */
134 /*    _gx_display_driver_24xrgb_pixel_blend Display driver basic function */
135 /*                                                                        */
136 /*  CALLED BY                                                             */
137 /*                                                                        */
138 /*    _gx_display_driver_24xrgb_pixelmap_blend                            */
139 /*                                                                        */
140 /*  RELEASE HISTORY                                                       */
141 /*                                                                        */
142 /*    DATE              NAME                      DESCRIPTION             */
143 /*                                                                        */
144 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
145 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
146 /*                                            resulting in version 6.1    */
147 /*  06-02-2021     Kenneth Maxwell          Modified comment(s),          */
148 /*                                            removed unused variable     */
149 /*                                            assignment,                 */
150 /*                                            resulting in version 6.1.7  */
151 /*                                                                        */
152 /**************************************************************************/
_gx_display_driver_24xrgb_pixelmap_alpha_blend(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap,GX_UBYTE alpha)153 static VOID _gx_display_driver_24xrgb_pixelmap_alpha_blend(GX_DRAW_CONTEXT *context,
154                                                            INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
155 {
156 int           xval;
157 int           yval;
158 int           color;
159 int           width;
160 ULONG        *get;
161 UCHAR         alpha_value;
162 ULONG         combined_alpha;
163 
164 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
165 
166     get = (GX_COLOR *)(pixelmap -> gx_pixelmap_data + (INT)sizeof(GX_COLOR) * pixelmap -> gx_pixelmap_width * (clip -> gx_rectangle_top - ypos));
167     get += (clip -> gx_rectangle_left - xpos);
168 
169     width = clip -> gx_rectangle_right - clip -> gx_rectangle_left + 1;
170 
171     for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
172     {
173         for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
174         {
175             alpha_value = (UCHAR)(*get >> 24);
176 
177             if (alpha_value)
178             {
179                 combined_alpha = alpha_value;
180                 combined_alpha *= alpha;
181                 combined_alpha /= 255;
182 
183                 if (combined_alpha)
184                 {
185                     color = *get & 0x00ffffff;
186                     _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, (GX_COLOR)color, (GX_UBYTE)combined_alpha);
187                 }
188             }
189             get++;
190         }
191         get += pixelmap -> gx_pixelmap_width - width;
192     }
193 }
194 
195 
196 /**************************************************************************/
197 /*                                                                        */
198 /*  FUNCTION                                               RELEASE        */
199 /*                                                                        */
200 /*    _gx_display_driver_24xrgb_palette_pixelmap_blend      PORTABLE C    */
201 /*                                                           6.1.7        */
202 /*  AUTHOR                                                                */
203 /*                                                                        */
204 /*    Kenneth Maxwell, Microsoft Corporation                              */
205 /*                                                                        */
206 /*  DESCRIPTION                                                           */
207 /*                                                                        */
208 /*    Internal helper function that handles writing of uncompressed       */
209 /*    pixlemap file without transparent of palette pixelmap.              */
210 /*                                                                        */
211 /*  INPUT                                                                 */
212 /*                                                                        */
213 /*    context                               Drawing context               */
214 /*    xpos                                  x-coord of top-left draw point*/
215 /*    ypos                                  y-coord of top-left draw point*/
216 /*    pixelmap                              Pointer to GX_PIXELMAP struct */
217 /*    alpha                                 blending value 0 to 255       */
218 /*                                                                        */
219 /*  OUTPUT                                                                */
220 /*                                                                        */
221 /*    None                                                                */
222 /*                                                                        */
223 /*  CALLS                                                                 */
224 /*                                                                        */
225 /*    _gx_display_driver_24xrgb_pixel_blend Display driver basic function */
226 /*                                                                        */
227 /*  CALLED BY                                                             */
228 /*                                                                        */
229 /*    _gx_display_driver_24xrgb_pixelmap_blend                            */
230 /*                                                                        */
231 /*  RELEASE HISTORY                                                       */
232 /*                                                                        */
233 /*    DATE              NAME                      DESCRIPTION             */
234 /*                                                                        */
235 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
236 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
237 /*                                            resulting in version 6.1    */
238 /*  06-02-2021     Kenneth Maxwell          Modified comment(s),          */
239 /*                                            removed unused variable     */
240 /*                                            assignment,                 */
241 /*                                            resulting in version 6.1.7  */
242 /*                                                                        */
243 /**************************************************************************/
_gx_display_driver_24xrgb_palette_pixelmap_blend(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap,GX_UBYTE alpha)244 static VOID _gx_display_driver_24xrgb_palette_pixelmap_blend(GX_DRAW_CONTEXT *context,
245                                                              INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
246 {
247 INT           xval;
248 INT           yval;
249 GX_COLOR      color;
250 INT           width;
251 GX_UBYTE     *get;
252 GX_COLOR     *palette;
253 GX_UBYTE      r;
254 GX_UBYTE      g;
255 GX_UBYTE      b;
256 
257 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
258 
259     get = (GX_UBYTE *)(pixelmap -> gx_pixelmap_data + pixelmap -> gx_pixelmap_width * (clip -> gx_rectangle_top - ypos));
260     get += (clip -> gx_rectangle_left - xpos);
261 
262     palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
263 
264     width = clip -> gx_rectangle_right - clip -> gx_rectangle_left + 1;
265 
266 
267         for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
268         {
269             for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
270             {
271                 r = (GX_UBYTE)REDVAL_32BPP(palette[*get]);
272                 g = (GX_UBYTE)GREENVAL_32BPP(palette[*get]);
273                 b = (GX_UBYTE)BLUEVAL_32BPP(palette[*get++]);
274 
275                 color = (GX_COLOR)ASSEMBLECOLOR_24BPP(r, g, b);
276 
277                 _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, color, alpha);
278             }
279 
280             get += pixelmap -> gx_pixelmap_width - width;
281         }
282 }
283 
284 /**************************************************************************/
285 /*                                                                        */
286 /*  FUNCTION                                               RELEASE        */
287 /*                                                                        */
288 /*    _gx_display_driver_24xrgb_palette_pixelmap_transparent_blend        */
289 /*                                                         PORTABLE C     */
290 /*                                                           6.1.7        */
291 /*  AUTHOR                                                                */
292 /*                                                                        */
293 /*    Kenneth Maxwell, Microsoft Corporation                              */
294 /*                                                                        */
295 /*  DESCRIPTION                                                           */
296 /*                                                                        */
297 /*    Internal helper function that handles writing of uncompressed       */
298 /*    pixlemap file with transparent of palette pixelmap.                 */
299 /*                                                                        */
300 /*  INPUT                                                                 */
301 /*                                                                        */
302 /*    context                               Drawing context               */
303 /*    xpos                                  x-coord of top-left draw point*/
304 /*    ypos                                  y-coord of top-left draw point*/
305 /*    pixelmap                              Pointer to GX_PIXELMAP struct */
306 /*    alpha                                 blending value 0 to 255       */
307 /*                                                                        */
308 /*  OUTPUT                                                                */
309 /*                                                                        */
310 /*    None                                                                */
311 /*                                                                        */
312 /*  CALLS                                                                 */
313 /*                                                                        */
314 /*    _gx_display_driver_24xrgb_pixel_blend Display driver basic function */
315 /*                                                                        */
316 /*  CALLED BY                                                             */
317 /*                                                                        */
318 /*    _gx_display_driver_24xrgb_pixelmap_blend                            */
319 /*                                                                        */
320 /*  RELEASE HISTORY                                                       */
321 /*                                                                        */
322 /*    DATE              NAME                      DESCRIPTION             */
323 /*                                                                        */
324 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
325 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
326 /*                                            resulting in version 6.1    */
327 /*  06-02-2021     Kenneth Maxwell          Modified comment(s),          */
328 /*                                            removed unused variable     */
329 /*                                            assignment,                 */
330 /*                                            resulting in version 6.1.7  */
331 /*                                                                        */
332 /**************************************************************************/
_gx_display_driver_24xrgb_palette_pixelmap_transparent_blend(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap,GX_UBYTE alpha)333 static VOID _gx_display_driver_24xrgb_palette_pixelmap_transparent_blend(GX_DRAW_CONTEXT *context,
334                                                                          INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
335  {
336 INT           xval;
337 INT           yval;
338 GX_COLOR      color;
339 INT           width;
340 GX_UBYTE     *get;
341 GX_COLOR     *palette;
342 GX_UBYTE      r;
343 GX_UBYTE      g;
344 GX_UBYTE      b;
345 
346 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
347 
348      get = (GX_UBYTE *)(pixelmap -> gx_pixelmap_data + pixelmap -> gx_pixelmap_width * (clip -> gx_rectangle_top - ypos));
349      get += (clip -> gx_rectangle_left - xpos);
350 
351      palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
352 
353      width = clip -> gx_rectangle_right - clip -> gx_rectangle_left + 1;
354 
355      for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
356      {
357          for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
358          {
359              if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
360              {
361                  r = (GX_UBYTE)REDVAL_32BPP(palette[*get]);
362                  g = (GX_UBYTE)GREENVAL_32BPP(palette[*get]);
363                  b = (GX_UBYTE)BLUEVAL_32BPP(palette[*get]);
364                  color = (GX_COLOR)ASSEMBLECOLOR_24BPP(r, g, b);
365                  _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, color, alpha);
366              }
367              get++;
368          }
369 
370          get += pixelmap -> gx_pixelmap_width - width;
371      }
372  }
373 
374 /**************************************************************************/
375 /*                                                                        */
376 /*  FUNCTION                                               RELEASE        */
377 /*                                                                        */
378 /*    _gx_display_driver_24xrgb_4444argb_pixelmap_alpha_blend             */
379 /*                                                            PORTABLE C  */
380 /*                                                           6.1          */
381 /*  AUTHOR                                                                */
382 /*                                                                        */
383 /*    Kenneth Maxwell, Microsoft Corporation                              */
384 /*                                                                        */
385 /*  DESCRIPTION                                                           */
386 /*                                                                        */
387 /*    Internal helper function that handles writing of uncompressed       */
388 /*    pixlemap file with alpha channel of 4444argb format.                */
389 /*                                                                        */
390 /*  INPUT                                                                 */
391 /*                                                                        */
392 /*    context                               Drawing context               */
393 /*    xpos                                  x-coord of top-left draw point*/
394 /*    ypos                                  y-coord of top-left draw point*/
395 /*    pixelmap                              Pointer to GX_PIXELMAP struct */
396 /*    alpha                                 blending value 0 to 255       */
397 /*                                                                        */
398 /*  OUTPUT                                                                */
399 /*                                                                        */
400 /*    None                                                                */
401 /*                                                                        */
402 /*  CALLS                                                                 */
403 /*                                                                        */
404 /*    _gx_display_driver_24xrgb_pixel_blend Display driver basic function */
405 /*                                                                        */
406 /*  CALLED BY                                                             */
407 /*                                                                        */
408 /*    _gx_display_driver_24xrgb_pixelmap_blend                            */
409 /*                                                                        */
410 /*  RELEASE HISTORY                                                       */
411 /*                                                                        */
412 /*    DATE              NAME                      DESCRIPTION             */
413 /*                                                                        */
414 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
415 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
416 /*                                            resulting in version 6.1    */
417 /*                                                                        */
418 /**************************************************************************/
_gx_display_driver_24xrgb_4444argb_pixelmap_alpha_blend(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap,GX_UBYTE alpha)419 static VOID _gx_display_driver_24xrgb_4444argb_pixelmap_alpha_blend(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
420 {
421 INT           skipcount;
422 INT           xval;
423 INT           yval;
424 USHORT       *getrow;
425 GX_CONST USHORT *get;
426 UCHAR         falpha;
427 GX_UBYTE      combined_alpha;
428 ULONG         pixel;
429 
430 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
431 
432     /* calculate how many pixels to skip */
433     skipcount = (pixelmap -> gx_pixelmap_width) * (clip -> gx_rectangle_top - ypos);
434     skipcount += (clip -> gx_rectangle_left - xpos);
435     getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
436     getrow += skipcount;
437 
438     for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
439     {
440         get = getrow;
441 
442         for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
443         {
444             /* 0x000f- -> b , 0x00f0- -> g , 0x0f00- -> r , 0xf000- -> a */
445             /*4444bgra - ->  565rgb*/
446             falpha = (UCHAR)(((*get) & 0xf000) >> 8);
447             if (falpha)
448             {
449                 falpha = (GX_UBYTE)(falpha | (falpha >> 4));
450                 pixel = (GX_COLOR)((((*get) & 0x0f00) << 12) | (((*get) & 0x00f0) << 8) | (((*get) & 0x000f) << 4));
451                 combined_alpha = (GX_UBYTE)(falpha * alpha / 255);
452                 _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, combined_alpha);
453             }
454             get++;
455         }
456         getrow += pixelmap -> gx_pixelmap_width;
457     }
458 }
459 
460 /**************************************************************************/
461 /*                                                                        */
462 /*  FUNCTION                                               RELEASE        */
463 /*                                                                        */
464 /*    _gx_display_driver_24xrgb_565rgb_pixelmap_alpha_blend               */
465 /*                                                        PORTABLE C      */
466 /*                                                           6.1          */
467 /*  AUTHOR                                                                */
468 /*                                                                        */
469 /*    Kenneth Maxwell, Microsoft Corporation                              */
470 /*                                                                        */
471 /*  DESCRIPTION                                                           */
472 /*                                                                        */
473 /*    Internal helper function that handles writing of non_compressed     */
474 /*    but with alpha channel pixelmap data of 565rgb format with 32bpp    */
475 /*    driver.                                                             */
476 /*                                                                        */
477 /*  INPUT                                                                 */
478 /*                                                                        */
479 /*    context                               Drawing context               */
480 /*    xpos                                  x-coord of top-left draw point*/
481 /*    ypos                                  y-coord of top-left draw point*/
482 /*    pixelmap                              Pointer to GX_PIXELMAP struct */
483 /*    alpha                                 blending value 0 to 255       */
484 /*                                                                        */
485 /*  OUTPUT                                                                */
486 /*                                                                        */
487 /*    None                                                                */
488 /*                                                                        */
489 /*  CALLS                                                                 */
490 /*                                                                        */
491 /*    _gx_display_driver_24xrgb_pixel_blend Display driver basic function */
492 /*                                                                        */
493 /*  CALLED BY                                                             */
494 /*                                                                        */
495 /*    _gx_display_driver_24xrgb_pixelmap_blend                            */
496 /*                                                                        */
497 /*  RELEASE HISTORY                                                       */
498 /*                                                                        */
499 /*    DATE              NAME                      DESCRIPTION             */
500 /*                                                                        */
501 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
502 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
503 /*                                            resulting in version 6.1    */
504 /*                                                                        */
505 /**************************************************************************/
_gx_display_driver_24xrgb_565rgb_pixelmap_alpha_blend(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap,GX_UBYTE alpha)506 static VOID _gx_display_driver_24xrgb_565rgb_pixelmap_alpha_blend(GX_DRAW_CONTEXT *context,
507                                                                   INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
508 {
509 INT             skipcount;
510 INT             xval;
511 INT             yval;
512 GX_CONST GX_UBYTE *getalpha;
513 GX_CONST USHORT   *get;
514 USHORT         *getrow;
515 GX_UBYTE       *getrowalpha;
516 GX_UBYTE        r;
517 GX_UBYTE        g;
518 GX_UBYTE        b;
519 GX_COLOR        pixel;
520 GX_UBYTE        falpha;
521 GX_UBYTE        combined_alpha;
522 
523 GX_RECTANGLE   *clip = context -> gx_draw_context_clip;
524 
525     skipcount = (pixelmap -> gx_pixelmap_width) * (clip -> gx_rectangle_top - ypos);
526     skipcount += (clip -> gx_rectangle_left - xpos);
527     getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
528     getrow += skipcount;
529 
530     getrowalpha = (GX_UBYTE *)(pixelmap -> gx_pixelmap_aux_data);
531     getrowalpha += skipcount;
532 
533     for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
534     {
535         get = getrow;
536         getalpha = getrowalpha;
537 
538         for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
539         {
540             falpha = *getalpha++;
541             if (falpha)
542             {
543                 combined_alpha = (GX_UBYTE)(falpha * alpha / 255);
544                 pixel = *get;
545                 r = (GX_UBYTE)(((USHORT)pixel & 0xf800) >> 8);
546                 g = (GX_UBYTE)(((USHORT)pixel & 0x07e0) >> 3);
547                 b = (GX_UBYTE)(((USHORT)pixel & 0x001f) << 3);
548                 pixel = (GX_COLOR)ASSEMBLECOLOR_32BPP(r, g, b);
549                 _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, combined_alpha);
550             }
551             get++;
552         }
553         getrow += pixelmap -> gx_pixelmap_width;
554         getrowalpha += pixelmap -> gx_pixelmap_width;
555     }
556 }
557 
558 /**************************************************************************/
559 /*                                                                        */
560 /*  FUNCTION                                               RELEASE        */
561 /*                                                                        */
562 /*    _gx_display_driver_24xrgb_565rgb_pixelmap_raw_blend PORTABLE C      */
563 /*                                                           6.1          */
564 /*  AUTHOR                                                                */
565 /*                                                                        */
566 /*    Kenneth Maxwell, Microsoft Corporation                              */
567 /*                                                                        */
568 /*  DESCRIPTION                                                           */
569 /*                                                                        */
570 /*    Internal helper function that handles writing of 565rgb format      */
571 /*    uncompressed pixlemap file without alpha channel.                   */
572 /*                                                                        */
573 /*  INPUT                                                                 */
574 /*                                                                        */
575 /*    context                               Drawing context               */
576 /*    xpos                                  x-coord of top-left draw point*/
577 /*    ypos                                  y-coord of top-left draw point*/
578 /*    pixelmap                              Pointer to GX_PIXELMAP struct */
579 /*    alpha                                 blending value 0 to 255       */
580 /*                                                                        */
581 /*  OUTPUT                                                                */
582 /*                                                                        */
583 /*    None                                                                */
584 /*                                                                        */
585 /*  CALLS                                                                 */
586 /*                                                                        */
587 /*    _gx_display_driver_24xrgb_pixel_blend Display driver basic function */
588 /*                                                                        */
589 /*  CALLED BY                                                             */
590 /*                                                                        */
591 /*    _gx_display_driver_24xrgb_pixelmap_blend                            */
592 /*                                                                        */
593 /*  RELEASE HISTORY                                                       */
594 /*                                                                        */
595 /*    DATE              NAME                      DESCRIPTION             */
596 /*                                                                        */
597 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
598 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
599 /*                                            resulting in version 6.1    */
600 /*                                                                        */
601 /**************************************************************************/
_gx_display_driver_24xrgb_565rgb_pixelmap_raw_blend(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap,GX_UBYTE alpha)602 static VOID _gx_display_driver_24xrgb_565rgb_pixelmap_raw_blend(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
603 {
604 INT           xval;
605 INT           yval;
606 USHORT       *getrow;
607 GX_CONST USHORT *get;
608 GX_COLOR      pixel;
609 
610 GX_RECTANGLE *clip = context -> gx_draw_context_clip;
611 
612     getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
613     getrow += pixelmap -> gx_pixelmap_width * (clip -> gx_rectangle_top - ypos);
614     getrow += (clip -> gx_rectangle_left - xpos);
615 
616     for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
617     {
618         get = getrow;
619 
620         for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
621         {
622             pixel = (GX_COLOR)ASSEMBLECOLOR_32BPP(REDVAL_16BPP(*get) << 3,
623                                                   GREENVAL_16BPP(*get) << 2,
624                                                   BLUEVAL_16BPP(*get) << 3);
625             _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, alpha);
626             get++;
627         }
628         getrow += pixelmap -> gx_pixelmap_width;
629     }
630 }
631 
632 /**************************************************************************/
633 /*                                                                        */
634 /*  FUNCTION                                               RELEASE        */
635 /*                                                                        */
636 /*    _gx_display_driver_24xrgb_pixelmap_blend            PORTABLE C      */
637 /*                                                           6.1          */
638 /*  AUTHOR                                                                */
639 /*                                                                        */
640 /*    Kenneth Maxwell, Microsoft Corporation                              */
641 /*                                                                        */
642 /*  DESCRIPTION                                                           */
643 /*                                                                        */
644 /*    32xrgb format screen driver pixelmap blending function that         */
645 /*    handles compressed or uncompress, with or without alpha channel.    */
646 /*                                                                        */
647 /*  INPUT                                                                 */
648 /*                                                                        */
649 /*    context                               Drawing context               */
650 /*    xpos                                  x-coord of top-left draw point*/
651 /*    ypos                                  y-coord of top-left draw point*/
652 /*    pixelmap                              Pointer to GX_PIXELMAP struct */
653 /*    alpha                                 blending value 0 to 255       */
654 /*                                                                        */
655 /*  OUTPUT                                                                */
656 /*                                                                        */
657 /*    None                                                                */
658 /*                                                                        */
659 /*  CALLS                                                                 */
660 /*                                                                        */
661 /*    _gx_display_driver_24xrgb_palette_pixelmap_transparent_blend        */
662 /*                                          Real pixelmap draw function.  */
663 /*    _gx_display_driver_24xrgb_palette_pixelmap_blend                    */
664 /*                                          Real pixelmap draw function.  */
665 /*    _gx_display_driver_24xrgb_4444argb_pixelmap_alpha_blend             */
666 /*                                          Real pixelmap draw function.  */
667 /*    _gx_display_driver_24xrgb_565rgb_pixelmap_alpha_blend               */
668 /*                                          Real pixelmap draw function.  */
669 /*    _gx_display_driver_24xrgb_565rgb_pixelmap_raw_blend                 */
670 /*                                          Real pixelmap draw function.  */
671 /*    _gx_display_driver_24xrgb_pixelmap_alpha_blend                      */
672 /*                                          Real pixelmap draw function.  */
673 /*    _gx_display_driver_24xrgb_pixelmap_raw_blend                        */
674 /*                                          Real pixelmap draw function.  */
675 /*                                                                        */
676 /*  CALLED BY                                                             */
677 /*                                                                        */
678 /*    GUIX Internal Code                                                  */
679 /*                                                                        */
680 /*  RELEASE HISTORY                                                       */
681 /*                                                                        */
682 /*    DATE              NAME                      DESCRIPTION             */
683 /*                                                                        */
684 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
685 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
686 /*                                            resulting in version 6.1    */
687 /*                                                                        */
688 /**************************************************************************/
_gx_display_driver_24xrgb_pixelmap_blend(GX_DRAW_CONTEXT * context,INT xpos,INT ypos,GX_PIXELMAP * pixelmap,GX_UBYTE alpha)689 VOID _gx_display_driver_24xrgb_pixelmap_blend(GX_DRAW_CONTEXT *context,
690                                               INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
691 {
692     if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
693     {
694         return;
695     }
696 
697     switch (pixelmap -> gx_pixelmap_format)
698     {
699     case GX_COLOR_FORMAT_8BIT_PALETTE:
700         if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
701         {
702             _gx_display_driver_24xrgb_palette_pixelmap_transparent_blend(context, xpos, ypos, pixelmap, alpha);
703         }
704         else
705         {
706             _gx_display_driver_24xrgb_palette_pixelmap_blend(context, xpos, ypos, pixelmap, alpha);
707         }
708         break;
709 
710     case GX_COLOR_FORMAT_4444ARGB:
711         _gx_display_driver_24xrgb_4444argb_pixelmap_alpha_blend(context, xpos, ypos, pixelmap, alpha);
712         break;
713 
714     case GX_COLOR_FORMAT_565RGB:
715         if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
716         {
717             _gx_display_driver_24xrgb_565rgb_pixelmap_alpha_blend(context, xpos, ypos, pixelmap, alpha);
718         }
719         else
720         {
721             _gx_display_driver_24xrgb_565rgb_pixelmap_raw_blend(context, xpos, ypos, pixelmap, alpha);
722         }
723         break;
724 
725     case GX_COLOR_FORMAT_24XRGB:
726     case GX_COLOR_FORMAT_32ARGB:
727         if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
728         {
729             _gx_display_driver_24xrgb_pixelmap_alpha_blend(context, xpos, ypos, pixelmap, alpha);
730 
731         }
732         else
733         {
734             _gx_display_driver_24xrgb_pixelmap_raw_blend(context, xpos, ypos, pixelmap, alpha);
735         }
736         break;
737     }
738 
739     return;
740 }
741