From a9941138dadd796ca2a8fbd6e2c9c66436a48c4b Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sun, 25 Jul 2010 20:50:59 +0000 Subject: TETBED: fixed the boundary error in palette rotation, added colored progress bar now svn-id: r51284 --- engines/testbed/graphics.cpp | 38 +++++++++++++++++++++----------------- engines/testbed/testsuite.cpp | 13 ++++++++----- engines/testbed/testsuite.h | 9 ++++++++- 3 files changed, 37 insertions(+), 23 deletions(-) (limited to 'engines') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 4ac683568f..38f5daf35d 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -82,6 +82,12 @@ void GFXTestSuite::setCustomColor(uint r, uint g, uint b) { _palette[8] = r; _palette[9] = g; _palette[10] = b; + + // Set colorNum kColorSpecial with a special color. + int absIndx = kColorSpecial * 4; + _palette[absIndx + 1] = 173; + _palette[absIndx + 2] = 255; + _palette[absIndx + 3] = 47; g_system->setPalette(_palette, 0, 256); } @@ -125,7 +131,7 @@ void GFXtests::HSVtoRGB(int &rComp, int &gComp, int &bComp, int hue, int sat, in float g = gComp; float b = bComp; - float h = hue * (360 / 254.0); // two colors are left for bg and fg + float h = hue * (360 / 256.0); // All colors are tried float s = sat; float v = val; @@ -901,26 +907,25 @@ bool GFXtests::overlayGraphics() { bool GFXtests::paletteRotation() { - Testsuite::clearScreen(); Common::String info = "Palette rotation. Here we draw a full 256 colored rainbow and then rotate it.\n" - "Note that the screen graphics change without having to draw anything."; + "Note that the screen graphics change without having to draw anything.\n" + "The palette should appear to rotate, Click the mouse button to exit."; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : palette Rotation\n"); return true; } Common::Point pt(0, 10); - Testsuite::writeOnScreen("Rotating palettes, palettes rotate towards left, click to stop!", pt); + Testsuite::clearEntireScreen(); // Use 256 colors - byte palette[256 * 4] = {0, 0, 0, 0, - 255, 255, 255, 0}; + byte palette[256 * 4] = {0}; int r, g, b; int colIndx; - for (int i = 2; i < 256; i++) { - HSVtoRGB(r, g, b, i - 2, 1, 1); + for (int i = 0; i < 256; i++) { + HSVtoRGB(r, g, b, i, 1, 1); colIndx = i * 4; palette[colIndx] = r; palette[colIndx + 1] = g; @@ -930,29 +935,28 @@ bool GFXtests::paletteRotation() { // Initialize this palette. g_system->setPalette(palette, 0, 256); - // Draw 254 Rectangles, each 1 pixel wide and 10 pixels long + // Draw 256 Rectangles, each 1 pixel wide and 10 pixels long // one for 0-255 color range other for 0-127-255 range - byte buffer[254 * 30] = {0}; + byte buffer[256 * 30] = {0}; for (int i = 0; i < 30; i++) { - for (int j = 0; j < 254; j++) { + for (int j = 0; j < 256; j++) { if (i < 10) { - buffer[i * 254 + j] = j + 2; + buffer[i * 256 + j] = j + 2; } else if (i < 20) { - buffer[i * 254 + j] = 0; + buffer[i * 256 + j] = 0; } else { - buffer[i * 254 + j] = ((j + 127) % 254) + 2; + buffer[i * 256 + j] = ((j + 127) % 256) + 2; } } } - g_system->copyRectToScreen(buffer, 254, 22, 50, 254, 30); + g_system->copyRectToScreen(buffer, 256, 22, 50, 256, 30); // Show mouse CursorMan.showMouse(true); g_system->updateScreen(); - g_system->delayMillis(1000); bool toRotate = true; Common::Event event; @@ -964,7 +968,7 @@ bool GFXtests::paletteRotation() { } } - rotatePalette(&palette[8], 254); + rotatePalette(palette, 256); g_system->delayMillis(10); g_system->setPalette(palette, 0, 256); diff --git a/engines/testbed/testsuite.cpp b/engines/testbed/testsuite.cpp index ea7d9c717a..22f931bed5 100644 --- a/engines/testbed/testsuite.cpp +++ b/engines/testbed/testsuite.cpp @@ -121,6 +121,8 @@ Testsuite::Testsuite() { _numTestsExecuted = 0; // Initially all testsuites are enabled, disable them by calling enableTestSuite(name, false) _isTsEnabled = true; + // Set custom color for progress bar + GFXTestSuite::setCustomColor(0, 0, 0); } Testsuite::~Testsuite() { @@ -247,6 +249,7 @@ uint Testsuite::parseEvents() { void Testsuite::updateStats(const char *prefix, const char *info, uint testNum, uint numTests, Common::Point pt) { Common::String text = Common::String::printf(" Running %s: %s (%d of %d) ", prefix, info, testNum, numTests); writeOnScreen(text, pt); + uint barColor = kColorSpecial; // below the text a rectangle denoting the progress in the testsuite can be drawn. int separation = getLineSeparation(); pt.y += separation; @@ -259,17 +262,17 @@ void Testsuite::updateStats(const char *prefix, const char *info, uint testNum, int wShaded = (int) (wRect * (((float)testNum) / numTests)); // draw the boundary - memset(buffer, 1, sizeof(byte) * wRect); - memset(buffer + (wRect * (lRect - 1)) , 1, sizeof(byte) * wRect); + memset(buffer, barColor, sizeof(byte) * wRect); + memset(buffer + (wRect * (lRect - 1)) , barColor, sizeof(byte) * wRect); for (int i = 0; i < lRect; i++) { for (int j = 0; j < wRect; j++) { if (j < wShaded) { - buffer[i * wRect + j] = 1; + buffer[i * wRect + j] = barColor; } } - buffer[i * wRect + 0] = 1; - buffer[i * wRect + wRect - 1] = 1; + buffer[i * wRect + 0] = barColor; + buffer[i * wRect + wRect - 1] = barColor; } g_system->copyRectToScreen(buffer, wRect, pt.x, pt.y, wRect, lRect); g_system->updateScreen(); diff --git a/engines/testbed/testsuite.h b/engines/testbed/testsuite.h index b4c30a7cdd..e19cfe1896 100644 --- a/engines/testbed/testsuite.h +++ b/engines/testbed/testsuite.h @@ -36,7 +36,8 @@ namespace Testbed { enum { kColorBlack = 0, kColorWhite = 1, - kColorCustom = 2 + kColorCustom = 2, + kColorSpecial = 5 ///< some random number }; enum OptionSelected { @@ -104,6 +105,12 @@ public: static void displayMessage(const Common::String &textToDisplay, const char *defaultButton = "OK", const char *altButton = 0); static Common::Rect writeOnScreen(const Common::String &textToDisplay, const Common::Point &pt, bool flag = false); static void clearScreen(const Common::Rect &rect); + static void clearEntireScreen() { + const int width = g_system->getWidth(); + const int height = g_system->getHeight(); + Common::Rect r(0, 0, width, height); + clearScreen(r); + } static void clearScreen(); static void clearScreen(bool flag); -- cgit v1.2.3