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 REDVAL(_c) (GX_UBYTE)((_c) >> 16) |
23 |
|
|
#define GREENVAL(_c) (GX_UBYTE)((_c) >> 8) |
24 |
|
|
#define BLUEVAL(_c) (GX_UBYTE)(_c) |
25 |
|
|
|
26 |
|
|
|
27 |
|
|
/* Define macros for assembling a 24-bit r:g:b value from 3 components. */ |
28 |
|
|
|
29 |
|
|
#define ASSEMBLECOLOR(_r, _g, _b) \ |
30 |
|
|
(((_r) << 16) | \ |
31 |
|
|
((_g) << 8) | \ |
32 |
|
|
(_b)) |
33 |
|
|
|
34 |
|
|
#define GX_SOURCE_CODE |
35 |
|
|
|
36 |
|
|
/* Include necessary system files. */ |
37 |
|
|
|
38 |
|
|
#include "gx_api.h" |
39 |
|
|
#include "gx_display.h" |
40 |
|
|
#include "gx_utility.h" |
41 |
|
|
|
42 |
|
|
|
43 |
|
|
/**************************************************************************/ |
44 |
|
|
/* */ |
45 |
|
|
/* FUNCTION RELEASE */ |
46 |
|
|
/* */ |
47 |
|
|
/* _gx_display_driver_24xrgb_canvas_blend PORTABLE C */ |
48 |
|
|
/* 6.1 */ |
49 |
|
|
/* AUTHOR */ |
50 |
|
|
/* */ |
51 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
52 |
|
|
/* */ |
53 |
|
|
/* DESCRIPTION */ |
54 |
|
|
/* */ |
55 |
|
|
/* Canvas blend function for 24xrgb 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 |
|
259 |
VOID _gx_display_driver_24xrgb_canvas_blend(GX_CANVAS *canvas, GX_CANVAS *composite) |
82 |
|
|
{ |
83 |
|
|
GX_RECTANGLE dirty; |
84 |
|
|
GX_RECTANGLE overlap; |
85 |
|
|
ULONG *read; |
86 |
|
|
ULONG *read_start; |
87 |
|
|
ULONG *write; |
88 |
|
|
ULONG *write_start; |
89 |
|
|
ULONG fcolor; |
90 |
|
|
GX_UBYTE fred, fgreen, fblue; |
91 |
|
|
GX_UBYTE bred, bgreen, bblue; |
92 |
|
|
GX_UBYTE alpha, balpha; |
93 |
|
|
|
94 |
|
|
ULONG bcolor; |
95 |
|
|
INT row; |
96 |
|
|
INT col; |
97 |
|
|
|
98 |
|
259 |
dirty.gx_rectangle_left = dirty.gx_rectangle_top = 0; |
99 |
|
259 |
dirty.gx_rectangle_right = (GX_VALUE)(canvas -> gx_canvas_x_resolution - 1); |
100 |
|
259 |
dirty.gx_rectangle_bottom = (GX_VALUE)(canvas -> gx_canvas_y_resolution - 1); |
101 |
|
|
|
102 |
|
259 |
_gx_utility_rectangle_shift(&dirty, canvas -> gx_canvas_display_offset_x, canvas -> gx_canvas_display_offset_y); |
103 |
|
|
|
104 |
✓✓ |
259 |
if (_gx_utility_rectangle_overlap_detect(&dirty, &composite -> gx_canvas_dirty_area, &overlap)) |
105 |
|
|
{ |
106 |
|
258 |
alpha = canvas -> gx_canvas_alpha; |
107 |
|
258 |
balpha = (GX_UBYTE)(256 - alpha); |
108 |
|
|
|
109 |
|
258 |
read_start = (ULONG *)canvas -> gx_canvas_memory; |
110 |
|
|
|
111 |
|
|
/* index into starting row */ |
112 |
|
258 |
read_start += (overlap.gx_rectangle_top - dirty.gx_rectangle_top) * canvas -> gx_canvas_x_resolution; |
113 |
|
|
|
114 |
|
|
/* index into pixel */ |
115 |
|
|
|
116 |
|
258 |
read_start += overlap.gx_rectangle_left - dirty.gx_rectangle_left; |
117 |
|
|
|
118 |
|
|
/* calculate the write pointer */ |
119 |
|
258 |
write_start = (ULONG *)composite -> gx_canvas_memory; |
120 |
|
258 |
write_start += overlap.gx_rectangle_top * composite -> gx_canvas_x_resolution; |
121 |
|
258 |
write_start += overlap.gx_rectangle_left; |
122 |
|
|
|
123 |
✓✓ |
19062 |
for (row = overlap.gx_rectangle_top; row <= overlap.gx_rectangle_bottom; row++) |
124 |
|
|
{ |
125 |
|
18804 |
read = read_start; |
126 |
|
18804 |
write = write_start; |
127 |
|
|
|
128 |
✓✓ |
1786380 |
for (col = overlap.gx_rectangle_left; col <= overlap.gx_rectangle_right; col++) |
129 |
|
|
{ |
130 |
|
|
/* read the foreground color */ |
131 |
|
1767576 |
fcolor = *read++; |
132 |
|
|
|
133 |
|
|
/* split foreground into red, green, and blue components */ |
134 |
|
1767576 |
fred = REDVAL(fcolor); |
135 |
|
1767576 |
fgreen = GREENVAL(fcolor); |
136 |
|
1767576 |
fblue = BLUEVAL(fcolor); |
137 |
|
|
|
138 |
|
|
/* read background color */ |
139 |
|
1767576 |
bcolor = *write; |
140 |
|
|
|
141 |
|
|
/* split background color into red, green, and blue components */ |
142 |
|
1767576 |
bred = REDVAL(bcolor); |
143 |
|
1767576 |
bgreen = GREENVAL(bcolor); |
144 |
|
1767576 |
bblue = BLUEVAL(bcolor); |
145 |
|
|
|
146 |
|
|
/* blend foreground and background, each color channel */ |
147 |
|
1767576 |
fred = (GX_UBYTE)(((bred * balpha) + (fred * alpha)) >> 8); |
148 |
|
1767576 |
fgreen = (GX_UBYTE)(((bgreen * balpha) + (fgreen * alpha)) >> 8); |
149 |
|
1767576 |
fblue = (GX_UBYTE)(((bblue * balpha) + (fblue * alpha)) >> 8); |
150 |
|
|
|
151 |
|
|
/* re-assemble into 16-bit color and write it out */ |
152 |
|
1767576 |
*write++ = ASSEMBLECOLOR((ULONG)fred, (ULONG)fgreen, (ULONG)fblue); |
153 |
|
|
} |
154 |
|
18804 |
write_start += composite -> gx_canvas_x_resolution; |
155 |
|
18804 |
read_start += canvas -> gx_canvas_x_resolution; |
156 |
|
|
} |
157 |
|
|
} |
158 |
|
259 |
} |
159 |
|
|
|