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: 2026-03-06 19:21:09 Branches: 168 168 100.0 %

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

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

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

7687
    if ((info -> draw) && (xstart <= xend))
257
    {
258
        /* Calculate draw start position. */
259
5233
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_height);
260
261
11476
        while (start_pos <= xend)
262
        {
263
6243
            xval = start_pos;
264
265
            /*Start from where we need to repeat.*/
266
6243
            get = (GX_CONST USHORT *)info -> current_pixel_ptr;
267
268
178349
            while (xval < start_pos + pixelmap -> gx_pixelmap_height)
269
            {
270
172106
                count = *get++;
271
172106
                if (count & 0x8000)
272
                {
273
98234
                    count = (USHORT)((count & 0x7fff) + 1);
274
98234
                    pixel = *get++;
275
957049
                    while (count--)
276
                    {
277

858815
                        if (xval >= xstart && xval <= xend)
278
                        {
279
272330
                            blend_func(context, xval, y, pixel, alpha);
280
                        }
281
858815
                        xval++;
282
                    }
283
                }
284
                else
285
                {
286
73872
                    count++;
287
881938
                    while (count--)
288
                    {
289
808066
                        pixel = *get++;
290

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

7447
    if ((info -> draw) && (xstart <= xend))
384
    {
385
        /* Calculate the draw start position. */
386
5233
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_height);
387
388
13163
        while (start_pos <= xend)
389
        {
390
7930
            xval = start_pos;
391
392
            /*Start from where we need to repeat.*/
393
7930
            get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
394
53418
            while (xval < start_pos + pixelmap -> gx_pixelmap_height)
395
            {
396
45488
                count = *get;
397
45488
                if (count & 0x80)
398
                {
399
25674
                    count = (GX_UBYTE)((count & 0x7f) + 1u);
400
25674
                    falpha = *(get + 1);
401
25674
                    combined_alpha = (GX_UBYTE)(falpha * alpha / 255);
402
25674
                    if (combined_alpha)
403
                    {
404
9773
                        get += 2;
405
9773
                        getpixel = (GX_CONST USHORT *)get;
406
9773
                        pixel = *getpixel;
407
9773
                        get += 2;
408
409
442649
                        while (count--)
410
                        {
411

432876
                            if (xval >= xstart && xval <= xend)
412
                            {
413
181998
                                blend_func(context, xval, y, pixel, combined_alpha);
414
                            }
415
432876
                            xval++;
416
                        }
417
                    }
418
                    else
419
                    {
420
15901
                        get += 4;
421
15901
                        xval += count;
422
                    }
423
                }
424
                else
425
                {
426
19814
                    count++;
427
73897
                    while (count--)
428
                    {
429

54083
                        if (xval >= xstart && xval <= xend)
430
                        {
431
23647
                            falpha = *(get + 1);
432
23647
                            combined_alpha = (GX_UBYTE)(falpha * alpha / 255);
433
23647
                            get += 2;
434
23647
                            getpixel = (USHORT *)get;
435
23647
                            pixel = *getpixel;
436
23647
                            get += 2;
437
23647
                            blend_func(context, xval, y, pixel, combined_alpha);
438
                        }
439
                        else
440
                        {
441
30436
                            get += 4;
442
                        }
443
54083
                        xval++;
444
                    }
445
                }
446
            }
447
7930
            start_pos += pixelmap -> gx_pixelmap_height;
448
        }
449
    }
450
    else
451
    {
452
        /* Skip this line. */
453
2214
        xval = 0;
454
2214
        get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
455
18049
        while (xval < pixelmap -> gx_pixelmap_height)
456
        {
457
15835
            count = *get;
458
15835
            if (count & 0x80)
459
            {
460
8737
                count = (GX_UBYTE)((count & 0x7f) + 1);
461
8737
                get += 4;
462
            }
463
            else
464
            {
465
7098
                count++;
466
7098
                get += count * 4;
467
            }
468
15835
            xval += count;
469
        }
470
    }
471
472
    /* Update data pointer for the next line. */
473
7447
    info -> current_pixel_ptr = (GX_UBYTE *)get;
474
7447
}
475
476
#endif /* GX_BRUSH_ALPHA_SUPPORT */
477
478
/**************************************************************************/
479
/*                                                                        */
480
/*  FUNCTION                                               RELEASE        */
481
/*                                                                        */
482
/*    _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_raw_write*/
483
/*                                                        PORTABLE C      */
484
/*                                                           6.1.3        */
485
/*  AUTHOR                                                                */
486
/*                                                                        */
487
/*    Kenneth Maxwell, Microsoft Corporation                              */
488
/*                                                                        */
489
/*  DESCRIPTION                                                           */
490
/*                                                                        */
491
/*    Internal helper function that handles writing of uncompressed       */
492
/*    pixlemap file without alpha channel.                                */
493
/*                                                                        */
494
/*  INPUT                                                                 */
495
/*                                                                        */
496
/*    context                               Drawing context               */
497
/*    xstart                                x-coord of line left          */
498
/*    xend                                  x-coord of line end           */
499
/*    y                                     y-coord of line top           */
500
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
501
/*                                                                        */
502
/*  OUTPUT                                                                */
503
/*                                                                        */
504
/*    None                                                                */
505
/*                                                                        */
506
/*  CALLS                                                                 */
507
/*                                                                        */
508
/*    None                                                                */
509
/*                                                                        */
510
/*  CALLED BY                                                             */
511
/*                                                                        */
512
/*    _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_draw     */
513
/*                                                                        */
514
/**************************************************************************/
515
26414
static VOID _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_raw_write(GX_DRAW_CONTEXT *context,
516
                                                                                 INT xstart, INT xend, INT y,
517
                                                                                 GX_FILL_PIXELMAP_INFO *info)
518
{
519
INT              xval;
520
INT              offset;
521
INT              pic_width;
522
26414
GX_CONST USHORT *get = GX_NULL;
523
USHORT          *put;
524
GX_PIXELMAP     *pixelmap;
525
526
26414
    pixelmap = info -> pixelmap;
527
528
26414
    pic_width = pixelmap -> gx_pixelmap_height;
529
530
    /* Pickup data pointer for the current line. */
531
26414
    get = (GX_CONST USHORT *)info -> current_pixel_ptr;
532
533

26414
    if ((info -> draw) && (xstart <= xend))
534
    {
535
18071
        put = (USHORT *)context -> gx_draw_context_memory;
536
18071
        put += y * context -> gx_draw_context_pitch;
537
18071
        put += xstart;
538
539
        /*calculate the offset.*/
540
18071
        offset = (info -> x_offset % pic_width);
541
542
3238740
        for (xval = xstart; xval <= xend; xval++)
543
        {
544
3220669
            *put++ = *(get + offset);
545
3220669
            offset++;
546
547
3220669
            if (offset >= pic_width)
548
            {
549
22692
                offset -= pic_width;
550
            }
551
        }
552
    }
553
554
    /* Update data pointer for the next line. */
555
26414
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
556
26414
}
557
558
/**************************************************************************/
559
/*                                                                        */
560
/*  FUNCTION                                               RELEASE        */
561
/*                                                                        */
562
/*    _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_alpha_   */
563
/*                                                                  write */
564
/*                                                        PORTABLE C      */
565
/*                                                           6.1.3        */
566
/*  AUTHOR                                                                */
567
/*                                                                        */
568
/*    Kenneth Maxwell, Microsoft Corporation                              */
569
/*                                                                        */
570
/*  DESCRIPTION                                                           */
571
/*                                                                        */
572
/*    Internal helper function that handles writing of uncompressed       */
573
/*    pixlemap file with alpha channel.                                   */
574
/*                                                                        */
575
/*  INPUT                                                                 */
576
/*                                                                        */
577
/*    context                               Drawing context               */
578
/*    xstart                                x-coord of line left          */
579
/*    xend                                  x-coord of line end           */
580
/*    y                                     y-coord of line top           */
581
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
582
/*                                                                        */
583
/*  OUTPUT                                                                */
584
/*                                                                        */
585
/*    None                                                                */
586
/*                                                                        */
587
/*  CALLS                                                                 */
588
/*                                                                        */
589
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
590
/*                                            blend function              */
591
/*    [gx_display_driver_pixel_write]       Basic display driver pixel    */
592
/*                                            write function              */
593
/*                                                                        */
594
/*  CALLED BY                                                             */
595
/*                                                                        */
596
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
597
/*                                                                        */
598
/**************************************************************************/
599
6369
static VOID _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_alpha_write(GX_DRAW_CONTEXT *context,
600
                                                                                   INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
601
{
602
INT                xval;
603
GX_CONST USHORT   *get;
604
GX_CONST GX_UBYTE *getalpha;
605
USHORT             color;
606
GX_UBYTE           alpha;
607
GX_PIXELMAP       *pixelmap;
608
INT                pic_width;
609
INT                offset;
610
611
6369
    pixelmap = info -> pixelmap;
612
613
6369
    pic_width = pixelmap -> gx_pixelmap_height;
614

6369
    if ((info -> draw) && (xstart <= xend))
615
    {
616
        /* Pick up data pointers to the current line. */
617
5233
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
618
5233
        getalpha = (GX_CONST GX_UBYTE *)info -> current_aux_ptr;
619
620
        /* calculate map offset in x-axis. */
621
5233
        offset = (info -> x_offset % pic_width);
622
623
533102
        for (xval = xstart; xval <= xend; xval++)
624
        {
625
527869
            color = *(get + offset);
626
527869
            alpha = *(getalpha + offset);
627
628
527869
            _gx_display_driver_565rgb_pixel_blend(context, xval, y, color, alpha);
629
630
527869
            offset++;
631
527869
            if (offset >= pic_width)
632
            {
633
13598
                offset -= pic_width;
634
            }
635
        }
636
    }
637
638
    /* Update data pointers for the next line. */
639
6369
    info -> current_pixel_ptr += (UINT)pic_width * sizeof(USHORT);
640
6369
    info -> current_aux_ptr += (UINT)pic_width * sizeof(GX_UBYTE);
641
6369
}
642
643
/**************************************************************************/
644
/*                                                                        */
645
/*  FUNCTION                                               RELEASE        */
646
/*                                                                        */
647
/*    _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_         */
648
/*                                                       compressed_write */
649
/*                                                        PORTABLE C      */
650
/*                                                           6.1.3        */
651
/*  AUTHOR                                                                */
652
/*                                                                        */
653
/*    Kenneth Maxwell, Microsoft Corporation                              */
654
/*                                                                        */
655
/*  DESCRIPTION                                                           */
656
/*                                                                        */
657
/*    Internal helper function that handles writing of compressed         */
658
/*    pixlemap file without alpha channel.                                */
659
/*                                                                        */
660
/*  INPUT                                                                 */
661
/*                                                                        */
662
/*    context                               Drawing context               */
663
/*    xstart                                x-coord of line left          */
664
/*    xend                                  x-coord of line end           */
665
/*    y                                     y-coord of line top           */
666
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
667
/*                                                                        */
668
/*  OUTPUT                                                                */
669
/*                                                                        */
670
/*    None                                                                */
671
/*                                                                        */
672
/*  CALLS                                                                 */
673
/*                                                                        */
674
/*    None                                                                */
675
/*                                                                        */
676
/*  CALLED BY                                                             */
677
/*                                                                        */
678
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
679
/*                                                                        */
680
/**************************************************************************/
681
7687
static VOID _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_compressed_write(GX_DRAW_CONTEXT *context,
682
                                                                                        INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
683
{
684
INT              start_pos;
685
INT              xval;
686
USHORT           count;
687
USHORT           pixel;
688
7687
GX_CONST USHORT *get = GX_NULL;
689
USHORT          *put;
690
GX_PIXELMAP     *pixelmap;
691
692
7687
    pixelmap = info -> pixelmap;
693
694

7687
    if ((info -> draw) && (xstart <= xend))
695
    {
696
        /* Calculate draw start position. */
697
5233
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_height);
698
699
5233
        put = (USHORT *)context -> gx_draw_context_memory;
700
5233
        put += y * context -> gx_draw_context_pitch + start_pos;
701
702
        /*Repeat the draw operation to fill the whole dirty area.*/
703
11476
        while (start_pos <= xend)
704
        {
705
6243
            xval = start_pos;
706
707
            /*Start from where we need to repeat.*/
708
6243
            get = (GX_CONST USHORT *)info -> current_pixel_ptr;
709
710
178349
            while (xval < start_pos + pixelmap -> gx_pixelmap_height)
711
            {
712
172106
                count = *get++;
713
172106
                if (count & 0x8000)
714
                {
715
98234
                    count = (USHORT)((count & 0x7fff) + 1);
716
98234
                    pixel = *get++;
717
957049
                    while (count--)
718
                    {
719

858815
                        if (xval >= xstart && xval <= xend)
720
                        {
721
272330
                            *put = pixel;
722
                        }
723
858815
                        xval++;
724
858815
                        put++;
725
                    }
726
                }
727
                else
728
                {
729
73872
                    count++;
730
881938
                    while (count--)
731
                    {
732
808066
                        pixel = *get++;
733

808066
                        if (xval >= xstart && xval <= xend)
734
                        {
735
255539
                            *put = pixel;
736
                        }
737
808066
                        xval++;
738
808066
                        put++;
739
                    }
740
                }
741
            }
742
6243
            start_pos += pixelmap -> gx_pixelmap_height;
743
        }
744
    }
745
    else
746
    {
747
2454
        xval = 0;
748
2454
        get = (GX_CONST USHORT *)info -> current_pixel_ptr;
749
75269
        while (xval < pixelmap -> gx_pixelmap_height)
750
        {
751
72815
            count = *get++;
752
72815
            if (count & 0x8000)
753
            {
754
41241
                count = (USHORT)((count & 0x7fff) + 1);
755
41241
                get++;
756
            }
757
            else
758
            {
759
31574
                count++;
760
31574
                get += count;
761
            }
762
72815
            xval += count;
763
        }
764
    }
765
766
    /* Update data pointer for the next line. */
767
7687
    info -> current_pixel_ptr = (GX_UBYTE *)get;
768
7687
}
769
770
/**************************************************************************/
771
/*                                                                        */
772
/*  FUNCTION                                               RELEASE        */
773
/*                                                                        */
774
/*    _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_c_a_write*/
775
/*                                                        PORTABLE C      */
776
/*                                                           6.1.3        */
777
/*  AUTHOR                                                                */
778
/*                                                                        */
779
/*    Kenneth Maxwell, Microsoft Corporation                              */
780
/*                                                                        */
781
/*  DESCRIPTION                                                           */
782
/*                                                                        */
783
/*    Internal helper function that handles writing of compressed         */
784
/*    pixlemap file with alpha channel.                                   */
785
/*                                                                        */
786
/*  INPUT                                                                 */
787
/*                                                                        */
788
/*    context                               Drawing context               */
789
/*    xstart                                x-coord of line left          */
790
/*    xend                                  x-coord of line end           */
791
/*    y                                     y-coord of line top           */
792
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
793
/*                                                                        */
794
/*  OUTPUT                                                                */
795
/*                                                                        */
796
/*    None                                                                */
797
/*                                                                        */
798
/*  CALLS                                                                 */
799
/*                                                                        */
800
/*    [gx_display_driver_pixel_blend]       Basic display driver pixel    */
801
/*                                            blend function              */
802
/*                                                                        */
803
/*  CALLED BY                                                             */
804
/*                                                                        */
805
/*    _gx_display_driver_565rgb_horizontal_pixelmap_line_draw             */
806
/*                                                                        */
807
/**************************************************************************/
808
7447
static VOID _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_compressed_alpha_write(GX_DRAW_CONTEXT *context,
809
                                                                                              INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info)
810
{
811
INT                xval;
812
GX_UBYTE           count;
813
INT                start_pos;
814
GX_UBYTE           alpha;
815
USHORT             pixel;
816
7447
GX_CONST GX_UBYTE *get = GX_NULL;
817
GX_CONST USHORT   *getpixel;
818
GX_PIXELMAP       *pixelmap;
819
VOID               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
820
821
7447
    pixelmap = info -> pixelmap;
822
7447
    blend_func = _gx_display_driver_565rgb_pixel_blend;
823
824

7447
    if ((info -> draw) && (xstart <= xend))
825
    {
826
        /* Calculate draw start position. */
827
5233
        start_pos = xstart - (info -> x_offset % pixelmap -> gx_pixelmap_height);
828
829
        /* Repeat the draw operation to fill the whole dirty area. */
830
13163
        while (start_pos <= xend)
831
        {
832
7930
            xval = start_pos;
833
834
            /* Start from where we need to repeat. */
835
7930
            get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
836
53418
            while (xval < start_pos + pixelmap -> gx_pixelmap_height)
837
            {
838
45488
                count = *get;
839
45488
                if (count & 0x80)
840
                {
841
25674
                    count = (GX_UBYTE)((count & 0x7f) + 1u);
842
25674
                    alpha = *(get + 1);
843
25674
                    if (alpha)
844
                    {
845
9773
                        get += 2;
846
847
9773
                        getpixel = (GX_CONST USHORT *)get;
848
9773
                        pixel = *getpixel;
849
9773
                        get += 2;
850
851
442649
                        while (count--)
852
                        {
853

432876
                            if (xval >= xstart && xval <= xend)
854
                            {
855
181998
                                blend_func(context, xval, y, pixel, alpha);
856
                            }
857
432876
                            xval++;
858
                        }
859
                    }
860
                    else
861
                    {
862
15901
                        get += 4;
863
15901
                        xval += count;
864
                    }
865
                }
866
                else
867
                {
868
19814
                    count++;
869
73897
                    while (count--)
870
                    {
871

54083
                        if (xval >= xstart && xval <= xend)
872
                        {
873
23647
                            alpha = *(get + 1);
874
23647
                            get += 2;
875
23647
                            getpixel = (USHORT *)get;
876
23647
                            pixel = *getpixel;
877
23647
                            get += 2;
878
23647
                            blend_func(context, xval, y, pixel, alpha);
879
                        }
880
                        else
881
                        {
882
30436
                            get += 4;
883
                        }
884
54083
                        xval++;
885
                    }
886
                }
887
            }
888
7930
            start_pos += pixelmap -> gx_pixelmap_height;
889
        }
890
    }
891
    else
892
    {
893
        /* Just do skip operation here. */
894
2214
        xval = 0;
895
2214
        get = (GX_CONST GX_UBYTE *)info -> current_pixel_ptr;
896
18049
        while (xval < pixelmap -> gx_pixelmap_height)
897
        {
898
15835
            count = *get;
899
15835
            if (count & 0x80)
900
            {
901
8737
                count = (GX_UBYTE)((count & 0x7f) + 1);
902
8737
                get += 4;
903
            }
904
            else
905
            {
906
7098
                count++;
907
7098
                get += count * 4;
908
            }
909
15835
            xval += count;
910
        }
911
    }
912
913
    /* Update data pinter for the next line. */
914
7447
    info -> current_pixel_ptr = (GX_UBYTE *)get;
915
7447
}
916
917
/**************************************************************************/
918
/*                                                                        */
919
/*  FUNCTION                                               RELEASE        */
920
/*                                                                        */
921
/*    _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_draw     */
922
/*                                                        PORTABLE C      */
923
/*                                                           6.1.3        */
924
/*  AUTHOR                                                                */
925
/*                                                                        */
926
/*    Kenneth Maxwell, Microsoft Corporation                              */
927
/*                                                                        */
928
/*  DESCRIPTION                                                           */
929
/*                                                                        */
930
/*    565rgb screen driver pixelmap drawing function that handles         */
931
/*    compressed or uncompress, with or without alpha channel.            */
932
/*                                                                        */
933
/*  INPUT                                                                 */
934
/*                                                                        */
935
/*    context                               Drawing context               */
936
/*    ystart                                y-coord of line top           */
937
/*    yend                                  y-coord of line bottom        */
938
/*    x                                     x-coord of line left          */
939
/*    info                                  GX_FILL_PIXELMAP_INFO struct  */
940
/*                                                                        */
941
/*  OUTPUT                                                                */
942
/*                                                                        */
943
/*    None                                                                */
944
/*                                                                        */
945
/*  CALLS                                                                 */
946
/*                                                                        */
947
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_c_a_blend       */
948
/*                                          Real pixelmap blend function  */
949
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_alpha_blend     */
950
/*                                          Real pixelmap blend function  */
951
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_c_blend         */
952
/*                                          Real pixelmap blend function  */
953
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_raw_blend       */
954
/*                                          Real pixelmap blend function  */
955
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_c_a_write       */
956
/*                                          Real pixelmap write function  */
957
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_alpha_write     */
958
/*                                          Real pixelmap write function  */
959
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_c_write         */
960
/*                                          Real pixelmap write function  */
961
/*     _gx_display_driver_565rgb_horizontal_pixelmap_line_raw_write       */
962
/*                                          Real pixelmap write function  */
963
/*                                                                        */
964
/*  CALLED BY                                                             */
965
/*                                                                        */
966
/*    GUIX Internal Code                                                  */
967
/*                                                                        */
968
/**************************************************************************/
969
105427
VOID _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_draw(GX_DRAW_CONTEXT *context,
970
                                                                     INT ystart, INT yend, INT x, GX_FILL_PIXELMAP_INFO *info)
971
{
972
INT      xstart;
973
INT      xend;
974
INT      y;
975
976
105427
    if (context -> gx_draw_context_display->gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
977
    {
978
70927
        xstart = ystart;
979
70927
        xend = yend;
980
70927
        y = context -> gx_draw_context_canvas->gx_canvas_x_resolution - x - 1;
981
    }
982
    else
983
    {
984
34500
        xstart = context -> gx_draw_context_canvas->gx_canvas_y_resolution - yend - 1;
985
34500
        xend = context -> gx_draw_context_canvas->gx_canvas_y_resolution - ystart - 1;
986
34500
        y = x;
987
34500
        info -> x_offset = (yend - ystart + 1 + info -> x_offset) % info->pixelmap -> gx_pixelmap_height;
988
989
34500
        if (info -> x_offset)
990
        {
991
31242
            info -> x_offset = info -> pixelmap -> gx_pixelmap_height - info -> x_offset;
992
        }
993
    }
994
995
#if defined GX_BRUSH_ALPHA_SUPPORT
996
GX_UBYTE alpha;
997
998
105427
    alpha = context -> gx_draw_context_brush.gx_brush_alpha;
999

105427
    if ((alpha == 0) || (info -> pixelmap == GX_NULL))
1000
    {
1001
        /* Nothing to drawn. Just return. */
1002
28020
        return;
1003
    }
1004
1005
77407
    if (alpha != 0xff)
1006
    {
1007
1008
29490
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1009
        {
1010
13816
            if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1011
            {
1012
                /* has both compression and alpha */
1013
7447
                _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_compressed_alpha_blend(context, xstart, xend, y, info, alpha);
1014
            }
1015
            else
1016
            {
1017
                /* alpha, no compression */
1018
6369
                _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_alpha_blend(context, xstart, xend, y, info, alpha);
1019
            }
1020
        }
1021
        else
1022
        {
1023
15674
            if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1024
            {
1025
                /* compressed with no alpha */
1026
7687
                _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_compressed_blend(context, xstart, xend, y, info, alpha);
1027
            }
1028
            else
1029
            {
1030
                /* no compression or alpha */
1031
7987
                _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_raw_blend(context, xstart, xend, y, info, alpha);
1032
            }
1033
        }
1034
1035
        /* Data pointer goes to the end of the fill map, move it to the start again. */
1036
29490
        if (info -> current_pixel_ptr >= info -> pixelmap -> gx_pixelmap_data + info -> pixelmap -> gx_pixelmap_data_size)
1037
        {
1038
234
            info -> current_pixel_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_data;
1039
234
            info -> current_aux_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_aux_data;
1040
        }
1041
29490
        return;
1042
    }
1043
#endif
1044
1045
47917
    if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
1046
    {
1047
13816
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1048
        {
1049
            /* has both compression and alpha */
1050
7447
            _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_compressed_alpha_write(context, xstart, xend, y, info);
1051
        }
1052
        else
1053
        {
1054
            /* alpha, no compression */
1055
6369
            _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_alpha_write(context, xstart, xend, y, info);
1056
        }
1057
    }
1058
    else
1059
    {
1060
34101
        if (info -> pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
1061
        {
1062
            /* compressed with no alpha */
1063
7687
            _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_compressed_write(context, xstart, xend, y, info);
1064
        }
1065
        else
1066
        {
1067
            /* no compression or alpha */
1068
26414
            _gx_display_driver_565rgb_rotated_horizontal_pixelmap_line_raw_write(context, xstart, xend, y, info);
1069
        }
1070
    }
1071
1072
    /* Data pointers goes to the end of full map, move it to the start again. */
1073
47917
    if (info -> current_pixel_ptr >= info -> pixelmap -> gx_pixelmap_data + info -> pixelmap -> gx_pixelmap_data_size)
1074
    {
1075
291
        info -> current_pixel_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_data;
1076
291
        info -> current_aux_ptr = (GX_UBYTE *)info -> pixelmap -> gx_pixelmap_aux_data;
1077
    }
1078
}