aboutsummaryrefslogtreecommitdiff
path: root/engines/sword1/animation.cpp
diff options
context:
space:
mode:
authorTorbjörn Andersson2008-11-18 17:48:19 +0000
committerTorbjörn Andersson2008-11-18 17:48:19 +0000
commit72a847797d383bef76ab09614a04a96fc585f9cf (patch)
treeb9f709c63b1f8584e02ad197cf7a68fd3cbeea36 /engines/sword1/animation.cpp
parentdf694b3de1c68ca52f671f58c5e7b7141e3de340 (diff)
downloadscummvm-rg350-72a847797d383bef76ab09614a04a96fc585f9cf.tar.gz
scummvm-rg350-72a847797d383bef76ab09614a04a96fc585f9cf.tar.bz2
scummvm-rg350-72a847797d383bef76ab09614a04a96fc585f9cf.zip
Committed by patch #2219361 ("BS1: Simplified subtitles"). It uses the
lockScreen() / unlockScreen() backend API, instead of copyRectToScreen(). Before, it had to copy a piece of the engine's screen to draw on to simulate transparency, which was awkward. However, this means we're now forcing full-screen updates on each frame. There may be performance regressions, particularly if the frames are much smaller than the screen. Hopefully, it's the decoding that's the bottleneck, but if this causes problems on low-end devices... well, Fingolfin had some ideas about that when he first proposed the lockScreen() / unlockScreen() API. svn-id: r35115
Diffstat (limited to 'engines/sword1/animation.cpp')
-rw-r--r--engines/sword1/animation.cpp54
1 files changed, 19 insertions, 35 deletions
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp
index c0cd85a7c2..592cc2e565 100644
--- a/engines/sword1/animation.cpp
+++ b/engines/sword1/animation.cpp
@@ -36,6 +36,7 @@
#include "common/str.h"
#include "common/events.h"
#include "common/system.h"
+#include "graphics/surface.h"
namespace Sword1 {
@@ -70,7 +71,6 @@ MoviePlayer::MoviePlayer(SwordEngine *vm, Screen *screen, Text *textMan, Audio::
: _vm(vm), _screen(screen), _textMan(textMan), _snd(snd), _system(system) {
_bgSoundStream = NULL;
_ticks = 0;
- _textSpriteBuf = NULL;
_black = 1;
_white = 255;
_currentFrame = 0;
@@ -275,12 +275,9 @@ void MoviePlayer::play(void) {
_textHeight = frame->height;
_textX = 320 - _textWidth / 2;
_textY = 420 - _textHeight;
- _textSpriteBuf = (byte *)calloc(_textHeight, _textWidth);
}
if (_currentFrame == _movieTexts[0]->_endFrame) {
_textMan->releaseText(2, false);
- free(_textSpriteBuf);
- _textSpriteBuf = NULL;
delete _movieTexts.remove_at(0);
}
}
@@ -309,11 +306,7 @@ void MoviePlayer::play(void) {
if (terminated)
_snd->stopHandle(_bgSoundHandle);
- if (_textSpriteBuf) {
- _textMan->releaseText(2, false);
- free(_textSpriteBuf);
- _textSpriteBuf = NULL;
- }
+ _textMan->releaseText(2, false);
while (!_movieTexts.empty())
delete _movieTexts.remove_at(_movieTexts.size() - 1);
@@ -444,31 +437,26 @@ bool MoviePlayerDXA::decodeFrame(void) {
}
void MoviePlayerDXA::processFrame(void) {
- // TODO: Handle the advanced cutscene packs. Do they really exist?
-
- // We cannot draw the text to _drawBuffer, since that's one of the
- // decoder's internal buffers. Instead, we copy part of _drawBuffer
- // to the text sprite.
+}
- if (_textSpriteBuf) {
- memset(_textSpriteBuf, 0, _textWidth * _textHeight);
+void MoviePlayerDXA::updateScreen(void) {
+ _system->copyRectToScreen(_drawBuffer, _frameWidth, _frameX, _frameY, _frameWidth, _frameHeight);
- // FIXME: This is inefficient
- int x, y;
+ // TODO: Handle the advanced cutscene packs. Do they really exist?
- for (y = _textY; y < _textY + _textHeight; y++) {
- for (x = _textX; x < _textX + _textWidth; x++) {
- if (x >= _frameX && x <= _frameX + _frameWidth && y >= _frameY && y <= _frameY + _frameHeight) {
- _textSpriteBuf[(y - _textY) * _textWidth + x - _textX] = _drawBuffer[(y - _frameY) * _frameWidth + x - _frameX];
- }
- }
- }
+ // We cannot draw the text to _drawBuffer, since that's one of the
+ // decoder's internal buffers, and besides it may be much smaller than
+ // the screen, so it's possible that the subtitles don't fit on it.
+ // Instead, we get the frame buffer from the backend, after copying the
+ // frame to it, and draw on that.
+ if (_textMan->giveSpriteData(2)) {
+ Graphics::Surface *frameBuffer = _system->lockScreen();
byte *src = (byte *)_textMan->giveSpriteData(2) + sizeof(FrameHeader);
- byte *dst = _textSpriteBuf;
+ byte *dst = (byte *)frameBuffer->getBasePtr(_textX, _textY);
- for (y = 0; y < _textHeight; y++) {
- for (x = 0; x < _textWidth; x++) {
+ for (int y = 0; y < _textHeight; y++) {
+ for (int x = 0; x < _textWidth; x++) {
switch (src[x]) {
case BORDER_COL:
dst[x] = _black;
@@ -479,16 +467,12 @@ void MoviePlayerDXA::processFrame(void) {
}
}
src += _textWidth;
- dst += _textWidth;
+ dst += frameBuffer->pitch;
}
- }
-}
-void MoviePlayerDXA::updateScreen(void) {
- _system->copyRectToScreen(_drawBuffer, _frameWidth, _frameX, _frameY, _frameWidth, _frameHeight);
- if (_textSpriteBuf) {
- _system->copyRectToScreen(_textSpriteBuf, _textWidth, _textX, _textY, _textWidth, _textHeight);
+ _system->unlockScreen();
}
+
_system->updateScreen();
}