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_display.h" |
28 |
|
|
#include "gx_system.h" |
29 |
|
|
#include "gx_utility.h" |
30 |
|
|
|
31 |
|
|
/**************************************************************************/ |
32 |
|
|
/* */ |
33 |
|
|
/* FUNCTION RELEASE */ |
34 |
|
|
/* */ |
35 |
|
|
/* _gx_display_driver_1bpp_block_move PORTABLE C */ |
36 |
|
|
/* 6.1 */ |
37 |
|
|
/* AUTHOR */ |
38 |
|
|
/* */ |
39 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
40 |
|
|
/* */ |
41 |
|
|
/* DESCRIPTION */ |
42 |
|
|
/* */ |
43 |
|
|
/* 1-bit color palette display driver block moving function. */ |
44 |
|
|
/* */ |
45 |
|
|
/* INPUT */ |
46 |
|
|
/* */ |
47 |
|
|
/* context Draw context */ |
48 |
|
|
/* block The rectangle to be moved */ |
49 |
|
|
/* xshift Amount to move on X-axis */ |
50 |
|
|
/* yshift Amount to move on Y-axis */ |
51 |
|
|
/* */ |
52 |
|
|
/* OUTPUT */ |
53 |
|
|
/* */ |
54 |
|
|
/* None */ |
55 |
|
|
/* */ |
56 |
|
|
/* CALLS */ |
57 |
|
|
/* */ |
58 |
|
|
/* memmove Move a block of data */ |
59 |
|
|
/* */ |
60 |
|
|
/* CALLED BY */ |
61 |
|
|
/* */ |
62 |
|
|
/* GUIX Internal Code */ |
63 |
|
|
/* */ |
64 |
|
|
/* RELEASE HISTORY */ |
65 |
|
|
/* */ |
66 |
|
|
/* DATE NAME DESCRIPTION */ |
67 |
|
|
/* */ |
68 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
69 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
70 |
|
|
/* resulting in version 6.1 */ |
71 |
|
|
/* */ |
72 |
|
|
/**************************************************************************/ |
73 |
|
8 |
VOID _gx_display_driver_1bpp_block_move(GX_DRAW_CONTEXT *context, |
74 |
|
|
GX_RECTANGLE *block, INT xshift, INT yshift) |
75 |
|
|
{ |
76 |
|
|
GX_UBYTE *putrow; |
77 |
|
|
GX_UBYTE *getrow; |
78 |
|
|
GX_UBYTE *pGet; |
79 |
|
|
GX_UBYTE *pPut; |
80 |
|
|
INT width; |
81 |
|
|
INT column; |
82 |
|
|
INT y; |
83 |
|
|
INT height; |
84 |
|
|
INT stride; |
85 |
|
|
GX_UBYTE putmask; |
86 |
|
|
GX_UBYTE getmask; |
87 |
|
|
INT move_width; |
88 |
|
|
|
89 |
|
8 |
putrow = (GX_UBYTE *)context -> gx_draw_context_memory; |
90 |
|
|
|
91 |
|
8 |
stride = (context -> gx_draw_context_pitch + 7) >> 3; |
92 |
|
|
|
93 |
✓✓ |
8 |
if (xshift) |
94 |
|
|
{ |
95 |
✓✓ |
4 |
if (xshift > 0) |
96 |
|
|
{ |
97 |
|
|
/* Copy from left to right. */ |
98 |
|
3 |
width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1; |
99 |
|
3 |
width -= xshift; |
100 |
|
|
|
101 |
|
3 |
putrow += block -> gx_rectangle_top * stride; |
102 |
|
3 |
getrow = putrow; |
103 |
|
|
|
104 |
|
3 |
putrow += block -> gx_rectangle_right >> 3; |
105 |
|
3 |
getrow += (block -> gx_rectangle_left + width - 1) >> 3; |
106 |
|
|
|
107 |
✓✓ |
345 |
for (y = block -> gx_rectangle_top; y <= block -> gx_rectangle_bottom; y++) |
108 |
|
|
{ |
109 |
|
342 |
pPut = putrow; |
110 |
|
342 |
pGet = getrow; |
111 |
|
|
|
112 |
|
342 |
putmask = (GX_UBYTE)(0x80 >> (block -> gx_rectangle_right & 0x07)); |
113 |
|
342 |
getmask = (GX_UBYTE)(0x80 >> ((block -> gx_rectangle_left + width - 1) & 0x07)); |
114 |
|
|
|
115 |
✓✓ |
53010 |
for (column = 0; column < width; column++) |
116 |
|
|
{ |
117 |
✓✓ |
52668 |
if ((*pGet) & getmask) |
118 |
|
|
{ |
119 |
|
14664 |
*pPut |= putmask; |
120 |
|
|
} |
121 |
|
|
else |
122 |
|
|
{ |
123 |
|
38004 |
*pPut = (GX_UBYTE)((*pPut) & (~putmask)); |
124 |
|
|
} |
125 |
|
|
|
126 |
✓✓ |
52668 |
if (getmask == 0x80) |
127 |
|
|
{ |
128 |
|
6726 |
getmask = 0x01; |
129 |
|
6726 |
pGet--; |
130 |
|
|
} |
131 |
|
|
else |
132 |
|
|
{ |
133 |
|
45942 |
getmask = (GX_UBYTE)(getmask << 1); |
134 |
|
|
} |
135 |
|
|
|
136 |
✓✓ |
52668 |
if (putmask == 0x80) |
137 |
|
|
{ |
138 |
|
6384 |
putmask = 0x01; |
139 |
|
6384 |
pPut--; |
140 |
|
|
} |
141 |
|
|
else |
142 |
|
|
{ |
143 |
|
46284 |
putmask = (GX_UBYTE)(putmask << 1); |
144 |
|
|
} |
145 |
|
|
} |
146 |
|
|
|
147 |
|
342 |
putrow += stride; |
148 |
|
342 |
getrow += stride; |
149 |
|
|
} |
150 |
|
|
} |
151 |
|
|
else |
152 |
|
|
{ |
153 |
|
|
/* Copy from right to left. */ |
154 |
|
1 |
width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1; |
155 |
|
1 |
width += xshift; |
156 |
|
|
|
157 |
|
1 |
putrow += block -> gx_rectangle_top * stride; |
158 |
|
1 |
getrow = putrow; |
159 |
|
|
|
160 |
|
1 |
putrow += block -> gx_rectangle_left >> 3; |
161 |
|
1 |
getrow += (block -> gx_rectangle_left - xshift) >> 3; |
162 |
|
|
|
163 |
✓✓ |
115 |
for (y = block -> gx_rectangle_top; y <= block -> gx_rectangle_bottom; y++) |
164 |
|
|
{ |
165 |
|
114 |
pPut = putrow; |
166 |
|
114 |
pGet = getrow; |
167 |
|
|
|
168 |
|
114 |
putmask = (GX_UBYTE)(0x80 >> (block -> gx_rectangle_left & 0x07)); |
169 |
|
114 |
getmask = (GX_UBYTE)(0x80 >> ((block -> gx_rectangle_left - xshift) & 0x07)); |
170 |
|
|
|
171 |
✓✓ |
9690 |
for (column = 0; column < width; column++) |
172 |
|
|
{ |
173 |
✓✓ |
9576 |
if ((*pGet) & getmask) |
174 |
|
|
{ |
175 |
|
1656 |
*pPut |= putmask; |
176 |
|
|
} |
177 |
|
|
else |
178 |
|
|
{ |
179 |
|
7920 |
*pPut &= (GX_UBYTE)(~putmask); |
180 |
|
|
} |
181 |
|
|
|
182 |
|
9576 |
getmask >>= 1; |
183 |
|
9576 |
putmask >>= 1; |
184 |
|
|
|
185 |
✓✓ |
9576 |
if (!getmask) |
186 |
|
|
{ |
187 |
|
1140 |
getmask = 0x80; |
188 |
|
1140 |
pGet++; |
189 |
|
|
} |
190 |
✓✓ |
9576 |
if (!putmask) |
191 |
|
|
{ |
192 |
|
1140 |
putmask = 0x80; |
193 |
|
1140 |
pPut++; |
194 |
|
|
} |
195 |
|
|
} |
196 |
|
|
|
197 |
|
114 |
putrow += stride; |
198 |
|
114 |
getrow += stride; |
199 |
|
|
} |
200 |
|
|
} |
201 |
|
|
} |
202 |
|
|
else |
203 |
|
|
{ |
204 |
|
4 |
width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1; |
205 |
|
|
|
206 |
✓✓ |
4 |
if (yshift > 0) |
207 |
|
|
{ |
208 |
|
|
/* Copy from top to bottom. */ |
209 |
|
3 |
putrow += (block -> gx_rectangle_bottom * stride); |
210 |
|
3 |
putrow += (block -> gx_rectangle_left >> 3); |
211 |
|
|
|
212 |
|
3 |
getrow = putrow; |
213 |
|
3 |
getrow -= yshift * stride; |
214 |
|
|
|
215 |
|
3 |
height = block -> gx_rectangle_bottom - block -> gx_rectangle_top + 1; |
216 |
|
3 |
height -= yshift; |
217 |
|
|
|
218 |
✓✓ |
297 |
for (y = 0; y < height; y++) |
219 |
|
|
{ |
220 |
|
294 |
pPut = putrow; |
221 |
|
294 |
pGet = getrow; |
222 |
|
|
|
223 |
|
294 |
putmask = (GX_UBYTE)(0x80 >> (block -> gx_rectangle_left & 0x07)); |
224 |
|
|
|
225 |
|
294 |
column = 0; |
226 |
✓✓ |
2624 |
while (column < width) |
227 |
|
|
{ |
228 |
✓✓✓✓
|
2330 |
if ((putmask == 0x80) && (width - column >= 8)) |
229 |
|
|
{ |
230 |
|
294 |
move_width = (width - column) >> 3; |
231 |
|
294 |
memmove(pPut, pGet, (size_t)move_width); |
232 |
|
294 |
pPut += move_width; |
233 |
|
294 |
pGet += move_width; |
234 |
|
294 |
column += (move_width << 3); |
235 |
|
|
} |
236 |
|
|
else |
237 |
|
|
{ |
238 |
✓✓ |
2036 |
if ((*pGet) & putmask) |
239 |
|
|
{ |
240 |
|
1176 |
*pPut |= putmask; |
241 |
|
|
} |
242 |
|
|
else |
243 |
|
|
{ |
244 |
|
860 |
*pPut &= (GX_UBYTE)(~putmask); |
245 |
|
|
} |
246 |
|
|
|
247 |
|
2036 |
putmask >>= 1; |
248 |
|
|
|
249 |
✓✓ |
2036 |
if (!putmask) |
250 |
|
|
{ |
251 |
|
68 |
putmask = 0x80; |
252 |
|
68 |
pPut++; |
253 |
|
68 |
pGet++; |
254 |
|
|
} |
255 |
|
|
|
256 |
|
2036 |
column++; |
257 |
|
|
} |
258 |
|
|
} |
259 |
|
|
|
260 |
|
294 |
putrow -= stride; |
261 |
|
294 |
getrow -= stride; |
262 |
|
|
} |
263 |
|
|
} |
264 |
|
|
else |
265 |
|
|
{ |
266 |
|
|
/* Copy from bottom to top. */ |
267 |
|
1 |
putrow += (block -> gx_rectangle_top * stride); |
268 |
|
1 |
putrow += (block -> gx_rectangle_left >> 3); |
269 |
|
|
|
270 |
|
1 |
getrow = putrow; |
271 |
|
1 |
getrow -= yshift * stride; |
272 |
|
|
|
273 |
|
1 |
height = block -> gx_rectangle_bottom - block -> gx_rectangle_top + 1; |
274 |
|
1 |
height += yshift; |
275 |
|
|
|
276 |
✓✓ |
69 |
for (y = 0; y < height; y++) |
277 |
|
|
{ |
278 |
|
68 |
pPut = putrow; |
279 |
|
68 |
pGet = getrow; |
280 |
|
|
|
281 |
|
68 |
putmask = (GX_UBYTE)(0x80 >> (block -> gx_rectangle_left & 0x07)); |
282 |
|
|
|
283 |
|
68 |
column = 0; |
284 |
|
|
|
285 |
✓✓ |
816 |
while (column < width) |
286 |
|
|
{ |
287 |
✓✓✓✓
|
748 |
if ((putmask == 0x80) && (width - column >= 8)) |
288 |
|
|
{ |
289 |
|
68 |
move_width = (width - column) >> 3; |
290 |
|
68 |
memmove(pPut, pGet, (size_t)move_width); |
291 |
|
68 |
pPut += move_width; |
292 |
|
68 |
pGet += move_width; |
293 |
|
68 |
column += (move_width << 3); |
294 |
|
|
} |
295 |
|
|
else |
296 |
|
|
{ |
297 |
✓✓ |
680 |
if ((*pGet) & putmask) |
298 |
|
|
{ |
299 |
|
526 |
*pPut |= putmask; |
300 |
|
|
} |
301 |
|
|
else |
302 |
|
|
{ |
303 |
|
154 |
*pPut &= (GX_UBYTE)(~putmask); |
304 |
|
|
} |
305 |
|
|
|
306 |
|
680 |
putmask >>= 1; |
307 |
|
|
|
308 |
✓✓ |
680 |
if (!putmask) |
309 |
|
|
{ |
310 |
|
68 |
putmask = 0x80; |
311 |
|
68 |
pPut++; |
312 |
|
68 |
pGet++; |
313 |
|
|
} |
314 |
|
|
|
315 |
|
680 |
column++; |
316 |
|
|
} |
317 |
|
|
} |
318 |
|
|
|
319 |
|
68 |
putrow += stride; |
320 |
|
68 |
getrow += stride; |
321 |
|
|
} |
322 |
|
|
} |
323 |
|
|
} |
324 |
|
8 |
} |
325 |
|
|
|