GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_16bpp_pixelmap_draw.c Lines: 489 489 100.0 %
Date: 2026-03-06 19:21:09 Branches: 278 278 100.0 %

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

117278
    switch (pixelmap -> gx_pixelmap_format)
1390
    {
1391
261
    case GX_COLOR_FORMAT_8BIT_PALETTE:
1392
261
        if (pixelmap -> gx_pixelmap_aux_data == GX_NULL)
1393
        {
1394
1
            break;
1395
        }
1396
1397
260
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
1398
        {
1399
185
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1400
            {
1401
                /* compressed with */
1402
86
                _gx_display_driver_565rgb_palette_pixelmap_transparent_compressed_write(context, xpos, ypos, pixelmap);
1403
86
                drawn = GX_TRUE;
1404
            }
1405
            else
1406
            {
1407
                /* no compression */
1408
99
                if (brush_alpha == 0xff)
1409
                {
1410
97
                    _gx_display_driver_565rgb_palette_pixelmap_transparent_raw_write(context, xpos, ypos, pixelmap);
1411
97
                    drawn = GX_TRUE;
1412
                }
1413
            }
1414
        }
1415
        else
1416
        {
1417
75
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1418
            {
1419
                /* compressed with */
1420
1421
71
                _gx_display_driver_565rgb_palette_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
1422
71
                drawn = GX_TRUE;
1423
            }
1424
            else
1425
            {
1426
                /* no compression */
1427
4
                if (brush_alpha == 0xff)
1428
                {
1429
2
                    _gx_display_driver_565rgb_palette_pixelmap_raw_write(context, xpos, ypos, pixelmap);
1430
2
                    drawn = GX_TRUE;
1431
                }
1432
            }
1433
        }
1434
260
        break;
1435
1436
116555
    case GX_COLOR_FORMAT_565BGR:
1437
    case GX_COLOR_FORMAT_565RGB:
1438
116555
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1439
        {
1440
77179
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1441
            {
1442
                /* has both compression and alpha */
1443
62671
                _gx_display_driver_565rgb_pixelmap_compressed_alpha_write(context,
1444
                                                                          xpos, ypos, pixelmap);
1445
62671
                drawn = GX_TRUE;
1446
            }
1447
            else
1448
            {
1449
                /* alpha, no compression */
1450
14508
                if (brush_alpha == 0xff)
1451
                {
1452
14252
                    _gx_display_driver_565rgb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
1453
14252
                    drawn = GX_TRUE;
1454
                }
1455
            }
1456
        }
1457
        else
1458
        {
1459
39376
            if (brush_alpha == 0xff)
1460
            {
1461
39372
                if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1462
                {
1463
                    /* compressed with no alpha */
1464
23966
                    _gx_display_driver_565rgb_pixelmap_compressed_write(context,
1465
                                                                        xpos, ypos, pixelmap);
1466
                }
1467
                else
1468
                {
1469
                    /* no compression or alpha */
1470
15406
                    _gx_display_driver_565rgb_pixelmap_raw_write(context,
1471
                                                                 xpos, ypos, pixelmap);
1472
                }
1473
39372
                drawn = GX_TRUE;
1474
            }
1475
        }
1476
116555
        break;
1477
1478
60
    case GX_COLOR_FORMAT_4444ARGB:
1479
60
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1480
        {
1481
            /*not write yet*/
1482
37
            _gx_display_driver_16bpp_4444argb_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
1483
37
            drawn = GX_TRUE;
1484
        }
1485
        else
1486
        {
1487
23
            if (brush_alpha == 0xff)
1488
            {
1489
19
                _gx_display_driver_16bpp_4444argb_pixelmap_raw_write(context, xpos, ypos, pixelmap);
1490
19
                drawn = GX_TRUE;
1491
            }
1492
        }
1493
60
        break;
1494
1495
402
    default:
1496
402
        drawn = GX_TRUE;
1497
402
        break;
1498
    }
1499
1500

117278
    if ((!drawn) && (brush_alpha != 0xff))
1501
    {
1502
268
        _gx_display_driver_565rgb_pixelmap_blend(context, xpos, ypos, pixelmap, brush_alpha);
1503
    }
1504
1505
117278
    return;
1506
}
1507
1508
1509
/**************************************************************************/
1510
/*                                                                        */
1511
/*  FUNCTION                                               RELEASE        */
1512
/*                                                                        */
1513
/*    _gx_display_driver_1555xrgb_pixelmap_draw           PORTABLE C      */
1514
/*                                                           6.1          */
1515
/*  AUTHOR                                                                */
1516
/*                                                                        */
1517
/*    Kenneth Maxwell, Microsoft Corporation                              */
1518
/*                                                                        */
1519
/*  DESCRIPTION                                                           */
1520
/*                                                                        */
1521
/*    1555xrgb screen driver pixelmap drawing function that handles       */
1522
/*    compressed or uncompress, with or without alpha channel.            */
1523
/*                                                                        */
1524
/*  INPUT                                                                 */
1525
/*                                                                        */
1526
/*    context                               Drawing context               */
1527
/*    xpos                                  x-coord of top-left draw point*/
1528
/*    ypos                                  y-coord of top-left draw point*/
1529
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1530
/*                                                                        */
1531
/*  OUTPUT                                                                */
1532
/*                                                                        */
1533
/*    None                                                                */
1534
/*                                                                        */
1535
/*  CALLS                                                                 */
1536
/*                                                                        */
1537
/*     _gx_display_driver_565rgb_pixelmap_compressed_alpha_write          */
1538
/*     _gx_display_driver_565rgb_pixelmap_alpha_write                     */
1539
/*     _gx_display_driver_565rgb_pixelmap_compressed_write                */
1540
/*     _gx_display_driver_565rgb_pixelmap_raw_write                       */
1541
/*     _gx_display_driver_15555xrgb_pixelmap_blend                        */
1542
/*                                                                        */
1543
/*  CALLED BY                                                             */
1544
/*                                                                        */
1545
/*    GUIX Internal Code                                                  */
1546
/*                                                                        */
1547
/**************************************************************************/
1548
12059
VOID _gx_display_driver_1555xrgb_pixelmap_draw(GX_DRAW_CONTEXT *context,
1549
                                               INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1550
{
1551
12059
GX_BOOL  drawn = GX_FALSE;
1552
12059
GX_UBYTE brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1553
1554
12059
    if (brush_alpha == 0)
1555
    {
1556
        /* Draw nothing here. Just return. */
1557
1
        return;
1558
    }
1559
1560
12058
    switch (pixelmap -> gx_pixelmap_format)
1561
    {
1562
12057
    case GX_COLOR_FORMAT_1555XRGB:
1563
12057
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1564
        {
1565
9320
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1566
            {
1567
                /* has both compression and alpha */
1568
3695
                _gx_display_driver_565rgb_pixelmap_compressed_alpha_write(context,
1569
                                                                          xpos, ypos, pixelmap);
1570
3695
                drawn = GX_TRUE;
1571
            }
1572
            else
1573
            {
1574
                /* alpha, no compression */
1575
5625
                if (brush_alpha == 0xff)
1576
                {
1577
5624
                    _gx_display_driver_565rgb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
1578
5624
                    drawn = GX_TRUE;
1579
                }
1580
            }
1581
        }
1582
        else
1583
        {
1584
2737
            if (brush_alpha == 0xff)
1585
            {
1586
2735
                if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1587
                {
1588
                    /* compressed with no alpha */
1589
400
                    _gx_display_driver_565rgb_pixelmap_compressed_write(context,
1590
                                                                        xpos, ypos, pixelmap);
1591
                }
1592
                else
1593
                {
1594
                    /* no compression or alpha */
1595
2335
                    _gx_display_driver_565rgb_pixelmap_raw_write(context,
1596
                                                                 xpos, ypos, pixelmap);
1597
                }
1598
2735
                drawn = GX_TRUE;
1599
            }
1600
        }
1601
12057
        break;
1602
1603
1
    default:
1604
1
        return;
1605
    }
1606
1607
12057
    if (!drawn)
1608
    {
1609
3
        _gx_display_driver_1555xrgb_pixelmap_blend(context, xpos, ypos, pixelmap, brush_alpha);
1610
    }
1611
1612
12057
    return;
1613
}
1614