[Scummvm-cvs-logs] SF.net SVN: scummvm:[52431] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sun Aug 29 02:39:34 CEST 2010


Revision: 52431
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52431&view=rev
Author:   thebluegr
Date:     2010-08-29 00:39:33 +0000 (Sun, 29 Aug 2010)

Log Message:
-----------
SCI: Throttle the invocations of Engine::shouldQuit()

SCI constantly invoked Engine::shouldQuit(), which in
turn called 2 virtual functions. This added a significant
overhead, as this was called constantly without any
throttling whatsoever. Now, the invocation of shouldQuit()
is throttled to be on each frame update (i.e. at a rate of
60fps). Thanks to wjp for profiling this.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/vm.cpp
    scummvm/trunk/engines/sci/event.cpp
    scummvm/trunk/engines/sci/graphics/animate.cpp
    scummvm/trunk/engines/sci/graphics/portrait.cpp

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2010-08-29 00:17:56 UTC (rev 52430)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2010-08-29 00:39:33 UTC (rev 52431)
@@ -911,7 +911,7 @@
 		g_sci->_debugState.old_pc_offset = s->xs->addr.pc.offset;
 		g_sci->_debugState.old_sp = s->xs->sp;
 
-		if (s->abortScriptProcessing != kAbortNone || g_engine->shouldQuit())
+		if (s->abortScriptProcessing != kAbortNone)
 			return; // Stop processing
 
 		if (s->_executionStackPosChanged) {
@@ -942,7 +942,7 @@
 			s->variables[VAR_PARAM] = s->xs->variables_argp;
 		}
 
-		if (s->abortScriptProcessing != kAbortNone || g_engine->shouldQuit())
+		if (s->abortScriptProcessing != kAbortNone)
 			return; // Stop processing
 
 		// Debug if this has been requested:
@@ -1442,7 +1442,7 @@
 			s->_executionStackPosChanged = true;
 
 			// If a game is being loaded, stop processing
-			if (s->abortScriptProcessing != kAbortNone || g_engine->shouldQuit())
+			if (s->abortScriptProcessing != kAbortNone)
 				return; // Stop processing
 
 			break;

Modified: scummvm/trunk/engines/sci/event.cpp
===================================================================
--- scummvm/trunk/engines/sci/event.cpp	2010-08-29 00:17:56 UTC (rev 52430)
+++ scummvm/trunk/engines/sci/event.cpp	2010-08-29 00:39:33 UTC (rev 52431)
@@ -351,9 +351,17 @@
 void EventManager::updateScreen() {
 	// Update the screen here, since it's called very often.
 	// Throttle the screen update rate to 60fps.
-	if (g_system->getMillis() - g_sci->getEngineState()->_screenUpdateTime >= 1000 / 60) {
+	EngineState *s = g_sci->getEngineState();
+	if (g_system->getMillis() - s->_screenUpdateTime >= 1000 / 60) {
 		g_system->updateScreen();
-		g_sci->getEngineState()->_screenUpdateTime = g_system->getMillis();
+		s->_screenUpdateTime = g_system->getMillis();
+		// Throttle the checking of shouldQuit() to 60fps as well, since 
+		// Engine::shouldQuit() invokes 2 virtual functions
+		// (EventManager::shouldQuit() and EventManager::shouldRTL()),
+		// which is very expensive to invoke constantly without any
+		// throttling at all.
+		if (g_engine->shouldQuit())
+			s->abortScriptProcessing = kAbortQuitGame;
 	}
 }
 

Modified: scummvm/trunk/engines/sci/graphics/animate.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/animate.cpp	2010-08-29 00:17:56 UTC (rev 52430)
+++ scummvm/trunk/engines/sci/graphics/animate.cpp	2010-08-29 00:39:33 UTC (rev 52431)
@@ -96,7 +96,7 @@
 			invokeSelector(_s, curObject, SELECTOR(doit), argc, argv, 0);
 
 			// If a game is being loaded, stop processing
-			if (_s->abortScriptProcessing != kAbortNone || g_engine->shouldQuit())
+			if (_s->abortScriptProcessing != kAbortNone)
 				return true; // Stop processing
 
 			// Lookup node again, since the nodetable it was in may have been reallocated.

Modified: scummvm/trunk/engines/sci/graphics/portrait.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/portrait.cpp	2010-08-29 00:17:56 UTC (rev 52430)
+++ scummvm/trunk/engines/sci/graphics/portrait.cpp	2010-08-29 00:39:33 UTC (rev 52431)
@@ -185,7 +185,7 @@
 			curEvent = _event->getSciEvent(SCI_EVENT_ANY);
 			if (curEvent.type == SCI_EVENT_MOUSE_PRESS ||
 				(curEvent.type == SCI_EVENT_KEYBOARD && curEvent.data == SCI_KEY_ESC) ||
-				g_engine->shouldQuit())
+				g_sci->getEngineState()->abortScriptProcessing == kAbortQuitGame)
 				userAbort = true;
 			curPosition = _audio->getAudioPosition();
 		} while ((curPosition != -1) && (curPosition < timerPosition) && (!userAbort));


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