GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_16bpp_pixelmap_draw.c Lines: 489 489 100.0 %
Date: 2024-12-05 08:52:37 Branches: 278 278 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
#include "gx_context.h"
29
30
/**************************************************************************/
31
/*                                                                        */
32
/*  FUNCTION                                               RELEASE        */
33
/*                                                                        */
34
/*    _gx_display_driver_565rgb_pixelmap_raw_write        PORTABLE C      */
35
/*                                                           6.X          */
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
/*    GUIX Internal Code                                                  */
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
/*  10-31-2023     Ting Zhu                 Modified comment(s),          */
72
/*                                            added partial canvas buffer */
73
/*                                            support,                    */
74
/*                                            resulting in version 6.3.0  */
75
/*                                                                        */
76
/**************************************************************************/
77
17741
static VOID _gx_display_driver_565rgb_pixelmap_raw_write(GX_DRAW_CONTEXT *context,
78
                                                         INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
79
{
80
INT              xval;
81
INT              yval;
82
INT              width;
83
USHORT          *putrow;
84
USHORT          *getrow;
85
USHORT          *put;
86
GX_CONST USHORT *get;
87
88
17741
GX_RECTANGLE    *clip = context -> gx_draw_context_clip;
89
90
17741
    putrow = (USHORT *)context -> gx_draw_context_memory;
91
92
17741
    GX_CALCULATE_PUTROW(putrow, clip->gx_rectangle_left, clip->gx_rectangle_top, context);
93
94
17741
    getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
95
17741
    getrow += pixelmap -> gx_pixelmap_width * (clip -> gx_rectangle_top - ypos);
96
17741
    getrow += (clip -> gx_rectangle_left - xpos);
97
98
17741
    width = clip -> gx_rectangle_right - clip -> gx_rectangle_left + 1;
99
100
1559586
    for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
101
    {
102
1541845
        put = putrow;
103
1541845
        get = getrow;
104
105
293360508
        for (xval = 0; xval < width; xval++)
106
        {
107
291818663
            *put++ = *get++;
108
        }
109
1541845
        putrow += context -> gx_draw_context_pitch;
110
1541845
        getrow += pixelmap -> gx_pixelmap_width;
111
    }
112
17741
}
113
114
/**************************************************************************/
115
/*                                                                        */
116
/*  FUNCTION                                               RELEASE        */
117
/*                                                                        */
118
/*    _gx_display_driver_565rgb_pixelmap_alpha_write      PORTABLE C      */
119
/*                                                           6.1          */
120
/*  AUTHOR                                                                */
121
/*                                                                        */
122
/*    Kenneth Maxwell, Microsoft Corporation                              */
123
/*                                                                        */
124
/*  DESCRIPTION                                                           */
125
/*                                                                        */
126
/*    Internal helper function that handles writing of uncompressed       */
127
/*    pixlemap file with alpha channel.                                   */
128
/*                                                                        */
129
/*  INPUT                                                                 */
130
/*                                                                        */
131
/*    context                               Drawing context               */
132
/*    xpos                                  x-coord of top-left draw point*/
133
/*    ypos                                  y-coord of top-left draw point*/
134
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
135
/*                                                                        */
136
/*  OUTPUT                                                                */
137
/*                                                                        */
138
/*    None                                                                */
139
/*                                                                        */
140
/*  CALLS                                                                 */
141
/*                                                                        */
142
/*    _gx_display_driver_565rgb_pixel_blend  Display driver basic pixel   */
143
/*                                             blend function             */
144
/*                                                                        */
145
/*  CALLED BY                                                             */
146
/*                                                                        */
147
/*    GUIX Internal Code                                                  */
148
/*                                                                        */
149
/*  RELEASE HISTORY                                                       */
150
/*                                                                        */
151
/*    DATE              NAME                      DESCRIPTION             */
152
/*                                                                        */
153
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
154
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
155
/*                                            resulting in version 6.1    */
156
/*                                                                        */
157
/**************************************************************************/
158
19876
static VOID _gx_display_driver_565rgb_pixelmap_alpha_write(GX_DRAW_CONTEXT *context,
159
                                                           INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
160
{
161
INT                skipcount;
162
INT                xval;
163
INT                yval;
164
USHORT            *getrow;
165
GX_UBYTE          *getrowalpha;
166
GX_CONST USHORT   *get;
167
GX_CONST GX_UBYTE *getalpha;
168
169
19876
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
170
void               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
171
172
19876
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
173
19876
    if (blend_func == GX_NULL)
174
    {
175
4
        return;
176
    }
177
178
    /* calculate how many pixels to skip */
179
19872
    skipcount = (pixelmap -> gx_pixelmap_width) * (clip -> gx_rectangle_top - ypos);
180
19872
    skipcount += (clip -> gx_rectangle_left - xpos);
181
19872
    getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
182
19872
    getrow += skipcount;
183
184
19872
    getrowalpha = (GX_UBYTE *)(pixelmap -> gx_pixelmap_aux_data);
185
19872
    getrowalpha += skipcount;
186
187
1998065
    for (yval  = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
188
    {
189
1978193
        get = getrow;
190
1978193
        getalpha = getrowalpha;
191
192
397238537
        for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
193
        {
194
395260344
            blend_func(context, xval, yval, *get++, *getalpha++);
195
        }
196
1978193
        getrow += pixelmap -> gx_pixelmap_width;
197
1978193
        getrowalpha += pixelmap -> gx_pixelmap_width;
198
    }
199
}
200
201
/**************************************************************************/
202
/*                                                                        */
203
/*  FUNCTION                                               RELEASE        */
204
/*                                                                        */
205
/*    _gx_display_driver_565rgb_pixelmap_compressed_write                 */
206
/*                                                        PORTABLE C      */
207
/*                                                           6.X          */
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
/*    None                                                                */
231
/*                                                                        */
232
/*  CALLED BY                                                             */
233
/*                                                                        */
234
/*    GUIX Internal Code                                                  */
235
/*                                                                        */
236
/*  RELEASE HISTORY                                                       */
237
/*                                                                        */
238
/*    DATE              NAME                      DESCRIPTION             */
239
/*                                                                        */
240
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
241
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
242
/*                                            resulting in version 6.1    */
243
/*  10-31-2023     Ting Zhu                 Modified comment(s),          */
244
/*                                            added partial canvas buffer */
245
/*                                            support,                    */
246
/*                                            resulting in version 6.3.0  */
247
/*                                                                        */
248
/**************************************************************************/
249
24366
static VOID _gx_display_driver_565rgb_pixelmap_compressed_write(GX_DRAW_CONTEXT *context,
250
                                                                INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
251
{
252
INT              yval;
253
INT              xval;
254
GX_CONST USHORT *get;
255
USHORT          *put;
256
USHORT          *putrow;
257
USHORT           count;
258
USHORT           pixel;
259
260
24366
GX_RECTANGLE    *clip = context -> gx_draw_context_clip;
261
262
24366
    get = (GX_CONST USHORT *)pixelmap -> gx_pixelmap_data;
263
    /* compressed with no alpha is a two-byte count and two-byte pixel value */
264
265
    /* first, skip to the starting row */
266
84109
    for (yval = ypos; yval < clip -> gx_rectangle_top; yval++)
267
    {
268
59743
        xval = 0;
269
2778605
        while (xval < pixelmap -> gx_pixelmap_width)
270
        {
271
2718862
            count = *get++;
272
273
2718862
            if (count & 0x8000)
274
            {
275
1362933
                count = (USHORT)((count & 0x7fff) + 1u);
276
1362933
                get++;      /* skip repeated pixel value */
277
            }
278
            else
279
            {
280
1355929
                count++;
281
1355929
                get += count;   /* skip raw pixel values */
282
            }
283
2718862
            xval += count;
284
        }
285
    }
286
287
    /* now we are on the first visible row, copy pixels until we get
288
       to the enf of the last visible row
289
     */
290
24366
    putrow = (USHORT *)context -> gx_draw_context_memory;
291
292
24366
    GX_CALCULATE_PUTROW(putrow, xpos, yval, context);
293
294
1762901
    while (yval <= clip -> gx_rectangle_bottom)
295
    {
296
1738535
        put = putrow;
297
1738535
        xval = xpos;
298
299
14294729
        while (xval < xpos + pixelmap -> gx_pixelmap_width)
300
        {
301
12556194
            count = *get++;
302
303
12556194
            if (count & 0x8000)
304
            {
305
                /* repeated value */
306
6316525
                count = (USHORT)((count & 0x7fff) + 1u);
307
6316525
                pixel = *get++;
308
212817708
                while (count--)
309
                {
310
206501183
                    if (xval >= clip -> gx_rectangle_left &&
311
205698256
                        xval <= clip -> gx_rectangle_right)
312
                    {
313
192947989
                        *put = pixel;
314
                    }
315
206501183
                    put++;
316
206501183
                    xval++;
317
                }
318
            }
319
            else
320
            {
321
                /* string of non-repeated values */
322
6239669
                count++;
323
324
185763419
                while (count--)
325
                {
326
179523750
                    if (xval >= clip -> gx_rectangle_left &&
327
173678310
                        xval <= clip -> gx_rectangle_right)
328
                    {
329
109170621
                        *put = *get;
330
                    }
331
179523750
                    put++;
332
179523750
                    get++;
333
179523750
                    xval++;
334
                }
335
            }
336
        }
337
1738535
        putrow +=  context -> gx_draw_context_pitch;
338
1738535
        yval++;
339
    }
340
24366
}
341
342
/**************************************************************************/
343
/*                                                                        */
344
/*  FUNCTION                                               RELEASE        */
345
/*                                                                        */
346
/*    _gx_display_driver_565rgb_pixelmap_compressed_alpha_write           */
347
/*                                                        PORTABLE C      */
348
/*                                                           6.1          */
349
/*  AUTHOR                                                                */
350
/*                                                                        */
351
/*    Kenneth Maxwell, Microsoft Corporation                              */
352
/*                                                                        */
353
/*  DESCRIPTION                                                           */
354
/*                                                                        */
355
/*    Internal helper function that handles writing of compressed         */
356
/*    pixlemap file with alpha channel.                                   */
357
/*                                                                        */
358
/*  INPUT                                                                 */
359
/*                                                                        */
360
/*    context                               Drawing context               */
361
/*    xpos                                  x-coord of top-left draw point*/
362
/*    ypos                                  y-coord of top-left draw point*/
363
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
364
/*                                                                        */
365
/*  OUTPUT                                                                */
366
/*                                                                        */
367
/*    None                                                                */
368
/*                                                                        */
369
/*  CALLS                                                                 */
370
/*                                                                        */
371
/*    _gx_display_driver_565rgb_pixel_blend  Display driver basic pixel   */
372
/*                                             blend function             */
373
/*                                                                        */
374
/*  CALLED BY                                                             */
375
/*                                                                        */
376
/*    GUIX Internal Code                                                  */
377
/*                                                                        */
378
/*  RELEASE HISTORY                                                       */
379
/*                                                                        */
380
/*    DATE              NAME                      DESCRIPTION             */
381
/*                                                                        */
382
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
383
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
384
/*                                            resulting in version 6.1    */
385
/*                                                                        */
386
/**************************************************************************/
387
66366
static VOID _gx_display_driver_565rgb_pixelmap_compressed_alpha_write(GX_DRAW_CONTEXT *context,
388
                                                                      INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
389
{
390
INT                yval;
391
INT                xval;
392
GX_CONST GX_UBYTE *get;
393
GX_CONST USHORT   *getpixel;
394
USHORT             count;
395
USHORT             pixel;
396
GX_UBYTE           falpha;
397
GX_UBYTE           brush_alpha;
398
GX_UBYTE           combined_alpha;
399
400
66366
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
401
void               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
402
403
66366
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
404
66366
    if (blend_func == GX_NULL)
405
    {
406
188
        return;
407
    }
408
409
66178
    get = pixelmap -> gx_pixelmap_data;
410
66178
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
411
412
    /* compressed with alpha is byte count, byte alpha, and and two-byte pixel value */
413
414
    /* first, skip to the starting row */
415
84766
    for (yval = ypos; yval < clip -> gx_rectangle_top; yval++)
416
    {
417
18588
        xval = 0;
418
105318
        while (xval < pixelmap -> gx_pixelmap_width)
419
        {
420
86730
            count = *get;
421
422
86730
            if (count & 0x80)
423
            {
424
55528
                count = (USHORT)((count & 0x7f) + 1u);
425
55528
                get +=  4;      /* skip repeated pixel value */
426
            }
427
            else
428
            {
429
31202
                count++;
430
31202
                get += (count * 4);      /* skip string of non-repeated pixels */
431
            }
432
86730
            xval += count;
433
        }
434
    }
435
436
    /* now we are on the first visible row, copy pixels until we get
437
       to the enf of the last visible row
438
     */
439
2983229
    while (yval <= clip -> gx_rectangle_bottom)
440
    {
441
2917051
        xval = xpos;
442
12696195
        while (xval < xpos + pixelmap -> gx_pixelmap_width)
443
        {
444
9779144
            count = *get;
445
446
9779144
            if (count & 0x80)
447
            {
448
                /* repeated value */
449
5144969
                count = (USHORT)((count & 0x7f) + 1u);
450
5144969
                falpha = *(get + 1);
451
452
5144969
                if (falpha)
453
                {
454
4389002
                    get += 2;
455
456
4389002
                    getpixel = (USHORT *)get;
457
4389002
                    pixel = *getpixel;
458
4389002
                    get += 2;
459
460
4389002
                    if (brush_alpha == 0xff)
461
                    {
462
4388466
                        combined_alpha = falpha;
463
                    }
464
                    else
465
                    {
466
536
                        combined_alpha = (GX_UBYTE)(falpha * brush_alpha / 255);
467
                    }
468
469
205027829
                    while (count--)
470
                    {
471
200638827
                        if (xval >= clip -> gx_rectangle_left &&
472
200635308
                            xval <= clip -> gx_rectangle_right)
473
                        {
474
197590174
                            blend_func(context, xval, yval, pixel, combined_alpha);
475
                        }
476
200638827
                        xval++;
477
                    }
478
                }
479
                else
480
                {
481
755967
                    get += 4;
482
755967
                    xval += count;
483
                }
484
            }
485
            else
486
            {
487
                /* string of non-repeated values */
488
4634175
                count++;
489
4634175
                if (brush_alpha == 0xff)
490
                {
491
106366785
                    while (count--)
492
                    {
493
101733618
                        if (xval >= clip -> gx_rectangle_left &&
494
101709324
                            xval <= clip -> gx_rectangle_right)
495
                        {
496
101406170
                            falpha = *(get + 1);
497
101406170
                            get += 2;
498
101406170
                            getpixel = (USHORT *)get;
499
101406170
                            pixel = *getpixel;
500
101406170
                            get += 2;
501
101406170
                            blend_func(context, xval, yval, pixel, falpha);
502
                        }
503
                        else
504
                        {
505
327448
                            get += 4;
506
                        }
507
101733618
                        xval++;
508
                    }
509
                }
510
                else
511
                {
512
6688
                    while (count--)
513
                    {
514
5680
                        if (xval >= clip -> gx_rectangle_left &&
515
5384
                            xval <= clip -> gx_rectangle_right)
516
                        {
517
5304
                            falpha = *(get + 1);
518
5304
                            get += 2;
519
5304
                            getpixel = (USHORT *)get;
520
5304
                            pixel = *getpixel;
521
5304
                            get += 2;
522
5304
                            combined_alpha = (GX_UBYTE)(falpha * brush_alpha / 255);
523
5304
                            blend_func(context, xval, yval, pixel, combined_alpha);
524
                        }
525
                        else
526
                        {
527
376
                            get += 4;
528
                        }
529
5680
                        xval++;
530
                    }
531
                }
532
            }
533
        }
534
2917051
        yval++;
535
    }
536
}
537
538
539
/**************************************************************************/
540
/*                                                                        */
541
/*  FUNCTION                                               RELEASE        */
542
/*                                                                        */
543
/*    _gx_display_driver_565rgb_palette_pixelmap_raw_write  PORTABLE C    */
544
/*                                                           6.3.0        */
545
/*  AUTHOR                                                                */
546
/*                                                                        */
547
/*    Kenneth Maxwell, Microsoft Corporation                              */
548
/*                                                                        */
549
/*  DESCRIPTION                                                           */
550
/*                                                                        */
551
/*    Internal helper function that handles writing of raw pixlemap       */
552
/*    file without transparent for palette pixelmap                       */
553
/*                                                                        */
554
/*  INPUT                                                                 */
555
/*                                                                        */
556
/*    context                               Drawing context               */
557
/*    xpos                                  x-coord of top-left draw point*/
558
/*    ypos                                  y-coord of top-left draw point*/
559
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
560
/*                                                                        */
561
/*  OUTPUT                                                                */
562
/*                                                                        */
563
/*    None                                                                */
564
/*                                                                        */
565
/*  CALLS                                                                 */
566
/*                                                                        */
567
/*    None                                                                */
568
/*                                                                        */
569
/*  CALLED BY                                                             */
570
/*                                                                        */
571
/*    GUIX Internal Code                                                  */
572
/*                                                                        */
573
/*  RELEASE HISTORY                                                       */
574
/*                                                                        */
575
/*    DATE              NAME                      DESCRIPTION             */
576
/*                                                                        */
577
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
578
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
579
/*                                            resulting in version 6.1    */
580
/*  10-31-2023     Ting Zhu                 Modified comment(s),          */
581
/*                                            added partial canvas buffer */
582
/*                                            support,                    */
583
/*                                            resulting in version 6.3.0  */
584
/*                                                                        */
585
/**************************************************************************/
586
2
static VOID _gx_display_driver_565rgb_palette_pixelmap_raw_write(GX_DRAW_CONTEXT *context,
587
                                                                 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
588
{
589
INT                xval;
590
INT                yval;
591
INT                width;
592
USHORT            *putrow;
593
GX_UBYTE          *getrow;
594
USHORT            *put;
595
GX_CONST GX_UBYTE *get;
596
GX_COLOR          *palette;
597
GX_UBYTE           r;
598
GX_UBYTE           g;
599
GX_UBYTE           b;
600
601
2
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
602
603
2
    putrow = (USHORT *)context -> gx_draw_context_memory;
604
605
2
    GX_CALCULATE_PUTROW(putrow, clip->gx_rectangle_left, clip->gx_rectangle_top, context);
606
607
2
    getrow = (GX_UBYTE *)(pixelmap -> gx_pixelmap_data);
608
2
    getrow += pixelmap -> gx_pixelmap_width * (clip -> gx_rectangle_top - ypos);
609
2
    getrow += (clip -> gx_rectangle_left - xpos);
610
611
2
    palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
612
613
2
    width = clip -> gx_rectangle_right - clip -> gx_rectangle_left + 1;
614
615
392
    for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
616
    {
617
390
        put = putrow;
618
390
        get = getrow;
619
620
94254
        for (xval = 0; xval < width; xval++)
621
        {
622
93864
            r = (GX_UBYTE)(REDVAL_32BPP(palette[*get]) >> 3);
623
93864
            g = (GX_UBYTE)(GREENVAL_32BPP(palette[*get]) >> 2);
624
93864
            b = (GX_UBYTE)(BLUEVAL_32BPP(palette[*get++]) >> 3);
625
93864
            *put++ = (USHORT)ASSEMBLECOLOR_16BPP(r, g, b);
626
        }
627
390
        putrow += context -> gx_draw_context_pitch;
628
390
        getrow += pixelmap -> gx_pixelmap_width;
629
    }
630
2
}
631
632
/**************************************************************************/
633
/*                                                                        */
634
/*  FUNCTION                                               RELEASE        */
635
/*                                                                        */
636
/*    _gx_display_driver_565rgb_palette_pixelmap_transparent_raw_write    */
637
/*                                                           PORTABLE C   */
638
/*                                                           6.X          */
639
/*  AUTHOR                                                                */
640
/*                                                                        */
641
/*    Kenneth Maxwell, Microsoft Corporation                              */
642
/*                                                                        */
643
/*  DESCRIPTION                                                           */
644
/*                                                                        */
645
/*    Internal helper function that handles writing of raw pixlemap       */
646
/*    file with transparent for palette pixelmap.                         */
647
/*                                                                        */
648
/*  INPUT                                                                 */
649
/*                                                                        */
650
/*    context                               Drawing context               */
651
/*    xpos                                  x-coord of top-left draw point*/
652
/*    ypos                                  y-coord of top-left draw point*/
653
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
654
/*                                                                        */
655
/*  OUTPUT                                                                */
656
/*                                                                        */
657
/*    None                                                                */
658
/*                                                                        */
659
/*  CALLS                                                                 */
660
/*                                                                        */
661
/*    None                                                                */
662
/*                                                                        */
663
/*  CALLED BY                                                             */
664
/*                                                                        */
665
/*    GUIX Internal Code                                                  */
666
/*                                                                        */
667
/*  RELEASE HISTORY                                                       */
668
/*                                                                        */
669
/*    DATE              NAME                      DESCRIPTION             */
670
/*                                                                        */
671
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
672
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
673
/*                                            resulting in version 6.1    */
674
/*  10-31-2023     Ting Zhu                 Modified comment(s),          */
675
/*                                            added partial canvas buffer */
676
/*                                            support,                    */
677
/*                                            resulting in version 6.3.0  */
678
/*                                                                        */
679
/**************************************************************************/
680
97
static VOID _gx_display_driver_565rgb_palette_pixelmap_transparent_raw_write(GX_DRAW_CONTEXT *context,
681
                                                                             INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
682
{
683
INT                xval;
684
INT                yval;
685
INT                width;
686
USHORT            *putrow;
687
GX_UBYTE          *getrow;
688
USHORT            *put;
689
GX_CONST GX_UBYTE *get;
690
GX_COLOR          *palette;
691
GX_UBYTE           r;
692
GX_UBYTE           g;
693
GX_UBYTE           b;
694
695
97
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
696
697
97
    putrow = (USHORT *)context->gx_draw_context_memory;
698
97
    GX_CALCULATE_PUTROW(putrow, clip->gx_rectangle_left, clip->gx_rectangle_top, context);
699
700
97
    getrow = (GX_UBYTE *)(pixelmap -> gx_pixelmap_data);
701
97
    getrow += pixelmap -> gx_pixelmap_width * (clip -> gx_rectangle_top - ypos);
702
97
    getrow += (clip -> gx_rectangle_left - xpos);
703
704
97
    palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
705
706
97
    width = clip -> gx_rectangle_right - clip -> gx_rectangle_left + 1;
707
708
11496
    for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
709
    {
710
11399
        put = putrow;
711
11399
        get = getrow;
712
713
1965767
        for (xval = 0; xval < width; xval++)
714
        {
715
1954368
            if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
716
            {
717
846243
                r = (GX_UBYTE)(REDVAL_32BPP(palette[*get]) >> 3);
718
846243
                g = (GX_UBYTE)(GREENVAL_32BPP(palette[*get]) >> 2);
719
846243
                b = (GX_UBYTE)(BLUEVAL_32BPP(palette[*get]) >> 3);
720
846243
                *put = (USHORT)ASSEMBLECOLOR_16BPP(r, g, b);
721
            }
722
1954368
            get++;
723
1954368
            put++;
724
        }
725
11399
        putrow += context -> gx_draw_context_pitch;
726
11399
        getrow += pixelmap -> gx_pixelmap_width;
727
    }
728
97
}
729
730
/**************************************************************************/
731
/*                                                                        */
732
/*  FUNCTION                                               RELEASE        */
733
/*                                                                        */
734
/*    _gx_display_driver_565rgb_palette_pixelmap_transparent_compressed   */
735
/*      _write                                                            */
736
/*                                                        PORTABLE C      */
737
/*                                                           6.3.0        */
738
/*  AUTHOR                                                                */
739
/*                                                                        */
740
/*    Kenneth Maxwell, Microsoft Corporation                              */
741
/*                                                                        */
742
/*  DESCRIPTION                                                           */
743
/*                                                                        */
744
/*    Internal helper function that handles writing of compressed         */
745
/*    pixlemap file with transparent for palette pixelmap                 */
746
/*                                                                        */
747
/*  INPUT                                                                 */
748
/*                                                                        */
749
/*    context                               Drawing context               */
750
/*    xpos                                  x-coord of top-left draw point*/
751
/*    ypos                                  y-coord of top-left draw point*/
752
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
753
/*                                                                        */
754
/*  OUTPUT                                                                */
755
/*                                                                        */
756
/*    None                                                                */
757
/*                                                                        */
758
/*  CALLS                                                                 */
759
/*                                                                        */
760
/*    _gx_display_driver_565rgb_pixel_blend  Display driver basic pixel   */
761
/*                                             blend function             */
762
/*                                                                        */
763
/*  CALLED BY                                                             */
764
/*                                                                        */
765
/*    GUIX Internal Code                                                  */
766
/*                                                                        */
767
/*  RELEASE HISTORY                                                       */
768
/*                                                                        */
769
/*    DATE              NAME                      DESCRIPTION             */
770
/*                                                                        */
771
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
772
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
773
/*                                            resulting in version 6.1    */
774
/*  10-31-2023     Ting Zhu                 Modified comment(s),          */
775
/*                                            added partial canvas buffer */
776
/*                                            support,                    */
777
/*                                            resulting in version 6.3.0  */
778
/*                                                                        */
779
/**************************************************************************/
780
86
static VOID _gx_display_driver_565rgb_palette_pixelmap_transparent_compressed_write(GX_DRAW_CONTEXT *context,
781
                                                                                    INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
782
{
783
INT                yval;
784
INT                xval;
785
GX_CONST GX_UBYTE *get;
786
USHORT            *put;
787
USHORT            *putrow;
788
GX_COLOR          *palette;
789
GX_UBYTE           brush_alpha;
790
USHORT             count;
791
USHORT             pixel;
792
GX_UBYTE           r;
793
GX_UBYTE           g;
794
GX_UBYTE           b;
795
86
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
796
797
86
    get = (GX_CONST GX_UBYTE *)pixelmap -> gx_pixelmap_data;
798
86
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
799
800
    /* compressed with no alpha is a one-byte count and one-byte index value */
801
    /* first, skip to the starting row */
802
163
    for (yval = ypos; yval < clip -> gx_rectangle_top; yval++)
803
    {
804
77
        xval = 0;
805
301
        while (xval < pixelmap -> gx_pixelmap_width)
806
        {
807
224
            count = *get++;
808
809
224
            if (count & 0x80)
810
            {
811
155
                count = (USHORT)((count & 0x7f) + 1u);
812
155
                get++;      /* skip repeated pixel value */
813
            }
814
            else
815
            {
816
69
                count++;
817
69
                get += count;   /* skip raw pixel values */
818
            }
819
224
            xval += count;
820
        }
821
    }
822
823
    /* Now we are on the first visible row, copy pixels until we get
824
       to the end of the last visible row. */
825
86
    putrow = (USHORT *)context -> gx_draw_context_memory;
826
86
    GX_CALCULATE_PUTROW(putrow, xpos, yval, context);
827
828
86
    palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
829
830
11365
    while (yval <= clip -> gx_rectangle_bottom)
831
    {
832
11279
        put = putrow;
833
11279
        xval = xpos;
834
835
204792
        while (xval < xpos + pixelmap -> gx_pixelmap_width)
836
        {
837
193513
            count = *get++;
838
839
193513
            if (count & 0x80)
840
            {
841
                /* repeated value */
842
126974
                count = (USHORT)((count & 0x7f) + 1u);
843
844
126974
                if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
845
                {
846
107467
                    r = (GX_UBYTE)(REDVAL_32BPP(palette[*get]) >> 3);
847
107467
                    g = (GX_UBYTE)(GREENVAL_32BPP(palette[*get]) >> 2);
848
107467
                    b = (GX_UBYTE)(BLUEVAL_32BPP(palette[*get]) >> 3);
849
850
107467
                    if (brush_alpha == 0xff)
851
                    {
852
666434
                        while (count--)
853
                        {
854
559423
                            if (xval >= clip -> gx_rectangle_left &&
855
559095
                                xval <= clip -> gx_rectangle_right)
856
                            {
857
558621
                                *put = (USHORT)ASSEMBLECOLOR_16BPP(r, g, b);
858
                            }
859
559423
                            put++;
860
559423
                            xval++;
861
                        }
862
                    }
863
                    else
864
                    {
865
456
                        pixel = (USHORT)ASSEMBLECOLOR_16BPP(r, g, b);
866
2790
                        while (count--)
867
                        {
868
2334
                            if (xval >= clip -> gx_rectangle_left &&
869
2006
                                xval <= clip -> gx_rectangle_right)
870
                            {
871
1532
                                _gx_display_driver_565rgb_pixel_blend(context, xval, yval, pixel, brush_alpha);
872
                            }
873
2334
                            xval++;
874
                        }
875
                    }
876
                }
877
                else
878
                {
879
19507
                    put += count;
880
19507
                    xval += count;
881
                }
882
126974
                get++;
883
            }
884
            else
885
            {
886
                /* string of non-repeated values */
887
66539
                count++;
888
889
66539
                if (brush_alpha == 0xff)
890
                {
891
378885
                    while (count--)
892
                    {
893
312848
                        if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
894
                        {
895
308591
                            if (xval >= clip -> gx_rectangle_left &&
896
308372
                                xval <= clip -> gx_rectangle_right)
897
                            {
898
308115
                                r = (GX_UBYTE)(REDVAL_32BPP(palette[*get]) >> 3);
899
308115
                                g = (GX_UBYTE)(GREENVAL_32BPP(palette[*get]) >> 2);
900
308115
                                b = (GX_UBYTE)(BLUEVAL_32BPP(palette[*get]) >> 3);
901
308115
                                *put = (USHORT)ASSEMBLECOLOR_16BPP(r, g, b);
902
                            }
903
                        }
904
312848
                        put++;
905
312848
                        get++;
906
312848
                        xval++;
907
                    }
908
                }
909
                else
910
                {
911
2334
                    while (count--)
912
                    {
913
1832
                        if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
914
                        {
915
1820
                            if (xval >= clip -> gx_rectangle_left &&
916
1601
                                xval <= clip -> gx_rectangle_right)
917
                            {
918
1344
                                r = (GX_UBYTE)(REDVAL_32BPP(palette[*get]) >> 3);
919
1344
                                g = (GX_UBYTE)(GREENVAL_32BPP(palette[*get]) >> 2);
920
1344
                                b = (GX_UBYTE)(BLUEVAL_32BPP(palette[*get]) >> 3);
921
1344
                                pixel = (USHORT)ASSEMBLECOLOR_16BPP(r, g, b);
922
1344
                                _gx_display_driver_565rgb_pixel_blend(context, xval, yval, pixel, brush_alpha);
923
                            }
924
                        }
925
1832
                        get++;
926
1832
                        xval++;
927
                    }
928
                }
929
            }
930
        }
931
11279
        putrow += context -> gx_draw_context_pitch;
932
11279
        yval++;
933
    }
934
86
}
935
936
937
/**************************************************************************/
938
/*                                                                        */
939
/*  FUNCTION                                               RELEASE        */
940
/*                                                                        */
941
/*    _gx_display_driver_565rgb_palette_pixelmap_compressed_write         */
942
/*                                                        PORTABLE C      */
943
/*                                                           6.3.0        */
944
/*  AUTHOR                                                                */
945
/*                                                                        */
946
/*    Kenneth Maxwell, Microsoft Corporation                              */
947
/*                                                                        */
948
/*  DESCRIPTION                                                           */
949
/*                                                                        */
950
/*    Internal helper function that handles writing of compressed         */
951
/*    pixlemap file without alpha channel for palette pixelmap.           */
952
/*                                                                        */
953
/*  INPUT                                                                 */
954
/*                                                                        */
955
/*    context                               Drawing context               */
956
/*    xpos                                  x-coord of top-left draw point*/
957
/*    ypos                                  y-coord of top-left draw point*/
958
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
959
/*                                                                        */
960
/*  OUTPUT                                                                */
961
/*                                                                        */
962
/*    None                                                                */
963
/*                                                                        */
964
/*  CALLS                                                                 */
965
/*                                                                        */
966
/*    None                                                                */
967
/*                                                                        */
968
/*  CALLED BY                                                             */
969
/*                                                                        */
970
/*    GUIX Internal Code                                                  */
971
/*                                                                        */
972
/*  RELEASE HISTORY                                                       */
973
/*                                                                        */
974
/*    DATE              NAME                      DESCRIPTION             */
975
/*                                                                        */
976
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
977
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
978
/*                                            resulting in version 6.1    */
979
/*  10-31-2023     Ting Zhu                 Modified comment(s),          */
980
/*                                            added partial canvas buffer */
981
/*                                            support,                    */
982
/*                                            resulting in version 6.3.0  */
983
/*                                                                        */
984
/**************************************************************************/
985
71
static VOID _gx_display_driver_565rgb_palette_pixelmap_compressed_write(GX_DRAW_CONTEXT *context,
986
                                                                        INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
987
{
988
INT                yval;
989
INT                xval;
990
GX_CONST GX_UBYTE *get;
991
USHORT            *put;
992
USHORT            *putrow;
993
GX_COLOR          *palette;
994
USHORT             count;
995
GX_UBYTE           r;
996
GX_UBYTE           g;
997
GX_UBYTE           b;
998
GX_UBYTE           brush_alpha;
999
71
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
1000
1001
71
    get = (GX_CONST GX_UBYTE *)pixelmap -> gx_pixelmap_data;
1002
71
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1003
1004
    /* compressed with no alpha is a one-byte count and one-byte index value */
1005
    /* first, skip to the starting row */
1006
148
    for (yval = ypos; yval < clip -> gx_rectangle_top; yval++)
1007
    {
1008
77
        xval = 0;
1009
661
        while (xval < pixelmap -> gx_pixelmap_width)
1010
        {
1011
584
            count = *get++;
1012
1013
584
            if (count & 0x80)
1014
            {
1015
385
                count = (USHORT)((count & 0x7f) + 1u);
1016
385
                get++;      /* skip repeated pixel value */
1017
            }
1018
            else
1019
            {
1020
199
                count++;
1021
199
                get += count;   /* skip raw pixel values */
1022
            }
1023
584
            xval += count;
1024
        }
1025
    }
1026
1027
    /* Now we are on the first visible row, copy pixels until we get
1028
       to the end of the last visible row. */
1029
71
    putrow = (USHORT *)context -> gx_draw_context_memory;
1030
71
    GX_CALCULATE_PUTROW(putrow, xpos, yval, context);
1031
1032
71
    palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
1033
1034
10793
    while (yval <= clip -> gx_rectangle_bottom)
1035
    {
1036
10722
        put = putrow;
1037
10722
        xval = xpos;
1038
1039
1369768
        while (xval < xpos + pixelmap -> gx_pixelmap_width)
1040
        {
1041
1359046
            count = *get++;
1042
1043
1359046
            if (count & 0x80)
1044
            {
1045
                /* repeated value */
1046
765276
                count = (USHORT)((count & 0x7f) + 1u);
1047
1048
765276
                r = (GX_UBYTE)(REDVAL_32BPP(palette[*get]) >> 3);
1049
765276
                g = (GX_UBYTE)(GREENVAL_32BPP(palette[*get]) >> 2);
1050
765276
                b = (GX_UBYTE)(BLUEVAL_32BPP(palette[*get++]) >> 3);
1051
1052
765276
                if (brush_alpha == 0xff)
1053
                {
1054
4465751
                    while (count--)
1055
                    {
1056
3702233
                        if (xval >= clip -> gx_rectangle_left &&
1057
3697978
                            xval <= clip -> gx_rectangle_right)
1058
                        {
1059
1069010
                            *put = (USHORT)ASSEMBLECOLOR_16BPP(r, g, b);
1060
                        }
1061
3702233
                        put++;
1062
3702233
                        xval++;
1063
                    }
1064
                }
1065
                else
1066
                {
1067
56554
                    while (count--)
1068
                    {
1069
54796
                        if (xval >= clip -> gx_rectangle_left &&
1070
47996
                            xval <= clip -> gx_rectangle_right)
1071
                        {
1072
41340
                            _gx_display_driver_565rgb_pixel_blend(context, xval, yval, (USHORT)ASSEMBLECOLOR_16BPP(r, g, b), brush_alpha);
1073
                        }
1074
54796
                        xval++;
1075
                    }
1076
                }
1077
            }
1078
            else
1079
            {
1080
                /* string of non-repeated values */
1081
593770
                count++;
1082
593770
                if (brush_alpha == 0xff)
1083
                {
1084
5852775
                    while (count--)
1085
                    {
1086
5260287
                        if (xval >= clip -> gx_rectangle_left &&
1087
5259972
                            xval <= clip -> gx_rectangle_right)
1088
                        {
1089
1440144
                            r = (GX_UBYTE)(REDVAL_32BPP(palette[*get]) >> 3);
1090
1440144
                            g = (GX_UBYTE)(GREENVAL_32BPP(palette[*get]) >> 2);
1091
1440144
                            b = (GX_UBYTE)(BLUEVAL_32BPP(palette[*get]) >> 3);
1092
1440144
                            *put = (USHORT)ASSEMBLECOLOR_16BPP(r, g, b);
1093
                        }
1094
1095
5260287
                        put++;
1096
5260287
                        get++;
1097
5260287
                        xval++;
1098
                    }
1099
                }
1100
                else
1101
                {
1102
6966
                    while (count--)
1103
                    {
1104
5684
                        if (xval >= clip -> gx_rectangle_left &&
1105
5054
                            xval <= clip -> gx_rectangle_right)
1106
                        {
1107
4034
                            r = (GX_UBYTE)(REDVAL_32BPP(palette[*get]) >> 3);
1108
4034
                            g = (GX_UBYTE)(GREENVAL_32BPP(palette[*get]) >> 2);
1109
4034
                            b = (GX_UBYTE)(BLUEVAL_32BPP(palette[*get]) >> 3);
1110
4034
                            _gx_display_driver_565rgb_pixel_blend(context, xval, yval, (USHORT)ASSEMBLECOLOR_16BPP(r, g, b), brush_alpha);
1111
                        }
1112
1113
5684
                        get++;
1114
5684
                        xval++;
1115
                    }
1116
                }
1117
            }
1118
        }
1119
10722
        putrow += context -> gx_draw_context_pitch;
1120
10722
        yval++;
1121
    }
1122
71
}
1123
1124
/**************************************************************************/
1125
/*                                                                        */
1126
/*  FUNCTION                                               RELEASE        */
1127
/*                                                                        */
1128
/*    _gx_display_driver_16bpp_4444argb_pixelmap_raw_write                */
1129
/*                                                         PORTABLE C     */
1130
/*                                                           6.1          */
1131
/*  AUTHOR                                                                */
1132
/*                                                                        */
1133
/*    Kenneth Maxwell, Microsoft Corporation                              */
1134
/*                                                                        */
1135
/*  DESCRIPTION                                                           */
1136
/*                                                                        */
1137
/*    Internal helper function that handles writing of uncompressed       */
1138
/*    pixlemap file with alpha channel of 4444argb format.                */
1139
/*                                                                        */
1140
/*  INPUT                                                                 */
1141
/*                                                                        */
1142
/*    context                               Drawing context               */
1143
/*    xpos                                  x-coord of top-left draw point*/
1144
/*    ypos                                  y-coord of top-left draw point*/
1145
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1146
/*                                                                        */
1147
/*  OUTPUT                                                                */
1148
/*                                                                        */
1149
/*    None                                                                */
1150
/*                                                                        */
1151
/*  CALLS                                                                 */
1152
/*                                                                        */
1153
/*    _gx_display_driver_565rgb_pixel_blend  Display driver basic pixel   */
1154
/*                                             blend function             */
1155
/*    _gx_display_driver_16bpp_pixel_write   Display driver basic pixel   */
1156
/*                                             write function             */
1157
/*                                                                        */
1158
/*  CALLED BY                                                             */
1159
/*                                                                        */
1160
/*    GUIX Internal Code                                                  */
1161
/*                                                                        */
1162
/*  RELEASE HISTORY                                                       */
1163
/*                                                                        */
1164
/*    DATE              NAME                      DESCRIPTION             */
1165
/*                                                                        */
1166
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1167
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1168
/*                                            resulting in version 6.1    */
1169
/*                                                                        */
1170
/**************************************************************************/
1171
19
static VOID _gx_display_driver_16bpp_4444argb_pixelmap_raw_write(GX_DRAW_CONTEXT *context,
1172
                                                                 INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1173
{
1174
INT              skipcount;
1175
INT              xval;
1176
INT              yval;
1177
USHORT          *getrow;
1178
GX_CONST USHORT *get;
1179
UCHAR            alpha_value;
1180
USHORT           pixel;
1181
1182
19
GX_RECTANGLE    *clip = context -> gx_draw_context_clip;
1183
1184
    /* calculate how many pixels to skip */
1185
19
    skipcount = (pixelmap -> gx_pixelmap_width) * (clip -> gx_rectangle_top - ypos);
1186
19
    skipcount += (clip -> gx_rectangle_left - xpos);
1187
19
    getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
1188
19
    getrow += skipcount;
1189
1190
2314
    for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
1191
    {
1192
2295
        get = getrow;
1193
1194
349813
        for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
1195
        {
1196
            /* 0x000f- -> b , 0x00f0- -> g , 0x0f00- -> r , 0xf000- -> a */
1197
            /*4444bgra - ->  565rgb*/
1198
347518
            alpha_value = (UCHAR)(((*get) & 0xf000) >> 8);
1199
347518
            alpha_value = alpha_value | (alpha_value >> 4);
1200
347518
            if (alpha_value)
1201
            {
1202
230959
                pixel = (USHORT)((((*get) & 0x0f00) << 4) | (((*get) & 0x00f0) << 3) | (((*get) & 0x000f) << 1));
1203
230959
                if (alpha_value == 0xff)
1204
                {
1205
134427
                    _gx_display_driver_16bpp_pixel_write(context, xval, yval, pixel);
1206
                }
1207
                else
1208
                {
1209
96532
                    _gx_display_driver_565rgb_pixel_blend(context, xval, yval, pixel, alpha_value);
1210
                }
1211
            }
1212
347518
            get++;
1213
        }
1214
2295
        getrow += pixelmap -> gx_pixelmap_width;
1215
    }
1216
19
}
1217
/**************************************************************************/
1218
/*                                                                        */
1219
/*  FUNCTION                                               RELEASE        */
1220
/*                                                                        */
1221
/*    _gx_display_driver_16bpp_4444argb_pixelmap_compressed_write         */
1222
/*                                                        PORTABLE C      */
1223
/*                                                           6.1          */
1224
/*  AUTHOR                                                                */
1225
/*                                                                        */
1226
/*    Kenneth Maxwell, Microsoft Corporation                              */
1227
/*                                                                        */
1228
/*  DESCRIPTION                                                           */
1229
/*                                                                        */
1230
/*    Internal helper function that handles writing of compressed         */
1231
/*    pixelmap data of format 4444argb in 16bpp drivers.                  */
1232
/*                                                                        */
1233
/*  INPUT                                                                 */
1234
/*                                                                        */
1235
/*    context                               Drawing context               */
1236
/*    xpos                                  x-coord of top-left draw point*/
1237
/*    ypos                                  y-coord of top-left draw point*/
1238
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1239
/*                                                                        */
1240
/*  OUTPUT                                                                */
1241
/*                                                                        */
1242
/*    None                                                                */
1243
/*                                                                        */
1244
/*  CALLS                                                                 */
1245
/*                                                                        */
1246
/*    _gx_display_driver_565rgb_pixel_blend  Display driver basic pixel   */
1247
/*                                             blend function             */
1248
/*    _gx_display_driver_16bpp_pixel_write   Display driver basic pixel   */
1249
/*                                             write function             */
1250
/*                                                                        */
1251
/*  CALLED BY                                                             */
1252
/*                                                                        */
1253
/*    GUIX Internal Code                                                  */
1254
/*                                                                        */
1255
/*  RELEASE HISTORY                                                       */
1256
/*                                                                        */
1257
/*    DATE              NAME                      DESCRIPTION             */
1258
/*                                                                        */
1259
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1260
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1261
/*                                            resulting in version 6.1    */
1262
/*                                                                        */
1263
/**************************************************************************/
1264
37
static VOID _gx_display_driver_16bpp_4444argb_pixelmap_compressed_write(GX_DRAW_CONTEXT *context,
1265
                                                                        INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1266
{
1267
INT              yval;
1268
INT              xval;
1269
GX_CONST USHORT *get;
1270
USHORT           count;
1271
USHORT           pixel;
1272
GX_UBYTE         alpha_value;
1273
GX_UBYTE         combined_alpha;
1274
GX_UBYTE         brush_alpha;
1275
GX_UBYTE         r;
1276
GX_UBYTE         g;
1277
GX_UBYTE         b;
1278
1279
37
GX_RECTANGLE    *clip = context -> gx_draw_context_clip;
1280
1281
37
    get = (GX_CONST USHORT *)pixelmap -> gx_pixelmap_data;
1282
37
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1283
1284
    /* first, skip to the starting row */
1285
151
    for (yval = ypos; yval < clip -> gx_rectangle_top; yval++)
1286
    {
1287
114
        xval = 0;
1288
7938
        while (xval < pixelmap -> gx_pixelmap_width)
1289
        {
1290
7824
            count = *get++;
1291
1292
7824
            if (count & 0x8000)
1293
            {
1294
4395
                count = (USHORT)((count & 0x7fff) + 1u);
1295
4395
                get++;      /* skip repeated pixel value */
1296
            }
1297
            else
1298
            {
1299
3429
                count++;
1300
3429
                get += count;   /* skip raw pixel values */
1301
            }
1302
7824
            xval += count;
1303
        }
1304
    }
1305
1306
    /* now we are on the first visible row, copy pixels until we get
1307
       to the enf of the last visible row
1308
     */
1309
1875
    while (yval <= clip -> gx_rectangle_bottom)
1310
    {
1311
1838
        xval = xpos;
1312
1313
110136
        while (xval < xpos + pixelmap -> gx_pixelmap_width)
1314
        {
1315
108298
            count = *get++;
1316
1317
108298
            if (count & 0x8000)
1318
            {
1319
                /* repeated value */
1320
60800
                count = (USHORT)((count & 0x7fff) + 1u);
1321
60800
                pixel = *get++;
1322
60800
                alpha_value = (GX_UBYTE)((pixel & 0xf000) >> 8);
1323
60800
                alpha_value = (alpha_value >> 4) | alpha_value;
1324
60800
                if (alpha_value)
1325
                {
1326
58762
                    r = (GX_UBYTE)((pixel & 0x0f00) >> 7);
1327
58762
                    g = (GX_UBYTE)((pixel & 0x00f0) >> 2);
1328
58762
                    b = (GX_UBYTE)((pixel & 0x000f) << 1);
1329
58762
                    pixel = (USHORT)ASSEMBLECOLOR_16BPP(r, g, b);
1330
1331
58762
                    if (brush_alpha == 0xff)
1332
                    {
1333
142768
                        while (count--)
1334
                        {
1335
120590
                            if (xval >= clip -> gx_rectangle_left &&
1336
117219
                                xval <= clip -> gx_rectangle_right)
1337
                            {
1338
48952
                                if (alpha_value == 0xff)
1339
                                {
1340
48893
                                    _gx_display_driver_16bpp_pixel_write(context, xval, yval, pixel);
1341
                                }
1342
                                else
1343
                                {
1344
59
                                    _gx_display_driver_565rgb_pixel_blend(context, xval, yval, pixel, alpha_value);
1345
                                }
1346
                            }
1347
120590
                            xval++;
1348
                        }
1349
                    }
1350
                    else
1351
                    {
1352
241118
                        while (count--)
1353
                        {
1354
204534
                            if (xval >= clip -> gx_rectangle_left &&
1355
197792
                                xval <= clip -> gx_rectangle_right)
1356
                            {
1357
61258
                                combined_alpha = (GX_UBYTE)(brush_alpha * alpha_value / 255);
1358
61258
                                _gx_display_driver_565rgb_pixel_blend(context, xval, yval, pixel, combined_alpha);
1359
                            }
1360
204534
                            xval++;
1361
                        }
1362
                    }
1363
                }
1364
                else
1365
                {
1366
58290
                    while (count--)
1367
                    {
1368
56252
                        xval++;
1369
                    }
1370
                }
1371
            }
1372
            else
1373
            {
1374
                /* string of non-repeated values */
1375
47498
                count++;
1376
1377
47498
                if (brush_alpha == 0xff)
1378
                {
1379
176354
                    while (count--)
1380
                    {
1381
158256
                        if (xval >= clip -> gx_rectangle_left &&
1382
154892
                            xval <= clip -> gx_rectangle_right)
1383
                        {
1384
59479
                            pixel = *get;
1385
59479
                            alpha_value = (GX_UBYTE)((pixel & 0xf000) >> 8);
1386
59479
                            alpha_value = (alpha_value >> 4) | alpha_value;
1387
59479
                            r = (GX_UBYTE)((pixel & 0x0f00) >> 7);
1388
59479
                            g = (GX_UBYTE)((pixel & 0x00f0) >> 2);
1389
59479
                            b = (GX_UBYTE)((pixel & 0x000f) << 1);
1390
59479
                            pixel = (USHORT)ASSEMBLECOLOR_16BPP(r, g, b);
1391
59479
                            if (alpha_value)
1392
                            {
1393
58837
                                if (alpha_value == 0xff)
1394
                                {
1395
56524
                                    _gx_display_driver_16bpp_pixel_write(context, xval, yval, pixel);
1396
                                }
1397
                                else
1398
                                {
1399
2313
                                    _gx_display_driver_565rgb_pixel_blend(context, xval, yval, pixel, alpha_value);
1400
                                }
1401
                            }
1402
                        }
1403
158256
                        get++;
1404
158256
                        xval++;
1405
                    }
1406
                }
1407
                else
1408
                {
1409
312120
                    while (count--)
1410
                    {
1411
282720
                        if (xval >= clip -> gx_rectangle_left &&
1412
275992
                            xval <= clip -> gx_rectangle_right)
1413
                        {
1414
85166
                            pixel = *get;
1415
85166
                            alpha_value = (GX_UBYTE)((pixel & 0xf000) >> 8);
1416
85166
                            alpha_value = (alpha_value >> 4) | alpha_value;
1417
85166
                            r = (GX_UBYTE)((pixel & 0x0f00) >> 7);
1418
85166
                            g = (GX_UBYTE)((pixel & 0x00f0) >> 2);
1419
85166
                            b = (GX_UBYTE)((pixel & 0x000f) << 1);
1420
85166
                            pixel = (USHORT)ASSEMBLECOLOR_16BPP(r, g, b);
1421
85166
                            combined_alpha = (GX_UBYTE)(brush_alpha * alpha_value / 255);
1422
85166
                            _gx_display_driver_565rgb_pixel_blend(context, xval, yval, pixel, combined_alpha);
1423
                        }
1424
282720
                        get++;
1425
282720
                        xval++;
1426
                    }
1427
                }
1428
            }
1429
        }
1430
1838
        yval++;
1431
    }
1432
37
}
1433
1434
/**************************************************************************/
1435
/*                                                                        */
1436
/*  FUNCTION                                               RELEASE        */
1437
/*                                                                        */
1438
/*    _gx_display_driver_565rgb_pixelmap_draw             PORTABLE C      */
1439
/*                                                           6.1          */
1440
/*  AUTHOR                                                                */
1441
/*                                                                        */
1442
/*    Kenneth Maxwell, Microsoft Corporation                              */
1443
/*                                                                        */
1444
/*  DESCRIPTION                                                           */
1445
/*                                                                        */
1446
/*    565rgb screen driver pixelmap drawing function that handles         */
1447
/*    compressed or uncompress, with or without alpha channel.            */
1448
/*                                                                        */
1449
/*  INPUT                                                                 */
1450
/*                                                                        */
1451
/*    context                               Drawing context               */
1452
/*    xpos                                  x-coord of top-left draw point*/
1453
/*    ypos                                  y-coord of top-left draw point*/
1454
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1455
/*                                                                        */
1456
/*  OUTPUT                                                                */
1457
/*                                                                        */
1458
/*    None                                                                */
1459
/*                                                                        */
1460
/*  CALLS                                                                 */
1461
/*                                                                        */
1462
/*     _gx_display_driver_565rgb_pixelmap_compressed_alpha_write          */
1463
/*     _gx_display_driver_565rgb_pixelmap_alpha_write                     */
1464
/*     _gx_display_driver_565rgb_pixelmap_compressed_write                */
1465
/*     _gx_display_driver_565rgb_pixelmap_raw_write                       */
1466
/*     _gx_display_driver_565rgb_palette_pixelmap_compressed_write        */
1467
/*     _gx_display_driver_565rgb_palette_pixelmap_raw_write               */
1468
/*     _gx_display_driver_16bpp_4444argb_pixelmap_raw_write               */
1469
/*     _gx_display_driver_565rgb_palette_pixelmap_transparent_compressed  */
1470
/*       _write                                                           */
1471
/*     _gx_display_driver_565rgb_palette_pixelmap_transparent_raw_write   */
1472
/*     _gx_display_driver_16bpp_4444argb_pixelmap_compressed_write        */
1473
/*     _gx_display_driver_565rgb_pixelmap_blend                           */
1474
/*                                                                        */
1475
/*  CALLED BY                                                             */
1476
/*                                                                        */
1477
/*    GUIX Internal Code                                                  */
1478
/*                                                                        */
1479
/*  RELEASE HISTORY                                                       */
1480
/*                                                                        */
1481
/*    DATE              NAME                      DESCRIPTION             */
1482
/*                                                                        */
1483
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1484
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1485
/*                                            resulting in version 6.1    */
1486
/*                                                                        */
1487
/**************************************************************************/
1488
117290
VOID _gx_display_driver_565rgb_pixelmap_draw(GX_DRAW_CONTEXT *context,
1489
                                             INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1490
{
1491
117290
GX_BOOL  drawn = GX_FALSE;
1492
117290
GX_UBYTE brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1493
1494
117290
    if (brush_alpha == 0)
1495
    {
1496
        /* Draw nothing here. Just return. */
1497
12
        return;
1498
    }
1499
1500

117278
    switch (pixelmap -> gx_pixelmap_format)
1501
    {
1502
261
    case GX_COLOR_FORMAT_8BIT_PALETTE:
1503
261
        if (pixelmap -> gx_pixelmap_aux_data == GX_NULL)
1504
        {
1505
1
            break;
1506
        }
1507
1508
260
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
1509
        {
1510
185
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1511
            {
1512
                /* compressed with */
1513
86
                _gx_display_driver_565rgb_palette_pixelmap_transparent_compressed_write(context, xpos, ypos, pixelmap);
1514
86
                drawn = GX_TRUE;
1515
            }
1516
            else
1517
            {
1518
                /* no compression */
1519
99
                if (brush_alpha == 0xff)
1520
                {
1521
97
                    _gx_display_driver_565rgb_palette_pixelmap_transparent_raw_write(context, xpos, ypos, pixelmap);
1522
97
                    drawn = GX_TRUE;
1523
                }
1524
            }
1525
        }
1526
        else
1527
        {
1528
75
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1529
            {
1530
                /* compressed with */
1531
1532
71
                _gx_display_driver_565rgb_palette_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
1533
71
                drawn = GX_TRUE;
1534
            }
1535
            else
1536
            {
1537
                /* no compression */
1538
4
                if (brush_alpha == 0xff)
1539
                {
1540
2
                    _gx_display_driver_565rgb_palette_pixelmap_raw_write(context, xpos, ypos, pixelmap);
1541
2
                    drawn = GX_TRUE;
1542
                }
1543
            }
1544
        }
1545
260
        break;
1546
1547
116555
    case GX_COLOR_FORMAT_565BGR:
1548
    case GX_COLOR_FORMAT_565RGB:
1549
116555
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1550
        {
1551
77179
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1552
            {
1553
                /* has both compression and alpha */
1554
62671
                _gx_display_driver_565rgb_pixelmap_compressed_alpha_write(context,
1555
                                                                          xpos, ypos, pixelmap);
1556
62671
                drawn = GX_TRUE;
1557
            }
1558
            else
1559
            {
1560
                /* alpha, no compression */
1561
14508
                if (brush_alpha == 0xff)
1562
                {
1563
14252
                    _gx_display_driver_565rgb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
1564
14252
                    drawn = GX_TRUE;
1565
                }
1566
            }
1567
        }
1568
        else
1569
        {
1570
39376
            if (brush_alpha == 0xff)
1571
            {
1572
39372
                if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1573
                {
1574
                    /* compressed with no alpha */
1575
23966
                    _gx_display_driver_565rgb_pixelmap_compressed_write(context,
1576
                                                                        xpos, ypos, pixelmap);
1577
                }
1578
                else
1579
                {
1580
                    /* no compression or alpha */
1581
15406
                    _gx_display_driver_565rgb_pixelmap_raw_write(context,
1582
                                                                 xpos, ypos, pixelmap);
1583
                }
1584
39372
                drawn = GX_TRUE;
1585
            }
1586
        }
1587
116555
        break;
1588
1589
60
    case GX_COLOR_FORMAT_4444ARGB:
1590
60
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1591
        {
1592
            /*not write yet*/
1593
37
            _gx_display_driver_16bpp_4444argb_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
1594
37
            drawn = GX_TRUE;
1595
        }
1596
        else
1597
        {
1598
23
            if (brush_alpha == 0xff)
1599
            {
1600
19
                _gx_display_driver_16bpp_4444argb_pixelmap_raw_write(context, xpos, ypos, pixelmap);
1601
19
                drawn = GX_TRUE;
1602
            }
1603
        }
1604
60
        break;
1605
1606
402
    default:
1607
402
        drawn = GX_TRUE;
1608
402
        break;
1609
    }
1610
1611

117278
    if ((!drawn) && (brush_alpha != 0xff))
1612
    {
1613
268
        _gx_display_driver_565rgb_pixelmap_blend(context, xpos, ypos, pixelmap, brush_alpha);
1614
    }
1615
1616
117278
    return;
1617
}
1618
1619
1620
/**************************************************************************/
1621
/*                                                                        */
1622
/*  FUNCTION                                               RELEASE        */
1623
/*                                                                        */
1624
/*    _gx_display_driver_1555xrgb_pixelmap_draw           PORTABLE C      */
1625
/*                                                           6.1          */
1626
/*  AUTHOR                                                                */
1627
/*                                                                        */
1628
/*    Kenneth Maxwell, Microsoft Corporation                              */
1629
/*                                                                        */
1630
/*  DESCRIPTION                                                           */
1631
/*                                                                        */
1632
/*    1555xrgb screen driver pixelmap drawing function that handles       */
1633
/*    compressed or uncompress, with or without alpha channel.            */
1634
/*                                                                        */
1635
/*  INPUT                                                                 */
1636
/*                                                                        */
1637
/*    context                               Drawing context               */
1638
/*    xpos                                  x-coord of top-left draw point*/
1639
/*    ypos                                  y-coord of top-left draw point*/
1640
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1641
/*                                                                        */
1642
/*  OUTPUT                                                                */
1643
/*                                                                        */
1644
/*    None                                                                */
1645
/*                                                                        */
1646
/*  CALLS                                                                 */
1647
/*                                                                        */
1648
/*     _gx_display_driver_565rgb_pixelmap_compressed_alpha_write          */
1649
/*     _gx_display_driver_565rgb_pixelmap_alpha_write                     */
1650
/*     _gx_display_driver_565rgb_pixelmap_compressed_write                */
1651
/*     _gx_display_driver_565rgb_pixelmap_raw_write                       */
1652
/*     _gx_display_driver_15555xrgb_pixelmap_blend                        */
1653
/*                                                                        */
1654
/*  CALLED BY                                                             */
1655
/*                                                                        */
1656
/*    GUIX Internal Code                                                  */
1657
/*                                                                        */
1658
/*  RELEASE HISTORY                                                       */
1659
/*                                                                        */
1660
/*    DATE              NAME                      DESCRIPTION             */
1661
/*                                                                        */
1662
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1663
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1664
/*                                            resulting in version 6.1    */
1665
/*                                                                        */
1666
/**************************************************************************/
1667
12059
VOID _gx_display_driver_1555xrgb_pixelmap_draw(GX_DRAW_CONTEXT *context,
1668
                                               INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1669
{
1670
12059
GX_BOOL  drawn = GX_FALSE;
1671
12059
GX_UBYTE brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1672
1673
12059
    if (brush_alpha == 0)
1674
    {
1675
        /* Draw nothing here. Just return. */
1676
1
        return;
1677
    }
1678
1679
12058
    switch (pixelmap -> gx_pixelmap_format)
1680
    {
1681
12057
    case GX_COLOR_FORMAT_1555XRGB:
1682
12057
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1683
        {
1684
9320
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1685
            {
1686
                /* has both compression and alpha */
1687
3695
                _gx_display_driver_565rgb_pixelmap_compressed_alpha_write(context,
1688
                                                                          xpos, ypos, pixelmap);
1689
3695
                drawn = GX_TRUE;
1690
            }
1691
            else
1692
            {
1693
                /* alpha, no compression */
1694
5625
                if (brush_alpha == 0xff)
1695
                {
1696
5624
                    _gx_display_driver_565rgb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
1697
5624
                    drawn = GX_TRUE;
1698
                }
1699
            }
1700
        }
1701
        else
1702
        {
1703
2737
            if (brush_alpha == 0xff)
1704
            {
1705
2735
                if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1706
                {
1707
                    /* compressed with no alpha */
1708
400
                    _gx_display_driver_565rgb_pixelmap_compressed_write(context,
1709
                                                                        xpos, ypos, pixelmap);
1710
                }
1711
                else
1712
                {
1713
                    /* no compression or alpha */
1714
2335
                    _gx_display_driver_565rgb_pixelmap_raw_write(context,
1715
                                                                 xpos, ypos, pixelmap);
1716
                }
1717
2735
                drawn = GX_TRUE;
1718
            }
1719
        }
1720
12057
        break;
1721
1722
1
    default:
1723
1
        return;
1724
    }
1725
1726
12057
    if (!drawn)
1727
    {
1728
3
        _gx_display_driver_1555xrgb_pixelmap_blend(context, xpos, ypos, pixelmap, brush_alpha);
1729
    }
1730
1731
12057
    return;
1732
}
1733