diff options
| author | Filippos Karapetis | 2010-08-29 00:39:33 +0000 |
|---|---|---|
| committer | Filippos Karapetis | 2010-08-29 00:39:33 +0000 |
| commit | 9096848e4b0411daa3cd54a677bafc13e2312082 (patch) | |
| tree | 6127a59517ec107d95b16cefed109710a234673f | |
| parent | 3f1f894e8eeb091153963b8b936b533f78f17e4a (diff) | |
| download | scummvm-rg350-9096848e4b0411daa3cd54a677bafc13e2312082.tar.gz scummvm-rg350-9096848e4b0411daa3cd54a677bafc13e2312082.tar.bz2 scummvm-rg350-9096848e4b0411daa3cd54a677bafc13e2312082.zip | |
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.
svn-id: r52431
| -rw-r--r-- | engines/sci/engine/vm.cpp | 6 | ||||
| -rw-r--r-- | engines/sci/event.cpp | 12 | ||||
| -rw-r--r-- | engines/sci/graphics/animate.cpp | 2 | ||||
| -rw-r--r-- | engines/sci/graphics/portrait.cpp | 2 |
4 files changed, 15 insertions, 7 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 11b508e454..f8ef172c5b 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -911,7 +911,7 @@ void run_vm(EngineState *s) { 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 @@ void run_vm(EngineState *s) { 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 @@ void run_vm(EngineState *s) { 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; diff --git a/engines/sci/event.cpp b/engines/sci/event.cpp index acd2e9f735..5d469eda7b 100644 --- a/engines/sci/event.cpp +++ b/engines/sci/event.cpp @@ -351,9 +351,17 @@ SciEvent EventManager::getScummVMEvent() { 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; } } diff --git a/engines/sci/graphics/animate.cpp b/engines/sci/graphics/animate.cpp index 8e6707f262..cd188bed8a 100644 --- a/engines/sci/graphics/animate.cpp +++ b/engines/sci/graphics/animate.cpp @@ -96,7 +96,7 @@ bool GfxAnimate::invoke(List *list, int argc, reg_t *argv) { 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. diff --git a/engines/sci/graphics/portrait.cpp b/engines/sci/graphics/portrait.cpp index 8f4fe094a8..f21fa39476 100644 --- a/engines/sci/graphics/portrait.cpp +++ b/engines/sci/graphics/portrait.cpp @@ -185,7 +185,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint 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)); |
