From f67bbc4eccd483e329845c05c8aa2dc5ab6f8215 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 14 Oct 2010 20:44:44 +0000 Subject: SWORD25: Attempt to optimize movie rendering Current code makes about 5 blits of each frame which is a huge overhead. This code is an attempt to make that 1. Doesn't work yet as the rendering pipe keeps blitting invisible pictures. svn-id: r53459 --- engines/sword25/fmv/movieplayer.cpp | 21 +++++++++++++++++++++ engines/sword25/fmv/movieplayer.h | 3 +++ 2 files changed, 24 insertions(+) (limited to 'engines/sword25/fmv') diff --git a/engines/sword25/fmv/movieplayer.cpp b/engines/sword25/fmv/movieplayer.cpp index 1ca7b43dae..164f46eb09 100644 --- a/engines/sword25/fmv/movieplayer.cpp +++ b/engines/sword25/fmv/movieplayer.cpp @@ -41,6 +41,8 @@ #ifdef USE_THEORADEC +#define INDIRECTRENDERING 1 + namespace Sword25 { #define BS_LOG_PREFIX "MOVIEPLAYER" @@ -69,6 +71,8 @@ bool MoviePlayer::loadMovie(const Common::String &filename, uint z) { // Ausgabebitmap erstellen GraphicEngine *pGfx = Kernel::GetInstance()->GetGfx(); + +#if INDIRECTRENDERING _outputBitmap = pGfx->GetMainPanel()->addDynamicBitmap(_decoder.getWidth(), _decoder.getHeight()); if (!_outputBitmap.isValid()) { BS_LOG_ERRORLN("Output bitmap for movie playback could not be created."); @@ -91,6 +95,17 @@ bool MoviePlayer::loadMovie(const Common::String &filename, uint z) { // Ausgabebitmap auf dem Bildschirm zentrieren _outputBitmap->setX((pGfx->GetDisplayWidth() - _outputBitmap->getWidth()) / 2); _outputBitmap->setY((pGfx->GetDisplayHeight() - _outputBitmap->getHeight()) / 2); +#else + _backSurface = pGfx->getSurface(); + + _outX = (pGfx->GetDisplayWidth() - _decoder.getWidth()) / 2; + _outY = (pGfx->GetDisplayHeight() - _decoder.getHeight()) / 2; + + if (_outX < 0) + _outX = 0; + if (_outY < 0) + _outY = 0; +#endif return true; } @@ -118,8 +133,14 @@ void MoviePlayer::update() { // Transfer the next frame assert(s->bytesPerPixel == 4); + +#if INDIRECTRENDERING byte *frameData = (byte *)s->getBasePtr(0, 0); _outputBitmap->setContent(frameData, s->pitch * s->h, 0, s->pitch); +#else + g_system->copyRectToScreen((byte *)s->getBasePtr(0, 0), s->pitch, _outX, _outY, MIN(s->w, _backSurface->w), MIN(s->h, _backSurface->h)); + g_system->updateScreen(); +#endif } } diff --git a/engines/sword25/fmv/movieplayer.h b/engines/sword25/fmv/movieplayer.h index c02285df74..26b5cdd0d8 100644 --- a/engines/sword25/fmv/movieplayer.h +++ b/engines/sword25/fmv/movieplayer.h @@ -140,6 +140,9 @@ private: TheoraDecoder _decoder; + Graphics::Surface *_backSurface; + int _outX, _outY; + RenderObjectPtr _outputBitmap; }; -- cgit v1.2.3