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