[Scummvm-cvs-logs] SF.net SVN: scummvm:[49634] scummvm/branches/gsoc2010-testbed/engines/ testbed

sud03r at users.sourceforge.net sud03r at users.sourceforge.net
Sun Jun 13 21:19:07 CEST 2010


Revision: 49634
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49634&view=rev
Author:   sud03r
Date:     2010-06-13 19:19:06 +0000 (Sun, 13 Jun 2010)

Log Message:
-----------
added code for testing shake, focus, overlay, scaling, need to fix more some of these although

Modified Paths:
--------------
    scummvm/branches/gsoc2010-testbed/engines/testbed/graphics.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/graphics.h
    scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/graphics.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/graphics.cpp	2010-06-13 14:19:10 UTC (rev 49633)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/graphics.cpp	2010-06-13 19:19:06 UTC (rev 49634)
@@ -20,14 +20,23 @@
 	g_system->grabPalette(_palette, 0, 3);
 	
 	// Add tests here
+	// TODO: Can do it without transactions?
 	addTest("FullScreenMode", &GFXtests::fullScreenMode);
 	addTest("AspectRatio", &GFXtests::aspectRatio);
 	addTest("PalettizedCursors", &GFXtests::palettizedCursors);
 	addTest("BlitBitmaps", &GFXtests::copyRectToScreen);
+	// TODO: doesn't returns back to normal states
 	addTest("IconifyingWindow", &GFXtests::iconifyWindow);
+	// TODO: need to fix it
+	// addTest("ScaledCursors", &GFXtests::scaledCursors);
+	addTest("shakingEffect", &GFXtests::shakingEffect);
+	// TODO: unable to notice any change, make it noticable
+	addTest("focusRectangle", &GFXtests::focusRectangle);
+	// TODO: unable to notice any change, make it noticable
+	addTest("Overlays", &GFXtests::overlayGraphics);
 }
 
-const char *GFXTestSuite::getName() {
+const char *GFXTestSuite::getName() const {
 	return "GFX";
 }
 
@@ -56,8 +65,43 @@
 	genReport();
 }
 
-// GFXtests go here
+// Helper functions used by GFX tests
 
+void GFXtests::drawCursor(const char *gfxModeName, int cursorTargetScale) {
+		
+		byte palette[3 * 4]; // Black, white and yellow
+		palette[0] = palette[1] = palette[2] = 0;
+		palette[4] = palette[5] = palette[6] = 255;
+		palette[8] = palette[9] = 255;
+		palette[10] = 0;
+		
+		byte buffer[10][10];
+		memset(&buffer[0][0], 2, 10 * 10);
+
+		// Mark the hotspot
+		for (int i = 0; i < 10; i++) {
+			buffer[i][i] = 0;
+			buffer[9 - i][i] = 0;
+		}
+	
+		CursorMan.pushCursorPalette(palette, 0, 3);
+		CursorMan.pushCursor(&buffer[0][0], 10, 10, 5, 5, cursorTargetScale);
+		CursorMan.showMouse(true);
+		g_system->updateScreen();
+
+		if (gfxModeName) {
+			Common::Point pt(0, 100);
+			char scaleFactor[10];
+			snprintf(scaleFactor, 10, "%dx", cursorTargetScale);
+			Common::String info = "GFX Mode:";
+			info = info + gfxModeName  + " Cursor scaled by:" + scaleFactor;
+			Testsuite::clearScreen();
+			Testsuite::writeOnScreen(info, pt);
+		}
+
+}
+
+
 /**
  * Used by aspectRatio()
  */
@@ -106,6 +150,8 @@
 	g_system->updateScreen();
 }
 
+// GFXtests go here
+
 /**
  * Tests the fullscreen mode by: toggling between fullscreen and windowed mode
  */
@@ -198,7 +244,6 @@
 	"You should be able to move it. The test finishes when the mouse(L/R) is clicked");
 	
 	Common::Point pt(0, 100);
-	Common::Rect rect = Testsuite::writeOnScreen("Testing Palettized Cursors", pt);
 	
 	bool isFeaturePresent;
 	bool isFeatureEnabled;
@@ -207,25 +252,10 @@
 	isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureCursorHasPalette);
 
 	if (isFeaturePresent) {
-		byte palette[3 * 4]; // Black, white and yellow
-		palette[0] = palette[1] = palette[2] = 0;
-		palette[4] = palette[5] = palette[6] = 255;
-		palette[8] = palette[9] = 255;
-		palette[10] = 0;
+		GFXtests::drawCursor();
 		
-		byte buffer[10][10];
-		memset(&buffer[0][0], 2, 10 * 10);
-
-		// Mark the hotspot
-		for (int i = 0; i < 10; i++) {
-			buffer[i][i] = 0;
-			buffer[9 - i][i] = 0;
-		}
+		Testsuite::writeOnScreen("Testing Palettized Cursors", pt);
 		
-		CursorMan.pushCursorPalette(palette, 0, 3);
-		CursorMan.pushCursor(&buffer[0][0], 10, 10, 5, 5, 1);
-		CursorMan.showMouse(true);
-
 		Common::EventManager *eventMan = g_system->getEventManager();
 		Common::Event event;
 
@@ -236,23 +266,23 @@
 		while (!quitLoop) {
 			while (eventMan->pollEvent(event)) {
 	
-				 if (lastRedraw + waitTime < g_system->getMillis()) {
-        	        g_system->updateScreen();
-            	    lastRedraw = g_system->getMillis();
-           		 }
+				if (lastRedraw + waitTime < g_system->getMillis()) {
+					g_system->updateScreen();
+					lastRedraw = g_system->getMillis();
+				}
 
 				switch (event.type) {
-				case Common::EVENT_MOUSEMOVE:
+					case Common::EVENT_MOUSEMOVE:
 					printf("Mouse Move\n");
 					break;
 				case Common::EVENT_LBUTTONDOWN:
 				case Common::EVENT_RBUTTONDOWN:
-					Testsuite::clearScreen(rect);
+					Testsuite::clearScreen();
 					Testsuite::writeOnScreen("Mouse Clicked", pt);
 					printf("Mouse Clicked\n");
 					g_system->delayMillis(1000);
 					quitLoop = true;
-					Testsuite::clearScreen(rect);
+					Testsuite::clearScreen();
 					Testsuite::writeOnScreen("TestFinished", pt);
 					g_system->delayMillis(1000);
 					break;
@@ -265,7 +295,7 @@
 	} else {
 		Testsuite::displayMessage("feature not supported");
 	}
-	Testsuite::clearScreen(rect);
+	Testsuite::clearScreen();
 
 	// Testing Mouse Movements now!
 	
@@ -291,15 +321,7 @@
 	return true;
 }
 
-/**
- * Tests Mouse Movements.
- * Currently plan to implement an automove along a diagonal to the mid point.
- */
 
-bool GFXtests::mouseMovements() {
-	return true;
-}
-
 /**
  * This basically blits the screen by the contents of its buffer.
  *
@@ -364,4 +386,105 @@
 	Testsuite::clearScreen(rect);
 	return true;
 }
+
+/**
+ * Testing feature: Scaled cursors
+ */
+
+bool GFXtests::scaledCursors() {
+
+	// TODO : Understand and fix the problem relating scaled cursors
+	
+	const OSystem::GraphicsMode *gfxMode = g_system->getSupportedGraphicsModes();
+	
+	while (gfxMode->name) {
+		// for every graphics mode display cursors for cursorTargetScale 1, 2 and 3
+		// Switch Graphics mode
+		g_system->warpMouse(80, 160);
+
+		//if (g_system->setGraphicsMode(gfxMode->id)) {
+		if (1) {
+			drawCursor(gfxMode->name, 1);
+			g_system->delayMillis(5000);
+			drawCursor(gfxMode->name, 2);
+			g_system->delayMillis(5000);
+			drawCursor(gfxMode->name, 3);
+			g_system->delayMillis(5000);
+		} else {
+			printf("Switching to graphics mode %s failed\n", gfxMode->name);
+		}
+		CursorMan.popAllCursors();
+		gfxMode++;
+	}
+
+	return true;
 }
+
+bool GFXtests::shakingEffect() {
+	Common::Point pt(0, 100);
+	Testsuite::writeOnScreen("Does this shakes!!?", pt);
+	int times = 25;
+	while (times--) {
+		g_system->setShakePos(10);
+		g_system->updateScreen();
+		g_system->setShakePos(0);
+		g_system->updateScreen();
+	}
+	g_system->delayMillis(500);
+	Testsuite::clearScreen();
+	return true;
+}
+
+bool GFXtests::focusRectangle() {
+	Testsuite::clearScreen();
+
+	const Graphics::Font &font(*FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont));
+
+	Graphics::Surface *screen = g_system->lockScreen();
+	int screenHeight = g_system->getHeight();
+	int screenWidth = g_system->getWidth();
+
+	int height = font.getFontHeight();
+	int width = screenWidth / 2;
+
+	Common::Rect rectLeft(0, 0, width, height * 2);
+	screen->fillRect(rectLeft, kColorWhite);
+	font.drawString(screen, "Focus 1", rectLeft.left, rectLeft.top, width, kColorBlack, Graphics::kTextAlignLeft);
+
+	Common::Rect rectRight(screenWidth - width, screenHeight - height * 2 , screenWidth, screenHeight);
+	screen->fillRect(rectRight, kColorWhite);
+	font.drawString(screen, "Focus 2", rectRight.left, rectRight.top, width, kColorBlack, Graphics::kTextAlignRight);
+	g_system->unlockScreen();
+	g_system->updateScreen();
+
+	g_system->setFocusRectangle(rectLeft);
+	g_system->updateScreen();
+	
+	g_system->delayMillis(1000);
+
+	g_system->setFocusRectangle(rectRight);
+	g_system->updateScreen();
+
+	return true;
+}
+
+bool GFXtests::overlayGraphics() {
+	Graphics::PixelFormat pf = g_system->getOverlayFormat();
+	
+	GFXTestSuite::setCustomColor(255, 255, 0);
+	OverlayColor buffer[20 * 40];
+	memset(buffer, 2, 20 * 40);
+
+	int x = g_system->getWidth() / 2 - 20;
+	int y = g_system->getHeight() / 2 - 10;
+
+	g_system->copyRectToOverlay(buffer, 40, x, y, 40, 20);
+	g_system->showOverlay();
+	g_system->updateScreen();
+	g_system->delayMillis(1000);
+	g_system->hideOverlay();
+
+	return true;
+}
+
+}

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/graphics.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/graphics.h	2010-06-13 14:19:10 UTC (rev 49633)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/graphics.h	2010-06-13 19:19:06 UTC (rev 49634)
@@ -9,14 +9,18 @@
 
 // Helper functions for GFX tests
 void drawEllipse(int x, int y, int a, int b);
+void drawCursor(const char *gfxModeName = 0, int cursorTargetScale = 1);
 
 // will contain function declarations for GFX tests
 bool fullScreenMode(); 
 bool aspectRatio();
 bool palettizedCursors();
 bool copyRectToScreen();
-bool mouseMovements();
 bool iconifyWindow();
+bool scaledCursors();
+bool shakingEffect();
+bool focusRectangle();
+bool overlayGraphics();
 // add more here
 }
 
@@ -33,7 +37,7 @@
 	GFXTestSuite();
 	~GFXTestSuite(){}
 	void execute();
-	const char *getName();
+	const char *getName() const;
 	static void setCustomColor(uint r, uint g, uint b);
 
 private:

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h	2010-06-13 14:19:10 UTC (rev 49633)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h	2010-06-13 19:19:06 UTC (rev 49634)
@@ -51,10 +51,10 @@
 		}	
 	}
 	
-	int getNumTests() { return _testsToExecute.size(); }
-	int getNumTestsPassed() { return _numTestsPassed; }
-	int getNumTestsFailed() { return _numTestsExecuted - _numTestsPassed; }
-	void genReport() {
+	int getNumTests() const { return _testsToExecute.size(); }
+	int getNumTestsPassed() const { return _numTestsPassed; }
+	int getNumTestsFailed() const { return _numTestsExecuted - _numTestsPassed; }
+	void genReport() const {
 		printf("Subsystem:%s\n",getName());
 		printf("Tests executed:%d\n", _numTestsExecuted);
 		printf("Tests Passed:%d\n", _numTestsPassed);
@@ -137,7 +137,7 @@
 		}
 		genReport();
 	}
-	virtual const char *getName() = 0;
+	virtual const char *getName() const = 0;
 
 protected:
 	Common::Array<Test*> _testsToExecute;			///< List of tests to be executed


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list