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

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Display Management (Display)                                        */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_display.h"
29
#include "gx_context.h"
30
31
#if defined(GX_BRUSH_ALPHA_SUPPORT)
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_blend    */
37
/*                                                        PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    Internal helper function that handles writing of uncompressed       */
46
/*    pixlemap file with alpha channel with brush alpha.                  */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    context                               Drawing context               */
51
/*    xstart                                x-coord of line left          */
52
/*    xend                                  x-coord of line right         */
53
/*    y                                     y-coord of line top           */
54
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
55
/*    alpha                                 Alpha value                   */
56
/*                                                                        */
57
/*  OUTPUT                                                                */
58
/*                                                                        */
59
/*    None                                                                */
60
/*                                                                        */
61
/*  CALLS                                                                 */
62
/*                                                                        */
63
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
64
/*                                            blend function              */
65
/*                                                                        */
66
/*  CALLED BY                                                             */
67
/*                                                                        */
68
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
69
/*                                                                        */
70
/**************************************************************************/
71
1986
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_blend(GX_DRAW_CONTEXT *context,
72
                                                                             INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
73
{
74
INT              xval;
75
INT              offset;
76
INT              pic_width;
77
USHORT           color;
78
GX_CONST USHORT *get;
79
GX_PIXELMAP     *pixelmap;
80
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
81
82
1986
    pixelmap = info -> pixelmap;
83
1986
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
84
85
1986
    if (blend_func == GX_NULL)
86
    {
87
857
        return;
88
    }
89
1129
    pic_width = pixelmap -> gx_pixelmap_width;
90
91

1129
    if ((info -> draw) && (xstart <= xend))
92
    {
93
907
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
94
95
        /*calculate the offset.*/
96
907
        offset = (info -> x_offset % pic_width);
97
98
119376
        for (xval = xstart; xval <= xend; xval++)
99
        {
100
            /*get points to the start postion of this row. So we need to calculate its position.*/
101
118469
            color = *(get + offset);
102
118469
            offset++;
103
118469
            if (color & 0xf000)
104
            {
105
                /* not transparent */
106
82173
                blend_func(context, xval, y, color, alpha);
107
            }
108
109
118469
            if (offset >= pic_width)
110
            {
111
593
                offset -= pic_width;
112
            }
113
        }
114
    }
115
116
    /*This line is drawn. Update the pointer position for next row.*/
117
1129
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
118
}
119
120
/**************************************************************************/
121
/*                                                                        */
122
/*  FUNCTION                                               RELEASE        */
123
/*                                                                        */
124
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_raw_blend      */
125
/*                                                        PORTABLE C      */
126
/*                                                           6.1          */
127
/*  AUTHOR                                                                */
128
/*                                                                        */
129
/*    Kenneth Maxwell, Microsoft Corporation                              */
130
/*                                                                        */
131
/*  DESCRIPTION                                                           */
132
/*                                                                        */
133
/*    Internal helper function that handles writing of uncompressed       */
134
/*    pixlemap file with alpha whose value is always 0xf.                 */
135
/*                                                                        */
136
/*  INPUT                                                                 */
137
/*                                                                        */
138
/*    context                               Drawing context               */
139
/*    xstart                                x-coord of line left          */
140
/*    xend                                  x-coord of line end           */
141
/*    y                                     y-coord of line top           */
142
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
143
/*    alpha                                 Alpha value                   */
144
/*                                                                        */
145
/*  OUTPUT                                                                */
146
/*                                                                        */
147
/*    None                                                                */
148
/*                                                                        */
149
/*  CALLS                                                                 */
150
/*                                                                        */
151
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
152
/*                                            blend function              */
153
/*                                                                        */
154
/*  CALLED BY                                                             */
155
/*                                                                        */
156
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
157
/*                                                                        */
158
/**************************************************************************/
159
1996
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_raw_blend(GX_DRAW_CONTEXT *context,
160
                                                                           INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
161
{
162
INT              xval;
163
INT              offset;
164
INT              pic_width;
165
GX_CONST USHORT *get;
166
GX_PIXELMAP     *pixelmap;
167
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
168
169
1996
    pixelmap = info -> pixelmap;
170
1996
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
171
172
1996
    if (blend_func == GX_NULL)
173
    {
174
872
        return;
175
    }
176
177
1124
    pic_width = pixelmap -> gx_pixelmap_width;
178
1124
    get = (GX_CONST USHORT *)info -> current_pixel_ptr;
179
180

1124
    if ((info -> draw) && (xstart <= xend))
181
    {
182
        /* calculate the offset. */
183
877
        offset = (info -> x_offset % pic_width);
184
185
118031
        for (xval = xstart; xval <= xend; xval++)
186
        {
187
            /*get points to the start postion of this row. So we need to calculate its position.*/
188
117154
            blend_func(context, xval, y, *(get + offset), alpha);
189
190
117154
            offset++;
191
117154
            if (offset >= pic_width)
192
            {
193
426
                offset -= pic_width;
194
            }
195
        }
196
    }
197
198
    /*This line is drawn. Update the pointer position for next row.*/
199
1124
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
200
}
201
202
/**************************************************************************/
203
/*                                                                        */
204
/*  FUNCTION                                               RELEASE        */
205
/*                                                                        */
206
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_    */
207
/*    alpha_blend                                                         */
208
/*                                                        PORTABLE C      */
209
/*                                                           6.1          */
210
/*  AUTHOR                                                                */
211
/*                                                                        */
212
/*    Kenneth Maxwell, Microsoft Corporation                              */
213
/*                                                                        */
214
/*  DESCRIPTION                                                           */
215
/*                                                                        */
216
/*    Internal helper function that handles writing of compressed         */
217
/*    pixlemap file with alpha channel.                                   */
218
/*                                                                        */
219
/*  INPUT                                                                 */
220
/*                                                                        */
221
/*    context                               Drawing context               */
222
/*    xstart                                x-coord of line left          */
223
/*    xend                                  x-coord of line end           */
224
/*    y                                     y-coord of line top           */
225
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
226
/*    alpha                                 Alpha value                   */
227
/*                                                                        */
228
/*  OUTPUT                                                                */
229
/*                                                                        */
230
/*    None                                                                */
231
/*                                                                        */
232
/*  CALLS                                                                 */
233
/*                                                                        */
234
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
235
/*                                            blend function              */
236
/*                                                                        */
237
/*  CALLED BY                                                             */
238
/*                                                                        */
239
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
240
/*                                                                        */
241
/**************************************************************************/
242
1796
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_alpha_blend(GX_DRAW_CONTEXT *context,
243
                                                                                        INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
244
{
245
INT              start_pos;
246
INT              xval;
247
USHORT           count;
248
USHORT           pixel;
249
1796
GX_CONST USHORT *get = GX_NULL;
250
GX_PIXELMAP     *pixelmap;
251
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
252
253
1796
    pixelmap = info -> pixelmap;
254
1796
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
255
256
1796
    if (blend_func == GX_NULL)
257
    {
258
724
        return;
259
    }
260
261

1072
    if ((info -> draw) && (xstart <= xend))
262
    {
263
        /* Calculate draw start position. */
264
710
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
265
266
        /* Repeat the draw operation to fill the whole dirty area. */
267
8370
        while (start_pos <= xend)
268
        {
269
7660
            xval = start_pos;
270
            /*Start from where we need to repeat.*/
271
7660
            get = (GX_CONST USHORT *)info -> current_pixel_ptr;
272
273
30556
            while (xval < start_pos + pixelmap -> gx_pixelmap_width)
274
            {
275
22896
                count = *get++;
276
22896
                if (count & 0x8000)
277
                {
278
9746
                    count = (USHORT)((count & 0x7fff) + 1);
279
9746
                    pixel = *get++;
280
9746
                    if (pixel & 0xf000)
281
                    {
282
56975
                        while (count--)
283
                        {
284

51115
                            if (xval >= xstart && xval <= xend)
285
                            {
286
43400
                                blend_func(context, xval, y, pixel, alpha);
287
                            }
288
51115
                            xval++;
289
                        }
290
                    }
291
                    else
292
                    {
293
3886
                        xval += count;
294
                    }
295
                }
296
                else
297
                {
298
13150
                    count++;
299
78596
                    while (count--)
300
                    {
301
65446
                        pixel = *get++;
302

65446
                        if (xval >= xstart && xval <= xend)
303
                        {
304
57896
                            if (pixel & 0xf000)
305
                            {
306
51331
                                blend_func(context, xval, y, pixel, alpha);
307
                            }
308
                        }
309
65446
                        xval++;
310
                    }
311
                }
312
            }
313
7660
            start_pos += pixelmap -> gx_pixelmap_width;
314
        }
315
    }
316
    else
317
    {
318
362
        xval = 0;
319
362
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
320
6917
        while (xval < pixelmap -> gx_pixelmap_width)
321
        {
322
6555
            count = *get++;
323
6555
            if (count & 0x8000)
324
            {
325
3878
                count = (USHORT)((count & 0x7fff) + 1);
326
3878
                get++;      /* skip repeated pixel value */
327
            }
328
            else
329
            {
330
2677
                count++;
331
2677
                get += count;   /* skip raw pixel values */
332
            }
333
6555
            xval += count;
334
        }
335
    }
336
337
    /*This line is drawn. cache the pointer for next line draw.*/
338
1072
    info -> current_pixel_ptr = (GX_UBYTE *)get;
339
}
340
341
/**************************************************************************/
342
/*                                                                        */
343
/*  FUNCTION                                               RELEASE        */
344
/*                                                                        */
345
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_c_blend        */
346
/*                                                        PORTABLE C      */
347
/*                                                           6.1          */
348
/*  AUTHOR                                                                */
349
/*                                                                        */
350
/*    Kenneth Maxwell, Microsoft Corporation                              */
351
/*                                                                        */
352
/*  DESCRIPTION                                                           */
353
/*                                                                        */
354
/*    Internal helper function that handles writing of compressed         */
355
/*    pixlemap file with alpha whose value is always 0xf.                 */
356
/*                                                                        */
357
/*  INPUT                                                                 */
358
/*                                                                        */
359
/*    context                               Drawing context               */
360
/*    xstart                                x-coord of line left          */
361
/*    xend                                  x-coord of line end           */
362
/*    y                                     y-coord of line top           */
363
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
364
/*    alpha                                 Alpha value                   */
365
/*                                                                        */
366
/*  OUTPUT                                                                */
367
/*                                                                        */
368
/*    None                                                                */
369
/*                                                                        */
370
/*  CALLS                                                                 */
371
/*                                                                        */
372
/*    None                                                                */
373
/*                                                                        */
374
/*  CALLED BY                                                             */
375
/*                                                                        */
376
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
377
/*                                            blend function              */
378
/*                                                                        */
379
/*  CALLED BY                                                             */
380
/*                                                                        */
381
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
382
/*                                                                        */
383
/**************************************************************************/
384
1490
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_blend(GX_DRAW_CONTEXT *context,
385
                                                                                  INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
386
{
387
INT              start_pos;
388
INT              xval;
389
USHORT           count;
390
USHORT           pixel;
391
1490
GX_CONST USHORT *get = GX_NULL;
392
GX_PIXELMAP     *pixelmap;
393
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
394
395
1490
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
396
1490
    pixelmap = info -> pixelmap;
397
1490
    if (blend_func == GX_NULL)
398
    {
399
728
        return;
400
    }
401
402

762
    if ((info -> draw) && (xstart <= xend))
403
    {
404
        /* Calculate draw start position. */
405
682
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
406
407
        /* Repeat the draw operation to fill the whole dirty area. */
408
7607
        while (start_pos <= xend)
409
        {
410
6925
            xval = start_pos;
411
            /*Start from where we need to repeat.*/
412
6925
            get = (GX_CONST USHORT *)info -> current_pixel_ptr;
413
414
22073
            while (xval < start_pos + pixelmap -> gx_pixelmap_width)
415
            {
416
15148
                count = *get++;
417
15148
                if (count & 0x8000)
418
                {
419
5872
                    count = (USHORT)((count & 0x7fff) + 1);
420
5872
                    pixel = *get++;
421
56818
                    while (count--)
422
                    {
423

50946
                        if (xval >= xstart && xval <= xend)
424
                        {
425
43068
                            blend_func(context, xval, y, pixel, alpha);
426
                        }
427
50946
                        xval++;
428
                    }
429
                }
430
                else
431
                {
432
9276
                    count++;
433
87516
                    while (count--)
434
                    {
435
78240
                        pixel = *get++;
436

78240
                        if (xval >= xstart && xval <= xend)
437
                        {
438
71578
                            blend_func(context, xval, y, pixel, alpha);
439
                        }
440
78240
                        xval++;
441
                    }
442
                }
443
            }
444
6925
            start_pos += pixelmap -> gx_pixelmap_width;
445
        }
446
    }
447
    else
448
    {
449
80
        xval = 0;
450
80
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
451
264
        while (xval < pixelmap -> gx_pixelmap_width)
452
        {
453
184
            count = *get++;
454
184
            if (count & 0x8000)
455
            {
456
78
                count = (USHORT)((count & 0x7fff) + 1);
457
78
                get++;      /* skip repeated pixel value */
458
            }
459
            else
460
            {
461
106
                count++;
462
106
                get += count;   /* skip raw pixel values */
463
            }
464
184
            xval += count;
465
        }
466
    }
467
468
    /* This line is drawn. cache the pointer for next line draw. */
469
762
    info -> current_pixel_ptr = (GX_UBYTE *)get;
470
}
471
472
#endif /* GX_BRUSH_ALPHA_SUPPORT */
473
/**************************************************************************/
474
/*                                                                        */
475
/*  FUNCTION                                               RELEASE        */
476
/*                                                                        */
477
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_write    */
478
/*                                                        PORTABLE C      */
479
/*                                                           6.1          */
480
/*  AUTHOR                                                                */
481
/*                                                                        */
482
/*    Kenneth Maxwell, Microsoft Corporation                              */
483
/*                                                                        */
484
/*  DESCRIPTION                                                           */
485
/*                                                                        */
486
/*    Internal helper function that handles writing of uncompressed       */
487
/*    pixlemap file with alpha channel.                                   */
488
/*                                                                        */
489
/*  INPUT                                                                 */
490
/*                                                                        */
491
/*    context                               Drawing context               */
492
/*    xstart                                x-coord of line left          */
493
/*    xend                                  x-coord of line end           */
494
/*    y                                     y-coord of line top           */
495
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
496
/*                                                                        */
497
/*  OUTPUT                                                                */
498
/*                                                                        */
499
/*    None                                                                */
500
/*                                                                        */
501
/*  CALLS                                                                 */
502
/*                                                                        */
503
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
504
/*                                            blend function              */
505
/*                                                                        */
506
/*  CALLED BY                                                             */
507
/*                                                                        */
508
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
509
/*                                                                        */
510
/**************************************************************************/
511
1986
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_write(GX_DRAW_CONTEXT *context,
512
                                                                             INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
513
{
514
INT              xval;
515
INT              offset;
516
INT              pic_width;
517
USHORT           color;
518
GX_CONST USHORT *get;
519
GX_PIXELMAP     *pixelmap;
520
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
521
522
1986
    pixelmap = info -> pixelmap;
523
1986
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
524
525
1986
    if (blend_func == GX_NULL)
526
    {
527
857
        return;
528
    }
529
1129
    pic_width = pixelmap -> gx_pixelmap_width;
530
531

1129
    if ((info -> draw) && (xstart <= xend))
532
    {
533
907
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
534
535
        /* calculate the offset. */
536
907
        offset = (info -> x_offset % pic_width);
537
538
119376
        for (xval = xstart; xval <= xend; xval++)
539
        {
540
            /* get points to the start postion of this row. So we need to calculate its position. */
541
118469
            color = *(get + offset);
542
118469
            offset++;
543
544
118469
            if (color & 0xf000)
545
            {
546
                /* not transparent */
547
82173
                blend_func(context, xval, y, color, 0xff);
548
            }
549
550
118469
            if (offset >= pic_width)
551
            {
552
593
                offset -= pic_width;
553
            }
554
        }
555
    }
556
557
    /* This line is drawn. Update the pointer position for next row. */
558
1129
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
559
}
560
561
/**************************************************************************/
562
/*                                                                        */
563
/*  FUNCTION                                               RELEASE        */
564
/*                                                                        */
565
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_raw_write      */
566
/*                                                        PORTABLE C      */
567
/*                                                           6.1          */
568
/*  AUTHOR                                                                */
569
/*                                                                        */
570
/*    Kenneth Maxwell, Microsoft Corporation                              */
571
/*                                                                        */
572
/*  DESCRIPTION                                                           */
573
/*                                                                        */
574
/*    Internal helper function that handles writing of uncompressed       */
575
/*    pixlemap file with alpha whose value is always 0xf.                 */
576
/*                                                                        */
577
/*  INPUT                                                                 */
578
/*                                                                        */
579
/*    context                               Drawing context               */
580
/*    xstart                                x-coord of line left          */
581
/*    xend                                  x-coord of line end           */
582
/*    y                                     y-coord of line top           */
583
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
584
/*                                                                        */
585
/*  OUTPUT                                                                */
586
/*                                                                        */
587
/*    None                                                                */
588
/*                                                                        */
589
/*  CALLS                                                                 */
590
/*                                                                        */
591
/*    None                                                                */
592
/*                                                                        */
593
/*  CALLED BY                                                             */
594
/*                                                                        */
595
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
596
/*                                                                        */
597
/**************************************************************************/
598
1996
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_raw_write(GX_DRAW_CONTEXT *context,
599
                                                                           INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
600
{
601
INT              xval;
602
INT              offset;
603
INT              pic_width;
604
GX_CONST USHORT *get;
605
USHORT          *put;
606
GX_PIXELMAP     *pixelmap;
607
608
1996
    pixelmap = info -> pixelmap;
609
610
1996
    pic_width = pixelmap -> gx_pixelmap_width;
611
1996
    get = (GX_CONST USHORT *)info -> current_pixel_ptr;
612
613

1996
    if ((info -> draw) && (xstart <= xend))
614
    {
615
1531
        put = (USHORT *)context -> gx_draw_context_memory;
616
1531
        put += y * context -> gx_draw_context_pitch;
617
1531
        put += xstart;
618
619
        /* calculate the offset. */
620
1531
        offset = (info -> x_offset % pic_width);
621
622
233212
        for (xval = xstart; xval <= xend; xval++)
623
        {
624
            /* get points to the start postion of this row. So we need to calculate its position. */
625
231681
            *put++ = *(get + offset);
626
231681
            offset++;
627
231681
            if (offset >= pic_width)
628
            {
629
833
                offset -= pic_width;
630
            }
631
        }
632
    }
633
634
    /* This line is drawn. Update the pointer position for next row. */
635
1996
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
636
1996
}
637
638
/**************************************************************************/
639
/*                                                                        */
640
/*  FUNCTION                                               RELEASE        */
641
/*                                                                        */
642
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_c_a_write      */
643
/*                                                        PORTABLE C      */
644
/*                                                           6.1          */
645
/*  AUTHOR                                                                */
646
/*                                                                        */
647
/*    Kenneth Maxwell, Microsoft Corporation                              */
648
/*                                                                        */
649
/*  DESCRIPTION                                                           */
650
/*                                                                        */
651
/*    Internal helper function that handles writing of compressed         */
652
/*    pixlemap file with alpha channel.                                   */
653
/*                                                                        */
654
/*  INPUT                                                                 */
655
/*                                                                        */
656
/*    context                               Drawing context               */
657
/*    xstart                                x-coord of line left          */
658
/*    xend                                  x-coord of line end           */
659
/*    y                                     y-coord of line top           */
660
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
661
/*                                                                        */
662
/*  OUTPUT                                                                */
663
/*                                                                        */
664
/*    None                                                                */
665
/*                                                                        */
666
/*  CALLS                                                                 */
667
/*                                                                        */
668
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
669
/*                                            blend function              */
670
/*                                                                        */
671
/*  CALLED BY                                                             */
672
/*                                                                        */
673
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
674
/*                                                                        */
675
/**************************************************************************/
676
1796
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_alpha_write(GX_DRAW_CONTEXT *context,
677
                                                                                        INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
678
{
679
INT              start_pos;
680
INT              xval;
681
USHORT           count;
682
USHORT           pixel;
683
1796
GX_CONST USHORT *get = GX_NULL;
684
GX_PIXELMAP     *pixelmap;
685
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
686
687
1796
    pixelmap = info -> pixelmap;
688
1796
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
689
690
1796
    if (blend_func == GX_NULL)
691
    {
692
724
        return;
693
    }
694
695

1072
    if ((info -> draw) && (xstart <= xend))
696
    {
697
        /* Calculate draw start position. */
698
710
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
699
700
        /* Repeat the draw operation to fill the whole dirty area. */
701
8370
        while (start_pos <= xend)
702
        {
703
7660
            xval = start_pos;
704
            /*Start from where we need to repeat.*/
705
7660
            get = (GX_CONST USHORT *)info -> current_pixel_ptr;
706
707
30556
            while (xval < start_pos + pixelmap -> gx_pixelmap_width)
708
            {
709
22896
                count = *get++;
710
22896
                if (count & 0x8000)
711
                {
712
9746
                    count = (USHORT)((count & 0x7fff) + 1);
713
9746
                    pixel = *get++;
714
9746
                    if (pixel & 0xf000)
715
                    {
716
56975
                        while (count--)
717
                        {
718

51115
                            if (xval >= xstart && xval <= xend)
719
                            {
720
43400
                                blend_func(context, xval, y, pixel, 0xff);
721
                            }
722
51115
                            xval++;
723
                        }
724
                    }
725
                    else
726
                    {
727
3886
                        xval += count;
728
                    }
729
                }
730
                else
731
                {
732
13150
                    count++;
733
78596
                    while (count--)
734
                    {
735
65446
                        pixel = *get++;
736

65446
                        if (xval >= xstart && xval <= xend)
737
                        {
738
57896
                            if (pixel & 0xf000)
739
                            {
740
51331
                                blend_func(context, xval, y, pixel, 0xff);
741
                            }
742
                        }
743
65446
                        xval++;
744
                    }
745
                }
746
            }
747
7660
            start_pos += pixelmap -> gx_pixelmap_width;
748
        }
749
    }
750
    else
751
    {
752
362
        xval = 0;
753
362
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
754
6917
        while (xval < pixelmap -> gx_pixelmap_width)
755
        {
756
6555
            count = *get++;
757
6555
            if (count & 0x8000)
758
            {
759
3878
                count = (USHORT)((count & 0x7fff) + 1);
760
3878
                get++;      /* skip repeated pixel value */
761
            }
762
            else
763
            {
764
2677
                count++;
765
2677
                get += count;   /* skip raw pixel values */
766
            }
767
6555
            xval += count;
768
        }
769
    }
770
771
    /* This line is drawn. cache the pointer for next line draw. */
772
1072
    info -> current_pixel_ptr = (GX_UBYTE *)get;
773
}
774
775
/**************************************************************************/
776
/*                                                                        */
777
/*  FUNCTION                                               RELEASE        */
778
/*                                                                        */
779
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_c_write        */
780
/*                                                        PORTABLE C      */
781
/*                                                           6.1          */
782
/*  AUTHOR                                                                */
783
/*                                                                        */
784
/*    Kenneth Maxwell, Microsoft Corporation                              */
785
/*                                                                        */
786
/*  DESCRIPTION                                                           */
787
/*                                                                        */
788
/*    Internal helper function that handles writing of compressed         */
789
/*    pixlemap file with alpha whose value is always 0xf.                 */
790
/*                                                                        */
791
/*  INPUT                                                                 */
792
/*                                                                        */
793
/*    context                               Drawing context               */
794
/*    xstart                                x-coord of line left          */
795
/*    xend                                  x-coord of line end           */
796
/*    y                                     y-coord of line top           */
797
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
798
/*                                                                        */
799
/*  OUTPUT                                                                */
800
/*                                                                        */
801
/*    None                                                                */
802
/*                                                                        */
803
/*  CALLS                                                                 */
804
/*                                                                        */
805
/*    None                                                                */
806
/*                                                                        */
807
/*  CALLED BY                                                             */
808
/*                                                                        */
809
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
810
/*                                                                        */
811
/**************************************************************************/
812
1490
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_write(GX_DRAW_CONTEXT *context,
813
                                                                                  INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
814
{
815
INT              start_pos;
816
INT              xval;
817
USHORT           count;
818
USHORT           pixel;
819
1490
GX_CONST USHORT *get = GX_NULL;
820
USHORT          *put;
821
GX_PIXELMAP     *pixelmap;
822
823
1490
    pixelmap = info -> pixelmap;
824
825

1490
    if ((info -> draw) && (xstart <= xend))
826
    {
827
        /* Calculate draw start position. */
828
1336
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
829
830
1336
        put = (USHORT *)context -> gx_draw_context_memory;
831
1336
        put += y * context -> gx_draw_context_pitch + start_pos;
832
833
        /* Repeat the draw operation to fill the whole dirty area. */
834
15158
        while (start_pos <= xend)
835
        {
836
13822
            xval = start_pos;
837
838
            /* Start from where we need to repeat. */
839
13822
            get = (GX_CONST USHORT *)info -> current_pixel_ptr;
840
841
43913
            while (xval < start_pos + pixelmap -> gx_pixelmap_width)
842
            {
843
30091
                count = *get++;
844
30091
                if (count & 0x8000)
845
                {
846
11614
                    count = (USHORT)((count & 0x7fff) + 1);
847
11614
                    pixel = *get++;
848
108878
                    while (count--)
849
                    {
850

97264
                        if (xval >= xstart && xval <= xend)
851
                        {
852
86017
                            *put = pixel;
853
                        }
854
97264
                        xval++;
855
97264
                        put++;
856
                    }
857
                }
858
                else
859
                {
860
18477
                    count++;
861
174545
                    while (count--)
862
                    {
863
156068
                        pixel = *get++;
864

156068
                        if (xval >= xstart && xval <= xend)
865
                        {
866
143156
                            *put = pixel;
867
                        }
868
156068
                        xval++;
869
156068
                        put++;
870
                    }
871
                }
872
            }
873
13822
            start_pos += pixelmap -> gx_pixelmap_width;
874
        }
875
    }
876
    else
877
    {
878
154
        xval = 0;
879
154
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
880
496
        while (xval < pixelmap -> gx_pixelmap_width)
881
        {
882
342
            count = *get++;
883
342
            if (count & 0x8000)
884
            {
885
138
                count = (USHORT)((count & 0x7fff) + 1);
886
138
                get++;      /* skip repeated pixel value */
887
            }
888
            else
889
            {
890
204
                count++;
891
204
                get += count;   /* skip raw pixel values */
892
            }
893
342
            xval += count;
894
        }
895
    }
896
897
    /* This line is drawn. cache the pointer for next line draw. */
898
1490
    info -> current_pixel_ptr = (GX_UBYTE *)get;
899
1490
}
900
901
/**************************************************************************/
902
/*                                                                        */
903
/*  FUNCTION                                               RELEASE        */
904
/*                                                                        */
905
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
906
/*                                                        PORTABLE C      */
907
/*                                                           6.1          */
908
/*  AUTHOR                                                                */
909
/*                                                                        */
910
/*    Kenneth Maxwell, Microsoft Corporation                              */
911
/*                                                                        */
912
/*  DESCRIPTION                                                           */
913
/*                                                                        */
914
/*    565rgb screen driver pixelmap drawing function that handles         */
915
/*    compressed or uncompress, with or without alpha channel.            */
916
/*                                                                        */
917
/*  INPUT                                                                 */
918
/*                                                                        */
919
/*    context                               Drawing context               */
920
/*    xstart                                x-coord of line left          */
921
/*    xend                                  x-coord of line end           */
922
/*    y                                     y-coord of line top           */
923
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
924
/*                                                                        */
925
/*  OUTPUT                                                                */
926
/*                                                                        */
927
/*    None                                                                */
928
/*                                                                        */
929
/*  CALLS                                                                 */
930
/*                                                                        */
931
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_c_a_blend      */
932
/*                                          Real display driver pixelmap  */
933
/*                                            line draw function          */
934
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_blend    */
935
/*                                          Real display driver pixelmap  */
936
/*                                            line draw function          */
937
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_c_blend        */
938
/*                                          Real display driver pixelmap  */
939
/*                                            line draw function          */
940
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_raw_blend      */
941
/*                                          Real display driver pixelmap  */
942
/*                                            line draw function          */
943
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_c_a_write      */
944
/*                                          Real display driver pixelmap  */
945
/*                                            line draw function          */
946
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_write    */
947
/*                                          Real display driver pixelmap  */
948
/*                                            line draw function          */
949
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_c_write        */
950
/*                                          Real display driver pixelmap  */
951
/*                                            line draw function          */
952
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_raw_write      */
953
/*                                          Real display driver pixelmap  */
954
/*                                            line draw function          */
955
/*                                                                        */
956
/*  CALLED BY                                                             */
957
/*                                                                        */
958
/*    GUIX Internal Code                                                  */
959
/*                                                                        */
960
/**************************************************************************/
961
15443
VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_draw(GX_DRAW_CONTEXT *context,
962
                                                               INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
963
{
964
#if defined GX_BRUSH_ALPHA_SUPPORT
965
GX_UBYTE alpha;
966
967
15443
    alpha = context -> gx_draw_context_brush.gx_brush_alpha;
968

15443
    if ((alpha == 0) || (info -> pixelmap == GX_NULL))
969
    {
970
        /* Nothing to drawn. Just return. */
971
907
        return;
972
    }
973
14536
    if (alpha != 0xff)
974
    {
975
976
7268
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
977
        {
978
3782
            if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
979
            {
980
                /* has both compression and alpha */
981
1796
                _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_alpha_blend(context, xstart, xend, y, info, alpha);
982
            }
983
            else
984
            {
985
                /* alpha, no compression */
986
1986
                _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_blend(context, xstart, xend, y, info, alpha);
987
            }
988
        }
989
        else
990
        {
991
3486
            if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
992
            {
993
                /* compressed with no alpha */
994
1490
                _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_blend(context, xstart, xend, y, info, alpha);
995
            }
996
            else
997
            {
998
                /* no compression or alpha */
999
1996
                _gx_display_driver_4444argb_horizontal_pixelmap_line_raw_blend(context, xstart, xend, y, info, alpha);
1000
            }
1001
        }
1002
1003
        /*Current pixelmap has gone over, so the offset pointer should be reset.*/
1004
7268
        if (info -> current_pixel_ptr >= info -> pixelmap -> gx_pixelmap_data + info -> pixelmap -> gx_pixelmap_data_size)
1005
        {
1006
95
            info -> current_pixel_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_data;
1007
95
            info -> current_aux_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_aux_data;
1008
        }
1009
7268
        return;
1010
    }
1011
#endif
1012
1013
7268
    if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1014
    {
1015
3782
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1016
        {
1017
            /* has both compression and alpha */
1018
1796
            _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_alpha_write(context, xstart, xend, y, info);
1019
        }
1020
        else
1021
        {
1022
            /* alpha, no compression */
1023
1986
            _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_write(context, xstart, xend, y, info);
1024
        }
1025
    }
1026
    else
1027
    {
1028
3486
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1029
        {
1030
            /* has both compression */
1031
1490
            _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_write(context, xstart, xend, y, info);
1032
        }
1033
        else
1034
        {
1035
            /*no alpha, no compression */
1036
1996
            _gx_display_driver_4444argb_horizontal_pixelmap_line_raw_write(context, xstart, xend, y, info);
1037
        }
1038
    }
1039
1040
    /*Current pixelmap has gone over, so the offset pointer should be reset.*/
1041
7268
    if (info -> current_pixel_ptr >= info -> pixelmap -> gx_pixelmap_data + info -> pixelmap -> gx_pixelmap_data_size)
1042
    {
1043
139
        info -> current_pixel_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_data;
1044
139
        info -> current_aux_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_aux_data;
1045
    }
1046
}