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 |
|
|
/* Include necessary system files. */ |
25 |
|
|
|
26 |
|
|
#include "gx_api.h" |
27 |
|
|
#include "gx_display.h" |
28 |
|
|
#include "gx_utility.h" |
29 |
|
|
|
30 |
|
|
#define REDVAL(_c) (GX_UBYTE)(((_c) >> 11) & 0x1f) |
31 |
|
|
#define GREENVAL(_c) (GX_UBYTE)(((_c) >> 5) & 0x3f) |
32 |
|
|
#define BLUEVAL(_c) (GX_UBYTE)(((_c)) & 0x1f) |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
/* Define macros for assembling a 16-bit r:g:b value from 3 components. */ |
36 |
|
|
|
37 |
|
|
#define ASSEMBLECOLOR(_r, _g, _b) \ |
38 |
|
|
((((_r) & 0x1f) << 11) | \ |
39 |
|
|
(((_g) & 0x3f) << 5) | \ |
40 |
|
|
(((_b) & 0x1f))) |
41 |
|
|
|
42 |
|
|
|
43 |
|
|
/**************************************************************************/ |
44 |
|
|
/* */ |
45 |
|
|
/* FUNCTION RELEASE */ |
46 |
|
|
/* */ |
47 |
|
|
/* _gx_display_driver_565rgb_rotated_canvas_blend PORTABLE C */ |
48 |
|
|
/* 6.1.3 */ |
49 |
|
|
/* AUTHOR */ |
50 |
|
|
/* */ |
51 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
52 |
|
|
/* */ |
53 |
|
|
/* DESCRIPTION */ |
54 |
|
|
/* */ |
55 |
|
|
/* Rotated canvas blend function for 565rgb color format. */ |
56 |
|
|
/* */ |
57 |
|
|
/* INPUT */ |
58 |
|
|
/* */ |
59 |
|
|
/* canvas The canvas to blend to */ |
60 |
|
|
/* composite The canvas to blend from */ |
61 |
|
|
/* */ |
62 |
|
|
/* OUTPUT */ |
63 |
|
|
/* */ |
64 |
|
|
/* None */ |
65 |
|
|
/* */ |
66 |
|
|
/* CALLS */ |
67 |
|
|
/* */ |
68 |
|
|
/* _gx_utility_rectangle_shift Adjust the rectangle */ |
69 |
|
|
/* _gx_utility_recttangle_overlap_detect Detect whether two areas */ |
70 |
|
|
/* overlap */ |
71 |
|
|
/* REDVAL Extrace Red from canvas */ |
72 |
|
|
/* GREENVAL Extrace Green from canvas */ |
73 |
|
|
/* BLUEVAL Extrace Blue from canvas */ |
74 |
|
|
/* ASSEMBLECOLOR Compose the RGB color */ |
75 |
|
|
/* */ |
76 |
|
|
/* CALLED BY */ |
77 |
|
|
/* */ |
78 |
|
|
/* GUIX Internal Code */ |
79 |
|
|
/* */ |
80 |
|
|
/**************************************************************************/ |
81 |
|
510 |
VOID _gx_display_driver_565rgb_rotated_canvas_blend(GX_CANVAS *canvas, GX_CANVAS *composite) |
82 |
|
|
{ |
83 |
|
|
GX_RECTANGLE dirty; |
84 |
|
|
GX_RECTANGLE overlap; |
85 |
|
|
USHORT *read; |
86 |
|
|
USHORT *read_start; |
87 |
|
|
USHORT *write; |
88 |
|
|
USHORT *write_start; |
89 |
|
|
USHORT fcolor; |
90 |
|
|
GX_UBYTE fred, fgreen, fblue; |
91 |
|
|
GX_UBYTE bred, bgreen, bblue; |
92 |
|
|
GX_UBYTE alpha, balpha; |
93 |
|
|
|
94 |
|
|
USHORT bcolor; |
95 |
|
|
INT row; |
96 |
|
|
INT col; |
97 |
|
|
|
98 |
|
510 |
dirty.gx_rectangle_left = dirty.gx_rectangle_top = 0; |
99 |
|
510 |
dirty.gx_rectangle_right = (GX_VALUE)(canvas -> gx_canvas_x_resolution - 1); |
100 |
|
510 |
dirty.gx_rectangle_bottom = (GX_VALUE)(canvas -> gx_canvas_y_resolution - 1); |
101 |
|
|
|
102 |
|
510 |
_gx_utility_rectangle_shift(&dirty, canvas -> gx_canvas_display_offset_x, canvas -> gx_canvas_display_offset_y); |
103 |
|
|
|
104 |
✓✓ |
510 |
if (_gx_utility_rectangle_overlap_detect(&dirty, &composite -> gx_canvas_dirty_area, &overlap)) |
105 |
|
|
{ |
106 |
|
508 |
alpha = canvas -> gx_canvas_alpha; |
107 |
|
508 |
balpha = (GX_UBYTE)(256 - alpha); |
108 |
|
|
|
109 |
|
508 |
read_start = (USHORT *)canvas -> gx_canvas_memory; |
110 |
|
508 |
write_start = (USHORT *)composite -> gx_canvas_memory; |
111 |
|
|
|
112 |
✓✓ |
508 |
if (canvas -> gx_canvas_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW) |
113 |
|
|
{ |
114 |
|
|
/* index into starting row */ |
115 |
|
254 |
read_start += (dirty.gx_rectangle_right - overlap.gx_rectangle_right) * canvas -> gx_canvas_y_resolution; |
116 |
|
|
|
117 |
|
|
/* index into pixel */ |
118 |
|
254 |
read_start += overlap.gx_rectangle_top - dirty.gx_rectangle_top; |
119 |
|
|
|
120 |
|
|
/* calculate the write pointer */ |
121 |
|
254 |
write_start += (composite -> gx_canvas_x_resolution - overlap.gx_rectangle_right - 1) * composite -> gx_canvas_y_resolution; |
122 |
|
254 |
write_start += overlap.gx_rectangle_top; |
123 |
|
|
} |
124 |
|
|
else |
125 |
|
|
{ |
126 |
|
|
/* index into starting row */ |
127 |
|
254 |
read_start += (overlap.gx_rectangle_left - dirty.gx_rectangle_left) * canvas -> gx_canvas_y_resolution; |
128 |
|
|
|
129 |
|
|
/* index into pixel */ |
130 |
|
254 |
read_start += dirty.gx_rectangle_bottom - overlap.gx_rectangle_bottom; |
131 |
|
|
|
132 |
|
|
/* calculate the write pointer */ |
133 |
|
254 |
write_start += overlap.gx_rectangle_left * composite -> gx_canvas_y_resolution; |
134 |
|
254 |
write_start += (composite -> gx_canvas_y_resolution - overlap.gx_rectangle_bottom - 1); |
135 |
|
|
} |
136 |
|
|
|
137 |
✓✓ |
48260 |
for (row = overlap.gx_rectangle_left; row <= overlap.gx_rectangle_right; row++) |
138 |
|
|
{ |
139 |
|
47752 |
read = read_start; |
140 |
|
47752 |
write = write_start; |
141 |
|
|
|
142 |
✓✓ |
3533648 |
for (col = overlap.gx_rectangle_top; col <= overlap.gx_rectangle_bottom; col++) |
143 |
|
|
{ |
144 |
|
|
/* read the foreground color */ |
145 |
|
3485896 |
fcolor = *read++; |
146 |
|
|
|
147 |
|
|
/* split foreground into red, green, and blue components */ |
148 |
|
3485896 |
fred = REDVAL(fcolor); |
149 |
|
3485896 |
fgreen = GREENVAL(fcolor); |
150 |
|
3485896 |
fblue = BLUEVAL(fcolor); |
151 |
|
|
|
152 |
|
|
/* read background color */ |
153 |
|
3485896 |
bcolor = *write; |
154 |
|
|
|
155 |
|
|
/* split background color into red, green, and blue components */ |
156 |
|
3485896 |
bred = REDVAL(bcolor); |
157 |
|
3485896 |
bgreen = GREENVAL(bcolor); |
158 |
|
3485896 |
bblue = BLUEVAL(bcolor); |
159 |
|
|
|
160 |
|
|
/* blend foreground and background, each color channel */ |
161 |
|
3485896 |
fred = (GX_UBYTE)(((bred * balpha) + (fred * alpha)) >> 8); |
162 |
|
3485896 |
fgreen = (GX_UBYTE)(((bgreen * balpha) + (fgreen * alpha)) >> 8); |
163 |
|
3485896 |
fblue = (GX_UBYTE)(((bblue * balpha) + (fblue * alpha)) >> 8); |
164 |
|
|
|
165 |
|
|
/* re-assemble into 16-bit color and write it out */ |
166 |
|
3485896 |
*write++ = (USHORT)ASSEMBLECOLOR(fred, fgreen, fblue); |
167 |
|
|
} |
168 |
|
47752 |
write_start += composite -> gx_canvas_y_resolution; |
169 |
|
47752 |
read_start += canvas -> gx_canvas_y_resolution; |
170 |
|
|
} |
171 |
|
|
} |
172 |
|
510 |
} |
173 |
|
|
|