GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_draw.c Lines: 270 270 100.0 %
Date: 2024-12-05 08:52:37 Branches: 178 178 100.0 %

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

7104
    if ((info -> draw) && (xstart <= xend))
93
    {
94
5950
        get = (GX_CONST GX_COLOR *)info -> current_pixel_ptr;
95
96
        /* Calculate the map offset in x-axis. */
97
5950
        offset = (GX_VALUE)(info -> x_offset % pic_width);
98
99
635353
        for (xval = xstart; xval <= xend; xval++)
100
        {
101
102
            /* Get points to the start postion of this row. So we need to calculate its position.  */
103
629403
            color = *(get + offset);
104
105
629403
            if (color & 0xff000000)
106
            {
107
245166
                _gx_display_driver_32argb_pixel_blend(context, xval, y, color, alpha);
108
            }
109
629403
            offset++;
110
629403
            if (offset >= pic_width)
111
            {
112
16291
                offset = (GX_VALUE)(offset - pic_width);
113
            }
114
        }
115
    }
116
117
    /* This line is drawn. Update the pointer position for next row.  */
118
7104
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(GX_COLOR);
119
7104
}
120
121
/**************************************************************************/
122
/*                                                                        */
123
/*  FUNCTION                                               RELEASE        */
124
/*                                                                        */
125
/*    _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_raw_blend */
126
/*                                                                        */
127
/*                                                        PORTABLE C      */
128
/*                                                           6.1.4        */
129
/*  AUTHOR                                                                */
130
/*                                                                        */
131
/*    Kenneth Maxwell, Microsoft Corporation                              */
132
/*                                                                        */
133
/*  DESCRIPTION                                                           */
134
/*                                                                        */
135
/*    Internal helper function that handles writing of raw pixlemap file  */
136
/*      with brush alpha by line.                                         */
137
/*                                                                        */
138
/*  INPUT                                                                 */
139
/*                                                                        */
140
/*    context                               Drawing context               */
141
/*    xstart                                x-coord of line left          */
142
/*    xend                                  x-coord of line right         */
143
/*    y                                     y-coord of line top           */
144
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
145
/*    alpha                                 Alpha value                   */
146
/*                                                                        */
147
/*  OUTPUT                                                                */
148
/*                                                                        */
149
/*    None                                                                */
150
/*                                                                        */
151
/*  CALLS                                                                 */
152
/*                                                                        */
153
/*    _gx_display_driver_32argb_pixel_blend Basic display driver pixel    */
154
/*                                            blend function              */
155
/*                                                                        */
156
/*  CALLED BY                                                             */
157
/*                                                                        */
158
/*    _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_draw      */
159
/*                                                                        */
160
/*  RELEASE HISTORY                                                       */
161
/*                                                                        */
162
/*    DATE              NAME                      DESCRIPTION             */
163
/*                                                                        */
164
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
165
/*                                                                        */
166
/**************************************************************************/
167
8684
static VOID _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_raw_blend(GX_DRAW_CONTEXT *context,
168
                                                                                INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
169
{
170
INT                xval;
171
INT                offset;
172
INT                pic_width;
173
GX_CONST GX_COLOR *get;
174
GX_COLOR           pixel;
175
GX_PIXELMAP       *pixelmap;
176
177
8684
    pixelmap = info -> pixelmap;
178
179
8684
    pic_width = pixelmap -> gx_pixelmap_height;
180
181

8684
    if ((info -> draw) && (xstart <= xend))
182
    {
183
5950
        get = (GX_CONST GX_COLOR *)info -> current_pixel_ptr;
184
185
        /* Calculate map offset in x-axis. */
186
5950
        offset = (info -> x_offset % pic_width);
187
188
635353
        for (xval = xstart; xval <= xend; xval++)
189
        {
190
191
            /* Get points to the start postion of this row. So we need to calculate its position.  */
192
629403
            pixel = *(get + offset);
193
629403
            _gx_display_driver_32argb_pixel_blend(context, xval, y, pixel, alpha);
194
629403
            offset++;
195
629403
            if (offset >= pic_width)
196
            {
197
3998
                offset -= pic_width;
198
            }
199
        }
200
    }
201
202
    /* This line is drawn. Update the pointer position for next row. */
203
8684
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(GX_COLOR);
204
8684
}
205
206
/**************************************************************************/
207
/*                                                                        */
208
/*  FUNCTION                                               RELEASE        */
209
/*                                                                        */
210
/*    _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_          */
211
/*                                                       compressed_blend */
212
/*                                                                        */
213
/*                                                        PORTABLE C      */
214
/*                                                           6.1.4        */
215
/*  AUTHOR                                                                */
216
/*                                                                        */
217
/*    Kenneth Maxwell, Microsoft Corporation                              */
218
/*                                                                        */
219
/*  DESCRIPTION                                                           */
220
/*                                                                        */
221
/*    Internal helper function that handles writing of compressed         */
222
/*    pixlemap file without alpha channel with brush alpha by line.       */
223
/*                                                                        */
224
/*  INPUT                                                                 */
225
/*                                                                        */
226
/*    context                               Drawing context               */
227
/*    xstart                                x-coord of line left          */
228
/*    xend                                  x-coord of line right         */
229
/*    y                                     y-coord of line top           */
230
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
231
/*    alpha                                 Alpha value                   */
232
/*                                                                        */
233
/*  OUTPUT                                                                */
234
/*                                                                        */
235
/*    None                                                                */
236
/*                                                                        */
237
/*  CALLS                                                                 */
238
/*                                                                        */
239
/*    _gx_display_driver_32argb_pixel_blend Basic display driver pixel    */
240
/*                                            blend function              */
241
/*                                                                        */
242
/*  CALLED BY                                                             */
243
/*                                                                        */
244
/*    _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_draw      */
245
/*                                                                        */
246
/*  RELEASE HISTORY                                                       */
247
/*                                                                        */
248
/*    DATE              NAME                      DESCRIPTION             */
249
/*                                                                        */
250
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
251
/*                                                                        */
252
/**************************************************************************/
253
8684
static VOID _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_compressed_blend(GX_DRAW_CONTEXT *context,
254
                                                                                       INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
255
{
256
INT                start_pos;
257
INT                xval;
258
GX_UBYTE           count;
259
GX_COLOR           pixel;
260
GX_PIXELMAP       *pixelmap;
261
8684
GX_CONST GX_COLOR *get = GX_NULL;
262
8684
GX_CONST GX_UBYTE *get_count = GX_NULL;
263
264
8684
    pixelmap = info -> pixelmap;
265
266

8684
    if ((info -> draw) && (xstart <= xend))
267
    {
268
        /* This means it's the draw operation. */
269
        /* Skip the invisible pixels.*/
270
5950
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_height);
271
272
        /* Repeat the draw operation to fill the whole dirty area. */
273
15623
        while (start_pos <= xend)
274
        {
275
9673
            xval = start_pos;
276
277
            /* Start from where we need to repeat. */
278
9673
            get = (GX_CONST GX_COLOR *)info -> current_pixel_ptr;
279
9673
            get_count = (GX_CONST GX_UBYTE *)info -> current_aux_ptr;
280
281
23276
            while (xval < start_pos + pixelmap -> gx_pixelmap_height)
282
            {
283
13603
                count = *get_count++;
284
13603
                if (count & 0x80)
285
                {
286
2025
                    count = (GX_UBYTE)((count & 0x7f) + 1);
287
288
2025
                    pixel = *get++;
289
8805
                    while (count--)
290
                    {
291

6780
                        if (xval >= xstart && xval <= xend)
292
                        {
293
3492
                            _gx_display_driver_32argb_pixel_blend(context, xval, y, pixel, alpha);
294
                        }
295
6780
                        xval++;
296
                    }
297
                }
298
                else
299
                {
300
11578
                    count++;
301
1223596
                    while (count--)
302
                    {
303
1212018
                        pixel = *get++;
304

1212018
                        if (xval >= xstart && xval <= xend)
305
                        {
306
625911
                            _gx_display_driver_32argb_pixel_blend(context, xval, y, pixel, alpha);
307
                        }
308
1212018
                        xval++;
309
                    }
310
                }
311
            }
312
9673
            start_pos += pixelmap -> gx_pixelmap_height;
313
        }
314
    }
315
    else
316
    {
317
        /* Just do skip operation here. */
318
2734
        xval = 0;
319
2734
        get = (GX_CONST GX_COLOR *)info -> current_pixel_ptr;
320
2734
        get_count = (GX_CONST GX_UBYTE *)info -> current_aux_ptr;
321
6338
        while (xval < pixelmap -> gx_pixelmap_height)
322
        {
323
3604
            count = *get_count++;
324
3604
            if (count & 0x80)
325
            {
326
438
                count = (GX_UBYTE)((count & 0x7f) + 1);
327
438
                get++;
328
            }
329
            else
330
            {
331
3166
                count++;
332
3166
                get += count;
333
            }
334
3604
            xval += count;
335
        }
336
    }
337
338
    /* This line is drawn. cache the pointer for next line draw. */
339
8684
    info -> current_pixel_ptr = (GX_UBYTE *)get;
340
8684
    info -> current_aux_ptr = (GX_UBYTE *)get_count;
341
8684
}
342
343
/**************************************************************************/
344
/*                                                                        */
345
/*  FUNCTION                                               RELEASE        */
346
/*                                                                        */
347
/*    _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_          */
348
/*                                                 compressed_alpha_blend */
349
/*                                                                        */
350
/*                                                        PORTABLE C      */
351
/*                                                           6.1.4        */
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 for one line.     */
360
/*                                                                        */
361
/*  INPUT                                                                 */
362
/*                                                                        */
363
/*    context                               Drawing context               */
364
/*    xstart                                x-coord of line left          */
365
/*    xend                                  x-coord of line right         */
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_32argb_pixel_blend Basic display driver pixel    */
377
/*                                            blend function              */
378
/*                                                                        */
379
/*  CALLED BY                                                             */
380
/*                                                                        */
381
/*    _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_draw      */
382
/*                                                                        */
383
/*  RELEASE HISTORY                                                       */
384
/*                                                                        */
385
/*    DATE              NAME                      DESCRIPTION             */
386
/*                                                                        */
387
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
388
/*                                                                        */
389
/**************************************************************************/
390
15848
static VOID _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_compressed_alpha_blend(GX_DRAW_CONTEXT *context,
391
                                                                                             INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info, GX_UBYTE alpha)
392
{
393
INT                xval;
394
GX_UBYTE           count;
395
INT                start_pos;
396
GX_COLOR           pixel;
397
15848
GX_CONST GX_COLOR *get = GX_NULL;
398
15848
GX_CONST GX_UBYTE *get_count = GX_NULL;
399
GX_PIXELMAP       *pixelmap;
400
401
15848
    pixelmap = info -> pixelmap;
402
403

15848
    if ((info -> draw) && (xstart <= xend))
404
    {
405
        /* Calculate draw start position. */
406
11644
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_height);
407
408
        /* Repeat the draw operation to fill the whole dirty area. */
409
35421
        while (start_pos <= xend)
410
        {
411
23777
            xval = start_pos;
412
413
            /* Start from where we need to repeat. */
414
23777
            get = (GX_CONST GX_COLOR *)info -> current_pixel_ptr;
415
23777
            get_count = (GX_CONST GX_UBYTE *)info -> current_aux_ptr;
416
417
140632
            while (xval < start_pos + pixelmap -> gx_pixelmap_height)
418
            {
419
116855
                count = *get_count++;
420
116855
                if (count & 0x80)
421
                {
422
64064
                    count = (GX_UBYTE)((count & 0x7f) + 1);
423
64064
                    pixel = *get++;
424
2186308
                    while (count--)
425
                    {
426
2122244
                        if (pixel & 0xff000000)
427
                        {
428

752542
                            if (xval >= xstart && xval <= xend)
429
                            {
430
330547
                                _gx_display_driver_32argb_pixel_blend(context, xval, y, pixel, alpha);
431
                            }
432
                        }
433
2122244
                        xval++;
434
                    }
435
                }
436
                else
437
                {
438
52791
                    count++;
439
314147
                    while (count--)
440
                    {
441
261356
                        pixel = *get++;
442
261356
                        if (pixel & 0xff000000)
443
                        {
444

222102
                            if (xval >= xstart && xval <= xend)
445
                            {
446
142324
                                _gx_display_driver_32argb_pixel_blend(context, xval, y, pixel, alpha);
447
                            }
448
                        }
449
261356
                        xval++;
450
                    }
451
                }
452
            }
453
23777
            start_pos += pixelmap -> gx_pixelmap_height;
454
        }
455
    }
456
    else
457
    {
458
        /* Just do skip operation here. */
459
4204
        xval = 0;
460
4204
        get = (GX_CONST GX_COLOR *)info -> current_pixel_ptr;
461
4204
        get_count = (GX_CONST GX_UBYTE *)info -> current_aux_ptr;
462
33653
        while (xval < pixelmap -> gx_pixelmap_height)
463
        {
464
29449
            count = *get_count++;
465
29449
            if (count & 0x80)
466
            {
467
16055
                count = (GX_UBYTE)((count & 0x7f) + 1);
468
16055
                get++;
469
            }
470
            else
471
            {
472
13394
                count++;
473
13394
                get += count;
474
            }
475
29449
            xval += count;
476
        }
477
    }
478
479
    /* This line is drawn. cache the pointer for next line draw. */
480
15848
    info -> current_pixel_ptr = (GX_UBYTE *)get;
481
15848
    info -> current_aux_ptr = (GX_UBYTE *)get_count;
482
15848
}
483
#endif
484
485
/**************************************************************************/
486
/*                                                                        */
487
/*  FUNCTION                                               RELEASE        */
488
/*                                                                        */
489
/*    _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_alpha_    */
490
/*                                                                  write */
491
/*                                                                        */
492
/*                                                        PORTABLE C      */
493
/*                                                           6.1.4        */
494
/*  AUTHOR                                                                */
495
/*                                                                        */
496
/*    Kenneth Maxwell, Microsoft Corporation                              */
497
/*                                                                        */
498
/*  DESCRIPTION                                                           */
499
/*                                                                        */
500
/*    Internal helper function that handles writing of uncompressed       */
501
/*    pixlemap file with alpha channel for one line.                      */
502
/*                                                                        */
503
/*  INPUT                                                                 */
504
/*                                                                        */
505
/*    context                               Drawing context               */
506
/*    xstart                                x-coord of line left          */
507
/*    xend                                  x-coord of line right         */
508
/*    y                                     y-coord of line top           */
509
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
510
/*                                                                        */
511
/*  OUTPUT                                                                */
512
/*                                                                        */
513
/*    None                                                                */
514
/*                                                                        */
515
/*  CALLS                                                                 */
516
/*                                                                        */
517
/*    _gx_display_driver_32argb_pixel_blend                               */
518
/*    _gx_display_driver_32argb_pixel_write                               */
519
/*                                                                        */
520
/*  CALLED BY                                                             */
521
/*                                                                        */
522
/*    _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_draw      */
523
/*                                                                        */
524
/*  RELEASE HISTORY                                                       */
525
/*                                                                        */
526
/*    DATE              NAME                      DESCRIPTION             */
527
/*                                                                        */
528
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
529
/*                                                                        */
530
/**************************************************************************/
531
7104
static VOID _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_alpha_write(GX_DRAW_CONTEXT *context,
532
                                                                                  INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
533
{
534
INT                xval;
535
GX_COLOR           color;
536
GX_CONST GX_COLOR *get;
537
UCHAR              alpha_value;
538
GX_PIXELMAP       *pixelmap;
539
GX_VALUE           pic_width;
540
GX_VALUE           offset;
541
542
7104
    pixelmap = info -> pixelmap;
543
544
7104
    pic_width = pixelmap -> gx_pixelmap_height;
545
546

7104
    if ((info -> draw) && (xstart <= xend))
547
    {
548
5950
        get = (GX_CONST GX_COLOR *)info -> current_pixel_ptr;
549
550
        /* Calculate the offset.  */
551
5950
        offset = (GX_VALUE)(info -> x_offset % pic_width);
552
553
635353
        for (xval = xstart; xval <= xend; xval++)
554
        {
555
            /* Get points to the start postion of this row. So we need to calculate its position.  */
556
629403
            color = *(get + offset);
557
629403
            alpha_value = (GX_UBYTE)((color >> 24) & 0xff);
558
629403
            if (alpha_value)
559
            {
560
245166
                if (alpha_value == 255)
561
                {
562
156849
                    _gx_display_driver_32bpp_pixel_write(context, xval, y, color);
563
                }
564
                else
565
                {
566
88317
                    _gx_display_driver_32argb_pixel_blend(context, xval, y, color, 0xff);
567
                }
568
            }
569
629403
            offset++;
570
629403
            if (offset >= pic_width)
571
            {
572
16291
                offset = (GX_VALUE)(offset - pic_width);
573
            }
574
        }
575
    }
576
577
    /* This line is drawn. Update the pointer position for next row.  */
578
7104
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(GX_COLOR);
579
7104
}
580
581
/**************************************************************************/
582
/*                                                                        */
583
/*  FUNCTION                                               RELEASE        */
584
/*                                                                        */
585
/*    _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_raw_write */
586
/*                                                                        */
587
/*                                                        PORTABLE C      */
588
/*                                                           6.1.4        */
589
/*  AUTHOR                                                                */
590
/*                                                                        */
591
/*    Kenneth Maxwell, Microsoft Corporation                              */
592
/*                                                                        */
593
/*  DESCRIPTION                                                           */
594
/*                                                                        */
595
/*    Internal helper function that handles writing of raw pixlemap file  */
596
/*    for one line.                                                       */
597
/*                                                                        */
598
/*  INPUT                                                                 */
599
/*                                                                        */
600
/*    context                               Drawing context               */
601
/*    xstart                                x-coord of line left          */
602
/*    xend                                  x-coord of line right         */
603
/*    y                                     y-coord of line top           */
604
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
605
/*                                                                        */
606
/*  OUTPUT                                                                */
607
/*                                                                        */
608
/*    None                                                                */
609
/*                                                                        */
610
/*  CALLS                                                                 */
611
/*                                                                        */
612
/*    None                                                                */
613
/*                                                                        */
614
/*  CALLED BY                                                             */
615
/*                                                                        */
616
/*    _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_draw      */
617
/*                                                                        */
618
/*  RELEASE HISTORY                                                       */
619
/*                                                                        */
620
/*    DATE              NAME                      DESCRIPTION             */
621
/*                                                                        */
622
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
623
/*                                                                        */
624
/**************************************************************************/
625
8684
static VOID _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_raw_write(GX_DRAW_CONTEXT *context,
626
                                                                                INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
627
{
628
INT                xval;
629
INT                offset;
630
INT                pic_width;
631
GX_CONST GX_COLOR *get;
632
GX_COLOR          *put;
633
GX_PIXELMAP       *pixelmap;
634
635
8684
    pixelmap = info -> pixelmap;
636
637
8684
    pic_width = pixelmap -> gx_pixelmap_height;
638
639

8684
    if ((info -> draw) && (xstart <= xend))
640
    {
641
5950
        get = (GX_CONST GX_COLOR *)info -> current_pixel_ptr;
642
5950
        put = (GX_COLOR *)context -> gx_draw_context_memory;
643
5950
        put += y * context -> gx_draw_context_pitch + xstart;
644
645
        /* Calculate the offset.  */
646
5950
        offset = (info -> x_offset % pic_width);
647
648
635353
        for (xval = xstart; xval <= xend; xval++)
649
        {
650
            /* Get points to the start postion of this row. So we need to calculate its position.  */
651
629403
            *put++ = *(get + offset);
652
629403
            offset++;
653
629403
            if (offset >= pic_width)
654
            {
655
3998
                offset -= pic_width;
656
            }
657
        }
658
    }
659
660
    /* This line is drawn. Update the pointer position for next row.  */
661
8684
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(GX_COLOR);
662
8684
}
663
664
/**************************************************************************/
665
/*                                                                        */
666
/*  FUNCTION                                               RELEASE        */
667
/*                                                                        */
668
/*    _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_          */
669
/*                                                       compressed_write */
670
/*                                                                        */
671
/*                                                        PORTABLE C      */
672
/*                                                           6.1.4        */
673
/*  AUTHOR                                                                */
674
/*                                                                        */
675
/*    Kenneth Maxwell, Microsoft Corporation                              */
676
/*                                                                        */
677
/*  DESCRIPTION                                                           */
678
/*                                                                        */
679
/*    Internal helper function that handles writing of compressed         */
680
/*    pixlemap file without alpha channel for one line.                   */
681
/*                                                                        */
682
/*  INPUT                                                                 */
683
/*                                                                        */
684
/*    context                               Drawing context               */
685
/*    xstart                                x-coord of line left          */
686
/*    xend                                  x-coord of line right         */
687
/*    y                                     y-coord of line top           */
688
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
689
/*                                                                        */
690
/*  OUTPUT                                                                */
691
/*                                                                        */
692
/*    None                                                                */
693
/*                                                                        */
694
/*  CALLS                                                                 */
695
/*                                                                        */
696
/*    None                                                                */
697
/*                                                                        */
698
/*  CALLED BY                                                             */
699
/*                                                                        */
700
/*    _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_draw      */
701
/*                                                                        */
702
/*  RELEASE HISTORY                                                       */
703
/*                                                                        */
704
/*    DATE              NAME                      DESCRIPTION             */
705
/*                                                                        */
706
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
707
/*                                                                        */
708
/**************************************************************************/
709
8684
static VOID _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_compressed_write(GX_DRAW_CONTEXT *context,
710
                                                                                       INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
711
{
712
INT                start_pos;
713
INT                xval;
714
GX_UBYTE           count;
715
GX_COLOR           pixel;
716
8684
GX_CONST GX_COLOR *get = GX_NULL;
717
GX_COLOR          *put;
718
8684
GX_CONST GX_UBYTE *get_count = GX_NULL;
719
GX_PIXELMAP       *pixelmap;
720
721
8684
    pixelmap = info -> pixelmap;
722
723

8684
    if ((info -> draw) && (xstart <= xend))
724
    {
725
        /* Calculate draw start position.  */
726
5950
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_height);
727
728
5950
        put = (GX_COLOR *)context -> gx_draw_context_memory;
729
5950
        put += y * context -> gx_draw_context_pitch + start_pos;
730
731
        /* Repeat the draw operation to fill the whole dirty area.  */
732
15623
        while (start_pos <= xend)
733
        {
734
9673
            xval = start_pos;
735
736
            /* Start from where we need to repeat.  */
737
9673
            get = (GX_CONST GX_COLOR *)info -> current_pixel_ptr;
738
9673
            get_count = (GX_CONST GX_UBYTE *)info -> current_aux_ptr;
739
740
23276
            while (xval < start_pos + pixelmap -> gx_pixelmap_height)
741
            {
742
13603
                count = *get_count++;
743
13603
                if (count & 0x80)
744
                {
745
2025
                    count = (GX_UBYTE)((count & 0x7f) + 1);
746
747
2025
                    pixel = *get++;
748
8805
                    while (count--)
749
                    {
750

6780
                        if (xval >= xstart && xval <= xend)
751
                        {
752
3492
                            *put = pixel;
753
                        }
754
6780
                        xval++;
755
6780
                        put++;
756
                    }
757
                }
758
                else
759
                {
760
11578
                    count++;
761
1223596
                    while (count--)
762
                    {
763
1212018
                        pixel = *get++;
764

1212018
                        if (xval >= xstart && xval <= xend)
765
                        {
766
625911
                            *put = pixel;
767
                        }
768
1212018
                        xval++;
769
1212018
                        put++;
770
                    }
771
                }
772
            }
773
9673
            start_pos += pixelmap -> gx_pixelmap_height;
774
        }
775
    }
776
    else
777
    {
778
        /* Just do skip operation here.  */
779
2734
        xval = 0;
780
2734
        get = (GX_CONST GX_COLOR *)info -> current_pixel_ptr;
781
2734
        get_count = (GX_CONST GX_UBYTE *)info -> current_aux_ptr;
782
6338
        while (xval < pixelmap -> gx_pixelmap_height)
783
        {
784
3604
            count = *get_count++;
785
3604
            if (count & 0x80)
786
            {
787
438
                count = (GX_UBYTE)((count & 0x7f) + 1);
788
438
                get++;
789
            }
790
            else
791
            {
792
3166
                count++;
793
3166
                get += count;
794
            }
795
3604
            xval += count;
796
        }
797
    }
798
799
    /* This line is drawn. cache the pointer for next line draw.  */
800
8684
    info -> current_pixel_ptr = (GX_UBYTE *)get;
801
8684
    info -> current_aux_ptr = (GX_UBYTE *)get_count;
802
8684
}
803
804
/**************************************************************************/
805
/*                                                                        */
806
/*  FUNCTION                                               RELEASE        */
807
/*                                                                        */
808
/*    _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_          */
809
/*                                                 compressed_alpha_write */
810
/*                                                                        */
811
/*                                                        PORTABLE C      */
812
/*                                                           6.1.4        */
813
/*  AUTHOR                                                                */
814
/*                                                                        */
815
/*    Kenneth Maxwell, Microsoft Corporation                              */
816
/*                                                                        */
817
/*  DESCRIPTION                                                           */
818
/*                                                                        */
819
/*    Internal helper function that handles writing of compressed         */
820
/*    pixlemap file with alpha channel.                                   */
821
/*                                                                        */
822
/*  INPUT                                                                 */
823
/*                                                                        */
824
/*    context                               Drawing context               */
825
/*    xstart                                x-coord of line left          */
826
/*    xend                                  x-coord of line right         */
827
/*    y                                     y-coord of line top           */
828
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
829
/*                                                                        */
830
/*  OUTPUT                                                                */
831
/*                                                                        */
832
/*    None                                                                */
833
/*                                                                        */
834
/*  CALLS                                                                 */
835
/*                                                                        */
836
/*    _gx_display_driver_32argb_pixel_blend                               */
837
/*    _gx_display_driver_32argb_pixel_write                               */
838
/*                                                                        */
839
/*  CALLED BY                                                             */
840
/*                                                                        */
841
/*    _gx_display_driver_32bpp_horizontal_pixelmap_line_draw              */
842
/*                                                                        */
843
/*  RELEASE HISTORY                                                       */
844
/*                                                                        */
845
/*    DATE              NAME                      DESCRIPTION             */
846
/*                                                                        */
847
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
848
/*                                                                        */
849
/**************************************************************************/
850
15848
static VOID _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_compressed_alpha_write(GX_DRAW_CONTEXT *context,
851
                                                                                             INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
852
{
853
INT                xval;
854
GX_UBYTE           count;
855
INT                start_pos;
856
GX_UBYTE           alpha_value;
857
GX_COLOR           pixel;
858
15848
GX_CONST GX_COLOR *get = GX_NULL;
859
15848
GX_CONST GX_UBYTE *get_count = GX_NULL;
860
GX_PIXELMAP       *pixelmap;
861
862
15848
    pixelmap = info -> pixelmap;
863
864

15848
    if ((info -> draw) && (xstart <= xend))
865
    {
866
        /* Calculate draw start position.  */
867
11644
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_height);
868
869
        /* Repeat the draw operation to fill the whole dirty area.  */
870
35421
        while (start_pos <= xend)
871
        {
872
23777
            xval = start_pos;
873
874
            /* Start from where we need to repeat.  */
875
23777
            get = (GX_CONST GX_COLOR *)info -> current_pixel_ptr;
876
23777
            get_count = (GX_CONST GX_UBYTE *)info -> current_aux_ptr;
877
878
140632
            while (xval < start_pos + pixelmap -> gx_pixelmap_height)
879
            {
880
116855
                count = *get_count++;
881
116855
                if (count & 0x80)
882
                {
883
64064
                    count = (GX_UBYTE)((count & 0x7f) + 1);
884
64064
                    pixel = *get++;
885
64064
                    alpha_value = (GX_UBYTE)((pixel >> 24) & 0xff);
886
2186308
                    while (count--)
887
                    {
888
2122244
                        if (alpha_value)
889
                        {
890

752542
                            if (xval >= xstart && xval <= xend)
891
                            {
892
330547
                                _gx_display_driver_32argb_pixel_blend(context, xval, y, pixel, 0xff);
893
                            }
894
                        }
895
2122244
                        xval++;
896
                    }
897
                }
898
                else
899
                {
900
52791
                    count++;
901
314147
                    while (count--)
902
                    {
903
261356
                        pixel = *get++;
904
261356
                        alpha_value = (GX_UBYTE)((pixel >> 24) & 0xff);
905
261356
                        if (alpha_value)
906
                        {
907

222102
                            if (xval >= xstart && xval <= xend)
908
                            {
909
142324
                                if (alpha_value == 0xff)
910
                                {
911
59799
                                    _gx_display_driver_32bpp_pixel_write(context, xval, y, pixel);
912
                                }
913
                                else
914
                                {
915
82525
                                    _gx_display_driver_32argb_pixel_blend(context, xval, y, pixel, 0xff);
916
                                }
917
                            }
918
                        }
919
261356
                        xval++;
920
                    }
921
                }
922
            }
923
23777
            start_pos += pixelmap -> gx_pixelmap_height;
924
        }
925
    }
926
    else
927
    {
928
        /* Just do skip operation here.  */
929
4204
        xval = 0;
930
4204
        get = (GX_CONST GX_COLOR *)info -> current_pixel_ptr;
931
4204
        get_count = (GX_CONST GX_UBYTE *)info -> current_aux_ptr;
932
33653
        while (xval < pixelmap -> gx_pixelmap_height)
933
        {
934
29449
            count = *get_count++;
935
29449
            if (count & 0x80)
936
            {
937
16055
                count = (GX_UBYTE)((count & 0x7f) + 1);
938
16055
                get++;
939
            }
940
            else
941
            {
942
13394
                count++;
943
13394
                get += count;
944
            }
945
29449
            xval += count;
946
        }
947
    }
948
949
    /* This line is drawn. cache the pointer for next line draw.  */
950
15848
    info -> current_pixel_ptr = (GX_UBYTE *)get;
951
15848
    info -> current_aux_ptr = (GX_UBYTE *)get_count;
952
15848
}
953
954
/**************************************************************************/
955
/*                                                                        */
956
/*  FUNCTION                                               RELEASE        */
957
/*                                                                        */
958
/*    _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_draw      */
959
/*                                                                        */
960
/*                                                        PORTABLE C      */
961
/*                                                           6.1.4        */
962
/*  AUTHOR                                                                */
963
/*                                                                        */
964
/*    Kenneth Maxwell, Microsoft Corporation                              */
965
/*                                                                        */
966
/*  DESCRIPTION                                                           */
967
/*                                                                        */
968
/*    32bpp screen driver horizontal pixelmap line drawing function that  */
969
/*    handles compressed or uncompress, with or without alpha channel.    */
970
/*                                                                        */
971
/*  INPUT                                                                 */
972
/*                                                                        */
973
/*    context                               Drawing context               */
974
/*    xstart                                x-coord of line left          */
975
/*    xend                                  x-coord of line right         */
976
/*    y                                     y-coord of line top           */
977
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
978
/*                                                                        */
979
/*  OUTPUT                                                                */
980
/*                                                                        */
981
/*    None                                                                */
982
/*                                                                        */
983
/*  CALLS                                                                 */
984
/*                                                                        */
985
/*     _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_         */
986
/*                                                 compressed_alpha_blend */
987
/*     _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_alpha_   */
988
/*                                                                  write */
989
/*     _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_         */
990
/*                                                       compressed_write */
991
/*     _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_raw_write*/
992
/*     _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_c_a_blend*/
993
/*     _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_a_blend  */
994
/*     _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_c_blend  */
995
/*     _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_raw_blend*/
996
/*                                                                        */
997
/*  CALLED BY                                                             */
998
/*                                                                        */
999
/*    GUIX Internal Code                                                  */
1000
/*                                                                        */
1001
/*  RELEASE HISTORY                                                       */
1002
/*                                                                        */
1003
/*    DATE              NAME                      DESCRIPTION             */
1004
/*                                                                        */
1005
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
1006
/*                                                                        */
1007
/**************************************************************************/
1008
119595
VOID _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_draw(GX_DRAW_CONTEXT *context,
1009
                                                                    INT ystart, INT yend, INT x, GX_FILL_PIXELMAP_INFO *info)
1010
{
1011
INT xstart;
1012
INT xend;
1013
INT y;
1014
1015
119595
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
1016
    {
1017
78651
        xstart = ystart;
1018
78651
        xend = yend;
1019
78651
        y = context -> gx_draw_context_canvas -> gx_canvas_x_resolution - x - 1;
1020
    }
1021
    else
1022
    {
1023
40944
        xstart = context -> gx_draw_context_canvas -> gx_canvas_y_resolution - yend - 1;
1024
40944
        xend = context -> gx_draw_context_canvas -> gx_canvas_y_resolution - ystart - 1;
1025
40944
        y = x;
1026
40944
        info -> x_offset = (yend - ystart + 1 + info -> x_offset) % info -> pixelmap -> gx_pixelmap_height;
1027
1028
40944
        if (info -> x_offset)
1029
        {
1030
38589
            info -> x_offset = info -> pixelmap -> gx_pixelmap_height - info -> x_offset;
1031
        }
1032
}
1033
1034
#if defined GX_BRUSH_ALPHA_SUPPORT
1035
GX_UBYTE alpha;
1036
1037
119595
    alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1038

119595
    if ((alpha == 0) || (info -> pixelmap == GX_NULL))
1039
    {
1040
        /* Nothing to drawn. Just return.  */
1041
38955
        return;
1042
    }
1043
1044
80640
    if (alpha != 0xff)
1045
    {
1046
40320
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1047
        {
1048
24532
            if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1049
            {
1050
                /* Compressed, with alpha channel.  */
1051
15848
                _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_compressed_alpha_blend(context, xstart, xend, y, info, alpha);
1052
            }
1053
            else
1054
            {
1055
                /* Compressed, without alpha channel.  */
1056
8684
                _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_compressed_blend(context, xstart, xend, y, info, alpha);
1057
            }
1058
        }
1059
        else
1060
        {
1061
15788
            if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1062
            {
1063
                /* No compression, with alpha channel.  */
1064
7104
                _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_alpha_blend(context, xstart, xend, y, info, alpha);
1065
            }
1066
            else
1067
            {
1068
                /* No compression without alpha channel.  */
1069
8684
                _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_raw_blend(context, xstart, xend, y, info, alpha);
1070
            }
1071
        }
1072
1073
        /* Current pixelmap has gone over, so the offset pointer should be reset.  */
1074
40320
        if (info -> current_pixel_ptr >= info -> pixelmap -> gx_pixelmap_data + info -> pixelmap -> gx_pixelmap_data_size)
1075
        {
1076
361
            info -> current_pixel_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_data;
1077
361
            info -> current_aux_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_aux_data;
1078
        }
1079
40320
        return;
1080
    }
1081
1082
#endif
1083
1084
40320
    if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1085
    {
1086
24532
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1087
        {
1088
            /* Compressed, with alpha channel.  */
1089
15848
            _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_compressed_alpha_write(context, xstart, xend, y, info);
1090
        }
1091
        else
1092
        {
1093
            /* Compressed, without alpha channel.  */
1094
8684
            _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_compressed_write(context, xstart, xend, y, info);
1095
        }
1096
    }
1097
    else
1098
    {
1099
15788
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1100
        {
1101
            /* No compression, with alpha channel.  */
1102
7104
            _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_alpha_write(context, xstart, xend, y, info);
1103
        }
1104
        else
1105
        {
1106
            /* No compression, without alpha channel.  */
1107
8684
            _gx_display_driver_32bpp_rotated_horizontal_pixelmap_line_raw_write(context, xstart, xend, y, info);
1108
        }
1109
    }
1110
1111
    /* Current pixelmap has gone over, so the offset pointer should be reset.  */
1112
40320
    if (info -> current_pixel_ptr >= info -> pixelmap -> gx_pixelmap_data + info -> pixelmap -> gx_pixelmap_data_size)
1113
    {
1114
361
        info -> current_pixel_ptr = (GX_UBYTE *)info ->  pixelmap -> gx_pixelmap_data;
1115
361
        info -> current_aux_ptr = (GX_UBYTE *)info ->  pixelmap -> gx_pixelmap_aux_data;
1116
    }
1117
}
1118