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_system.h" |
28 |
|
|
#include "gx_display.h" |
29 |
|
|
|
30 |
|
|
#if defined GX_BRUSH_ALPHA_SUPPORT |
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _gx_display_driver_generic_rotated_alphamap_raw_alpha_draw */ |
37 |
|
|
/* PORTABLE C */ |
38 |
|
|
/* 6.1.3 */ |
39 |
|
|
/* AUTHOR */ |
40 |
|
|
/* */ |
41 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
42 |
|
|
/* */ |
43 |
|
|
/* DESCRIPTION */ |
44 |
|
|
/* */ |
45 |
|
|
/* Internal helper function that handles writing with brush alpha */ |
46 |
|
|
/* of uncompressed alpha map file. */ |
47 |
|
|
/* */ |
48 |
|
|
/* INPUT */ |
49 |
|
|
/* */ |
50 |
|
|
/* context Drawing context */ |
51 |
|
|
/* xpos x-coord of top-left draw point*/ |
52 |
|
|
/* ypos y-coord of top-left draw point*/ |
53 |
|
|
/* pixelmap Pointer to GX_PIXELMAP struct */ |
54 |
|
|
/* alpha alpha value from 0 to 255 */ |
55 |
|
|
/* */ |
56 |
|
|
/* OUTPUT */ |
57 |
|
|
/* */ |
58 |
|
|
/* None */ |
59 |
|
|
/* */ |
60 |
|
|
/* CALLS */ |
61 |
|
|
/* */ |
62 |
|
|
/* [gx_display_driver_pixel_blend] Basic display driver pixel */ |
63 |
|
|
/* blend function */ |
64 |
|
|
/* */ |
65 |
|
|
/* CALLED BY */ |
66 |
|
|
/* */ |
67 |
|
|
/* _gx_display_driver_generic_alphamap_draw */ |
68 |
|
|
/* */ |
69 |
|
|
/* RELEASE HISTORY */ |
70 |
|
|
/* */ |
71 |
|
|
/* DATE NAME DESCRIPTION */ |
72 |
|
|
/* */ |
73 |
|
|
/* 12-31-2020 Kenneth Maxwell Initial Version 6.1.3 */ |
74 |
|
|
/* */ |
75 |
|
|
/**************************************************************************/ |
76 |
|
43 |
static VOID _gx_display_driver_generic_rotated_alphamap_raw_alpha_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pmp, GX_UBYTE alpha) |
77 |
|
|
{ |
78 |
|
|
INT xval; |
79 |
|
|
INT yval; |
80 |
|
|
GX_UBYTE *getrowalpha; |
81 |
|
|
GX_CONST GX_UBYTE *getalpha; |
82 |
|
|
GX_UBYTE combined_alpha; |
83 |
|
|
GX_COLOR fill_color; |
84 |
|
|
GX_RECTANGLE *clip; |
85 |
|
|
GX_RECTANGLE rotated_clip; |
86 |
|
|
VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha); |
87 |
|
|
|
88 |
|
|
/* Pick up clip rectangle. */ |
89 |
|
43 |
clip = context -> gx_draw_context_clip; |
90 |
|
|
|
91 |
✓✓✓✓
|
43 |
GX_SET_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format) |
92 |
|
|
|
93 |
|
|
/* Pick up context fill color. */ |
94 |
|
32 |
fill_color = context -> gx_draw_context_brush.gx_brush_fill_color; |
95 |
|
|
|
96 |
|
32 |
GX_SWAP_VALS(xpos, ypos); |
97 |
|
|
|
98 |
✓✓ |
32 |
if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW) |
99 |
|
|
{ |
100 |
|
27 |
ypos = context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pmp -> gx_pixelmap_width; |
101 |
|
27 |
rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top; |
102 |
|
27 |
rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom; |
103 |
|
27 |
rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1); |
104 |
|
27 |
rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1); |
105 |
|
|
} |
106 |
|
|
else |
107 |
|
|
{ |
108 |
|
5 |
xpos = context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pmp -> gx_pixelmap_height; |
109 |
|
5 |
rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1); |
110 |
|
5 |
rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1); |
111 |
|
5 |
rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left; |
112 |
|
5 |
rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right; |
113 |
|
|
} |
114 |
|
|
|
115 |
|
32 |
getrowalpha = (UCHAR *)(pmp -> gx_pixelmap_data); |
116 |
|
32 |
getrowalpha += (pmp -> gx_pixelmap_height) * (rotated_clip.gx_rectangle_top - ypos); |
117 |
|
32 |
getrowalpha += (rotated_clip.gx_rectangle_left - xpos); |
118 |
|
|
|
119 |
✓✓ |
5789 |
for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++) |
120 |
|
|
{ |
121 |
|
5757 |
getalpha = getrowalpha; |
122 |
|
|
|
123 |
✓✓ |
1128024 |
for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++) |
124 |
|
|
{ |
125 |
|
1122267 |
combined_alpha = (GX_UBYTE)((*getalpha++) * alpha / 255); |
126 |
|
1122267 |
blend_func(context, xval, yval, fill_color, combined_alpha); |
127 |
|
|
} |
128 |
|
|
|
129 |
|
5757 |
getrowalpha += pmp -> gx_pixelmap_height; |
130 |
|
|
} |
131 |
|
|
} |
132 |
|
|
|
133 |
|
|
/**************************************************************************/ |
134 |
|
|
/* */ |
135 |
|
|
/* FUNCTION RELEASE */ |
136 |
|
|
/* */ |
137 |
|
|
/* _gx_display_driver_generic_rotated_alphamap_compressed_alpha_draw */ |
138 |
|
|
/* PORTABLE C */ |
139 |
|
|
/* 6.1.3 */ |
140 |
|
|
/* AUTHOR */ |
141 |
|
|
/* */ |
142 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
143 |
|
|
/* */ |
144 |
|
|
/* DESCRIPTION */ |
145 |
|
|
/* */ |
146 |
|
|
/* Internal helper function that handles writing with brush alpha */ |
147 |
|
|
/* of compressed alpha map file. */ |
148 |
|
|
/* */ |
149 |
|
|
/* INPUT */ |
150 |
|
|
/* */ |
151 |
|
|
/* context Drawing context */ |
152 |
|
|
/* xpos x-coord of top-left draw point*/ |
153 |
|
|
/* ypos y-coord of top-left draw point*/ |
154 |
|
|
/* pixelmap Pointer to GX_PIXELMAP struct */ |
155 |
|
|
/* alpha alpha value from 0 to 255 */ |
156 |
|
|
/* */ |
157 |
|
|
/* OUTPUT */ |
158 |
|
|
/* */ |
159 |
|
|
/* None */ |
160 |
|
|
/* */ |
161 |
|
|
/* CALLS */ |
162 |
|
|
/* */ |
163 |
|
|
/* [gx_display_driver_pixel_blend] Basic display driver pixel */ |
164 |
|
|
/* blend function */ |
165 |
|
|
/* */ |
166 |
|
|
/* CALLED BY */ |
167 |
|
|
/* */ |
168 |
|
|
/* _gx_display_driver_generic_alphamap_draw */ |
169 |
|
|
/* */ |
170 |
|
|
/* RELEASE HISTORY */ |
171 |
|
|
/* */ |
172 |
|
|
/* DATE NAME DESCRIPTION */ |
173 |
|
|
/* */ |
174 |
|
|
/* 12-31-2020 Kenneth Maxwell Initial Version 6.1.3 */ |
175 |
|
|
/* */ |
176 |
|
|
/**************************************************************************/ |
177 |
|
50 |
static VOID _gx_display_driver_generic_rotated_alphamap_compressed_alpha_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pmp, GX_UBYTE alpha) |
178 |
|
|
{ |
179 |
|
|
INT yval; |
180 |
|
|
INT xval; |
181 |
|
|
GX_CONST GX_UBYTE *get; |
182 |
|
|
GX_UBYTE count; |
183 |
|
|
GX_UBYTE falpha; |
184 |
|
|
GX_COLOR fill_color; |
185 |
|
|
GX_RECTANGLE *clip; |
186 |
|
|
GX_RECTANGLE rotated_clip; |
187 |
|
|
GX_UBYTE combined_alpha; |
188 |
|
|
VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha); |
189 |
|
|
|
190 |
|
|
/* Pick up clip rectangle. */ |
191 |
|
50 |
clip = context -> gx_draw_context_clip; |
192 |
|
|
|
193 |
✓✓✓✓
|
50 |
GX_SET_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format) |
194 |
|
|
|
195 |
|
|
/* Pick up context fill color. */ |
196 |
|
39 |
fill_color = context -> gx_draw_context_brush.gx_brush_fill_color; |
197 |
|
|
|
198 |
|
39 |
get = (GX_CONST GX_UBYTE *)pmp -> gx_pixelmap_data; |
199 |
|
|
|
200 |
|
39 |
GX_SWAP_VALS(xpos, ypos); |
201 |
|
|
|
202 |
✓✓ |
39 |
if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW) |
203 |
|
|
{ |
204 |
|
34 |
ypos = context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pmp -> gx_pixelmap_width; |
205 |
|
34 |
rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top; |
206 |
|
34 |
rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom; |
207 |
|
34 |
rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1); |
208 |
|
34 |
rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1); |
209 |
|
|
} |
210 |
|
|
else |
211 |
|
|
{ |
212 |
|
5 |
xpos = context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pmp -> gx_pixelmap_height; |
213 |
|
5 |
rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1); |
214 |
|
5 |
rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1); |
215 |
|
5 |
rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left; |
216 |
|
5 |
rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right; |
217 |
|
|
} |
218 |
|
|
|
219 |
|
|
/* compressed with no alpha is a two-byte count and two-byte pixel value */ |
220 |
|
|
|
221 |
|
|
/* first, skip to the starting row */ |
222 |
✓✓ |
167 |
for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++) |
223 |
|
|
{ |
224 |
|
128 |
xval = 0; |
225 |
✓✓ |
272 |
while (xval < pmp -> gx_pixelmap_height) |
226 |
|
|
{ |
227 |
|
144 |
count = *get++; |
228 |
|
|
|
229 |
✓✓ |
144 |
if (count & 0x80) |
230 |
|
|
{ |
231 |
|
136 |
count = (GX_UBYTE)((count & 0x7f) + 1); |
232 |
|
136 |
get++; /* skip repeated pixel value */ |
233 |
|
|
} |
234 |
|
|
else |
235 |
|
|
{ |
236 |
|
8 |
count++; |
237 |
|
8 |
get += count; /* skip raw pixel values */ |
238 |
|
|
} |
239 |
|
144 |
xval += count; |
240 |
|
|
} |
241 |
|
|
} |
242 |
|
|
|
243 |
|
|
/* now we are on the first visible row, copy pixels until we get |
244 |
|
|
to the enf of the last visible row |
245 |
|
|
*/ |
246 |
|
|
|
247 |
✓✓ |
4647 |
while (yval <= rotated_clip.gx_rectangle_bottom) |
248 |
|
|
{ |
249 |
|
4608 |
xval = xpos; |
250 |
|
|
|
251 |
✓✓ |
25353 |
while (xval < xpos + pmp -> gx_pixelmap_height) |
252 |
|
|
{ |
253 |
|
20745 |
count = *get++; |
254 |
|
|
|
255 |
✓✓ |
20745 |
if (count & 0x80) |
256 |
|
|
{ |
257 |
|
|
/* repeated value */ |
258 |
|
12702 |
count = (GX_UBYTE)((count & 0x7f) + 1); |
259 |
|
12702 |
falpha = *get++; |
260 |
|
|
|
261 |
✓✓ |
312555 |
while (count--) |
262 |
|
|
{ |
263 |
✓✓ |
299853 |
if (xval >= rotated_clip.gx_rectangle_left && |
264 |
✓✓ |
277861 |
xval <= rotated_clip.gx_rectangle_right) |
265 |
|
|
{ |
266 |
|
258853 |
combined_alpha = (GX_UBYTE)(falpha * alpha / 255); |
267 |
|
258853 |
blend_func(context, xval, yval, fill_color, combined_alpha); |
268 |
|
|
} |
269 |
|
299853 |
xval++; |
270 |
|
|
} |
271 |
|
|
} |
272 |
|
|
else |
273 |
|
|
{ |
274 |
|
|
/* string of non-repeated values */ |
275 |
|
8043 |
count++; |
276 |
✓✓ |
54114 |
while (count--) |
277 |
|
|
{ |
278 |
✓✓ |
46071 |
if (xval >= rotated_clip.gx_rectangle_left && |
279 |
✓✓ |
45428 |
xval <= rotated_clip.gx_rectangle_right) |
280 |
|
|
{ |
281 |
|
42972 |
combined_alpha = (GX_UBYTE)((*get) * alpha / 255); |
282 |
|
42972 |
blend_func(context, xval, yval, fill_color, combined_alpha); |
283 |
|
|
} |
284 |
|
46071 |
get++; |
285 |
|
46071 |
xval++; |
286 |
|
|
} |
287 |
|
|
} |
288 |
|
|
} |
289 |
|
4608 |
yval++; |
290 |
|
|
} |
291 |
|
|
} |
292 |
|
|
#endif /* GX_BRUSH_ALPHA_SUPPORT*/ |
293 |
|
|
|
294 |
|
|
/**************************************************************************/ |
295 |
|
|
/* */ |
296 |
|
|
/* FUNCTION RELEASE */ |
297 |
|
|
/* */ |
298 |
|
|
/* _gx_display_driver_generic_rotated_alphamap_raw_draw */ |
299 |
|
|
/* PORTABLE C */ |
300 |
|
|
/* 6.1.3 */ |
301 |
|
|
/* AUTHOR */ |
302 |
|
|
/* */ |
303 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
304 |
|
|
/* */ |
305 |
|
|
/* DESCRIPTION */ |
306 |
|
|
/* */ |
307 |
|
|
/* Internal helper function that handles writing of uncompressed */ |
308 |
|
|
/* alpha map file. */ |
309 |
|
|
/* */ |
310 |
|
|
/* INPUT */ |
311 |
|
|
/* */ |
312 |
|
|
/* context Drawing context */ |
313 |
|
|
/* xpos x-coord of top-left draw point*/ |
314 |
|
|
/* ypos y-coord of top-left draw point*/ |
315 |
|
|
/* pixelmap Pointer to GX_PIXELMAP struct */ |
316 |
|
|
/* */ |
317 |
|
|
/* OUTPUT */ |
318 |
|
|
/* */ |
319 |
|
|
/* None */ |
320 |
|
|
/* */ |
321 |
|
|
/* CALLS */ |
322 |
|
|
/* */ |
323 |
|
|
/* [gx_display_driver_pixel_blend] Basic display driver pixel */ |
324 |
|
|
/* blend function */ |
325 |
|
|
/* */ |
326 |
|
|
/* CALLED BY */ |
327 |
|
|
/* */ |
328 |
|
|
/* _gx_display_driver_generic_alphamap_draw */ |
329 |
|
|
/* */ |
330 |
|
|
/* RELEASE HISTORY */ |
331 |
|
|
/* */ |
332 |
|
|
/* DATE NAME DESCRIPTION */ |
333 |
|
|
/* */ |
334 |
|
|
/* 12-31-2020 Kenneth Maxwell Initial Version 6.1.3 */ |
335 |
|
|
/* */ |
336 |
|
|
/**************************************************************************/ |
337 |
|
2246 |
static VOID _gx_display_driver_generic_rotated_alphamap_raw_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pmp) |
338 |
|
|
{ |
339 |
|
|
INT xval; |
340 |
|
|
INT yval; |
341 |
|
|
GX_UBYTE *getrowalpha; |
342 |
|
|
GX_CONST GX_UBYTE *getalpha; |
343 |
|
|
GX_COLOR fill_color; |
344 |
|
|
GX_RECTANGLE *clip; |
345 |
|
|
GX_RECTANGLE rotated_clip; |
346 |
|
|
VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha); |
347 |
|
|
|
348 |
|
|
/* Pick up clip rectangle. */ |
349 |
|
2246 |
clip = context -> gx_draw_context_clip; |
350 |
|
|
|
351 |
✓✓✓✓
|
2246 |
GX_SET_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format) |
352 |
|
|
|
353 |
|
|
/* Pick up context fill color. */ |
354 |
|
2235 |
fill_color = context -> gx_draw_context_brush.gx_brush_fill_color; |
355 |
|
|
|
356 |
|
2235 |
GX_SWAP_VALS(xpos, ypos); |
357 |
|
|
|
358 |
✓✓ |
2235 |
if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW) |
359 |
|
|
{ |
360 |
|
1278 |
ypos = context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pmp -> gx_pixelmap_width; |
361 |
|
1278 |
rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top; |
362 |
|
1278 |
rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom; |
363 |
|
1278 |
rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1); |
364 |
|
1278 |
rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1); |
365 |
|
|
} |
366 |
|
|
else |
367 |
|
|
{ |
368 |
|
957 |
xpos = context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pmp -> gx_pixelmap_height; |
369 |
|
957 |
rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1); |
370 |
|
957 |
rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1); |
371 |
|
957 |
rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left; |
372 |
|
957 |
rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right; |
373 |
|
|
} |
374 |
|
|
|
375 |
|
2235 |
getrowalpha = (UCHAR *)(pmp -> gx_pixelmap_data); |
376 |
|
2235 |
getrowalpha += (pmp -> gx_pixelmap_height) * (rotated_clip.gx_rectangle_top - ypos); |
377 |
|
2235 |
getrowalpha += (rotated_clip.gx_rectangle_left - xpos); |
378 |
|
|
|
379 |
✓✓ |
27670 |
for (yval = rotated_clip.gx_rectangle_top; yval <= rotated_clip.gx_rectangle_bottom; yval++) |
380 |
|
|
{ |
381 |
|
25435 |
getalpha = getrowalpha; |
382 |
|
|
|
383 |
✓✓ |
3171627 |
for (xval = rotated_clip.gx_rectangle_left; xval <= rotated_clip.gx_rectangle_right; xval++) |
384 |
|
|
{ |
385 |
|
3146192 |
blend_func(context, xval, yval, fill_color, *getalpha++); |
386 |
|
|
} |
387 |
|
|
|
388 |
|
25435 |
getrowalpha += pmp -> gx_pixelmap_height; |
389 |
|
|
} |
390 |
|
|
} |
391 |
|
|
|
392 |
|
|
/**************************************************************************/ |
393 |
|
|
/* */ |
394 |
|
|
/* FUNCTION RELEASE */ |
395 |
|
|
/* */ |
396 |
|
|
/* _gx_display_driver_generic_rotated_alphamap_compressed_draw */ |
397 |
|
|
/* PORTABLE C */ |
398 |
|
|
/* 6.1.3 */ |
399 |
|
|
/* AUTHOR */ |
400 |
|
|
/* */ |
401 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
402 |
|
|
/* */ |
403 |
|
|
/* DESCRIPTION */ |
404 |
|
|
/* */ |
405 |
|
|
/* Internal helper function that handles writing of compressed */ |
406 |
|
|
/* alpha map file. */ |
407 |
|
|
/* */ |
408 |
|
|
/* INPUT */ |
409 |
|
|
/* */ |
410 |
|
|
/* context Drawing context */ |
411 |
|
|
/* xpos x-coord of top-left draw point*/ |
412 |
|
|
/* ypos y-coord of top-left draw point*/ |
413 |
|
|
/* pixelmap Pointer to GX_PIXELMAP struct */ |
414 |
|
|
/* */ |
415 |
|
|
/* OUTPUT */ |
416 |
|
|
/* */ |
417 |
|
|
/* None */ |
418 |
|
|
/* */ |
419 |
|
|
/* CALLS */ |
420 |
|
|
/* */ |
421 |
|
|
/* [gx_display_driver_pixel_blend] Basic display driver pixel */ |
422 |
|
|
/* blend function */ |
423 |
|
|
/* */ |
424 |
|
|
/* CALLED BY */ |
425 |
|
|
/* */ |
426 |
|
|
/* _gx_display_driver_generic_alphamap_draw */ |
427 |
|
|
/* */ |
428 |
|
|
/* RELEASE HISTORY */ |
429 |
|
|
/* */ |
430 |
|
|
/* DATE NAME DESCRIPTION */ |
431 |
|
|
/* */ |
432 |
|
|
/* 12-31-2020 Kenneth Maxwell Initial Version 6.1.3 */ |
433 |
|
|
/* */ |
434 |
|
|
/**************************************************************************/ |
435 |
|
72 |
static VOID _gx_display_driver_generic_rotated_alphamap_compressed_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pmp) |
436 |
|
|
{ |
437 |
|
|
INT yval; |
438 |
|
|
INT xval; |
439 |
|
|
GX_CONST GX_UBYTE *get; |
440 |
|
|
GX_UBYTE count; |
441 |
|
|
GX_UBYTE pixel; |
442 |
|
|
GX_COLOR fill_color; |
443 |
|
|
GX_RECTANGLE *clip; |
444 |
|
|
GX_RECTANGLE rotated_clip; |
445 |
|
|
VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha); |
446 |
|
|
|
447 |
|
|
/* Pick up clip rectangle. */ |
448 |
|
72 |
clip = context->gx_draw_context_clip; |
449 |
|
|
|
450 |
✓✓✓✓
|
72 |
GX_SET_BLEND_FUNCTION(blend_func, context -> gx_draw_context_display -> gx_display_color_format) |
451 |
|
|
|
452 |
|
|
/* Pick up context fill color. */ |
453 |
|
61 |
fill_color = context -> gx_draw_context_brush.gx_brush_fill_color; |
454 |
|
|
|
455 |
|
61 |
get = (GX_CONST GX_UBYTE *)pmp -> gx_pixelmap_data; |
456 |
|
|
|
457 |
|
61 |
GX_SWAP_VALS(xpos, ypos); |
458 |
|
|
|
459 |
✓✓ |
61 |
if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW) |
460 |
|
|
{ |
461 |
|
40 |
ypos = context -> gx_draw_context_canvas -> gx_canvas_x_resolution - ypos - pmp -> gx_pixelmap_width; |
462 |
|
40 |
rotated_clip.gx_rectangle_left = clip -> gx_rectangle_top; |
463 |
|
40 |
rotated_clip.gx_rectangle_right = clip -> gx_rectangle_bottom; |
464 |
|
40 |
rotated_clip.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_right - 1); |
465 |
|
40 |
rotated_clip.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - clip -> gx_rectangle_left - 1); |
466 |
|
|
} |
467 |
|
|
else |
468 |
|
|
{ |
469 |
|
21 |
xpos = context -> gx_draw_context_canvas -> gx_canvas_y_resolution - xpos - pmp -> gx_pixelmap_height; |
470 |
|
21 |
rotated_clip.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_bottom - 1); |
471 |
|
21 |
rotated_clip.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - clip -> gx_rectangle_top - 1); |
472 |
|
21 |
rotated_clip.gx_rectangle_top = clip -> gx_rectangle_left; |
473 |
|
21 |
rotated_clip.gx_rectangle_bottom = clip -> gx_rectangle_right; |
474 |
|
|
} |
475 |
|
|
|
476 |
|
|
/* compressed with no alpha is a two-byte count and two-byte pixel value */ |
477 |
|
|
|
478 |
|
|
/* first, skip to the starting row */ |
479 |
✓✓ |
265 |
for (yval = ypos; yval < rotated_clip.gx_rectangle_top; yval++) |
480 |
|
|
{ |
481 |
|
204 |
xval = 0; |
482 |
✓✓ |
424 |
while (xval < pmp -> gx_pixelmap_height) |
483 |
|
|
{ |
484 |
|
220 |
count = *get++; |
485 |
|
|
|
486 |
✓✓ |
220 |
if (count & 0x80) |
487 |
|
|
{ |
488 |
|
212 |
count = (GX_UBYTE)((count & 0x7f) + 1); |
489 |
|
212 |
get++; /* skip repeated pixel value */ |
490 |
|
|
} |
491 |
|
|
else |
492 |
|
|
{ |
493 |
|
8 |
count++; |
494 |
|
8 |
get += count; /* skip raw pixel values */ |
495 |
|
|
} |
496 |
|
220 |
xval += count; |
497 |
|
|
} |
498 |
|
|
} |
499 |
|
|
|
500 |
|
|
/* now we are on the first visible row, copy pixels until we get |
501 |
|
|
to the enf of the last visible row |
502 |
|
|
*/ |
503 |
|
|
|
504 |
✓✓ |
7689 |
while (yval <= rotated_clip.gx_rectangle_bottom) |
505 |
|
|
{ |
506 |
|
7628 |
xval = xpos; |
507 |
|
|
|
508 |
✓✓ |
42151 |
while (xval < xpos + pmp -> gx_pixelmap_height) |
509 |
|
|
{ |
510 |
|
34523 |
count = *get++; |
511 |
|
|
|
512 |
✓✓ |
34523 |
if (count & 0x80) |
513 |
|
|
{ |
514 |
|
|
/* repeated value */ |
515 |
|
21200 |
count = (GX_UBYTE)((count & 0x7f) + 1); |
516 |
|
21200 |
pixel = *get++; |
517 |
|
|
|
518 |
✓✓ |
523145 |
while (count--) |
519 |
|
|
{ |
520 |
✓✓ |
501945 |
if (xval >= rotated_clip.gx_rectangle_left && |
521 |
✓✓ |
475483 |
xval <= rotated_clip.gx_rectangle_right) |
522 |
|
|
{ |
523 |
|
451095 |
blend_func(context, xval, yval, fill_color, pixel); |
524 |
|
|
} |
525 |
|
501945 |
xval++; |
526 |
|
|
} |
527 |
|
|
} |
528 |
|
|
else |
529 |
|
|
{ |
530 |
|
|
/* string of non-repeated values */ |
531 |
|
13323 |
count++; |
532 |
✓✓ |
89842 |
while (count--) |
533 |
|
|
{ |
534 |
✓✓ |
76519 |
if (xval >= rotated_clip.gx_rectangle_left && |
535 |
✓✓ |
75504 |
xval <= rotated_clip.gx_rectangle_right) |
536 |
|
|
{ |
537 |
|
73048 |
blend_func(context, xval, yval, fill_color, *get); |
538 |
|
|
} |
539 |
|
76519 |
get++; |
540 |
|
76519 |
xval++; |
541 |
|
|
} |
542 |
|
|
} |
543 |
|
|
} |
544 |
|
7628 |
yval++; |
545 |
|
|
} |
546 |
|
|
} |
547 |
|
|
|
548 |
|
|
/**************************************************************************/ |
549 |
|
|
/* */ |
550 |
|
|
/* FUNCTION RELEASE */ |
551 |
|
|
/* */ |
552 |
|
|
/* _gx_display_driver_generic_rotated_alphamap_draw PORTABLE C */ |
553 |
|
|
/* 6.1.3 */ |
554 |
|
|
/* AUTHOR */ |
555 |
|
|
/* */ |
556 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
557 |
|
|
/* */ |
558 |
|
|
/* DESCRIPTION */ |
559 |
|
|
/* */ |
560 |
|
|
/* This function blends the context fill color with the canvas */ |
561 |
|
|
/* background. */ |
562 |
|
|
/* */ |
563 |
|
|
/* INPUT */ |
564 |
|
|
/* */ |
565 |
|
|
/* context Drawing context */ |
566 |
|
|
/* xpos x-coord of top-left draw point*/ |
567 |
|
|
/* ypos y-coord of top-left draw point*/ |
568 |
|
|
/* pmp Pointer to GX_PIXELMAP struct */ |
569 |
|
|
/* */ |
570 |
|
|
/* OUTPUT */ |
571 |
|
|
/* */ |
572 |
|
|
/* status Completion status */ |
573 |
|
|
/* */ |
574 |
|
|
/* CALLS */ |
575 |
|
|
/* */ |
576 |
|
|
/* _gx_display_driver_generic_rotated_alphamap_compressed_alpha_draw */ |
577 |
|
|
/* Real display driver alphamap */ |
578 |
|
|
/* draw function */ |
579 |
|
|
/* _gx_display_driver_generic_rotated_alphamap_raw_alpha_draw */ |
580 |
|
|
/* Real display driver alphamap */ |
581 |
|
|
/* draw function */ |
582 |
|
|
/* _gx_display_driver_generic_rotated_alphamap_compressed_draw */ |
583 |
|
|
/* Real display driver alphamap */ |
584 |
|
|
/* draw function */ |
585 |
|
|
/* _gx_display_driver_generic_rotated_alphamap_raw_draw */ |
586 |
|
|
/* Real display driver alphamap */ |
587 |
|
|
/* draw function */ |
588 |
|
|
/* */ |
589 |
|
|
/* CALLED BY */ |
590 |
|
|
/* */ |
591 |
|
|
/* Application Code */ |
592 |
|
|
/* GUIX default draw funtions */ |
593 |
|
|
/* */ |
594 |
|
|
/* RELEASE HISTORY */ |
595 |
|
|
/* */ |
596 |
|
|
/* DATE NAME DESCRIPTION */ |
597 |
|
|
/* */ |
598 |
|
|
/* 12-31-2020 Kenneth Maxwell Initial Version 6.1.3 */ |
599 |
|
|
/* */ |
600 |
|
|
/**************************************************************************/ |
601 |
|
2412 |
VOID _gx_display_driver_generic_rotated_alphamap_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pmp) |
602 |
|
|
{ |
603 |
|
|
#if defined GX_BRUSH_ALPHA_SUPPORT |
604 |
|
|
GX_UBYTE alpha; |
605 |
|
|
|
606 |
|
2412 |
alpha = context -> gx_draw_context_brush.gx_brush_alpha; |
607 |
✓✓ |
2412 |
if (alpha == 0) |
608 |
|
|
{ |
609 |
|
|
/* Nothing to drawn. Just return. */ |
610 |
|
1 |
return; |
611 |
|
|
} |
612 |
|
|
|
613 |
✓✓ |
2411 |
if (alpha != 0xff) |
614 |
|
|
{ |
615 |
✓✓ |
93 |
if (pmp -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED) |
616 |
|
|
{ |
617 |
|
50 |
_gx_display_driver_generic_rotated_alphamap_compressed_alpha_draw(context, xpos, ypos, pmp, alpha); |
618 |
|
|
} |
619 |
|
|
else |
620 |
|
|
{ |
621 |
|
43 |
_gx_display_driver_generic_rotated_alphamap_raw_alpha_draw(context, xpos, ypos, pmp, alpha); |
622 |
|
|
} |
623 |
|
93 |
return; |
624 |
|
|
} |
625 |
|
|
#endif |
626 |
|
|
|
627 |
✓✓ |
2318 |
if (pmp -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED) |
628 |
|
|
{ |
629 |
|
72 |
_gx_display_driver_generic_rotated_alphamap_compressed_draw(context, xpos, ypos, pmp); |
630 |
|
|
} |
631 |
|
|
else |
632 |
|
|
{ |
633 |
|
2246 |
_gx_display_driver_generic_rotated_alphamap_raw_draw(context, xpos, ypos, pmp); |
634 |
|
|
} |
635 |
|
|
} |
636 |
|
|
|