1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
#include <Library/DebugLib.h>
#include <Library/HiiLib.h>
#include <Library/MemoryAllocationLib.h>
#include "Gradients.h"
enum UMT_GRADIENTS_PARAM {
UMT_GRADIENTS_PARAM_COLOR = 0,
UMT_GRADIENTS_PARAM_STEP
};
enum UMT_GRADIENTS_STEPS {
UMT_GRADIENTS_STEP_8 = 0,
UMT_GRADIENTS_STEP_16,
UMT_GRADIENTS_STEP_32,
UMT_GRADIENTS_STEP_64,
UMT_GRADIENTS_STEP_128,
UMT_GRADIENTS_STEP_256,
UMT_GRADIENTS_STEP_END
};
STATIC enum UMT_COLORS CurrentColor = 1;
STATIC enum UMT_GRADIENTS_STEPS CurrentStep = UMT_GRADIENTS_STEP_8;
STATIC enum UMT_GRADIENTS_PARAM CurrentParam = UMT_GRADIENTS_PARAM_COLOR;
CONST UINT32 mGradientsSteps[UMT_GRADIENTS_STEP_END] = {
8, 16, 32, 64, 128, 256
};
VOID
GradientsTestInit (
IN UMT_CONTEXT *Ctx
)
{
UINT32 Index;
GRAPHICS_PIXEL_COLOR ColorOutput = { 0x00 };
GRAPHICS_PIXEL_COLOR ColorInc = { 0x00 };
GRAPHICS_CONTEXT *Graphics = Ctx->Graphics;
ColorInc.Red = ((gUmtColors[CurrentColor].Color.Red) / (mGradientsSteps[CurrentStep]-1));
ColorInc.Green = ((gUmtColors[CurrentColor].Color.Green) / (mGradientsSteps[CurrentStep]-1));
ColorInc.Blue = ((gUmtColors[CurrentColor].Color.Blue) / (mGradientsSteps[CurrentStep]-1));
for (Index = 0; Index < mGradientsSteps[CurrentStep]; Index++)
{
PutRect (Graphics, (Graphics->Width * Index) / mGradientsSteps[CurrentStep],
0,
(Graphics->Width * (Index + 1)) / mGradientsSteps[CurrentStep],
Graphics->Height,
&ColorOutput);
ColorOutput.Red += ColorInc.Red;
ColorOutput.Green += ColorInc.Green;
ColorOutput.Blue += ColorInc.Blue;
}
if (Ctx->ShowTip) {
GradientsTestTip (Ctx);
}
}
VOID
GradientsTestDoit (
IN UMT_CONTEXT *Ctx
)
{
}
VOID
GradientsTestTip (
IN UMT_CONTEXT *Ctx
)
{
GRAPHICS_CONTEXT *Graphics;
CHAR16 *ColorMsg;
Graphics = Ctx->Graphics;
if (Ctx->ShowTip == FALSE) {
// Restore
GradientsTestInit (Ctx);
return;
}
ColorMsg = HiiGetString (gUmtHiiHandle, gUmtColors[CurrentColor].StringId, NULL);
DrawRectWithBorder (Graphics,
15,
Graphics->Height - 15 - 174,
510, Graphics->Height - 15,
3,
&gUmtColors[UMT_COLOR_WHITE].Color,
&gUmtColors[UMT_COLOR_NAVY].Color);
DrawHiiStringF (Graphics,
25,
Graphics->Height - 15 - 164,
&gUmtColors[UMT_COLOR_NAVY].Color,
STRING_TOKEN (STR_GRADIENTS_TITLE), gUmtHiiHandle);
DrawHiiStringF (Graphics,
25,
Graphics->Height - 15 - 144,
&gUmtColors[UMT_COLOR_BLACK].Color,
STRING_TOKEN (STR_GRADIENTS_MSG), gUmtHiiHandle,
(CurrentParam == UMT_GRADIENTS_PARAM_COLOR) ? L'*' : L' ',
ColorMsg,
(CurrentParam == UMT_GRADIENTS_PARAM_STEP) ? L'*' : L' ',
mGradientsSteps[CurrentStep]);
FreePool (ColorMsg);
}
VOID
GradientsTestChangeValue (
IN UMT_CONTEXT *Ctx,
IN INT8 ValueStep
)
{
switch (CurrentParam) {
case UMT_GRADIENTS_PARAM_COLOR:
if (CurrentColor == UMT_COLOR_WHITE && ValueStep < 0) {
CurrentColor = UMT_COLOR_MAGENTA;
} else {
CurrentColor += ValueStep;
if (CurrentColor > UMT_COLOR_MAGENTA) {
CurrentColor = UMT_COLOR_WHITE;
}
}
break;
case UMT_GRADIENTS_PARAM_STEP:
if (CurrentStep == 0 && ValueStep < 0) {
return;
} else {
CurrentStep += ValueStep;
if (CurrentStep > UMT_GRADIENTS_STEP_256)
{
CurrentStep = UMT_GRADIENTS_STEP_256;
return;
}
}
break;
default:
ASSERT(FALSE);
return;
}
GradientsTestInit (Ctx);
}
VOID
GradientsTestChangeParam (
IN UMT_CONTEXT *Ctx,
IN INT8 ParamStep
)
{
if (CurrentParam == 0 && ParamStep < 0) {
CurrentParam = UMT_GRADIENTS_PARAM_STEP;
} else {
CurrentParam += ParamStep;
if (CurrentParam > UMT_GRADIENTS_PARAM_STEP)
{
CurrentParam = UMT_GRADIENTS_PARAM_COLOR;
}
}
GradientsTestInit (Ctx);
}
|