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

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

3075
    if ((info -> draw) && (xstart <= xend))
97
    {
98
        /* Calculate the map offset in x-axis. */
99
2081
        offset = (info -> x_offset % pic_width);
100
101
227461
        for (xval = xstart; xval <= xend; xval++)
102
        {
103
225380
            pixel = *(get + offset);
104
225380
            blend_func(context, xval, y, pixel, alpha);
105
225380
            offset++;
106
107
225380
            if (offset >= pic_width)
108
            {
109
6519
                offset -= pic_width;
110
            }
111
        }
112
    }
113
114
    /* Update data pointer for next row.*/
115
3075
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
116
}
117
118
/**************************************************************************/
119
/*                                                                        */
120
/*  FUNCTION                                               RELEASE        */
121
/*                                                                        */
122
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_alpha_blend      */
123
/*                                                        PORTABLE C      */
124
/*                                                           6.1          */
125
/*  AUTHOR                                                                */
126
/*                                                                        */
127
/*    Kenneth Maxwell, Microsoft Corporation                              */
128
/*                                                                        */
129
/*  DESCRIPTION                                                           */
130
/*                                                                        */
131
/*    Internal helper function that handles writing of uncompressed       */
132
/*    pixlemap file with alpha channel with brush alpha.                  */
133
/*                                                                        */
134
/*  INPUT                                                                 */
135
/*                                                                        */
136
/*    context                               Drawing context               */
137
/*    xstart                                x-coord of line left          */
138
/*    xend                                  x-coord of line end           */
139
/*    y                                     y-coord of line top           */
140
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
141
/*    alpha                                 Alpha value                   */
142
/*                                                                        */
143
/*  OUTPUT                                                                */
144
/*                                                                        */
145
/*    None                                                                */
146
/*                                                                        */
147
/*  CALLS                                                                 */
148
/*                                                                        */
149
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
150
/*                                            blend function              */
151
/*                                                                        */
152
/*  CALLED BY                                                             */
153
/*                                                                        */
154
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
155
/*                                                                        */
156
/**************************************************************************/
157
3728
static VOID _gx_display_driver_565rgb_horizontal_pixelmap_line_alpha_blend(GX_DRAW_CONTEXT *context,
158
                                                                           INT xstart, INT xend, INT y,
159
                                                                           GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
160
{
161
INT                xval;
162
GX_CONST USHORT   *get;
163
GX_CONST GX_UBYTE *getalpha;
164
USHORT             color;
165
GX_UBYTE           falpha;
166
GX_UBYTE           combined_alpha;
167
GX_PIXELMAP       *pixelmap;
168
INT                pic_width;
169
INT                offset;
170
VOID               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
171
172
3728
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
173
3728
    if (blend_func == GX_NULL)
174
    {
175
857
        return;
176
    }
177
178
2871
    pixelmap = info -> pixelmap;
179
2871
    pic_width = pixelmap -> gx_pixelmap_width;
180
181

2871
    if ((info -> draw) && (xstart <= xend))
182
    {
183
        /* Pick the data pointer to the current row. */
184
2068
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
185
2068
        getalpha = (GX_CONST GX_UBYTE *)info -> current_aux_ptr;
186
187
        /* Calculate the map offset in x-axis. */
188
2068
        offset = (info -> x_offset % pic_width);
189
190
225596
        for (xval = xstart; xval <= xend; xval++)
191
        {
192
223528
            color = *(get + offset);
193
223528
            falpha = *(getalpha + offset);
194
195
223528
            if (falpha)
196
            {
197
123452
                combined_alpha = (GX_UBYTE)(falpha * alpha / 255);
198
199
123452
                blend_func(context, xval, y, color, combined_alpha);
200
            }
201
202
223528
            offset++;
203
223528
            if (offset >= pic_width)
204
            {
205
3276
                offset -= pic_width;
206
            }
207
        }
208
    }
209
210
    /* Update data pointers for next row. */
211
2871
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
212
2871
    info -> current_aux_ptr += (UINT)pic_width * sizeof(GX_UBYTE);
213
}
214
215
216
/**************************************************************************/
217
/*                                                                        */
218
/*  FUNCTION                                               RELEASE        */
219
/*                                                                        */
220
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_compressed_blend */
221
/*                                                        PORTABLE C      */
222
/*                                                           6.1          */
223
/*  AUTHOR                                                                */
224
/*                                                                        */
225
/*    Kenneth Maxwell, Microsoft Corporation                              */
226
/*                                                                        */
227
/*  DESCRIPTION                                                           */
228
/*                                                                        */
229
/*    Internal helper function that handles writing of compressed         */
230
/*    pixlemap file without alpha channel with brush_alpha.               */
231
/*                                                                        */
232
/*  INPUT                                                                 */
233
/*                                                                        */
234
/*    context                               Drawing context               */
235
/*    xstart                                x-coord of line left          */
236
/*    xend                                  x-coord of line end           */
237
/*    y                                     y-coord of line top           */
238
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
239
/*    alpha                                 Alpha value                   */
240
/*                                                                        */
241
/*  OUTPUT                                                                */
242
/*                                                                        */
243
/*    None                                                                */
244
/*                                                                        */
245
/*  CALLS                                                                 */
246
/*                                                                        */
247
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
248
/*                                            blend function              */
249
/*                                                                        */
250
/*  CALLED BY                                                             */
251
/*                                                                        */
252
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
253
/*                                                                        */
254
/**************************************************************************/
255
4919
static VOID _gx_display_driver_565rgb_horizontal_pixelmap_line_compressed_blend(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
256
{
257
INT              start_pos;
258
INT              xval;
259
USHORT           count;
260
USHORT           pixel;
261
4919
GX_CONST USHORT *get = GX_NULL;
262
GX_PIXELMAP     *pixelmap;
263
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
264
265
4919
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
266
4919
    pixelmap = info -> pixelmap;
267
4919
    if (blend_func == GX_NULL)
268
    {
269
1124
        return;
270
    }
271
272

3795
    if ((info -> draw) && (xstart <= xend))
273
    {
274
        /* Calculate draw start position. */
275
2057
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
276
277
4428
        while (start_pos <= xend)
278
        {
279
2371
            xval = start_pos;
280
281
            /*Start from where we need to repeat.*/
282
2371
            get = (GX_CONST USHORT *)info -> current_pixel_ptr;
283
284
70129
            while (xval < start_pos + pixelmap -> gx_pixelmap_width)
285
            {
286
67758
                count = *get++;
287
67758
                if (count & 0x8000)
288
                {
289
36698
                    count = (USHORT)((count & 0x7fff) + 1);
290
36698
                    pixel = *get++;
291
283557
                    while (count--)
292
                    {
293

246859
                        if (xval >= xstart && xval <= xend)
294
                        {
295
61415
                            blend_func(context, xval, y, pixel, alpha);
296
                        }
297
246859
                        xval++;
298
                    }
299
                }
300
                else
301
                {
302
31060
                    count++;
303
696498
                    while (count--)
304
                    {
305
665438
                        pixel = *get++;
306

665438
                        if (xval >= xstart && xval <= xend)
307
                        {
308
160198
                            blend_func(context, xval, y, pixel, alpha);
309
                        }
310
665438
                        xval++;
311
                    }
312
                }
313
            }
314
2371
            start_pos += pixelmap -> gx_pixelmap_width;
315
        }
316
    }
317
    else
318
    {
319
1738
        xval = 0;
320
1738
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
321
42192
        while (xval < pixelmap -> gx_pixelmap_width)
322
        {
323
40454
            count = *get++;
324
40454
            if (count & 0x8000)
325
            {
326
21565
                count = (USHORT)((count & 0x7fff) + 1);
327
21565
                get++;
328
            }
329
            else
330
            {
331
18889
                count++;
332
18889
                get += count;
333
            }
334
40454
            xval += count;
335
        }
336
    }
337
338
    /* Update data pointer for next row. */
339
3795
    info -> current_pixel_ptr = (GX_UBYTE *)get;
340
}
341
342
/**************************************************************************/
343
/*                                                                        */
344
/*  FUNCTION                                               RELEASE        */
345
/*                                                                        */
346
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_c_a_blend        */
347
/*                                                        PORTABLE C      */
348
/*                                                           6.1          */
349
/*  AUTHOR                                                                */
350
/*                                                                        */
351
/*    Kenneth Maxwell, Microsoft Corporation                              */
352
/*                                                                        */
353
/*  DESCRIPTION                                                           */
354
/*                                                                        */
355
/*    Internal helper function that handles writing of compressed         */
356
/*    pixlemap file with alpha channel with brush alpha.                  */
357
/*                                                                        */
358
/*  INPUT                                                                 */
359
/*                                                                        */
360
/*    context                               Drawing context               */
361
/*    xstart                                x-coord of line left          */
362
/*    xend                                  x-coord of line end           */
363
/*    y                                     y-coord of line top           */
364
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
365
/*    alpha                                 Alpha value                   */
366
/*                                                                        */
367
/*  OUTPUT                                                                */
368
/*                                                                        */
369
/*    None                                                                */
370
/*                                                                        */
371
/*  CALLS                                                                 */
372
/*                                                                        */
373
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
374
/*                                            blend function              */
375
/*                                                                        */
376
/*  CALLED BY                                                             */
377
/*                                                                        */
378
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
379
/*                                                                        */
380
/**************************************************************************/
381
4092
static VOID _gx_display_driver_565rgb_horizontal_pixelmap_line_compressed_alpha_blend(GX_DRAW_CONTEXT *context,
382
                                                                                      INT xstart, INT xend, INT y,
383
                                                                                      GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
384
{
385
INT                xval;
386
GX_UBYTE           count;
387
INT                start_pos;
388
GX_UBYTE           falpha;
389
GX_UBYTE           combined_alpha;
390
USHORT             pixel;
391
4092
GX_CONST GX_UBYTE *get = GX_NULL;
392
GX_CONST USHORT   *getpixel;
393
GX_PIXELMAP       *pixelmap;
394
VOID               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
395
396
4092
    pixelmap = info -> pixelmap;
397
4092
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
398
399
4092
    if (blend_func == GX_NULL)
400
    {
401
724
        return;
402
    }
403
404

3368
    if ((info -> draw) && (xstart <= xend))
405
    {
406
        /* Calculate the draw start position. */
407
2038
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
408
409
11414
        while (start_pos <= xend)
410
        {
411
9376
            xval = start_pos;
412
413
            /*Start from where we need to repeat.*/
414
9376
            get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
415
44354
            while (xval < start_pos + pixelmap -> gx_pixelmap_width)
416
            {
417
34978
                count = *get;
418
34978
                if (count & 0x80)
419
                {
420
17410
                    count = (GX_UBYTE)((count & 0x7f) + 1u);
421
17410
                    falpha = *(get + 1);
422
17410
                    combined_alpha = (GX_UBYTE)(falpha * alpha / 255);
423
17410
                    if (combined_alpha)
424
                    {
425
7391
                        get += 2;
426
7391
                        getpixel = (GX_CONST USHORT *)get;
427
7391
                        pixel = *getpixel;
428
7391
                        get += 2;
429
430
165920
                        while (count--)
431
                        {
432

158529
                            if (xval >= xstart && xval <= xend)
433
                            {
434
76559
                                blend_func(context, xval, y, pixel, combined_alpha);
435
                            }
436
158529
                            xval++;
437
                        }
438
                    }
439
                    else
440
                    {
441
10019
                        get += 4;
442
10019
                        xval += count;
443
                    }
444
                }
445
                else
446
                {
447
17568
                    count++;
448
99828
                    while (count--)
449
                    {
450

82260
                        if (xval >= xstart && xval <= xend)
451
                        {
452
65712
                            falpha = *(get + 1);
453
65712
                            combined_alpha = (GX_UBYTE)(falpha * alpha / 255);
454
65712
                            get += 2;
455
65712
                            getpixel = (USHORT *)get;
456
65712
                            pixel = *getpixel;
457
65712
                            get += 2;
458
65712
                            blend_func(context, xval, y, pixel, combined_alpha);
459
                        }
460
                        else
461
                        {
462
16548
                            get += 4;
463
                        }
464
82260
                        xval++;
465
                    }
466
                }
467
            }
468
9376
            start_pos += pixelmap -> gx_pixelmap_width;
469
        }
470
    }
471
    else
472
    {
473
        /* Skip this line. */
474
1330
        xval = 0;
475
1330
        get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
476
11615
        while (xval < pixelmap -> gx_pixelmap_width)
477
        {
478
10285
            count = *get;
479
10285
            if (count & 0x80)
480
            {
481
6508
                count = (GX_UBYTE)((count & 0x7f) + 1);
482
6508
                get += 4;
483
            }
484
            else
485
            {
486
3777
                count++;
487
3777
                get += count * 4;
488
            }
489
10285
            xval += count;
490
        }
491
    }
492
493
    /* Update data pointer for the next line. */
494
3368
    info -> current_pixel_ptr = (GX_UBYTE *)get;
495
}
496
497
#endif /* GX_BRUSH_ALPHA_SUPPORT */
498
499
/**************************************************************************/
500
/*                                                                        */
501
/*  FUNCTION                                               RELEASE        */
502
/*                                                                        */
503
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_raw_write        */
504
/*                                                        PORTABLE C      */
505
/*                                                           6.X          */
506
/*  AUTHOR                                                                */
507
/*                                                                        */
508
/*    Kenneth Maxwell, Microsoft Corporation                              */
509
/*                                                                        */
510
/*  DESCRIPTION                                                           */
511
/*                                                                        */
512
/*    Internal helper function that handles writing of uncompressed       */
513
/*    pixlemap file without alpha channel.                                */
514
/*                                                                        */
515
/*  INPUT                                                                 */
516
/*                                                                        */
517
/*    context                               Drawing context               */
518
/*    xstart                                x-coord of line left          */
519
/*    xend                                  x-coord of line end           */
520
/*    y                                     y-coord of line top           */
521
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
522
/*                                                                        */
523
/*  OUTPUT                                                                */
524
/*                                                                        */
525
/*    None                                                                */
526
/*                                                                        */
527
/*  CALLS                                                                 */
528
/*                                                                        */
529
/*    None                                                                */
530
/*                                                                        */
531
/*  CALLED BY                                                             */
532
/*                                                                        */
533
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
534
/*                                                                        */
535
/**************************************************************************/
536
4122
static VOID _gx_display_driver_565rgb_horizontal_pixelmap_line_raw_write(GX_DRAW_CONTEXT *context,
537
                                                                         INT xstart, INT xend, INT y,
538
                                                                         GX_FILL_PIXELMAP_INFO *info)
539
{
540
INT              xval;
541
INT              offset;
542
INT              pic_width;
543
4122
GX_CONST USHORT *get = GX_NULL;
544
USHORT          *put;
545
GX_PIXELMAP     *pixelmap;
546
547
4122
    pixelmap = info -> pixelmap;
548
549
4122
    pic_width = pixelmap -> gx_pixelmap_width;
550
551
    /* Pickup data pointer for the current line. */
552
4122
    get = (GX_CONST USHORT *)info -> current_pixel_ptr;
553
554

4122
    if ((info -> draw) && (xstart <= xend))
555
    {
556
3054
        put = (USHORT *)context -> gx_draw_context_memory;
557
3054
        GX_CALCULATE_PUTROW(put, xstart, y, context);
558
559
        /*calculate the offset.*/
560
3054
        offset = (info -> x_offset % pic_width);
561
562
423330
        for (xval = xstart; xval <= xend; xval++)
563
        {
564
420276
            *put++ = *(get + offset);
565
420276
            offset++;
566
567
420276
            if (offset >= pic_width)
568
            {
569
13074
                offset -= pic_width;
570
            }
571
        }
572
    }
573
574
    /* Update data pointer for the next line. */
575
4122
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
576
4122
}
577
578
/**************************************************************************/
579
/*                                                                        */
580
/*  FUNCTION                                               RELEASE        */
581
/*                                                                        */
582
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_alpha_write      */
583
/*                                                        PORTABLE C      */
584
/*                                                           6.1          */
585
/*  AUTHOR                                                                */
586
/*                                                                        */
587
/*    Kenneth Maxwell, Microsoft Corporation                              */
588
/*                                                                        */
589
/*  DESCRIPTION                                                           */
590
/*                                                                        */
591
/*    Internal helper function that handles writing of uncompressed       */
592
/*    pixlemap file with alpha channel.                                   */
593
/*                                                                        */
594
/*  INPUT                                                                 */
595
/*                                                                        */
596
/*    context                               Drawing context               */
597
/*    xstart                                x-coord of line left          */
598
/*    xend                                  x-coord of line end           */
599
/*    y                                     y-coord of line top           */
600
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
601
/*                                                                        */
602
/*  OUTPUT                                                                */
603
/*                                                                        */
604
/*    None                                                                */
605
/*                                                                        */
606
/*  CALLS                                                                 */
607
/*                                                                        */
608
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
609
/*                                            blend function              */
610
/*    [gx_display_driver_pixel_write]       Basic display driver pixel    */
611
/*                                            write function              */
612
/*                                                                        */
613
/*  CALLED BY                                                             */
614
/*                                                                        */
615
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
616
/*                                                                        */
617
/**************************************************************************/
618
4047
static VOID _gx_display_driver_565rgb_horizontal_pixelmap_line_alpha_write(GX_DRAW_CONTEXT *context,
619
                                                                           INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
620
{
621
INT                xval;
622
GX_CONST USHORT   *get;
623
GX_CONST GX_UBYTE *getalpha;
624
USHORT             color;
625
GX_UBYTE           alpha;
626
GX_PIXELMAP       *pixelmap;
627
INT                pic_width;
628
INT                offset;
629
VOID               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
630
631
4047
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
632
4047
    pixelmap = info -> pixelmap;
633
634
4047
    if (blend_func == GX_NULL)
635
    {
636
857
        return;
637
    }
638
639
3190
    pic_width = pixelmap -> gx_pixelmap_width;
640

3190
    if ((info -> draw) && (xstart <= xend))
641
    {
642
        /* Pick up data pointers to the current line. */
643
2387
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
644
2387
        getalpha = (GX_CONST GX_UBYTE *)info -> current_aux_ptr;
645
646
        /* calculate map offset in x-axis. */
647
2387
        offset = (info -> x_offset % pic_width);
648
649
306284
        for (xval = xstart; xval <= xend; xval++)
650
        {
651
303897
            color = *(get + offset);
652
303897
            alpha = *(getalpha + offset);
653
654
303897
            blend_func(context, xval, y, color, alpha);
655
656
303897
            offset++;
657
303897
            if (offset >= pic_width)
658
            {
659
5366
                offset -= pic_width;
660
            }
661
        }
662
    }
663
664
    /* Update data pointers for the next line. */
665
3190
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
666
3190
    info -> current_aux_ptr += (UINT)pic_width * sizeof(GX_UBYTE);
667
}
668
669
/**************************************************************************/
670
/*                                                                        */
671
/*  FUNCTION                                               RELEASE        */
672
/*                                                                        */
673
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_compressed_write */
674
/*                                                        PORTABLE C      */
675
/*                                                           6.3.0        */
676
/*  AUTHOR                                                                */
677
/*                                                                        */
678
/*    Kenneth Maxwell, Microsoft Corporation                              */
679
/*                                                                        */
680
/*  DESCRIPTION                                                           */
681
/*                                                                        */
682
/*    Internal helper function that handles writing of compressed         */
683
/*    pixlemap file without alpha channel.                                */
684
/*                                                                        */
685
/*  INPUT                                                                 */
686
/*                                                                        */
687
/*    context                               Drawing context               */
688
/*    xstart                                x-coord of line left          */
689
/*    xend                                  x-coord of line end           */
690
/*    y                                     y-coord of line top           */
691
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
692
/*                                                                        */
693
/*  OUTPUT                                                                */
694
/*                                                                        */
695
/*    None                                                                */
696
/*                                                                        */
697
/*  CALLS                                                                 */
698
/*                                                                        */
699
/*    None                                                                */
700
/*                                                                        */
701
/*  CALLED BY                                                             */
702
/*                                                                        */
703
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
704
/*                                                                        */
705
/**************************************************************************/
706
5238
static VOID _gx_display_driver_565rgb_horizontal_pixelmap_line_compressed_write(GX_DRAW_CONTEXT *context,
707
                                                                                INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
708
{
709
INT              start_pos;
710
INT              xval;
711
USHORT           count;
712
USHORT           pixel;
713
5238
GX_CONST USHORT *get = GX_NULL;
714
USHORT          *put;
715
GX_PIXELMAP     *pixelmap;
716
717
5238
    pixelmap = info -> pixelmap;
718
719

5238
    if ((info -> draw) && (xstart <= xend))
720
    {
721
        /* Calculate draw start position. */
722
3030
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
723
724
3030
        put = (USHORT *)context -> gx_draw_context_memory;
725
3030
        GX_CALCULATE_PUTROW(put, start_pos, y, context);
726
727
        /*Repeat the draw operation to fill the whole dirty area.*/
728
6687
        while (start_pos <= xend)
729
        {
730
3657
            xval = start_pos;
731
732
            /*Start from where we need to repeat.*/
733
3657
            get = (GX_CONST USHORT *)info -> current_pixel_ptr;
734
735
127632
            while (xval < start_pos + pixelmap -> gx_pixelmap_width)
736
            {
737
123975
                count = *get++;
738
123975
                if (count & 0x8000)
739
                {
740
67179
                    count = (USHORT)((count & 0x7fff) + 1);
741
67179
                    pixel = *get++;
742
478354
                    while (count--)
743
                    {
744

411175
                        if (xval >= xstart && xval <= xend)
745
                        {
746
118668
                            *put = pixel;
747
                        }
748
411175
                        xval++;
749
411175
                        put++;
750
                    }
751
                }
752
                else
753
                {
754
56796
                    count++;
755
1258640
                    while (count--)
756
                    {
757
1201844
                        pixel = *get++;
758

1201844
                        if (xval >= xstart && xval <= xend)
759
                        {
760
297841
                            *put = pixel;
761
                        }
762
1201844
                        xval++;
763
1201844
                        put++;
764
                    }
765
                }
766
            }
767
3657
            start_pos += pixelmap -> gx_pixelmap_width;
768
        }
769
    }
770
    else
771
    {
772
2208
        xval = 0;
773
2208
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
774
67516
        while (xval < pixelmap -> gx_pixelmap_width)
775
        {
776
65308
            count = *get++;
777
65308
            if (count & 0x8000)
778
            {
779
34365
                count = (USHORT)((count & 0x7fff) + 1);
780
34365
                get++;
781
            }
782
            else
783
            {
784
30943
                count++;
785
30943
                get += count;
786
            }
787
65308
            xval += count;
788
        }
789
    }
790
791
    /* Update data pointer for the next line. */
792
5238
    info -> current_pixel_ptr = (GX_UBYTE *)get;
793
5238
}
794
795
/**************************************************************************/
796
/*                                                                        */
797
/*  FUNCTION                                               RELEASE        */
798
/*                                                                        */
799
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_c_a_write        */
800
/*                                                        PORTABLE C      */
801
/*                                                           6.1          */
802
/*  AUTHOR                                                                */
803
/*                                                                        */
804
/*    Kenneth Maxwell, Microsoft Corporation                              */
805
/*                                                                        */
806
/*  DESCRIPTION                                                           */
807
/*                                                                        */
808
/*    Internal helper function that handles writing of compressed         */
809
/*    pixlemap file with alpha channel.                                   */
810
/*                                                                        */
811
/*  INPUT                                                                 */
812
/*                                                                        */
813
/*    context                               Drawing context               */
814
/*    xstart                                x-coord of line left          */
815
/*    xend                                  x-coord of line end           */
816
/*    y                                     y-coord of line top           */
817
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
818
/*                                                                        */
819
/*  OUTPUT                                                                */
820
/*                                                                        */
821
/*    None                                                                */
822
/*                                                                        */
823
/*  CALLS                                                                 */
824
/*                                                                        */
825
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
826
/*                                            blend function              */
827
/*                                                                        */
828
/*  CALLED BY                                                             */
829
/*                                                                        */
830
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
831
/*                                                                        */
832
/**************************************************************************/
833
4411
static VOID _gx_display_driver_565rgb_horizontal_pixelmap_line_compressed_alpha_write(GX_DRAW_CONTEXT *context,
834
                                                                                      INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
835
{
836
INT                xval;
837
GX_UBYTE           count;
838
INT                start_pos;
839
GX_UBYTE           alpha;
840
USHORT             pixel;
841
4411
GX_CONST GX_UBYTE *get = GX_NULL;
842
GX_CONST USHORT   *getpixel;
843
GX_PIXELMAP       *pixelmap;
844
VOID               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
845
846
4411
    pixelmap = info -> pixelmap;
847
4411
    blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend;
848
849
4411
    if (blend_func == GX_NULL)
850
    {
851
724
        return;
852
    }
853
854

3687
    if ((info -> draw) && (xstart <= xend))
855
    {
856
        /* Calculate draw start position. */
857
2357
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_width);
858
859
        /* Repeat the draw operation to fill the whole dirty area. */
860
12369
        while (start_pos <= xend)
861
        {
862
10012
            xval = start_pos;
863
864
            /* Start from where we need to repeat. */
865
10012
            get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
866
49915
            while (xval < start_pos + pixelmap -> gx_pixelmap_width)
867
            {
868
39903
                count = *get;
869
39903
                if (count & 0x80)
870
                {
871
20544
                    count = (GX_UBYTE)((count & 0x7f) + 1u);
872
20544
                    alpha = *(get + 1);
873
20544
                    if (alpha)
874
                    {
875
8323
                        get += 2;
876
877
8323
                        getpixel = (GX_CONST USHORT *)get;
878
8323
                        pixel = *getpixel;
879
8323
                        get += 2;
880
881
207073
                        while (count--)
882
                        {
883

198750
                            if (xval >= xstart && xval <= xend)
884
                            {
885
107607
                                blend_func(context, xval, y, pixel, alpha);
886
                            }
887
198750
                            xval++;
888
                        }
889
                    }
890
                    else
891
                    {
892
12221
                        get += 4;
893
12221
                        xval += count;
894
                    }
895
                }
896
                else
897
                {
898
19359
                    count++;
899
107749
                    while (count--)
900
                    {
901

88390
                        if (xval >= xstart && xval <= xend)
902
                        {
903
69676
                            alpha = *(get + 1);
904
69676
                            get += 2;
905
69676
                            getpixel = (USHORT *)get;
906
69676
                            pixel = *getpixel;
907
69676
                            get += 2;
908
69676
                            blend_func(context, xval, y, pixel, alpha);
909
                        }
910
                        else
911
                        {
912
18714
                            get += 4;
913
                        }
914
88390
                        xval++;
915
                    }
916
                }
917
            }
918
10012
            start_pos += pixelmap -> gx_pixelmap_width;
919
        }
920
    }
921
    else
922
    {
923
        /* Just do skip operation here. */
924
1330
        xval = 0;
925
1330
        get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
926
11615
        while (xval < pixelmap -> gx_pixelmap_width)
927
        {
928
10285
            count = *get;
929
10285
            if (count & 0x80)
930
            {
931
6508
                count = (GX_UBYTE)((count & 0x7f) + 1);
932
6508
                get += 4;
933
            }
934
            else
935
            {
936
3777
                count++;
937
3777
                get += count * 4;
938
            }
939
10285
            xval += count;
940
        }
941
    }
942
943
    /* Update data pinter for the next line. */
944
3687
    info -> current_pixel_ptr = (GX_UBYTE *)get;
945
}
946
947
/**************************************************************************/
948
/*                                                                        */
949
/*  FUNCTION                                               RELEASE        */
950
/*                                                                        */
951
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
952
/*                                                        PORTABLE C      */
953
/*                                                           6.1          */
954
/*  AUTHOR                                                                */
955
/*                                                                        */
956
/*    Kenneth Maxwell, Microsoft Corporation                              */
957
/*                                                                        */
958
/*  DESCRIPTION                                                           */
959
/*                                                                        */
960
/*    565rgb screen driver pixelmap drawing function that handles         */
961
/*    compressed or uncompress, with or without alpha channel.            */
962
/*                                                                        */
963
/*  INPUT                                                                 */
964
/*                                                                        */
965
/*    context                               Drawing context               */
966
/*    xstart                                x-coord of line left          */
967
/*    xend                                  x-coord of line right         */
968
/*    y                                     y-coord of line top           */
969
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
970
/*                                                                        */
971
/*  OUTPUT                                                                */
972
/*                                                                        */
973
/*    None                                                                */
974
/*                                                                        */
975
/*  CALLS                                                                 */
976
/*                                                                        */
977
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_c_a_blend       */
978
/*                                          Real pixelmap blend function  */
979
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_alpha_blend     */
980
/*                                          Real pixelmap blend function  */
981
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_c_blend         */
982
/*                                          Real pixelmap blend function  */
983
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_raw_blend       */
984
/*                                          Real pixelmap blend function  */
985
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_c_a_write       */
986
/*                                          Real pixelmap write function  */
987
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_alpha_write     */
988
/*                                          Real pixelmap write function  */
989
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_c_write         */
990
/*                                          Real pixelmap write function  */
991
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_raw_write       */
992
/*                                          Real pixelmap write function  */
993
/*                                                                        */
994
/*  CALLED BY                                                             */
995
/*                                                                        */
996
/*    GUIX Internal Code                                                  */
997
/*                                                                        */
998
/**************************************************************************/
999
44037
VOID _gx_display_driver_565rgb_horizontal_pixelmap_line_draw(GX_DRAW_CONTEXT *context,
1000
                                                             INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
1001
{
1002
#if defined GX_BRUSH_ALPHA_SUPPORT
1003
GX_UBYTE alpha;
1004
1005
44037
    alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1006

44037
    if ((alpha == 0) || (info -> pixelmap == GX_NULL))
1007
    {
1008
        /* Nothing to drawn. Just return. */
1009
9677
        return;
1010
    }
1011
1012
34360
    if (alpha != 0xff)
1013
    {
1014
1015
16542
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1016
        {
1017
7820
            if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1018
            {
1019
                /* has both compression and alpha */
1020
4092
                _gx_display_driver_565rgb_horizontal_pixelmap_line_compressed_alpha_blend(context, xstart, xend, y, info, alpha);
1021
            }
1022
            else
1023
            {
1024
                /* alpha, no compression */
1025
3728
                _gx_display_driver_565rgb_horizontal_pixelmap_line_alpha_blend(context, xstart, xend, y, info, alpha);
1026
            }
1027
        }
1028
        else
1029
        {
1030
8722
            if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1031
            {
1032
                /* compressed with no alpha */
1033
4919
                _gx_display_driver_565rgb_horizontal_pixelmap_line_compressed_blend(context, xstart, xend, y, info, alpha);
1034
            }
1035
            else
1036
            {
1037
                /* no compression or alpha */
1038
3803
                _gx_display_driver_565rgb_horizontal_pixelmap_line_raw_blend(context, xstart, xend, y, info, alpha);
1039
            }
1040
        }
1041
1042
        /* Data pointer goes to the end of the fill map, move it to the start again. */
1043
16542
        if (info -> current_pixel_ptr >= info -> pixelmap -> gx_pixelmap_data + info -> pixelmap -> gx_pixelmap_data_size)
1044
        {
1045
144
            info -> current_pixel_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_data;
1046
144
            info -> current_aux_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_aux_data;
1047
        }
1048
16542
        return;
1049
    }
1050
#endif
1051
1052
17818
    if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1053
    {
1054
8458
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1055
        {
1056
            /* has both compression and alpha */
1057
4411
            _gx_display_driver_565rgb_horizontal_pixelmap_line_compressed_alpha_write(context, xstart, xend, y, info);
1058
        }
1059
        else
1060
        {
1061
            /* alpha, no compression */
1062
4047
            _gx_display_driver_565rgb_horizontal_pixelmap_line_alpha_write(context, xstart, xend, y, info);
1063
        }
1064
    }
1065
    else
1066
    {
1067
9360
        if (info -> pixelmap ->  gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1068
        {
1069
            /* compressed with no alpha */
1070
5238
            _gx_display_driver_565rgb_horizontal_pixelmap_line_compressed_write(context, xstart, xend, y, info);
1071
        }
1072
        else
1073
        {
1074
            /* no compression or alpha */
1075
4122
            _gx_display_driver_565rgb_horizontal_pixelmap_line_raw_write(context, xstart, xend, y, info);
1076
        }
1077
    }
1078
1079
    /* Data pointers goes to the end of full map, move it to the start again. */
1080
17818
    if (info -> current_pixel_ptr >= info -> pixelmap -> gx_pixelmap_data + info -> pixelmap -> gx_pixelmap_data_size)
1081
    {
1082
196
        info -> current_pixel_ptr = (GX_UBYTE *)info ->  pixelmap -> gx_pixelmap_data;
1083
196
        info -> current_aux_ptr = (GX_UBYTE *)info ->  pixelmap -> gx_pixelmap_aux_data;
1084
    }
1085
}