GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_32bpp_pixelmap_draw.c Lines: 676 676 100.0 %
Date: 2024-12-05 08:52:37 Branches: 373 373 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** GUIX Component                                                        */
16
/**                                                                       */
17
/**   Display Management (Display)                                        */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_display.h"
28
29
30
/**************************************************************************/
31
/*                                                                        */
32
/*  FUNCTION                                               RELEASE        */
33
/*                                                                        */
34
/*    _gx_display_driver_24xrgb_pixelmap_raw_write        PORTABLE C      */
35
/*                                                           6.1          */
36
/*  AUTHOR                                                                */
37
/*                                                                        */
38
/*    Kenneth Maxwell, Microsoft Corporation                              */
39
/*                                                                        */
40
/*  DESCRIPTION                                                           */
41
/*                                                                        */
42
/*    Internal helper function that handles writing of uncompressed       */
43
/*    pixlemap file without alpha channel.                                */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    context                               Drawing context               */
48
/*    xpos                                  x-coord of top-left draw point*/
49
/*    ypos                                  y-coord of top-left draw point*/
50
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    None                                                                */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    None                                                                */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    _gx_display_driver_24xrgb_pixelmap_draw                             */
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
/*                                                                        */
72
/**************************************************************************/
73
28341
static VOID _gx_display_driver_24xrgb_pixelmap_raw_write(GX_DRAW_CONTEXT *context,
74
                                                         INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
75
{
76
INT           xval;
77
INT           yval;
78
INT           width;
79
GX_COLOR     *putrow;
80
GX_COLOR     *getrow;
81
GX_COLOR     *put;
82
GX_COLOR     *get;
83
84
28341
GX_RECTANGLE *clip = context -> gx_draw_context_clip;
85
86
28341
    getrow = (GX_COLOR *)(pixelmap -> gx_pixelmap_data);
87
28341
    getrow += pixelmap -> gx_pixelmap_width * (clip -> gx_rectangle_top - ypos);
88
28341
    getrow += (clip -> gx_rectangle_left - xpos);
89
90
    /* brush alpha is 0xff means draw pixelmap to memory directly. */
91
28341
    putrow = context -> gx_draw_context_memory;
92
28341
    putrow += clip -> gx_rectangle_top * context -> gx_draw_context_pitch;
93
28341
    putrow += clip -> gx_rectangle_left;
94
95
28341
    width = clip -> gx_rectangle_right - clip -> gx_rectangle_left + 1;
96
97
1653800
    for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
98
    {
99
1625459
        put = putrow;
100
1625459
        get = getrow;
101
102
291923386
        for (xval = 0; xval < width; xval++)
103
        {
104
290297927
            *put++ = *get++;
105
        }
106
1625459
        putrow += context -> gx_draw_context_pitch;
107
1625459
        getrow += pixelmap -> gx_pixelmap_width;
108
    }
109
28341
}
110
111
/**************************************************************************/
112
/*                                                                        */
113
/*  FUNCTION                                               RELEASE        */
114
/*                                                                        */
115
/*    _gx_display_driver_24xrgb_pixelmap_alpha_write      PORTABLE C      */
116
/*                                                           6.1.7        */
117
/*  AUTHOR                                                                */
118
/*                                                                        */
119
/*    Kenneth Maxwell, Microsoft Corporation                              */
120
/*                                                                        */
121
/*  DESCRIPTION                                                           */
122
/*                                                                        */
123
/*    Internal helper function that handles writing of uncompressed       */
124
/*    pixlemap file with alpha channel.                                   */
125
/*                                                                        */
126
/*  INPUT                                                                 */
127
/*                                                                        */
128
/*    context                               Drawing context               */
129
/*    xpos                                  x-coord of top-left draw point*/
130
/*    ypos                                  y-coord of top-left draw point*/
131
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
132
/*                                                                        */
133
/*  OUTPUT                                                                */
134
/*                                                                        */
135
/*    None                                                                */
136
/*                                                                        */
137
/*  CALLS                                                                 */
138
/*                                                                        */
139
/*    _gx_display_driver_24xrgb_pixel_blend Basic display driver pixel    */
140
/*                                            blend function for 24xrgb   */
141
/*                                            format                      */
142
/*    _gx_display_driver_32bpp_pixel_write  Basic display driver pixel    */
143
/*                                            write function for 32bpp    */
144
/*                                            color depth                 */
145
/*                                                                        */
146
/*  CALLED BY                                                             */
147
/*                                                                        */
148
/*    _gx_display_driver_24xrgb_pixelmap_draw                             */
149
/*                                                                        */
150
/*  RELEASE HISTORY                                                       */
151
/*                                                                        */
152
/*    DATE              NAME                      DESCRIPTION             */
153
/*                                                                        */
154
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
155
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
156
/*                                            resulting in version 6.1    */
157
/*  06-02-2021     Kenneth Maxwell          Modified comment(s),          */
158
/*                                            removed unused assignments, */
159
/*                                            resulting in version 6.1.7  */
160
/*                                                                        */
161
/**************************************************************************/
162
173097
static VOID _gx_display_driver_24xrgb_pixelmap_alpha_write(GX_DRAW_CONTEXT *context,
163
                                                           INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
164
{
165
INT           xval;
166
INT           yval;
167
GX_COLOR      color;
168
INT           width;
169
ULONG        *get;
170
UCHAR         alpha_value;
171
173097
GX_RECTANGLE *clip = context -> gx_draw_context_clip;
172
173
173097
    get = (ULONG *)((UINT)(pixelmap -> gx_pixelmap_data) + (INT)sizeof(GX_COLOR) * (UINT)(pixelmap -> gx_pixelmap_width) * (UINT)((INT)(clip -> gx_rectangle_top) - ypos));
174
173097
    get += (clip -> gx_rectangle_left - xpos);
175
176
173097
    width = clip -> gx_rectangle_right - clip -> gx_rectangle_left + 1;
177
178
6454598
    for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
179
    {
180
369994252
        for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
181
        {
182
363712751
            alpha_value = (UCHAR)(*get >> 24);
183
363712751
            if (alpha_value)
184
            {
185
322470404
                color = *get & 0x00ffffff;
186
322470404
                if (alpha_value == 255)
187
                {
188
40213244
                    _gx_display_driver_32bpp_pixel_write(context, xval, yval, color);
189
                }
190
                else
191
                {
192
282257160
                    _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, color, alpha_value);
193
                }
194
            }
195
363712751
            get++;
196
        }
197
6281501
        get += pixelmap -> gx_pixelmap_width - width;
198
    }
199
173097
}
200
201
/**************************************************************************/
202
/*                                                                        */
203
/*  FUNCTION                                               RELEASE        */
204
/*                                                                        */
205
/*    _gx_display_driver_24xrgb_pixelmap_compressed_write                 */
206
/*                                                        PORTABLE C      */
207
/*                                                           6.1          */
208
/*  AUTHOR                                                                */
209
/*                                                                        */
210
/*    Kenneth Maxwell, Microsoft Corporation                              */
211
/*                                                                        */
212
/*  DESCRIPTION                                                           */
213
/*                                                                        */
214
/*    Internal helper function that handles writing of compressed         */
215
/*    pixlemap file without alpha channel.                                */
216
/*                                                                        */
217
/*  INPUT                                                                 */
218
/*                                                                        */
219
/*    context                               Drawing context               */
220
/*    xpos                                  x-coord of top-left draw point*/
221
/*    ypos                                  y-coord of top-left draw point*/
222
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
223
/*                                                                        */
224
/*  OUTPUT                                                                */
225
/*                                                                        */
226
/*    None                                                                */
227
/*                                                                        */
228
/*  CALLS                                                                 */
229
/*                                                                        */
230
/*    _gx_display_driver_24xrgb_pixel_blend Basic display driver pixel    */
231
/*                                            blend function for 24xrgb   */
232
/*                                            format                      */
233
/*                                                                        */
234
/*  CALLED BY                                                             */
235
/*                                                                        */
236
/*    _gx_display_driver_24xrgb_pixelmap_draw                             */
237
/*                                                                        */
238
/*  RELEASE HISTORY                                                       */
239
/*                                                                        */
240
/*    DATE              NAME                      DESCRIPTION             */
241
/*                                                                        */
242
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
243
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
244
/*                                            resulting in version 6.1    */
245
/*                                                                        */
246
/**************************************************************************/
247
109023
static VOID _gx_display_driver_24xrgb_pixelmap_compressed_write(GX_DRAW_CONTEXT *context,
248
                                                                INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
249
{
250
INT                yval;
251
INT                xval;
252
GX_CONST GX_COLOR *get;
253
GX_COLOR          *put;
254
GX_COLOR          *putrow;
255
GX_UBYTE           count;
256
GX_COLOR           pixel;
257
GX_CONST GX_UBYTE *get_count;
258
GX_UBYTE           brush_alpha;
259
260
109023
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
261
262
109023
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
263
264
109023
    get = (GX_CONST GX_COLOR *)pixelmap -> gx_pixelmap_data;
265
109023
    get_count = (GX_CONST GX_UBYTE *)pixelmap -> gx_pixelmap_aux_data;
266
267
    /* first, skip to the starting row */
268
1033417
    for (yval = ypos; yval < clip -> gx_rectangle_top; yval++)
269
    {
270
924394
        xval = 0;
271
4245883
        while (xval < pixelmap -> gx_pixelmap_width)
272
        {
273
3321489
            count = *get_count++;
274
275
3321489
            if (count & 0x80)
276
            {
277
770317
                count = (GX_UBYTE)((count & 0x7f) + 1u);
278
770317
                get++;      /* skip repeated pixel value */
279
            }
280
            else
281
            {
282
2551172
                count++;
283
2551172
                get += count;   /* skip raw pixel values */
284
            }
285
3321489
            xval += count;
286
        }
287
    }
288
289
    /* now we are on the first visible row, copy pixels until we get
290
       to the enf of the last visible row
291
     */
292
109023
    putrow = (GX_COLOR *)context -> gx_draw_context_memory;
293
109023
    putrow += yval * context -> gx_draw_context_pitch;
294
109023
    putrow += xpos;
295
296
14737486
    while (yval <= clip -> gx_rectangle_bottom)
297
    {
298
14628463
        put = putrow;
299
14628463
        xval = xpos;
300
301
54464411
        while (xval < xpos + pixelmap -> gx_pixelmap_width)
302
        {
303
39835948
            count = *get_count++;
304
305
39835948
            if (count & 0x80)
306
            {
307
                /* repeated value */
308
19806728
                count = (GX_UBYTE)((count & 0x7f) + 1u);
309
19806728
                pixel = (*get++) & 0x00ffffff;
310
311
19806728
                if (brush_alpha == 0xff)
312
                {
313
449959531
                    while (count--)
314
                    {
315
430154781
                        if (xval >= clip -> gx_rectangle_left &&
316
429234838
                            xval <= clip -> gx_rectangle_right)
317
                        {
318
420235087
                            *put = pixel;
319
                        }
320
430154781
                        put++;
321
430154781
                        xval++;
322
                    }
323
                }
324
                else
325
                {
326
15389
                    while (count--)
327
                    {
328
13411
                        if (xval >= clip -> gx_rectangle_left &&
329
13308
                            xval <= clip -> gx_rectangle_right)
330
                        {
331
11202
                            _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, brush_alpha);
332
                        }
333
13411
                        xval++;
334
                    }
335
                }
336
            }
337
            else
338
            {
339
                /* string of non-repeated values */
340
20029220
                count++;
341
342
20029220
                if (brush_alpha == 0xff)
343
                {
344
523023501
                    while (count--)
345
                    {
346
503022372
                        if (xval >= clip -> gx_rectangle_left &&
347
466134083
                            xval <= clip -> gx_rectangle_right)
348
                        {
349
265404898
                            *put = (*get) & 0x00ffffff;
350
                        }
351
503022372
                        put++;
352
503022372
                        get++;
353
503022372
                        xval++;
354
                    }
355
                }
356
                else
357
                {
358
3210089
                    while (count--)
359
                    {
360
3181998
                        if (xval >= clip -> gx_rectangle_left &&
361
3167114
                            xval <= clip -> gx_rectangle_right)
362
                        {
363
670018
                            _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, *get, brush_alpha);
364
                        }
365
3181998
                        get++;
366
3181998
                        xval++;
367
                    }
368
                }
369
            }
370
        }
371
14628463
        putrow += context -> gx_draw_context_pitch;
372
14628463
        yval++;
373
    }
374
109023
}
375
376
/**************************************************************************/
377
/*                                                                        */
378
/*  FUNCTION                                               RELEASE        */
379
/*                                                                        */
380
/*    _gx_display_driver_24xrgb_pixelmap_compressed_alpha_write           */
381
/*                                                        PORTABLE C      */
382
/*                                                           6.1          */
383
/*  AUTHOR                                                                */
384
/*                                                                        */
385
/*    Kenneth Maxwell, Microsoft Corporation                              */
386
/*                                                                        */
387
/*  DESCRIPTION                                                           */
388
/*                                                                        */
389
/*    Internal helper function that handles writing of compressed         */
390
/*    pixlemap file with alpha channel.                                   */
391
/*                                                                        */
392
/*  INPUT                                                                 */
393
/*                                                                        */
394
/*    context                               Drawing context               */
395
/*    xpos                                  x-coord of top-left draw point*/
396
/*    ypos                                  y-coord of top-left draw point*/
397
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
398
/*                                                                        */
399
/*  OUTPUT                                                                */
400
/*                                                                        */
401
/*    None                                                                */
402
/*                                                                        */
403
/*  CALLS                                                                 */
404
/*                                                                        */
405
/*    _gx_display_driver_24xrgb_pixel_blend Basic display driver pixel    */
406
/*                                            blend function for 24xrgb   */
407
/*                                            format                      */
408
/*                                                                        */
409
/*  CALLED BY                                                             */
410
/*                                                                        */
411
/*    _gx_display_driver_24xrgb_pixelmap_draw                             */
412
/*                                                                        */
413
/*  RELEASE HISTORY                                                       */
414
/*                                                                        */
415
/*    DATE              NAME                      DESCRIPTION             */
416
/*                                                                        */
417
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
418
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
419
/*                                            resulting in version 6.1    */
420
/*                                                                        */
421
/**************************************************************************/
422
725697
static VOID _gx_display_driver_24xrgb_pixelmap_compressed_alpha_write(GX_DRAW_CONTEXT *context,
423
                                                                      INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
424
{
425
INT                yval;
426
INT                xval;
427
GX_CONST GX_COLOR *get;
428
GX_UBYTE           count;
429
GX_COLOR           pixel;
430
GX_CONST GX_UBYTE *get_count;
431
GX_UBYTE           brush_alpha;
432
GX_UBYTE           alpha;
433
GX_UBYTE           combined_alpha;
434
435
725697
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
436
437
725697
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
438
439
725697
    get = (GX_CONST GX_COLOR *)pixelmap -> gx_pixelmap_data;
440
725697
    get_count = (GX_CONST GX_UBYTE *)pixelmap -> gx_pixelmap_aux_data;
441
442
    /* first, skip to the starting row */
443
966329
    for (yval = ypos; yval < clip -> gx_rectangle_top; yval++)
444
    {
445
240632
        xval = 0;
446
1928985
        while (xval < pixelmap -> gx_pixelmap_width)
447
        {
448
1688353
            count = *get_count++;
449
450
1688353
            if (count & 0x80)
451
            {
452
890058
                count = (GX_UBYTE)((count & 0x7f) + 1u);
453
890058
                get++;      /* skip repeated pixel value */
454
            }
455
            else
456
            {
457
798295
                count++;
458
798295
                get += count;   /* skip raw pixel values */
459
            }
460
1688353
            xval += count;
461
        }
462
    }
463
464
    /* now we are on the first visible row, copy pixels until we get
465
       to the enf of the last visible row
466
     */
467
468
27622074
    while (yval <= clip -> gx_rectangle_bottom)
469
    {
470
26896377
        xval = xpos;
471
472
86564916
        while (xval < xpos + pixelmap -> gx_pixelmap_width)
473
        {
474
59668539
            count = *get_count++;
475
476
59668539
            if (count & 0x80)
477
            {
478
                /* repeated value */
479
41171030
                count = (GX_UBYTE)((count & 0x7f) + 1u);
480
41171030
                alpha = (GX_UBYTE)((*get) >> 24);
481
41171030
                pixel = (*get++) & 0x00ffffff;
482
483
41171030
                combined_alpha = (GX_UBYTE)(alpha * brush_alpha / 255);
484
485
41171030
                if (combined_alpha)
486
                {
487
443373638
                    while (count--)
488
                    {
489
405579181
                        if (xval >= clip -> gx_rectangle_left &&
490
404004154
                            xval <= clip -> gx_rectangle_right)
491
                        {
492
398890908
                            _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, combined_alpha);
493
                        }
494
405579181
                        xval++;
495
                    }
496
                }
497
                else
498
                {
499
3376573
                    xval += count;
500
                }
501
            }
502
            else
503
            {
504
                /* string of non-repeated values */
505
18497509
                count++;
506
507
246010046
                while (count--)
508
                {
509
227512537
                    if (xval >= clip -> gx_rectangle_left &&
510
224783155
                        xval <= clip -> gx_rectangle_right)
511
                    {
512
220290187
                        alpha = (GX_UBYTE)((*get) >> 24);
513
220290187
                        pixel = (*get) & 0x00ffffff;
514
220290187
                        combined_alpha = (GX_UBYTE)(alpha * brush_alpha / 255);
515
220290187
                        _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, combined_alpha);
516
                    }
517
227512537
                    get++;
518
227512537
                    xval++;
519
                }
520
            }
521
        }
522
26896377
        yval++;
523
    }
524
725697
}
525
526
/**************************************************************************/
527
/*                                                                        */
528
/*  FUNCTION                                               RELEASE        */
529
/*                                                                        */
530
/*    _gx_display_driver_24xrgb_palette_pixelmap_compressed_write         */
531
/*                                                        PORTABLE C      */
532
/*                                                           6.1          */
533
/*  AUTHOR                                                                */
534
/*                                                                        */
535
/*    Kenneth Maxwell, Microsoft Corporation                              */
536
/*                                                                        */
537
/*  DESCRIPTION                                                           */
538
/*                                                                        */
539
/*    Internal helper function that handles writing of compressed         */
540
/*    pixlemap file without transparent of palette pixelmap.              */
541
/*                                                                        */
542
/*  INPUT                                                                 */
543
/*                                                                        */
544
/*    context                               Drawing context               */
545
/*    xpos                                  x-coord of top-left draw point*/
546
/*    ypos                                  y-coord of top-left draw point*/
547
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
548
/*                                                                        */
549
/*  OUTPUT                                                                */
550
/*                                                                        */
551
/*    None                                                                */
552
/*                                                                        */
553
/*  CALLS                                                                 */
554
/*                                                                        */
555
/*    _gx_display_driver_24xrgb_pixel_blend Basic display driver pixel    */
556
/*                                            blend function for 24xrgb   */
557
/*                                            format                      */
558
/*                                                                        */
559
/*  CALLED BY                                                             */
560
/*                                                                        */
561
/*    _gx_display_driver_24xrgb_pixelmap_draw                             */
562
/*                                                                        */
563
/*  RELEASE HISTORY                                                       */
564
/*                                                                        */
565
/*    DATE              NAME                      DESCRIPTION             */
566
/*                                                                        */
567
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
568
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
569
/*                                            resulting in version 6.1    */
570
/*                                                                        */
571
/**************************************************************************/
572
81
static VOID _gx_display_driver_24xrgb_palette_pixelmap_compressed_write(GX_DRAW_CONTEXT *context,
573
                                                                        INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
574
{
575
INT             yval;
576
INT             xval;
577
GX_CONST UCHAR *get;
578
UCHAR           count;
579
GX_COLOR       *put;
580
GX_COLOR       *putrow;
581
GX_COLOR        pixel;
582
GX_COLOR       *palette;
583
GX_UBYTE        brush_alpha;
584
GX_UBYTE        r;
585
GX_UBYTE        g;
586
GX_UBYTE        b;
587
81
GX_RECTANGLE   *clip = context -> gx_draw_context_clip;
588
589
81
    get = (GX_CONST UCHAR *)pixelmap -> gx_pixelmap_data;
590
81
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
591
592
    /* compressed with  alpha is a one-byte count and  one-byte pixel index */
593
    /* first, skip to the starting row */
594
219
    for (yval = ypos; yval < clip -> gx_rectangle_top; yval++)
595
    {
596
138
        xval = 0;
597
1777
        while (xval < pixelmap -> gx_pixelmap_width)
598
        {
599
1639
            count = *get++;
600
601
1639
            if (count & 0x80)
602
            {
603
995
                count = (UCHAR)((count & 0x7f) + 1);
604
995
                get++;      /* skip repeated pixel value */
605
            }
606
            else
607
            {
608
644
                count++;
609
644
                get += count;   /* skip raw pixel values */
610
            }
611
1639
            xval += count;
612
        }
613
    }
614
615
    /* now we are on the first visible row, copy pixels until we get
616
       to the enf of the last visible row
617
     */
618
81
    putrow = (GX_COLOR *)context -> gx_draw_context_memory;
619
81
    putrow += yval * context -> gx_draw_context_pitch;
620
81
    putrow += xpos;
621
622
    /* Now we are on the first visible row, copy pixels until we get
623
       to the end of the last visible row. */
624
625
81
    palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
626
627
13575
    while (yval <= clip -> gx_rectangle_bottom)
628
    {
629
13494
        xval = xpos;
630
13494
        put = putrow;
631
632
1422399
        while (xval < xpos + pixelmap -> gx_pixelmap_width)
633
        {
634
1408905
            count = *get++;
635
636
1408905
            if (count & 0x80)
637
            {
638
                /* repeated value */
639
792833
                count = (UCHAR)((count & 0x7f) + 1);
640
641
792833
                r = (GX_UBYTE)REDVAL_32BPP(palette[*get]);
642
792833
                g = (GX_UBYTE)GREENVAL_32BPP(palette[*get]);
643
792833
                b = (GX_UBYTE)BLUEVAL_32BPP(palette[*get++]);
644
645
792833
                pixel = (GX_COLOR)ASSEMBLECOLOR_24BPP(r, g, b);
646
647
792833
                if (brush_alpha == 0xff)
648
                {
649
4581793
                    while (count--)
650
                    {
651
3804704
                        if (xval >= clip -> gx_rectangle_left &&
652
3794027
                            xval <= clip -> gx_rectangle_right)
653
                        {
654
1168626
                            *put = pixel & 0x00ffffff;
655
                        }
656
3804704
                        put++;
657
3804704
                        xval++;
658
                    }
659
                }
660
                else
661
                {
662
171734
                    while (count--)
663
                    {
664
155990
                        if (xval >= clip -> gx_rectangle_left &&
665
142768
                            xval <= clip -> gx_rectangle_right)
666
                        {
667
139679
                            _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, brush_alpha);
668
                        }
669
155990
                        xval++;
670
                    }
671
                }
672
            }
673
            else
674
            {
675
                /* string of non-repeated values */
676
616072
                count++;
677
616072
                if (brush_alpha == 0xff)
678
                {
679
5944805
                    while (count--)
680
                    {
681
5341348
                        if (xval >= clip -> gx_rectangle_left &&
682
5337695
                            xval <= clip -> gx_rectangle_right)
683
                        {
684
1515587
                            r = (GX_UBYTE)REDVAL_32BPP(palette[*get]);
685
1515587
                            g = (GX_UBYTE)GREENVAL_32BPP(palette[*get]);
686
1515587
                            b = (GX_UBYTE)BLUEVAL_32BPP(palette[*get]);
687
1515587
                            pixel = (GX_COLOR)ASSEMBLECOLOR_24BPP(r, g, b);
688
1515587
                            *put = pixel & 0x00ffffff;
689
                        }
690
5341348
                        get++;
691
5341348
                        put++;
692
5341348
                        xval++;
693
                    }
694
                }
695
                else
696
                {
697
100237
                    while (count--)
698
                    {
699
87622
                        if (xval >= clip -> gx_rectangle_left &&
700
83654
                            xval <= clip -> gx_rectangle_right)
701
                        {
702
80354
                            r = (GX_UBYTE)REDVAL_32BPP(palette[*get]);
703
80354
                            g = (GX_UBYTE)GREENVAL_32BPP(palette[*get]);
704
80354
                            b = (GX_UBYTE)BLUEVAL_32BPP(palette[*get]);
705
80354
                            pixel = (GX_COLOR)ASSEMBLECOLOR_24BPP(r, g, b);
706
80354
                            _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, brush_alpha);
707
                        }
708
87622
                        get++;
709
87622
                        xval++;
710
                    }
711
                }
712
            }
713
        }
714
13494
        putrow += context -> gx_draw_context_pitch;
715
13494
        yval++;
716
    }
717
81
}
718
719
/**************************************************************************/
720
/*                                                                        */
721
/*  FUNCTION                                               RELEASE        */
722
/*                                                                        */
723
/*    _gx_display_driver_24xrgb_palette_pixelmap_write    PORTABLE C      */
724
/*                                                           6.1.7        */
725
/*  AUTHOR                                                                */
726
/*                                                                        */
727
/*    Kenneth Maxwell, Microsoft Corporation                              */
728
/*                                                                        */
729
/*  DESCRIPTION                                                           */
730
/*                                                                        */
731
/*    Internal helper function that handles writing of uncompressed       */
732
/*    pixlemap file without transparent of palette pixelmap.              */
733
/*                                                                        */
734
/*  INPUT                                                                 */
735
/*                                                                        */
736
/*    context                               Drawing context               */
737
/*    xpos                                  x-coord of top-left draw point*/
738
/*    ypos                                  y-coord of top-left draw point*/
739
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
740
/*                                                                        */
741
/*  OUTPUT                                                                */
742
/*                                                                        */
743
/*    None                                                                */
744
/*                                                                        */
745
/*  CALLS                                                                 */
746
/*                                                                        */
747
/*    None                                                                */
748
/*                                                                        */
749
/*  CALLED BY                                                             */
750
/*                                                                        */
751
/*    _gx_display_driver_24xrgb_pixelmap_draw                             */
752
/*                                                                        */
753
/*  RELEASE HISTORY                                                       */
754
/*                                                                        */
755
/*    DATE              NAME                      DESCRIPTION             */
756
/*                                                                        */
757
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
758
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
759
/*                                            resulting in version 6.1    */
760
/*  06-02-2021     Kenneth Maxwell          Modified comment(s),          */
761
/*                                            removed unused assignments, */
762
/*                                            resulting in version 6.1.7  */
763
/*                                                                        */
764
/**************************************************************************/
765
7
static VOID _gx_display_driver_24xrgb_palette_pixelmap_write(GX_DRAW_CONTEXT *context,
766
                                                             INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
767
{
768
INT           xval;
769
INT           yval;
770
GX_COLOR      color;
771
INT           width;
772
GX_UBYTE     *get;
773
GX_COLOR     *palette;
774
GX_COLOR     *put;
775
GX_COLOR     *putrow;
776
GX_UBYTE      r;
777
GX_UBYTE      g;
778
GX_UBYTE      b;
779
780
7
GX_RECTANGLE *clip = context -> gx_draw_context_clip;
781
782
7
    yval = clip -> gx_rectangle_top;
783
784
7
    get = (GX_UBYTE *)(pixelmap -> gx_pixelmap_data + pixelmap -> gx_pixelmap_width * (clip -> gx_rectangle_top - ypos));
785
7
    get += (clip -> gx_rectangle_left - xpos);
786
787
7
    palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
788
789
7
    if (!palette)
790
    {
791
1
        return;
792
    }
793
    /* now we are on the first visible row, copy pixels until we get
794
       to the enf of the last visible row
795
     */
796
6
    putrow = (GX_COLOR *)context -> gx_draw_context_memory;
797
6
    putrow += yval * context -> gx_draw_context_pitch;
798
6
    putrow += xpos;
799
800
6
    width = clip -> gx_rectangle_right - clip -> gx_rectangle_left + 1;
801
802
1432
    for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
803
    {
804
1426
        put = putrow;
805
202703
        for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
806
        {
807
201277
            r = (GX_UBYTE)REDVAL_32BPP(palette[*get]);
808
201277
            g = (GX_UBYTE)GREENVAL_32BPP(palette[*get]);
809
201277
            b = (GX_UBYTE)BLUEVAL_32BPP(palette[*get++]);
810
811
201277
            color = (GX_COLOR)ASSEMBLECOLOR_24BPP(r, g, b);
812
201277
            *put++ = color & 0x00ffffff;
813
        }
814
1426
        putrow += context -> gx_draw_context_pitch;
815
1426
        get += pixelmap -> gx_pixelmap_width - width;
816
    }
817
}
818
819
/**************************************************************************/
820
/*                                                                        */
821
/*  FUNCTION                                               RELEASE        */
822
/*                                                                        */
823
/*    _gx_display_driver_24xrgb_palette_pixelmap_transparent_write        */
824
/*                                                         PORTABLE C     */
825
/*                                                           6.1.7        */
826
/*  AUTHOR                                                                */
827
/*                                                                        */
828
/*    Kenneth Maxwell, Microsoft Corporation                              */
829
/*                                                                        */
830
/*  DESCRIPTION                                                           */
831
/*                                                                        */
832
/*    Internal helper function that handles writing of uncompressed       */
833
/*    pixlemap file with transparent of palette pixelmap.                 */
834
/*                                                                        */
835
/*  INPUT                                                                 */
836
/*                                                                        */
837
/*    context                               Drawing context               */
838
/*    xpos                                  x-coord of top-left draw point*/
839
/*    ypos                                  y-coord of top-left draw point*/
840
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
841
/*                                                                        */
842
/*  OUTPUT                                                                */
843
/*                                                                        */
844
/*    None                                                                */
845
/*                                                                        */
846
/*  CALLS                                                                 */
847
/*                                                                        */
848
/*    _gx_display_driver_32bpp_pixel_write  Basic display driver pixel    */
849
/*                                            write function for 32bpp    */
850
/*                                            color depth                 */
851
/*                                                                        */
852
/*  CALLED BY                                                             */
853
/*                                                                        */
854
/*    _gx_display_driver_24xrgb_pixelmap_draw                             */
855
/*                                                                        */
856
/*  RELEASE HISTORY                                                       */
857
/*                                                                        */
858
/*    DATE              NAME                      DESCRIPTION             */
859
/*                                                                        */
860
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
861
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
862
/*                                            resulting in version 6.1    */
863
/*  06-02-2021     Kenneth Maxwell          Modified comment(s),          */
864
/*                                            removed unused assignments, */
865
/*                                            resulting in version 6.1.7  */
866
/*                                                                        */
867
/**************************************************************************/
868
65
static VOID _gx_display_driver_24xrgb_palette_pixelmap_transparent_write(GX_DRAW_CONTEXT *context,
869
                                                                         INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
870
{
871
INT           xval;
872
INT           yval;
873
GX_COLOR      color;
874
INT           width;
875
GX_UBYTE     *get;
876
GX_COLOR     *palette;
877
GX_UBYTE      r;
878
GX_UBYTE      g;
879
GX_UBYTE      b;
880
881
65
GX_RECTANGLE *clip = context -> gx_draw_context_clip;
882
883
65
    palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
884
885
65
    if (!palette)
886
    {
887
1
        return;
888
    }
889
890
64
    get = (GX_UBYTE *)(pixelmap -> gx_pixelmap_data + pixelmap -> gx_pixelmap_width * (clip -> gx_rectangle_top - ypos));
891
64
    get += (clip -> gx_rectangle_left - xpos);
892
893
64
    width = clip -> gx_rectangle_right - clip -> gx_rectangle_left + 1;
894
895
9699
    for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
896
    {
897
1742199
        for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
898
        {
899
1732564
            if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
900
            {
901
694551
                r = (GX_UBYTE)REDVAL_32BPP(palette[*get]);
902
694551
                g = (GX_UBYTE)GREENVAL_32BPP(palette[*get]);
903
694551
                b = (GX_UBYTE)BLUEVAL_32BPP(palette[*get]);
904
694551
                color = (GX_COLOR)ASSEMBLECOLOR_24BPP(r, g, b);
905
694551
                _gx_display_driver_32bpp_pixel_write(context, xval, yval, color);
906
            }
907
1732564
            get++;
908
        }
909
910
9635
        get += pixelmap -> gx_pixelmap_width - width;
911
    }
912
}
913
914
/**************************************************************************/
915
/*                                                                        */
916
/*  FUNCTION                                               RELEASE        */
917
/*                                                                        */
918
/*    _gx_display_driver_24xrgb_palette_pixelmap_transparent_compressed   */
919
/*    _write                                              PORTABLE C      */
920
/*                                                           6.1          */
921
/*  AUTHOR                                                                */
922
/*                                                                        */
923
/*    Kenneth Maxwell, Microsoft Corporation                              */
924
/*                                                                        */
925
/*  DESCRIPTION                                                           */
926
/*                                                                        */
927
/*    Internal helper function that handles writing of compressed         */
928
/*    pixlemap file with transparent of palette pixelmap.                 */
929
/*                                                                        */
930
/*  INPUT                                                                 */
931
/*                                                                        */
932
/*    context                               Drawing context               */
933
/*    xpos                                  x-coord of top-left draw point*/
934
/*    ypos                                  y-coord of top-left draw point*/
935
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
936
/*                                                                        */
937
/*  OUTPUT                                                                */
938
/*                                                                        */
939
/*    None                                                                */
940
/*                                                                        */
941
/*  CALLS                                                                 */
942
/*                                                                        */
943
/*    _gx_display_driver_24xrgb_pixel_blend Basic display driver pixel    */
944
/*                                            blend function for 24xrgb   */
945
/*                                            format                      */
946
/*                                                                        */
947
/*  CALLED BY                                                             */
948
/*                                                                        */
949
/*    _gx_display_driver_24xrgb_pixelmap_draw                             */
950
/*                                                                        */
951
/*  RELEASE HISTORY                                                       */
952
/*                                                                        */
953
/*    DATE              NAME                      DESCRIPTION             */
954
/*                                                                        */
955
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
956
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
957
/*                                            resulting in version 6.1    */
958
/*                                                                        */
959
/**************************************************************************/
960
70
static VOID _gx_display_driver_24xrgb_palette_pixelmap_transparent_compressed_write(GX_DRAW_CONTEXT *context,
961
                                                                                    INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
962
{
963
INT             yval;
964
INT             xval;
965
GX_CONST UCHAR *get;
966
UCHAR           count;
967
GX_COLOR        pixel;
968
GX_COLOR       *palette;
969
GX_COLOR       *put;
970
GX_COLOR       *putrow;
971
GX_UBYTE        r;
972
GX_UBYTE        g;
973
GX_UBYTE        b;
974
GX_UBYTE        brush_alpha;
975
70
GX_RECTANGLE   *clip = context -> gx_draw_context_clip;
976
977
70
    get = (GX_CONST UCHAR *)pixelmap -> gx_pixelmap_data;
978
70
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
979
980
    /* compressed with  alpha is a one-byte count and  one-byte pixel index */
981
    /* first, skip to the starting row */
982
163
    for (yval = ypos; yval < clip -> gx_rectangle_top; yval++)
983
    {
984
93
        xval = 0;
985
709
        while (xval < pixelmap -> gx_pixelmap_width)
986
        {
987
616
            count = *get++;
988
989
616
            if (count & 0x80)
990
            {
991
399
                count = (UCHAR)((count & 0x7f) + 1);
992
399
                get++;      /* skip repeated pixel value */
993
            }
994
            else
995
            {
996
217
                count++;
997
217
                get += count;   /* skip raw pixel values */
998
            }
999
616
            xval += count;
1000
        }
1001
    }
1002
1003
    /* Now we are on the first visible row, copy pixels until we get
1004
       to the end of the last visible row. */
1005
1006
70
    palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
1007
70
    putrow = (GX_COLOR *)context -> gx_draw_context_memory;
1008
70
    putrow += yval * context -> gx_draw_context_pitch;
1009
70
    putrow += xpos;
1010
1011
11365
    while (yval <= clip -> gx_rectangle_bottom)
1012
    {
1013
11295
        xval = xpos;
1014
11295
        put = putrow;
1015
1016
228262
        while (xval < xpos + pixelmap -> gx_pixelmap_width)
1017
        {
1018
216967
            count = *get++;
1019
216967
            if (count & 0x80)
1020
            {
1021
                /* repeated value */
1022
142535
                count = (UCHAR)((count & 0x7f) + 1);
1023
142535
                if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
1024
                {
1025
123010
                    r = (GX_UBYTE)REDVAL_32BPP(palette[*get]);
1026
123010
                    g = (GX_UBYTE)GREENVAL_32BPP(palette[*get]);
1027
123010
                    b = (GX_UBYTE)BLUEVAL_32BPP(palette[*get]);
1028
1029
123010
                    pixel = (GX_COLOR)ASSEMBLECOLOR_24BPP(r, g, b);
1030
123010
                    if (brush_alpha == 0xff)
1031
                    {
1032
716070
                        while (count--)
1033
                        {
1034
601968
                            if (xval >= clip -> gx_rectangle_left &&
1035
597920
                                xval <= clip -> gx_rectangle_right)
1036
                            {
1037
595632
                                *put = pixel;
1038
                            }
1039
601968
                            xval++;
1040
601968
                            put++;
1041
                        }
1042
                    }
1043
                    else
1044
                    {
1045
61384
                        while (count--)
1046
                        {
1047
52476
                            if (xval >= clip -> gx_rectangle_left &&
1048
48428
                                xval <= clip -> gx_rectangle_right)
1049
                            {
1050
46140
                                _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, brush_alpha);
1051
                            }
1052
52476
                            xval++;
1053
                        }
1054
                    }
1055
                }
1056
                else
1057
                {
1058
19525
                    xval += count;
1059
19525
                    put += count;
1060
                }
1061
1062
142535
                get++;
1063
            }
1064
            else
1065
            {
1066
                /* string of non-repeated values */
1067
74432
                count++;
1068
74432
                if (brush_alpha == 0xff)
1069
                {
1070
395126
                    while (count--)
1071
                    {
1072
325984
                        if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
1073
                        {
1074
321585
                            if (xval >= clip -> gx_rectangle_left &&
1075
319110
                                xval <= clip -> gx_rectangle_right)
1076
                            {
1077
317643
                                r = (GX_UBYTE)REDVAL_32BPP(palette[*get]);
1078
317643
                                g = (GX_UBYTE)GREENVAL_32BPP(palette[*get]);
1079
317643
                                b = (GX_UBYTE)BLUEVAL_32BPP(palette[*get]);
1080
317643
                                pixel = (GX_COLOR)ASSEMBLECOLOR_24BPP(r, g, b);
1081
317643
                                *put = pixel;
1082
                            }
1083
                        }
1084
325984
                        get++;
1085
325984
                        xval++;
1086
325984
                        put++;
1087
                    }
1088
                }
1089
                else
1090
                {
1091
27226
                    while (count--)
1092
                    {
1093
21936
                        if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
1094
                        {
1095
21752
                            if (xval >= clip -> gx_rectangle_left &&
1096
19277
                                xval <= clip -> gx_rectangle_right)
1097
                            {
1098
17810
                                r = (GX_UBYTE)REDVAL_32BPP(palette[*get]);
1099
17810
                                g = (GX_UBYTE)GREENVAL_32BPP(palette[*get]);
1100
17810
                                b = (GX_UBYTE)BLUEVAL_32BPP(palette[*get]);
1101
17810
                                pixel = (GX_COLOR)ASSEMBLECOLOR_24BPP(r, g, b);
1102
17810
                                _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, brush_alpha);
1103
                            }
1104
                        }
1105
21936
                        get++;
1106
21936
                        xval++;
1107
                    }
1108
                }
1109
            }
1110
        }
1111
11295
        yval++;
1112
11295
        putrow += context -> gx_draw_context_pitch;
1113
    }
1114
70
}
1115
1116
/**************************************************************************/
1117
/*                                                                        */
1118
/*  FUNCTION                                               RELEASE        */
1119
/*                                                                        */
1120
/*    _gx_display_driver_24xrgb_565rgb_pixelmap_write     PORTABLE C      */
1121
/*                                                           6.1          */
1122
/*  AUTHOR                                                                */
1123
/*                                                                        */
1124
/*    Kenneth Maxwell, Microsoft Corporation                              */
1125
/*                                                                        */
1126
/*  DESCRIPTION                                                           */
1127
/*                                                                        */
1128
/*    Internal helper function that handles writing of 565rgb format      */
1129
/*    uncompressed pixlemap file without alpha channel.                   */
1130
/*                                                                        */
1131
/*  INPUT                                                                 */
1132
/*                                                                        */
1133
/*    context                               Drawing context               */
1134
/*    xpos                                  x-coord of top-left draw point*/
1135
/*    ypos                                  y-coord of top-left draw point*/
1136
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1137
/*                                                                        */
1138
/*  OUTPUT                                                                */
1139
/*                                                                        */
1140
/*    None                                                                */
1141
/*                                                                        */
1142
/*  CALLS                                                                 */
1143
/*                                                                        */
1144
/*    None                                                                */
1145
/*                                                                        */
1146
/*  CALLED BY                                                             */
1147
/*                                                                        */
1148
/*    _gx_display_driver_24xrgb_pixelmap_draw                             */
1149
/*                                                                        */
1150
/*  RELEASE HISTORY                                                       */
1151
/*                                                                        */
1152
/*    DATE              NAME                      DESCRIPTION             */
1153
/*                                                                        */
1154
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1155
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1156
/*                                            resulting in version 6.1    */
1157
/*                                                                        */
1158
/**************************************************************************/
1159
574
static VOID _gx_display_driver_24xrgb_565rgb_pixelmap_raw_write(GX_DRAW_CONTEXT *context,
1160
                                                                INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1161
{
1162
INT              xval;
1163
INT              yval;
1164
INT              width;
1165
GX_COLOR        *putrow;
1166
USHORT          *getrow;
1167
GX_COLOR        *put;
1168
GX_CONST USHORT *get;
1169
1170
574
GX_RECTANGLE    *clip = context -> gx_draw_context_clip;
1171
1172
574
    putrow = (GX_COLOR *)context -> gx_draw_context_memory;
1173
574
    putrow += clip -> gx_rectangle_top * context -> gx_draw_context_pitch;
1174
574
    putrow += clip -> gx_rectangle_left;
1175
1176
574
    getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
1177
574
    getrow += pixelmap -> gx_pixelmap_width * (clip -> gx_rectangle_top - ypos);
1178
574
    getrow += (clip -> gx_rectangle_left - xpos);
1179
1180
574
    width = clip -> gx_rectangle_right - clip -> gx_rectangle_left + 1;
1181
1182
2525
    for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
1183
    {
1184
1951
        put = putrow;
1185
1951
        get = getrow;
1186
1187
121490
        for (xval = 0; xval < width; xval++)
1188
        {
1189
119539
            *put++ = (GX_COLOR)ASSEMBLECOLOR_32BPP(REDVAL_16BPP(*get) << 3,
1190
                                                   GREENVAL_16BPP(*get) << 2,
1191
                                                   BLUEVAL_16BPP(*get) << 3);
1192
119539
            get++;
1193
        }
1194
1951
        putrow += context -> gx_draw_context_pitch;
1195
1951
        getrow += pixelmap -> gx_pixelmap_width;
1196
    }
1197
574
}
1198
1199
/**************************************************************************/
1200
/*                                                                        */
1201
/*  FUNCTION                                               RELEASE        */
1202
/*                                                                        */
1203
/*    _gx_display_driver_24xrgb_565rgb_pixelmap_compressed_write          */
1204
/*                                                        PORTABLE C      */
1205
/*                                                           6.1          */
1206
/*  AUTHOR                                                                */
1207
/*                                                                        */
1208
/*    Kenneth Maxwell, Microsoft Corporation                              */
1209
/*                                                                        */
1210
/*  DESCRIPTION                                                           */
1211
/*                                                                        */
1212
/*    Internal helper function that handles writing of compressed         */
1213
/*    pixelmap data of 565rgb format in 32bpp driver.                     */
1214
/*                                                                        */
1215
/*  INPUT                                                                 */
1216
/*                                                                        */
1217
/*    context                               Drawing context               */
1218
/*    xpos                                  x-coord of top-left draw point*/
1219
/*    ypos                                  y-coord of top-left draw point*/
1220
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1221
/*                                                                        */
1222
/*  OUTPUT                                                                */
1223
/*                                                                        */
1224
/*    None                                                                */
1225
/*                                                                        */
1226
/*  CALLS                                                                 */
1227
/*                                                                        */
1228
/*    _gx_display_driver_24xrgb_pixel_blend Basic display driver pixel    */
1229
/*                                            blend function for 24xrgb   */
1230
/*                                            format                      */
1231
/*                                                                        */
1232
/*  CALLED BY                                                             */
1233
/*                                                                        */
1234
/*    _gx_display_driver_24xrgb_pixelmap_draw                             */
1235
/*                                                                        */
1236
/*  RELEASE HISTORY                                                       */
1237
/*                                                                        */
1238
/*    DATE              NAME                      DESCRIPTION             */
1239
/*                                                                        */
1240
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1241
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1242
/*                                            resulting in version 6.1    */
1243
/*                                                                        */
1244
/**************************************************************************/
1245
3
static VOID _gx_display_driver_24xrgb_565rgb_pixelmap_compressed_write(GX_DRAW_CONTEXT *context,
1246
                                                                       INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1247
{
1248
INT              yval;
1249
INT              xval;
1250
GX_CONST USHORT *get;
1251
USHORT           count;
1252
GX_COLOR         pixel;
1253
GX_UBYTE         r;
1254
GX_UBYTE         g;
1255
GX_UBYTE         b;
1256
GX_UBYTE         brush_alpha;
1257
GX_COLOR        *put;
1258
GX_COLOR        *putrow;
1259
3
GX_RECTANGLE    *clip = context -> gx_draw_context_clip;
1260
1261
3
    get = (GX_CONST USHORT *)pixelmap -> gx_pixelmap_data;
1262
3
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1263
1264
    /* first, skip to the starting row */
1265
60
    for (yval = ypos; yval < clip -> gx_rectangle_top; yval++)
1266
    {
1267
57
        xval = 0;
1268
2292
        while (xval < pixelmap -> gx_pixelmap_width)
1269
        {
1270
2235
            count = *get++;
1271
1272
2235
            if (count & 0x8000)
1273
            {
1274
1095
                count = (USHORT)((count & 0x7fff) + 1);
1275
1095
                get++;      /* skip repeated pixel value */
1276
            }
1277
            else
1278
            {
1279
1140
                count++;
1280
1140
                get += count;   /* skip raw pixel values */
1281
            }
1282
2235
            xval += count;
1283
        }
1284
    }
1285
1286
    /* now we are on the first visible row, copy pixels until we get
1287
       to the enf of the last visible row
1288
     */
1289
3
    putrow = (GX_COLOR *)context -> gx_draw_context_memory;
1290
3
    putrow += yval * context -> gx_draw_context_pitch;
1291
3
    putrow += xpos;
1292
1293
795
    while (yval <= clip -> gx_rectangle_bottom)
1294
    {
1295
792
        xval = xpos;
1296
792
        put = putrow;
1297
1298
42399
        while (xval < xpos + pixelmap -> gx_pixelmap_width)
1299
        {
1300
41607
            count = *get++;
1301
1302
41607
            if (count & 0x8000)
1303
            {
1304
                /* repeated value */
1305
21432
                count = (USHORT)((count & 0x7fff) + 1);
1306
21432
                pixel = *get++;
1307
21432
                r = (GX_UBYTE)(((USHORT)pixel & 0xf800) >> 8);
1308
21432
                g = (GX_UBYTE)(((USHORT)pixel & 0x07e0) >> 3);
1309
21432
                b = (GX_UBYTE)(((USHORT)pixel & 0x001f) << 3);
1310
21432
                pixel = (GX_COLOR)ASSEMBLECOLOR_32BPP(r, g, b);
1311
21432
                if (brush_alpha == 0xff)
1312
                {
1313
35706
                    while (count--)
1314
                    {
1315
28562
                        if (xval >= clip -> gx_rectangle_left &&
1316
28019
                            xval <= clip -> gx_rectangle_right)
1317
                        {
1318
5785
                            *put = pixel;
1319
                        }
1320
28562
                        xval++;
1321
28562
                        put++;
1322
                    }
1323
                }
1324
                else
1325
                {
1326
71412
                    while (count--)
1327
                    {
1328
57124
                        if (xval >= clip -> gx_rectangle_left &&
1329
56038
                            xval <= clip -> gx_rectangle_right)
1330
                        {
1331
11570
                            _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, brush_alpha);
1332
                        }
1333
57124
                        xval++;
1334
                    }
1335
                }
1336
            }
1337
            else
1338
            {
1339
                /* string of non-repeated values */
1340
20175
                count++;
1341
20175
                if (brush_alpha == 0xff)
1342
                {
1343
211275
                    while (count--)
1344
                    {
1345
204550
                        if (xval >= clip -> gx_rectangle_left &&
1346
199285
                            xval <= clip -> gx_rectangle_right)
1347
                        {
1348
57839
                            pixel = *get;
1349
57839
                            r = (GX_UBYTE)(((USHORT)pixel & 0xf800) >> 8);
1350
57839
                            g = (GX_UBYTE)(((USHORT)pixel & 0x07e0) >> 3);
1351
57839
                            b = (GX_UBYTE)(((USHORT)pixel & 0x001f) << 3);
1352
57839
                            pixel = (GX_COLOR)ASSEMBLECOLOR_32BPP(r, g, b);
1353
57839
                            *put = pixel;
1354
                        }
1355
204550
                        get++;
1356
204550
                        put++;
1357
204550
                        xval++;
1358
                    }
1359
                }
1360
                else
1361
                {
1362
422550
                    while (count--)
1363
                    {
1364
409100
                        if (xval >= clip -> gx_rectangle_left &&
1365
398570
                            xval <= clip -> gx_rectangle_right)
1366
                        {
1367
115678
                            pixel = *get;
1368
115678
                            r = (GX_UBYTE)(((USHORT)pixel & 0xf800) >> 8);
1369
115678
                            g = (GX_UBYTE)(((USHORT)pixel & 0x07e0) >> 3);
1370
115678
                            b = (GX_UBYTE)(((USHORT)pixel & 0x001f) << 3);
1371
115678
                            pixel = (GX_COLOR)ASSEMBLECOLOR_32BPP(r, g, b);
1372
115678
                            _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, brush_alpha);
1373
                        }
1374
409100
                        get++;
1375
409100
                        xval++;
1376
                    }
1377
                }
1378
            }
1379
        }
1380
792
        yval++;
1381
792
        putrow += context -> gx_draw_context_pitch;
1382
    }
1383
3
}
1384
1385
/**************************************************************************/
1386
/*                                                                        */
1387
/*  FUNCTION                                               RELEASE        */
1388
/*                                                                        */
1389
/*    _gx_display_driver_24xrgb_565rgb_pixelmap_compressed_alpha_write    */
1390
/*                                                        PORTABLE C      */
1391
/*                                                           6.1          */
1392
/*  AUTHOR                                                                */
1393
/*                                                                        */
1394
/*    Kenneth Maxwell, Microsoft Corporation                              */
1395
/*                                                                        */
1396
/*  DESCRIPTION                                                           */
1397
/*                                                                        */
1398
/*    Internal helper function that handles writing of compressed-alpha   */
1399
/*    pixelmap data of 565rgb format with 32bpp driver.                   */
1400
/*                                                                        */
1401
/*  INPUT                                                                 */
1402
/*                                                                        */
1403
/*    context                               Drawing context               */
1404
/*    xpos                                  x-coord of top-left draw point*/
1405
/*    ypos                                  y-coord of top-left draw point*/
1406
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1407
/*                                                                        */
1408
/*  OUTPUT                                                                */
1409
/*                                                                        */
1410
/*    None                                                                */
1411
/*                                                                        */
1412
/*  CALLS                                                                 */
1413
/*                                                                        */
1414
/*    _gx_display_driver_24xrgb_pixel_blend Basic display driver pixel    */
1415
/*                                            blend function for 24xrgb   */
1416
/*                                            format                      */
1417
/*    _gx_display_driver_32bpp_pixel_write  Basic display driver pixel    */
1418
/*                                            write function for 32bpp    */
1419
/*                                            color depth                 */
1420
/*                                                                        */
1421
/*  CALLED BY                                                             */
1422
/*                                                                        */
1423
/*    _gx_display_driver_24xrgb_pixelmap_draw                             */
1424
/*                                                                        */
1425
/*  RELEASE HISTORY                                                       */
1426
/*                                                                        */
1427
/*    DATE              NAME                      DESCRIPTION             */
1428
/*                                                                        */
1429
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1430
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1431
/*                                            resulting in version 6.1    */
1432
/*                                                                        */
1433
/**************************************************************************/
1434
7
static VOID _gx_display_driver_24xrgb_565rgb_pixelmap_compressed_alpha_write(GX_DRAW_CONTEXT *context,
1435
                                                                             INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1436
{
1437
INT                yval;
1438
INT                xval;
1439
GX_CONST GX_UBYTE *get;
1440
GX_UBYTE           count;
1441
GX_COLOR           pixel;
1442
GX_UBYTE           alpha_value;
1443
GX_UBYTE           r;
1444
GX_UBYTE           g;
1445
GX_UBYTE           b;
1446
GX_UBYTE           brush_alpha;
1447
GX_UBYTE           combined_alpha;
1448
1449
7
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
1450
1451
7
    get = (GX_CONST GX_UBYTE *)pixelmap -> gx_pixelmap_data;
1452
7
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1453
1454
    /* first, skip to the starting row */
1455
100
    for (yval = ypos; yval < clip -> gx_rectangle_top; yval++)
1456
    {
1457
93
        xval = 0;
1458
730
        while (xval < pixelmap -> gx_pixelmap_width)
1459
        {
1460
637
            count = *get;
1461
1462
637
            if (count & 0x80)
1463
            {
1464
458
                count = (GX_UBYTE)((count & 0x7f) + 1);
1465
458
                get += 4;      /* skip repeated pixel value */
1466
            }
1467
            else
1468
            {
1469
179
                count++;
1470
179
                get += (count * 4);   /* skip raw pixel values */
1471
            }
1472
637
            xval += count;
1473
        }
1474
    }
1475
1476
    /* now we are on the first visible row, copy pixels until we get
1477
       to the enf of the last visible row
1478
     */
1479
957
    while (yval <= clip -> gx_rectangle_bottom)
1480
    {
1481
950
        xval = xpos;
1482
1483
8461
        while (xval < xpos + pixelmap -> gx_pixelmap_width)
1484
        {
1485
7511
            count = *get;
1486
1487
7511
            if (count & 0x80)
1488
            {
1489
                /* repeated value */
1490
4694
                count = (GX_UBYTE)((count & 0x7f) + 1);
1491
4694
                alpha_value = *(get + 1);
1492
1493
4694
                if (alpha_value)
1494
                {
1495
1454
                    if (brush_alpha == 0xff)
1496
                    {
1497
626
                        get += 2;
1498
626
                        pixel = *(USHORT *)get;
1499
626
                        r = (GX_UBYTE)(((USHORT)pixel & 0xf800) >> 8);
1500
626
                        g = (GX_UBYTE)(((USHORT)pixel & 0x07e0) >> 3);
1501
626
                        b = (GX_UBYTE)(((USHORT)pixel & 0x001f) << 3);
1502
626
                        pixel = (GX_COLOR)ASSEMBLECOLOR_32BPP(r, g, b);
1503
626
                        get += 2;
1504
29280
                        while (count--)
1505
                        {
1506
28654
                            if (xval >= clip -> gx_rectangle_left &&
1507
25700
                                xval <= clip -> gx_rectangle_right)
1508
                            {
1509
25224
                                if (alpha_value == 0xff)
1510
                                {
1511
25215
                                    _gx_display_driver_32bpp_pixel_write(context, xval, yval, pixel);
1512
                                }
1513
                                else
1514
                                {
1515
9
                                    _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, alpha_value);
1516
                                }
1517
                            }
1518
28654
                            xval++;
1519
                        }
1520
                    }
1521
                    else
1522
                    {
1523
828
                        combined_alpha = (GX_UBYTE)(alpha_value * brush_alpha / 255);
1524
828
                        if (combined_alpha)
1525
                        {
1526
824
                            get += 2;
1527
824
                            pixel = *(USHORT *)get;
1528
824
                            r = (GX_UBYTE)(((USHORT)pixel & 0xf800) >> 8);
1529
824
                            g = (GX_UBYTE)(((USHORT)pixel & 0x07e0) >> 3);
1530
824
                            b = (GX_UBYTE)(((USHORT)pixel & 0x001f) << 3);
1531
824
                            pixel = (GX_COLOR)ASSEMBLECOLOR_32BPP(r, g, b);
1532
824
                            get += 2;
1533
38826
                            while (count--)
1534
                            {
1535
38002
                                if (xval >= clip -> gx_rectangle_left &&
1536
34262
                                    xval <= clip -> gx_rectangle_right)
1537
                                {
1538
33786
                                    _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, combined_alpha);
1539
                                }
1540
38002
                                xval++;
1541
                            }
1542
                        }
1543
                        else
1544
                        {
1545
4
                            get += 4;
1546
4
                            xval += count;
1547
                        }
1548
                    }
1549
                }
1550
                else
1551
                {
1552
3240
                    xval += count;
1553
3240
                    get += 4;
1554
                }
1555
            }
1556
            else
1557
            {
1558
                /* string of non-repeated values */
1559
2817
                count++;
1560
2817
                if (brush_alpha == 0xff)
1561
                {
1562
5378
                    while (count--)
1563
                    {
1564
4165
                        if (xval >= clip -> gx_rectangle_left &&
1565
3773
                            xval <= clip -> gx_rectangle_right)
1566
                        {
1567
3462
                            alpha_value = *(get + 1);
1568
3462
                            get += 2;
1569
3462
                            if (alpha_value)
1570
                            {
1571
3330
                                pixel = *(USHORT *)get;
1572
3330
                                r = (GX_UBYTE)(((USHORT)pixel & 0xf800) >> 8);
1573
3330
                                g = (GX_UBYTE)(((USHORT)pixel & 0x07e0) >> 3);
1574
3330
                                b = (GX_UBYTE)(((USHORT)pixel & 0x001f) << 3);
1575
3330
                                pixel = (GX_COLOR)ASSEMBLECOLOR_32BPP(r, g, b);
1576
3330
                                if (alpha_value == 0xff)
1577
                                {
1578
51
                                    _gx_display_driver_32bpp_pixel_write(context, xval, yval, pixel);
1579
                                }
1580
                                else
1581
                                {
1582
3279
                                    _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, alpha_value);
1583
                                }
1584
                            }
1585
3462
                            get += 2;
1586
                        }
1587
                        else
1588
                        {
1589
703
                            get += 4;
1590
                        }
1591
4165
                        xval++;
1592
                    }
1593
                }
1594
                else
1595
                {
1596
7120
                    while (count--)
1597
                    {
1598
5516
                        if (xval >= clip -> gx_rectangle_left &&
1599
4976
                            xval <= clip -> gx_rectangle_right)
1600
                        {
1601
4665
                            alpha_value = *(get + 1);
1602
4665
                            get += 2;
1603
4665
                            if (alpha_value)
1604
                            {
1605
4485
                                pixel = *(USHORT *)get;
1606
4485
                                r = (GX_UBYTE)(((USHORT)pixel & 0xf800) >> 8);
1607
4485
                                g = (GX_UBYTE)(((USHORT)pixel & 0x07e0) >> 3);
1608
4485
                                b = (GX_UBYTE)(((USHORT)pixel & 0x001f) << 3);
1609
4485
                                pixel = (GX_COLOR)ASSEMBLECOLOR_32BPP(r, g, b);
1610
4485
                                combined_alpha = (GX_UBYTE)(brush_alpha * alpha_value / 255);
1611
4485
                                _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, combined_alpha);
1612
                            }
1613
4665
                            get += 2;
1614
                        }
1615
                        else
1616
                        {
1617
851
                            get += 4;
1618
                        }
1619
5516
                        xval++;
1620
                    }
1621
                }
1622
            }
1623
        }
1624
950
        yval++;
1625
    }
1626
7
}
1627
1628
/**************************************************************************/
1629
/*                                                                        */
1630
/*  FUNCTION                                               RELEASE        */
1631
/*                                                                        */
1632
/*    _gx_display_driver_24xrgb_565rgb_pixelmap_alpha_write               */
1633
/*                                                        PORTABLE C      */
1634
/*                                                           6.1          */
1635
/*  AUTHOR                                                                */
1636
/*                                                                        */
1637
/*    Kenneth Maxwell, Microsoft Corporation                              */
1638
/*                                                                        */
1639
/*  DESCRIPTION                                                           */
1640
/*                                                                        */
1641
/*    Internal helper function that handles writing of non_compressed     */
1642
/*    but with alpha channel pixelmap data of 565rgb format with 32bpp    */
1643
/*    driver.                                                             */
1644
/*  INPUT                                                                 */
1645
/*                                                                        */
1646
/*    context                               Drawing context               */
1647
/*    xpos                                  x-coord of top-left draw point*/
1648
/*    ypos                                  y-coord of top-left draw point*/
1649
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1650
/*                                                                        */
1651
/*  OUTPUT                                                                */
1652
/*                                                                        */
1653
/*    None                                                                */
1654
/*                                                                        */
1655
/*  CALLS                                                                 */
1656
/*                                                                        */
1657
/*    _gx_display_driver_24xrgb_pixel_blend Basic display driver pixel    */
1658
/*                                            blend function for 24xrgb   */
1659
/*                                            format                      */
1660
/*    _gx_display_driver_32bpp_pixel_write  Basic display driver pixel    */
1661
/*                                            write function for 32bpp    */
1662
/*                                            color depth                 */
1663
/*                                                                        */
1664
/*  CALLED BY                                                             */
1665
/*                                                                        */
1666
/*    _gx_display_driver_24xrgb_pixelmap_draw                             */
1667
/*                                                                        */
1668
/*  RELEASE HISTORY                                                       */
1669
/*                                                                        */
1670
/*    DATE              NAME                      DESCRIPTION             */
1671
/*                                                                        */
1672
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1673
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1674
/*                                            resulting in version 6.1    */
1675
/*                                                                        */
1676
/**************************************************************************/
1677
3
static VOID _gx_display_driver_24xrgb_565rgb_pixelmap_alpha_write(GX_DRAW_CONTEXT *context,
1678
                                                                  INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1679
{
1680
INT                skipcount;
1681
INT                xval;
1682
INT                yval;
1683
GX_CONST GX_UBYTE *getalpha;
1684
GX_CONST USHORT   *get;
1685
USHORT            *getrow;
1686
GX_UBYTE          *getrowalpha;
1687
GX_UBYTE           r;
1688
GX_UBYTE           g;
1689
GX_UBYTE           b;
1690
GX_COLOR           pixel;
1691
GX_UBYTE           alpha_value;
1692
1693
3
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
1694
1695
3
    skipcount = (pixelmap -> gx_pixelmap_width) * (clip -> gx_rectangle_top - ypos);
1696
3
    skipcount += (clip -> gx_rectangle_left - xpos);
1697
3
    getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
1698
3
    getrow += skipcount;
1699
1700
3
    getrowalpha = (GX_UBYTE *)(pixelmap -> gx_pixelmap_aux_data);
1701
3
    getrowalpha += skipcount;
1702
1703
580
    for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
1704
    {
1705
577
        get = getrow;
1706
577
        getalpha = getrowalpha;
1707
1708
85315
        for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
1709
        {
1710
84738
            alpha_value = *getalpha++;
1711
84738
            pixel = *get++;
1712
84738
            if (alpha_value)
1713
            {
1714
63381
                r = (GX_UBYTE)(((USHORT)pixel & 0xf800) >> 8);
1715
63381
                g = (GX_UBYTE)(((USHORT)pixel & 0x07e0) >> 3);
1716
63381
                b = (GX_UBYTE)(((USHORT)pixel & 0x001f) << 3);
1717
63381
                pixel = (GX_COLOR)ASSEMBLECOLOR_32BPP(r, g, b);
1718
63381
                if (alpha_value == 0xff)
1719
                {
1720
61974
                    _gx_display_driver_32bpp_pixel_write(context, xval, yval, pixel);
1721
                }
1722
                else
1723
                {
1724
1407
                    _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, alpha_value);
1725
                }
1726
            }
1727
        }
1728
577
        getrow += pixelmap -> gx_pixelmap_width;
1729
577
        getrowalpha += pixelmap -> gx_pixelmap_width;
1730
    }
1731
3
}
1732
1733
/**************************************************************************/
1734
/*                                                                        */
1735
/*  FUNCTION                                               RELEASE        */
1736
/*                                                                        */
1737
/*    _gx_display_driver_24xrgb_4444argb_pixelmap_alpha_write             */
1738
/*                                                        PORTABLE C      */
1739
/*                                                           6.1          */
1740
/*  AUTHOR                                                                */
1741
/*                                                                        */
1742
/*    Kenneth Maxwell, Microsoft Corporation                              */
1743
/*                                                                        */
1744
/*  DESCRIPTION                                                           */
1745
/*                                                                        */
1746
/*    Internal helper function that handles writing of uncompressed       */
1747
/*    pixlemap file with alpha channel of 4444argb format.                */
1748
/*                                                                        */
1749
/*  INPUT                                                                 */
1750
/*                                                                        */
1751
/*    context                               Drawing context               */
1752
/*    xpos                                  x-coord of top-left draw point*/
1753
/*    ypos                                  y-coord of top-left draw point*/
1754
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1755
/*                                                                        */
1756
/*  OUTPUT                                                                */
1757
/*                                                                        */
1758
/*    None                                                                */
1759
/*                                                                        */
1760
/*  CALLS                                                                 */
1761
/*                                                                        */
1762
/*    _gx_display_driver_24xrgb_pixel_blend Basic display driver pixel    */
1763
/*                                            blend function for 24xrgb   */
1764
/*                                            format                      */
1765
/*    _gx_display_driver_32bpp_pixel_write  Basic display driver pixel    */
1766
/*                                            write function for 32bpp    */
1767
/*                                            color depth                 */
1768
/*                                                                        */
1769
/*  CALLED BY                                                             */
1770
/*                                                                        */
1771
/*    _gx_display_driver_24xrgb_pixelmap_draw                             */
1772
/*                                                                        */
1773
/*  RELEASE HISTORY                                                       */
1774
/*                                                                        */
1775
/*    DATE              NAME                      DESCRIPTION             */
1776
/*                                                                        */
1777
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1778
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1779
/*                                            resulting in version 6.1    */
1780
/*                                                                        */
1781
/**************************************************************************/
1782
150
static VOID _gx_display_driver_24xrgb_4444argb_pixelmap_alpha_write(GX_DRAW_CONTEXT *context,
1783
                                                                    INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1784
{
1785
INT              skipcount;
1786
INT              xval;
1787
INT              yval;
1788
USHORT          *getrow;
1789
GX_CONST USHORT *get;
1790
UCHAR            alpha_value;
1791
ULONG            pixel;
1792
1793
150
GX_RECTANGLE    *clip = context -> gx_draw_context_clip;
1794
1795
    /* calculate how many pixels to skip */
1796
150
    skipcount = (pixelmap -> gx_pixelmap_width) * (clip -> gx_rectangle_top - ypos);
1797
150
    skipcount += (clip -> gx_rectangle_left - xpos);
1798
150
    getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
1799
150
    getrow += skipcount;
1800
1801
18709
    for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
1802
    {
1803
18559
        get = getrow;
1804
1805
2958784
        for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
1806
        {
1807
            /* 0x000f- -> b , 0x00f0- -> g , 0x0f00- -> r , 0xf000- -> a */
1808
            /*4444bgra - ->  565rgb*/
1809
2940225
            alpha_value = (UCHAR)(((*get) & 0xf000) >> 8);
1810
2940225
            if (alpha_value)
1811
            {
1812
2901438
                pixel = (GX_COLOR)((((*get) & 0x0f00) << 12) | (((*get) & 0x00f0) << 8) | (((*get) & 0x000f) << 4));
1813
2901438
                if (alpha_value == 0xf0)
1814
                {
1815
103865
                    _gx_display_driver_32bpp_pixel_write(context, xval, yval, pixel);
1816
                }
1817
                else
1818
                {
1819
2797573
                    _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, alpha_value);
1820
                }
1821
            }
1822
2940225
            get++;
1823
        }
1824
18559
        getrow += pixelmap -> gx_pixelmap_width;
1825
    }
1826
150
}
1827
1828
/**************************************************************************/
1829
/*                                                                        */
1830
/*  FUNCTION                                               RELEASE        */
1831
/*                                                                        */
1832
/*    _gx_display_driver_24xrgb_4444argb_pixelmap_compressed_alpha_write  */
1833
/*                                                        PORTABLE C      */
1834
/*                                                           6.1          */
1835
/*  AUTHOR                                                                */
1836
/*                                                                        */
1837
/*    Kenneth Maxwell, Microsoft Corporation                              */
1838
/*                                                                        */
1839
/*  DESCRIPTION                                                           */
1840
/*                                                                        */
1841
/*    Internal helper function that handles writing of compressed         */
1842
/*    pixelmap data of 4444argb format.                                   */
1843
/*                                                                        */
1844
/*  INPUT                                                                 */
1845
/*                                                                        */
1846
/*    context                               Drawing context               */
1847
/*    xpos                                  x-coord of top-left draw point*/
1848
/*    ypos                                  y-coord of top-left draw point*/
1849
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1850
/*                                                                        */
1851
/*  OUTPUT                                                                */
1852
/*                                                                        */
1853
/*    None                                                                */
1854
/*                                                                        */
1855
/*  CALLS                                                                 */
1856
/*                                                                        */
1857
/*    _gx_display_driver_24xrgb_pixel_blend Basic display driver pixel    */
1858
/*                                            blend function for 24xrgb   */
1859
/*                                            format                      */
1860
/*                                                                        */
1861
/*  CALLED BY                                                             */
1862
/*                                                                        */
1863
/*    _gx_display_driver_24xrgb_pixelmap_draw                             */
1864
/*                                                                        */
1865
/*  RELEASE HISTORY                                                       */
1866
/*                                                                        */
1867
/*    DATE              NAME                      DESCRIPTION             */
1868
/*                                                                        */
1869
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1870
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1871
/*                                            resulting in version 6.1    */
1872
/*                                                                        */
1873
/**************************************************************************/
1874
132
static VOID _gx_display_driver_24xrgb_4444argb_pixelmap_compressed_alpha_write(GX_DRAW_CONTEXT *context,
1875
                                                                               INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1876
{
1877
INT              yval;
1878
INT              xval;
1879
GX_CONST USHORT *get;
1880
USHORT           count;
1881
GX_COLOR         pixel;
1882
GX_UBYTE         falpha;
1883
GX_UBYTE         brush_alpha;
1884
GX_UBYTE         combined_alpha;
1885
GX_UBYTE         r;
1886
GX_UBYTE         g;
1887
GX_UBYTE         b;
1888
1889
132
GX_RECTANGLE    *clip = context -> gx_draw_context_clip;
1890
1891
132
    get = (GX_CONST USHORT *)pixelmap -> gx_pixelmap_data;
1892
132
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1893
1894
    /* first, skip to the starting row */
1895
246
    for (yval = ypos; yval < clip -> gx_rectangle_top; yval++)
1896
    {
1897
114
        xval = 0;
1898
7938
        while (xval < pixelmap -> gx_pixelmap_width)
1899
        {
1900
7824
            count = *get++;
1901
1902
7824
            if (count & 0x8000)
1903
            {
1904
4395
                count = (USHORT)((count & 0x7fff) + 1);
1905
4395
                get++;      /* skip repeated pixel value */
1906
            }
1907
            else
1908
            {
1909
3429
                count++;
1910
3429
                get += count;   /* skip raw pixel values */
1911
            }
1912
7824
            xval += count;
1913
        }
1914
    }
1915
1916
    /* now we are on the first visible row, copy pixels until we get
1917
       to the enf of the last visible row
1918
     */
1919
18072
    while (yval <= clip -> gx_rectangle_bottom)
1920
    {
1921
17940
        xval = xpos;
1922
1923
185277
        while (xval < xpos + pixelmap -> gx_pixelmap_width)
1924
        {
1925
167337
            count = *get++;
1926
1927
167337
            if (count & 0x8000)
1928
            {
1929
                /* repeated value */
1930
89721
                count = (USHORT)((count & 0x7fff) + 1);
1931
89721
                pixel = *get++;
1932
89721
                falpha = (GX_UBYTE)(((USHORT)pixel & 0xf000) >> 8);
1933
89721
                falpha = (falpha >> 4) | falpha;
1934
89721
                if (falpha)
1935
                {
1936
88392
                    r = (GX_UBYTE)(((USHORT)pixel & 0x0f00) >> 4);
1937
88392
                    r = (GX_UBYTE)((r >> 4) | r);
1938
88392
                    g = (GX_UBYTE)((USHORT)pixel & 0x00f0);
1939
88392
                    g = (GX_UBYTE)((g >> 4) | g);
1940
88392
                    b = (GX_UBYTE)((USHORT)pixel & 0x000f);
1941
88392
                    b = (GX_UBYTE)((b << 4) | b);
1942
88392
                    pixel = (GX_COLOR)ASSEMBLECOLOR_32BPP(r, g, b);
1943
88392
                    if (brush_alpha == 0xff)
1944
                    {
1945
51808
                        combined_alpha = falpha;
1946
                    }
1947
                    else
1948
                    {
1949
36584
                        combined_alpha = (GX_UBYTE)(brush_alpha * falpha / 255);
1950
                    }
1951
1952
2674281
                    while (count--)
1953
                    {
1954
2585889
                        if (xval >= clip -> gx_rectangle_left &&
1955
2575776
                            xval <= clip -> gx_rectangle_right)
1956
                        {
1957
1767687
                            _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, combined_alpha);
1958
                        }
1959
2585889
                        xval++;
1960
                    }
1961
                }
1962
                else
1963
                {
1964
1329
                    xval += count;
1965
                }
1966
            }
1967
            else
1968
            {
1969
                /* string of non-repeated values */
1970
77616
                count++;
1971
77616
                if (brush_alpha == 0xff)
1972
                {
1973
1262088
                    while (count--)
1974
                    {
1975
1213872
                        if (xval >= clip -> gx_rectangle_left &&
1976
1210508
                            xval <= clip -> gx_rectangle_right)
1977
                        {
1978
1115095
                            pixel = *get;
1979
1115095
                            falpha = (GX_UBYTE)(((USHORT)pixel & 0xf000) >> 8);
1980
1115095
                            falpha = (falpha >> 4) | falpha;
1981
1115095
                            r = (GX_UBYTE)(((USHORT)pixel & 0x0f00) >> 4);
1982
1115095
                            r = (GX_UBYTE)((r >> 4) | r);
1983
1115095
                            g = (GX_UBYTE)((USHORT)pixel & 0x00f0);
1984
1115095
                            g = (GX_UBYTE)((g >> 4) | g);
1985
1115095
                            b = (GX_UBYTE)((USHORT)pixel & 0x000f);
1986
1115095
                            b = (GX_UBYTE)((b << 4) | b);
1987
1115095
                            pixel = (GX_COLOR)ASSEMBLECOLOR_32BPP(r, g, b);
1988
1115095
                            if (falpha)
1989
                            {
1990
1115039
                                _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, falpha);
1991
                            }
1992
                        }
1993
1213872
                        get++;
1994
1213872
                        xval++;
1995
                    }
1996
                }
1997
                else
1998
                {
1999
312120
                    while (count--)
2000
                    {
2001
282720
                        if (xval >= clip -> gx_rectangle_left &&
2002
275992
                            xval <= clip -> gx_rectangle_right)
2003
                        {
2004
85166
                            pixel = *get;
2005
85166
                            falpha = (GX_UBYTE)(((USHORT)pixel & 0xf000) >> 8);
2006
85166
                            falpha = (falpha >> 4) | falpha;
2007
85166
                            combined_alpha = (GX_UBYTE)(falpha * brush_alpha / 255);
2008
85166
                            r = (GX_UBYTE)(((USHORT)pixel & 0x0f00) >> 4);
2009
85166
                            r = (GX_UBYTE)((r >> 4) | r);
2010
85166
                            g = (GX_UBYTE)((USHORT)pixel & 0x00f0);
2011
85166
                            g = (GX_UBYTE)((g >> 4) | g);
2012
85166
                            b = (GX_UBYTE)((USHORT)pixel & 0x000f);
2013
85166
                            b = (GX_UBYTE)((b << 4) | b);
2014
85166
                            pixel = (GX_COLOR)ASSEMBLECOLOR_32BPP(r, g, b);
2015
85166
                            _gx_display_driver_24xrgb_pixel_blend(context, xval, yval, pixel, combined_alpha);
2016
                        }
2017
282720
                        get++;
2018
282720
                        xval++;
2019
                    }
2020
                }
2021
            }
2022
        }
2023
17940
        yval++;
2024
    }
2025
132
}
2026
2027
/**************************************************************************/
2028
/*                                                                        */
2029
/*  FUNCTION                                               RELEASE        */
2030
/*                                                                        */
2031
/*    _gx_display_driver_24xrgb_pixelmap_draw             PORTABLE C      */
2032
/*                                                           6.1          */
2033
/*  AUTHOR                                                                */
2034
/*                                                                        */
2035
/*    Kenneth Maxwell, Microsoft Corporation                              */
2036
/*                                                                        */
2037
/*  DESCRIPTION                                                           */
2038
/*                                                                        */
2039
/*    32xrgb format screen driver pixelmap drawing function that handles  */
2040
/*    compressed or uncompress, with or without alpha channel.            */
2041
/*                                                                        */
2042
/*  INPUT                                                                 */
2043
/*                                                                        */
2044
/*    context                               Drawing context               */
2045
/*    xpos                                  x-coord of top-left draw point*/
2046
/*    ypos                                  y-coord of top-left draw point*/
2047
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
2048
/*                                                                        */
2049
/*  OUTPUT                                                                */
2050
/*                                                                        */
2051
/*    None                                                                */
2052
/*                                                                        */
2053
/*  CALLS                                                                 */
2054
/*                                                                        */
2055
/*    _gx_display_driver_24xrgb_palette_pixelmap_transparent_c_write      */
2056
/*                                          Real display driver pixelmap  */
2057
/*                                            draw function               */
2058
/*    _gx_display_driver_24xrgb_palette_pixelmap_transparent_write        */
2059
/*                                          Real display driver pixelmap  */
2060
/*                                            draw function               */
2061
/*    _gx_display_driver_24xrgb_palette_pixelmap_compressed_write         */
2062
/*                                          Real display driver pixelmap  */
2063
/*                                            draw function               */
2064
/*    _gx_display_driver_24xrgb_palette_pixelmap_write                    */
2065
/*                                          Real display driver pixelmap  */
2066
/*                                            draw function               */
2067
/*    _gx_display_driver_24xrgb_4444argb_pixelmap_compressed_alpha_write  */
2068
/*                                          Real display driver pixelmap  */
2069
/*                                            draw function               */
2070
/*    _gx_display_driver_24xrgb_4444argb_pixelmap_alpha_write             */
2071
/*                                          Real display driver pixelmap  */
2072
/*                                            draw function               */
2073
/*    _gx_display_driver_24xrgb_565rgb_pixelmap_compressed_alpha_write    */
2074
/*                                          Real display driver pixelmap  */
2075
/*                                            draw function               */
2076
/*    _gx_display_driver_24xrgb_565rgb_pixelmap_alpha_write               */
2077
/*                                          Real display driver pixelmap  */
2078
/*                                            draw function               */
2079
/*    _gx_display_driver_24xrgb_565rgb_pixelmap_compressed_write          */
2080
/*                                          Real display driver pixelmap  */
2081
/*                                            draw function               */
2082
/*    _gx_display_driver_24xrgb_565rgb_pixelmap_raw_write                 */
2083
/*                                          Real display driver pixelmap  */
2084
/*                                            draw function               */
2085
/*    _gx_display_driver_24xrgb_pixelmap_compressed_alpha_write           */
2086
/*                                          Real display driver pixelmap  */
2087
/*                                            draw function               */
2088
/*    _gx_display_driver_24xrgb_pixelmap_alpha_write                      */
2089
/*                                          Real display driver pixelmap  */
2090
/*                                            draw function               */
2091
/*    _gx_display_driver_24xrgb_pixelmap_compressed_write                 */
2092
/*                                          Real display driver pixelmap  */
2093
/*                                            draw function               */
2094
/*    _gx_display_driver_24xrgb_pixelmap_raw_write                        */
2095
/*                                          Real display driver pixelmap  */
2096
/*                                            draw function               */
2097
/*    _gx_display_driver_24xrgb_pixelmap_blend                            */
2098
/*                                          Basic display driver pixelmap */
2099
/*                                            blend function with alpha   */
2100
/*                                                                        */
2101
/*  CALLED BY                                                             */
2102
/*                                                                        */
2103
/*    GUIX Internal Code                                                  */
2104
/*                                                                        */
2105
/*  RELEASE HISTORY                                                       */
2106
/*                                                                        */
2107
/*    DATE              NAME                      DESCRIPTION             */
2108
/*                                                                        */
2109
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
2110
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
2111
/*                                            resulting in version 6.1    */
2112
/*                                                                        */
2113
/**************************************************************************/
2114
1048857
VOID _gx_display_driver_24xrgb_pixelmap_draw(GX_DRAW_CONTEXT *context,
2115
                                             INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
2116
{
2117
1048857
GX_BOOL  drawn = GX_FALSE;
2118
1048857
GX_UBYTE brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
2119
2120
1048857
    if (brush_alpha == 0)
2121
    {
2122
        /* Draw nothing here. Just return. */
2123
642
        return;
2124
    }
2125
2126

1048215
    switch (pixelmap -> gx_pixelmap_format)
2127
    {
2128
232
    case GX_COLOR_FORMAT_8BIT_PALETTE:
2129
232
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
2130
        {
2131
137
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2132
            {
2133
                /* compressed with transparent */
2134
70
                _gx_display_driver_24xrgb_palette_pixelmap_transparent_compressed_write(context, xpos, ypos, pixelmap);
2135
70
                drawn = GX_TRUE;
2136
            }
2137
            else
2138
            {
2139
                /* no compression with transparent */
2140
67
                if (brush_alpha == 0xff)
2141
                {
2142
65
                    _gx_display_driver_24xrgb_palette_pixelmap_transparent_write(context, xpos, ypos, pixelmap);
2143
65
                    drawn = GX_TRUE;
2144
                }
2145
            }
2146
        }
2147
        else
2148
        {
2149
95
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2150
            {
2151
                /* compressed with no alpha */
2152
81
                _gx_display_driver_24xrgb_palette_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2153
81
                drawn = GX_TRUE;
2154
            }
2155
            else
2156
            {
2157
                /* no compression or alpha */
2158
14
                if (brush_alpha == 0xff)
2159
                {
2160
7
                    _gx_display_driver_24xrgb_palette_pixelmap_write(context, xpos, ypos, pixelmap);
2161
7
                    drawn = GX_TRUE;
2162
                }
2163
            }
2164
        }
2165
232
        break;
2166
2167
291
    case GX_COLOR_FORMAT_4444ARGB:
2168
291
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2169
        {
2170
            /* compressed */
2171
132
            _gx_display_driver_24xrgb_4444argb_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2172
132
            drawn = GX_TRUE;
2173
        }
2174
        else
2175
        {
2176
            /* no compression  */
2177
159
            if (brush_alpha == 0xff)
2178
            {
2179
150
                _gx_display_driver_24xrgb_4444argb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2180
150
                drawn = GX_TRUE;
2181
            }
2182
        }
2183
291
        break;
2184
2185
594
    case GX_COLOR_FORMAT_565RGB:
2186
594
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
2187
        {
2188
14
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2189
            {
2190
                /* compressed with alpha */
2191
7
                _gx_display_driver_24xrgb_565rgb_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2192
7
                drawn = GX_TRUE;
2193
            }
2194
            else
2195
            {
2196
                /* uncompressed with alpha */
2197
7
                if (brush_alpha == 0xff)
2198
                {
2199
3
                    _gx_display_driver_24xrgb_565rgb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2200
3
                    drawn = GX_TRUE;
2201
                }
2202
            }
2203
        }
2204
        else
2205
        {
2206
580
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2207
            {
2208
                /* compressed without alpha */
2209
3
                _gx_display_driver_24xrgb_565rgb_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2210
3
                drawn = GX_TRUE;
2211
            }
2212
            else
2213
            {
2214
                /* uncompressed withou alpha */
2215
577
                if (brush_alpha == 0xff)
2216
                {
2217
574
                    _gx_display_driver_24xrgb_565rgb_pixelmap_raw_write(context, xpos, ypos, pixelmap);
2218
574
                    drawn = GX_TRUE;
2219
                }
2220
            }
2221
        }
2222
594
        break;
2223
2224
1047095
    case GX_COLOR_FORMAT_24XRGB:
2225
    case GX_COLOR_FORMAT_32ARGB:
2226
1047095
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
2227
        {
2228
908766
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2229
            {
2230
                /* has both compression and alpha */
2231
725697
                _gx_display_driver_24xrgb_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2232
725697
                drawn = GX_TRUE;
2233
            }
2234
            else
2235
            {
2236
                /* alpha, no compression */
2237
183069
                if (brush_alpha == 0xff)
2238
                {
2239
173097
                    _gx_display_driver_24xrgb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2240
173097
                    drawn = GX_TRUE;
2241
                }
2242
            }
2243
        }
2244
        else
2245
        {
2246
138329
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2247
            {
2248
                /* compressed with no alpha */
2249
109023
                _gx_display_driver_24xrgb_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2250
109023
                drawn = GX_TRUE;
2251
            }
2252
            else
2253
            {
2254
                /* no compression or alpha */
2255
29306
                if (brush_alpha == 0xff)
2256
                {
2257
28341
                    _gx_display_driver_24xrgb_pixelmap_raw_write(context, xpos, ypos, pixelmap);
2258
28341
                    drawn = GX_TRUE;
2259
                }
2260
            }
2261
        }
2262
1047095
        break;
2263
2264
3
    default:
2265
3
        break;
2266
    }
2267
2268

1048215
    if ((!drawn) && (brush_alpha != 0xff))
2269
    {
2270
10964
        _gx_display_driver_24xrgb_pixelmap_blend(context, xpos, ypos, pixelmap, brush_alpha);
2271
    }
2272
2273
1048215
    return;
2274
}
2275