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 #include "gx_context.h"
29 
30 #if defined(GX_BRUSH_ALPHA_SUPPORT)
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_raw_blend          */
37 /*                                                        PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Kenneth Maxwell, Microsoft Corporation                              */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    Internal helper function that handles blending of uncompressed      */
46 /*    pixlemap file without alpha channel with brush alpha.               */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    context                               Drawing context               */
51 /*    xstart                                x-coord of line left          */
52 /*    xend                                  x-coord of line right         */
53 /*    y                                     y-coord of line top           */
54 /*    info                                  GX_FILL_PIXELMAP_INFO struct  */
55 /*    alpha                                 Alpha value                   */
56 /*                                                                        */
57 /*  OUTPUT                                                                */
58 /*                                                                        */
59 /*    None                                                                */
60 /*                                                                        */
61 /*  CALLS                                                                 */
62 /*                                                                        */
63 /*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
64 /*                                            blend function              */
65 /*                                                                        */
66 /*  CALLED BY                                                             */
67 /*                                                                        */
68 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_draw               */
69 /*                                                                        */
70 /*  RELEASE HISTORY                                                       */
71 /*                                                                        */
72 /*    DATE              NAME                      DESCRIPTION             */
73 /*                                                                        */
74 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
75 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
76 /*                                            resulting in version 6.1    */
77 /*                                                                        */
78 /**************************************************************************/
_gx_display_driver_8bpp_horizontal_pixelmap_line_raw_blend(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT y,GX_FILL_PIXELMAP_INFO * info,GX_UBYTE alpha)79 static VOID _gx_display_driver_8bpp_horizontal_pixelmap_line_raw_blend(GX_DRAW_CONTEXT *context,
80                                                                        INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
81 {
82 INT                xval;
83 INT                offset;
84 INT                pic_width;
85 GX_CONST GX_UBYTE *get;
86 GX_PIXELMAP       *pixelmap;
87 VOID               (*blend_func)(GX_DRAW_CONTEXT *, INT, INT, GX_COLOR, GX_UBYTE);
88 
89     pixelmap = info -> pixelmap;
90 
91     blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
92     if (blend_func == GX_NULL)
93     {
94         return;
95     }
96 
97     pic_width = pixelmap -> gx_pixelmap_width;
98 
99     if ((info -> draw) && (xstart <= xend))
100     {
101         get = info -> current_pixel_ptr;
102 
103         /* Calculate the map offset in x-axis. */
104         offset = (info -> x_offset % pic_width);
105 
106         for (xval = xstart; xval <= xend; xval++)
107         {
108             /* get points to the start postion of this row. So we need to calculate its position. */
109             blend_func(context, xval, y, *(get + offset), alpha);
110             offset++;
111             if (offset >= pic_width)
112             {
113                 offset -= pic_width;
114             }
115         }
116     }
117 
118     /* This line is drawn. Update the pointer position for next row. */
119     info -> current_pixel_ptr += (UINT)pic_width * sizeof(GX_UBYTE);
120 }
121 
122 /**************************************************************************/
123 /*                                                                        */
124 /*  FUNCTION                                               RELEASE        */
125 /*                                                                        */
126 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_blend   */
127 /*                                                        PORTABLE C      */
128 /*                                                           6.1          */
129 /*  AUTHOR                                                                */
130 /*                                                                        */
131 /*    Kenneth Maxwell, Microsoft Corporation                              */
132 /*                                                                        */
133 /*  DESCRIPTION                                                           */
134 /*                                                                        */
135 /*    Internal helper function that handles blending of compressed        */
136 /*    pixlemap file with brush alpha.                                     */
137 /*                                                                        */
138 /*  INPUT                                                                 */
139 /*                                                                        */
140 /*    context                               Drawing context               */
141 /*    xstart                                x-coord of line left          */
142 /*    xend                                  x-coord of line right         */
143 /*    y                                     y-coord of line top           */
144 /*    info                                  GX_FILL_PIXELMAP_INFO struct  */
145 /*    alpha                                 Alpha value                   */
146 /*                                                                        */
147 /*  OUTPUT                                                                */
148 /*                                                                        */
149 /*    None                                                                */
150 /*                                                                        */
151 /*  CALLS                                                                 */
152 /*                                                                        */
153 /*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
154 /*                                            blend function              */
155 /*                                                                        */
156 /*  CALLED BY                                                             */
157 /*                                                                        */
158 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_draw               */
159 /*                                                                        */
160 /*  RELEASE HISTORY                                                       */
161 /*                                                                        */
162 /*    DATE              NAME                      DESCRIPTION             */
163 /*                                                                        */
164 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
165 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
166 /*                                            resulting in version 6.1    */
167 /*                                                                        */
168 /**************************************************************************/
_gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_blend(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT y,GX_FILL_PIXELMAP_INFO * info,GX_UBYTE alpha)169 static VOID _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_blend(GX_DRAW_CONTEXT *context,
170                                                                               INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
171 {
172 INT                start_pos;
173 INT                xval;
174 GX_UBYTE           count;
175 GX_CONST GX_UBYTE *get = GX_NULL;
176 GX_UBYTE           pixel;
177 GX_PIXELMAP       *pixelmap;
178 VOID               (*blend_func)(GX_DRAW_CONTEXT *, INT, INT, GX_COLOR, GX_UBYTE);
179 
180     pixelmap = info -> pixelmap;
181     blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
182     if (blend_func == GX_NULL)
183     {
184         return;
185     }
186 
187     if ((info -> draw) && (xstart <= xend))
188     {
189         /* This means it's the draw operation. */
190         /* Skip the invisible pixels.*/
191         start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
192 
193         /*Repeat the draw operation to fill the whole dirty area.*/
194         while (start_pos <= xend)
195         {
196             xval = start_pos;
197 
198             /*Start from where we need to repeat.*/
199             get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
200 
201             while (xval < start_pos + pixelmap -> gx_pixelmap_width)
202             {
203                 count = *get++;
204                 if (count & 0x80)
205                 {
206                     count = (GX_UBYTE)((count & 0x7f) + 1);
207                     pixel = *get++;
208                     while (count--)
209                     {
210                         if (xval >= xstart && xval <= xend)
211                         {
212                             blend_func(context, xval, y, pixel, alpha);
213                         }
214                         xval++;
215                     }
216                 }
217                 else
218                 {
219                     count++;
220                     while (count--)
221                     {
222                         pixel = *get++;
223                         if (xval >= xstart && xval <= xend)
224                         {
225                             blend_func(context, xval, y, pixel, alpha);
226                         }
227                         xval++;
228                     }
229                 }
230             }
231             start_pos += pixelmap -> gx_pixelmap_width;
232         }
233     }
234     else
235     {
236         xval = 0;
237         get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
238         while (xval < pixelmap -> gx_pixelmap_width)
239         {
240             count = *get++;
241             if (count & 0x80)
242             {
243                 count = (GX_UBYTE)((count & 0x7f) + 1);
244                 get++;
245             }
246             else
247             {
248                 count++;
249                 get += count;
250             }
251             xval += count;
252         }
253     }
254 
255     /* This line is drawn. cache the pointer for next line draw. */
256     info -> current_pixel_ptr = (GX_UBYTE *)get;
257 }
258 
259 /**************************************************************************/
260 /*                                                                        */
261 /*  FUNCTION                                               RELEASE        */
262 /*                                                                        */
263 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_alpha_blend        */
264 /*                                                        PORTABLE C      */
265 /*                                                           6.1          */
266 /*  AUTHOR                                                                */
267 /*                                                                        */
268 /*    Kenneth Maxwell, Microsoft Corporation                              */
269 /*                                                                        */
270 /*  DESCRIPTION                                                           */
271 /*                                                                        */
272 /*    Internal helper function that handles blending of uncompressed      */
273 /*    pixlemap file with alpha channel with brush alpha.                  */
274 /*                                                                        */
275 /*  INPUT                                                                 */
276 /*                                                                        */
277 /*    context                               Drawing context               */
278 /*    xstart                                x-coord of line left          */
279 /*    xend                                  x-coord of line end           */
280 /*    y                                     y-coord of line top           */
281 /*    info                                  GX_FILL_PIXELMAP_INFO struct  */
282 /*    alpha                                 Alpha value                   */
283 /*                                                                        */
284 /*  OUTPUT                                                                */
285 /*                                                                        */
286 /*    None                                                                */
287 /*                                                                        */
288 /*  CALLS                                                                 */
289 /*                                                                        */
290 /*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
291 /*                                            blend function              */
292 /*                                                                        */
293 /*  CALLED BY                                                             */
294 /*                                                                        */
295 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_draw               */
296 /*                                                                        */
297 /*  RELEASE HISTORY                                                       */
298 /*                                                                        */
299 /*    DATE              NAME                      DESCRIPTION             */
300 /*                                                                        */
301 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
302 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
303 /*                                            resulting in version 6.1    */
304 /*                                                                        */
305 /**************************************************************************/
_gx_display_driver_8bpp_horizontal_pixelmap_line_alpha_blend(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT y,GX_FILL_PIXELMAP_INFO * info,GX_UBYTE alpha)306 static VOID _gx_display_driver_8bpp_horizontal_pixelmap_line_alpha_blend(GX_DRAW_CONTEXT *context,
307                                                                          INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
308 {
309 INT                xval;
310 GX_CONST GX_UBYTE *get;
311 GX_CONST GX_UBYTE *get_alpha;
312 GX_UBYTE           falpha;
313 GX_UBYTE           pixel;
314 GX_PIXELMAP       *pixelmap;
315 INT                pic_width;
316 INT                offset;
317 GX_UBYTE           combined_alpha;
318 VOID               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
319 
320     blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
321     pixelmap = info -> pixelmap;
322 
323     if (blend_func == GX_NULL)
324     {
325         return;
326     }
327 
328     pic_width = pixelmap -> gx_pixelmap_width;
329     if ((info -> draw) && (xstart <= xend))
330     {
331         get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
332         get_alpha = (GX_CONST GX_UBYTE *)info -> current_aux_ptr;
333 
334         /*calculate the offset.*/
335         offset = (info -> x_offset % pic_width);
336 
337         for (xval = xstart; xval <= xend; xval++)
338         {
339             /*get points to the start postion of this row. So we need to calculate its position.*/
340             pixel = *(get + offset);
341             falpha = *(get_alpha + offset);
342             if (falpha)
343             {
344                 combined_alpha = (GX_UBYTE)(falpha * alpha / 255);
345                 blend_func(context, xval, y, pixel, combined_alpha);
346             }
347 
348             offset++;
349             if (offset >= pic_width)
350             {
351                 offset -= pic_width;
352             }
353         }
354     }
355 
356     info -> current_pixel_ptr += (UINT)pic_width * sizeof(GX_UBYTE);
357     info -> current_aux_ptr += (UINT)pic_width * sizeof(GX_UBYTE);
358 }
359 
360 
361 /**************************************************************************/
362 /*                                                                        */
363 /*  FUNCTION                                               RELEASE        */
364 /*                                                                        */
365 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_alpha   */
366 /*        _blend                                                          */
367 /*                                                        PORTABLE C      */
368 /*                                                           6.1          */
369 /*  AUTHOR                                                                */
370 /*                                                                        */
371 /*    Kenneth Maxwell, Microsoft Corporation                              */
372 /*                                                                        */
373 /*  DESCRIPTION                                                           */
374 /*                                                                        */
375 /*    Internal helper function that handles blending of compressed        */
376 /*    pixlemap file with alpha channel.                                   */
377 /*                                                                        */
378 /*  INPUT                                                                 */
379 /*                                                                        */
380 /*    context                               Drawing context               */
381 /*    xstart                                x-coord of line left          */
382 /*    xend                                  x-coord of line end           */
383 /*    y                                     y-coord of line top           */
384 /*    info                                  GX_FILL_PIXELMAP_INFO struct  */
385 /*    alpha                                 Alpha value                   */
386 /*                                                                        */
387 /*  OUTPUT                                                                */
388 /*                                                                        */
389 /*    None                                                                */
390 /*                                                                        */
391 /*  CALLS                                                                 */
392 /*                                                                        */
393 /*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
394 /*                                            blend function              */
395 /*                                                                        */
396 /*  CALLED BY                                                             */
397 /*                                                                        */
398 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_draw               */
399 /*                                                                        */
400 /*  RELEASE HISTORY                                                       */
401 /*                                                                        */
402 /*    DATE              NAME                      DESCRIPTION             */
403 /*                                                                        */
404 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
405 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
406 /*                                            resulting in version 6.1    */
407 /*                                                                        */
408 /**************************************************************************/
_gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_alpha_blend(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT y,GX_FILL_PIXELMAP_INFO * info,GX_UBYTE alpha)409 static VOID _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_alpha_blend(GX_DRAW_CONTEXT *context,
410                                                                                     INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
411 {
412 INT              xval;
413 USHORT           count;
414 INT              start_pos;
415 GX_UBYTE         falpha;
416 GX_UBYTE         combined_alpha;
417 USHORT           pixel;
418 GX_CONST USHORT *get = GX_NULL;
419 GX_PIXELMAP     *pixelmap;
420 VOID             (*blend_func)(GX_DRAW_CONTEXT *, INT, INT, GX_COLOR, GX_UBYTE);
421 
422     pixelmap = info -> pixelmap;
423     blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
424 
425     if (blend_func == GX_NULL)
426     {
427         return;
428     }
429 
430     if ((info -> draw) && (xstart <= xend))
431     {
432         /* Calcualte draw start position. */
433         start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
434 
435         /*Repeat the draw operation to fill the whole dirty area.*/
436         while (start_pos <= xend)
437         {
438             xval = start_pos;
439             get = (GX_CONST USHORT *)info -> current_pixel_ptr;
440             while (xval < start_pos + pixelmap -> gx_pixelmap_width)
441             {
442                 count = *get++;
443 
444                 if (count & 0x8000)
445                 {
446                     /* repeated value */
447                     count = (USHORT)((count & 0x7fff) + 1u);
448                     pixel = *get++;
449                     falpha = (GX_UBYTE)((pixel & 0xff00) >> 8);
450                     combined_alpha = (GX_UBYTE)(falpha * alpha / 255);
451                     if (combined_alpha)
452                     {
453                         while (count--)
454                         {
455                             if (xval >= xstart && xval <= xend)
456                             {
457                                 blend_func(context, xval, y, (GX_COLOR)(pixel & 0xff), combined_alpha);
458                             }
459                             xval++;
460                         }
461                     }
462                     else
463                     {
464                         xval += count;
465                     }
466                 }
467                 else
468                 {
469                     /* string of non-repeated values */
470                     count++;
471                     while (count--)
472                     {
473                         if (xval >= xstart && xval <= xend)
474                         {
475                             pixel = *get;
476                             falpha = (GX_UBYTE)((pixel & 0xff00) >> 8);
477                             combined_alpha = (GX_UBYTE)(falpha * alpha / 255);
478                             blend_func(context, xval, y, (GX_COLOR)(pixel & 0xff), combined_alpha);
479                         }
480                         get++;
481                         xval++;
482                     }
483                 }
484             }
485             start_pos += pixelmap -> gx_pixelmap_width;
486         }
487     }
488     else
489     {
490         xval = 0;
491         get = (GX_CONST USHORT *)info -> current_pixel_ptr;
492 
493         while (xval < pixelmap -> gx_pixelmap_width)
494         {
495             count = *get++;
496             if (count & 0x8000)
497             {
498                 count = (USHORT)((count & 0x7fff) + 1);
499                 get++;
500             }
501             else
502             {
503                 count++;
504                 get += count;
505             }
506             xval += count;
507         }
508     }
509 
510     /* This line is drawn. cache the pointer for next line draw. */
511     info -> current_pixel_ptr = (GX_UBYTE *)get;
512 }
513 
514 #endif /* GX_BRUSH_ALPHA_SUPPORT */
515 
516 /**************************************************************************/
517 /*                                                                        */
518 /*  FUNCTION                                               RELEASE        */
519 /*                                                                        */
520 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_raw_write          */
521 /*                                                        PORTABLE C      */
522 /*                                                           6.1          */
523 /*  AUTHOR                                                                */
524 /*                                                                        */
525 /*    Kenneth Maxwell, Microsoft Corporation                              */
526 /*                                                                        */
527 /*  DESCRIPTION                                                           */
528 /*                                                                        */
529 /*    Internal helper function that handles writing of uncompressed       */
530 /*    pixlemap file without alpha channel.                                */
531 /*                                                                        */
532 /*  INPUT                                                                 */
533 /*                                                                        */
534 /*    context                               Drawing context               */
535 /*    xstart                                x-coord of line left          */
536 /*    xend                                  x-coord of line right         */
537 /*    y                                     y-coord of line top           */
538 /*    info                                  GX_FILL_PIXELMAP_INFO struct  */
539 /*                                                                        */
540 /*  OUTPUT                                                                */
541 /*                                                                        */
542 /*    None                                                                */
543 /*                                                                        */
544 /*  CALLED BY                                                             */
545 /*                                                                        */
546 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_draw               */
547 /*                                                                        */
548 /*  RELEASE HISTORY                                                       */
549 /*                                                                        */
550 /*    DATE              NAME                      DESCRIPTION             */
551 /*                                                                        */
552 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
553 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
554 /*                                            resulting in version 6.1    */
555 /*                                                                        */
556 /**************************************************************************/
_gx_display_driver_8bpp_horizontal_pixelmap_line_raw_write(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT y,GX_FILL_PIXELMAP_INFO * info)557 static VOID _gx_display_driver_8bpp_horizontal_pixelmap_line_raw_write(GX_DRAW_CONTEXT *context,
558                                                                        INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
559 {
560 INT                xval;
561 INT                offset;
562 INT                pic_width;
563 GX_CONST GX_UBYTE *get;
564 GX_UBYTE          *put;
565 GX_PIXELMAP       *pixelmap;
566 
567     pixelmap = info -> pixelmap;
568 
569     pic_width = pixelmap -> gx_pixelmap_width;
570 
571     if ((info -> draw) && (xstart <= xend))
572     {
573         get = info -> current_pixel_ptr;
574         put = (GX_UBYTE *)context -> gx_draw_context_memory;
575         put += y * context -> gx_draw_context_pitch + xstart;
576 
577         /* Calculate the map offset in x-axis. */
578         offset = (info -> x_offset % pic_width);
579 
580         for (xval = xstart; xval <= xend; xval++)
581         {
582             /* get points to the start postion of this row. So we need to calculate its position. */
583             *put++ = *(get + offset);
584             offset++;
585             if (offset >= pic_width)
586             {
587                 offset -= pic_width;
588             }
589         }
590     }
591 
592     /* This line is drawn. Update the pointer position for next row. */
593     info -> current_pixel_ptr += (UINT)pic_width * sizeof(GX_UBYTE);
594 }
595 
596 /**************************************************************************/
597 /*                                                                        */
598 /*  FUNCTION                                               RELEASE        */
599 /*                                                                        */
600 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_write   */
601 /*                                                        PORTABLE C      */
602 /*                                                           6.1          */
603 /*  AUTHOR                                                                */
604 /*                                                                        */
605 /*    Kenneth Maxwell, Microsoft Corporation                              */
606 /*                                                                        */
607 /*  DESCRIPTION                                                           */
608 /*                                                                        */
609 /*    Internal helper function that handles writing of compressed         */
610 /*    pixlemap file.                                                      */
611 /*                                                                        */
612 /*  INPUT                                                                 */
613 /*                                                                        */
614 /*    context                               Drawing context               */
615 /*    xstart                                x-coord of line left          */
616 /*    xend                                  x-coord of line right         */
617 /*    y                                     y-coord of line top           */
618 /*    info                                  GX_FILL_PIXELMAP_INFO struct  */
619 /*                                                                        */
620 /*  OUTPUT                                                                */
621 /*                                                                        */
622 /*    None                                                                */
623 /*                                                                        */
624 /*  CALLS                                                                 */
625 /*                                                                        */
626 /*    None                                                                */
627 /*                                                                        */
628 /*  CALLED BY                                                             */
629 /*                                                                        */
630 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_draw               */
631 /*                                                                        */
632 /*  RELEASE HISTORY                                                       */
633 /*                                                                        */
634 /*    DATE              NAME                      DESCRIPTION             */
635 /*                                                                        */
636 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
637 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
638 /*                                            resulting in version 6.1    */
639 /*                                                                        */
640 /**************************************************************************/
_gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_write(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT y,GX_FILL_PIXELMAP_INFO * info)641 static VOID _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_write(GX_DRAW_CONTEXT *context,
642                                                                               INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
643 {
644 INT                start_pos;
645 INT                xval;
646 GX_UBYTE           count;
647 GX_CONST GX_UBYTE *get = GX_NULL;
648 GX_UBYTE           pixel;
649 GX_UBYTE          *put;
650 GX_PIXELMAP       *pixelmap;
651 
652     pixelmap = info -> pixelmap;
653 
654     if ((info -> draw) && (xstart <= xend))
655     {
656         /* Calculate draw start position. */
657         start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
658 
659         put = (GX_UBYTE *)context -> gx_draw_context_memory;
660         put += y * context -> gx_draw_context_pitch + start_pos;
661 
662         /*Repeat the draw operation to fill the whole dirty area.*/
663         while (start_pos <= xend)
664         {
665             xval = start_pos;
666 
667             /*Start from where we need to repeat.*/
668             get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
669 
670             while (xval < start_pos + pixelmap -> gx_pixelmap_width)
671             {
672                 count = *get++;
673                 if (count & 0x80)
674                 {
675                     count = (GX_UBYTE)((count & 0x7f) + 1);
676                     pixel = *get++;
677                     while (count--)
678                     {
679                         if (xval >= xstart && xval <= xend)
680                         {
681                             *put = pixel;
682                         }
683                         xval++;
684                         put++;
685                     }
686                 }
687                 else
688                 {
689                     count++;
690                     while (count--)
691                     {
692                         pixel = *get++;
693                         if (xval >= xstart && xval <= xend)
694                         {
695                             *put = pixel;
696                         }
697                         xval++;
698                         put++;
699                     }
700                 }
701             }
702             start_pos += pixelmap -> gx_pixelmap_width;
703         }
704     }
705     else
706     {
707         xval = 0;
708         get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
709         while (xval < pixelmap -> gx_pixelmap_width)
710         {
711             count = *get++;
712             if (count & 0x80)
713             {
714                 count = (GX_UBYTE)((count & 0x7f) + 1);
715                 get++;
716             }
717             else
718             {
719                 count++;
720                 get += count;
721             }
722             xval += count;
723         }
724     }
725 
726     /*This line is drawn. cache the pointer for next line draw.*/
727     info -> current_pixel_ptr = (GX_UBYTE *)get;
728 }
729 
730 /**************************************************************************/
731 /*                                                                        */
732 /*  FUNCTION                                               RELEASE        */
733 /*                                                                        */
734 /*    _gx_display_driver_8bpp_horizontal_line_pixelmap_transparent_write  */
735 /*                                                        PORTABLE C      */
736 /*                                                           6.1          */
737 /*  AUTHOR                                                                */
738 /*                                                                        */
739 /*    Kenneth Maxwell, Microsoft Corporation                              */
740 /*                                                                        */
741 /*  DESCRIPTION                                                           */
742 /*                                                                        */
743 /*    Internal helper function that handles writing of uncompressed       */
744 /*    pixlemap file with alpha channel.                                   */
745 /*                                                                        */
746 /*  INPUT                                                                 */
747 /*                                                                        */
748 /*    context                               Drawing context               */
749 /*    xstart                                x-coord of line left          */
750 /*    xend                                  x-coord of line right         */
751 /*    y                                     y-coord of line top           */
752 /*    info                                  GX_FILL_PIXELMAP_INFO struct  */
753 /*                                                                        */
754 /*  OUTPUT                                                                */
755 /*                                                                        */
756 /*    None                                                                */
757 /*                                                                        */
758 /*  CALLS                                                                 */
759 /*                                                                        */
760 /*    None                                                                */
761 /*                                                                        */
762 /*  CALLED BY                                                             */
763 /*                                                                        */
764 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_draw               */
765 /*                                                                        */
766 /*  RELEASE HISTORY                                                       */
767 /*                                                                        */
768 /*    DATE              NAME                      DESCRIPTION             */
769 /*                                                                        */
770 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
771 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
772 /*                                            resulting in version 6.1    */
773 /*                                                                        */
774 /**************************************************************************/
_gx_display_driver_8bpp_horizontal_pixelmap_line_transparent_write(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT y,GX_FILL_PIXELMAP_INFO * info)775 static VOID _gx_display_driver_8bpp_horizontal_pixelmap_line_transparent_write(GX_DRAW_CONTEXT *context,
776                                                                                INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
777 {
778 INT                xval;
779 INT                offset;
780 INT                pic_width;
781 GX_CONST GX_UBYTE *get;
782 GX_UBYTE          *put;
783 GX_PIXELMAP       *pixelmap;
784 GX_UBYTE           pixel;
785 
786     pixelmap = info -> pixelmap;
787     pic_width = pixelmap -> gx_pixelmap_width;
788 
789     if ((info -> draw) && (xstart <= xend))
790     {
791         get = info -> current_pixel_ptr;
792         put = (GX_UBYTE *)context -> gx_draw_context_memory;
793         put += y * context -> gx_draw_context_pitch + xstart;
794 
795         /* Calculate the map offset in x-axis. */
796         offset = (info -> x_offset % pic_width);
797 
798         for (xval = xstart; xval <= xend; xval++)
799         {
800             /* get points to the start postion of this row. So we need to calculate its position. */
801             pixel = *(get + offset);
802             offset++;
803             if (offset >= pic_width)
804             {
805                 offset -= pic_width;
806             }
807 
808             if (pixel != pixelmap -> gx_pixelmap_transparent_color)
809             {
810                 *put = pixel;
811             }
812             put++;
813         }
814     }
815 
816     /* This line is drawn. Update the pointer position for next row. */
817     info -> current_pixel_ptr += (UINT)pic_width * sizeof(GX_UBYTE);
818 }
819 
820 /**************************************************************************/
821 /*                                                                        */
822 /*  FUNCTION                                               RELEASE        */
823 /*                                                                        */
824 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_        */
825 /*    transparent_write                                                   */
826 /*                                                        PORTABLE C      */
827 /*                                                           6.1          */
828 /*  AUTHOR                                                                */
829 /*                                                                        */
830 /*    Kenneth Maxwell, Microsoft Corporation                              */
831 /*                                                                        */
832 /*  DESCRIPTION                                                           */
833 /*                                                                        */
834 /*    Internal helper function that handles writing of compressed         */
835 /*    pixlemap file with alpha channel.                                   */
836 /*                                                                        */
837 /*  INPUT                                                                 */
838 /*                                                                        */
839 /*    context                               Drawing context               */
840 /*    xstart                                x-coord of line left          */
841 /*    xend                                  x-coord of line right         */
842 /*    y                                     y-coord of line top           */
843 /*    info                                  GX_FILL_PIXELMAP_INFO struct  */
844 /*                                                                        */
845 /*  OUTPUT                                                                */
846 /*                                                                        */
847 /*    None                                                                */
848 /*                                                                        */
849 /*  CALLS                                                                 */
850 /*                                                                        */
851 /*    None                                                                */
852 /*                                                                        */
853 /*  CALLED BY                                                             */
854 /*                                                                        */
855 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_draw               */
856 /*                                                                        */
857 /*  RELEASE HISTORY                                                       */
858 /*                                                                        */
859 /*    DATE              NAME                      DESCRIPTION             */
860 /*                                                                        */
861 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
862 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
863 /*                                            resulting in version 6.1    */
864 /*                                                                        */
865 /**************************************************************************/
_gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_transparent_write(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT y,GX_FILL_PIXELMAP_INFO * info)866 static VOID _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_transparent_write(GX_DRAW_CONTEXT *context,
867                                                                                           INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
868 {
869 INT                start_pos;
870 INT                xval;
871 GX_UBYTE           count;
872 GX_CONST GX_UBYTE *get = GX_NULL;
873 GX_UBYTE           pixel;
874 GX_UBYTE          *put;
875 GX_PIXELMAP       *pixelmap;
876 
877     pixelmap = info -> pixelmap;
878 
879     if ((info -> draw) && (xstart <= xend))
880     {
881         /* Calcualte draw start position. */
882         start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
883 
884         put = (GX_UBYTE *)context -> gx_draw_context_memory;
885         put += y * context -> gx_draw_context_pitch + start_pos;
886 
887 
888         /*Repeat the draw operation to fill the whole dirty area.*/
889         while (start_pos <= xend)
890         {
891             xval = start_pos;
892 
893             /*Start from where we need to repeat.*/
894             get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
895 
896             while (xval < start_pos + pixelmap -> gx_pixelmap_width)
897             {
898                 count = *get++;
899                 if (count & 0x80)
900                 {
901                     count = (GX_UBYTE)((count & 0x7f) + 1);
902                     pixel = *get++;
903                     if (pixel != pixelmap -> gx_pixelmap_transparent_color)
904                     {
905                         while (count--)
906                         {
907                             if (xval >= xstart && xval <= xend)
908                             {
909                                 *put = pixel;
910                             }
911                             xval++;
912                             put++;
913                         }
914                     }
915                     else
916                     {
917                         xval += count;
918                         put += count;
919                     }
920                 }
921                 else
922                 {
923                     count++;
924                     while (count--)
925                     {
926                         pixel = *get++;
927 
928                         if (xval >= xstart && xval <= xend)
929                         {
930                             if (pixel != pixelmap -> gx_pixelmap_transparent_color)
931                             {
932                                 *put = pixel;
933                             }
934                         }
935                         xval++;
936                         put++;
937                     }
938                 }
939             }
940             start_pos += pixelmap -> gx_pixelmap_width;
941         }
942     }
943     else
944     {
945         xval = 0;
946         get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
947         while (xval < pixelmap -> gx_pixelmap_width)
948         {
949             count = *get++;
950             if (count & 0x80)
951             {
952                 count = (GX_UBYTE)((count & 0x7f) + 1);
953                 get++;
954             }
955             else
956             {
957                 count++;
958                 get += count;
959             }
960             xval += count;
961         }
962     }
963 
964     /* This line is drawn. cache the pointer for next line draw.*/
965     info -> current_pixel_ptr = (GX_UBYTE *)get;
966 }
967 
968 /**************************************************************************/
969 /*                                                                        */
970 /*  FUNCTION                                               RELEASE        */
971 /*                                                                        */
972 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_alpha_write        */
973 /*                                                        PORTABLE C      */
974 /*                                                           6.1          */
975 /*  AUTHOR                                                                */
976 /*                                                                        */
977 /*    Kenneth Maxwell, Microsoft Corporation                              */
978 /*                                                                        */
979 /*  DESCRIPTION                                                           */
980 /*                                                                        */
981 /*    Internal helper function that handles writing of uncompressed       */
982 /*    pixlemap file with alpha channel.                                   */
983 /*                                                                        */
984 /*  INPUT                                                                 */
985 /*                                                                        */
986 /*    context                               Drawing context               */
987 /*    xstart                                x-coord of line left          */
988 /*    xend                                  x-coord of line end           */
989 /*    y                                     y-coord of line top           */
990 /*    info                                  GX_FILL_PIXELMAP_INFO struct  */
991 /*    alpha                                 Alpha value                   */
992 /*                                                                        */
993 /*  OUTPUT                                                                */
994 /*                                                                        */
995 /*    None                                                                */
996 /*                                                                        */
997 /*  CALLS                                                                 */
998 /*                                                                        */
999 /*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
1000 /*                                            blend function              */
1001 /*    [gx_display_driver_pixel_write]       Basic display driver pixel    */
1002 /*                                            write function              */
1003 /*                                                                        */
1004 /*  CALLED BY                                                             */
1005 /*                                                                        */
1006 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_draw               */
1007 /*                                                                        */
1008 /*  RELEASE HISTORY                                                       */
1009 /*                                                                        */
1010 /*    DATE              NAME                      DESCRIPTION             */
1011 /*                                                                        */
1012 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1013 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1014 /*                                            resulting in version 6.1    */
1015 /*                                                                        */
1016 /**************************************************************************/
_gx_display_driver_8bpp_horizontal_pixelmap_line_alpha_write(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT y,GX_FILL_PIXELMAP_INFO * info)1017 static VOID _gx_display_driver_8bpp_horizontal_pixelmap_line_alpha_write(GX_DRAW_CONTEXT *context,
1018                                                                          INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
1019 {
1020 INT                xval;
1021 GX_CONST GX_UBYTE *get;
1022 GX_CONST GX_UBYTE *get_alpha;
1023 GX_UBYTE           alpha;
1024 GX_UBYTE           pixel;
1025 GX_PIXELMAP       *pixelmap;
1026 INT                pic_width;
1027 INT                offset;
1028 VOID               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
1029 
1030     blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
1031     pixelmap = info -> pixelmap;
1032 
1033     if (blend_func == GX_NULL)
1034     {
1035         return;
1036     }
1037 
1038     pic_width = pixelmap -> gx_pixelmap_width;
1039     if ((info -> draw) && (xstart <= xend))
1040     {
1041         get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
1042         get_alpha = (GX_CONST GX_UBYTE *)info -> current_aux_ptr;
1043 
1044         /*calculate the offset.*/
1045         offset = (info -> x_offset % pic_width);
1046 
1047         for (xval = xstart; xval <= xend; xval++)
1048         {
1049             /*get points to the start postion of this row. So we need to calculate its position.*/
1050             pixel = *(get + offset);
1051             alpha = *(get_alpha + offset);
1052 
1053             blend_func(context, xval, y, pixel, alpha);
1054 
1055             offset++;
1056             if (offset >= pic_width)
1057             {
1058                 offset -= pic_width;
1059             }
1060         }
1061     }
1062 
1063     info -> current_pixel_ptr += (UINT)pic_width * sizeof(GX_UBYTE);
1064     info -> current_aux_ptr += (UINT)pic_width * sizeof(GX_UBYTE);
1065 }
1066 
1067 /**************************************************************************/
1068 /*                                                                        */
1069 /*  FUNCTION                                               RELEASE        */
1070 /*                                                                        */
1071 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_alpha   */
1072 /*        _write                                                          */
1073 /*                                                        PORTABLE C      */
1074 /*                                                           6.1          */
1075 /*  AUTHOR                                                                */
1076 /*                                                                        */
1077 /*    Kenneth Maxwell, Microsoft Corporation                              */
1078 /*                                                                        */
1079 /*  DESCRIPTION                                                           */
1080 /*                                                                        */
1081 /*    Internal helper function that handles writing of compressed         */
1082 /*    pixlemap file with alpha channel.                                   */
1083 /*                                                                        */
1084 /*  INPUT                                                                 */
1085 /*                                                                        */
1086 /*    context                               Drawing context               */
1087 /*    xstart                                x-coord of line left          */
1088 /*    xend                                  x-coord of line end           */
1089 /*    y                                     y-coord of line top           */
1090 /*    info                                  GX_FILL_PIXELMAP_INFO struct  */
1091 /*                                                                        */
1092 /*  OUTPUT                                                                */
1093 /*                                                                        */
1094 /*    None                                                                */
1095 /*                                                                        */
1096 /*  CALLS                                                                 */
1097 /*                                                                        */
1098 /*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
1099 /*                                            blend function              */
1100 /*                                                                        */
1101 /*  CALLED BY                                                             */
1102 /*                                                                        */
1103 /*    _gx_display_driver_8bpp_horizontal_pixelmap_line_draw               */
1104 /*                                                                        */
1105 /*  RELEASE HISTORY                                                       */
1106 /*                                                                        */
1107 /*    DATE              NAME                      DESCRIPTION             */
1108 /*                                                                        */
1109 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1110 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1111 /*                                            resulting in version 6.1    */
1112 /*                                                                        */
1113 /**************************************************************************/
_gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_alpha_write(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT y,GX_FILL_PIXELMAP_INFO * info)1114 static VOID _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_alpha_write(GX_DRAW_CONTEXT *context,
1115                                                                                     INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
1116 {
1117 INT              xval;
1118 USHORT           count;
1119 INT              start_pos;
1120 GX_UBYTE         alpha;
1121 USHORT           pixel;
1122 GX_CONST USHORT *get = GX_NULL;
1123 GX_PIXELMAP     *pixelmap;
1124 VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
1125 
1126     pixelmap = info -> pixelmap;
1127     blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
1128 
1129     if (blend_func == GX_NULL)
1130     {
1131         return;
1132     }
1133 
1134     if ((info -> draw) && (xstart <= xend))
1135     {
1136         /* This means it's the draw operation. */
1137         /* Skip the invisible pixels.*/
1138         start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
1139 
1140         /*Repeat the draw operation to fill the whole dirty area.*/
1141         while (start_pos <= xend)
1142         {
1143             xval = start_pos;
1144             get = (GX_CONST USHORT *)info -> current_pixel_ptr;
1145             while (xval < start_pos + pixelmap -> gx_pixelmap_width)
1146             {
1147                 count = *get++;
1148 
1149                 if (count & 0x8000)
1150                 {
1151                     /* repeated value */
1152                     count = (USHORT)((count & 0x7fff) + 1u);
1153                     pixel = *get++;
1154                     alpha = (GX_UBYTE)((pixel & 0xff00) >> 8);
1155 
1156                     if (alpha)
1157                     {
1158                         while (count--)
1159                         {
1160                             if (xval >= xstart && xval <= xend)
1161                             {
1162                                 blend_func(context, xval, y, (GX_COLOR)(pixel & 0xff), alpha);
1163                             }
1164                             xval++;
1165                         }
1166                     }
1167                     else
1168                     {
1169                         xval += count;
1170                     }
1171                 }
1172                 else
1173                 {
1174                     /* string of non-repeated values */
1175                     count++;
1176                     while (count--)
1177                     {
1178                         if (xval >= xstart && xval <= xend)
1179                         {
1180                             pixel = *get;
1181                             alpha = (GX_UBYTE)((pixel & 0xff00) >> 8);
1182                             if (alpha)
1183                             {
1184                                 blend_func(context, xval, y, (GX_COLOR)(pixel & 0xff), alpha);
1185                             }
1186                         }
1187                         get++;
1188                         xval++;
1189                     }
1190                 }
1191             }
1192             start_pos += pixelmap -> gx_pixelmap_width;
1193         }
1194     }
1195     else
1196     {
1197         xval = 0;
1198         get = (GX_CONST USHORT *)info -> current_pixel_ptr;
1199 
1200         while (xval < pixelmap -> gx_pixelmap_width)
1201         {
1202             count = *get++;
1203             if (count & 0x8000)
1204             {
1205                 count = (USHORT)((count & 0x7fff) + 1);
1206                 get++;
1207             }
1208             else
1209             {
1210                 count++;
1211                 get += count;
1212             }
1213             xval += count;
1214         }
1215     }
1216 
1217     /*This line is drawn. cache the pointer for next line draw.*/
1218     info -> current_pixel_ptr = (GX_UBYTE *)get;
1219 }
1220 
1221 /**************************************************************************/
1222 /*                                                                        */
1223 /*  FUNCTION                                               RELEASE        */
1224 /*                                                                        */
1225 /*    _gx_display_driver_8bpp_pixelmap_draw               PORTABLE C      */
1226 /*                                                           6.1          */
1227 /*  AUTHOR                                                                */
1228 /*                                                                        */
1229 /*    Kenneth Maxwell, Microsoft Corporation                              */
1230 /*                                                                        */
1231 /*  DESCRIPTION                                                           */
1232 /*                                                                        */
1233 /*    8bit screen driver pixelmap drawing function that handles           */
1234 /*    compressed or uncompress, with or without alpha channel.            */
1235 /*                                                                        */
1236 /*  INPUT                                                                 */
1237 /*                                                                        */
1238 /*    context                               Drawing context               */
1239 /*    xstart                                x-coord of line left          */
1240 /*    xend                                  x-coord of line end           */
1241 /*    y                                     y-coord of line top           */
1242 /*    info                                  GX_FILL_PIXELMAP_INFO struct  */
1243 /*                                                                        */
1244 /*  OUTPUT                                                                */
1245 /*                                                                        */
1246 /*    None                                                                */
1247 /*                                                                        */
1248 /*  CALLS                                                                 */
1249 /*                                                                        */
1250 /*     _gx_display_driver_8bit_horizontal_pixelmap_line_raw_write         */
1251 /*                                          Draw raw pixelmap             */
1252 /*     _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_write  */
1253 /*                                          Draw pixelmap with            */
1254 /*                                            compression                 */
1255 /*     _gx_display_driver_8bpp_horizontal_pixelmap_line_transparent_write */
1256 /*                                          Draw pixelmap with            */
1257 /*                                            transparency                */
1258 /*     _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_       */
1259 /*     transparent_write                                                  */
1260 /*                                          Draw pixelmap with            */
1261 /*                                            transparency and compression*/
1262 /*                                                                        */
1263 /*  CALLED BY                                                             */
1264 /*                                                                        */
1265 /*    GUIX Internal Code                                                  */
1266 /*                                                                        */
1267 /*  RELEASE HISTORY                                                       */
1268 /*                                                                        */
1269 /*    DATE              NAME                      DESCRIPTION             */
1270 /*                                                                        */
1271 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1272 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1273 /*                                            resulting in version 6.1    */
1274 /*                                                                        */
1275 /**************************************************************************/
_gx_display_driver_8bpp_horizontal_pixelmap_line_draw(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT y,GX_FILL_PIXELMAP_INFO * info)1276 VOID _gx_display_driver_8bpp_horizontal_pixelmap_line_draw(GX_DRAW_CONTEXT *context,
1277                                                            INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
1278 {
1279 
1280     if (info -> pixelmap == GX_NULL)
1281     {
1282         return;
1283     }
1284 
1285     if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
1286     {
1287         if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1288         {
1289             /* has both compression and transparent */
1290             _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_transparent_write(context, xstart, xend, y, info);
1291         }
1292         else
1293         {
1294             /* transparent, no compression */
1295             _gx_display_driver_8bpp_horizontal_pixelmap_line_transparent_write(context, xstart, xend, y, info);
1296         }
1297     }
1298     else
1299     {
1300         if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1301         {
1302             /* compressed with no transparency */
1303             _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_write(context, xstart, xend, y, info);
1304         }
1305         else
1306         {
1307             /* no compression or transaprency */
1308             _gx_display_driver_8bpp_horizontal_pixelmap_line_raw_write(context, xstart, xend, y, info);
1309         }
1310     }
1311 
1312 
1313     /*Current pixelmap has gone over, so the offset pointer should be reset.*/
1314     if (info -> current_pixel_ptr >= info -> pixelmap -> gx_pixelmap_data + info -> pixelmap -> gx_pixelmap_data_size)
1315     {
1316         info -> current_pixel_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_data;
1317         info -> current_aux_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_aux_data;
1318     }
1319 
1320     return;
1321 }
1322 
1323 /**************************************************************************/
1324 /*                                                                        */
1325 /*  FUNCTION                                               RELEASE        */
1326 /*                                                                        */
1327 /*    _gx_display_driver_8bpp_pixelmap_draw               PORTABLE C      */
1328 /*                                                           6.1          */
1329 /*  AUTHOR                                                                */
1330 /*                                                                        */
1331 /*    Kenneth Maxwell, Microsoft Corporation                              */
1332 /*                                                                        */
1333 /*  DESCRIPTION                                                           */
1334 /*                                                                        */
1335 /*    8bit screen driver pixelmap drawing function that handles           */
1336 /*    compressed or uncompress, with or without alpha channel.            */
1337 /*                                                                        */
1338 /*  INPUT                                                                 */
1339 /*                                                                        */
1340 /*    context                               Drawing context               */
1341 /*    xstart                                x-coord of line left          */
1342 /*    xend                                  x-coord of line end           */
1343 /*    y                                     y-coord of line top           */
1344 /*    info                                  GX_FILL_PIXELMAP_INFO struct  */
1345 /*                                                                        */
1346 /*  OUTPUT                                                                */
1347 /*                                                                        */
1348 /*    None                                                                */
1349 /*                                                                        */
1350 /*  CALLS                                                                 */
1351 /*                                                                        */
1352 /*     _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_       */
1353 /*     alpha_blend                                                        */
1354 /*                                          Blend pixelmap with           */
1355 /*                                            compression and alpha       */
1356 /*     _gx_display_driver_8bpp_horizontal_pixelmap_line_alpha_blend       */
1357 /*                                          Blend pixelmap with alpha     */
1358 /*     _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_blend  */
1359 /*                                          Blend pixelmap with           */
1360 /*                                            compression                 */
1361 /*     _gx_display_driver_8bpp_horizontal_pixelmap_line_raw_blend         */
1362 /*                                          Blend raw pixelmap            */
1363 /*     _gx_display_driver_8bit_horizontal_pixelmap_line_raw_write         */
1364 /*                                          Draw draw pixelmap            */
1365 /*     _gx_display_driver_8bpp_horizontal_pixelmap_line_alpha_write       */
1366 /*                                          Draw pixelmap with alpha      */
1367 /*     _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_write  */
1368 /*                                          Draw pixelmap with            */
1369 /*                                            compression                 */
1370 /*     _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_       */
1371 /*     alpha_write                                                        */
1372 /*                                          DRaw pxielmap with            */
1373 /*                                            compression and alpha       */
1374 /*                                                                        */
1375 /*  CALLED BY                                                             */
1376 /*                                                                        */
1377 /*    GUIX Internal Code                                                  */
1378 /*                                                                        */
1379 /*  RELEASE HISTORY                                                       */
1380 /*                                                                        */
1381 /*    DATE              NAME                      DESCRIPTION             */
1382 /*                                                                        */
1383 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1384 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1385 /*                                            resulting in version 6.1    */
1386 /*                                                                        */
1387 /**************************************************************************/
_gx_display_driver_332rgb_horizontal_pixelmap_line_draw(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT y,GX_FILL_PIXELMAP_INFO * info)1388 VOID _gx_display_driver_332rgb_horizontal_pixelmap_line_draw(GX_DRAW_CONTEXT *context,
1389                                                              INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
1390 {
1391 #if defined GX_BRUSH_ALPHA_SUPPORT
1392 GX_UBYTE alpha;
1393 
1394     alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1395     if (alpha == 0)
1396     {
1397         /* Nothing to drawn. Just return. */
1398         return;
1399     }
1400 
1401     if (info -> pixelmap == GX_NULL)
1402     {
1403         /* No pixelmap info here.So just return. */
1404         return;
1405     }
1406 
1407     if (alpha != 0xff)
1408     {
1409         if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1410         {
1411             if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1412             {
1413                 _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_alpha_blend(context, xstart, xend, y, info, alpha);
1414             }
1415             else
1416             {
1417                 /* alpha, no compression */
1418                 _gx_display_driver_8bpp_horizontal_pixelmap_line_alpha_blend(context, xstart, xend, y, info, alpha);
1419             }
1420         }
1421         else
1422         {
1423             if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1424             {
1425                 _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_blend(context, xstart, xend, y, info, alpha);
1426             }
1427             else
1428             {
1429                 _gx_display_driver_8bpp_horizontal_pixelmap_line_raw_blend(context, xstart, xend, y, info, alpha);
1430             }
1431         }
1432     }
1433     else
1434     {
1435 #endif
1436         if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1437         {
1438             if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1439             {
1440                 _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_alpha_write(context, xstart, xend, y, info);
1441             }
1442             else
1443             {
1444                 /* alpha, no compression */
1445                 _gx_display_driver_8bpp_horizontal_pixelmap_line_alpha_write(context, xstart, xend, y, info);
1446             }
1447         }
1448         else
1449         {
1450             if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1451             {
1452                 _gx_display_driver_8bpp_horizontal_pixelmap_line_compressed_write(context, xstart, xend, y, info);
1453             }
1454             else
1455             {
1456                 _gx_display_driver_8bpp_horizontal_pixelmap_line_raw_write(context, xstart, xend, y, info);
1457             }
1458         }
1459 #if defined GX_BRUSH_ALPHA_SUPPORT
1460     }
1461 #endif
1462 
1463     /*Current pixelmap has gone over, so the offset pointer should be reset.*/
1464     if (info -> current_pixel_ptr >= info -> pixelmap -> gx_pixelmap_data + info -> pixelmap -> gx_pixelmap_data_size)
1465     {
1466         info -> current_pixel_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_data;
1467         info -> current_aux_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_aux_data;
1468     }
1469 
1470     return;
1471 }
1472 
1473