GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_32bpp_rotated_pixelmap_draw.c Lines: 820 820 100.0 %
Date: 2024-12-05 08:52:37 Branches: 428 429 99.8 %

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
29
30
/**************************************************************************/
31
/*                                                                        */
32
/*  FUNCTION                                               RELEASE        */
33
/*                                                                        */
34
/*    _gx_display_driver_32bpp_rotated_pixelmap_raw_write                 */
35
/*                                                        PORTABLE C      */
36
/*                                                           6.1.4        */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    Internal helper function that handles writing of rotated            */
44
/*    uncompressed pixlemap data without alpha channel.                   */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    context                               Drawing context               */
49
/*    xpos                                  x-coord of top-left draw point*/
50
/*    ypos                                  y-coord of top-left draw point*/
51
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    None                                                                */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    None                                                                */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    GUIX Internal Code                                                  */
64
/*                                                                        */
65
/*  RELEASE HISTORY                                                       */
66
/*                                                                        */
67
/*    DATE              NAME                      DESCRIPTION             */
68
/*                                                                        */
69
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
70
/*                                                                        */
71
/**************************************************************************/
72
769
static VOID _gx_display_driver_32bpp_rotated_pixelmap_raw_write(GX_DRAW_CONTEXT *context,
73
                                                                INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
74
{
75
INT           xval;
76
INT           yval;
77
GX_COLOR     *putrow;
78
GX_COLOR     *getrow;
79
GX_COLOR     *put;
80
GX_COLOR     *get;
81
82
769
GX_RECTANGLE *clip = context -> gx_draw_context_clip;
83
GX_RECTANGLE  rotated_clip;
84
85
769
    GX_SWAP_VALS(xpos, ypos);
86
87
769
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
88
    {
89
654
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
90
654
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
91
654
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
92
654
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
93
654
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
94
    }
95
    else
96
    {
97
115
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
98
115
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
99
115
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
100
115
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
101
115
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
102
    }
103
104
769
    getrow = (GX_COLOR *)(pixelmap -> gx_pixelmap_data);
105
769
    getrow += pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos);
106
769
    getrow += (rotated_clip.gx_rectangle_left - xpos);
107
108
    /* Brush alpha is 0xff means draw pixelmap to memory directly.  */
109
769
    putrow = context -> gx_draw_context_memory;
110
769
    putrow += rotated_clip.gx_rectangle_top * context -> gx_draw_context_pitch;
111
769
    putrow += rotated_clip.gx_rectangle_left;
112
113
121208
    for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
114
    {
115
120439
        put = putrow;
116
120439
        get = getrow;
117
118
14281611
        for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
119
        {
120
14161172
            *put++ = *get++;
121
        }
122
120439
        putrow += context -> gx_draw_context_pitch;
123
120439
        getrow += pixelmap -> gx_pixelmap_height;
124
    }
125
769
}
126
127
/**************************************************************************/
128
/*                                                                        */
129
/*  FUNCTION                                               RELEASE        */
130
/*                                                                        */
131
/*    _gx_display_driver_32bpp_rotated_pixelmap_alpha_write               */
132
/*                                                        PORTABLE C      */
133
/*                                                           6.1.5        */
134
/*  AUTHOR                                                                */
135
/*                                                                        */
136
/*    Kenneth Maxwell, Microsoft Corporation                              */
137
/*                                                                        */
138
/*  DESCRIPTION                                                           */
139
/*                                                                        */
140
/*    Internal helper function that handles writing of rotated            */
141
/*    uncompressed pixlemap data with alpha channel.                      */
142
/*                                                                        */
143
/*  INPUT                                                                 */
144
/*                                                                        */
145
/*    context                               Drawing context               */
146
/*    xpos                                  x-coord of top-left draw point*/
147
/*    ypos                                  y-coord of top-left draw point*/
148
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
149
/*                                                                        */
150
/*  OUTPUT                                                                */
151
/*                                                                        */
152
/*    None                                                                */
153
/*                                                                        */
154
/*  CALLS                                                                 */
155
/*                                                                        */
156
/*    _gx_display_driver_24xrgb_pixel_blend                               */
157
/*    _gx_display_driver_32bpp_pixel_write                                */
158
/*                                                                        */
159
/*  CALLED BY                                                             */
160
/*                                                                        */
161
/*    _gx_display_driver_32bpp_rotated_pixelmap_draw                      */
162
/*                                                                        */
163
/*  RELEASE HISTORY                                                       */
164
/*                                                                        */
165
/*    DATE              NAME                      DESCRIPTION             */
166
/*                                                                        */
167
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
168
/*  03-02-2021     Ting Zhu                 Modified comment(s), changed  */
169
/*                                            blend function set macro,   */
170
/*                                            resulting in version 6.1.5  */
171
/*                                                                        */
172
/**************************************************************************/
173
7278
static VOID _gx_display_driver_32bpp_rotated_pixelmap_alpha_write(GX_DRAW_CONTEXT *context,
174
                                                                  INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
175
{
176
INT           xval;
177
INT           yval;
178
GX_COLOR      color;
179
ULONG        *getrow;
180
ULONG        *get;
181
UCHAR         alpha_value;
182
7278
GX_RECTANGLE *clip = context -> gx_draw_context_clip;
183
GX_RECTANGLE  rotated_clip;
184
VOID          (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
185
186
7278
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
187
188
7258
    GX_SWAP_VALS(xpos, ypos);
189
190
7258
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
191
    {
192
4481
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
193
4481
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
194
4481
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
195
4481
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
196
4481
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
197
    }
198
    else
199
    {
200
2777
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
201
2777
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
202
2777
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
203
2777
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
204
2777
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
205
    }
206
207
7258
    getrow = (ULONG *)(pixelmap -> gx_pixelmap_data);
208
7258
    getrow += pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos);
209
7258
    getrow += (rotated_clip.gx_rectangle_left - xpos);
210
211
661770
    for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
212
    {
213
654512
        get = getrow;
214
164212193
        for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
215
        {
216
163557681
            alpha_value = ALPHAVAL_32BPP(*get);
217
163557681
            if (alpha_value)
218
            {
219
77738656
                color = *get;
220
77738656
                if (alpha_value == 255)
221
                {
222
73857738
                    _gx_display_driver_32bpp_pixel_write(context, xval, yval, color);
223
                }
224
                else
225
                {
226
3880918
                    color |= 0xff000000;
227
3880918
                    blend_func(context, xval, yval, color, alpha_value);
228
                }
229
            }
230
163557681
            get++;
231
        }
232
654512
        getrow += pixelmap -> gx_pixelmap_height;
233
    }
234
}
235
236
/**************************************************************************/
237
/*                                                                        */
238
/*  FUNCTION                                               RELEASE        */
239
/*                                                                        */
240
/*    _gx_display_driver_32bpp_rotated_pixelmap_compressed_write          */
241
/*                                                                        */
242
/*                                                        PORTABLE C      */
243
/*                                                           6.1.5        */
244
/*  AUTHOR                                                                */
245
/*                                                                        */
246
/*    Kenneth Maxwell, Microsoft Corporation                              */
247
/*                                                                        */
248
/*  DESCRIPTION                                                           */
249
/*                                                                        */
250
/*    Internal helper function that handles writing of rotated compressed */
251
/*    pixlemap data without alpha channel.                                */
252
/*                                                                        */
253
/*  INPUT                                                                 */
254
/*                                                                        */
255
/*    context                               Drawing context               */
256
/*    xpos                                  x-coord of top-left draw point*/
257
/*    ypos                                  y-coord of top-left draw point*/
258
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
259
/*                                                                        */
260
/*  OUTPUT                                                                */
261
/*                                                                        */
262
/*    None                                                                */
263
/*                                                                        */
264
/*  CALLS                                                                 */
265
/*                                                                        */
266
/*    _gx_display_driver_24xrgb_pixel_blend                               */
267
/*    _gx_display_driver_32argb_pixel_blend                               */
268
/*                                                                        */
269
/*  CALLED BY                                                             */
270
/*                                                                        */
271
/*    _gx_display_driver_32bpp_rotated_pixelmap_draw                      */
272
/*                                                                        */
273
/*  RELEASE HISTORY                                                       */
274
/*                                                                        */
275
/*    DATE              NAME                      DESCRIPTION             */
276
/*                                                                        */
277
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
278
/*  03-02-2021     Ting Zhu                 Modified comment(s), changed  */
279
/*                                            blend function set macro,   */
280
/*                                            resulting in version 6.1.5  */
281
/*                                                                        */
282
/**************************************************************************/
283
9392
static VOID _gx_display_driver_32bpp_rotated_pixelmap_compressed_write(GX_DRAW_CONTEXT *context,
284
                                                                       INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
285
{
286
INT                yval;
287
INT                xval;
288
GX_CONST GX_COLOR *get;
289
GX_COLOR          *put;
290
GX_COLOR          *putrow;
291
GX_UBYTE           count;
292
GX_COLOR           pixel;
293
GX_CONST GX_UBYTE *get_count;
294
GX_UBYTE           brush_alpha;
295
9392
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
296
GX_RECTANGLE       rotated_clip;
297
VOID               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
298
299
9392
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
300
301
9181
    GX_SWAP_VALS(xpos, ypos);
302
303
9181
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
304
    {
305
6085
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
306
6085
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
307
6085
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
308
6085
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
309
6085
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
310
    }
311
    else
312
    {
313
3096
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
314
3096
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
315
3096
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
316
3096
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
317
3096
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
318
    }
319
9181
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
320
321
9181
    get = (GX_CONST GX_COLOR *)pixelmap -> gx_pixelmap_data;
322
9181
    get_count = (GX_CONST GX_UBYTE *)pixelmap -> gx_pixelmap_aux_data;
323
324
    /* First, skip to the starting row.  */
325
9417
    for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++)
326
    {
327
236
        xval = 0;
328
604
        while (xval < pixelmap -> gx_pixelmap_height)
329
        {
330
368
            count = *get_count++;
331
332
368
            if (count & 0x80)
333
            {
334
68
                count = (GX_UBYTE)((count & 0x7f) + 1u);
335
336
                /* Skip repeated pixel value.  */
337
68
                get++;
338
            }
339
            else
340
            {
341
300
                count++;
342
343
                /* Skip raw pixel values.  */
344
300
                get += count;
345
            }
346
368
            xval += count;
347
        }
348
    }
349
350
    /* Now we are on the first visible row, copy pixels until we get
351
       to the enf of the last visible row.  */
352
9181
    putrow = (GX_COLOR *)context -> gx_draw_context_memory;
353
9181
    putrow += yval * context -> gx_draw_context_pitch;
354
9181
    putrow += xpos;
355
356
162863
    while (yval <= rotated_clip.gx_rectangle_bottom)
357
    {
358
153682
        put = putrow;
359
153682
        xval = xpos;
360
361
428898
        while (xval < xpos + pixelmap -> gx_pixelmap_height)
362
        {
363
275216
            count = *get_count++;
364
365
275216
            if (count & 0x80)
366
            {
367
368
                /* Repeated value.  */
369
79556
                count = (GX_UBYTE)((count & 0x7f) + 1u);
370
79556
                pixel = (*get++);
371
372
79556
                if (brush_alpha == 0xff)
373
                {
374
722227
                    while (count--)
375
                    {
376
643149
                        if (xval >= rotated_clip.gx_rectangle_left &&
377
643125
                            xval <= rotated_clip.gx_rectangle_right)
378
                        {
379
643113
                            *put = pixel;
380
                        }
381
643149
                        put++;
382
643149
                        xval++;
383
                    }
384
                }
385
                else
386
                {
387
2302
                    while (count--)
388
                    {
389
1824
                        if (xval >= rotated_clip.gx_rectangle_left &&
390
1808
                            xval <= rotated_clip.gx_rectangle_right)
391
                        {
392
1808
                            blend_func(context, xval, yval, pixel, brush_alpha);
393
                        }
394
1824
                        xval++;
395
                    }
396
                }
397
            }
398
            else
399
            {
400
401
                /* String of non-repeated values.  */
402
195660
                count++;
403
404
195660
                if (brush_alpha == 0xff)
405
                {
406
2472945
                    while (count--)
407
                    {
408
2280111
                        if (xval >= rotated_clip.gx_rectangle_left &&
409
2261726
                            xval <= rotated_clip.gx_rectangle_right)
410
                        {
411
2241774
                            *put = (*get);
412
                        }
413
2280111
                        put++;
414
2280111
                        get++;
415
2280111
                        xval++;
416
                    }
417
                }
418
                else
419
                {
420
294986
                    while (count--)
421
                    {
422
292160
                        if (xval >= rotated_clip.gx_rectangle_left &&
423
282956
                            xval <= rotated_clip.gx_rectangle_right)
424
                        {
425
274658
                            blend_func(context, xval, yval, *get, brush_alpha);
426
                        }
427
292160
                        get++;
428
292160
                        xval++;
429
                    }
430
                }
431
            }
432
        }
433
153682
        putrow += context -> gx_draw_context_pitch;
434
153682
        yval++;
435
    }
436
}
437
438
/**************************************************************************/
439
/*                                                                        */
440
/*  FUNCTION                                               RELEASE        */
441
/*                                                                        */
442
/*    _gx_display_driver_32bpp_rotated_pixelmap_compressed_alpha_write    */
443
/*                                                                        */
444
/*                                                        PORTABLE C      */
445
/*                                                           6.1.5        */
446
/*  AUTHOR                                                                */
447
/*                                                                        */
448
/*    Kenneth Maxwell, Microsoft Corporation                              */
449
/*                                                                        */
450
/*  DESCRIPTION                                                           */
451
/*                                                                        */
452
/*    Internal helper function that handles writing of compressed         */
453
/*    pixlemap file with alpha channel.                                   */
454
/*                                                                        */
455
/*  INPUT                                                                 */
456
/*                                                                        */
457
/*    context                               Drawing context               */
458
/*    xpos                                  x-coord of top-left draw point*/
459
/*    ypos                                  y-coord of top-left draw point*/
460
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
461
/*                                                                        */
462
/*  OUTPUT                                                                */
463
/*                                                                        */
464
/*    None                                                                */
465
/*                                                                        */
466
/*  CALLS                                                                 */
467
/*                                                                        */
468
/*    _gx_display_driver_24xrgb_pixel_blend                               */
469
/*    _gx_display_driver_32argb_pixel_blend                               */
470
/*                                                                        */
471
/*  CALLED BY                                                             */
472
/*                                                                        */
473
/*    _gx_display_driver_32bpp_rotated_pixelmap_draw                      */
474
/*                                                                        */
475
/*  RELEASE HISTORY                                                       */
476
/*                                                                        */
477
/*    DATE              NAME                      DESCRIPTION             */
478
/*                                                                        */
479
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
480
/*  03-02-2021     Ting Zhu                 Modified comment(s), changed  */
481
/*                                            blend function set macro,   */
482
/*                                            resulting in version 6.1.5  */
483
/*                                                                        */
484
/**************************************************************************/
485
21802
static VOID _gx_display_driver_32bpp_rotated_pixelmap_compressed_alpha_write(GX_DRAW_CONTEXT *context,
486
                                                                             INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
487
{
488
INT                yval;
489
INT                xval;
490
GX_CONST GX_COLOR *get;
491
GX_UBYTE           count;
492
GX_COLOR           pixel;
493
GX_CONST GX_UBYTE *get_count;
494
GX_UBYTE           brush_alpha;
495
GX_UBYTE           alpha;
496
GX_UBYTE           combined_alpha;
497
21802
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
498
GX_RECTANGLE       rotated_clip;
499
VOID               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
500
501
21802
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
502
503
21545
    GX_SWAP_VALS(xpos, ypos);
504
505
21545
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
506
    {
507
14329
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
508
14329
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
509
14329
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
510
14329
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
511
14329
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
512
    }
513
    else
514
    {
515
7216
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
516
7216
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
517
7216
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
518
7216
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
519
7216
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
520
    }
521
522
21545
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
523
524
21545
    get = (GX_CONST GX_COLOR *)pixelmap -> gx_pixelmap_data;
525
21545
    get_count = (GX_CONST GX_UBYTE *)pixelmap -> gx_pixelmap_aux_data;
526
527
    /* First, skip to the starting row.  */
528
23793
    for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++)
529
    {
530
2248
        xval = 0;
531
6822
        while (xval < pixelmap -> gx_pixelmap_height)
532
        {
533
4574
            count = *get_count++;
534
535
4574
            if (count & 0x80)
536
            {
537
3760
                count = (GX_UBYTE)((count & 0x7f) + 1u);
538
539
                /* Skip repeated pixel value.  */
540
3760
                get++;
541
            }
542
            else
543
            {
544
814
                count++;
545
546
                /* Skip raw pixel values.  */
547
814
                get += count;
548
            }
549
4574
            xval += count;
550
        }
551
    }
552
553
    /* Now we are on the first visible row, copy pixels until we get
554
       to the enf of the last visible row.  */
555
556
395891
    while (yval <= rotated_clip.gx_rectangle_bottom)
557
    {
558
374346
        xval = xpos;
559
560
1538493
        while (xval < xpos + pixelmap -> gx_pixelmap_height)
561
        {
562
1164147
            count = *get_count++;
563
564
1164147
            if (count & 0x80)
565
            {
566
567
                /* Repeated value.  */
568
515105
                count = (GX_UBYTE)((count & 0x7f) + 1u);
569
515105
                alpha = (GX_UBYTE)((*get) >> 24);
570
515105
                pixel = (*get++) | 0xff000000;
571
572
515105
                combined_alpha = (GX_UBYTE)(alpha * brush_alpha / 255);
573
574
515105
                if (combined_alpha)
575
                {
576
3047468
                    while (count--)
577
                    {
578
2773673
                        if (xval >= rotated_clip.gx_rectangle_left &&
579
2769271
                            xval <= rotated_clip.gx_rectangle_right)
580
                        {
581
2764231
                            blend_func(context, xval, yval, pixel, combined_alpha);
582
                        }
583
2773673
                        xval++;
584
                    }
585
                }
586
                else
587
                {
588
241310
                    xval += count;
589
                }
590
            }
591
            else
592
            {
593
594
                /* String of non-repeated values.  */
595
649042
                count++;
596
597
4811377
                while (count--)
598
                {
599
4162335
                    if (xval >= rotated_clip.gx_rectangle_left &&
600
4158452
                        xval <= rotated_clip.gx_rectangle_right)
601
                    {
602
4154193
                        alpha = (GX_UBYTE)((*get) >> 24);
603
4154193
                        pixel = (*get) | 0xff000000;
604
4154193
                        combined_alpha = (GX_UBYTE)(alpha * brush_alpha / 255);
605
4154193
                        blend_func(context, xval, yval, pixel, combined_alpha);
606
                    }
607
4162335
                    get++;
608
4162335
                    xval++;
609
                }
610
            }
611
        }
612
374346
        yval++;
613
    }
614
}
615
616
/**************************************************************************/
617
/*                                                                        */
618
/*  FUNCTION                                               RELEASE        */
619
/*                                                                        */
620
/*    _gx_display_driver_32bpp_rotated_palette_pixelmap_compressed_write  */
621
/*                                                                        */
622
/*                                                        PORTABLE C      */
623
/*                                                           6.1.5        */
624
/*  AUTHOR                                                                */
625
/*                                                                        */
626
/*    Kenneth Maxwell, Microsoft Corporation                              */
627
/*                                                                        */
628
/*  DESCRIPTION                                                           */
629
/*                                                                        */
630
/*    Internal helper function that handles writing of rotated compressed */
631
/*    pixlemap file without transparent of palette pixelmap.              */
632
/*                                                                        */
633
/*  INPUT                                                                 */
634
/*                                                                        */
635
/*    context                               Drawing context               */
636
/*    xpos                                  x-coord of top-left draw point*/
637
/*    ypos                                  y-coord of top-left draw point*/
638
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
639
/*                                                                        */
640
/*  OUTPUT                                                                */
641
/*                                                                        */
642
/*    None                                                                */
643
/*                                                                        */
644
/*  CALLS                                                                 */
645
/*                                                                        */
646
/*    _gx_display_driver_24xrgb_pixel_blend                               */
647
/*                                                                        */
648
/*  CALLED BY                                                             */
649
/*                                                                        */
650
/*    _gx_display_driver_32bpp_rotated_pixelmap_draw                      */
651
/*                                                                        */
652
/*  RELEASE HISTORY                                                       */
653
/*                                                                        */
654
/*    DATE              NAME                      DESCRIPTION             */
655
/*                                                                        */
656
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
657
/*  03-02-2021     Ting Zhu                 Modified comment(s), changed  */
658
/*                                            blend function set macro,   */
659
/*                                            moved NULL pointer check to */
660
/*                                            caller function,            */
661
/*                                            resulting in version 6.1.5  */
662
/*                                                                        */
663
/**************************************************************************/
664
45
static VOID _gx_display_driver_32bpp_rotated_palette_pixelmap_compressed_write(GX_DRAW_CONTEXT *context,
665
                                                                               INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
666
{
667
INT             yval;
668
INT             xval;
669
GX_CONST UCHAR *get;
670
UCHAR           count;
671
GX_COLOR       *put;
672
GX_COLOR       *putrow;
673
GX_COLOR        pixel;
674
GX_COLOR       *palette;
675
GX_UBYTE        brush_alpha;
676
45
GX_RECTANGLE   *clip = context -> gx_draw_context_clip;
677
GX_RECTANGLE    rotated_clip;
678
VOID            (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
679
680
45
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
681
682
25
    GX_SWAP_VALS(xpos, ypos);
683
684
25
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
685
    {
686
20
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
687
20
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
688
20
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
689
20
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
690
20
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
691
    }
692
    else
693
    {
694
5
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
695
5
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
696
5
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
697
5
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
698
5
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
699
    }
700
25
    get = (GX_CONST UCHAR *)pixelmap -> gx_pixelmap_data;
701
25
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
702
703
    /* Compressed with  alpha is a one-byte count and  one-byte pixel index,
704
       first, skip to the starting row.   */
705
117
    for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++)
706
    {
707
92
        xval = 0;
708
2182
        while (xval < pixelmap -> gx_pixelmap_height)
709
        {
710
2090
            count = *get++;
711
712
2090
            if (count & 0x80)
713
            {
714
1164
                count = (UCHAR)((count & 0x7f) + 1);
715
716
                /* Skip repeated pixel value.  */
717
1164
                get++;
718
            }
719
            else
720
            {
721
926
                count++;
722
723
                /* Skip raw pixel values.  */
724
926
                get += count;
725
            }
726
2090
            xval += count;
727
        }
728
    }
729
730
    /* Now we are on the first visible row, copy pixels until we get
731
       to the enf of the last visible row. */
732
25
    putrow = (GX_COLOR *)context -> gx_draw_context_memory;
733
25
    putrow += yval * context -> gx_draw_context_pitch;
734
25
    putrow += xpos;
735
736
    /* Now we are on the first visible row, copy pixels until we get
737
       to the end of the last visible row.  */
738
25
    palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
739
740
5835
    while (yval <= rotated_clip.gx_rectangle_bottom)
741
    {
742
5810
        xval = xpos;
743
5810
        put = putrow;
744
745
123295
        while (xval < xpos + pixelmap -> gx_pixelmap_height)
746
        {
747
117485
            count = *get++;
748
749
117485
            if (count & 0x80)
750
            {
751
                /* Repeated value.  */
752
64890
                count = (UCHAR)((count & 0x7f) + 1);
753
754
64890
                pixel = palette[*get++];
755
756
64890
                if (brush_alpha == 0xff)
757
                {
758
243006
                    while (count--)
759
                    {
760
204072
                        if (xval >= rotated_clip.gx_rectangle_left &&
761
199286
                            xval <= rotated_clip.gx_rectangle_right)
762
                        {
763
194943
                            *put = pixel;
764
                        }
765
204072
                        put++;
766
204072
                        xval++;
767
                    }
768
                }
769
                else
770
                {
771
162004
                    while (count--)
772
                    {
773
136048
                        if (xval >= rotated_clip.gx_rectangle_left &&
774
132562
                            xval <= rotated_clip.gx_rectangle_right)
775
                        {
776
129962
                            blend_func(context, xval, yval, pixel, brush_alpha);
777
                        }
778
136048
                        xval++;
779
                    }
780
                }
781
            }
782
            else
783
            {
784
                /* String of non-repeated values.  */
785
52595
                count++;
786
52595
                if (brush_alpha == 0xff)
787
                {
788
266721
                    while (count--)
789
                    {
790
235164
                        if (xval >= rotated_clip.gx_rectangle_left &&
791
226581
                            xval <= rotated_clip.gx_rectangle_right)
792
                        {
793
218016
                            pixel = palette[*get];
794
218016
                            *put = pixel;
795
                        }
796
235164
                        get++;
797
235164
                        put++;
798
235164
                        xval++;
799
                    }
800
                }
801
                else
802
                {
803
177814
                    while (count--)
804
                    {
805
156776
                        if (xval >= rotated_clip.gx_rectangle_left &&
806
151042
                            xval <= rotated_clip.gx_rectangle_right)
807
                        {
808
145344
                            pixel = palette[*get];
809
145344
                            blend_func(context, xval, yval, pixel, brush_alpha);
810
                        }
811
156776
                        get++;
812
156776
                        xval++;
813
                    }
814
                }
815
            }
816
        }
817
5810
        putrow += context -> gx_draw_context_pitch;
818
5810
        yval++;
819
    }
820
}
821
822
/**************************************************************************/
823
/*                                                                        */
824
/*  FUNCTION                                               RELEASE        */
825
/*                                                                        */
826
/*    _gx_display_driver_32bpp_rotated_palette_pixelmap_write             */
827
/*                                                                        */
828
/*                                                        PORTABLE C      */
829
/*                                                           6.1.4        */
830
/*  AUTHOR                                                                */
831
/*                                                                        */
832
/*    Kenneth Maxwell, Microsoft Corporation                              */
833
/*                                                                        */
834
/*  DESCRIPTION                                                           */
835
/*                                                                        */
836
/*    Internal helper function that handles writing of rotated            */
837
/*    uncompressed pixlemap file without transparent of palette pixelmap. */
838
/*                                                                        */
839
/*  INPUT                                                                 */
840
/*                                                                        */
841
/*    context                               Drawing context               */
842
/*    xpos                                  x-coord of top-left draw point*/
843
/*    ypos                                  y-coord of top-left draw point*/
844
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
845
/*                                                                        */
846
/*  OUTPUT                                                                */
847
/*                                                                        */
848
/*    None                                                                */
849
/*                                                                        */
850
/*  CALLS                                                                 */
851
/*                                                                        */
852
/*    None                                                                */
853
/*                                                                        */
854
/*  CALLED BY                                                             */
855
/*                                                                        */
856
/*    _gx_display_driver_32bpp_rotated_pixelmap_draw                      */
857
/*                                                                        */
858
/*  RELEASE HISTORY                                                       */
859
/*                                                                        */
860
/*    DATE              NAME                      DESCRIPTION             */
861
/*                                                                        */
862
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
863
/*                                                                        */
864
/**************************************************************************/
865
25
static VOID _gx_display_driver_32bpp_rotated_palette_pixelmap_write(GX_DRAW_CONTEXT *context,
866
                                                                    INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
867
{
868
INT           xval;
869
INT           yval;
870
GX_UBYTE     *getrow;
871
GX_UBYTE     *get;
872
GX_COLOR     *palette;
873
GX_COLOR     *put;
874
GX_COLOR     *putrow;
875
25
GX_RECTANGLE *clip = context -> gx_draw_context_clip;
876
GX_RECTANGLE  rotated_clip;
877
878
25
    GX_SWAP_VALS(xpos, ypos);
879
880
25
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
881
    {
882
20
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
883
20
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
884
20
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
885
20
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
886
20
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
887
    }
888
    else
889
    {
890
5
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
891
5
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
892
5
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
893
5
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
894
5
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
895
    }
896
897
25
    getrow = (GX_UBYTE *)(pixelmap -> gx_pixelmap_data);
898
25
    getrow += (pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos));
899
25
    getrow += (rotated_clip.gx_rectangle_left - xpos);
900
901
25
    palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
902
903
    /* Now we are on the first visible row, copy pixels until we get
904
       to the enf of the last visible row.  */
905
25
    putrow = (GX_COLOR *)context -> gx_draw_context_memory;
906
25
    putrow += rotated_clip.gx_rectangle_top * context -> gx_draw_context_pitch;
907
25
    putrow += rotated_clip.gx_rectangle_left;
908
909
5835
    for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
910
    {
911
5810
        put = putrow;
912
5810
        get = getrow;
913
914
694075
        for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
915
        {
916
688265
            *put++ = palette[*get++];
917
        }
918
5810
        putrow += context -> gx_draw_context_pitch;
919
5810
        getrow += pixelmap -> gx_pixelmap_height;
920
    }
921
25
}
922
923
/**************************************************************************/
924
/*                                                                        */
925
/*  FUNCTION                                               RELEASE        */
926
/*                                                                        */
927
/*    _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_write */
928
/*                                                                        */
929
/*                                                         PORTABLE C     */
930
/*                                                           6.1.4        */
931
/*  AUTHOR                                                                */
932
/*                                                                        */
933
/*    Kenneth Maxwell, Microsoft Corporation                              */
934
/*                                                                        */
935
/*  DESCRIPTION                                                           */
936
/*                                                                        */
937
/*    Internal helper function that handles writing of uncompressed       */
938
/*    pixlemap file with transparent of palette pixelmap.                 */
939
/*                                                                        */
940
/*  INPUT                                                                 */
941
/*                                                                        */
942
/*    context                               Drawing context               */
943
/*    xpos                                  x-coord of top-left draw point*/
944
/*    ypos                                  y-coord of top-left draw point*/
945
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
946
/*                                                                        */
947
/*  OUTPUT                                                                */
948
/*                                                                        */
949
/*    None                                                                */
950
/*                                                                        */
951
/*  CALLS                                                                 */
952
/*                                                                        */
953
/*    _gx_display_driver_32bpp_pixel_write                                */
954
/*                                                                        */
955
/*  CALLED BY                                                             */
956
/*                                                                        */
957
/*    _gx_display_driver_32bpp_rotated_pixelmap_draw                      */
958
/*                                                                        */
959
/*  RELEASE HISTORY                                                       */
960
/*                                                                        */
961
/*    DATE              NAME                      DESCRIPTION             */
962
/*                                                                        */
963
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
964
/*                                                                        */
965
/**************************************************************************/
966
817
static VOID _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_write(GX_DRAW_CONTEXT *context,
967
                                                                                INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
968
{
969
INT           xval;
970
INT           yval;
971
GX_UBYTE     *getrow;
972
GX_UBYTE     *get;
973
GX_COLOR     *palette;
974
975
817
GX_RECTANGLE *clip = context -> gx_draw_context_clip;
976
GX_RECTANGLE  rotated_clip;
977
978
817
    GX_SWAP_VALS(xpos, ypos);
979
980
817
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
981
    {
982
545
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
983
545
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
984
545
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
985
545
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
986
545
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
987
    }
988
    else
989
    {
990
272
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
991
272
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
992
272
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
993
272
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
994
272
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
995
    }
996
997
817
    palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
998
817
    getrow = (GX_UBYTE *)(pixelmap -> gx_pixelmap_data);
999
817
    getrow += (pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos));
1000
817
    getrow += (rotated_clip.gx_rectangle_left - xpos);
1001
1002
31673
    for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
1003
    {
1004
30856
        get = getrow;
1005
1197969
        for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
1006
        {
1007
1167113
            if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
1008
            {
1009
361735
                _gx_display_driver_32bpp_pixel_write(context, xval, yval, palette[*get]);
1010
            }
1011
1167113
            get++;
1012
        }
1013
1014
30856
        getrow += pixelmap -> gx_pixelmap_height;
1015
    }
1016
817
}
1017
1018
/**************************************************************************/
1019
/*                                                                        */
1020
/*  FUNCTION                                               RELEASE        */
1021
/*                                                                        */
1022
/*    _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_      */
1023
/*                                                       compressed_write */
1024
/*                                                                        */
1025
/*                                                        PORTABLE C      */
1026
/*                                                           6.1.5        */
1027
/*  AUTHOR                                                                */
1028
/*                                                                        */
1029
/*    Kenneth Maxwell, Microsoft Corporation                              */
1030
/*                                                                        */
1031
/*  DESCRIPTION                                                           */
1032
/*                                                                        */
1033
/*    Internal helper function that handles writing of rotated compressed */
1034
/*    pixlemap file with transparent of palette pixelmap.                 */
1035
/*                                                                        */
1036
/*  INPUT                                                                 */
1037
/*                                                                        */
1038
/*    context                               Drawing context               */
1039
/*    xpos                                  x-coord of top-left draw point*/
1040
/*    ypos                                  y-coord of top-left draw point*/
1041
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1042
/*                                                                        */
1043
/*  OUTPUT                                                                */
1044
/*                                                                        */
1045
/*    None                                                                */
1046
/*                                                                        */
1047
/*  CALLS                                                                 */
1048
/*                                                                        */
1049
/*    _gx_display_driver_24xrgb_pixel_blend                               */
1050
/*    _gx_display_driver_32argb_pixel_blend                               */
1051
/*                                                                        */
1052
/*  CALLED BY                                                             */
1053
/*                                                                        */
1054
/*    _gx_display_driver_32bpp_rotated_pixelmap_draw                      */
1055
/*                                                                        */
1056
/*  RELEASE HISTORY                                                       */
1057
/*                                                                        */
1058
/*    DATE              NAME                      DESCRIPTION             */
1059
/*                                                                        */
1060
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
1061
/*  03-02-2021     Ting Zhu                 Modified comment(s), changed  */
1062
/*                                            blend function set macro,   */
1063
/*                                            resulting in version 6.1.5  */
1064
/*                                                                        */
1065
/**************************************************************************/
1066
1112
static VOID _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_compressed_write(GX_DRAW_CONTEXT *context,
1067
                                                                                           INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1068
{
1069
INT             yval;
1070
INT             xval;
1071
GX_CONST UCHAR *get;
1072
UCHAR           count;
1073
GX_COLOR        pixel;
1074
GX_COLOR       *palette;
1075
GX_COLOR       *put;
1076
GX_COLOR       *putrow;
1077
GX_UBYTE        brush_alpha;
1078
1112
GX_RECTANGLE   *clip = context -> gx_draw_context_clip;
1079
GX_RECTANGLE    rotated_clip;
1080
VOID            (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
1081
1082
1112
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
1083
1084
998
    GX_SWAP_VALS(xpos, ypos);
1085
1086
998
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
1087
    {
1088
683
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
1089
683
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
1090
683
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
1091
683
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
1092
683
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
1093
    }
1094
    else
1095
    {
1096
315
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
1097
315
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
1098
315
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
1099
315
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
1100
315
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
1101
    }
1102
998
    get = (GX_CONST UCHAR *)pixelmap -> gx_pixelmap_data;
1103
998
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1104
1105
    /* Compressed with  alpha is a one-byte count and  one-byte pixel index,
1106
       first, skip to the starting row.  */
1107
1090
    for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++)
1108
    {
1109
92
        xval = 0;
1110
252
        while (xval < pixelmap -> gx_pixelmap_height)
1111
        {
1112
160
            count = *get++;
1113
1114
160
            if (count & 0x80)
1115
            {
1116
128
                count = (UCHAR)((count & 0x7f) + 1);
1117
1118
                /* Skip repeated pixel value.  */
1119
128
                get++;
1120
            }
1121
            else
1122
            {
1123
32
                count++;
1124
1125
                /* Skip raw pixel values.  */
1126
32
                get += count;
1127
            }
1128
160
            xval += count;
1129
        }
1130
    }
1131
1132
    /* Now we are on the first visible row, copy pixels until we get
1133
       to the end of the last visible row. */
1134
998
    palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
1135
998
    putrow = (GX_COLOR *)context -> gx_draw_context_memory;
1136
998
    putrow += yval * context -> gx_draw_context_pitch;
1137
998
    putrow += xpos;
1138
1139
39166
    while (yval <= rotated_clip.gx_rectangle_bottom)
1140
    {
1141
38168
        xval = xpos;
1142
38168
        put = putrow;
1143
1144
197726
        while (xval < xpos + pixelmap -> gx_pixelmap_height)
1145
        {
1146
159558
            count = *get++;
1147
159558
            if (count & 0x80)
1148
            {
1149
                /* repeated value */
1150
100948
                count = (UCHAR)((count & 0x7f) + 1);
1151
100948
                if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
1152
                {
1153
40556
                    pixel = palette[*get];
1154
40556
                    if (brush_alpha == 0xff)
1155
                    {
1156
352169
                        while (count--)
1157
                        {
1158
312049
                            if (xval >= rotated_clip.gx_rectangle_left &&
1159
311973
                                xval <= rotated_clip.gx_rectangle_right)
1160
                            {
1161
311863
                                *put = pixel;
1162
                            }
1163
312049
                            xval++;
1164
312049
                            put++;
1165
                        }
1166
                    }
1167
                    else
1168
                    {
1169
3876
                        while (count--)
1170
                        {
1171
3440
                            if (xval >= rotated_clip.gx_rectangle_left &&
1172
3412
                                xval <= rotated_clip.gx_rectangle_right)
1173
                            {
1174
3316
                                blend_func(context, xval, yval, pixel, brush_alpha);
1175
                            }
1176
3440
                            xval++;
1177
                        }
1178
                    }
1179
                }
1180
                else
1181
                {
1182
60392
                    xval += count;
1183
60392
                    put += count;
1184
                }
1185
1186
100948
                get++;
1187
            }
1188
            else
1189
            {
1190
                /* string of non-repeated values */
1191
58610
                count++;
1192
58610
                if (brush_alpha == 0xff)
1193
                {
1194
395809
                    while (count--)
1195
                    {
1196
337831
                        if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
1197
                        {
1198
330910
                            if (xval >= rotated_clip.gx_rectangle_left &&
1199
330436
                                xval <= rotated_clip.gx_rectangle_right)
1200
                            {
1201
330094
                                pixel = palette[*get];
1202
330094
                                *put = pixel;
1203
                            }
1204
                        }
1205
337831
                        get++;
1206
337831
                        xval++;
1207
337831
                        put++;
1208
                    }
1209
                }
1210
                else
1211
                {
1212
4336
                    while (count--)
1213
                    {
1214
3704
                        if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
1215
                        {
1216
3620
                            if (xval >= rotated_clip.gx_rectangle_left &&
1217
3216
                                xval <= rotated_clip.gx_rectangle_right)
1218
                            {
1219
3076
                                pixel = palette[*get];
1220
3076
                                blend_func(context, xval, yval, pixel, brush_alpha);
1221
                            }
1222
                        }
1223
3704
                        get++;
1224
3704
                        xval++;
1225
                    }
1226
                }
1227
            }
1228
        }
1229
38168
        yval++;
1230
38168
        putrow += context -> gx_draw_context_pitch;
1231
    }
1232
}
1233
1234
/**************************************************************************/
1235
/*                                                                        */
1236
/*  FUNCTION                                               RELEASE        */
1237
/*                                                                        */
1238
/*    _gx_display_driver_32bpp_rotated_565rgb_pixelmap_raw_write          */
1239
/*                                                                        */
1240
/*                                                        PORTABLE C      */
1241
/*                                                           6.1.4        */
1242
/*  AUTHOR                                                                */
1243
/*                                                                        */
1244
/*    Kenneth Maxwell, Microsoft Corporation                              */
1245
/*                                                                        */
1246
/*  DESCRIPTION                                                           */
1247
/*                                                                        */
1248
/*    Internal helper function that handles writing of 565rgb format      */
1249
/*    uncompressed pixlemap file without alpha channel.                   */
1250
/*                                                                        */
1251
/*  INPUT                                                                 */
1252
/*                                                                        */
1253
/*    context                               Drawing context               */
1254
/*    xpos                                  x-coord of top-left draw point*/
1255
/*    ypos                                  y-coord of top-left draw point*/
1256
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1257
/*                                                                        */
1258
/*  OUTPUT                                                                */
1259
/*                                                                        */
1260
/*    None                                                                */
1261
/*                                                                        */
1262
/*  CALLS                                                                 */
1263
/*                                                                        */
1264
/*    None                                                                */
1265
/*                                                                        */
1266
/*  CALLED BY                                                             */
1267
/*                                                                        */
1268
/*    _gx_display_driver_32bpp_rotated_pixelmap_draw                      */
1269
/*                                                                        */
1270
/*  RELEASE HISTORY                                                       */
1271
/*                                                                        */
1272
/*    DATE              NAME                      DESCRIPTION             */
1273
/*                                                                        */
1274
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
1275
/*                                                                        */
1276
/**************************************************************************/
1277
577
static VOID _gx_display_driver_32bpp_rotated_565rgb_pixelmap_raw_write(GX_DRAW_CONTEXT *context,
1278
                                                                       INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1279
{
1280
INT              xval;
1281
INT              yval;
1282
GX_COLOR        *putrow;
1283
USHORT          *getrow;
1284
GX_COLOR        *put;
1285
GX_CONST USHORT *get;
1286
1287
577
GX_RECTANGLE    *clip = context -> gx_draw_context_clip;
1288
GX_RECTANGLE     rotated_clip;
1289
1290
577
    GX_SWAP_VALS(xpos, ypos);
1291
1292
577
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
1293
    {
1294
290
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
1295
290
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
1296
290
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
1297
290
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
1298
290
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
1299
    }
1300
    else
1301
    {
1302
287
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
1303
287
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
1304
287
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
1305
287
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
1306
287
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
1307
    }
1308
1309
577
    putrow = (GX_COLOR *)context -> gx_draw_context_memory;
1310
577
    putrow += rotated_clip.gx_rectangle_top * context -> gx_draw_context_pitch;
1311
577
    putrow += rotated_clip.gx_rectangle_left;
1312
1313
577
    getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
1314
577
    getrow += pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos);
1315
577
    getrow += (rotated_clip.gx_rectangle_left - xpos);
1316
1317
2292
    for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
1318
    {
1319
1715
        put = putrow;
1320
1715
        get = getrow;
1321
1322
78890
        for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
1323
        {
1324
77175
            *put++ = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff,
1325
                                                    REDVAL_16BPP(*get) << 3,
1326
                                                    GREENVAL_16BPP(*get) << 2,
1327
                                                    BLUEVAL_16BPP(*get) << 3);
1328
77175
            get++;
1329
        }
1330
1715
        putrow += context -> gx_draw_context_pitch;
1331
1715
        getrow += pixelmap -> gx_pixelmap_height;
1332
    }
1333
577
}
1334
1335
/**************************************************************************/
1336
/*                                                                        */
1337
/*  FUNCTION                                               RELEASE        */
1338
/*                                                                        */
1339
/*    _gx_display_driver_24xrgb_rotated_565rgb_pixelmap_compressed_write  */
1340
/*                                                                        */
1341
/*                                                        PORTABLE C      */
1342
/*                                                           6.1.5        */
1343
/*  AUTHOR                                                                */
1344
/*                                                                        */
1345
/*    Kenneth Maxwell, Microsoft Corporation                              */
1346
/*                                                                        */
1347
/*  DESCRIPTION                                                           */
1348
/*                                                                        */
1349
/*    Internal helper function that handles writing of rotated compressed */
1350
/*    pixelmap data of 565rgb format in 32bpp driver.                     */
1351
/*                                                                        */
1352
/*  INPUT                                                                 */
1353
/*                                                                        */
1354
/*    context                               Drawing context               */
1355
/*    xpos                                  x-coord of top-left draw point*/
1356
/*    ypos                                  y-coord of top-left draw point*/
1357
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1358
/*                                                                        */
1359
/*  OUTPUT                                                                */
1360
/*                                                                        */
1361
/*    None                                                                */
1362
/*                                                                        */
1363
/*  CALLS                                                                 */
1364
/*                                                                        */
1365
/*    _gx_display_driver_24xrgb_pixel_blend                               */
1366
/*                                                                        */
1367
/*  CALLED BY                                                             */
1368
/*                                                                        */
1369
/*    _gx_display_driver_32bpp_rotated_pixelmap_draw                      */
1370
/*                                                                        */
1371
/*  RELEASE HISTORY                                                       */
1372
/*                                                                        */
1373
/*    DATE              NAME                      DESCRIPTION             */
1374
/*                                                                        */
1375
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
1376
/*  03-02-2021     Ting Zhu                 Modified comment(s), changed  */
1377
/*                                            blend function set macro,   */
1378
/*                                            resulting in version 6.1.5  */
1379
/*                                                                        */
1380
/**************************************************************************/
1381
577
static VOID _gx_display_driver_32bpp_rotated_565rgb_pixelmap_compressed_write(GX_DRAW_CONTEXT *context,
1382
                                                                              INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1383
{
1384
INT              yval;
1385
INT              xval;
1386
GX_CONST USHORT *get;
1387
USHORT           count;
1388
GX_COLOR         pixel;
1389
GX_UBYTE         r;
1390
GX_UBYTE         g;
1391
GX_UBYTE         b;
1392
GX_UBYTE         brush_alpha;
1393
GX_COLOR        *put;
1394
GX_COLOR        *putrow;
1395
577
GX_RECTANGLE    *clip = context -> gx_draw_context_clip;
1396
GX_RECTANGLE     rotated_clip;
1397
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
1398
1399
577
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
1400
1401
557
    GX_SWAP_VALS(xpos, ypos);
1402
1403
557
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
1404
    {
1405
286
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
1406
286
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
1407
286
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
1408
286
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
1409
286
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
1410
    }
1411
    else
1412
    {
1413
271
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
1414
271
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
1415
271
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
1416
271
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
1417
271
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
1418
    }
1419
557
    get = (GX_CONST USHORT *)pixelmap -> gx_pixelmap_data;
1420
557
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1421
1422
    /* First, skip to the starting row.  */
1423
19947
    for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++)
1424
    {
1425
19390
        xval = 0;
1426
161537
        while (xval < pixelmap -> gx_pixelmap_height)
1427
        {
1428
142147
            count = *get++;
1429
1430
142147
            if (count & 0x8000)
1431
            {
1432
64960
                count = (USHORT)((count & 0x7fff) + 1);
1433
1434
                /* Skip repeated pixel value.  */
1435
64960
                get++;
1436
            }
1437
            else
1438
            {
1439
77187
                count++;
1440
1441
                /* Skip raw pixel values.  */
1442
77187
                get += count;
1443
            }
1444
142147
            xval += count;
1445
        }
1446
    }
1447
1448
    /* Now we are on the first visible row, copy pixels until we get
1449
       to the enf of the last visible row.  */
1450
557
    putrow = (GX_COLOR *)context -> gx_draw_context_memory;
1451
557
    putrow += yval * context -> gx_draw_context_pitch;
1452
557
    putrow += xpos;
1453
1454
95611
    while (yval <= rotated_clip.gx_rectangle_bottom)
1455
    {
1456
95054
        xval = xpos;
1457
95054
        put = putrow;
1458
1459
934622
        while (xval < xpos + pixelmap -> gx_pixelmap_height)
1460
        {
1461
839568
            count = *get++;
1462
1463
839568
            if (count & 0x8000)
1464
            {
1465
1466
                /* Repeated value.  */
1467
410362
                count = (USHORT)((count & 0x7fff) + 1);
1468
410362
                pixel = *get++;
1469
410362
                r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1470
410362
                g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1471
410362
                b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1472
410362
                pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1473
1474
410362
                if (brush_alpha == 0xff)
1475
                {
1476
2038740
                    while (count--)
1477
                    {
1478
1641896
                        if (xval >= rotated_clip.gx_rectangle_left &&
1479
1619240
                            xval <= rotated_clip.gx_rectangle_right)
1480
                        {
1481
1595925
                            *put = pixel;
1482
                        }
1483
1641896
                        xval++;
1484
1641896
                        put++;
1485
                    }
1486
                }
1487
                else
1488
                {
1489
66744
                    while (count--)
1490
                    {
1491
53226
                        if (xval >= rotated_clip.gx_rectangle_left &&
1492
52416
                            xval <= rotated_clip.gx_rectangle_right)
1493
                        {
1494
51243
                            blend_func(context, xval, yval, pixel, brush_alpha);
1495
                        }
1496
53226
                        xval++;
1497
                    }
1498
                }
1499
            }
1500
            else
1501
            {
1502
1503
                /* String of non-repeated values.  */
1504
429206
                count++;
1505
429206
                if (brush_alpha == 0xff)
1506
                {
1507
10450479
                    while (count--)
1508
                    {
1509
10034488
                        if (xval >= rotated_clip.gx_rectangle_left &&
1510
9508951
                            xval <= rotated_clip.gx_rectangle_right)
1511
                        {
1512
8984566
                            pixel = *get;
1513
8984566
                            r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1514
8984566
                            g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1515
8984566
                            b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1516
8984566
                            pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1517
8984566
                            *put = pixel;
1518
                        }
1519
10034488
                        get++;
1520
10034488
                        put++;
1521
10034488
                        xval++;
1522
                    }
1523
                }
1524
                else
1525
                {
1526
265377
                    while (count--)
1527
                    {
1528
252162
                        if (xval >= rotated_clip.gx_rectangle_left &&
1529
243432
                            xval <= rotated_clip.gx_rectangle_right)
1530
                        {
1531
236019
                            pixel = *get;
1532
236019
                            r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1533
236019
                            g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1534
236019
                            b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1535
236019
                            pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1536
236019
                            blend_func(context, xval, yval, pixel, brush_alpha);
1537
                        }
1538
252162
                        get++;
1539
252162
                        xval++;
1540
                    }
1541
                }
1542
            }
1543
        }
1544
95054
        yval++;
1545
95054
        putrow += context -> gx_draw_context_pitch;
1546
    }
1547
}
1548
1549
/**************************************************************************/
1550
/*                                                                        */
1551
/*  FUNCTION                                               RELEASE        */
1552
/*                                                                        */
1553
/*    _gx_display_driver_24xrgb_rotated_565rgb_pixelmap_compressed_alpha_ */
1554
/*                                                               write    */
1555
/*                                                                        */
1556
/*                                                        PORTABLE C      */
1557
/*                                                           6.1.5        */
1558
/*  AUTHOR                                                                */
1559
/*                                                                        */
1560
/*    Kenneth Maxwell, Microsoft Corporation                              */
1561
/*                                                                        */
1562
/*  DESCRIPTION                                                           */
1563
/*                                                                        */
1564
/*    Internal helper function that handles writing of compressed-alpha   */
1565
/*    pixelmap data of 565rgb format with 32bpp driver.                   */
1566
/*                                                                        */
1567
/*  INPUT                                                                 */
1568
/*                                                                        */
1569
/*    context                               Drawing context               */
1570
/*    xpos                                  x-coord of top-left draw point*/
1571
/*    ypos                                  y-coord of top-left draw point*/
1572
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1573
/*                                                                        */
1574
/*  OUTPUT                                                                */
1575
/*                                                                        */
1576
/*    None                                                                */
1577
/*                                                                        */
1578
/*  CALLS                                                                 */
1579
/*                                                                        */
1580
/*    _gx_display_driver_24xrgb_pixel_blend                               */
1581
/*    _gx_display_driver_32bpp_pixel_write                                */
1582
/*                                                                        */
1583
/*  CALLED BY                                                             */
1584
/*                                                                        */
1585
/*    _gx_display_driver_32bpp_rotated_pixelmap_draw                      */
1586
/*                                                                        */
1587
/*  RELEASE HISTORY                                                       */
1588
/*                                                                        */
1589
/*    DATE              NAME                      DESCRIPTION             */
1590
/*                                                                        */
1591
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
1592
/*  03-02-2021     Ting Zhu                 Modified comment(s), changed  */
1593
/*                                            blend function set macro,   */
1594
/*                                            resulting in version 6.1.5  */
1595
/*                                                                        */
1596
/**************************************************************************/
1597
73
static VOID _gx_display_driver_32bpp_rotated_565rgb_pixelmap_compressed_alpha_write(GX_DRAW_CONTEXT *context,
1598
                                                                                    INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1599
{
1600
INT                yval;
1601
INT                xval;
1602
GX_CONST GX_UBYTE *get;
1603
GX_UBYTE           count;
1604
GX_COLOR           pixel;
1605
GX_UBYTE           alpha_value;
1606
GX_UBYTE           r;
1607
GX_UBYTE           g;
1608
GX_UBYTE           b;
1609
GX_UBYTE           brush_alpha;
1610
GX_UBYTE           combined_alpha;
1611
1612
73
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
1613
GX_RECTANGLE       rotated_clip;
1614
VOID               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
1615
1616
73
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
1617
1618
43
    GX_SWAP_VALS(xpos, ypos);
1619
1620
43
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
1621
    {
1622
34
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
1623
34
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
1624
34
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
1625
34
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
1626
34
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
1627
    }
1628
    else
1629
    {
1630
9
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
1631
9
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
1632
9
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
1633
9
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
1634
9
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
1635
    }
1636
43
    get = (GX_CONST GX_UBYTE *)pixelmap -> gx_pixelmap_data;
1637
43
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
1638
1639
    /* First, skip to the starting row.  */
1640
171
    for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++)
1641
    {
1642
128
        xval = 0;
1643
692
        while (xval < pixelmap -> gx_pixelmap_height)
1644
        {
1645
564
            count = *get;
1646
1647
564
            if (count & 0x80)
1648
            {
1649
346
                count = (GX_UBYTE)((count & 0x7f) + 1);
1650
1651
                /* Skip repeated pixel value.  */
1652
346
                get += 4;
1653
            }
1654
            else
1655
            {
1656
218
                count++;
1657
1658
                /* Skip raw pixel values.  */
1659
218
                get += (count * 4);
1660
            }
1661
564
            xval += count;
1662
        }
1663
    }
1664
1665
    /* Now we are on the first visible row, copy pixels until we get
1666
       to the enf of the last visible row.  */
1667
6977
    while (yval <= rotated_clip.gx_rectangle_bottom)
1668
    {
1669
6934
        xval = xpos;
1670
1671
271145
        while (xval < xpos + pixelmap -> gx_pixelmap_height)
1672
        {
1673
264211
            count = *get;
1674
1675
264211
            if (count & 0x80)
1676
            {
1677
1678
                /* Repeated value.  */
1679
139915
                count = (GX_UBYTE)((count & 0x7f) + 1);
1680
139915
                alpha_value = *(get + 1);
1681
1682
139915
                if (alpha_value)
1683
                {
1684
126357
                    if (brush_alpha == 0xff)
1685
                    {
1686
98708
                        get += 2;
1687
98708
                        pixel = *(USHORT *)get;
1688
98708
                        r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1689
98708
                        g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1690
98708
                        b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1691
98708
                        pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1692
98708
                        get += 2;
1693
577678
                        while (count--)
1694
                        {
1695
478970
                            if (xval >= rotated_clip.gx_rectangle_left &&
1696
478714
                                xval <= rotated_clip.gx_rectangle_right)
1697
                            {
1698
478414
                                if (alpha_value == 0xff)
1699
                                {
1700
478256
                                    _gx_display_driver_32bpp_pixel_write(context, xval, yval, pixel);
1701
                                }
1702
                                else
1703
                                {
1704
158
                                    blend_func(context, xval, yval, pixel, alpha_value);
1705
                                }
1706
                            }
1707
478970
                            xval++;
1708
                        }
1709
                    }
1710
                    else
1711
                    {
1712
27649
                        combined_alpha = (GX_UBYTE)(alpha_value * brush_alpha / 255);
1713
27649
                        if (combined_alpha)
1714
                        {
1715
27643
                            get += 2;
1716
27643
                            pixel = *(USHORT *)get;
1717
27643
                            r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1718
27643
                            g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1719
27643
                            b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1720
27643
                            pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1721
27643
                            get += 2;
1722
162397
                            while (count--)
1723
                            {
1724
134754
                                if (xval >= rotated_clip.gx_rectangle_left &&
1725
134558
                                    xval <= rotated_clip.gx_rectangle_right)
1726
                                {
1727
134426
                                    blend_func(context, xval, yval, pixel, combined_alpha);
1728
                                }
1729
134754
                                xval++;
1730
                            }
1731
                        }
1732
                        else
1733
                        {
1734
6
                            get += 4;
1735
6
                            xval += count;
1736
                        }
1737
                    }
1738
                }
1739
                else
1740
                {
1741
13558
                    xval += count;
1742
13558
                    get += 4;
1743
                }
1744
            }
1745
            else
1746
            {
1747
1748
                /* String of non-repeated values.  */
1749
124296
                count++;
1750
124296
                if (brush_alpha == 0xff)
1751
                {
1752
638360
                    while (count--)
1753
                    {
1754
541606
                        if (xval >= rotated_clip.gx_rectangle_left &&
1755
540684
                            xval <= rotated_clip.gx_rectangle_right)
1756
                        {
1757
539709
                            alpha_value = *(get + 1);
1758
539709
                            get += 2;
1759
539709
                            if (alpha_value)
1760
                            {
1761
539130
                                pixel = *(USHORT *)get;
1762
539130
                                r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1763
539130
                                g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1764
539130
                                b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1765
539130
                                pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1766
539130
                                if (alpha_value == 0xff)
1767
                                {
1768
515100
                                    _gx_display_driver_32bpp_pixel_write(context, xval, yval, pixel);
1769
                                }
1770
                                else
1771
                                {
1772
24030
                                    blend_func(context, xval, yval, pixel, alpha_value);
1773
                                }
1774
                            }
1775
539709
                            get += 2;
1776
                        }
1777
                        else
1778
                        {
1779
1897
                            get += 4;
1780
                        }
1781
541606
                        xval++;
1782
                    }
1783
                }
1784
                else
1785
                {
1786
182287
                    while (count--)
1787
                    {
1788
154745
                        if (xval >= rotated_clip.gx_rectangle_left &&
1789
153917
                            xval <= rotated_clip.gx_rectangle_right)
1790
                        {
1791
153141
                            alpha_value = *(get + 1);
1792
153141
                            get += 2;
1793
153141
                            if (alpha_value)
1794
                            {
1795
152594
                                pixel = *(USHORT *)get;
1796
152594
                                r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1797
152594
                                g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1798
152594
                                b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1799
152594
                                pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1800
152594
                                combined_alpha = (GX_UBYTE)(brush_alpha * alpha_value / 255);
1801
152594
                                blend_func(context, xval, yval, pixel, combined_alpha);
1802
                            }
1803
153141
                            get += 2;
1804
                        }
1805
                        else
1806
                        {
1807
1604
                            get += 4;
1808
                        }
1809
154745
                        xval++;
1810
                    }
1811
                }
1812
            }
1813
        }
1814
6934
        yval++;
1815
    }
1816
}
1817
1818
/**************************************************************************/
1819
/*                                                                        */
1820
/*  FUNCTION                                               RELEASE        */
1821
/*                                                                        */
1822
/*    _gx_display_driver_24xrgb_rotated_565rgb_pixelmap_alpha_write       */
1823
/*                                                                        */
1824
/*                                                        PORTABLE C      */
1825
/*                                                           6.1.5        */
1826
/*  AUTHOR                                                                */
1827
/*                                                                        */
1828
/*    Kenneth Maxwell, Microsoft Corporation                              */
1829
/*                                                                        */
1830
/*  DESCRIPTION                                                           */
1831
/*                                                                        */
1832
/*    Internal helper function that handles writing of non_compressed     */
1833
/*    but with alpha channel pixelmap data of 565rgb format with 32bpp    */
1834
/*    driver.                                                             */
1835
/*                                                                        */
1836
/*  INPUT                                                                 */
1837
/*                                                                        */
1838
/*    context                               Drawing context               */
1839
/*    xpos                                  x-coord of top-left draw point*/
1840
/*    ypos                                  y-coord of top-left draw point*/
1841
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1842
/*                                                                        */
1843
/*  OUTPUT                                                                */
1844
/*                                                                        */
1845
/*    None                                                                */
1846
/*                                                                        */
1847
/*  CALLS                                                                 */
1848
/*                                                                        */
1849
/*    _gx_display_driver_24xrgb_pixel_blend                               */
1850
/*    _gx_display_driver_32bpp_pixel_write                                */
1851
/*                                                                        */
1852
/*  CALLED BY                                                             */
1853
/*                                                                        */
1854
/*    _gx_display_driver_32bpp_rotated_pixelmap_draw                      */
1855
/*                                                                        */
1856
/*  RELEASE HISTORY                                                       */
1857
/*                                                                        */
1858
/*    DATE              NAME                      DESCRIPTION             */
1859
/*                                                                        */
1860
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
1861
/*  03-02-2021     Ting Zhu                 Modified comment(s), changed  */
1862
/*                                            blend function set macro,   */
1863
/*                                            resulting in version 6.1.5  */
1864
/*                                                                        */
1865
/**************************************************************************/
1866
555
static VOID _gx_display_driver_32bpp_rotated_565rgb_pixelmap_alpha_write(GX_DRAW_CONTEXT *context,
1867
                                                                         INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1868
{
1869
INT                skipcount;
1870
INT                xval;
1871
INT                yval;
1872
GX_CONST GX_UBYTE *getalpha;
1873
GX_CONST USHORT   *get;
1874
USHORT            *getrow;
1875
GX_UBYTE          *getrowalpha;
1876
GX_UBYTE           r;
1877
GX_UBYTE           g;
1878
GX_UBYTE           b;
1879
GX_COLOR           pixel;
1880
GX_UBYTE           alpha_value;
1881
1882
555
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
1883
GX_RECTANGLE       rotated_clip;
1884
VOID               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
1885
1886
555
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
1887
1888
545
    GX_SWAP_VALS(xpos, ypos);
1889
1890
545
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
1891
    {
1892
275
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
1893
275
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
1894
275
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
1895
275
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
1896
275
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
1897
    }
1898
    else
1899
    {
1900
270
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
1901
270
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
1902
270
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
1903
270
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
1904
270
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
1905
    }
1906
545
    skipcount = (pixelmap -> gx_pixelmap_height) * (rotated_clip.gx_rectangle_top - ypos);
1907
545
    skipcount += (rotated_clip.gx_rectangle_left - xpos);
1908
545
    getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
1909
545
    getrow += skipcount;
1910
1911
545
    getrowalpha = (GX_UBYTE *)(pixelmap -> gx_pixelmap_aux_data);
1912
545
    getrowalpha += skipcount;
1913
1914
21141
    for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
1915
    {
1916
20596
        get = getrow;
1917
20596
        getalpha = getrowalpha;
1918
1919
799995
        for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
1920
        {
1921
779399
            alpha_value = *getalpha++;
1922
779399
            pixel = *get++;
1923
779399
            if (alpha_value)
1924
            {
1925
602821
                r = (GX_UBYTE)(REDVAL_16BPP(pixel) << 3);
1926
602821
                g = (GX_UBYTE)(GREENVAL_16BPP(pixel) << 2);
1927
602821
                b = (GX_UBYTE)(BLUEVAL_16BPP(pixel) << 3);
1928
602821
                pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
1929
602821
                if (alpha_value == 0xff)
1930
                {
1931
528583
                    _gx_display_driver_32bpp_pixel_write(context, xval, yval, pixel);
1932
                }
1933
                else
1934
                {
1935
74238
                    blend_func(context, xval, yval, pixel, alpha_value);
1936
                }
1937
            }
1938
        }
1939
20596
        getrow += pixelmap -> gx_pixelmap_height;
1940
20596
        getrowalpha += pixelmap -> gx_pixelmap_height;
1941
    }
1942
}
1943
1944
/**************************************************************************/
1945
/*                                                                        */
1946
/*  FUNCTION                                               RELEASE        */
1947
/*                                                                        */
1948
/*    _gx_display_driver_32bpp_rotated_4444argb_pixelmap_alpha_write      */
1949
/*                                                                        */
1950
/*                                                        PORTABLE C      */
1951
/*                                                           6.1.5        */
1952
/*  AUTHOR                                                                */
1953
/*                                                                        */
1954
/*    Kenneth Maxwell, Microsoft Corporation                              */
1955
/*                                                                        */
1956
/*  DESCRIPTION                                                           */
1957
/*                                                                        */
1958
/*    Internal helper function that handles writing of uncompressed       */
1959
/*    pixlemap file with alpha channel of 4444argb format.                */
1960
/*                                                                        */
1961
/*  INPUT                                                                 */
1962
/*                                                                        */
1963
/*    context                               Drawing context               */
1964
/*    xpos                                  x-coord of top-left draw point*/
1965
/*    ypos                                  y-coord of top-left draw point*/
1966
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
1967
/*                                                                        */
1968
/*  OUTPUT                                                                */
1969
/*                                                                        */
1970
/*    None                                                                */
1971
/*                                                                        */
1972
/*  CALLS                                                                 */
1973
/*                                                                        */
1974
/*    _gx_display_driver_24xrgb_pixel_blend                               */
1975
/*    _gx_display_driver_32bpp_pixel_write                                */
1976
/*                                                                        */
1977
/*  CALLED BY                                                             */
1978
/*                                                                        */
1979
/*    _gx_display_driver_32bpp_rotated_pixelmap_draw                      */
1980
/*                                                                        */
1981
/*  RELEASE HISTORY                                                       */
1982
/*                                                                        */
1983
/*    DATE              NAME                      DESCRIPTION             */
1984
/*                                                                        */
1985
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
1986
/*  03-02-2021     Ting Zhu                 Modified comment(s), changed  */
1987
/*                                            blend function set macro,   */
1988
/*                                            resulting in version 6.1.5  */
1989
/*                                                                        */
1990
/**************************************************************************/
1991
817
static VOID _gx_display_driver_32bpp_rotated_4444argb_pixelmap_alpha_write(GX_DRAW_CONTEXT *context,
1992
                                                                           INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
1993
{
1994
INT              skipcount;
1995
INT              xval;
1996
INT              yval;
1997
USHORT          *getrow;
1998
GX_CONST USHORT *get;
1999
UCHAR            alpha_value;
2000
ULONG            pixel;
2001
2002
817
GX_RECTANGLE    *clip = context -> gx_draw_context_clip;
2003
GX_RECTANGLE     rotated_clip;
2004
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
2005
2006
817
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
2007
2008
807
    GX_SWAP_VALS(xpos, ypos);
2009
2010
807
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
2011
    {
2012
535
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
2013
535
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
2014
535
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
2015
535
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
2016
535
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
2017
    }
2018
    else
2019
    {
2020
272
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
2021
272
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
2022
272
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
2023
272
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
2024
272
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
2025
    }
2026
2027
    /* Calculate how many pixels to skip.  */
2028
807
    skipcount = (pixelmap -> gx_pixelmap_height) * (rotated_clip.gx_rectangle_top - ypos);
2029
807
    skipcount += (rotated_clip.gx_rectangle_left - xpos);
2030
807
    getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
2031
807
    getrow += skipcount;
2032
2033
31359
    for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
2034
    {
2035
30552
        get = getrow;
2036
2037
1188279
        for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
2038
        {
2039
1157727
            alpha_value = (UCHAR)(((*get) & 0xf000) >> 8);
2040
1157727
            if (alpha_value)
2041
            {
2042
2043
                /* Convert 4444argb pixel to 24xrgb pixel.  */
2044
430230
                pixel = (GX_COLOR)((((*get) & 0x0f00) << 12) | (((*get) & 0x00f0) << 8) | (((*get) & 0x000f) << 4));
2045
430230
                pixel |= 0xff000000;
2046
430230
                if (alpha_value == 0xf0)
2047
                {
2048
317829
                    _gx_display_driver_32bpp_pixel_write(context, xval, yval, pixel);
2049
                }
2050
                else
2051
                {
2052
112401
                    blend_func(context, xval, yval, pixel, alpha_value);
2053
                }
2054
            }
2055
1157727
            get++;
2056
        }
2057
30552
        getrow += pixelmap -> gx_pixelmap_height;
2058
    }
2059
}
2060
2061
/**************************************************************************/
2062
/*                                                                        */
2063
/*  FUNCTION                                               RELEASE        */
2064
/*                                                                        */
2065
/*    _gx_display_driver_24xrgb_4444argb_rotated_pixelmap_compressed_     */
2066
/*                                                            alpha_write */
2067
/*                                                                        */
2068
/*                                                        PORTABLE C      */
2069
/*                                                           6.1.5        */
2070
/*  AUTHOR                                                                */
2071
/*                                                                        */
2072
/*    Kenneth Maxwell, Microsoft Corporation                              */
2073
/*                                                                        */
2074
/*  DESCRIPTION                                                           */
2075
/*                                                                        */
2076
/*    Internal helper function that handles writing of rotated compressed */
2077
/*    pixelmap data of 4444argb format.                                   */
2078
/*                                                                        */
2079
/*  INPUT                                                                 */
2080
/*                                                                        */
2081
/*    context                               Drawing context               */
2082
/*    xpos                                  x-coord of top-left draw point*/
2083
/*    ypos                                  y-coord of top-left draw point*/
2084
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
2085
/*                                                                        */
2086
/*  OUTPUT                                                                */
2087
/*                                                                        */
2088
/*    None                                                                */
2089
/*                                                                        */
2090
/*  CALLS                                                                 */
2091
/*                                                                        */
2092
/*    _gx_display_driver_24xrgb_pixel_blend                               */
2093
/*                                                                        */
2094
/*  CALLED BY                                                             */
2095
/*                                                                        */
2096
/*    _gx_display_driver_32bpp_rotated_pixelmap_draw                      */
2097
/*                                                                        */
2098
/*  RELEASE HISTORY                                                       */
2099
/*                                                                        */
2100
/*    DATE              NAME                      DESCRIPTION             */
2101
/*                                                                        */
2102
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
2103
/*  03-02-2021     Ting Zhu                 Modified comment(s), changed  */
2104
/*                                            blend function set macro,   */
2105
/*                                            resulting in version 6.1.5  */
2106
/*                                                                        */
2107
/**************************************************************************/
2108
837
static VOID _gx_display_driver_32bpp_rotated_4444argb_pixelmap_compressed_alpha_write(GX_DRAW_CONTEXT *context,
2109
                                                                                      INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
2110
{
2111
INT              yval;
2112
INT              xval;
2113
GX_CONST USHORT *get;
2114
USHORT           count;
2115
GX_COLOR         pixel;
2116
GX_UBYTE         falpha;
2117
GX_UBYTE         brush_alpha;
2118
GX_UBYTE         combined_alpha;
2119
GX_UBYTE         r;
2120
GX_UBYTE         g;
2121
GX_UBYTE         b;
2122
837
GX_RECTANGLE    *clip = context -> gx_draw_context_clip;
2123
GX_RECTANGLE     rotated_clip;
2124
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
2125
2126
837
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
2127
2128
817
    GX_SWAP_VALS(xpos, ypos);
2129
2130
817
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
2131
    {
2132
545
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
2133
545
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
2134
545
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
2135
545
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
2136
545
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
2137
    }
2138
    else
2139
    {
2140
272
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
2141
272
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
2142
272
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
2143
272
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
2144
272
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
2145
    }
2146
817
    get = (GX_CONST USHORT *)pixelmap -> gx_pixelmap_data;
2147
817
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
2148
2149
    /* First, skip to the starting row.  */
2150
909
    for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++)
2151
    {
2152
92
        xval = 0;
2153
278
        while (xval < pixelmap -> gx_pixelmap_height)
2154
        {
2155
186
            count = *get++;
2156
2157
186
            if (count & 0x8000)
2158
            {
2159
144
                count = (USHORT)((count & 0x7fff) + 1);
2160
2161
                /* Skip repeated pixel value.  */
2162
144
                get++;
2163
            }
2164
            else
2165
            {
2166
42
                count++;
2167
2168
                /* Skip raw pixel values.  */
2169
42
                get += count;
2170
            }
2171
186
            xval += count;
2172
        }
2173
    }
2174
2175
    /* Now we are on the first visible row, copy pixels until we get
2176
       to the enf of the last visible row.  */
2177
31673
    while (yval <= rotated_clip.gx_rectangle_bottom)
2178
    {
2179
30856
        xval = xpos;
2180
2181
117098
        while (xval < xpos + pixelmap -> gx_pixelmap_height)
2182
        {
2183
86242
            count = *get++;
2184
2185
86242
            if (count & 0x8000)
2186
            {
2187
                /* Repeated value.  */
2188
47116
                count = (USHORT)((count & 0x7fff) + 1);
2189
47116
                pixel = *get++;
2190
47116
                falpha = (GX_UBYTE)(((USHORT)pixel & 0xf000) >> 8);
2191
47116
                falpha = (falpha >> 4) | falpha;
2192
47116
                if (falpha)
2193
                {
2194
18761
                    r = (GX_UBYTE)(((USHORT)pixel & 0x0f00) >> 4);
2195
18761
                    r = (GX_UBYTE)((r >> 4) | r);
2196
18761
                    g = (GX_UBYTE)((USHORT)pixel & 0x00f0);
2197
18761
                    g = (GX_UBYTE)((g >> 4) | g);
2198
18761
                    b = (GX_UBYTE)((USHORT)pixel & 0x000f);
2199
18761
                    b = (GX_UBYTE)((b << 4) | b);
2200
18761
                    pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
2201
18761
                    if (brush_alpha == 0xff)
2202
                    {
2203
18543
                        combined_alpha = falpha;
2204
                    }
2205
                    else
2206
                    {
2207
218
                        combined_alpha = (GX_UBYTE)(brush_alpha * falpha / 255);
2208
                    }
2209
2210
77495
                    while (count--)
2211
                    {
2212
58734
                        if (xval >= rotated_clip.gx_rectangle_left &&
2213
58622
                            xval <= rotated_clip.gx_rectangle_right)
2214
                        {
2215
58564
                            blend_func(context, xval, yval, pixel, combined_alpha);
2216
                        }
2217
58734
                        xval++;
2218
                    }
2219
                }
2220
                else
2221
                {
2222
28355
                    xval += count;
2223
                }
2224
            }
2225
            else
2226
            {
2227
2228
                /* String of non-repeated values.  */
2229
39126
                count++;
2230
39126
                if (brush_alpha == 0xff)
2231
                {
2232
557964
                    while (count--)
2233
                    {
2234
519282
                        if (xval >= rotated_clip.gx_rectangle_left &&
2235
518368
                            xval <= rotated_clip.gx_rectangle_right)
2236
                        {
2237
517380
                            pixel = *get;
2238
517380
                            falpha = (GX_UBYTE)(((USHORT)pixel & 0xf000) >> 8);
2239
517380
                            falpha = (falpha >> 4) | falpha;
2240
517380
                            r = (GX_UBYTE)(((USHORT)pixel & 0x0f00) >> 4);
2241
517380
                            r = (GX_UBYTE)((r >> 4) | r);
2242
517380
                            g = (GX_UBYTE)((USHORT)pixel & 0x00f0);
2243
517380
                            g = (GX_UBYTE)((g >> 4) | g);
2244
517380
                            b = (GX_UBYTE)((USHORT)pixel & 0x000f);
2245
517380
                            b = (GX_UBYTE)((b << 4) | b);
2246
517380
                            pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
2247
517380
                            if (falpha)
2248
                            {
2249
490935
                                blend_func(context, xval, yval, pixel, falpha);
2250
                            }
2251
                        }
2252
519282
                        get++;
2253
519282
                        xval++;
2254
                    }
2255
                }
2256
                else
2257
                {
2258
6600
                    while (count--)
2259
                    {
2260
6156
                        if (xval >= rotated_clip.gx_rectangle_left &&
2261
5596
                            xval <= rotated_clip.gx_rectangle_right)
2262
                        {
2263
4888
                            pixel = *get;
2264
4888
                            falpha = (GX_UBYTE)(((USHORT)pixel & 0xf000) >> 8);
2265
4888
                            falpha = (falpha >> 4) | falpha;
2266
4888
                            combined_alpha = (GX_UBYTE)(falpha * brush_alpha / 255);
2267
4888
                            r = (GX_UBYTE)(((USHORT)pixel & 0x0f00) >> 4);
2268
4888
                            r = (GX_UBYTE)((r >> 4) | r);
2269
4888
                            g = (GX_UBYTE)((USHORT)pixel & 0x00f0);
2270
4888
                            g = (GX_UBYTE)((g >> 4) | g);
2271
4888
                            b = (GX_UBYTE)((USHORT)pixel & 0x000f);
2272
4888
                            b = (GX_UBYTE)((b << 4) | b);
2273
4888
                            pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff, r, g, b);
2274
4888
                            blend_func(context, xval, yval, pixel, combined_alpha);
2275
                        }
2276
6156
                        get++;
2277
6156
                        xval++;
2278
                    }
2279
                }
2280
            }
2281
        }
2282
30856
        yval++;
2283
    }
2284
}
2285
2286
/**************************************************************************/
2287
/*                                                                        */
2288
/*  FUNCTION                                               RELEASE        */
2289
/*                                                                        */
2290
/*    _gx_display_driver_24xrgb_rotated_pixelmap_draw     PORTABLE C      */
2291
/*                                                           6.1.5        */
2292
/*  AUTHOR                                                                */
2293
/*                                                                        */
2294
/*    Kenneth Maxwell, Microsoft Corporation                              */
2295
/*                                                                        */
2296
/*  DESCRIPTION                                                           */
2297
/*                                                                        */
2298
/*    32xrgb format screen driver pixelmap drawing function that handles  */
2299
/*    compressed or uncompress, with or without alpha channel.            */
2300
/*                                                                        */
2301
/*  INPUT                                                                 */
2302
/*                                                                        */
2303
/*    context                               Drawing context               */
2304
/*    xpos                                  x-coord of top-left draw point*/
2305
/*    ypos                                  y-coord of top-left draw point*/
2306
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
2307
/*                                                                        */
2308
/*  OUTPUT                                                                */
2309
/*                                                                        */
2310
/*    None                                                                */
2311
/*                                                                        */
2312
/*  CALLS                                                                 */
2313
/*                                                                        */
2314
/*    _gx_display_driver_24xrgb_rotated_palette_pixelmap_transparent_     */
2315
/*                                                       compressed_write */
2316
/*    _gx_display_driver_24xrgb_rotated_palette_pixelmap_transparent_write*/
2317
/*    _gx_display_driver_24xrgb_rotated_palette_pixelmap_compressed_write */
2318
/*    _gx_display_driver_24xrgb_rotated_palette_pixelmap_write            */
2319
/*    _gx_display_driver_24xrgb_rotated_4444argb_pixelmap_compressed_     */
2320
/*                                                            alpha_write */
2321
/*    _gx_display_driver_24xrgb_rotated_4444argb_pixelmap_alpha_write     */
2322
/*    _gx_display_driver_24xrgb_rotated_565rgb_pixelmap_compressed_alpha_ */
2323
/*                                                                  write */
2324
/*    _gx_display_driver_24xrgb_rotated_565rgb_pixelmap_alpha_write       */
2325
/*    _gx_display_driver_24xrgb_rotated_565rgb_pixelmap_compressed_write  */
2326
/*    _gx_display_driver_24xrgb_rotated_565rgb_pixelmap_raw_write         */
2327
/*    _gx_display_driver_24xrgb_rotated_pixelmap_compressed_alpha_write   */
2328
/*    _gx_display_driver_24xrgb_rotated_pixelmap_alpha_write              */
2329
/*    _gx_display_driver_24xrgb_rotated_pixelmap_compressed_write         */
2330
/*    _gx_display_driver_24xrgb_rotated_pixelmap_raw_write                */
2331
/*    _gx_display_driver_24xrgb_rotated_pixelmap_blend                    */
2332
/*                                                                        */
2333
/*  CALLED BY                                                             */
2334
/*                                                                        */
2335
/*    GUIX Internal Code                                                  */
2336
/*                                                                        */
2337
/*  RELEASE HISTORY                                                       */
2338
/*                                                                        */
2339
/*    DATE              NAME                      DESCRIPTION             */
2340
/*                                                                        */
2341
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
2342
/*  03-02-2021     Ting Zhu                 Modified comment(s),          */
2343
/*                                            added 8bit palette table    */
2344
/*                                            NULL pointer check,         */
2345
/*                                            resulting in version 6.1.5  */
2346
/*                                                                        */
2347
/**************************************************************************/
2348
44859
VOID _gx_display_driver_32bpp_rotated_pixelmap_draw(GX_DRAW_CONTEXT *context,
2349
                                                    INT xpos, INT ypos, GX_PIXELMAP *pixelmap)
2350
{
2351
44859
GX_BOOL  drawn = GX_FALSE;
2352
44859
GX_UBYTE brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
2353
2354
44859
    if (brush_alpha == 0)
2355
    {
2356
        /* Draw nothing here. Just return.  */
2357
5
        return;
2358
    }
2359
2360

44854
    switch (pixelmap -> gx_pixelmap_format)
2361
    {
2362
2040
    case GX_COLOR_FORMAT_8BIT_PALETTE:
2363
2040
        if (pixelmap -> gx_pixelmap_aux_data == GX_NULL)
2364
        {
2365
2366
            /* Palette data is not availlable.  */
2367
1
            return;
2368
        }
2369
2370
2039
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
2371
        {
2372
1949
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2373
            {
2374
                /* Compressed with transparent.  */
2375
1112
                _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_compressed_write(context, xpos, ypos, pixelmap);
2376
1112
                drawn = GX_TRUE;
2377
            }
2378
            else
2379
            {
2380
                /* No compression with transparent.  */
2381
837
                if (brush_alpha == 0xff)
2382
                {
2383
817
                    _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_write(context, xpos, ypos, pixelmap);
2384
817
                    drawn = GX_TRUE;
2385
                }
2386
            }
2387
        }
2388
        else
2389
        {
2390
90
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2391
            {
2392
                /* Compressed with no alpha.  */
2393
45
                _gx_display_driver_32bpp_rotated_palette_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2394
45
                drawn = GX_TRUE;
2395
            }
2396
            else
2397
            {
2398
                /* No compression or alpha.  */
2399
45
                if (brush_alpha == 0xff)
2400
                {
2401
25
                    _gx_display_driver_32bpp_rotated_palette_pixelmap_write(context, xpos, ypos, pixelmap);
2402
25
                    drawn = GX_TRUE;
2403
                }
2404
            }
2405
        }
2406
2039
        break;
2407
2408
1674
    case GX_COLOR_FORMAT_4444ARGB:
2409
1674
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2410
        {
2411
            /* Compressed.  */
2412
837
            _gx_display_driver_32bpp_rotated_4444argb_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2413
837
            drawn = GX_TRUE;
2414
        }
2415
        else
2416
        {
2417
            /* No compression.  */
2418
837
            if (brush_alpha == 0xff)
2419
            {
2420
817
                _gx_display_driver_32bpp_rotated_4444argb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2421
817
                drawn = GX_TRUE;
2422
            }
2423
        }
2424
1674
        break;
2425
2426
1806
    case GX_COLOR_FORMAT_565RGB:
2427
1806
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
2428
        {
2429
648
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2430
            {
2431
                /* Compressed with alpha.  */
2432
73
                _gx_display_driver_32bpp_rotated_565rgb_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2433
73
                drawn = GX_TRUE;
2434
            }
2435
            else
2436
            {
2437
                /* Uncompressed with alpha.  */
2438
575
                if (brush_alpha == 0xff)
2439
                {
2440
555
                    _gx_display_driver_32bpp_rotated_565rgb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2441
555
                    drawn = GX_TRUE;
2442
                }
2443
            }
2444
        }
2445
        else
2446
        {
2447
1158
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2448
            {
2449
2450
                /* Compressed without alpha.  */
2451
577
                _gx_display_driver_32bpp_rotated_565rgb_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2452
577
                drawn = GX_TRUE;
2453
            }
2454
            else
2455
            {
2456
2457
                /* Uncompressed withou alpha.  */
2458
581
                if (brush_alpha == 0xff)
2459
                {
2460
577
                    _gx_display_driver_32bpp_rotated_565rgb_pixelmap_raw_write(context, xpos, ypos, pixelmap);
2461
577
                    drawn = GX_TRUE;
2462
                }
2463
            }
2464
        }
2465
1806
        break;
2466
2467
39331
    case GX_COLOR_FORMAT_24XRGB:
2468
    case GX_COLOR_FORMAT_32ARGB:
2469
39331
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
2470
        {
2471
29125
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2472
            {
2473
2474
                /* Has both compression and alpha.  */
2475
21802
                _gx_display_driver_32bpp_rotated_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2476
21802
                drawn = GX_TRUE;
2477
            }
2478
            else
2479
            {
2480
2481
                /* Alpha, no compression.  */
2482
7323
                if (brush_alpha == 0xff)
2483
                {
2484
7278
                    _gx_display_driver_32bpp_rotated_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2485
7278
                    drawn = GX_TRUE;
2486
                }
2487
            }
2488
        }
2489
        else
2490
        {
2491
10206
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2492
            {
2493
2494
                /* Compressed with no alpha.  */
2495
9392
                _gx_display_driver_32bpp_rotated_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2496
9392
                drawn = GX_TRUE;
2497
            }
2498
            else
2499
            {
2500
2501
                /* No compression or alpha.  */
2502
814
                if (brush_alpha == 0xff)
2503
                {
2504
769
                    _gx_display_driver_32bpp_rotated_pixelmap_raw_write(context, xpos, ypos, pixelmap);
2505
769
                    drawn = GX_TRUE;
2506
                }
2507
            }
2508
        }
2509
39331
        break;
2510
2511
3
    default:
2512
3
        break;
2513
    }
2514
2515

44853
    if ((!drawn) && (brush_alpha != 0xff))
2516
    {
2517
176
        _gx_display_driver_32bpp_rotated_pixelmap_blend(context, xpos, ypos, pixelmap, brush_alpha);
2518
    }
2519
2520
44853
    return;
2521
}
2522