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

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** GUIX Component                                                        */
16
/**                                                                       */
17
/**   Display Management (Display)                                        */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_display.h"
28
29
/**************************************************************************/
30
/*                                                                        */
31
/*  FUNCTION                                               RELEASE        */
32
/*                                                                        */
33
/*    _gx_display_driver_32argb_pixelmap_raw_blend        PORTABLE C      */
34
/*                                                           6.1.7        */
35
/*  AUTHOR                                                                */
36
/*                                                                        */
37
/*    Kenneth Maxwell, Microsoft Corporation                              */
38
/*                                                                        */
39
/*  DESCRIPTION                                                           */
40
/*                                                                        */
41
/*    Internal helper function that handles blending of uncompressed      */
42
/*    pixlemap file without alpha channel.                                */
43
/*                                                                        */
44
/*  INPUT                                                                 */
45
/*                                                                        */
46
/*    context                               Drawing context               */
47
/*    xpos                                  x-coord of top-left draw point*/
48
/*    ypos                                  y-coord of top-left draw point*/
49
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
50
/*    alpha                                 blending value 0 to 255       */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    None                                                                */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _gx_display_driver_32xrgb_pixel_blend Display driver pixel blend    */
59
/*                                            function                    */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    _gx_display_driver_32argb_pixelmap_blend                            */
64
/*                                                                        */
65
/*  RELEASE HISTORY                                                       */
66
/*                                                                        */
67
/*    DATE              NAME                      DESCRIPTION             */
68
/*                                                                        */
69
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
70
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
71
/*                                            resulting in version 6.1    */
72
/*  06-02-2021     Kenneth Maxwell          Modified comment(s),          */
73
/*                                            removed unused variable     */
74
/*                                            assignment,                 */
75
/*                                            resulting in version 6.1.7  */
76
/*                                                                        */
77
/**************************************************************************/
78
10
static VOID _gx_display_driver_32argb_pixelmap_raw_blend(GX_DRAW_CONTEXT *context,
79
                                                         INT xpos, INT ypos,
80
                                                         GX_PIXELMAP *pixelmap,
81
                                                         GX_UBYTE alpha)
82
{
83
INT           yval;
84
INT           xval;
85
GX_COLOR      color;
86
GX_COLOR     *get;
87
GX_COLOR     *getrow;
88
89
10
GX_RECTANGLE *clip = context -> gx_draw_context_clip;
90
91
10
    getrow = (GX_COLOR *)((UINT)(pixelmap -> gx_pixelmap_data) + sizeof(GX_COLOR) * (UINT)(pixelmap -> gx_pixelmap_width) * (UINT)((INT)(clip -> gx_rectangle_top) - ypos));
92
10
    getrow += (clip -> gx_rectangle_left - xpos);
93
94
1190
    for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
95
    {
96
1180
        get = getrow;
97
98
275100
        for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
99
        {
100
273920
            color = *get;
101
273920
            get++;
102
273920
            _gx_display_driver_32argb_pixel_blend(context, xval, yval, color, alpha);
103
        }
104
105
1180
        getrow += pixelmap -> gx_pixelmap_width;
106
    }
107
10
}
108
109
/**************************************************************************/
110
/*                                                                        */
111
/*  FUNCTION                                               RELEASE        */
112
/*                                                                        */
113
/*    _gx_display_driver_32argb_pixelmap_alpha_blend      PORTABLE C      */
114
/*                                                           6.1.7        */
115
/*  AUTHOR                                                                */
116
/*                                                                        */
117
/*    Kenneth Maxwell, Microsoft Corporation                              */
118
/*                                                                        */
119
/*  DESCRIPTION                                                           */
120
/*                                                                        */
121
/*    Internal helper function that handles blending of uncompressed      */
122
/*    pixlemap file with alpha channel.                                   */
123
/*                                                                        */
124
/*  INPUT                                                                 */
125
/*                                                                        */
126
/*    context                               Drawing context               */
127
/*    xpos                                  x-coord of top-left draw point*/
128
/*    ypos                                  y-coord of top-left draw point*/
129
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
130
/*    alpha                                 blending value 0 to 255       */
131
/*                                                                        */
132
/*  OUTPUT                                                                */
133
/*                                                                        */
134
/*    None                                                                */
135
/*                                                                        */
136
/*  CALLS                                                                 */
137
/*                                                                        */
138
/*    _gx_display_driver_32xrgb_pixel_blend Display driver pixel blend    */
139
/*                                            function                    */
140
/*                                                                        */
141
/*  CALLED BY                                                             */
142
/*                                                                        */
143
/*    _gx_display_driver_32argb_pixelmap_blend                            */
144
/*                                                                        */
145
/*  RELEASE HISTORY                                                       */
146
/*                                                                        */
147
/*    DATE              NAME                      DESCRIPTION             */
148
/*                                                                        */
149
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
150
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
151
/*                                            resulting in version 6.1    */
152
/*  06-02-2021     Kenneth Maxwell          Modified comment(s),          */
153
/*                                            removed unused variable     */
154
/*                                            assignment,                 */
155
/*                                            resulting in version 6.1.7  */
156
/*                                                                        */
157
/**************************************************************************/
158
10
static VOID _gx_display_driver_32argb_pixelmap_alpha_blend(GX_DRAW_CONTEXT *context,
159
                                                           INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
160
{
161
int           xval;
162
int           yval;
163
int           color;
164
int           width;
165
ULONG        *get;
166
167
10
GX_RECTANGLE *clip = context -> gx_draw_context_clip;
168
169
10
    get = (ULONG *)((pixelmap -> gx_pixelmap_data) + sizeof(GX_COLOR) * (UINT)pixelmap -> gx_pixelmap_width * (UINT)((INT)clip -> gx_rectangle_top - ypos));
170
10
    get += (clip -> gx_rectangle_left - xpos);
171
10
    width = clip -> gx_rectangle_right - clip -> gx_rectangle_left + 1;
172
173
1420
    for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++)
174
    {
175
244090
        for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++)
176
        {
177
242680
            color = (int)(*get);
178
242680
            _gx_display_driver_32argb_pixel_blend(context, xval, yval, (GX_COLOR)color, alpha);
179
242680
            get++;
180
        }
181
1410
        get += pixelmap -> gx_pixelmap_width - width;
182
    }
183
10
}
184
185
/**************************************************************************/
186
/*                                                                        */
187
/*  FUNCTION                                               RELEASE        */
188
/*                                                                        */
189
/*    _gx_display_driver_32argb_pixelmap_blend            PORTABLE C      */
190
/*                                                           6.1          */
191
/*  AUTHOR                                                                */
192
/*                                                                        */
193
/*    Kenneth Maxwell, Microsoft Corporation                              */
194
/*                                                                        */
195
/*  DESCRIPTION                                                           */
196
/*                                                                        */
197
/*    32xrgb format screen driver pixelmap blending function that         */
198
/*    handles compressed or uncompress, with or without alpha channel.    */
199
/*                                                                        */
200
/*  INPUT                                                                 */
201
/*                                                                        */
202
/*    context                               Drawing context               */
203
/*    xpos                                  x-coord of top-left draw point*/
204
/*    ypos                                  y-coord of top-left draw point*/
205
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
206
/*    alpha                                 blending value 0 to 255       */
207
/*                                                                        */
208
/*  OUTPUT                                                                */
209
/*                                                                        */
210
/*    None                                                                */
211
/*                                                                        */
212
/*  CALLS                                                                 */
213
/*                                                                        */
214
/*     _gx_display_driver_32argb_pixelmap_alpha_blend                     */
215
/*                                          Real pixelmap blend function  */
216
/*     _gx_display_driver_32argb_pixelmap_raw_blend                       */
217
/*                                          Real pixelmap blend function  */
218
/*                                                                        */
219
/*  CALLED BY                                                             */
220
/*                                                                        */
221
/*    GUIX Internal Code                                                  */
222
/*                                                                        */
223
/*  RELEASE HISTORY                                                       */
224
/*                                                                        */
225
/*    DATE              NAME                      DESCRIPTION             */
226
/*                                                                        */
227
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
228
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
229
/*                                            resulting in version 6.1    */
230
/*                                                                        */
231
/**************************************************************************/
232
23
VOID _gx_display_driver_32argb_pixelmap_blend(GX_DRAW_CONTEXT *context,
233
                                              INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha)
234
{
235
23
    if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
236
    {
237
        /* Not supported yet. */
238
1
        return;
239
    }
240
241
22
    if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
242
    {
243
1
        return;
244
    }
245
246
21
    if (pixelmap -> gx_pixelmap_format != GX_COLOR_FORMAT_32ARGB)
247
    {
248
        /* wrong color format for this driver */
249
1
        return;
250
    }
251
252
20
    if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
253
    {
254
        /* alpha, no compression */
255
10
        _gx_display_driver_32argb_pixelmap_alpha_blend(context, xpos, ypos, pixelmap, alpha);
256
257
    }
258
    else
259
    {
260
        /* no compression or alpha */
261
10
        _gx_display_driver_32argb_pixelmap_raw_blend(context, xpos, ypos, pixelmap, alpha);
262
    }
263
}
264