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_display.h" |
29 |
|
|
#include "gx_system.h" |
30 |
|
|
#include "gx_utility.h" |
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _gx_display_driver_16bpp_rotated_block_move PORTABLE C */ |
37 |
|
|
/* 6.1.3 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* Generic 16bpp color format display driver rotated block moving */ |
45 |
|
|
/* function. */ |
46 |
|
|
/* */ |
47 |
|
|
/* INPUT */ |
48 |
|
|
/* */ |
49 |
|
|
/* context Draw context */ |
50 |
|
|
/* block The rectangle to be moved */ |
51 |
|
|
/* xshift Amount to move on X-axis */ |
52 |
|
|
/* yshift Amount to move on Y-axis */ |
53 |
|
|
/* */ |
54 |
|
|
/* OUTPUT */ |
55 |
|
|
/* */ |
56 |
|
|
/* None */ |
57 |
|
|
/* */ |
58 |
|
|
/* CALLS */ |
59 |
|
|
/* */ |
60 |
|
|
/* memmove Move a block of data */ |
61 |
|
|
/* */ |
62 |
|
|
/* CALLED BY */ |
63 |
|
|
/* */ |
64 |
|
|
/* GUIX Internal Code */ |
65 |
|
|
/* */ |
66 |
|
|
/**************************************************************************/ |
67 |
|
45 |
VOID _gx_display_driver_16bpp_rotated_block_move(GX_DRAW_CONTEXT *context, |
68 |
|
|
GX_RECTANGLE *block, INT xshift, INT yshift) |
69 |
|
|
{ |
70 |
|
|
USHORT *pGet; |
71 |
|
|
USHORT *pPut; |
72 |
|
|
INT width; |
73 |
|
|
INT width_in_bytes; |
74 |
|
|
INT y; |
75 |
|
|
INT height; |
76 |
|
|
GX_RECTANGLE rotated_block; |
77 |
|
|
|
78 |
|
45 |
GX_SWAP_VALS(xshift, yshift); |
79 |
|
|
|
80 |
✓✓ |
45 |
if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW) |
81 |
|
|
{ |
82 |
|
41 |
rotated_block.gx_rectangle_left = block -> gx_rectangle_top; |
83 |
|
41 |
rotated_block.gx_rectangle_right = block -> gx_rectangle_bottom; |
84 |
|
41 |
rotated_block.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - block -> gx_rectangle_right - 1); |
85 |
|
41 |
rotated_block.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - block -> gx_rectangle_left - 1); |
86 |
|
|
|
87 |
|
41 |
yshift = -yshift; |
88 |
|
|
} |
89 |
|
|
else |
90 |
|
|
{ |
91 |
|
4 |
rotated_block.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - block -> gx_rectangle_bottom - 1); |
92 |
|
4 |
rotated_block.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - block -> gx_rectangle_top - 1); |
93 |
|
4 |
rotated_block.gx_rectangle_top = block -> gx_rectangle_left; |
94 |
|
4 |
rotated_block.gx_rectangle_bottom = block -> gx_rectangle_right; |
95 |
|
|
|
96 |
|
4 |
xshift = -xshift; |
97 |
|
|
} |
98 |
|
|
|
99 |
✓✓ |
45 |
if (xshift) |
100 |
|
|
{ |
101 |
✓✓ |
41 |
if (xshift > 0) |
102 |
|
|
{ |
103 |
|
|
|
104 |
|
|
/* Have to copy from left to right. */ |
105 |
|
4 |
pPut = (USHORT *)context -> gx_draw_context_memory; |
106 |
|
4 |
pPut += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch; |
107 |
|
4 |
pPut += rotated_block.gx_rectangle_left + xshift; |
108 |
|
|
|
109 |
|
4 |
pGet = (USHORT *)context -> gx_draw_context_memory; |
110 |
|
4 |
pGet += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch; |
111 |
|
4 |
pGet += rotated_block.gx_rectangle_left; |
112 |
|
|
|
113 |
|
4 |
width = rotated_block.gx_rectangle_right - rotated_block.gx_rectangle_left + 1 - xshift; |
114 |
|
4 |
width_in_bytes = width * (int)sizeof(USHORT); |
115 |
|
|
|
116 |
✓✓ |
4 |
if (width_in_bytes <= 0) |
117 |
|
|
{ |
118 |
|
2 |
return; |
119 |
|
|
} |
120 |
|
|
|
121 |
✓✓ |
650 |
for (y = rotated_block.gx_rectangle_top; y <= rotated_block.gx_rectangle_bottom; y++) |
122 |
|
|
{ |
123 |
|
647 |
memmove(pPut, pGet, (size_t)width_in_bytes); |
124 |
|
|
|
125 |
|
647 |
pPut += context -> gx_draw_context_pitch; |
126 |
|
647 |
pGet += context -> gx_draw_context_pitch; |
127 |
|
|
} |
128 |
|
|
} |
129 |
|
|
else |
130 |
|
|
{ |
131 |
|
|
|
132 |
|
|
/* Have to copy from right to left. */ |
133 |
|
37 |
pPut = (USHORT *)context -> gx_draw_context_memory; |
134 |
|
37 |
pPut += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch; |
135 |
|
37 |
pPut += rotated_block.gx_rectangle_left; |
136 |
|
|
|
137 |
|
37 |
pGet = (USHORT *)context -> gx_draw_context_memory; |
138 |
|
37 |
pGet += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch; |
139 |
|
37 |
pGet += rotated_block.gx_rectangle_left - xshift; |
140 |
|
|
|
141 |
|
37 |
width = rotated_block.gx_rectangle_right - rotated_block.gx_rectangle_left + 1 + xshift; |
142 |
|
37 |
width_in_bytes = width * (int)sizeof(USHORT); |
143 |
|
|
|
144 |
✓✓ |
37 |
if (width_in_bytes <= 0) |
145 |
|
|
{ |
146 |
|
1 |
return; |
147 |
|
|
} |
148 |
|
|
|
149 |
✓✓ |
7916 |
for (y = rotated_block.gx_rectangle_top; y <= rotated_block.gx_rectangle_bottom; y++) |
150 |
|
|
{ |
151 |
|
7880 |
memmove(pPut, pGet, (size_t)width_in_bytes); |
152 |
|
|
|
153 |
|
7880 |
pPut += context -> gx_draw_context_pitch; |
154 |
|
7880 |
pGet += context -> gx_draw_context_pitch; |
155 |
|
|
} |
156 |
|
|
} |
157 |
|
|
} |
158 |
|
|
else |
159 |
|
|
{ |
160 |
|
4 |
width = rotated_block.gx_rectangle_right - rotated_block.gx_rectangle_left + 1; |
161 |
|
4 |
width_in_bytes = width * (int)sizeof(USHORT); |
162 |
|
|
|
163 |
✓✓ |
4 |
if (yshift > 0) |
164 |
|
|
{ |
165 |
|
|
|
166 |
|
|
/* Have to copy from top to bottom. */ |
167 |
|
2 |
pPut = (USHORT *)context -> gx_draw_context_memory; |
168 |
|
2 |
pPut += rotated_block.gx_rectangle_bottom * context -> gx_draw_context_pitch; |
169 |
|
2 |
pPut += rotated_block.gx_rectangle_left; |
170 |
|
|
|
171 |
|
2 |
pGet = (USHORT *)context -> gx_draw_context_memory; |
172 |
|
2 |
pGet += (rotated_block.gx_rectangle_bottom - yshift) * context -> gx_draw_context_pitch; |
173 |
|
2 |
pGet += rotated_block.gx_rectangle_left; |
174 |
|
|
|
175 |
|
2 |
height = rotated_block.gx_rectangle_bottom - rotated_block.gx_rectangle_top + 1 - yshift; |
176 |
|
|
|
177 |
✓✓ |
170 |
for (y = 0; y < height; y++) |
178 |
|
|
{ |
179 |
|
168 |
memmove(pPut, pGet, (size_t)width_in_bytes); |
180 |
|
|
|
181 |
|
168 |
pPut -= context -> gx_draw_context_pitch; |
182 |
|
168 |
pGet -= context -> gx_draw_context_pitch; |
183 |
|
|
} |
184 |
|
|
} |
185 |
|
|
else |
186 |
|
|
{ |
187 |
|
|
|
188 |
|
|
/* Have to copy from bottom to top. */ |
189 |
|
2 |
pPut = (USHORT *)context -> gx_draw_context_memory; |
190 |
|
2 |
pPut += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch; |
191 |
|
2 |
pPut += rotated_block.gx_rectangle_left; |
192 |
|
|
|
193 |
|
2 |
pGet = (USHORT *)context -> gx_draw_context_memory; |
194 |
|
2 |
pGet += (rotated_block.gx_rectangle_top - yshift) * context -> gx_draw_context_pitch; |
195 |
|
2 |
pGet += rotated_block.gx_rectangle_left; |
196 |
|
|
|
197 |
|
2 |
height = rotated_block.gx_rectangle_bottom - rotated_block.gx_rectangle_top + 1 + yshift; |
198 |
|
|
|
199 |
✓✓ |
170 |
for (y = 0; y < height; y++) |
200 |
|
|
{ |
201 |
|
168 |
memmove(pPut, pGet, (size_t)width_in_bytes); |
202 |
|
|
|
203 |
|
168 |
pPut += context -> gx_draw_context_pitch; |
204 |
|
168 |
pGet += context -> gx_draw_context_pitch; |
205 |
|
|
} |
206 |
|
|
} |
207 |
|
|
} |
208 |
|
|
} |
209 |
|
|
|