GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_32bpp_rotated_pixelmap_draw.c Lines: 820 820 100.0 %
Date: 2026-03-06 19:21:09 Branches: 428 429 99.8 %

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

44854
    switch (pixelmap -> gx_pixelmap_format)
2236
    {
2237
2040
    case GX_COLOR_FORMAT_8BIT_PALETTE:
2238
2040
        if (pixelmap -> gx_pixelmap_aux_data == GX_NULL)
2239
        {
2240
2241
            /* Palette data is not availlable.  */
2242
1
            return;
2243
        }
2244
2245
2039
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
2246
        {
2247
1949
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2248
            {
2249
                /* Compressed with transparent.  */
2250
1112
                _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_compressed_write(context, xpos, ypos, pixelmap);
2251
1112
                drawn = GX_TRUE;
2252
            }
2253
            else
2254
            {
2255
                /* No compression with transparent.  */
2256
837
                if (brush_alpha == 0xff)
2257
                {
2258
817
                    _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_write(context, xpos, ypos, pixelmap);
2259
817
                    drawn = GX_TRUE;
2260
                }
2261
            }
2262
        }
2263
        else
2264
        {
2265
90
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2266
            {
2267
                /* Compressed with no alpha.  */
2268
45
                _gx_display_driver_32bpp_rotated_palette_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2269
45
                drawn = GX_TRUE;
2270
            }
2271
            else
2272
            {
2273
                /* No compression or alpha.  */
2274
45
                if (brush_alpha == 0xff)
2275
                {
2276
25
                    _gx_display_driver_32bpp_rotated_palette_pixelmap_write(context, xpos, ypos, pixelmap);
2277
25
                    drawn = GX_TRUE;
2278
                }
2279
            }
2280
        }
2281
2039
        break;
2282
2283
1674
    case GX_COLOR_FORMAT_4444ARGB:
2284
1674
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2285
        {
2286
            /* Compressed.  */
2287
837
            _gx_display_driver_32bpp_rotated_4444argb_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2288
837
            drawn = GX_TRUE;
2289
        }
2290
        else
2291
        {
2292
            /* No compression.  */
2293
837
            if (brush_alpha == 0xff)
2294
            {
2295
817
                _gx_display_driver_32bpp_rotated_4444argb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2296
817
                drawn = GX_TRUE;
2297
            }
2298
        }
2299
1674
        break;
2300
2301
1806
    case GX_COLOR_FORMAT_565RGB:
2302
1806
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
2303
        {
2304
648
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2305
            {
2306
                /* Compressed with alpha.  */
2307
73
                _gx_display_driver_32bpp_rotated_565rgb_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2308
73
                drawn = GX_TRUE;
2309
            }
2310
            else
2311
            {
2312
                /* Uncompressed with alpha.  */
2313
575
                if (brush_alpha == 0xff)
2314
                {
2315
555
                    _gx_display_driver_32bpp_rotated_565rgb_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2316
555
                    drawn = GX_TRUE;
2317
                }
2318
            }
2319
        }
2320
        else
2321
        {
2322
1158
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2323
            {
2324
2325
                /* Compressed without alpha.  */
2326
577
                _gx_display_driver_32bpp_rotated_565rgb_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2327
577
                drawn = GX_TRUE;
2328
            }
2329
            else
2330
            {
2331
2332
                /* Uncompressed withou alpha.  */
2333
581
                if (brush_alpha == 0xff)
2334
                {
2335
577
                    _gx_display_driver_32bpp_rotated_565rgb_pixelmap_raw_write(context, xpos, ypos, pixelmap);
2336
577
                    drawn = GX_TRUE;
2337
                }
2338
            }
2339
        }
2340
1806
        break;
2341
2342
39331
    case GX_COLOR_FORMAT_24XRGB:
2343
    case GX_COLOR_FORMAT_32ARGB:
2344
39331
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
2345
        {
2346
29125
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2347
            {
2348
2349
                /* Has both compression and alpha.  */
2350
21802
                _gx_display_driver_32bpp_rotated_pixelmap_compressed_alpha_write(context, xpos, ypos, pixelmap);
2351
21802
                drawn = GX_TRUE;
2352
            }
2353
            else
2354
            {
2355
2356
                /* Alpha, no compression.  */
2357
7323
                if (brush_alpha == 0xff)
2358
                {
2359
7278
                    _gx_display_driver_32bpp_rotated_pixelmap_alpha_write(context, xpos, ypos, pixelmap);
2360
7278
                    drawn = GX_TRUE;
2361
                }
2362
            }
2363
        }
2364
        else
2365
        {
2366
10206
            if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
2367
            {
2368
2369
                /* Compressed with no alpha.  */
2370
9392
                _gx_display_driver_32bpp_rotated_pixelmap_compressed_write(context, xpos, ypos, pixelmap);
2371
9392
                drawn = GX_TRUE;
2372
            }
2373
            else
2374
            {
2375
2376
                /* No compression or alpha.  */
2377
814
                if (brush_alpha == 0xff)
2378
                {
2379
769
                    _gx_display_driver_32bpp_rotated_pixelmap_raw_write(context, xpos, ypos, pixelmap);
2380
769
                    drawn = GX_TRUE;
2381
                }
2382
            }
2383
        }
2384
39331
        break;
2385
2386
3
    default:
2387
3
        break;
2388
    }
2389
2390

44853
    if ((!drawn) && (brush_alpha != 0xff))
2391
    {
2392
176
        _gx_display_driver_32bpp_rotated_pixelmap_blend(context, xpos, ypos, pixelmap, brush_alpha);
2393
    }
2394
2395
44853
    return;
2396
}
2397