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_utility.h" |
29 |
|
|
#include "gx_display.h" |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _gx_display_driver_generic_rotated_glyph_8bit_draw PORTABLE C */ |
37 |
|
|
/* 6.1.3 */ |
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_position The X and Y coordinate where */ |
51 |
|
|
/* the glyph is drawn to */ |
52 |
|
|
/* string String to draw */ |
53 |
|
|
/* count Count of string characters */ |
54 |
|
|
/* view view to clip drawing within */ |
55 |
|
|
/* */ |
56 |
|
|
/* OUTPUT */ |
57 |
|
|
/* */ |
58 |
|
|
/* None */ |
59 |
|
|
/* */ |
60 |
|
|
/* CALLS */ |
61 |
|
|
/* */ |
62 |
|
|
/* _gx_display_driver_565rgb_pixel_blend Call display driver pixel */ |
63 |
|
|
/* blend function */ |
64 |
|
|
/* */ |
65 |
|
|
/* CALLED BY */ |
66 |
|
|
/* */ |
67 |
|
|
/* GUIX internal code */ |
68 |
|
|
/* */ |
69 |
|
|
/* RELEASE HISTORY */ |
70 |
|
|
/* */ |
71 |
|
|
/* DATE NAME DESCRIPTION */ |
72 |
|
|
/* */ |
73 |
|
|
/* 12-31-2020 Kenneth Maxwell Initial Version 6.1.3 */ |
74 |
|
|
/* */ |
75 |
|
|
/**************************************************************************/ |
76 |
|
413918 |
VOID _gx_display_driver_generic_rotated_glyph_8bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, GX_CONST GX_GLYPH *glyph) |
77 |
|
|
{ |
78 |
|
|
GX_UBYTE *glyph_row; |
79 |
|
|
GX_UBYTE *glyph_data; |
80 |
|
|
UINT row; |
81 |
|
|
UINT col; |
82 |
|
413918 |
UINT pixel_width = 0; |
83 |
|
|
GX_COLOR text_color; |
84 |
|
|
UINT y_height; |
85 |
|
|
GX_UBYTE alpha1; |
86 |
|
413918 |
GX_UBYTE brush_alpha = 0xff; |
87 |
|
|
GX_VALUE rotated_map_offset_x; |
88 |
|
|
GX_VALUE rotated_map_offset_y; |
89 |
|
|
GX_VALUE rotated_left; |
90 |
|
|
GX_VALUE rotated_top; |
91 |
|
|
VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha); |
92 |
|
|
|
93 |
|
|
#if defined(GX_BRUSH_ALPHA_SUPPORT) |
94 |
|
413918 |
brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha; |
95 |
✓✓ |
413918 |
if (brush_alpha == 0) |
96 |
|
|
{ |
97 |
|
97 |
return; |
98 |
|
|
} |
99 |
|
|
#endif |
100 |
|
|
|
101 |
✓✓✓✓
|
413821 |
GX_SET_BLEND_FUNCTION(blend_func, context->gx_draw_context_display->gx_display_color_format) |
102 |
|
|
|
103 |
|
405355 |
text_color = context -> gx_draw_context_brush.gx_brush_line_color; |
104 |
|
|
|
105 |
|
405355 |
pixel_width = (UINT)(draw_area -> gx_rectangle_bottom - draw_area -> gx_rectangle_top + 1); |
106 |
|
405355 |
y_height = (UINT)(draw_area -> gx_rectangle_right - draw_area -> gx_rectangle_left + 1); |
107 |
|
|
|
108 |
✓✓ |
405355 |
if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW) |
109 |
|
|
{ |
110 |
|
247361 |
rotated_left = draw_area -> gx_rectangle_top; |
111 |
|
247361 |
rotated_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - draw_area -> gx_rectangle_right - 1); |
112 |
|
|
|
113 |
|
247361 |
rotated_map_offset_x = map_offset -> gx_point_y; |
114 |
|
247361 |
rotated_map_offset_y = (GX_VALUE)(glyph -> gx_glyph_width - map_offset -> gx_point_x - (GX_VALUE)y_height); |
115 |
|
|
} |
116 |
|
|
else |
117 |
|
|
{ |
118 |
|
157994 |
rotated_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_display_offset_y - draw_area -> gx_rectangle_bottom - 1); |
119 |
|
157994 |
rotated_top = draw_area -> gx_rectangle_left; |
120 |
|
|
|
121 |
|
157994 |
rotated_map_offset_x = (GX_VALUE)(glyph -> gx_glyph_height - map_offset -> gx_point_y - (GX_VALUE)pixel_width); |
122 |
|
157994 |
rotated_map_offset_y = map_offset -> gx_point_x; |
123 |
|
|
} |
124 |
|
|
|
125 |
|
405355 |
glyph_row = (GX_UBYTE *)glyph -> gx_glyph_map; |
126 |
|
|
|
127 |
✓✓ |
405355 |
if (rotated_map_offset_y) |
128 |
|
|
{ |
129 |
|
3971 |
glyph_row = glyph_row + (glyph -> gx_glyph_height * rotated_map_offset_y); |
130 |
|
|
} |
131 |
|
|
|
132 |
|
405355 |
glyph_row += rotated_map_offset_x; |
133 |
|
|
|
134 |
✓✓ |
405355 |
if (brush_alpha == 0xff) |
135 |
|
|
{ |
136 |
✓✓ |
3715433 |
for (row = 0; row < y_height; row++) |
137 |
|
|
{ |
138 |
|
3310521 |
glyph_data = glyph_row; |
139 |
|
|
|
140 |
✓✓ |
41427421 |
for (col = 0; col < pixel_width; col++) |
141 |
|
|
{ |
142 |
|
38116900 |
alpha1 = *glyph_data; |
143 |
|
|
|
144 |
✓✓ |
38116900 |
if (alpha1 > 0) |
145 |
|
|
{ |
146 |
|
25051715 |
blend_func(context, |
147 |
|
25051715 |
rotated_left + (GX_VALUE)col, |
148 |
|
25051715 |
rotated_top + (GX_VALUE)row, |
149 |
|
|
text_color, (GX_UBYTE)alpha1); |
150 |
|
|
} |
151 |
|
38116900 |
glyph_data++; |
152 |
|
|
} |
153 |
|
3310521 |
glyph_row += glyph -> gx_glyph_height; |
154 |
|
|
} |
155 |
|
|
} |
156 |
|
|
#if defined(GX_BRUSH_ALPHA_SUPPORT) |
157 |
|
|
else |
158 |
|
|
{ |
159 |
✓✓ |
6853 |
for (row = 0; row < y_height; row++) |
160 |
|
|
{ |
161 |
|
6410 |
glyph_data = glyph_row; |
162 |
|
|
|
163 |
✓✓ |
123180 |
for (col = 0; col < pixel_width; col++) |
164 |
|
|
{ |
165 |
|
116770 |
alpha1 = *glyph_data; |
166 |
|
116770 |
alpha1 = (GX_UBYTE)(alpha1 * brush_alpha / 255); |
167 |
|
|
|
168 |
✓✓ |
116770 |
if (alpha1 > 0) |
169 |
|
|
{ |
170 |
|
56506 |
blend_func(context, |
171 |
|
56506 |
rotated_left + (GX_VALUE)col, |
172 |
|
56506 |
rotated_top + (GX_VALUE)row, |
173 |
|
|
text_color, (GX_UBYTE)alpha1); |
174 |
|
|
} |
175 |
|
|
|
176 |
|
116770 |
glyph_data++; |
177 |
|
|
} |
178 |
|
6410 |
glyph_row += glyph -> gx_glyph_height; |
179 |
|
|
} |
180 |
|
|
} |
181 |
|
|
#endif |
182 |
|
|
} |
183 |
|
|
|