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: 2024-12-05 08:52:37 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_ARC_DRAWING_SUPPORT)
31
32
#if defined(GX_BRUSH_ALPHA_SUPPORT)
33
34
/**************************************************************************/
35
/*                                                                        */
36
/*  FUNCTION                                               RELEASE        */
37
/*                                                                        */
38
/*    _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_raw_blend*/
39
/*                                                        PORTABLE C      */
40
/*                                                           6.1.3        */
41
/*  AUTHOR                                                                */
42
/*                                                                        */
43
/*    Kenneth Maxwell, Microsoft Corporation                              */
44
/*                                                                        */
45
/*  DESCRIPTION                                                           */
46
/*                                                                        */
47
/*    Internal helper function that handles writing of uncompressed       */
48
/*    pixlemap file without alpha channel with brush alpha.               */
49
/*                                                                        */
50
/*  INPUT                                                                 */
51
/*                                                                        */
52
/*    context                               Drawing context               */
53
/*    xstart                                x-coord of line left          */
54
/*    xend                                  x-coord of line end           */
55
/*    y                                     y-coord of line top           */
56
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
57
/*    alpha                                 Alpha value                   */
58
/*                                                                        */
59
/*  OUTPUT                                                                */
60
/*                                                                        */
61
/*    None                                                                */
62
/*                                                                        */
63
/*  CALLS                                                                 */
64
/*                                                                        */
65
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
66
/*                                            blend function              */
67
/*                                                                        */
68
/*  CALLED BY                                                             */
69
/*                                                                        */
70
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
71
/*                                                                        */
72
/*  RELEASE HISTORY                                                       */
73
/*                                                                        */
74
/*    DATE              NAME                      DESCRIPTION             */
75
/*                                                                        */
76
/*  12-31-2020     Kenneth Maxwell          Initial Version 6.1.3         */
77
/*                                                                        */
78
/**************************************************************************/
79
7987
static VOID _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_raw_blend(GX_DRAW_CONTEXT *context,
80
                                                                                 INT xstart, INT xend, INT y,
81
                                                                                 GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
82
{
83
INT              xval;
84
INT              offset;
85
INT              pic_width;
86
GX_CONST USHORT *get;
87
USHORT           pixel;
88
GX_PIXELMAP     *pixelmap;
89
90
7987
    pixelmap = info -> pixelmap;
91
7987
    pic_width = pixelmap -> gx_pixelmap_height;
92
93
    /* Pick the data pointer to the current row. */
94
7987
    get = (GX_CONST USHORT *)info -> current_pixel_ptr;
95
96

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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