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 |
|
|
#include "gx_context.h" |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
/**************************************************************************/ |
32 |
|
|
/* */ |
33 |
|
|
/* FUNCTION RELEASE */ |
34 |
|
|
/* */ |
35 |
|
|
/* _gx_display_driver_8bpp_pixelmap_raw_blend PORTABLE C */ |
36 |
|
|
/* 6.1 */ |
37 |
|
|
/* AUTHOR */ |
38 |
|
|
/* */ |
39 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
40 |
|
|
/* */ |
41 |
|
|
/* DESCRIPTION */ |
42 |
|
|
/* */ |
43 |
|
|
/* Internal helper function that handles blending of uncompressed */ |
44 |
|
|
/* pixlemap file. */ |
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_pixel_blend] Basic display driver pixel */ |
61 |
|
|
/* blend function */ |
62 |
|
|
/* */ |
63 |
|
|
/* CALLED BY */ |
64 |
|
|
/* */ |
65 |
|
|
/* _gx_display_driver_8bpp_pixelmap_blend */ |
66 |
|
|
/* */ |
67 |
|
|
/* RELEASE HISTORY */ |
68 |
|
|
/* */ |
69 |
|
|
/* DATE NAME DESCRIPTION */ |
70 |
|
|
/* */ |
71 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
72 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
73 |
|
|
/* resulting in version 6.1 */ |
74 |
|
|
/* */ |
75 |
|
|
/**************************************************************************/ |
76 |
|
9 |
static VOID _gx_display_driver_8bpp_pixelmap_raw_blend(GX_DRAW_CONTEXT *context, |
77 |
|
|
INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha) |
78 |
|
|
{ |
79 |
|
|
INT xval; |
80 |
|
|
INT yval; |
81 |
|
|
GX_UBYTE *get; |
82 |
|
|
GX_UBYTE *getrow; |
83 |
|
|
GX_UBYTE pixel; |
84 |
|
|
|
85 |
|
9 |
GX_RECTANGLE *clip = context -> gx_draw_context_clip; |
86 |
|
|
VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha); |
87 |
|
|
|
88 |
|
9 |
blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend; |
89 |
✓✓ |
9 |
if (!blend_func) |
90 |
|
|
{ |
91 |
|
1 |
return; |
92 |
|
|
} |
93 |
|
|
|
94 |
|
8 |
getrow = (GX_UBYTE *)(pixelmap -> gx_pixelmap_data + (INT)sizeof(GX_UBYTE) * pixelmap -> gx_pixelmap_width * (clip -> gx_rectangle_top - ypos)); |
95 |
|
8 |
getrow += (clip -> gx_rectangle_left - xpos); |
96 |
✓✓ |
2360 |
for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++) |
97 |
|
|
{ |
98 |
|
2352 |
get = getrow; |
99 |
✓✓ |
227754 |
for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++) |
100 |
|
|
{ |
101 |
|
225402 |
pixel = *get++; |
102 |
|
225402 |
blend_func(context, xval, yval, pixel, alpha); |
103 |
|
|
} |
104 |
|
2352 |
getrow += pixelmap -> gx_pixelmap_width; |
105 |
|
|
} |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
/**************************************************************************/ |
109 |
|
|
/* */ |
110 |
|
|
/* FUNCTION RELEASE */ |
111 |
|
|
/* */ |
112 |
|
|
/* _gx_display_driver_8bpp_pixelmap_alpha_blend PORTABLE C */ |
113 |
|
|
/* 6.1 */ |
114 |
|
|
/* AUTHOR */ |
115 |
|
|
/* */ |
116 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
117 |
|
|
/* */ |
118 |
|
|
/* DESCRIPTION */ |
119 |
|
|
/* */ |
120 |
|
|
/* Internal helper function that handles blending of uncompressed */ |
121 |
|
|
/* pixelmap file with alpha channel. */ |
122 |
|
|
/* */ |
123 |
|
|
/* INPUT */ |
124 |
|
|
/* */ |
125 |
|
|
/* context Drawing context */ |
126 |
|
|
/* xpos x-coord of top-left draw point*/ |
127 |
|
|
/* ypos y-coord of top-left draw point*/ |
128 |
|
|
/* pixelmap Pointer to GX_PIXELMAP struct */ |
129 |
|
|
/* alpha blending value 0 to 255 */ |
130 |
|
|
/* */ |
131 |
|
|
/* OUTPUT */ |
132 |
|
|
/* */ |
133 |
|
|
/* None */ |
134 |
|
|
/* */ |
135 |
|
|
/* CALLS */ |
136 |
|
|
/* */ |
137 |
|
|
/* [gx_display_driver_pixel_blend] Basic display driver pixel */ |
138 |
|
|
/* blend function */ |
139 |
|
|
/* */ |
140 |
|
|
/* CALLED BY */ |
141 |
|
|
/* */ |
142 |
|
|
/* _gx_display_driver_8bpp_pixelmap_blend */ |
143 |
|
|
/* */ |
144 |
|
|
/* RELEASE HISTORY */ |
145 |
|
|
/* */ |
146 |
|
|
/* DATE NAME DESCRIPTION */ |
147 |
|
|
/* */ |
148 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
149 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
150 |
|
|
/* resulting in version 6.1 */ |
151 |
|
|
/* */ |
152 |
|
|
/**************************************************************************/ |
153 |
|
15 |
static VOID _gx_display_driver_8bpp_pixelmap_alpha_blend(GX_DRAW_CONTEXT *context, |
154 |
|
|
INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha) |
155 |
|
|
{ |
156 |
|
|
INT skipcount; |
157 |
|
|
INT xval; |
158 |
|
|
INT yval; |
159 |
|
|
GX_UBYTE *getrow; |
160 |
|
|
GX_UBYTE *getrowalpha; |
161 |
|
|
GX_UBYTE *get; |
162 |
|
|
GX_UBYTE pixel; |
163 |
|
|
GX_UBYTE *getalpha; |
164 |
|
|
INT combined_alpha; |
165 |
|
|
GX_UBYTE internal_alpha; |
166 |
|
|
VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha); |
167 |
|
15 |
GX_RECTANGLE *clip = context -> gx_draw_context_clip; |
168 |
|
|
|
169 |
|
15 |
blend_func = context -> gx_draw_context_display -> gx_display_driver_pixel_blend; |
170 |
✓✓ |
15 |
if (GX_NULL == blend_func) |
171 |
|
|
{ |
172 |
|
2 |
return; |
173 |
|
|
} |
174 |
|
|
|
175 |
|
|
/* calculate how many pixels to skip */ |
176 |
|
13 |
skipcount = (pixelmap -> gx_pixelmap_width) * (clip -> gx_rectangle_top - ypos); |
177 |
|
13 |
skipcount += (clip -> gx_rectangle_left - xpos); |
178 |
|
13 |
getrow = (GX_UBYTE *)(pixelmap -> gx_pixelmap_data); |
179 |
|
13 |
getrow += skipcount; |
180 |
|
|
|
181 |
|
13 |
getrowalpha = (GX_UBYTE *)(pixelmap -> gx_pixelmap_aux_data); |
182 |
|
13 |
getrowalpha += skipcount; |
183 |
|
|
|
184 |
✓✓ |
2471 |
for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++) |
185 |
|
|
{ |
186 |
|
2458 |
get = getrow; |
187 |
|
2458 |
getalpha = getrowalpha; |
188 |
|
|
|
189 |
✓✓ |
255394 |
for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++) |
190 |
|
|
{ |
191 |
|
252936 |
internal_alpha = *getalpha++; |
192 |
✓✓ |
252936 |
if (internal_alpha) |
193 |
|
|
{ |
194 |
|
181572 |
combined_alpha = internal_alpha * alpha; |
195 |
|
181572 |
combined_alpha /= 255; |
196 |
|
181572 |
pixel = *get; |
197 |
|
181572 |
blend_func(context, xval, yval, pixel, (GX_UBYTE)combined_alpha); |
198 |
|
|
} |
199 |
|
252936 |
get++; |
200 |
|
|
} |
201 |
|
2458 |
getrow += pixelmap -> gx_pixelmap_width; |
202 |
|
2458 |
getrowalpha += pixelmap -> gx_pixelmap_width; |
203 |
|
|
} |
204 |
|
|
} |
205 |
|
|
|
206 |
|
|
/**************************************************************************/ |
207 |
|
|
/* */ |
208 |
|
|
/* FUNCTION RELEASE */ |
209 |
|
|
/* */ |
210 |
|
|
/* _gx_display_driver_8bpp_pixelmap_blend PORTABLE C */ |
211 |
|
|
/* 6.1 */ |
212 |
|
|
/* AUTHOR */ |
213 |
|
|
/* */ |
214 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
215 |
|
|
/* */ |
216 |
|
|
/* DESCRIPTION */ |
217 |
|
|
/* */ |
218 |
|
|
/* Driver entry point for pixelmap blending function that handles */ |
219 |
|
|
/* compressed or uncompress, with or without alpha channel. */ |
220 |
|
|
/* */ |
221 |
|
|
/* INPUT */ |
222 |
|
|
/* */ |
223 |
|
|
/* context Drawing context */ |
224 |
|
|
/* xpos x-coord of top-left draw point*/ |
225 |
|
|
/* ypos y-coord of top-left draw point*/ |
226 |
|
|
/* pixelmap Pointer to GX_PIXELMAP struct */ |
227 |
|
|
/* alpha blending value 0 to 255 */ |
228 |
|
|
/* */ |
229 |
|
|
/* OUTPUT */ |
230 |
|
|
/* */ |
231 |
|
|
/* None */ |
232 |
|
|
/* */ |
233 |
|
|
/* CALLS */ |
234 |
|
|
/* */ |
235 |
|
|
/* _gx_display_driver_8bpp_pixelmap_alpha_blend */ |
236 |
|
|
/* Real display driver pixelmap */ |
237 |
|
|
/* blend function for 8bpp */ |
238 |
|
|
/* _gx_display_driver_8bpp_pixelmap_raw_blend */ |
239 |
|
|
/* Real display driver pixelmap */ |
240 |
|
|
/* blend function for 8bpp */ |
241 |
|
|
/* */ |
242 |
|
|
/* CALLED BY */ |
243 |
|
|
/* */ |
244 |
|
|
/* GUIX Internal Code */ |
245 |
|
|
/* */ |
246 |
|
|
/* RELEASE HISTORY */ |
247 |
|
|
/* */ |
248 |
|
|
/* DATE NAME DESCRIPTION */ |
249 |
|
|
/* */ |
250 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
251 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
252 |
|
|
/* resulting in version 6.1 */ |
253 |
|
|
/* */ |
254 |
|
|
/**************************************************************************/ |
255 |
|
27 |
VOID _gx_display_driver_8bpp_pixelmap_blend(GX_DRAW_CONTEXT *context, |
256 |
|
|
INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha) |
257 |
|
|
{ |
258 |
✓✓✓✓
|
27 |
if ((pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT) || (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)) |
259 |
|
|
{ |
260 |
|
|
/* Wrong format. */ |
261 |
|
2 |
return; |
262 |
|
|
} |
263 |
|
|
|
264 |
✓✓ |
25 |
if (pixelmap -> gx_pixelmap_format != GX_COLOR_FORMAT_8BIT_PACKED_PIXEL) |
265 |
|
|
{ |
266 |
|
|
/* wrong color format for this driver */ |
267 |
|
1 |
return; |
268 |
|
|
} |
269 |
|
|
|
270 |
✓✓ |
24 |
if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA) |
271 |
|
|
{ |
272 |
|
|
/* alpha, no compression */ |
273 |
|
15 |
_gx_display_driver_8bpp_pixelmap_alpha_blend(context, |
274 |
|
|
xpos, ypos, pixelmap, alpha); |
275 |
|
|
} |
276 |
|
|
else |
277 |
|
|
{ |
278 |
|
|
/* no compression or alpha */ |
279 |
|
9 |
_gx_display_driver_8bpp_pixelmap_raw_blend(context, |
280 |
|
|
xpos, ypos, pixelmap, alpha); |
281 |
|
|
} |
282 |
|
|
} |
283 |
|
|
|