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

1048233
    switch (pixelmap -> gx_pixelmap_format)
1999
    {
2000
232
    case GX_COLOR_FORMAT_8BIT_PALETTE:
2001
232
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
2002
        {
2003
137
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2004
            {
2005
                /* compressed with transparent */
2006
70
                _gx_display_driver_24xrgb_palette_pixelmap_transparent_compressed_write(context, xpos, ypos, pixelmap);
2007
70
                drawn = GX_TRUE;
2008
            }
2009
            else
2010
            {
2011
                /* no compression with transparent */
2012
67
                if (brush_alpha == 0xff)
2013
                {
2014
65
                    _gx_display_driver_24xrgb_palette_pixelmap_transparent_write(context, xpos, ypos, pixelmap);
2015
65
                    drawn = GX_TRUE;
2016
                }
2017
            }
2018
        }
2019
        else
2020
        {
2021
95
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2022
            {
2023
                /* compressed with no alpha */
2024
81
                _gx_display_driver_24xrgb_palette_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2025
81
                drawn = GX_TRUE;
2026
            }
2027
            else
2028
            {
2029
                /* no compression or alpha */
2030
14
                if (brush_alpha == 0xff)
2031
                {
2032
7
                    _gx_display_driver_24xrgb_palette_pixelmap_write(context, xpos, ypos, pixelmap);
2033
7
                    drawn = GX_TRUE;
2034
                }
2035
            }
2036
        }
2037
232
        break;
2038
2039
291
    case GX_COLOR_FORMAT_4444ARGB:
2040
291
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2041
        {
2042
            /* compressed */
2043
132
            _gx_display_driver_24xrgb_4444argb_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2044
132
            drawn = GX_TRUE;
2045
        }
2046
        else
2047
        {
2048
            /* no compression  */
2049
159
            if (brush_alpha == 0xff)
2050
            {
2051
150
                _gx_display_driver_24xrgb_4444argb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2052
150
                drawn = GX_TRUE;
2053
            }
2054
        }
2055
291
        break;
2056
2057
594
    case GX_COLOR_FORMAT_565RGB:
2058
594
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
2059
        {
2060
14
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2061
            {
2062
                /* compressed with alpha */
2063
7
                _gx_display_driver_24xrgb_565rgb_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2064
7
                drawn = GX_TRUE;
2065
            }
2066
            else
2067
            {
2068
                /* uncompressed with alpha */
2069
7
                if (brush_alpha == 0xff)
2070
                {
2071
3
                    _gx_display_driver_24xrgb_565rgb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2072
3
                    drawn = GX_TRUE;
2073
                }
2074
            }
2075
        }
2076
        else
2077
        {
2078
580
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2079
            {
2080
                /* compressed without alpha */
2081
3
                _gx_display_driver_24xrgb_565rgb_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2082
3
                drawn = GX_TRUE;
2083
            }
2084
            else
2085
            {
2086
                /* uncompressed withou alpha */
2087
577
                if (brush_alpha == 0xff)
2088
                {
2089
574
                    _gx_display_driver_24xrgb_565rgb_pixelmap_raw_write(context, xpos, ypos, pixelmap);
2090
574
                    drawn = GX_TRUE;
2091
                }
2092
            }
2093
        }
2094
594
        break;
2095
2096
1047113
    case GX_COLOR_FORMAT_24XRGB:
2097
    case GX_COLOR_FORMAT_32ARGB:
2098
1047113
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
2099
        {
2100
908784
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2101
            {
2102
                /* has both compression and alpha */
2103
725712
                _gx_display_driver_24xrgb_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2104
725712
                drawn = GX_TRUE;
2105
            }
2106
            else
2107
            {
2108
                /* alpha, no compression */
2109
183072
                if (brush_alpha == 0xff)
2110
                {
2111
173100
                    _gx_display_driver_24xrgb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2112
173100
                    drawn = GX_TRUE;
2113
                }
2114
            }
2115
        }
2116
        else
2117
        {
2118
138329
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2119
            {
2120
                /* compressed with no alpha */
2121
109023
                _gx_display_driver_24xrgb_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2122
109023
                drawn = GX_TRUE;
2123
            }
2124
            else
2125
            {
2126
                /* no compression or alpha */
2127
29306
                if (brush_alpha == 0xff)
2128
                {
2129
28341
                    _gx_display_driver_24xrgb_pixelmap_raw_write(context, xpos, ypos, pixelmap);
2130
28341
                    drawn = GX_TRUE;
2131
                }
2132
            }
2133
        }
2134
1047113
        break;
2135
2136
3
    default:
2137
3
        break;
2138
    }
2139
2140

1048233
    if ((!drawn) && (brush_alpha != 0xff))
2141
    {
2142
10964
        _gx_display_driver_24xrgb_pixelmap_blend(context, xpos, ypos, pixelmap, brush_alpha);
2143
    }
2144
2145
1048233
    return;
2146
}
2147