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_8bpp_rotated_block_move PORTABLE C */ |
36 |
|
|
/* 6.1.4 */ |
37 |
|
|
/* AUTHOR */ |
38 |
|
|
/* */ |
39 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
40 |
|
|
/* */ |
41 |
|
|
/* DESCRIPTION */ |
42 |
|
|
/* */ |
43 |
|
|
/* 8-bit color format display driver rotated 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 |
|
|
/* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */ |
69 |
|
|
/* */ |
70 |
|
|
/**************************************************************************/ |
71 |
|
79 |
VOID _gx_display_driver_8bpp_rotated_block_move(GX_DRAW_CONTEXT *context, |
72 |
|
|
GX_RECTANGLE *block, INT xshift, INT yshift) |
73 |
|
|
{ |
74 |
|
|
GX_UBYTE *pGet; |
75 |
|
|
GX_UBYTE *pPut; |
76 |
|
|
int width; |
77 |
|
|
int y; |
78 |
|
|
int height; |
79 |
|
|
GX_RECTANGLE rotated_block; |
80 |
|
|
|
81 |
|
79 |
GX_SWAP_VALS(xshift, yshift); |
82 |
|
|
|
83 |
✓✓ |
79 |
if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW) |
84 |
|
|
{ |
85 |
|
75 |
rotated_block.gx_rectangle_left = block -> gx_rectangle_top; |
86 |
|
75 |
rotated_block.gx_rectangle_right = block -> gx_rectangle_bottom; |
87 |
|
75 |
rotated_block.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - block -> gx_rectangle_right - 1); |
88 |
|
75 |
rotated_block.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - block -> gx_rectangle_left - 1); |
89 |
|
|
|
90 |
|
75 |
yshift = -yshift; |
91 |
|
|
} |
92 |
|
|
else |
93 |
|
|
{ |
94 |
|
4 |
rotated_block.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - block -> gx_rectangle_bottom - 1); |
95 |
|
4 |
rotated_block.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - block -> gx_rectangle_top - 1); |
96 |
|
4 |
rotated_block.gx_rectangle_top = block -> gx_rectangle_left; |
97 |
|
4 |
rotated_block.gx_rectangle_bottom = block -> gx_rectangle_right; |
98 |
|
|
|
99 |
|
4 |
xshift = -xshift; |
100 |
|
|
} |
101 |
|
|
|
102 |
✓✓ |
79 |
if (xshift) |
103 |
|
|
{ |
104 |
✓✓ |
75 |
if (xshift > 0) |
105 |
|
|
{ |
106 |
|
4 |
pPut = (GX_UBYTE *)context -> gx_draw_context_memory; |
107 |
|
4 |
pPut += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch; |
108 |
|
4 |
pPut += rotated_block.gx_rectangle_left + xshift; |
109 |
|
|
|
110 |
|
4 |
pGet = (GX_UBYTE *)context -> gx_draw_context_memory; |
111 |
|
4 |
pGet += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch; |
112 |
|
4 |
pGet += rotated_block.gx_rectangle_left; |
113 |
|
|
|
114 |
|
4 |
width = rotated_block.gx_rectangle_right - rotated_block.gx_rectangle_left + 1 - xshift; |
115 |
|
|
} |
116 |
|
|
else |
117 |
|
|
{ |
118 |
|
|
/* Have to copy from right to left. */ |
119 |
|
71 |
pPut = (GX_UBYTE *)context -> gx_draw_context_memory; |
120 |
|
71 |
pPut += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch; |
121 |
|
71 |
pPut += rotated_block.gx_rectangle_left; |
122 |
|
|
|
123 |
|
71 |
pGet = (GX_UBYTE *)context -> gx_draw_context_memory; |
124 |
|
71 |
pGet += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch; |
125 |
|
71 |
pGet += rotated_block.gx_rectangle_left - xshift; |
126 |
|
|
|
127 |
|
71 |
width = rotated_block.gx_rectangle_right - rotated_block.gx_rectangle_left + 1 + xshift; |
128 |
|
|
} |
129 |
|
|
|
130 |
|
|
|
131 |
✓✓ |
75 |
if (width <= 0) |
132 |
|
|
{ |
133 |
|
2 |
return; |
134 |
|
|
} |
135 |
|
|
|
136 |
✓✓ |
16284 |
for (y = rotated_block.gx_rectangle_top; y <= rotated_block.gx_rectangle_bottom; y++) |
137 |
|
|
{ |
138 |
|
16211 |
memmove(pPut, pGet, (size_t)width); |
139 |
|
|
|
140 |
|
16211 |
pPut += context -> gx_draw_context_pitch; |
141 |
|
16211 |
pGet += context -> gx_draw_context_pitch; |
142 |
|
|
} |
143 |
|
|
} |
144 |
|
|
else |
145 |
|
|
{ |
146 |
|
4 |
width = rotated_block.gx_rectangle_right - rotated_block.gx_rectangle_left + 1; |
147 |
|
|
|
148 |
✓✓ |
4 |
if (yshift > 0) |
149 |
|
|
{ |
150 |
|
|
/* Have to copy from top to bottom. */ |
151 |
|
2 |
pPut = (GX_UBYTE *)context -> gx_draw_context_memory; |
152 |
|
2 |
pPut += rotated_block.gx_rectangle_bottom * context -> gx_draw_context_pitch; |
153 |
|
2 |
pPut += rotated_block.gx_rectangle_left; |
154 |
|
|
|
155 |
|
2 |
pGet = (GX_UBYTE *)context -> gx_draw_context_memory; |
156 |
|
2 |
pGet += (rotated_block.gx_rectangle_bottom - yshift) * context -> gx_draw_context_pitch; |
157 |
|
2 |
pGet += rotated_block.gx_rectangle_left; |
158 |
|
|
|
159 |
|
2 |
height = rotated_block.gx_rectangle_bottom - rotated_block.gx_rectangle_top + 1 - yshift; |
160 |
|
|
|
161 |
✓✓ |
170 |
for (y = 0; y < height; y++) |
162 |
|
|
{ |
163 |
|
168 |
memmove(pPut, pGet, (size_t)width); |
164 |
|
|
|
165 |
|
168 |
pPut -= context -> gx_draw_context_pitch; |
166 |
|
168 |
pGet -= context -> gx_draw_context_pitch; |
167 |
|
|
} |
168 |
|
|
} |
169 |
|
|
else |
170 |
|
|
{ |
171 |
|
|
/* Have to copy from bottom to top. */ |
172 |
|
2 |
pPut = (GX_UBYTE *)context -> gx_draw_context_memory; |
173 |
|
2 |
pPut += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch; |
174 |
|
2 |
pPut += rotated_block.gx_rectangle_left; |
175 |
|
|
|
176 |
|
2 |
pGet = (GX_UBYTE *)context -> gx_draw_context_memory; |
177 |
|
2 |
pGet += (rotated_block.gx_rectangle_top - yshift) * context -> gx_draw_context_pitch; |
178 |
|
2 |
pGet += rotated_block.gx_rectangle_left; |
179 |
|
|
|
180 |
|
2 |
height = rotated_block.gx_rectangle_bottom - rotated_block.gx_rectangle_top + 1 + yshift; |
181 |
|
|
|
182 |
✓✓ |
170 |
for (y = 0; y < height; y++) |
183 |
|
|
{ |
184 |
|
168 |
memmove(pPut, pGet, (size_t)width); |
185 |
|
|
|
186 |
|
168 |
pPut += context -> gx_draw_context_pitch; |
187 |
|
168 |
pGet += context -> gx_draw_context_pitch; |
188 |
|
|
} |
189 |
|
|
} |
190 |
|
|
} |
191 |
|
|
} |
192 |
|
|
|