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 _COLOR_FORMAT_ 565rgb |
23 |
|
|
#define PIXEL_LOC USHORT |
24 |
|
|
|
25 |
|
|
#define REDVAL(_c) (GX_UBYTE)(((_c) >> 11) & 0x1f) |
26 |
|
|
#define GREENVAL(_c) (GX_UBYTE)(((_c) >> 5) & 0x3f) |
27 |
|
|
#define BLUEVAL(_c) (GX_UBYTE)(((_c)) & 0x1f) |
28 |
|
|
|
29 |
|
|
#define ASSEMBLECOLOR(_r, _g, _b) \ |
30 |
|
|
((((_r) & 0x1f) << 11) | \ |
31 |
|
|
(((_g) & 0x3f) << 5) | \ |
32 |
|
|
(((_b) & 0x1f))) |
33 |
|
|
|
34 |
|
|
#define GX_SOURCE_CODE |
35 |
|
|
|
36 |
|
|
|
37 |
|
|
/* Include necessary system files. */ |
38 |
|
|
|
39 |
|
|
#include "gx_api.h" |
40 |
|
|
#include "gx_display.h" |
41 |
|
|
|
42 |
|
|
/**************************************************************************/ |
43 |
|
|
/* */ |
44 |
|
|
/* FUNCTION RELEASE */ |
45 |
|
|
/* */ |
46 |
|
|
/* _gx_display_driver_565rgb_rotated_pixel_blend PORTABLE C */ |
47 |
|
|
/* 6.1.3 */ |
48 |
|
|
/* AUTHOR */ |
49 |
|
|
/* */ |
50 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
51 |
|
|
/* */ |
52 |
|
|
/* DESCRIPTION */ |
53 |
|
|
/* */ |
54 |
|
|
/* Rotated pixel blend function for 565rgb color format. */ |
55 |
|
|
/* */ |
56 |
|
|
/* INPUT */ |
57 |
|
|
/* */ |
58 |
|
|
/* context Drawing context */ |
59 |
|
|
/* x X coordinate */ |
60 |
|
|
/* y Y coordinate */ |
61 |
|
|
/* color Color of line to write */ |
62 |
|
|
/* alpha Alpha value */ |
63 |
|
|
/* */ |
64 |
|
|
/* OUTPUT */ |
65 |
|
|
/* */ |
66 |
|
|
/* None */ |
67 |
|
|
/* */ |
68 |
|
|
/* CALLS */ |
69 |
|
|
/* */ |
70 |
|
|
/* REDVAL Extract the red component */ |
71 |
|
|
/* GREENVAL Extract the green component */ |
72 |
|
|
/* BLUEVAL Extract the blue component */ |
73 |
|
|
/* ASSEMBLECOLOR Assemble color components */ |
74 |
|
|
/* */ |
75 |
|
|
/* CALLED BY */ |
76 |
|
|
/* */ |
77 |
|
|
/* GUIX Internal Code */ |
78 |
|
|
/* */ |
79 |
|
|
/**************************************************************************/ |
80 |
|
969077 |
VOID _gx_display_driver_565rgb_rotated_pixel_blend(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha) |
81 |
|
|
{ |
82 |
|
|
GX_UBYTE fred, fgreen, fblue; |
83 |
|
|
GX_UBYTE bred, bgreen, bblue; |
84 |
|
|
GX_UBYTE balpha; |
85 |
|
|
|
86 |
|
|
USHORT bcolor; |
87 |
|
|
USHORT *put; |
88 |
|
|
|
89 |
|
|
|
90 |
|
|
/* Is the pixel non-transparent? */ |
91 |
✓✓ |
969077 |
if (alpha > 0) |
92 |
|
|
{ |
93 |
|
964211 |
put = (USHORT *)context -> gx_draw_context_memory; |
94 |
|
|
|
95 |
|
|
/* calculate address of pixel */ |
96 |
✓✓ |
964211 |
if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW) |
97 |
|
|
{ |
98 |
|
678469 |
put += context -> gx_draw_context_pitch * (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - x - 1); |
99 |
|
678469 |
put += y; |
100 |
|
|
} |
101 |
|
|
else |
102 |
|
|
{ |
103 |
|
285742 |
put += context -> gx_draw_context_pitch * x; |
104 |
|
285742 |
put += (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - y - 1); |
105 |
|
|
} |
106 |
|
|
|
107 |
|
|
/* No need to blend if alpha value is 255. */ |
108 |
✓✓ |
964211 |
if (alpha == 255) |
109 |
|
|
{ |
110 |
|
5298 |
*put = (USHORT)fcolor; |
111 |
|
5298 |
return; |
112 |
|
|
} |
113 |
|
|
|
114 |
|
|
/* split foreground into red, green, and blue components */ |
115 |
|
958913 |
fred = REDVAL(fcolor); |
116 |
|
958913 |
fgreen = GREENVAL(fcolor); |
117 |
|
958913 |
fblue = BLUEVAL(fcolor); |
118 |
|
|
|
119 |
|
|
/* read background color */ |
120 |
|
958913 |
bcolor = *put; |
121 |
|
|
|
122 |
|
|
/* split background color into red, green, and blue components */ |
123 |
|
958913 |
bred = REDVAL(bcolor); |
124 |
|
958913 |
bgreen = GREENVAL(bcolor); |
125 |
|
958913 |
bblue = BLUEVAL(bcolor); |
126 |
|
|
|
127 |
|
|
/* background alpha is inverse of foreground alpha */ |
128 |
|
958913 |
balpha = (GX_UBYTE)(256 - alpha); |
129 |
|
|
|
130 |
|
|
/* blend foreground and background, each color channel */ |
131 |
|
958913 |
fred = (GX_UBYTE)(((bred * balpha) + (fred * alpha)) >> 8); |
132 |
|
958913 |
fgreen = (GX_UBYTE)(((bgreen * balpha) + (fgreen * alpha)) >> 8); |
133 |
|
958913 |
fblue = (GX_UBYTE)(((bblue * balpha) + (fblue * alpha)) >> 8); |
134 |
|
|
|
135 |
|
|
/* re-assemble into 16-bit color and write it out */ |
136 |
|
958913 |
*put = (USHORT)ASSEMBLECOLOR(fred, fgreen, fblue); |
137 |
|
|
} |
138 |
|
|
} |
139 |
|
|
|