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_utility.h" |
30 |
|
|
#include "gx_display.h" |
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _gx_display_driver_generic_glyph_4bit_draw PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function draws the specified text using the current context, */ |
45 |
|
|
/* clipped to one viewport */ |
46 |
|
|
/* */ |
47 |
|
|
/* INPUT */ |
48 |
|
|
/* */ |
49 |
|
|
/* context Draw context */ |
50 |
|
|
/* draw_area The rectangle where the glyph */ |
51 |
|
|
/* is drawn to */ |
52 |
|
|
/* map_offset Offset from the glyph map */ |
53 |
|
|
/* glyph The glyph structure */ |
54 |
|
|
/* */ |
55 |
|
|
/* OUTPUT */ |
56 |
|
|
/* */ |
57 |
|
|
/* None */ |
58 |
|
|
/* */ |
59 |
|
|
/* CALLS */ |
60 |
|
|
/* */ |
61 |
|
|
/* [gx_display_driver_pixel_blend] Call display driver pixel */ |
62 |
|
|
/* blend function */ |
63 |
|
|
/* */ |
64 |
|
|
/* CALLED BY */ |
65 |
|
|
/* */ |
66 |
|
|
/* GUIX internal code */ |
67 |
|
|
/* */ |
68 |
|
|
/**************************************************************************/ |
69 |
|
448976 |
VOID _gx_display_driver_generic_glyph_4bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, GX_CONST GX_GLYPH *glyph) |
70 |
|
|
{ |
71 |
|
|
GX_DISPLAY *display; |
72 |
|
|
GX_UBYTE *glyph_row; |
73 |
|
|
GX_UBYTE *glyph_data; |
74 |
|
|
UINT row; |
75 |
|
|
UINT col; |
76 |
|
448976 |
UINT pixel_width = 0; |
77 |
|
|
UINT leading_pixel; |
78 |
|
|
UINT trailing_pixel; |
79 |
|
|
GX_COLOR text_color; |
80 |
|
|
UINT y_height; |
81 |
|
|
GX_UBYTE alpha; |
82 |
|
|
UINT pitch; |
83 |
|
|
UINT index; |
84 |
|
|
VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha); |
85 |
|
448976 |
GX_UBYTE brush_alpha = 0xff; |
86 |
|
|
|
87 |
|
|
#if defined (GX_BRUSH_ALPHA_SUPPORT) |
88 |
|
|
INT alpha_sum; |
89 |
|
448976 |
brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha; |
90 |
✓✓ |
448976 |
if (brush_alpha == 0) |
91 |
|
|
{ |
92 |
|
2964 |
return; |
93 |
|
|
} |
94 |
|
|
#endif |
95 |
|
|
|
96 |
|
446012 |
text_color = context -> gx_draw_context_brush.gx_brush_line_color; |
97 |
|
446012 |
pixel_width = (UINT)(draw_area -> gx_rectangle_right - draw_area -> gx_rectangle_left + 1); |
98 |
|
|
|
99 |
|
|
/* pickup pointer to current dispaly driver */ |
100 |
|
446012 |
display = context -> gx_draw_context_display; |
101 |
|
|
|
102 |
✓✓ |
446012 |
if (display -> gx_display_driver_pixel_blend == GX_NULL) |
103 |
|
|
{ |
104 |
|
196 |
return; |
105 |
|
|
} |
106 |
|
|
|
107 |
|
|
/* Find the width of the glyph */ |
108 |
|
445816 |
pitch = glyph -> gx_glyph_width; |
109 |
|
|
/* Make it byte-aligned. */ |
110 |
|
445816 |
pitch = (pitch + 1) >> 1; |
111 |
|
|
|
112 |
|
445816 |
glyph_row = (GX_UBYTE *)glyph -> gx_glyph_map; |
113 |
|
|
|
114 |
✓✓ |
445816 |
if (map_offset -> gx_point_y) |
115 |
|
|
{ |
116 |
|
4134 |
glyph_row = glyph_row + ((INT)pitch * map_offset -> gx_point_y); |
117 |
|
|
} |
118 |
|
|
|
119 |
|
445816 |
glyph_row += (map_offset -> gx_point_x >> 1); |
120 |
|
|
|
121 |
|
445816 |
y_height = (UINT)(draw_area -> gx_rectangle_bottom - draw_area -> gx_rectangle_top + 1); |
122 |
|
|
|
123 |
|
445816 |
blend_func = display -> gx_display_driver_pixel_blend; |
124 |
|
|
|
125 |
|
445816 |
leading_pixel = (map_offset -> gx_point_x & 1); |
126 |
|
|
|
127 |
|
445816 |
pixel_width -= leading_pixel; |
128 |
|
|
|
129 |
|
445816 |
trailing_pixel = pixel_width & 1; |
130 |
|
|
|
131 |
|
445816 |
pixel_width = pixel_width >> 1; |
132 |
|
|
|
133 |
✓✓ |
445816 |
if (brush_alpha == 0xff) |
134 |
|
|
{ |
135 |
✓✓ |
2747197 |
for (row = 0; row < y_height; row++) |
136 |
|
|
{ |
137 |
|
2521900 |
col = 0; |
138 |
|
2521900 |
glyph_data = glyph_row; |
139 |
|
|
|
140 |
✓✓ |
2521900 |
if (leading_pixel) |
141 |
|
|
{ |
142 |
|
6828 |
alpha = (*glyph_data) & 0x0f; |
143 |
|
6828 |
alpha = (GX_UBYTE)(alpha | (GX_UBYTE)(alpha << 4)); |
144 |
|
|
|
145 |
✓✓ |
6828 |
if (alpha > 0) |
146 |
|
|
{ |
147 |
|
4076 |
blend_func(context, |
148 |
|
4076 |
draw_area -> gx_rectangle_left + (GX_VALUE)col, |
149 |
|
4076 |
draw_area -> gx_rectangle_top + (GX_VALUE)row, |
150 |
|
|
text_color, (GX_UBYTE)alpha); |
151 |
|
|
} |
152 |
|
6828 |
col++; |
153 |
|
6828 |
glyph_data++; |
154 |
|
|
} |
155 |
|
|
|
156 |
✓✓ |
11796242 |
for (index = 0; index < pixel_width; index++) |
157 |
|
|
{ |
158 |
|
9274342 |
alpha = (*glyph_data) & 0xf0; |
159 |
|
9274342 |
alpha = (GX_UBYTE)(alpha | (GX_UBYTE)(alpha >> 4)); |
160 |
|
|
|
161 |
✓✓ |
9274342 |
if (alpha > 0) |
162 |
|
|
{ |
163 |
|
4948529 |
blend_func(context, |
164 |
|
4948529 |
draw_area -> gx_rectangle_left + (GX_VALUE)col, |
165 |
|
4948529 |
draw_area -> gx_rectangle_top + (GX_VALUE)row, |
166 |
|
|
text_color, (GX_UBYTE)alpha); |
167 |
|
|
} |
168 |
|
9274342 |
col++; |
169 |
|
|
|
170 |
|
9274342 |
alpha = (*glyph_data) & 0x0f; |
171 |
|
9274342 |
alpha = (GX_UBYTE)(alpha | (GX_UBYTE)(alpha << 4)); |
172 |
|
|
|
173 |
✓✓ |
9274342 |
if (alpha > 0) |
174 |
|
|
{ |
175 |
|
5093194 |
blend_func(context, |
176 |
|
5093194 |
draw_area -> gx_rectangle_left + (GX_VALUE)col, |
177 |
|
5093194 |
draw_area -> gx_rectangle_top + (GX_VALUE)row, |
178 |
|
|
text_color, (GX_UBYTE)alpha); |
179 |
|
|
} |
180 |
|
9274342 |
col++; |
181 |
|
9274342 |
glyph_data++; |
182 |
|
|
} |
183 |
|
|
|
184 |
✓✓ |
2521900 |
if (trailing_pixel) |
185 |
|
|
{ |
186 |
|
1446213 |
alpha = (*glyph_data) & 0xf0; |
187 |
|
1446213 |
alpha = (GX_UBYTE)(alpha | (GX_UBYTE)(alpha >> 4)); |
188 |
|
|
|
189 |
✓✓ |
1446213 |
if (alpha > 0) |
190 |
|
|
{ |
191 |
|
466142 |
blend_func(context, |
192 |
|
466142 |
draw_area -> gx_rectangle_left + (GX_VALUE)col, |
193 |
|
466142 |
draw_area -> gx_rectangle_top + (GX_VALUE)row, |
194 |
|
|
text_color, (GX_UBYTE)alpha); |
195 |
|
|
} |
196 |
|
|
} |
197 |
|
2521900 |
glyph_row += pitch; |
198 |
|
|
} |
199 |
|
|
} |
200 |
|
|
#if defined (GX_BRUSH_ALPHA_SUPPORT) |
201 |
|
|
else |
202 |
|
|
{ |
203 |
✓✓ |
2687188 |
for (row = 0; row < y_height; row++) |
204 |
|
|
{ |
205 |
|
2466669 |
col = 0; |
206 |
|
2466669 |
glyph_data = glyph_row; |
207 |
|
|
|
208 |
✓✓ |
2466669 |
if (leading_pixel) |
209 |
|
|
{ |
210 |
|
6828 |
alpha = (*glyph_data) & 0x0f; |
211 |
|
6828 |
alpha = (GX_UBYTE)(alpha | (GX_UBYTE)(alpha << 4)); |
212 |
|
|
|
213 |
|
6828 |
alpha_sum = alpha * brush_alpha / 255; |
214 |
|
|
|
215 |
✓✓ |
6828 |
if (alpha_sum > 0) |
216 |
|
|
{ |
217 |
|
4072 |
blend_func(context, |
218 |
|
4072 |
draw_area->gx_rectangle_left + (GX_VALUE)col, |
219 |
|
4072 |
draw_area->gx_rectangle_top + (GX_VALUE)row, |
220 |
|
4072 |
text_color, (GX_UBYTE)alpha_sum); |
221 |
|
|
} |
222 |
|
6828 |
col++; |
223 |
|
6828 |
glyph_data++; |
224 |
|
|
} |
225 |
|
|
|
226 |
✓✓ |
11478714 |
for (index = 0; index < pixel_width; index++) |
227 |
|
|
{ |
228 |
|
9012045 |
alpha = (*glyph_data) & 0xf0; |
229 |
|
9012045 |
alpha = (GX_UBYTE)(alpha | (GX_UBYTE)(alpha >> 4)); |
230 |
|
9012045 |
alpha_sum = alpha * brush_alpha / 255; |
231 |
|
|
|
232 |
✓✓ |
9012045 |
if (alpha_sum > 0) |
233 |
|
|
{ |
234 |
|
4804379 |
blend_func(context, |
235 |
|
4804379 |
draw_area -> gx_rectangle_left + (GX_VALUE)col, |
236 |
|
4804379 |
draw_area -> gx_rectangle_top + (GX_VALUE)row, |
237 |
|
4804379 |
text_color, (GX_UBYTE)alpha_sum); |
238 |
|
|
} |
239 |
|
9012045 |
col++; |
240 |
|
|
|
241 |
|
9012045 |
alpha = (*glyph_data) & 0x0f; |
242 |
|
9012045 |
alpha = (GX_UBYTE)(alpha | (GX_UBYTE)(alpha << 4)); |
243 |
|
9012045 |
alpha_sum = alpha * brush_alpha / 255; |
244 |
|
|
|
245 |
✓✓ |
9012045 |
if (alpha_sum > 0) |
246 |
|
|
{ |
247 |
|
4962546 |
blend_func(context, |
248 |
|
4962546 |
draw_area -> gx_rectangle_left + (GX_VALUE)col, |
249 |
|
4962546 |
draw_area -> gx_rectangle_top + (GX_VALUE)row, |
250 |
|
4962546 |
text_color, (GX_UBYTE)alpha_sum); |
251 |
|
|
} |
252 |
|
9012045 |
col++; |
253 |
|
9012045 |
glyph_data++; |
254 |
|
|
} |
255 |
|
|
|
256 |
✓✓ |
2466669 |
if (trailing_pixel) |
257 |
|
|
{ |
258 |
|
1418227 |
alpha = (*glyph_data) & 0xf0; |
259 |
|
1418227 |
alpha = (GX_UBYTE)(alpha | (GX_UBYTE)(alpha >> 4)); |
260 |
|
1418227 |
alpha_sum = alpha * brush_alpha / 255; |
261 |
|
|
|
262 |
✓✓ |
1418227 |
if (alpha_sum > 0) |
263 |
|
|
{ |
264 |
|
456124 |
blend_func(context, |
265 |
|
456124 |
draw_area -> gx_rectangle_left + (GX_VALUE)col, |
266 |
|
456124 |
draw_area -> gx_rectangle_top + (GX_VALUE)row, |
267 |
|
456124 |
text_color, (GX_UBYTE)alpha_sum); |
268 |
|
|
} |
269 |
|
|
} |
270 |
|
2466669 |
glyph_row += pitch; |
271 |
|
|
} |
272 |
|
|
} |
273 |
|
|
#endif |
274 |
|
|
|
275 |
|
|
} |
276 |
|
|
|