GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_32bpp_rotated_pixelmap_blend.c Lines: 182 217 83.9 %
Date: 2026-03-06 19:21:09 Branches: 79 86 91.9 %

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
/*  FUNCTION                                               RELEASE        */
33
/*                                                                        */
34
/*    _gx_display_driver_32bpp_rotated_pixelmap_raw_blend                 */
35
/*                                                        PORTABLE C      */
36
/*                                                           6.1.5        */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    Internal helper function that handles blending of rotated           */
44
/*    uncompressed pixlemap data without alpha channel.                   */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    context                               Drawing context               */
49
/*    xpos                                  x-coord of top-left draw point*/
50
/*    ypos                                  y-coord of top-left draw point*/
51
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
52
/*    alpha                                 blending value 0 to 255       */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    None                                                                */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    _gx_display_driver_24xrgb_pixel_blend                               */
61
/*    _gx_display_driver_32argb_pixel_blend                               */
62
/*                                                                        */
63
/*  CALLED BY                                                             */
64
/*                                                                        */
65
/*    _gx_display_driver_32bpp_rotated_pixelmap_blend                     */
66
/*                                                                        */
67
/**************************************************************************/
68
45
static VOID _gx_display_driver_32bpp_rotated_pixelmap_raw_blend(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
69
{
70
INT           yval;
71
INT           xval;
72
ULONG        *get;
73
ULONG        *getrow;
74
45
GX_RECTANGLE *clip = context -> gx_draw_context_clip;
75
GX_RECTANGLE  rotated_clip;
76
VOID          (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
77
78
45
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
79
80
25
    GX_SWAP_VALS(xpos, ypos);
81
82
25
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
83
    {
84
25
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
85
25
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
86
25
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
87
25
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
88
25
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
89
    }
90
    else
91
    {
92
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
93
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
94
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
95
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
96
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
97
    }
98
99
25
    getrow = (GX_COLOR *)pixelmap -> gx_pixelmap_data;
100
25
    getrow +=  pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos);
101
25
    getrow += (rotated_clip.gx_rectangle_left - xpos);
102
103
2505
    for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
104
    {
105
2480
        get = getrow;
106
279625
        for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
107
        {
108
277145
            blend_func(context, xval, yval, (*get++), alpha);
109
        }
110
2480
        getrow += pixelmap -> gx_pixelmap_height;
111
    }
112
}
113
114
/**************************************************************************/
115
/*                                                                        */
116
/*  FUNCTION                                               RELEASE        */
117
/*                                                                        */
118
/*    _gx_display_driver_32bpp_rotated_pixelmap_alpha_blend               */
119
/*                                                        PORTABLE C      */
120
/*                                                           6.1.5        */
121
/*  AUTHOR                                                                */
122
/*                                                                        */
123
/*    Kenneth Maxwell, Microsoft Corporation                              */
124
/*                                                                        */
125
/*  DESCRIPTION                                                           */
126
/*                                                                        */
127
/*    Internal helper function that handles blending of rotated           */
128
/*    uncompressed pixlemap data with alpha channel.                      */
129
/*                                                                        */
130
/*  INPUT                                                                 */
131
/*                                                                        */
132
/*    context                               Drawing context               */
133
/*    xpos                                  x-coord of top-left draw point*/
134
/*    ypos                                  y-coord of top-left draw point*/
135
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
136
/*    alpha                                 blending value 0 to 255       */
137
/*                                                                        */
138
/*  OUTPUT                                                                */
139
/*                                                                        */
140
/*    None                                                                */
141
/*                                                                        */
142
/*  CALLS                                                                 */
143
/*                                                                        */
144
/*    _gx_display_driver_24xrgb_pixel_blend                               */
145
/*    _gx_display_driver_32argb_pixel_blend                               */
146
/*                                                                        */
147
/*  CALLED BY                                                             */
148
/*                                                                        */
149
/*    _gx_display_driver_32bpp_rotated_pixelmap_blend                     */
150
/*                                                                        */
151
/**************************************************************************/
152
45
static VOID _gx_display_driver_32bpp_rotated_pixelmap_alpha_blend(GX_DRAW_CONTEXT *context,
153
                                                                  INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
154
{
155
int           xval;
156
int           yval;
157
ULONG        *get;
158
ULONG        *getrow;
159
UCHAR         alpha_value;
160
ULONG         combined_alpha;
161
ULONG         color;
162
45
GX_RECTANGLE *clip = context -> gx_draw_context_clip;
163
GX_RECTANGLE  rotated_clip;
164
VOID          (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
165
166
45
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
167
168
25
    GX_SWAP_VALS(xpos, ypos);
169
170
25
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
171
    {
172
25
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
173
25
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
174
25
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
175
25
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
176
25
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
177
    }
178
    else
179
    {
180
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
181
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
182
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
183
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
184
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
185
    }
186
187
25
    getrow = (GX_COLOR *)(pixelmap -> gx_pixelmap_data);
188
25
    getrow += (pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos));
189
25
    getrow += (rotated_clip.gx_rectangle_left - xpos);
190
191
3140
    for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
192
    {
193
3115
        get = getrow;
194
741891
        for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
195
        {
196
738776
            color = (*get);
197
738776
            alpha_value = ALPHAVAL_32BPP(color);
198
199
738776
            if (alpha_value)
200
            {
201
540905
                combined_alpha = alpha_value;
202
540905
                combined_alpha *= alpha;
203
540905
                combined_alpha /= 255;
204
205
540905
                if (combined_alpha)
206
                {
207
540893
                    color |= 0xff000000;
208
540893
                    blend_func(context, xval, yval, color, (GX_UBYTE)combined_alpha);
209
                }
210
            }
211
738776
            get++;
212
        }
213
3115
        getrow += pixelmap -> gx_pixelmap_height;
214
    }
215
}
216
217
218
/**************************************************************************/
219
/*                                                                        */
220
/*  FUNCTION                                               RELEASE        */
221
/*                                                                        */
222
/*    _gx_display_driver_32bpp_rotated_palette_pixelmap_blend             */
223
/*                                                          PORTABLE C    */
224
/*                                                           6.1.5        */
225
/*  AUTHOR                                                                */
226
/*                                                                        */
227
/*    Kenneth Maxwell, Microsoft Corporation                              */
228
/*                                                                        */
229
/*  DESCRIPTION                                                           */
230
/*                                                                        */
231
/*    Internal helper function that handles writing of rotated            */
232
/*    uncompressed palette pixlemap data without transparent.             */
233
/*                                                                        */
234
/*  INPUT                                                                 */
235
/*                                                                        */
236
/*    context                               Drawing context               */
237
/*    xpos                                  x-coord of top-left draw point*/
238
/*    ypos                                  y-coord of top-left draw point*/
239
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
240
/*    alpha                                 blending value 0 to 255       */
241
/*                                                                        */
242
/*  OUTPUT                                                                */
243
/*                                                                        */
244
/*    None                                                                */
245
/*                                                                        */
246
/*  CALLS                                                                 */
247
/*                                                                        */
248
/*    _gx_display_driver_24xrgb_pixel_blend                               */
249
/*    _gx_display_driver_32argb_pixel_blend                               */
250
/*                                                                        */
251
/*  CALLED BY                                                             */
252
/*                                                                        */
253
/*    _gx_display_driver_32bpp_rotated_pixelmap_blend                     */
254
/*                                                                        */
255
/**************************************************************************/
256
20
static VOID _gx_display_driver_32bpp_rotated_palette_pixelmap_blend(GX_DRAW_CONTEXT *context,
257
                                                                    INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
258
{
259
INT           xval;
260
INT           yval;
261
GX_UBYTE     *getrow;
262
GX_UBYTE     *get;
263
GX_COLOR     *palette;
264
20
GX_RECTANGLE *clip = context -> gx_draw_context_clip;
265
GX_RECTANGLE  rotated_clip;
266
VOID          (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
267
268
20
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
269
270
10
    GX_SWAP_VALS(xpos, ypos);
271
272
10
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
273
    {
274
10
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
275
10
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
276
10
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
277
10
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
278
10
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
279
    }
280
    else
281
    {
282
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
283
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
284
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
285
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
286
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
287
    }
288
289
10
    getrow = (GX_UBYTE *)(pixelmap -> gx_pixelmap_data);
290
10
    getrow += pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos);
291
10
    getrow += (rotated_clip.gx_rectangle_left - xpos);
292
293
294
10
    palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
295
296
2334
    for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
297
    {
298
2324
        get = getrow;
299
277630
        for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
300
        {
301
275306
            blend_func(context, xval, yval, palette[*get++], alpha);
302
        }
303
304
2324
        getrow += pixelmap -> gx_pixelmap_height;
305
    }
306
}
307
308
/**************************************************************************/
309
/*                                                                        */
310
/*  FUNCTION                                               RELEASE        */
311
/*                                                                        */
312
/*    _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_blend */
313
/*                                                                        */
314
/*                                                         PORTABLE C     */
315
/*                                                           6.1.5        */
316
/*  AUTHOR                                                                */
317
/*                                                                        */
318
/*    Kenneth Maxwell, Microsoft Corporation                              */
319
/*                                                                        */
320
/*  DESCRIPTION                                                           */
321
/*                                                                        */
322
/*    Internal helper function that handles writing of rotated            */
323
/*    uncompressed palette pixlemap data with transparent.                */
324
/*                                                                        */
325
/*  INPUT                                                                 */
326
/*                                                                        */
327
/*    context                               Drawing context               */
328
/*    xpos                                  x-coord of top-left draw point*/
329
/*    ypos                                  y-coord of top-left draw point*/
330
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
331
/*    alpha                                 blending value 0 to 255       */
332
/*                                                                        */
333
/*  OUTPUT                                                                */
334
/*                                                                        */
335
/*    None                                                                */
336
/*                                                                        */
337
/*  CALLS                                                                 */
338
/*                                                                        */
339
/*    _gx_display_driver_24xrgb_pixel_blend                               */
340
/*    _gx_display_driver_32argb_pixel_blend                               */
341
/*                                                                        */
342
/*  CALLED BY                                                             */
343
/*                                                                        */
344
/*    GUIX Internal Code                                                  */
345
/*                                                                        */
346
/**************************************************************************/
347
20
static VOID _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_blend(GX_DRAW_CONTEXT *context,
348
                                                                                INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
349
{
350
INT           xval;
351
INT           yval;
352
GX_UBYTE     *getrow;
353
GX_UBYTE     *get;
354
GX_COLOR     *palette;
355
20
GX_RECTANGLE *clip = context -> gx_draw_context_clip;
356
GX_RECTANGLE  rotated_clip;
357
VOID          (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
358
359
20
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
360
361
10
    GX_SWAP_VALS(xpos, ypos);
362
363
10
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
364
    {
365
10
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
366
10
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
367
10
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
368
10
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
369
10
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
370
    }
371
    else
372
    {
373
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
374
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
375
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
376
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
377
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
378
    }
379
380
10
    getrow = (GX_UBYTE *)(pixelmap -> gx_pixelmap_data);
381
10
    getrow += pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos);
382
10
    getrow += (rotated_clip.gx_rectangle_left - xpos);
383
10
    palette = (GX_COLOR *)pixelmap -> gx_pixelmap_aux_data;
384
385
314
    for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
386
    {
387
304
        get = getrow;
388
9690
        for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
389
        {
390
9386
            if ((*get) != pixelmap -> gx_pixelmap_transparent_color)
391
            {
392
3718
                blend_func(context, xval, yval, palette[*get], alpha);
393
            }
394
9386
            get++;
395
        }
396
397
304
        getrow += pixelmap -> gx_pixelmap_height;
398
    }
399
}
400
401
/**************************************************************************/
402
/*                                                                        */
403
/*  FUNCTION                                               RELEASE        */
404
/*                                                                        */
405
/*    _gx_display_driver_32bpp_rotated_4444argb_pixelmap_alpha_blend      */
406
/*                                                                        */
407
/*                                                         PORTABLE C     */
408
/*                                                           6.1.5        */
409
/*  AUTHOR                                                                */
410
/*                                                                        */
411
/*    Kenneth Maxwell, Microsoft Corporation                              */
412
/*                                                                        */
413
/*  DESCRIPTION                                                           */
414
/*                                                                        */
415
/*    Internal helper function that handles writing of rotated            */
416
/*    uncompressed 4444argb format pixlemap data with alpha channel.      */
417
/*                                                                        */
418
/*  INPUT                                                                 */
419
/*                                                                        */
420
/*    context                               Drawing context               */
421
/*    xpos                                  x-coord of top-left draw point*/
422
/*    ypos                                  y-coord of top-left draw point*/
423
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
424
/*    alpha                                 blending value 0 to 255       */
425
/*                                                                        */
426
/*  OUTPUT                                                                */
427
/*                                                                        */
428
/*    None                                                                */
429
/*                                                                        */
430
/*  CALLS                                                                 */
431
/*                                                                        */
432
/*    _gx_display_driver_24xrgb_pixel_blend                               */
433
/*                                                                        */
434
/*  CALLED BY                                                             */
435
/*                                                                        */
436
/*    _gx_display_driver_32bpp_rotated_pixelmap_blend                     */
437
/*                                                                        */
438
/**************************************************************************/
439
20
static VOID _gx_display_driver_32bpp_rotated_4444argb_pixelmap_alpha_blend(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
440
{
441
INT              xval;
442
INT              yval;
443
USHORT          *getrow;
444
GX_CONST USHORT *get;
445
UCHAR            falpha;
446
GX_UBYTE         combined_alpha;
447
ULONG            pixel;
448
449
20
GX_RECTANGLE    *clip = context -> gx_draw_context_clip;
450
GX_RECTANGLE     rotated_clip;
451
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
452
453
20
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
454
455
10
    GX_SWAP_VALS(xpos, ypos);
456
457
10
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
458
    {
459
10
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
460
10
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
461
10
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
462
10
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
463
10
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
464
    }
465
    else
466
    {
467
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
468
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
469
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
470
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
471
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
472
    }
473
474
    /* Calculate how many pixels to skip.  */
475
10
    getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
476
10
    getrow += pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos);
477
10
    getrow += (rotated_clip.gx_rectangle_left - xpos);
478
479
314
    for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
480
    {
481
304
        get = getrow;
482
483
9690
        for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
484
        {
485
486
            /* Pick alpha value from 4444argb color.  */
487
9386
            falpha = (UCHAR)(((*get) & 0xf000) >> 8);
488
489
9386
            if (falpha)
490
            {
491
                /* Extend alpha value to improve accuracy.  */
492
4340
                falpha = (GX_UBYTE)(falpha | (falpha >> 4));
493
494
                /* Convert 4444argb color to 24xrgb color.  */
495
4340
                pixel = (GX_COLOR)((((*get) & 0x0f00) << 12) | (((*get) & 0x00f0) << 8) | (((*get) & 0x000f) << 4));
496
4340
                pixel |= 0xff000000;
497
498
                /* Calulate combined alpha.  */
499
4340
                combined_alpha = (GX_UBYTE)(falpha * alpha / 255);
500
501
                /* Blend color to background.  */
502
4340
                blend_func(context, xval, yval, pixel, combined_alpha);
503
            }
504
9386
            get++;
505
        }
506
304
        getrow += pixelmap -> gx_pixelmap_height;
507
    }
508
}
509
510
/**************************************************************************/
511
/*                                                                        */
512
/*  FUNCTION                                               RELEASE        */
513
/*                                                                        */
514
/*    _gx_display_driver_32bpp_rotated_565rgb_pixelmap_alpha_blend        */
515
/*                                                                        */
516
/*                                                        PORTABLE C      */
517
/*                                                           6.1.5        */
518
/*  AUTHOR                                                                */
519
/*                                                                        */
520
/*    Kenneth Maxwell, Microsoft Corporation                              */
521
/*                                                                        */
522
/*  DESCRIPTION                                                           */
523
/*                                                                        */
524
/*    Internal helper function that handles writing of rotated            */
525
/*    uncompressed 565rgb format pixelmap data with alpha channel.        */
526
/*                                                                        */
527
/*  INPUT                                                                 */
528
/*                                                                        */
529
/*    context                               Drawing context               */
530
/*    xpos                                  x-coord of top-left draw point*/
531
/*    ypos                                  y-coord of top-left draw point*/
532
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
533
/*    alpha                                 blending value 0 to 255       */
534
/*                                                                        */
535
/*  OUTPUT                                                                */
536
/*                                                                        */
537
/*    None                                                                */
538
/*                                                                        */
539
/*  CALLS                                                                 */
540
/*                                                                        */
541
/*    _gx_display_driver_24xrgb_pixel_blend                               */
542
/*    _gx_display_driver_32argb_pixel_blend                               */
543
/*                                                                        */
544
/*  CALLED BY                                                             */
545
/*                                                                        */
546
/*    _gx_display_driver_32bpp_rotated_pixelmap_blend                     */
547
/*                                                                        */
548
/**************************************************************************/
549
20
static VOID _gx_display_driver_32bpp_rotated_565rgb_pixelmap_alpha_blend(GX_DRAW_CONTEXT *context,
550
                                                                         INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
551
{
552
INT                skipcount;
553
INT                xval;
554
INT                yval;
555
GX_CONST GX_UBYTE *getalpha;
556
GX_CONST USHORT   *get;
557
USHORT            *getrow;
558
GX_UBYTE          *getrowalpha;
559
GX_COLOR           pixel;
560
GX_UBYTE           falpha;
561
GX_UBYTE           combined_alpha;
562
20
GX_RECTANGLE      *clip = context -> gx_draw_context_clip;
563
GX_RECTANGLE       rotated_clip;
564
VOID               (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
565
566
20
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
567
568
10
    GX_SWAP_VALS(xpos, ypos);
569
570
10
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
571
    {
572
10
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
573
10
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
574
10
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
575
10
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
576
10
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
577
    }
578
    else
579
    {
580
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
581
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
582
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
583
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
584
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
585
    }
586
587
10
    skipcount = (pixelmap -> gx_pixelmap_height) * (rotated_clip.gx_rectangle_top - ypos);
588
10
    skipcount += (rotated_clip.gx_rectangle_left - xpos);
589
10
    getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
590
10
    getrow += skipcount;
591
592
10
    getrowalpha = (GX_UBYTE *)(pixelmap -> gx_pixelmap_aux_data);
593
10
    getrowalpha += skipcount;
594
595
314
    for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
596
    {
597
304
        get = getrow;
598
304
        getalpha = getrowalpha;
599
600
9690
        for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
601
        {
602
9386
            falpha = *getalpha++;
603
9386
            if (falpha)
604
            {
605
7914
                combined_alpha = (GX_UBYTE)(falpha * alpha / 255);
606
7914
                pixel = *get;
607
608
                /* Convert 565rgb color to 24xrgb color.  */
609
7914
                pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff,
610
                                                       REDVAL_16BPP(pixel) << 3,
611
                                                       GREENVAL_16BPP(pixel) << 2,
612
                                                       BLUEVAL_16BPP(pixel) << 3);
613
614
                /* Blend 24xrgb color to background.  */
615
7914
                blend_func(context, xval, yval, pixel, combined_alpha);
616
            }
617
9386
            get++;
618
        }
619
620
304
        getrow += pixelmap -> gx_pixelmap_height;
621
304
        getrowalpha += pixelmap -> gx_pixelmap_height;
622
    }
623
}
624
625
/**************************************************************************/
626
/*                                                                        */
627
/*  FUNCTION                                               RELEASE        */
628
/*                                                                        */
629
/*    _gx_display_driver_32bpp_rotated_565rgb_pixelmap_raw_blend          */
630
/*                                                        PORTABLE C      */
631
/*                                                           6.1.5        */
632
/*  AUTHOR                                                                */
633
/*                                                                        */
634
/*    Kenneth Maxwell, Microsoft Corporation                              */
635
/*                                                                        */
636
/*  DESCRIPTION                                                           */
637
/*                                                                        */
638
/*    Internal helper function that handles writing of rotated            */
639
/*    uncompressed 565rgb format pixlemap data without alpha channel.     */
640
/*                                                                        */
641
/*  INPUT                                                                 */
642
/*                                                                        */
643
/*    context                               Drawing context               */
644
/*    xpos                                  x-coord of top-left draw point*/
645
/*    ypos                                  y-coord of top-left draw point*/
646
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
647
/*    alpha                                 blending value 0 to 255       */
648
/*                                                                        */
649
/*  OUTPUT                                                                */
650
/*                                                                        */
651
/*    None                                                                */
652
/*                                                                        */
653
/*  CALLS                                                                 */
654
/*                                                                        */
655
/*    _gx_display_driver_24xrgb_pixel_blend                               */
656
/*    _gx_display_driver_32argb_pixel_blend                               */
657
/*                                                                        */
658
/*  CALLED BY                                                             */
659
/*                                                                        */
660
/*    _gx_display_driver_32bpp_rotated_pixelmap_blend                     */
661
/*                                                                        */
662
/**************************************************************************/
663
4
static VOID _gx_display_driver_32bpp_rotated_565rgb_pixelmap_raw_blend(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
664
{
665
INT              xval;
666
INT              yval;
667
USHORT          *getrow;
668
GX_CONST USHORT *get;
669
GX_COLOR         pixel;
670
4
GX_RECTANGLE    *clip = context -> gx_draw_context_clip;
671
GX_RECTANGLE     rotated_clip;
672
VOID             (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);
673
674
4
    GX_SET_32BPP_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format);
675
676
2
    GX_SWAP_VALS(xpos, ypos);
677
678
2
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
679
    {
680
2
        rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top;
681
2
        rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom;
682
2
        rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1);
683
2
        rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1);
684
2
        ypos = (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pixelmap -> gx_pixelmap_width);
685
    }
686
    else
687
    {
688
        rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1);
689
        rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1);
690
        rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left;
691
        rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right;
692
        xpos = (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pixelmap -> gx_pixelmap_height);
693
    }
694
695
2
    getrow = (USHORT *)(pixelmap -> gx_pixelmap_data);
696
2
    getrow += pixelmap -> gx_pixelmap_height * (rotated_clip.gx_rectangle_top - ypos);
697
2
    getrow += (rotated_clip.gx_rectangle_left - xpos);
698
699
8
    for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++)
700
    {
701
6
        get = getrow;
702
703
276
        for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++)
704
        {
705
            /* Convert 565rgb color to 24xrgb color.  */
706
270
            pixel = (GX_COLOR)ASSEMBLECOLOR_32ARGB(0xff,
707
                                                   REDVAL_16BPP(*get) << 3,
708
                                                   GREENVAL_16BPP(*get) << 2,
709
                                                   BLUEVAL_16BPP(*get) << 3);
710
711
270
            blend_func(context, xval, yval, pixel, alpha);
712
270
            get++;
713
        }
714
715
6
        getrow += pixelmap -> gx_pixelmap_height;
716
    }
717
}
718
719
/**************************************************************************/
720
/*                                                                        */
721
/*  FUNCTION                                               RELEASE        */
722
/*                                                                        */
723
/*    _gx_display_driver_32bpp_rotated_pixelmap_blend    PORTABLE C       */
724
/*                                                           6.1.4        */
725
/*  AUTHOR                                                                */
726
/*                                                                        */
727
/*    Kenneth Maxwell, Microsoft Corporation                              */
728
/*                                                                        */
729
/*  DESCRIPTION                                                           */
730
/*                                                                        */
731
/*    24xrgb format screen driver pixelmap blending function that         */
732
/*    handles uncompressed pixelmap blend, with or without alpha channel. */
733
/*                                                                        */
734
/*  INPUT                                                                 */
735
/*                                                                        */
736
/*    context                               Drawing context               */
737
/*    xpos                                  x-coord of top-left draw point*/
738
/*    ypos                                  y-coord of top-left draw point*/
739
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
740
/*    alpha                                 blending value 0 to 255       */
741
/*                                                                        */
742
/*  OUTPUT                                                                */
743
/*                                                                        */
744
/*    None                                                                */
745
/*                                                                        */
746
/*  CALLS                                                                 */
747
/*                                                                        */
748
/*    _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_blend */
749
/*    _gx_display_driver_32bpp_rotated_palette_pixelmap_blend             */
750
/*    _gx_display_driver_32bpp_rotated_4444argb_pixelmap_alpha_blend      */
751
/*    _gx_display_driver_32bpp_rotated_565rgb_pixelmap_alpha_blend        */
752
/*    _gx_display_driver_32bpp_rotated_565rgb_pixelmap_raw_blend          */
753
/*    _gx_display_driver_32bpp_rotated_pixelmap_alpha_blend               */
754
/*    _gx_display_driver_32bpp_rotated_pixelmap_raw_blend                 */
755
/*                                                                        */
756
/*  CALLED BY                                                             */
757
/*                                                                        */
758
/*    GUIX Internal Code                                                  */
759
/*                                                                        */
760
/**************************************************************************/
761
176
VOID _gx_display_driver_32bpp_rotated_pixelmap_blend(GX_DRAW_CONTEXT *context,
762
                                                     INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
763
{
764
176
    if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
765
    {
766
1
        return;
767
    }
768
769

175
    switch (pixelmap -> gx_pixelmap_format)
770
    {
771
40
    case GX_COLOR_FORMAT_8BIT_PALETTE:
772
40
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
773
        {
774
20
            _gx_display_driver_32bpp_rotated_palette_pixelmap_transparent_blend(context, xpos, ypos, pixelmap, alpha);
775
        }
776
        else
777
        {
778
20
            _gx_display_driver_32bpp_rotated_palette_pixelmap_blend(context, xpos, ypos, pixelmap, alpha);
779
        }
780
40
        break;
781
782
20
    case GX_COLOR_FORMAT_4444ARGB:
783
20
        _gx_display_driver_32bpp_rotated_4444argb_pixelmap_alpha_blend(context, xpos, ypos, pixelmap, alpha);
784
20
        break;
785
786
24
    case GX_COLOR_FORMAT_565RGB:
787
24
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
788
        {
789
20
            _gx_display_driver_32bpp_rotated_565rgb_pixelmap_alpha_blend(context, xpos, ypos, pixelmap, alpha);
790
        }
791
        else
792
        {
793
4
            _gx_display_driver_32bpp_rotated_565rgb_pixelmap_raw_blend(context, xpos, ypos, pixelmap, alpha);
794
        }
795
24
        break;
796
797
90
    case GX_COLOR_FORMAT_24XRGB:
798
    case GX_COLOR_FORMAT_32ARGB:
799
90
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
800
        {
801
45
            _gx_display_driver_32bpp_rotated_pixelmap_alpha_blend(context, xpos, ypos, pixelmap, alpha);
802
        }
803
        else
804
        {
805
45
            _gx_display_driver_32bpp_rotated_pixelmap_raw_blend(context, xpos, ypos, pixelmap, alpha);
806
        }
807
90
        break;
808
    }
809
810
175
    return;
811
}
812