mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-02 06:41:51 +00:00
SCI32: Improve performance when flushing events during video playback
Calling through EventManager::getSciEvent to flush events is pretty inefficient and created stalls that lead to dropped frames during the chapter 7 chase in Phantasmagoria 1. If necessary, performance could be improved further by extending Common::EventManager to expose SDL_FlushEvents, but this seems to finish in 0-1ms so should be OK for now. Refs Trac#9974, Trac#9975.
This commit is contained in:
parent
6b87b13ab1
commit
0beb259278
@ -408,6 +408,13 @@ SciEvent EventManager::getSciEvent(uint32 mask) {
|
||||
return event;
|
||||
}
|
||||
|
||||
void EventManager::flushEvents() {
|
||||
Common::EventManager *em = g_system->getEventManager();
|
||||
Common::Event event;
|
||||
while (em->pollEvent(event));
|
||||
_events.clear();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SCI32
|
||||
void EventManager::setHotRectanglesActive(const bool active) {
|
||||
_hotRectanglesActive = active;
|
||||
|
@ -138,6 +138,7 @@ public:
|
||||
|
||||
void updateScreen();
|
||||
SciEvent getSciEvent(uint32 mask);
|
||||
void flushEvents();
|
||||
|
||||
private:
|
||||
SciEvent getScummVMEvent();
|
||||
|
@ -56,18 +56,6 @@ namespace Graphics { struct Surface; }
|
||||
|
||||
namespace Sci {
|
||||
|
||||
static void flushEvents(EventManager *eventMan) {
|
||||
// Flushing all the keyboard and mouse events out of the event manager
|
||||
// keeps events queued from before the start of playback from accidentally
|
||||
// activating a video stop flag
|
||||
for (;;) {
|
||||
const SciEvent event = eventMan->getSciEvent(SCI_EVENT_ANY & ~SCI_EVENT_QUIT);
|
||||
if (event.type == SCI_EVENT_NONE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool VideoPlayer::open(const Common::String &fileName) {
|
||||
if (!_decoder->loadFile(fileName)) {
|
||||
warning("Failed to load %s", fileName.c_str());
|
||||
@ -129,7 +117,10 @@ bool VideoPlayer::endHQVideo() {
|
||||
}
|
||||
|
||||
VideoPlayer::EventFlags VideoPlayer::playUntilEvent(const EventFlags flags, const uint32 maxSleepMs) {
|
||||
flushEvents(_eventMan);
|
||||
// Flushing all the keyboard and mouse events out of the event manager
|
||||
// keeps events queued from before the start of playback from accidentally
|
||||
// activating a video stop flag
|
||||
_eventMan->flushEvents();
|
||||
_decoder->start();
|
||||
|
||||
EventFlags stopFlag = kEventFlagNone;
|
||||
|
Loading…
x
Reference in New Issue
Block a user