From bd3f9ad1e21a791dafee1943099492d6b49d32be Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 20 Jan 2011 05:19:41 +0000 Subject: GOB: Use Surface::blit() in VideoPlayer::copyFrame() svn-id: r55344 --- engines/gob/inter_v6.cpp | 5 ++-- engines/gob/scenery.cpp | 3 +-- engines/gob/videoplayer.cpp | 56 ++++----------------------------------------- engines/gob/videoplayer.h | 6 ++--- 4 files changed, 11 insertions(+), 59 deletions(-) diff --git a/engines/gob/inter_v6.cpp b/engines/gob/inter_v6.cpp index 0ae08dc387..561996dcfc 100644 --- a/engines/gob/inter_v6.cpp +++ b/engines/gob/inter_v6.cpp @@ -244,10 +244,9 @@ bool Inter_v6::o6_loadCursor(OpFuncParams ¶ms) { props.waitEndFrame = false; _vm->_vidPlayer->play(vmdSlot, props); - _vm->_vidPlayer->copyFrame(vmdSlot, _vm->_draw->_cursorSprites->getData(), + _vm->_vidPlayer->copyFrame(vmdSlot, *_vm->_draw->_cursorSprites, 0, 0, _vm->_draw->_cursorWidth, _vm->_draw->_cursorWidth, - (start + i) * _vm->_draw->_cursorWidth, 0, - _vm->_draw->_cursorSprites->getWidth() * 2, 2); + (start + i) * _vm->_draw->_cursorWidth, 0); } _vm->_vidPlayer->closeVideo(vmdSlot); diff --git a/engines/gob/scenery.cpp b/engines/gob/scenery.cpp index fbaa7fa864..fb167f81cb 100644 --- a/engines/gob/scenery.cpp +++ b/engines/gob/scenery.cpp @@ -733,11 +733,10 @@ void Scenery::updateAnim(int16 layer, int16 frame, int16 animation, int16 flags, _vm->_draw->_spriteLeft = _vm->_vidPlayer->getWidth(obj.videoSlot - 1) - (destX + _vm->_draw->_spriteRight); - _vm->_vidPlayer->copyFrame(obj.videoSlot - 1, _vm->_draw->_backSurface->getData(), + _vm->_vidPlayer->copyFrame(obj.videoSlot - 1, *_vm->_draw->_backSurface, _vm->_draw->_spriteLeft, _vm->_draw->_spriteTop, _vm->_draw->_spriteRight, _vm->_draw->_spriteBottom, _vm->_draw->_destSpriteX, _vm->_draw->_destSpriteY, - _vm->_draw->_backSurface->getWidth(), 1, (_vm->_draw->_transparency != 0) ? 0 : -1); _vm->_draw->invalidateRect(_vm->_draw->_destSpriteX, _vm->_draw->_destSpriteY, diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp index 8ac4c47202..a7284feb66 100644 --- a/engines/gob/videoplayer.cpp +++ b/engines/gob/videoplayer.cpp @@ -611,9 +611,9 @@ void VideoPlayer::writeVideoInfo(const Common::String &file, int16 varX, int16 v } } -bool VideoPlayer::copyFrame(int slot, byte *dest, - uint16 left, uint16 top, uint16 width, uint16 height, - uint16 x, uint16 y, uint16 pitch, uint8 bpp, int16 transp) const { +bool VideoPlayer::copyFrame(int slot, Surface &dest, + uint16 left, uint16 top, uint16 width, uint16 height, uint16 x, uint16 y, + int32 transp) const { const Video *video = getVideoBySlot(slot); if (!video) @@ -623,55 +623,9 @@ bool VideoPlayer::copyFrame(int slot, byte *dest, if (!surface) return false; - assert(surface->bytesPerPixel == bpp); - - int32 w = MIN(width , surface->w); - int32 h = MIN(height, surface->h); - - const byte *src = (byte*)surface->pixels + (top * surface->pitch) + left; - byte *dst = dest + (y * pitch) + x; - - if (transp < 0) { - // No transparency - - if ((x == 0) && (left == 0) && (pitch == surface->pitch) && (width == surface->w)) { - // Dimensions fit, we can copy everything at once - - memcpy(dst, src, w * h * bpp); - return true; - } - - // Copy row-by-row - - while (h-- > 0) { - const byte *srcRow = src; - byte *dstRow = dst; - - memcpy(dstRow, srcRow, w * bpp); - - src += surface->pitch; - dst += pitch; - } - - return true; - } - - // Copy pixel-by-pixel - - assert(bpp == 1); - - while (h-- > 0) { - const byte *srcRow = src; - byte *dstRow = dst; - - for (int32 i = 0; i < w; i++, srcRow++, dstRow++) - if (*srcRow != transp) - *dstRow = *srcRow; - - src += surface->pitch; - dst += pitch; - } + Surface src(surface->w, surface->h, surface->bytesPerPixel, (byte *)surface->pixels); + dest.blit(src, left, top, left + width - 1, top + height - 1, x, y, transp); return true; } diff --git a/engines/gob/videoplayer.h b/engines/gob/videoplayer.h index 2708ee1c56..35ad5545e6 100644 --- a/engines/gob/videoplayer.h +++ b/engines/gob/videoplayer.h @@ -133,9 +133,9 @@ public: void writeVideoInfo(const Common::String &file, int16 varX, int16 varY, int16 varFrames, int16 varWidth, int16 varHeight); - bool copyFrame(int slot, byte *dest, - uint16 left, uint16 top, uint16 width, uint16 height, - uint16 x, uint16 y, uint16 pitch, uint8 bpp = 1, int16 transp = -1) const; + bool copyFrame(int slot, Surface &dest, + uint16 left, uint16 top, uint16 width, uint16 height, uint16 x, uint16 y, + int32 transp = -1) const; private: struct Video { -- cgit v1.2.3