diff options
author | Marisa-Chan | 2013-11-24 14:48:45 +0000 |
---|---|---|
committer | Marisa-Chan | 2013-11-24 14:48:45 +0000 |
commit | 4cb006f2602199a3f201f918392f3e66a385df0e (patch) | |
tree | 464013c734e764bc8031875a652bd63cc528dc57 /engines | |
parent | f877410feef2e0030dd6c0664d615cc86118ca29 (diff) | |
download | scummvm-rg350-4cb006f2602199a3f201f918392f3e66a385df0e.tar.gz scummvm-rg350-4cb006f2602199a3f201f918392f3e66a385df0e.tar.bz2 scummvm-rg350-4cb006f2602199a3f201f918392f3e66a385df0e.zip |
ZVISION: Animation nodes now scaleable.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/zvision/actions.cpp | 4 | ||||
-rw-r--r-- | engines/zvision/actions.h | 4 | ||||
-rw-r--r-- | engines/zvision/animation_node.cpp | 45 | ||||
-rw-r--r-- | engines/zvision/animation_node.h | 3 | ||||
-rw-r--r-- | engines/zvision/render_manager.cpp | 27 | ||||
-rw-r--r-- | engines/zvision/render_manager.h | 2 |
6 files changed, 76 insertions, 9 deletions
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 5568e39bdb..2fbec2945a 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -361,7 +361,7 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, const Common::String & // The two %*u are always 0 and dont seem to have a use sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %d %*u %*u %d %d)", - &_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &_loopCount, &_mask, &_framerate); + &_key, fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate); if (_mask > 0) { byte r, g, b; @@ -386,7 +386,7 @@ bool ActionPlayAnimation::execute() { nod->stop(); if (nod) - nod->addPlayNode(_key, _x, _y, _width, _height, _start, _end, _loopCount); + nod->addPlayNode(_key, _x, _y, _x2, _y2, _start, _end, _loopCount); return true; } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index 50224aaaf5..d9871328cb 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -257,8 +257,8 @@ private: Common::String _fileName; uint32 _x; uint32 _y; - uint32 _width; - uint32 _height; + uint32 _x2; + uint32 _y2; uint32 _start; uint32 _end; int32 _mask; diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp index 72afeabac6..73e419ee19 100644 --- a/engines/zvision/animation_node.cpp +++ b/engines/zvision/animation_node.cpp @@ -69,9 +69,13 @@ AnimationNode::~AnimationNode() { _engine->getScriptManager()->setStateValue(_key, 2); PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) + if (it != _playList.end()) { _engine->getScriptManager()->setStateValue((*it).slot, 2); + if ((*it)._scaled) + delete(*it)._scaled; + } + _playList.clear(); } @@ -108,6 +112,8 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { if (nod->loop == 0) { if (nod->slot >= 0) _engine->getScriptManager()->setStateValue(nod->slot, 2); + if (nod->_scaled) + delete nod->_scaled; _playList.erase(it); return _DisposeAfterUse; } @@ -129,6 +135,33 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { } if (frame) { + + uint32 dstw; + uint32 dsth; + if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { + dstw = nod->pos.height(); + dsth = nod->pos.width(); + } else { + dstw = nod->pos.width(); + dsth = nod->pos.height(); + } + + if (frame->w != dstw || frame->h != dsth) { + if (nod->_scaled) + if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) { + delete nod->_scaled; + nod->_scaled = NULL; + } + + if (!nod->_scaled) { + nod->_scaled = new Graphics::Surface; + nod->_scaled->create(dstw, dsth, frame->format); + } + + _engine->getRenderManager()->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth); + frame = nod->_scaled; + } + if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { Graphics::Surface *transposed = RenderManager::tranposeSurface(frame); if (_mask > 0) @@ -151,22 +184,26 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { -void AnimationNode::addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops) { +void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops) { playnode nod; nod.loop = loops; - nod.pos = Common::Rect(x, y, x + w - 1, y + h - 1); + nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1); nod.start = start_frame; nod.stop = end_frame; nod.slot = slot; nod._cur_frm = -1; nod._delay = 0; + nod._scaled = NULL; _playList.push_back(nod); } bool AnimationNode::stop() { PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) + if (it != _playList.end()) { _engine->getScriptManager()->setStateValue((*it).slot, 2); + if ((*it)._scaled) + delete(*it)._scaled; + } _playList.clear(); diff --git a/engines/zvision/animation_node.h b/engines/zvision/animation_node.h index 76c961ceb1..843e59236b 100644 --- a/engines/zvision/animation_node.h +++ b/engines/zvision/animation_node.h @@ -58,6 +58,7 @@ public: int32 loop; int32 _cur_frm; int32 _delay; + Graphics::Surface *_scaled; }; private: @@ -84,7 +85,7 @@ private: public: bool process(uint32 deltaTimeInMillis); - void addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops = 1); + void addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops = 1); bool stop(); }; diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp index 58df5a8d11..fc15e18fd0 100644 --- a/engines/zvision/render_manager.cpp +++ b/engines/zvision/render_manager.cpp @@ -694,4 +694,31 @@ Graphics::Surface *RenderManager::tranposeSurface(const Graphics::Surface *surfa return tranposedSurface; } +void RenderManager::scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight) { + assert(bytesPerPixel == 1 || bytesPerPixel == 2); + + const float xscale = (float)srcWidth / (float)dstWidth; + const float yscale = (float)srcHeight / (float)dstHeight; + + if (bytesPerPixel == 1) { + const byte *srcPtr = (const byte *)src; + byte *dstPtr = (byte *)dst; + for (uint32 y = 0; y < dstHeight; ++y) { + for (uint32 x = 0; x < dstWidth; ++x) { + *dstPtr = srcPtr[(int)(x * xscale) + (int)(y * yscale) * srcWidth]; + dstPtr++; + } + } + } else if (bytesPerPixel == 2) { + const uint16 *srcPtr = (const uint16 *)src; + uint16 *dstPtr = (uint16 *)dst; + for (uint32 y = 0; y < dstHeight; ++y) { + for (uint32 x = 0; x < dstWidth; ++x) { + *dstPtr = srcPtr[(int)(x * xscale) + (int)(y * yscale) * srcWidth]; + dstPtr++; + } + } + } +} + } // End of namespace ZVision diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h index c302844117..14ca704ce1 100644 --- a/engines/zvision/render_manager.h +++ b/engines/zvision/render_manager.h @@ -367,6 +367,8 @@ public: */ static Graphics::Surface *tranposeSurface(const Graphics::Surface *surface); + void scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight); + private: /** * Renders a subRectangle of an image to the backbuffer. The destinationRect and SubRect |