diff options
author | RichieSams | 2013-09-08 17:05:35 -0500 |
---|---|---|
committer | RichieSams | 2013-09-09 11:16:45 -0500 |
commit | 4a4330cec727fd5e08015479bdec94331b2e7662 (patch) | |
tree | 183044c611940480391e4cadc0edf6e01926829b | |
parent | f5f053d335f019a0c26dc8c11730cf0231d9bc60 (diff) | |
download | scummvm-rg350-4a4330cec727fd5e08015479bdec94331b2e7662.tar.gz scummvm-rg350-4a4330cec727fd5e08015479bdec94331b2e7662.tar.bz2 scummvm-rg350-4a4330cec727fd5e08015479bdec94331b2e7662.zip |
ZVISION: Cleanup the cached frame before loading the next one
-rw-r--r-- | engines/zvision/animation_control.cpp | 25 | ||||
-rw-r--r-- | engines/zvision/animation_control.h | 1 |
2 files changed, 25 insertions, 1 deletions
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp index 8c8f6eb238..f80faea0f9 100644 --- a/engines/zvision/animation_control.cpp +++ b/engines/zvision/animation_control.cpp @@ -40,7 +40,8 @@ AnimationControl::AnimationControl(ZVision *engine, uint32 controlKey, const Com _loopCount(1), _currentLoop(0), _accumulatedTime(0), - _cachedFrame(0) { + _cachedFrame(0), + _cachedFrameNeedsDeletion(false) { if (fileName.hasSuffix(".rlf")) { _fileType = RLF; _animation.rlf = new RlfAnimation(fileName, false); @@ -104,7 +105,13 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) { // If the background can move, we need to cache the last frame so it can be rendered during background movement if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { + if (_cachedFrameNeedsDeletion) { + _cachedFrame->free(); + delete _cachedFrame; + _cachedFrameNeedsDeletion = false; + } _cachedFrame = tranposedFrame; + _cachedFrameNeedsDeletion = true; } else { // Cleanup tranposedFrame->free(); @@ -115,6 +122,11 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) { // If the background can move, we need to cache the last frame so it can be rendered during background movement if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { + if (_cachedFrameNeedsDeletion) { + _cachedFrame->free(); + delete _cachedFrame; + _cachedFrameNeedsDeletion = false; + } _cachedFrame->copyFrom(*frame); } } @@ -177,7 +189,13 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) { // If the background can move, we need to cache the last frame so it can be rendered during background movement if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { + if (_cachedFrameNeedsDeletion) { + _cachedFrame->free(); + delete _cachedFrame; + _cachedFrameNeedsDeletion = false; + } _cachedFrame = tranposedFrame; + _cachedFrameNeedsDeletion = true; } else { // Cleanup tranposedFrame->free(); @@ -188,6 +206,11 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) { // If the background can move, we need to cache the last frame so it can be rendered during background movement if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { + if (_cachedFrameNeedsDeletion) { + _cachedFrame->free(); + delete _cachedFrame; + _cachedFrameNeedsDeletion = false; + } _cachedFrame->copyFrom(*frame); } } diff --git a/engines/zvision/animation_control.h b/engines/zvision/animation_control.h index 6b104d4c06..935f4abb4b 100644 --- a/engines/zvision/animation_control.h +++ b/engines/zvision/animation_control.h @@ -65,6 +65,7 @@ private: uint _currentLoop; Graphics::Surface *_cachedFrame; + bool _cachedFrameNeedsDeletion; public: bool process(uint32 deltaTimeInMillis); |