aboutsummaryrefslogtreecommitdiff
path: root/engines/testbed
diff options
context:
space:
mode:
authorNeeraj Kumar2010-07-11 16:50:18 +0000
committerNeeraj Kumar2010-07-11 16:50:18 +0000
commit570560e9b5f1b07b20111d58593bbf2f6251bf61 (patch)
tree2e18e4386f3fbfc35dea9ff17ec32ea68efe931d /engines/testbed
parentf9c03dc8db9a745d10e628f778cb4cad0d6f6a55 (diff)
downloadscummvm-rg350-570560e9b5f1b07b20111d58593bbf2f6251bf61.tar.gz
scummvm-rg350-570560e9b5f1b07b20111d58593bbf2f6251bf61.tar.bz2
scummvm-rg350-570560e9b5f1b07b20111d58593bbf2f6251bf61.zip
improved the scaling test to have a rectangle of estimated size of scaled cursor the scaled cursor should entirely cover that estimated rectangle
svn-id: r50802
Diffstat (limited to 'engines/testbed')
-rw-r--r--engines/testbed/graphics.cpp62
-rw-r--r--engines/testbed/graphics.h3
2 files changed, 60 insertions, 5 deletions
diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp
index c70f6f5726..8380de496f 100644
--- a/engines/testbed/graphics.cpp
+++ b/engines/testbed/graphics.cpp
@@ -102,6 +102,28 @@ void GFXtests::initMousePalette() {
}
+Common::Rect GFXtests::computeSize(Common::Rect &cursorRect, int scalingFactor, int cursorTargetScale) {
+ if (cursorTargetScale == 1 || scalingFactor == 1) {
+ // Game data and cursor would be scaled equally.
+ // so dimensions would be same.
+ return Common::Rect(cursorRect.width(), cursorRect.height());
+ }
+
+ if (scalingFactor == 2) {
+ // Game data is scaled by 2, cursor is said to be scaled by 2 or 3. so it wud not be scaled any further
+ // So a w/2 x h/2 rectangle when scaled would match the cursor
+ return Common::Rect(cursorRect.width() / 2, cursorRect.height() / 2);
+ }
+
+ if (scalingFactor == 3) {
+ // Cursor traget scale is 2 or 3.
+ return Common::Rect((cursorRect.width() / cursorTargetScale), (cursorRect.height() / cursorTargetScale));
+ } else {
+ Testsuite::logPrintf("Unsupported scaler %dx\n", scalingFactor);
+ return Common::Rect();
+ }
+}
+
void GFXtests::HSVtoRGB(int& rComp, int& gComp, int& bComp, int hue, int sat, int val) {
float r = rComp;
@@ -165,11 +187,14 @@ void GFXtests::HSVtoRGB(int& rComp, int& gComp, int& bComp, int hue, int sat, in
bComp = b * 255;
}
-void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, int cursorTargetScale) {
+Common::Rect GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, int cursorTargetScale) {
// Buffer initialized with yellow color
byte buffer[500];
memset(buffer, 2, sizeof(buffer));
+
+ int cursorWidth = 12;
+ int cursorHeight = 12;
/* Disable HotSpot highlighting as of now
@@ -197,6 +222,7 @@ void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, i
}
g_system->updateScreen();
+ return Common::Rect(0, 0, cursorWidth, cursorHeight);
}
void rotatePalette(byte *palette, int size) {
@@ -222,10 +248,11 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName
bool isFeaturePresent;
isFeaturePresent = g_system->hasFeature(OSystem::kFeatureCursorHasPalette);
+ Common::Rect cursorRect;
if (isFeaturePresent) {
- GFXtests::drawCursor(disableCursorPalette, gfxModeName, cursorTargetScale);
+ cursorRect = GFXtests::drawCursor(disableCursorPalette, gfxModeName, cursorTargetScale);
Common::EventManager *eventMan = g_system->getEventManager();
Common::Event event;
@@ -248,9 +275,35 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName
char cScale = cursorTargetScale + '0';
info += "Cursor scale: ";
info += cScale;
+
+ Common::String gfxScalarMode(gfxModeName);
+ Common::Rect estimatedCursorRect;
- if (!Common::String(gfxModeName).equals("")) {
+ if (!gfxScalarMode.equals("")) {
+
+ if (gfxScalarMode.contains("1x")) {
+ estimatedCursorRect = computeSize(cursorRect, 1, cursorTargetScale);
+ } else if (gfxScalarMode.contains("2x")) {
+ estimatedCursorRect = computeSize(cursorRect, 2, cursorTargetScale);
+ } else if (gfxScalarMode.contains("3x")){
+ estimatedCursorRect = computeSize(cursorRect, 3, cursorTargetScale);
+ } else {
+ // If unable to detect scaler, default to 2
+ Testsuite::writeOnScreen("Unable to detect scaling factor, assuming 2x", Common::Point(0, 5));
+ estimatedCursorRect = computeSize(cursorRect, 2, cursorTargetScale);
+ }
Testsuite::writeOnScreen(info, Common::Point(0, 120));
+
+ // Move cursor to (20, 20)
+ g_system->warpMouse(20, 20);
+ // Move estimated rect to (20, 20)
+ estimatedCursorRect.moveTo(20, 20);
+
+ Graphics::Surface *screen = g_system->lockScreen();
+ GFXTestSuite::setCustomColor(255, 0, 0);
+ screen->fillRect(estimatedCursorRect, 2);
+ g_system->unlockScreen();
+ g_system->updateScreen();
}
while (!quitLoop) {
@@ -620,7 +673,8 @@ bool GFXtests::iconifyWindow() {
bool GFXtests::scaledCursors() {
Testsuite::displayMessage("Testing : Scaled cursors\n"
- "Here every graphics mode is tried with a cursorTargetScale of 1,2 and 3"
+ "Here every graphics mode is tried with a cursorTargetScale of 1,2 and 3.\n"
+ "The expected cursor size is drawn as a rectangle, the cursor should entirely cover that rectangle.\n"
"This may take time, You may skip the later scalers and just examine the first three i.e 1x,2x and 3x");
int maxLimit = 1000;
diff --git a/engines/testbed/graphics.h b/engines/testbed/graphics.h
index 5a11e0ef0d..7f004f36ac 100644
--- a/engines/testbed/graphics.h
+++ b/engines/testbed/graphics.h
@@ -36,8 +36,9 @@ void drawEllipse(int x, int y, int a, int b);
void setupMouseLoop(bool disableCursorPalette = false, const char *gfxModeName = "", int cursorTargetScale = 1);
void initMousePalette();
void mouseMovements();
+Common::Rect computeSize(Common::Rect &cursorRect, int scalingFactor, int cursorTargetScale);
void HSVtoRGB(int& rComp, int& gComp,int& bComp, int hue, int sat, int val);
-void drawCursor(bool cursorPaletteDisabled = false, const char *gfxModeName = "", int cursorTargetScale = 1);
+Common::Rect drawCursor(bool cursorPaletteDisabled = false, const char *gfxModeName = "", int cursorTargetScale = 1);
// will contain function declarations for GFX tests
bool fullScreenMode();