mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-24 13:13:58 +00:00
VIDEO/GOB: Add setSurfaceMemory() to CoktelDecoder
This allows the video player to directly draw onto its own video memory without having to blit each frame another time. Will also be needed for proper handling of transparency in Woodruff. svn-id: r51857
This commit is contained in:
parent
863872216f
commit
9255d2e217
@ -136,19 +136,17 @@ int VideoPlayer::openVideo(bool primary, const Common::String &file, Properties
|
||||
if (!_vm->_draw->_spritesArray[properties.sprite]) {
|
||||
properties.sprite = -1;
|
||||
video->surface.reset();
|
||||
// video->decoder->setVideoMemory();
|
||||
video->decoder->setSurfaceMemory();
|
||||
} else {
|
||||
video->surface = _vm->_draw->_spritesArray[properties.sprite];
|
||||
/*
|
||||
video->decoder->setVideoMemory(video->surface->getVidMem(),
|
||||
video->surface->getWidth(), video->surface->getHeight());
|
||||
*/
|
||||
video->decoder->setSurfaceMemory(video->surface->getVidMem(),
|
||||
video->surface->getWidth(), video->surface->getHeight(), 1);
|
||||
}
|
||||
|
||||
} else {
|
||||
properties.sprite = -1;
|
||||
video->surface.reset();
|
||||
// video->decoder->setVideoMemory();
|
||||
video->decoder->setSurfaceMemory();
|
||||
}
|
||||
|
||||
if (primary)
|
||||
@ -270,7 +268,7 @@ bool VideoPlayer::playFrame(int slot, Properties &properties) {
|
||||
|
||||
WRITE_VAR(11, video->decoder->getCurFrame());
|
||||
|
||||
blitFrame(video->surface, *surface);
|
||||
// blitFrame(video->surface, *surface);
|
||||
|
||||
if (_woodruffCohCottWorkaround && (properties.startFrame == 31)) {
|
||||
// WORKAROUND: This frame mistakenly masks Coh Cott, making her vanish
|
||||
|
@ -34,7 +34,8 @@ CoktelDecoder::State::State() : left(0), top(0), right(0), bottom(0), flags(0),
|
||||
|
||||
|
||||
CoktelDecoder::CoktelDecoder(Audio::Mixer &mixer, Audio::Mixer::SoundType soundType) :
|
||||
_mixer(&mixer), _soundType(soundType), _width(0), _height(0), _frameCount(0), _paletteDirty(false) {
|
||||
_mixer(&mixer), _soundType(soundType), _width(0), _height(0), _frameCount(0),
|
||||
_paletteDirty(false), _ownSurface(true) {
|
||||
|
||||
memset(_palette, 0, 768);
|
||||
}
|
||||
@ -42,6 +43,59 @@ CoktelDecoder::CoktelDecoder(Audio::Mixer &mixer, Audio::Mixer::SoundType soundT
|
||||
CoktelDecoder::~CoktelDecoder() {
|
||||
}
|
||||
|
||||
void CoktelDecoder::setSurfaceMemory(void *mem, uint16 width, uint16 height, uint8 bpp) {
|
||||
freeSurface();
|
||||
|
||||
assert((width > 0) && (height > 0));
|
||||
assert(bpp == getPixelFormat().bytesPerPixel);
|
||||
|
||||
_surface.w = width;
|
||||
_surface.h = height;
|
||||
_surface.pitch = width * bpp;
|
||||
_surface.pixels = mem;
|
||||
_surface.bytesPerPixel = bpp;
|
||||
|
||||
_ownSurface = false;
|
||||
}
|
||||
|
||||
void CoktelDecoder::setSurfaceMemory() {
|
||||
freeSurface();
|
||||
createSurface();
|
||||
|
||||
_ownSurface = true;
|
||||
}
|
||||
|
||||
bool CoktelDecoder::hasSurface() {
|
||||
return _surface.pixels != 0;
|
||||
}
|
||||
|
||||
void CoktelDecoder::createSurface() {
|
||||
if (hasSurface())
|
||||
return;
|
||||
|
||||
if ((_width > 0) && (_height > 0))
|
||||
_surface.create(_width, _height, getPixelFormat().bytesPerPixel);
|
||||
|
||||
_ownSurface = true;
|
||||
}
|
||||
|
||||
void CoktelDecoder::freeSurface() {
|
||||
if (!_ownSurface) {
|
||||
_surface.w = 0;
|
||||
_surface.h = 0;
|
||||
_surface.pitch = 0;
|
||||
_surface.pixels = 0;
|
||||
_surface.bytesPerPixel = 0;
|
||||
} else
|
||||
_surface.free();
|
||||
|
||||
_ownSurface = true;
|
||||
}
|
||||
|
||||
void CoktelDecoder::close() {
|
||||
freeSurface();
|
||||
}
|
||||
|
||||
uint16 CoktelDecoder::getWidth() const {
|
||||
return _width;
|
||||
}
|
||||
@ -129,8 +183,6 @@ bool PreIMDDecoder::load(Common::SeekableReadStream &stream) {
|
||||
|
||||
_frameCount = _stream->readUint16LE();
|
||||
|
||||
_surface.create(_width, _height, 1);
|
||||
|
||||
_videoBufferSize = _width * _height;
|
||||
_videoBuffer = new byte[_videoBufferSize];
|
||||
|
||||
@ -142,7 +194,7 @@ bool PreIMDDecoder::load(Common::SeekableReadStream &stream) {
|
||||
void PreIMDDecoder::close() {
|
||||
reset();
|
||||
|
||||
_surface.free();
|
||||
CoktelDecoder::close();
|
||||
|
||||
delete _stream;
|
||||
|
||||
@ -162,6 +214,8 @@ Surface *PreIMDDecoder::decodeNextFrame() {
|
||||
if (!isVideoLoaded() || endOfVideo())
|
||||
return 0;
|
||||
|
||||
createSurface();
|
||||
|
||||
processFrame();
|
||||
renderFrame();
|
||||
|
||||
|
@ -64,8 +64,15 @@ public:
|
||||
|
||||
virtual bool seek(int32 frame, int whence = SEEK_SET, bool restart = false) = 0;
|
||||
|
||||
/** Draw directly onto the specified video memory. */
|
||||
void setSurfaceMemory(void *mem, uint16 width, uint16 height, uint8 bpp);
|
||||
/** Reset the video memory. */
|
||||
void setSurfaceMemory();
|
||||
|
||||
// VideoDecoder interface
|
||||
|
||||
void close();
|
||||
|
||||
uint16 getWidth() const;
|
||||
uint16 getHeight() const;
|
||||
|
||||
@ -86,8 +93,15 @@ protected:
|
||||
byte _palette[768];
|
||||
bool _paletteDirty;
|
||||
|
||||
bool _ownSurface;
|
||||
Surface _surface;
|
||||
|
||||
Common::Rational _frameRate;
|
||||
|
||||
bool hasSurface();
|
||||
void createSurface();
|
||||
void freeSurface();
|
||||
|
||||
// FixedRateVideoDecoder interface
|
||||
Common::Rational getFrameRate() const;
|
||||
};
|
||||
@ -117,8 +131,6 @@ private:
|
||||
byte *_videoBuffer;
|
||||
uint32 _videoBufferSize;
|
||||
|
||||
Surface _surface;
|
||||
|
||||
void processFrame();
|
||||
void renderFrame();
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user