GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_4444argb_horizontal_pixelmap_line_draw.c Lines: 251 251 100.0 %
Date: 2025-09-29 22:21:50 Branches: 182 182 100.0 %

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

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

1124
    if ((info -> draw) && (xstart <= xend))
196
    {
197
        /* calculate the offset. */
198
877
        offset = (info -> x_offset % pic_width);
199
200
118031
        for (xval = xstart; xval <= xend; xval++)
201
        {
202
            /*get points to the start postion of this row. So we need to calculate its position.*/
203
117154
            blend_func(context, xval, y, *(get + offset), alpha);
204
205
117154
            offset++;
206
117154
            if (offset >= pic_width)
207
            {
208
426
                offset -= pic_width;
209
            }
210
        }
211
    }
212
213
    /*This line is drawn. Update the pointer position for next row.*/
214
1124
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
215
}
216
217
/**************************************************************************/
218
/*                                                                        */
219
/*  FUNCTION                                               RELEASE        */
220
/*                                                                        */
221
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_    */
222
/*    alpha_blend                                                         */
223
/*                                                        PORTABLE C      */
224
/*                                                           6.1          */
225
/*  AUTHOR                                                                */
226
/*                                                                        */
227
/*    Kenneth Maxwell, Microsoft Corporation                              */
228
/*                                                                        */
229
/*  DESCRIPTION                                                           */
230
/*                                                                        */
231
/*    Internal helper function that handles writing of compressed         */
232
/*    pixlemap file with alpha channel.                                   */
233
/*                                                                        */
234
/*  INPUT                                                                 */
235
/*                                                                        */
236
/*    context                               Drawing context               */
237
/*    xstart                                x-coord of line left          */
238
/*    xend                                  x-coord of line end           */
239
/*    y                                     y-coord of line top           */
240
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
241
/*    alpha                                 Alpha value                   */
242
/*                                                                        */
243
/*  OUTPUT                                                                */
244
/*                                                                        */
245
/*    None                                                                */
246
/*                                                                        */
247
/*  CALLS                                                                 */
248
/*                                                                        */
249
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
250
/*                                            blend function              */
251
/*                                                                        */
252
/*  CALLED BY                                                             */
253
/*                                                                        */
254
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
255
/*                                                                        */
256
/*  RELEASE HISTORY                                                       */
257
/*                                                                        */
258
/*    DATE              NAME                      DESCRIPTION             */
259
/*                                                                        */
260
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
261
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
262
/*                                            resulting in version 6.1    */
263
/*                                                                        */
264
/**************************************************************************/
265
1796
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_alpha_blend(GX_DRAW_CONTEXT *context,
266
                                                                                        INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
267
{
268
INT              start_pos;
269
INT              xval;
270
USHORT           count;
271
USHORT           pixel;
272
1796
GX_CONST USHORT *get = GX_NULL;
273
GX_PIXELMAP     *pixelmap;
274
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
275
276
1796
    pixelmap = info -> pixelmap;
277
1796
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
278
279
1796
    if (blend_func == GX_NULL)
280
    {
281
724
        return;
282
    }
283
284

1072
    if ((info -> draw) && (xstart <= xend))
285
    {
286
        /* Calculate draw start position. */
287
710
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
288
289
        /* Repeat the draw operation to fill the whole dirty area. */
290
8370
        while (start_pos <= xend)
291
        {
292
7660
            xval = start_pos;
293
            /*Start from where we need to repeat.*/
294
7660
            get = (GX_CONST USHORT *)info -> current_pixel_ptr;
295
296
30556
            while (xval < start_pos + pixelmap -> gx_pixelmap_width)
297
            {
298
22896
                count = *get++;
299
22896
                if (count & 0x8000)
300
                {
301
9746
                    count = (USHORT)((count & 0x7fff) + 1);
302
9746
                    pixel = *get++;
303
9746
                    if (pixel & 0xf000)
304
                    {
305
56975
                        while (count--)
306
                        {
307

51115
                            if (xval >= xstart && xval <= xend)
308
                            {
309
43400
                                blend_func(context, xval, y, pixel, alpha);
310
                            }
311
51115
                            xval++;
312
                        }
313
                    }
314
                    else
315
                    {
316
3886
                        xval += count;
317
                    }
318
                }
319
                else
320
                {
321
13150
                    count++;
322
78596
                    while (count--)
323
                    {
324
65446
                        pixel = *get++;
325

65446
                        if (xval >= xstart && xval <= xend)
326
                        {
327
57896
                            if (pixel & 0xf000)
328
                            {
329
51331
                                blend_func(context, xval, y, pixel, alpha);
330
                            }
331
                        }
332
65446
                        xval++;
333
                    }
334
                }
335
            }
336
7660
            start_pos += pixelmap -> gx_pixelmap_width;
337
        }
338
    }
339
    else
340
    {
341
362
        xval = 0;
342
362
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
343
6917
        while (xval < pixelmap -> gx_pixelmap_width)
344
        {
345
6555
            count = *get++;
346
6555
            if (count & 0x8000)
347
            {
348
3878
                count = (USHORT)((count & 0x7fff) + 1);
349
3878
                get++;      /* skip repeated pixel value */
350
            }
351
            else
352
            {
353
2677
                count++;
354
2677
                get += count;   /* skip raw pixel values */
355
            }
356
6555
            xval += count;
357
        }
358
    }
359
360
    /*This line is drawn. cache the pointer for next line draw.*/
361
1072
    info -> current_pixel_ptr = (GX_UBYTE *)get;
362
}
363
364
/**************************************************************************/
365
/*                                                                        */
366
/*  FUNCTION                                               RELEASE        */
367
/*                                                                        */
368
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_c_blend        */
369
/*                                                        PORTABLE C      */
370
/*                                                           6.1          */
371
/*  AUTHOR                                                                */
372
/*                                                                        */
373
/*    Kenneth Maxwell, Microsoft Corporation                              */
374
/*                                                                        */
375
/*  DESCRIPTION                                                           */
376
/*                                                                        */
377
/*    Internal helper function that handles writing of compressed         */
378
/*    pixlemap file with alpha whose value is always 0xf.                 */
379
/*                                                                        */
380
/*  INPUT                                                                 */
381
/*                                                                        */
382
/*    context                               Drawing context               */
383
/*    xstart                                x-coord of line left          */
384
/*    xend                                  x-coord of line end           */
385
/*    y                                     y-coord of line top           */
386
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
387
/*    alpha                                 Alpha value                   */
388
/*                                                                        */
389
/*  OUTPUT                                                                */
390
/*                                                                        */
391
/*    None                                                                */
392
/*                                                                        */
393
/*  CALLS                                                                 */
394
/*                                                                        */
395
/*    None                                                                */
396
/*                                                                        */
397
/*  CALLED BY                                                             */
398
/*                                                                        */
399
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
400
/*                                            blend function              */
401
/*                                                                        */
402
/*  CALLED BY                                                             */
403
/*                                                                        */
404
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
405
/*                                                                        */
406
/*  RELEASE HISTORY                                                       */
407
/*                                                                        */
408
/*    DATE              NAME                      DESCRIPTION             */
409
/*                                                                        */
410
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
411
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
412
/*                                            resulting in version 6.1    */
413
/*                                                                        */
414
/**************************************************************************/
415
1490
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_blend(GX_DRAW_CONTEXT *context,
416
                                                                                  INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
417
{
418
INT              start_pos;
419
INT              xval;
420
USHORT           count;
421
USHORT           pixel;
422
1490
GX_CONST USHORT *get = GX_NULL;
423
GX_PIXELMAP     *pixelmap;
424
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
425
426
1490
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
427
1490
    pixelmap = info -> pixelmap;
428
1490
    if (blend_func == GX_NULL)
429
    {
430
728
        return;
431
    }
432
433

762
    if ((info -> draw) && (xstart <= xend))
434
    {
435
        /* Calculate draw start position. */
436
682
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
437
438
        /* Repeat the draw operation to fill the whole dirty area. */
439
7607
        while (start_pos <= xend)
440
        {
441
6925
            xval = start_pos;
442
            /*Start from where we need to repeat.*/
443
6925
            get = (GX_CONST USHORT *)info -> current_pixel_ptr;
444
445
22073
            while (xval < start_pos + pixelmap -> gx_pixelmap_width)
446
            {
447
15148
                count = *get++;
448
15148
                if (count & 0x8000)
449
                {
450
5872
                    count = (USHORT)((count & 0x7fff) + 1);
451
5872
                    pixel = *get++;
452
56818
                    while (count--)
453
                    {
454

50946
                        if (xval >= xstart && xval <= xend)
455
                        {
456
43068
                            blend_func(context, xval, y, pixel, alpha);
457
                        }
458
50946
                        xval++;
459
                    }
460
                }
461
                else
462
                {
463
9276
                    count++;
464
87516
                    while (count--)
465
                    {
466
78240
                        pixel = *get++;
467

78240
                        if (xval >= xstart && xval <= xend)
468
                        {
469
71578
                            blend_func(context, xval, y, pixel, alpha);
470
                        }
471
78240
                        xval++;
472
                    }
473
                }
474
            }
475
6925
            start_pos += pixelmap -> gx_pixelmap_width;
476
        }
477
    }
478
    else
479
    {
480
80
        xval = 0;
481
80
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
482
264
        while (xval < pixelmap -> gx_pixelmap_width)
483
        {
484
184
            count = *get++;
485
184
            if (count & 0x8000)
486
            {
487
78
                count = (USHORT)((count & 0x7fff) + 1);
488
78
                get++;      /* skip repeated pixel value */
489
            }
490
            else
491
            {
492
106
                count++;
493
106
                get += count;   /* skip raw pixel values */
494
            }
495
184
            xval += count;
496
        }
497
    }
498
499
    /* This line is drawn. cache the pointer for next line draw. */
500
762
    info -> current_pixel_ptr = (GX_UBYTE *)get;
501
}
502
503
#endif /* GX_BRUSH_ALPHA_SUPPORT */
504
/**************************************************************************/
505
/*                                                                        */
506
/*  FUNCTION                                               RELEASE        */
507
/*                                                                        */
508
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_write    */
509
/*                                                        PORTABLE C      */
510
/*                                                           6.1          */
511
/*  AUTHOR                                                                */
512
/*                                                                        */
513
/*    Kenneth Maxwell, Microsoft Corporation                              */
514
/*                                                                        */
515
/*  DESCRIPTION                                                           */
516
/*                                                                        */
517
/*    Internal helper function that handles writing of uncompressed       */
518
/*    pixlemap file with alpha channel.                                   */
519
/*                                                                        */
520
/*  INPUT                                                                 */
521
/*                                                                        */
522
/*    context                               Drawing context               */
523
/*    xstart                                x-coord of line left          */
524
/*    xend                                  x-coord of line end           */
525
/*    y                                     y-coord of line top           */
526
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
527
/*                                                                        */
528
/*  OUTPUT                                                                */
529
/*                                                                        */
530
/*    None                                                                */
531
/*                                                                        */
532
/*  CALLS                                                                 */
533
/*                                                                        */
534
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
535
/*                                            blend function              */
536
/*                                                                        */
537
/*  CALLED BY                                                             */
538
/*                                                                        */
539
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
540
/*                                                                        */
541
/*  RELEASE HISTORY                                                       */
542
/*                                                                        */
543
/*    DATE              NAME                      DESCRIPTION             */
544
/*                                                                        */
545
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
546
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
547
/*                                            resulting in version 6.1    */
548
/*                                                                        */
549
/**************************************************************************/
550
1986
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_write(GX_DRAW_CONTEXT *context,
551
                                                                             INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
552
{
553
INT              xval;
554
INT              offset;
555
INT              pic_width;
556
USHORT           color;
557
GX_CONST USHORT *get;
558
GX_PIXELMAP     *pixelmap;
559
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
560
561
1986
    pixelmap = info -> pixelmap;
562
1986
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
563
564
1986
    if (blend_func == GX_NULL)
565
    {
566
857
        return;
567
    }
568
1129
    pic_width = pixelmap -> gx_pixelmap_width;
569
570

1129
    if ((info -> draw) && (xstart <= xend))
571
    {
572
907
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
573
574
        /* calculate the offset. */
575
907
        offset = (info -> x_offset % pic_width);
576
577
119376
        for (xval = xstart; xval <= xend; xval++)
578
        {
579
            /* get points to the start postion of this row. So we need to calculate its position. */
580
118469
            color = *(get + offset);
581
118469
            offset++;
582
583
118469
            if (color & 0xf000)
584
            {
585
                /* not transparent */
586
82173
                blend_func(context, xval, y, color, 0xff);
587
            }
588
589
118469
            if (offset >= pic_width)
590
            {
591
593
                offset -= pic_width;
592
            }
593
        }
594
    }
595
596
    /* This line is drawn. Update the pointer position for next row. */
597
1129
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
598
}
599
600
/**************************************************************************/
601
/*                                                                        */
602
/*  FUNCTION                                               RELEASE        */
603
/*                                                                        */
604
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_raw_write      */
605
/*                                                        PORTABLE C      */
606
/*                                                           6.1          */
607
/*  AUTHOR                                                                */
608
/*                                                                        */
609
/*    Kenneth Maxwell, Microsoft Corporation                              */
610
/*                                                                        */
611
/*  DESCRIPTION                                                           */
612
/*                                                                        */
613
/*    Internal helper function that handles writing of uncompressed       */
614
/*    pixlemap file with alpha whose value is always 0xf.                 */
615
/*                                                                        */
616
/*  INPUT                                                                 */
617
/*                                                                        */
618
/*    context                               Drawing context               */
619
/*    xstart                                x-coord of line left          */
620
/*    xend                                  x-coord of line end           */
621
/*    y                                     y-coord of line top           */
622
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
623
/*                                                                        */
624
/*  OUTPUT                                                                */
625
/*                                                                        */
626
/*    None                                                                */
627
/*                                                                        */
628
/*  CALLS                                                                 */
629
/*                                                                        */
630
/*    None                                                                */
631
/*                                                                        */
632
/*  CALLED BY                                                             */
633
/*                                                                        */
634
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
635
/*                                                                        */
636
/*  RELEASE HISTORY                                                       */
637
/*                                                                        */
638
/*    DATE              NAME                      DESCRIPTION             */
639
/*                                                                        */
640
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
641
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
642
/*                                            resulting in version 6.1    */
643
/*                                                                        */
644
/**************************************************************************/
645
1996
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_raw_write(GX_DRAW_CONTEXT *context,
646
                                                                           INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
647
{
648
INT              xval;
649
INT              offset;
650
INT              pic_width;
651
GX_CONST USHORT *get;
652
USHORT          *put;
653
GX_PIXELMAP     *pixelmap;
654
655
1996
    pixelmap = info -> pixelmap;
656
657
1996
    pic_width = pixelmap -> gx_pixelmap_width;
658
1996
    get = (GX_CONST USHORT *)info -> current_pixel_ptr;
659
660

1996
    if ((info -> draw) && (xstart <= xend))
661
    {
662
1531
        put = (USHORT *)context -> gx_draw_context_memory;
663
1531
        put += y * context -> gx_draw_context_pitch;
664
1531
        put += xstart;
665
666
        /* calculate the offset. */
667
1531
        offset = (info -> x_offset % pic_width);
668
669
233212
        for (xval = xstart; xval <= xend; xval++)
670
        {
671
            /* get points to the start postion of this row. So we need to calculate its position. */
672
231681
            *put++ = *(get + offset);
673
231681
            offset++;
674
231681
            if (offset >= pic_width)
675
            {
676
833
                offset -= pic_width;
677
            }
678
        }
679
    }
680
681
    /* This line is drawn. Update the pointer position for next row. */
682
1996
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
683
1996
}
684
685
/**************************************************************************/
686
/*                                                                        */
687
/*  FUNCTION                                               RELEASE        */
688
/*                                                                        */
689
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_c_a_write      */
690
/*                                                        PORTABLE C      */
691
/*                                                           6.1          */
692
/*  AUTHOR                                                                */
693
/*                                                                        */
694
/*    Kenneth Maxwell, Microsoft Corporation                              */
695
/*                                                                        */
696
/*  DESCRIPTION                                                           */
697
/*                                                                        */
698
/*    Internal helper function that handles writing of compressed         */
699
/*    pixlemap file with alpha channel.                                   */
700
/*                                                                        */
701
/*  INPUT                                                                 */
702
/*                                                                        */
703
/*    context                               Drawing context               */
704
/*    xstart                                x-coord of line left          */
705
/*    xend                                  x-coord of line end           */
706
/*    y                                     y-coord of line top           */
707
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
708
/*                                                                        */
709
/*  OUTPUT                                                                */
710
/*                                                                        */
711
/*    None                                                                */
712
/*                                                                        */
713
/*  CALLS                                                                 */
714
/*                                                                        */
715
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
716
/*                                            blend function              */
717
/*                                                                        */
718
/*  CALLED BY                                                             */
719
/*                                                                        */
720
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
721
/*                                                                        */
722
/*  RELEASE HISTORY                                                       */
723
/*                                                                        */
724
/*    DATE              NAME                      DESCRIPTION             */
725
/*                                                                        */
726
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
727
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
728
/*                                            resulting in version 6.1    */
729
/*                                                                        */
730
/**************************************************************************/
731
1796
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_alpha_write(GX_DRAW_CONTEXT *context,
732
                                                                                        INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
733
{
734
INT              start_pos;
735
INT              xval;
736
USHORT           count;
737
USHORT           pixel;
738
1796
GX_CONST USHORT *get = GX_NULL;
739
GX_PIXELMAP     *pixelmap;
740
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
741
742
1796
    pixelmap = info -> pixelmap;
743
1796
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
744
745
1796
    if (blend_func == GX_NULL)
746
    {
747
724
        return;
748
    }
749
750

1072
    if ((info -> draw) && (xstart <= xend))
751
    {
752
        /* Calculate draw start position. */
753
710
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
754
755
        /* Repeat the draw operation to fill the whole dirty area. */
756
8370
        while (start_pos <= xend)
757
        {
758
7660
            xval = start_pos;
759
            /*Start from where we need to repeat.*/
760
7660
            get = (GX_CONST USHORT *)info -> current_pixel_ptr;
761
762
30556
            while (xval < start_pos + pixelmap -> gx_pixelmap_width)
763
            {
764
22896
                count = *get++;
765
22896
                if (count & 0x8000)
766
                {
767
9746
                    count = (USHORT)((count & 0x7fff) + 1);
768
9746
                    pixel = *get++;
769
9746
                    if (pixel & 0xf000)
770
                    {
771
56975
                        while (count--)
772
                        {
773

51115
                            if (xval >= xstart && xval <= xend)
774
                            {
775
43400
                                blend_func(context, xval, y, pixel, 0xff);
776
                            }
777
51115
                            xval++;
778
                        }
779
                    }
780
                    else
781
                    {
782
3886
                        xval += count;
783
                    }
784
                }
785
                else
786
                {
787
13150
                    count++;
788
78596
                    while (count--)
789
                    {
790
65446
                        pixel = *get++;
791

65446
                        if (xval >= xstart && xval <= xend)
792
                        {
793
57896
                            if (pixel & 0xf000)
794
                            {
795
51331
                                blend_func(context, xval, y, pixel, 0xff);
796
                            }
797
                        }
798
65446
                        xval++;
799
                    }
800
                }
801
            }
802
7660
            start_pos += pixelmap -> gx_pixelmap_width;
803
        }
804
    }
805
    else
806
    {
807
362
        xval = 0;
808
362
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
809
6917
        while (xval < pixelmap -> gx_pixelmap_width)
810
        {
811
6555
            count = *get++;
812
6555
            if (count & 0x8000)
813
            {
814
3878
                count = (USHORT)((count & 0x7fff) + 1);
815
3878
                get++;      /* skip repeated pixel value */
816
            }
817
            else
818
            {
819
2677
                count++;
820
2677
                get += count;   /* skip raw pixel values */
821
            }
822
6555
            xval += count;
823
        }
824
    }
825
826
    /* This line is drawn. cache the pointer for next line draw. */
827
1072
    info -> current_pixel_ptr = (GX_UBYTE *)get;
828
}
829
830
/**************************************************************************/
831
/*                                                                        */
832
/*  FUNCTION                                               RELEASE        */
833
/*                                                                        */
834
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_c_write        */
835
/*                                                        PORTABLE C      */
836
/*                                                           6.1          */
837
/*  AUTHOR                                                                */
838
/*                                                                        */
839
/*    Kenneth Maxwell, Microsoft Corporation                              */
840
/*                                                                        */
841
/*  DESCRIPTION                                                           */
842
/*                                                                        */
843
/*    Internal helper function that handles writing of compressed         */
844
/*    pixlemap file with alpha whose value is always 0xf.                 */
845
/*                                                                        */
846
/*  INPUT                                                                 */
847
/*                                                                        */
848
/*    context                               Drawing context               */
849
/*    xstart                                x-coord of line left          */
850
/*    xend                                  x-coord of line end           */
851
/*    y                                     y-coord of line top           */
852
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
853
/*                                                                        */
854
/*  OUTPUT                                                                */
855
/*                                                                        */
856
/*    None                                                                */
857
/*                                                                        */
858
/*  CALLS                                                                 */
859
/*                                                                        */
860
/*    None                                                                */
861
/*                                                                        */
862
/*  CALLED BY                                                             */
863
/*                                                                        */
864
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
865
/*                                                                        */
866
/*  RELEASE HISTORY                                                       */
867
/*                                                                        */
868
/*    DATE              NAME                      DESCRIPTION             */
869
/*                                                                        */
870
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
871
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
872
/*                                            resulting in version 6.1    */
873
/*                                                                        */
874
/**************************************************************************/
875
1490
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_write(GX_DRAW_CONTEXT *context,
876
                                                                                  INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
877
{
878
INT              start_pos;
879
INT              xval;
880
USHORT           count;
881
USHORT           pixel;
882
1490
GX_CONST USHORT *get = GX_NULL;
883
USHORT          *put;
884
GX_PIXELMAP     *pixelmap;
885
886
1490
    pixelmap = info -> pixelmap;
887
888

1490
    if ((info -> draw) && (xstart <= xend))
889
    {
890
        /* Calculate draw start position. */
891
1336
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
892
893
1336
        put = (USHORT *)context -> gx_draw_context_memory;
894
1336
        put += y * context -> gx_draw_context_pitch + start_pos;
895
896
        /* Repeat the draw operation to fill the whole dirty area. */
897
15158
        while (start_pos <= xend)
898
        {
899
13822
            xval = start_pos;
900
901
            /* Start from where we need to repeat. */
902
13822
            get = (GX_CONST USHORT *)info -> current_pixel_ptr;
903
904
43913
            while (xval < start_pos + pixelmap -> gx_pixelmap_width)
905
            {
906
30091
                count = *get++;
907
30091
                if (count & 0x8000)
908
                {
909
11614
                    count = (USHORT)((count & 0x7fff) + 1);
910
11614
                    pixel = *get++;
911
108878
                    while (count--)
912
                    {
913

97264
                        if (xval >= xstart && xval <= xend)
914
                        {
915
86017
                            *put = pixel;
916
                        }
917
97264
                        xval++;
918
97264
                        put++;
919
                    }
920
                }
921
                else
922
                {
923
18477
                    count++;
924
174545
                    while (count--)
925
                    {
926
156068
                        pixel = *get++;
927

156068
                        if (xval >= xstart && xval <= xend)
928
                        {
929
143156
                            *put = pixel;
930
                        }
931
156068
                        xval++;
932
156068
                        put++;
933
                    }
934
                }
935
            }
936
13822
            start_pos += pixelmap -> gx_pixelmap_width;
937
        }
938
    }
939
    else
940
    {
941
154
        xval = 0;
942
154
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
943
496
        while (xval < pixelmap -> gx_pixelmap_width)
944
        {
945
342
            count = *get++;
946
342
            if (count & 0x8000)
947
            {
948
138
                count = (USHORT)((count & 0x7fff) + 1);
949
138
                get++;      /* skip repeated pixel value */
950
            }
951
            else
952
            {
953
204
                count++;
954
204
                get += count;   /* skip raw pixel values */
955
            }
956
342
            xval += count;
957
        }
958
    }
959
960
    /* This line is drawn. cache the pointer for next line draw. */
961
1490
    info -> current_pixel_ptr = (GX_UBYTE *)get;
962
1490
}
963
964
/**************************************************************************/
965
/*                                                                        */
966
/*  FUNCTION                                               RELEASE        */
967
/*                                                                        */
968
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_draw           */
969
/*                                                        PORTABLE C      */
970
/*                                                           6.1          */
971
/*  AUTHOR                                                                */
972
/*                                                                        */
973
/*    Kenneth Maxwell, Microsoft Corporation                              */
974
/*                                                                        */
975
/*  DESCRIPTION                                                           */
976
/*                                                                        */
977
/*    565rgb screen driver pixelmap drawing function that handles         */
978
/*    compressed or uncompress, with or without alpha channel.            */
979
/*                                                                        */
980
/*  INPUT                                                                 */
981
/*                                                                        */
982
/*    context                               Drawing context               */
983
/*    xstart                                x-coord of line left          */
984
/*    xend                                  x-coord of line end           */
985
/*    y                                     y-coord of line top           */
986
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
987
/*                                                                        */
988
/*  OUTPUT                                                                */
989
/*                                                                        */
990
/*    None                                                                */
991
/*                                                                        */
992
/*  CALLS                                                                 */
993
/*                                                                        */
994
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_c_a_blend      */
995
/*                                          Real display driver pixelmap  */
996
/*                                            line draw function          */
997
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_blend    */
998
/*                                          Real display driver pixelmap  */
999
/*                                            line draw function          */
1000
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_c_blend        */
1001
/*                                          Real display driver pixelmap  */
1002
/*                                            line draw function          */
1003
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_raw_blend      */
1004
/*                                          Real display driver pixelmap  */
1005
/*                                            line draw function          */
1006
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_c_a_write      */
1007
/*                                          Real display driver pixelmap  */
1008
/*                                            line draw function          */
1009
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_write    */
1010
/*                                          Real display driver pixelmap  */
1011
/*                                            line draw function          */
1012
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_c_write        */
1013
/*                                          Real display driver pixelmap  */
1014
/*                                            line draw function          */
1015
/*    _gx_display_driver_4444argb_horizontal_pixelmap_line_raw_write      */
1016
/*                                          Real display driver pixelmap  */
1017
/*                                            line draw function          */
1018
/*                                                                        */
1019
/*  CALLED BY                                                             */
1020
/*                                                                        */
1021
/*    GUIX Internal Code                                                  */
1022
/*                                                                        */
1023
/*  RELEASE HISTORY                                                       */
1024
/*                                                                        */
1025
/*    DATE              NAME                      DESCRIPTION             */
1026
/*                                                                        */
1027
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
1028
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
1029
/*                                            resulting in version 6.1    */
1030
/*                                                                        */
1031
/**************************************************************************/
1032
15443
VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_draw(GX_DRAW_CONTEXT *context,
1033
                                                               INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
1034
{
1035
#if defined GX_BRUSH_ALPHA_SUPPORT
1036
GX_UBYTE alpha;
1037
1038
15443
    alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1039

15443
    if ((alpha == 0) || (info -> pixelmap == GX_NULL))
1040
    {
1041
        /* Nothing to drawn. Just return. */
1042
907
        return;
1043
    }
1044
14536
    if (alpha != 0xff)
1045
    {
1046
1047
7268
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1048
        {
1049
3782
            if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1050
            {
1051
                /* has both compression and alpha */
1052
1796
                _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_alpha_blend(context, xstart, xend, y, info, alpha);
1053
            }
1054
            else
1055
            {
1056
                /* alpha, no compression */
1057
1986
                _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_blend(context, xstart, xend, y, info, alpha);
1058
            }
1059
        }
1060
        else
1061
        {
1062
3486
            if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1063
            {
1064
                /* compressed with no alpha */
1065
1490
                _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_blend(context, xstart, xend, y, info, alpha);
1066
            }
1067
            else
1068
            {
1069
                /* no compression or alpha */
1070
1996
                _gx_display_driver_4444argb_horizontal_pixelmap_line_raw_blend(context, xstart, xend, y, info, alpha);
1071
            }
1072
        }
1073
1074
        /*Current pixelmap has gone over, so the offset pointer should be reset.*/
1075
7268
        if (info -> current_pixel_ptr >= info -> pixelmap -> gx_pixelmap_data + info -> pixelmap -> gx_pixelmap_data_size)
1076
        {
1077
95
            info -> current_pixel_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_data;
1078
95
            info -> current_aux_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_aux_data;
1079
        }
1080
7268
        return;
1081
    }
1082
#endif
1083
1084
7268
    if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1085
    {
1086
3782
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1087
        {
1088
            /* has both compression and alpha */
1089
1796
            _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_alpha_write(context, xstart, xend, y, info);
1090
        }
1091
        else
1092
        {
1093
            /* alpha, no compression */
1094
1986
            _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_write(context, xstart, xend, y, info);
1095
        }
1096
    }
1097
    else
1098
    {
1099
3486
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1100
        {
1101
            /* has both compression */
1102
1490
            _gx_display_driver_4444argb_horizontal_pixelmap_line_compressed_write(context, xstart, xend, y, info);
1103
        }
1104
        else
1105
        {
1106
            /*no alpha, no compression */
1107
1996
            _gx_display_driver_4444argb_horizontal_pixelmap_line_raw_write(context, xstart, xend, y, info);
1108
        }
1109
    }
1110
1111
    /*Current pixelmap has gone over, so the offset pointer should be reset.*/
1112
7268
    if (info -> current_pixel_ptr >= info -> pixelmap -> gx_pixelmap_data + info -> pixelmap -> gx_pixelmap_data_size)
1113
    {
1114
139
        info -> current_pixel_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_data;
1115
139
        info -> current_aux_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_aux_data;
1116
    }
1117
}