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_4bpp_glyph_4bit_draw PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This 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 |
|
|
/* None */ |
63 |
|
|
/* */ |
64 |
|
|
/* CALLED BY */ |
65 |
|
|
/* */ |
66 |
|
|
/* _gx_canvas_text_draw */ |
67 |
|
|
/* */ |
68 |
|
|
/* RELEASE HISTORY */ |
69 |
|
|
/* */ |
70 |
|
|
/* DATE NAME DESCRIPTION */ |
71 |
|
|
/* */ |
72 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
73 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
74 |
|
|
/* resulting in version 6.1 */ |
75 |
|
|
/* */ |
76 |
|
|
/**************************************************************************/ |
77 |
|
104 |
VOID _gx_display_driver_4bpp_glyph_4bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph) |
78 |
|
|
{ |
79 |
|
|
UINT row; |
80 |
|
|
UINT height; |
81 |
|
|
GX_VALUE index; |
82 |
|
|
GX_UBYTE *glyph_getrow; |
83 |
|
|
GX_UBYTE *glyphdata_get; |
84 |
|
|
GX_UBYTE getmask; |
85 |
|
|
GX_UBYTE text_color; |
86 |
|
|
GX_UBYTE alpha; |
87 |
|
|
GX_UBYTE *put; |
88 |
|
|
GX_UBYTE putmask; |
89 |
|
|
GX_UBYTE *draw_start; |
90 |
|
|
INT putstride; |
91 |
|
|
INT getstride; |
92 |
|
|
|
93 |
|
104 |
putstride = (INT)(context -> gx_draw_context_pitch + 1) >> 1; |
94 |
|
104 |
draw_start = (GX_UBYTE *)context -> gx_draw_context_memory; |
95 |
|
104 |
draw_start += putstride * draw_area -> gx_rectangle_top; |
96 |
|
104 |
draw_start += draw_area -> gx_rectangle_left >> 1; |
97 |
|
|
|
98 |
|
104 |
text_color = (GX_UBYTE)(context -> gx_draw_context_brush.gx_brush_line_color + 15); |
99 |
|
|
|
100 |
|
|
/* Find the width of the glyph */ |
101 |
|
104 |
getstride = glyph -> gx_glyph_width; |
102 |
|
|
/* Make it byte-aligned. */ |
103 |
|
104 |
getstride = (getstride + 1) >> 1; |
104 |
|
|
|
105 |
|
104 |
glyph_getrow = (GX_UBYTE *)glyph -> gx_glyph_map; |
106 |
|
|
|
107 |
✓✓ |
104 |
if (map_offset -> gx_point_y) |
108 |
|
|
{ |
109 |
|
11 |
glyph_getrow = glyph_getrow + ((INT)getstride * map_offset -> gx_point_y); |
110 |
|
|
} |
111 |
|
|
|
112 |
|
104 |
glyph_getrow += (map_offset -> gx_point_x >> 1); |
113 |
|
|
|
114 |
|
104 |
height = (UINT)(draw_area -> gx_rectangle_bottom - draw_area -> gx_rectangle_top + 1); |
115 |
|
|
|
116 |
✓✓ |
1154 |
for (row = 0; row < height; row++) |
117 |
|
|
{ |
118 |
|
1050 |
glyphdata_get = glyph_getrow; |
119 |
✓✓ |
1050 |
if (map_offset -> gx_point_x & 1) |
120 |
|
|
{ |
121 |
|
9 |
getmask = 0x0f; |
122 |
|
|
} |
123 |
|
|
else |
124 |
|
|
{ |
125 |
|
1041 |
getmask = 0xf0; |
126 |
|
|
} |
127 |
|
|
|
128 |
|
1050 |
put = draw_start; |
129 |
✓✓ |
1050 |
if (draw_area -> gx_rectangle_left & 1) |
130 |
|
|
{ |
131 |
|
558 |
putmask = 0x0f; |
132 |
|
|
} |
133 |
|
|
else |
134 |
|
|
{ |
135 |
|
492 |
putmask = 0xf0; |
136 |
|
|
} |
137 |
|
|
|
138 |
✓✓ |
9084 |
for (index = draw_area -> gx_rectangle_left; index <= draw_area -> gx_rectangle_right; index++) |
139 |
|
|
{ |
140 |
|
8034 |
alpha = *glyphdata_get & getmask; |
141 |
|
|
|
142 |
✓✓ |
8034 |
if (getmask == 0xf0) |
143 |
|
|
{ |
144 |
|
4230 |
alpha >>= 4; |
145 |
|
4230 |
getmask >>= 4; |
146 |
|
|
} |
147 |
|
|
else |
148 |
|
|
{ |
149 |
|
3804 |
glyphdata_get++; |
150 |
|
3804 |
getmask = 0xf0; |
151 |
|
|
} |
152 |
|
|
|
153 |
|
8034 |
alpha = (GX_UBYTE)(text_color - alpha); |
154 |
|
8034 |
alpha |= (GX_UBYTE)(alpha << 4); |
155 |
|
|
|
156 |
|
8034 |
*put &= (GX_UBYTE)(~putmask); |
157 |
|
8034 |
*put |= (alpha & putmask); |
158 |
|
|
|
159 |
|
8034 |
putmask >>= 4; |
160 |
✓✓ |
8034 |
if (putmask == 0) |
161 |
|
|
{ |
162 |
|
4005 |
putmask = 0xf0; |
163 |
|
4005 |
put++; |
164 |
|
|
} |
165 |
|
|
|
166 |
|
|
} |
167 |
|
|
|
168 |
|
1050 |
glyph_getrow += getstride; |
169 |
|
1050 |
draw_start += putstride; |
170 |
|
|
} |
171 |
|
104 |
} |
172 |
|
|
|