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_utility.h" |
30 |
|
|
|
31 |
|
|
/**************************************************************************/ |
32 |
|
|
/* */ |
33 |
|
|
/* FUNCTION RELEASE */ |
34 |
|
|
/* */ |
35 |
|
|
/* _gx_display_driver_4bpp_canvas_copy PORTABLE C */ |
36 |
|
|
/* 6.1 */ |
37 |
|
|
/* AUTHOR */ |
38 |
|
|
/* */ |
39 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
40 |
|
|
/* */ |
41 |
|
|
/* DESCRIPTION */ |
42 |
|
|
/* */ |
43 |
|
|
/* Generic 4bpp canvas copy function. */ |
44 |
|
|
/* */ |
45 |
|
|
/* INPUT */ |
46 |
|
|
/* */ |
47 |
|
|
/* canvas The canvas to copy from */ |
48 |
|
|
/* composite The canvas to copy to */ |
49 |
|
|
/* */ |
50 |
|
|
/* OUTPUT */ |
51 |
|
|
/* */ |
52 |
|
|
/* None */ |
53 |
|
|
/* */ |
54 |
|
|
/* CALLS */ |
55 |
|
|
/* */ |
56 |
|
|
/* _gx_utility_rectangle_shift Move the rectangle */ |
57 |
|
|
/* _gx_utility_rectangle_overlap_detect Detect two rectangles being */ |
58 |
|
|
/* overlap to each other */ |
59 |
|
|
/* memcpy Move canvas data */ |
60 |
|
|
/* */ |
61 |
|
|
/* CALLED BY */ |
62 |
|
|
/* */ |
63 |
|
|
/* GUIX Internal Code */ |
64 |
|
|
/* */ |
65 |
|
|
/**************************************************************************/ |
66 |
|
46 |
VOID _gx_display_driver_4bpp_canvas_copy(GX_CANVAS *canvas, GX_CANVAS *composite) |
67 |
|
|
{ |
68 |
|
|
GX_RECTANGLE dirty; |
69 |
|
|
GX_RECTANGLE overlap; |
70 |
|
|
GX_UBYTE *read; |
71 |
|
|
GX_UBYTE *write; |
72 |
|
|
GX_UBYTE color; |
73 |
|
|
INT row; |
74 |
|
|
INT column; |
75 |
|
|
UINT read_pos; |
76 |
|
|
UINT write_pos; |
77 |
|
|
GX_UBYTE read_mask; |
78 |
|
|
GX_UBYTE write_mask; |
79 |
|
|
INT readstride; |
80 |
|
|
INT writestride; |
81 |
|
|
INT offset; |
82 |
|
|
|
83 |
|
46 |
dirty.gx_rectangle_left = dirty.gx_rectangle_top = 0; |
84 |
|
46 |
dirty.gx_rectangle_right = (GX_VALUE)(canvas -> gx_canvas_x_resolution - 1); |
85 |
|
46 |
dirty.gx_rectangle_bottom = (GX_VALUE)(canvas -> gx_canvas_y_resolution - 1); |
86 |
|
46 |
readstride = (canvas->gx_canvas_x_resolution + 1) >> 1; |
87 |
|
46 |
writestride = (composite->gx_canvas_x_resolution + 1) >> 1; |
88 |
|
|
|
89 |
|
46 |
_gx_utility_rectangle_shift(&dirty, canvas -> gx_canvas_display_offset_x, canvas -> gx_canvas_display_offset_y); |
90 |
|
|
|
91 |
✓✓ |
46 |
if (_gx_utility_rectangle_overlap_detect(&dirty, &composite -> gx_canvas_dirty_area, &overlap)) |
92 |
|
|
{ |
93 |
|
38 |
offset = overlap.gx_rectangle_left - dirty.gx_rectangle_left; |
94 |
|
38 |
read_pos = (UINT)((overlap.gx_rectangle_top - dirty.gx_rectangle_top) * readstride + (offset >> 1)); |
95 |
|
38 |
write_pos = (UINT)(overlap.gx_rectangle_top * writestride + (overlap.gx_rectangle_left >> 1)); |
96 |
|
|
|
97 |
✓✓ |
8678 |
for (row = overlap.gx_rectangle_top; row <= overlap.gx_rectangle_bottom; row++) |
98 |
|
|
{ |
99 |
|
8640 |
read = (GX_UBYTE *)canvas->gx_canvas_memory; |
100 |
|
8640 |
write = (GX_UBYTE *)composite->gx_canvas_memory; |
101 |
|
|
|
102 |
|
8640 |
read += read_pos; |
103 |
|
8640 |
write += write_pos; |
104 |
|
|
/* If position is odd, it means the low bits. */ |
105 |
✓✓ |
8640 |
if (offset & 0x01) |
106 |
|
|
{ |
107 |
|
724 |
read_mask = 0x0f; |
108 |
|
|
} |
109 |
|
|
else |
110 |
|
|
{ |
111 |
|
7916 |
read_mask = 0xf0; |
112 |
|
|
} |
113 |
|
|
|
114 |
✓✓ |
8640 |
if (overlap.gx_rectangle_left & 0x01) |
115 |
|
|
{ |
116 |
|
651 |
write_mask = 0x0f; |
117 |
|
|
} |
118 |
|
|
else |
119 |
|
|
{ |
120 |
|
7989 |
write_mask = 0xf0; |
121 |
|
|
} |
122 |
|
|
|
123 |
✓✓ |
4499601 |
for (column = overlap.gx_rectangle_left; column <= overlap.gx_rectangle_right; column++) |
124 |
|
|
{ |
125 |
|
4490961 |
color = (*read) & read_mask; |
126 |
|
4490961 |
*write = (GX_UBYTE)((*write) & (~write_mask)); |
127 |
|
|
|
128 |
✓✓ |
4490961 |
if (color) |
129 |
|
|
{ |
130 |
|
|
/* Read and write have same mask bits. */ |
131 |
✓✓ |
3221304 |
if (read_mask & write_mask) |
132 |
|
|
{ |
133 |
|
3214772 |
*write |= color; |
134 |
|
|
} |
135 |
|
|
else |
136 |
|
|
{ |
137 |
|
|
/* Read and write are malposed. */ |
138 |
|
|
/* If position is odd, it means the low bits. */ |
139 |
✓✓ |
6532 |
if (write_mask & 0x01) |
140 |
|
|
{ |
141 |
|
3266 |
*write |= (GX_UBYTE)(color >> 4); |
142 |
|
|
} |
143 |
|
|
else |
144 |
|
|
{ |
145 |
|
3266 |
*write |= (GX_UBYTE)(color << 4); |
146 |
|
|
} |
147 |
|
|
} |
148 |
|
|
} |
149 |
|
|
|
150 |
|
4490961 |
read_mask >>= 4; |
151 |
|
4490961 |
write_mask >>= 4; |
152 |
✓✓ |
4490961 |
if (!read_mask) |
153 |
|
|
{ |
154 |
|
2244844 |
read++; |
155 |
|
2244844 |
read_mask = 0xf0; |
156 |
|
|
} |
157 |
✓✓ |
4490961 |
if (!write_mask) |
158 |
|
|
{ |
159 |
|
2244771 |
write++; |
160 |
|
2244771 |
write_mask = 0xf0; |
161 |
|
|
} |
162 |
|
|
} |
163 |
|
8640 |
write_pos = (UINT)((INT)write_pos + writestride); |
164 |
|
8640 |
read_pos = (UINT)((INT)read_pos + readstride); |
165 |
|
|
} |
166 |
|
|
} |
167 |
|
46 |
} |
168 |
|
|
|