aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita <102851041+HyperNiki@users.noreply.github.com>2022-05-12 10:57:29 +0300
committerGitHub <noreply@github.com>2022-05-12 10:57:29 +0300
commit072a1226b09d5372a34b962b126f687f38755477 (patch)
tree5996b2793feb6a6bcc6151a35e6fa68daf01cbb1
parent0a723eefe5a06c7f9b71a5084005f5778c046d87 (diff)
downloadumt-072a1226b09d5372a34b962b126f687f38755477.tar.gz
umt-072a1226b09d5372a34b962b126f687f38755477.tar.bz2
umt-072a1226b09d5372a34b962b126f687f38755477.zip
add gradients test
-rw-r--r--UefiMonitorTest/UefiMonitorTest.c4
-rw-r--r--UefiMonitorTest/UefiMonitorTest.h1
-rw-r--r--UefiMonitorTest/UefiMonitorTest.inf1
-rw-r--r--UefiMonitorTest/UefiMonitorTestStrings.uni14
-rw-r--r--UefiMonitorTest/tests/Gradients.c171
-rw-r--r--UefiMonitorTest/tests/Gradients.h33
6 files changed, 223 insertions, 1 deletions
diff --git a/UefiMonitorTest/UefiMonitorTest.c b/UefiMonitorTest/UefiMonitorTest.c
index 2183cb7..cd776c0 100644
--- a/UefiMonitorTest/UefiMonitorTest.c
+++ b/UefiMonitorTest/UefiMonitorTest.c
@@ -12,11 +12,13 @@
#include "MainMenu.h"
#include "SettingsMenu.h"
#include "tests/SolidColors.h"
+#include "tests/Gradients.h"
STATIC CONST UMT_STATE_ACTIONS mStateActions[UMT_STATE_END] = {
{ MainMenuInit, MainMenuDoit, MainMenuTip, MainMenuChangeParam, MainMenuChangeValue },
{ SettingsMenuInit, SettingsMenuDoit, SettingsMenuTip, SettingsChangeParam, SettingsMenuChangeValue },
- { SolidColorsTestInit, SolidColorsTestDoit, SolidColorsTestTip, SolidColorsTestChangeParam, SolidColorsTestChangeValue }
+ { SolidColorsTestInit, SolidColorsTestDoit, SolidColorsTestTip, SolidColorsTestChangeParam, SolidColorsTestChangeValue },
+ { GradientsTestInit, GradientsTestDoit, GradientsTestTip, GradientsTestChangeParam, GradientsTestChangeValue }
};
EFI_HII_HANDLE gUmtHiiHandle = NULL;
diff --git a/UefiMonitorTest/UefiMonitorTest.h b/UefiMonitorTest/UefiMonitorTest.h
index d02ead8..efb1e57 100644
--- a/UefiMonitorTest/UefiMonitorTest.h
+++ b/UefiMonitorTest/UefiMonitorTest.h
@@ -20,6 +20,7 @@ enum UMT_STATE {
UMT_STATE_MAIN_MENU = 0,
UMT_STATE_SETTINGS,
UMT_STATE_SOLID_COLORS_TEST,
+ UMT_STATE_GRADIENTS_TEST,
UMT_STATE_END
};
diff --git a/UefiMonitorTest/UefiMonitorTest.inf b/UefiMonitorTest/UefiMonitorTest.inf
index 142ebdb..9f23922 100644
--- a/UefiMonitorTest/UefiMonitorTest.inf
+++ b/UefiMonitorTest/UefiMonitorTest.inf
@@ -13,6 +13,7 @@
MainMenu.c
SettingsMenu.c
tests/SolidColors.c
+ tests/Gradients.c
UefiMonitorTestStrings.uni
[Packages]
diff --git a/UefiMonitorTest/UefiMonitorTestStrings.uni b/UefiMonitorTest/UefiMonitorTestStrings.uni
index a0e1ef1..52ce002 100644
--- a/UefiMonitorTest/UefiMonitorTestStrings.uni
+++ b/UefiMonitorTest/UefiMonitorTestStrings.uni
@@ -73,3 +73,17 @@
#string STR_SOLID_COLORS_BLUE_MSG #language en-US "Check if there are any defective pixels on the monitor.\n"
"All of the pixels should be blue. If you see a black\n"
"pixel, this indicates a missing blue subpixel.\n"
+
+// Test "Gradients"
+
+#string STR_GRADIENTS_TITLE #language en-US "GRADIENTS"
+
+#string STR_GRADIENTS_MSG #language en-US "The grayscale image should be reproduced in the overall\n"
+ "view without any unnecessary color and with an even\n"
+ "gradient, and, at 256 intervals, there should not be any\n"
+ "noticeable abrupt changes in brightness between individual\n"
+ "grayscales. At a smaller number of intervals, the respective\n"
+ "bars should be clearly differentiable from one another.\n
+ "\n"
+ "Color%c: %s\n"
+ "Steps%c: %d\n"
diff --git a/UefiMonitorTest/tests/Gradients.c b/UefiMonitorTest/tests/Gradients.c
new file mode 100644
index 0000000..03af391
--- /dev/null
+++ b/UefiMonitorTest/tests/Gradients.c
@@ -0,0 +1,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);
+}
diff --git a/UefiMonitorTest/tests/Gradients.h b/UefiMonitorTest/tests/Gradients.h
new file mode 100644
index 0000000..7c6141b
--- /dev/null
+++ b/UefiMonitorTest/tests/Gradients.h
@@ -0,0 +1,33 @@
+#ifndef UMT_GRADIENTS_TEST_H
+#define UMT_GRADIENTS_TEST_H
+
+#include "UefiMonitorTest.h"
+
+VOID
+GradientsTestInit (
+ IN UMT_CONTEXT *Ctx
+ );
+
+VOID
+GradientsTestDoit (
+ IN UMT_CONTEXT *Ctx
+ );
+
+VOID
+GradientsTestTip (
+ IN UMT_CONTEXT *Ctx
+ );
+
+VOID
+GradientsTestChangeParam (
+ IN UMT_CONTEXT *Ctx,
+ IN INT8 ParamStep
+ );
+
+VOID
+GradientsTestChangeValue (
+ IN UMT_CONTEXT *Ctx,
+ IN INT8 ValueStep
+ );
+
+#endif /* UMT_GRADIENTS_TEST_H */