GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_4444argb_horizontal_pixelmap_line_draw.c Lines: 251 251 100.0 %
Date: 2024-12-05 08:52:37 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
#if defined(GX_ARC_DRAWING_SUPPORT)
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
/*  RELEASE HISTORY                                                       */
71
/*                                                                        */
72
/*    DATE              NAME                      DESCRIPTION             */
73
/*                                                                        */
74
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
75
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
76
/*                                            resulting in version 6.1    */
77
/*                                                                        */
78
/**************************************************************************/
79
1986
static VOID _gx_display_driver_4444argb_horizontal_pixelmap_line_alpha_blend(GX_DRAW_CONTEXT *context,
80
                                                                             INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
81
{
82
INT              xval;
83
INT              offset;
84
INT              pic_width;
85
USHORT           color;
86
GX_CONST USHORT *get;
87
GX_PIXELMAP     *pixelmap;
88
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
89
90
1986
    pixelmap = info -> pixelmap;
91
1986
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
92
93
1986
    if (blend_func == GX_NULL)
94
    {
95
857
        return;
96
    }
97
1129
    pic_width = pixelmap -> gx_pixelmap_width;
98
99

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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