diff options
author | Neeraj Kumar | 2010-06-24 15:27:28 +0000 |
---|---|---|
committer | Neeraj Kumar | 2010-06-24 15:27:28 +0000 |
commit | b243a93932ae6111d676799ce891ae63a97b0c94 (patch) | |
tree | df18eec884d32d129e986e7f73da0c61a54a69bf /engines/testbed/graphics.cpp | |
parent | f444d451169cdcf7e3dd2deef146e5a26e73bd49 (diff) | |
download | scummvm-rg350-b243a93932ae6111d676799ce891ae63a97b0c94.tar.gz scummvm-rg350-b243a93932ae6111d676799ce891ae63a97b0c94.tar.bz2 scummvm-rg350-b243a93932ae6111d676799ce891ae63a97b0c94.zip |
added palette rotation test
svn-id: r50220
Diffstat (limited to 'engines/testbed/graphics.cpp')
-rw-r--r-- | engines/testbed/graphics.cpp | 79 |
1 files changed, 70 insertions, 9 deletions
diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index e481b48458..e44d71782f 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -1,4 +1,5 @@ #include "common/events.h" +#include "common/random.h" #include "testbed/graphics.h" #include "testbed/testsuite.h" @@ -34,14 +35,19 @@ GFXTestSuite::GFXTestSuite() { // Mouse Layer tests (Palettes and movements) // addTest("PalettizedCursors", &GFXtests::palettizedCursors); // FIXME: need to fix it - addTest("ScaledCursors", &GFXtests::scaledCursors); + // addTest("ScaledCursors", &GFXtests::scaledCursors); // Effects // addTest("shakingEffect", &GFXtests::shakingEffect); // addTest("focusRectangle", &GFXtests::focusRectangle); - // TODO: unable to notice any change, make it noticable + // Overlay // addTest("Overlays", &GFXtests::overlayGraphics); + + // Specific Tests: + addTest("Palette Rotation", &GFXtests::paletteRotation); + addTest("Pixel Formats", &GFXtests::pixelFormats); + } const char *GFXTestSuite::getName() const { @@ -103,6 +109,22 @@ void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, i g_system->updateScreen(); } +void rotatePalette(byte palette[], int size) { + // Ignore rotating black color, as that is background + // take a temporary palette color + byte tColor[4] = {0}; + // save the first color in tColor + memcpy(tColor, &palette[4], 4 * sizeof(byte)); + + // Move each color upward by 1 + for (int i = 1; i < size - 1; i++) { + memcpy(&palette[i * 4], &palette[(i + 1) * 4], 4 * sizeof(byte)); + } + // Assign last color to tcolor + memcpy(&palette[(size -1) * 4], tColor, 4 * sizeof(byte)); + g_system->setPalette(palette, 0, 10); +} + /** * Sets up mouse loop, exits when user clicks any of the mouse button */ @@ -617,12 +639,6 @@ bool GFXtests::focusRectangle() { bool GFXtests::overlayGraphics() { - // TODO: ifind out if this is required? - g_system->beginGFXTransaction(); - g_system->initSize(640, 400); - g_system->endGFXTransaction(); - - Graphics::PixelFormat pf = g_system->getOverlayFormat(); OverlayColor buffer[20 * 40]; @@ -633,8 +649,8 @@ bool GFXtests::overlayGraphics() { } // FIXME: Not Working. - g_system->copyRectToOverlay(buffer, 40, 100, 100, 40, 20); g_system->showOverlay(); + g_system->copyRectToOverlay(buffer, 40, 100, 100, 40, 20); g_system->updateScreen(); g_system->delayMillis(1000); @@ -649,4 +665,49 @@ bool GFXtests::overlayGraphics() { return true; } +bool GFXtests::paletteRotation() { + byte palette[10 * 4] = {0, 0, 0, 0, + 255, 255, 255, 0, + 135, 48, 21, 0, + 205, 190, 87, 0, + 0, 32, 64, 0, + 181, 126, 145, 0, + 47, 78, 36, 0, + 185, 115, 20, 0, + 160, 164, 137, 0, + 43, 52, 0, 0}; // 10 colors : B, W and 8 random + + Common::RandomSource rs; + + // Initialize this palette randomly + g_system->setPalette(palette, 0, 10); + + // Draw 10 Rectangles, each of width 100 pixels and height 10 pixels + byte buffer[10 * 100 * 10] = {0}; + + for (int i = 0; i < 10; i++) { + memset(buffer + i * 1000, i, 1000 * sizeof(byte)); + } + + g_system->copyRectToScreen(buffer, 100, 110, 50, 100, 100); + + int toRotate = 10; + + while (toRotate--) { + g_system->updateScreen(); + g_system->delayMillis(1000); + rotatePalette(palette, 10); + } + + if(Testsuite::handleInteractiveInput("Did you want to rotate the palettes?", "Yes", "No", kOptionRight)) { + return false; + } + + return true; +} + +bool GFXtests::pixelFormats() { + +} + } |