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

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** GUIX Component                                                        */
16
/**                                                                       */
17
/**   Display Management (Display)                                        */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_display.h"
28
#include "gx_context.h"
29
30
#if defined(GX_BRUSH_ALPHA_SUPPORT)
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_raw_blend*/
37
/*                                                        PORTABLE C      */
38
/*                                                           6.1.3        */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    Internal helper function that handles writing of uncompressed       */
46
/*    pixlemap file without 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 end           */
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_565rgb_horizontal_pixelmap_line_draw             */
69
/*                                                                        */
70
/*  RELEASE HISTORY                                                       */
71
/*                                                                        */
72
/*    DATE              NAME                      DESCRIPTION             */
73
/*                                                                        */
74
/*  12-31-2020     Kenneth Maxwell          Initial Version 6.1.3         */
75
/*                                                                        */
76
/**************************************************************************/
77
7987
static VOID _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_raw_blend(GX_DRAW_CONTEXT *context,
78
                                                                                 INT xstart, INT xend, INT y,
79
                                                                                 GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
80
{
81
INT              xval;
82
INT              offset;
83
INT              pic_width;
84
GX_CONST USHORT *get;
85
USHORT           pixel;
86
GX_PIXELMAP     *pixelmap;
87
88
7987
    pixelmap = info -> pixelmap;
89
7987
    pic_width = pixelmap -> gx_pixelmap_height;
90
91
    /* Pick the data pointer to the current row. */
92
7987
    get = (GX_CONST USHORT *)info -> current_pixel_ptr;
93
94

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

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

7687
    if ((info -> draw) && (xstart <= xend))
274
    {
275
        /* Calculate draw start position. */
276
5233
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_height);
277
278
11476
        while (start_pos <= xend)
279
        {
280
6243
            xval = start_pos;
281
282
            /*Start from where we need to repeat.*/
283
6243
            get = (GX_CONST USHORT *)info -> current_pixel_ptr;
284
285
178349
            while (xval < start_pos + pixelmap -> gx_pixelmap_height)
286
            {
287
172106
                count = *get++;
288
172106
                if (count & 0x8000)
289
                {
290
98234
                    count = (USHORT)((count & 0x7fff) + 1);
291
98234
                    pixel = *get++;
292
957049
                    while (count--)
293
                    {
294

858815
                        if (xval >= xstart && xval <= xend)
295
                        {
296
272330
                            blend_func(context, xval, y, pixel, alpha);
297
                        }
298
858815
                        xval++;
299
                    }
300
                }
301
                else
302
                {
303
73872
                    count++;
304
881938
                    while (count--)
305
                    {
306
808066
                        pixel = *get++;
307

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

7447
    if ((info -> draw) && (xstart <= xend))
407
    {
408
        /* Calculate the draw start position. */
409
5233
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_height);
410
411
13163
        while (start_pos <= xend)
412
        {
413
7930
            xval = start_pos;
414
415
            /*Start from where we need to repeat.*/
416
7930
            get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
417
53418
            while (xval < start_pos + pixelmap -> gx_pixelmap_height)
418
            {
419
45488
                count = *get;
420
45488
                if (count & 0x80)
421
                {
422
25674
                    count = (GX_UBYTE)((count & 0x7f) + 1u);
423
25674
                    falpha = *(get + 1);
424
25674
                    combined_alpha = (GX_UBYTE)(falpha * alpha / 255);
425
25674
                    if (combined_alpha)
426
                    {
427
9773
                        get += 2;
428
9773
                        getpixel = (GX_CONST USHORT *)get;
429
9773
                        pixel = *getpixel;
430
9773
                        get += 2;
431
432
442649
                        while (count--)
433
                        {
434

432876
                            if (xval >= xstart && xval <= xend)
435
                            {
436
181998
                                blend_func(context, xval, y, pixel, combined_alpha);
437
                            }
438
432876
                            xval++;
439
                        }
440
                    }
441
                    else
442
                    {
443
15901
                        get += 4;
444
15901
                        xval += count;
445
                    }
446
                }
447
                else
448
                {
449
19814
                    count++;
450
73897
                    while (count--)
451
                    {
452

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

26414
    if ((info -> draw) && (xstart <= xend))
563
    {
564
18071
        put = (USHORT *)context -> gx_draw_context_memory;
565
18071
        put += y * context -> gx_draw_context_pitch;
566
18071
        put += xstart;
567
568
        /*calculate the offset.*/
569
18071
        offset = (info -> x_offset % pic_width);
570
571
3238740
        for (xval = xstart; xval <= xend; xval++)
572
        {
573
3220669
            *put++ = *(get + offset);
574
3220669
            offset++;
575
576
3220669
            if (offset >= pic_width)
577
            {
578
22692
                offset -= pic_width;
579
            }
580
        }
581
    }
582
583
    /* Update data pointer for the next line. */
584
26414
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
585
26414
}
586
587
/**************************************************************************/
588
/*                                                                        */
589
/*  FUNCTION                                               RELEASE        */
590
/*                                                                        */
591
/*    _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_alpha_   */
592
/*                                                                  write */
593
/*                                                        PORTABLE C      */
594
/*                                                           6.1.3        */
595
/*  AUTHOR                                                                */
596
/*                                                                        */
597
/*    Kenneth Maxwell, Microsoft Corporation                              */
598
/*                                                                        */
599
/*  DESCRIPTION                                                           */
600
/*                                                                        */
601
/*    Internal helper function that handles writing of uncompressed       */
602
/*    pixlemap file with alpha channel.                                   */
603
/*                                                                        */
604
/*  INPUT                                                                 */
605
/*                                                                        */
606
/*    context                               Drawing context               */
607
/*    xstart                                x-coord of line left          */
608
/*    xend                                  x-coord of line end           */
609
/*    y                                     y-coord of line top           */
610
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
611
/*                                                                        */
612
/*  OUTPUT                                                                */
613
/*                                                                        */
614
/*    None                                                                */
615
/*                                                                        */
616
/*  CALLS                                                                 */
617
/*                                                                        */
618
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
619
/*                                            blend function              */
620
/*    [gx_display_driver_pixel_write]       Basic display driver pixel    */
621
/*                                            write function              */
622
/*                                                                        */
623
/*  CALLED BY                                                             */
624
/*                                                                        */
625
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
626
/*                                                                        */
627
/*  RELEASE HISTORY                                                       */
628
/*                                                                        */
629
/*    DATE              NAME                      DESCRIPTION             */
630
/*                                                                        */
631
/*  12-31-2020     Kenneth Maxwell          Initial Version 6.1.3         */
632
/*                                                                        */
633
/**************************************************************************/
634
6369
static VOID _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_alpha_write(GX_DRAW_CONTEXT *context,
635
                                                                                   INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
636
{
637
INT                xval;
638
GX_CONST USHORT   *get;
639
GX_CONST GX_UBYTE *getalpha;
640
USHORT             color;
641
GX_UBYTE           alpha;
642
GX_PIXELMAP       *pixelmap;
643
INT                pic_width;
644
INT                offset;
645
646
6369
    pixelmap = info -> pixelmap;
647
648
6369
    pic_width = pixelmap -> gx_pixelmap_height;
649

6369
    if ((info -> draw) && (xstart <= xend))
650
    {
651
        /* Pick up data pointers to the current line. */
652
5233
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
653
5233
        getalpha = (GX_CONST GX_UBYTE *)info -> current_aux_ptr;
654
655
        /* calculate map offset in x-axis. */
656
5233
        offset = (info -> x_offset % pic_width);
657
658
533102
        for (xval = xstart; xval <= xend; xval++)
659
        {
660
527869
            color = *(get + offset);
661
527869
            alpha = *(getalpha + offset);
662
663
527869
            _gx_display_driver_565rgb_pixel_blend(context, xval, y, color, alpha);
664
665
527869
            offset++;
666
527869
            if (offset >= pic_width)
667
            {
668
13598
                offset -= pic_width;
669
            }
670
        }
671
    }
672
673
    /* Update data pointers for the next line. */
674
6369
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
675
6369
    info -> current_aux_ptr += (UINT)pic_width * sizeof(GX_UBYTE);
676
6369
}
677
678
/**************************************************************************/
679
/*                                                                        */
680
/*  FUNCTION                                               RELEASE        */
681
/*                                                                        */
682
/*    _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_         */
683
/*                                                       compressed_write */
684
/*                                                        PORTABLE C      */
685
/*                                                           6.1.3        */
686
/*  AUTHOR                                                                */
687
/*                                                                        */
688
/*    Kenneth Maxwell, Microsoft Corporation                              */
689
/*                                                                        */
690
/*  DESCRIPTION                                                           */
691
/*                                                                        */
692
/*    Internal helper function that handles writing of compressed         */
693
/*    pixlemap file without alpha channel.                                */
694
/*                                                                        */
695
/*  INPUT                                                                 */
696
/*                                                                        */
697
/*    context                               Drawing context               */
698
/*    xstart                                x-coord of line left          */
699
/*    xend                                  x-coord of line end           */
700
/*    y                                     y-coord of line top           */
701
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
702
/*                                                                        */
703
/*  OUTPUT                                                                */
704
/*                                                                        */
705
/*    None                                                                */
706
/*                                                                        */
707
/*  CALLS                                                                 */
708
/*                                                                        */
709
/*    None                                                                */
710
/*                                                                        */
711
/*  CALLED BY                                                             */
712
/*                                                                        */
713
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
714
/*                                                                        */
715
/*  RELEASE HISTORY                                                       */
716
/*                                                                        */
717
/*    DATE              NAME                      DESCRIPTION             */
718
/*                                                                        */
719
/*  12-31-2020     Kenneth Maxwell          Initial Version 6.1.3         */
720
/*                                                                        */
721
/**************************************************************************/
722
7687
static VOID _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_compressed_write(GX_DRAW_CONTEXT *context,
723
                                                                                        INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
724
{
725
INT              start_pos;
726
INT              xval;
727
USHORT           count;
728
USHORT           pixel;
729
7687
GX_CONST USHORT *get = GX_NULL;
730
USHORT          *put;
731
GX_PIXELMAP     *pixelmap;
732
733
7687
    pixelmap = info -> pixelmap;
734
735

7687
    if ((info -> draw) && (xstart <= xend))
736
    {
737
        /* Calculate draw start position. */
738
5233
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_height);
739
740
5233
        put = (USHORT *)context -> gx_draw_context_memory;
741
5233
        put += y * context -> gx_draw_context_pitch + start_pos;
742
743
        /*Repeat the draw operation to fill the whole dirty area.*/
744
11476
        while (start_pos <= xend)
745
        {
746
6243
            xval = start_pos;
747
748
            /*Start from where we need to repeat.*/
749
6243
            get = (GX_CONST USHORT *)info -> current_pixel_ptr;
750
751
178349
            while (xval < start_pos + pixelmap -> gx_pixelmap_height)
752
            {
753
172106
                count = *get++;
754
172106
                if (count & 0x8000)
755
                {
756
98234
                    count = (USHORT)((count & 0x7fff) + 1);
757
98234
                    pixel = *get++;
758
957049
                    while (count--)
759
                    {
760

858815
                        if (xval >= xstart && xval <= xend)
761
                        {
762
272330
                            *put = pixel;
763
                        }
764
858815
                        xval++;
765
858815
                        put++;
766
                    }
767
                }
768
                else
769
                {
770
73872
                    count++;
771
881938
                    while (count--)
772
                    {
773
808066
                        pixel = *get++;
774

808066
                        if (xval >= xstart && xval <= xend)
775
                        {
776
255539
                            *put = pixel;
777
                        }
778
808066
                        xval++;
779
808066
                        put++;
780
                    }
781
                }
782
            }
783
6243
            start_pos += pixelmap -> gx_pixelmap_height;
784
        }
785
    }
786
    else
787
    {
788
2454
        xval = 0;
789
2454
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
790
75269
        while (xval < pixelmap -> gx_pixelmap_height)
791
        {
792
72815
            count = *get++;
793
72815
            if (count & 0x8000)
794
            {
795
41241
                count = (USHORT)((count & 0x7fff) + 1);
796
41241
                get++;
797
            }
798
            else
799
            {
800
31574
                count++;
801
31574
                get += count;
802
            }
803
72815
            xval += count;
804
        }
805
    }
806
807
    /* Update data pointer for the next line. */
808
7687
    info -> current_pixel_ptr = (GX_UBYTE *)get;
809
7687
}
810
811
/**************************************************************************/
812
/*                                                                        */
813
/*  FUNCTION                                               RELEASE        */
814
/*                                                                        */
815
/*    _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_c_a_write*/
816
/*                                                        PORTABLE C      */
817
/*                                                           6.1.3        */
818
/*  AUTHOR                                                                */
819
/*                                                                        */
820
/*    Kenneth Maxwell, Microsoft Corporation                              */
821
/*                                                                        */
822
/*  DESCRIPTION                                                           */
823
/*                                                                        */
824
/*    Internal helper function that handles writing of compressed         */
825
/*    pixlemap file with alpha channel.                                   */
826
/*                                                                        */
827
/*  INPUT                                                                 */
828
/*                                                                        */
829
/*    context                               Drawing context               */
830
/*    xstart                                x-coord of line left          */
831
/*    xend                                  x-coord of line end           */
832
/*    y                                     y-coord of line top           */
833
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
834
/*                                                                        */
835
/*  OUTPUT                                                                */
836
/*                                                                        */
837
/*    None                                                                */
838
/*                                                                        */
839
/*  CALLS                                                                 */
840
/*                                                                        */
841
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
842
/*                                            blend function              */
843
/*                                                                        */
844
/*  CALLED BY                                                             */
845
/*                                                                        */
846
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
847
/*                                                                        */
848
/*  RELEASE HISTORY                                                       */
849
/*                                                                        */
850
/*    DATE              NAME                      DESCRIPTION             */
851
/*                                                                        */
852
/*  12-31-2020     Kenneth Maxwell          Initial Version 6.1.3         */
853
/*                                                                        */
854
/**************************************************************************/
855
7447
static VOID _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_compressed_alpha_write(GX_DRAW_CONTEXT *context,
856
                                                                                              INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
857
{
858
INT                xval;
859
GX_UBYTE           count;
860
INT                start_pos;
861
GX_UBYTE           alpha;
862
USHORT             pixel;
863
7447
GX_CONST GX_UBYTE *get = GX_NULL;
864
GX_CONST USHORT   *getpixel;
865
GX_PIXELMAP       *pixelmap;
866
VOID               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
867
868
7447
    pixelmap = info -> pixelmap;
869
7447
    blend_func = _gx_display_driver_565rgb_pixel_blend;
870
871

7447
    if ((info -> draw) && (xstart <= xend))
872
    {
873
        /* Calculate draw start position. */
874
5233
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_height);
875
876
        /* Repeat the draw operation to fill the whole dirty area. */
877
13163
        while (start_pos <= xend)
878
        {
879
7930
            xval = start_pos;
880
881
            /* Start from where we need to repeat. */
882
7930
            get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
883
53418
            while (xval < start_pos + pixelmap -> gx_pixelmap_height)
884
            {
885
45488
                count = *get;
886
45488
                if (count & 0x80)
887
                {
888
25674
                    count = (GX_UBYTE)((count & 0x7f) + 1u);
889
25674
                    alpha = *(get + 1);
890
25674
                    if (alpha)
891
                    {
892
9773
                        get += 2;
893
894
9773
                        getpixel = (GX_CONST USHORT *)get;
895
9773
                        pixel = *getpixel;
896
9773
                        get += 2;
897
898
442649
                        while (count--)
899
                        {
900

432876
                            if (xval >= xstart && xval <= xend)
901
                            {
902
181998
                                blend_func(context, xval, y, pixel, alpha);
903
                            }
904
432876
                            xval++;
905
                        }
906
                    }
907
                    else
908
                    {
909
15901
                        get += 4;
910
15901
                        xval += count;
911
                    }
912
                }
913
                else
914
                {
915
19814
                    count++;
916
73897
                    while (count--)
917
                    {
918

54083
                        if (xval >= xstart && xval <= xend)
919
                        {
920
23647
                            alpha = *(get + 1);
921
23647
                            get += 2;
922
23647
                            getpixel = (USHORT *)get;
923
23647
                            pixel = *getpixel;
924
23647
                            get += 2;
925
23647
                            blend_func(context, xval, y, pixel, alpha);
926
                        }
927
                        else
928
                        {
929
30436
                            get += 4;
930
                        }
931
54083
                        xval++;
932
                    }
933
                }
934
            }
935
7930
            start_pos += pixelmap -> gx_pixelmap_height;
936
        }
937
    }
938
    else
939
    {
940
        /* Just do skip operation here. */
941
2214
        xval = 0;
942
2214
        get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
943
18049
        while (xval < pixelmap -> gx_pixelmap_height)
944
        {
945
15835
            count = *get;
946
15835
            if (count & 0x80)
947
            {
948
8737
                count = (GX_UBYTE)((count & 0x7f) + 1);
949
8737
                get += 4;
950
            }
951
            else
952
            {
953
7098
                count++;
954
7098
                get += count * 4;
955
            }
956
15835
            xval += count;
957
        }
958
    }
959
960
    /* Update data pinter for the next line. */
961
7447
    info -> current_pixel_ptr = (GX_UBYTE *)get;
962
7447
}
963
964
/**************************************************************************/
965
/*                                                                        */
966
/*  FUNCTION                                               RELEASE        */
967
/*                                                                        */
968
/*    _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_draw     */
969
/*                                                        PORTABLE C      */
970
/*                                                           6.1.3        */
971
/*  AUTHOR                                                                */
972
/*                                                                        */
973
/*    Kenneth Maxwell, Microsoft Corporation                              */
974
/*                                                                        */
975
/*  DESCRIPTION                                                           */
976
/*                                                                        */
977
/*    565rgb screen driver pixelmap drawing function that handles         */
978
/*    compressed or uncompress, with or without alpha channel.            */
979
/*                                                                        */
980
/*  INPUT                                                                 */
981
/*                                                                        */
982
/*    context                               Drawing context               */
983
/*    ystart                                y-coord of line top           */
984
/*    yend                                  y-coord of line bottom        */
985
/*    x                                     x-coord of line left          */
986
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
987
/*                                                                        */
988
/*  OUTPUT                                                                */
989
/*                                                                        */
990
/*    None                                                                */
991
/*                                                                        */
992
/*  CALLS                                                                 */
993
/*                                                                        */
994
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_c_a_blend       */
995
/*                                          Real pixelmap blend function  */
996
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_alpha_blend     */
997
/*                                          Real pixelmap blend function  */
998
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_c_blend         */
999
/*                                          Real pixelmap blend function  */
1000
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_raw_blend       */
1001
/*                                          Real pixelmap blend function  */
1002
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_c_a_write       */
1003
/*                                          Real pixelmap write function  */
1004
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_alpha_write     */
1005
/*                                          Real pixelmap write function  */
1006
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_c_write         */
1007
/*                                          Real pixelmap write function  */
1008
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_raw_write       */
1009
/*                                          Real pixelmap write function  */
1010
/*                                                                        */
1011
/*  CALLED BY                                                             */
1012
/*                                                                        */
1013
/*    GUIX Internal Code                                                  */
1014
/*                                                                        */
1015
/*  RELEASE HISTORY                                                       */
1016
/*                                                                        */
1017
/*    DATE              NAME                      DESCRIPTION             */
1018
/*                                                                        */
1019
/*  12-31-2020     Kenneth Maxwell          Initial Version 6.1.3         */
1020
/*                                                                        */
1021
/**************************************************************************/
1022
105427
VOID _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_draw(GX_DRAW_CONTEXT *context,
1023
                                                                     INT ystart, INT yend, INT x, GX_FILL_PIXELMAP_INFO *info)
1024
{
1025
INT      xstart;
1026
INT      xend;
1027
INT      y;
1028
1029
105427
    if (context -> gx_draw_context_display->gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
1030
    {
1031
70927
        xstart = ystart;
1032
70927
        xend = yend;
1033
70927
        y = context -> gx_draw_context_canvas->gx_canvas_x_resolution - x - 1;
1034
    }
1035
    else
1036
    {
1037
34500
        xstart = context -> gx_draw_context_canvas->gx_canvas_y_resolution - yend - 1;
1038
34500
        xend = context -> gx_draw_context_canvas->gx_canvas_y_resolution - ystart - 1;
1039
34500
        y = x;
1040
34500
        info -> x_offset = (yend - ystart + 1 + info -> x_offset) % info->pixelmap -> gx_pixelmap_height;
1041
1042
34500
        if (info -> x_offset)
1043
        {
1044
31242
            info -> x_offset = info -> pixelmap -> gx_pixelmap_height - info -> x_offset;
1045
        }
1046
    }
1047
1048
#if defined GX_BRUSH_ALPHA_SUPPORT
1049
GX_UBYTE alpha;
1050
1051
105427
    alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1052

105427
    if ((alpha == 0) || (info -> pixelmap == GX_NULL))
1053
    {
1054
        /* Nothing to drawn. Just return. */
1055
28020
        return;
1056
    }
1057
1058
77407
    if (alpha != 0xff)
1059
    {
1060
1061
29490
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1062
        {
1063
13816
            if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1064
            {
1065
                /* has both compression and alpha */
1066
7447
                _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_compressed_alpha_blend(context, xstart, xend, y, info, alpha);
1067
            }
1068
            else
1069
            {
1070
                /* alpha, no compression */
1071
6369
                _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_alpha_blend(context, xstart, xend, y, info, alpha);
1072
            }
1073
        }
1074
        else
1075
        {
1076
15674
            if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1077
            {
1078
                /* compressed with no alpha */
1079
7687
                _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_compressed_blend(context, xstart, xend, y, info, alpha);
1080
            }
1081
            else
1082
            {
1083
                /* no compression or alpha */
1084
7987
                _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_raw_blend(context, xstart, xend, y, info, alpha);
1085
            }
1086
        }
1087
1088
        /* Data pointer goes to the end of the fill map, move it to the start again. */
1089
29490
        if (info -> current_pixel_ptr >= info -> pixelmap -> gx_pixelmap_data + info -> pixelmap -> gx_pixelmap_data_size)
1090
        {
1091
234
            info -> current_pixel_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_data;
1092
234
            info -> current_aux_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_aux_data;
1093
        }
1094
29490
        return;
1095
    }
1096
#endif
1097
1098
47917
    if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1099
    {
1100
13816
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1101
        {
1102
            /* has both compression and alpha */
1103
7447
            _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_compressed_alpha_write(context, xstart, xend, y, info);
1104
        }
1105
        else
1106
        {
1107
            /* alpha, no compression */
1108
6369
            _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_alpha_write(context, xstart, xend, y, info);
1109
        }
1110
    }
1111
    else
1112
    {
1113
34101
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1114
        {
1115
            /* compressed with no alpha */
1116
7687
            _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_compressed_write(context, xstart, xend, y, info);
1117
        }
1118
        else
1119
        {
1120
            /* no compression or alpha */
1121
26414
            _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_raw_write(context, xstart, xend, y, info);
1122
        }
1123
    }
1124
1125
    /* Data pointers goes to the end of full map, move it to the start again. */
1126
47917
    if (info -> current_pixel_ptr >= info -> pixelmap -> gx_pixelmap_data + info -> pixelmap -> gx_pixelmap_data_size)
1127
    {
1128
291
        info -> current_pixel_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_data;
1129
291
        info -> current_aux_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_aux_data;
1130
    }
1131
}