diff options
author | Paul Gilbert | 2014-12-13 22:33:23 -0500 |
---|---|---|
committer | Paul Gilbert | 2014-12-13 22:33:23 -0500 |
commit | 310853a285d5d648f1695cc3a40a165223b2928a (patch) | |
tree | 95ae165f55c12c2d5f8aae170f0dbfad5d4ea35b /engines/access | |
parent | 9314daa11cb2eb8d4c4ecbe1c00fc044ba271f3d (diff) | |
download | scummvm-rg350-310853a285d5d648f1695cc3a40a165223b2928a.tar.gz scummvm-rg350-310853a285d5d648f1695cc3a40a165223b2928a.tar.bz2 scummvm-rg350-310853a285d5d648f1695cc3a40a165223b2928a.zip |
ACCESS: Add dirty rects when plotting images to the screen
Diffstat (limited to 'engines/access')
-rw-r--r-- | engines/access/amazon/amazon_logic.cpp | 2 | ||||
-rw-r--r-- | engines/access/amazon/amazon_scripts.cpp | 6 | ||||
-rw-r--r-- | engines/access/asurface.cpp | 43 | ||||
-rw-r--r-- | engines/access/asurface.h | 12 | ||||
-rw-r--r-- | engines/access/screen.cpp | 15 | ||||
-rw-r--r-- | engines/access/screen.h | 6 |
6 files changed, 56 insertions, 28 deletions
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index e8e27fc24e..42f9a243ce 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -356,7 +356,7 @@ void Opening::doTitle() { int id = COUNTDOWN[_pCount * 2]; int xp = COUNTDOWN[_pCount * 2 + 1]; _vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71)); - screen.copyFrom(_vm->_buffer2); + _vm->_buffer2.copyTo(_vm->_screen); _vm->_sound->playSound(1); _vm->_events->_vbCount = 70; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index ce9a3d5c5c..6f9d9c9697 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -71,8 +71,8 @@ void AmazonScripts::mWhile1() { _sequence = 2100; } while (_vm->_flags[52] == 1); - _vm->_screen->copyFrom(_vm->_buffer1); - _vm->_buffer1.copyFrom(_vm->_buffer2); + _vm->_buffer1.copyTo(_vm->_screen); + _vm->_buffer2.copyTo(&_vm->_buffer1); _game->establish(-1, 14); @@ -446,7 +446,7 @@ void AmazonScripts::cmdHelp() { _vm->_screen->clearBuffer(); } - _vm->_screen->copyFrom(_vm->_buffer2); + _vm->_buffer2.copyTo(_vm->_screen); _vm->_screen->restorePalette(); _vm->_screen->setPalette(); _vm->_events->showCursor(); diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index cd872e04b2..9725a5f646 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -203,13 +203,13 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi } } -void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) { - if (dest->getPixels() == nullptr) - dest->create(w, h); +void ASurface::copyFrom(ASurface *src, const Common::Point &destPos) { + if (getPixels() == nullptr) + create(w, h); - for (int yp = 0; yp < h; ++yp) { - byte *srcP = (byte *)getBasePtr(0, yp); - byte *destP = (byte *)dest->getBasePtr(destPos.x, destPos.y + yp); + for (int yp = 0; yp < src->h; ++yp) { + const byte *srcP = (const byte *)src->getBasePtr(0, yp); + byte *destP = (byte *)getBasePtr(destPos.x, destPos.y + yp); for (int xp = 0; xp < this->w; ++xp, ++srcP, ++destP) { if (*srcP != 0) @@ -218,13 +218,13 @@ void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) { } } -void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { +void ASurface::copyFrom(ASurface *src, const Common::Rect &bounds) { const int SCALE_LIMIT = 0x100; - int scaleX = SCALE_LIMIT * bounds.width() / this->w; - int scaleY = SCALE_LIMIT * bounds.height() / this->h; + int scaleX = SCALE_LIMIT * bounds.width() / src->w; + int scaleY = SCALE_LIMIT * bounds.height() / src->h; int scaleXCtr = 0, scaleYCtr = 0; - for (int yCtr = 0, destY = bounds.top; yCtr < this->h; ++yCtr) { + for (int yCtr = 0, destY = bounds.top; yCtr < src->h; ++yCtr) { // Handle skipping lines if Y scaling scaleYCtr += scaleY; if (scaleYCtr < SCALE_LIMIT) @@ -232,17 +232,17 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { scaleYCtr -= SCALE_LIMIT; // Handle off-screen lines - if (destY >= dest->h) + if (destY >= this->h) break; if (destY >= 0) { // Handle drawing the line - byte *pSrc = (byte *)getBasePtr(0, yCtr); - byte *pDest = (byte *)dest->getBasePtr(bounds.left, destY); + const byte *pSrc = (const byte *)src->getBasePtr(0, yCtr); + byte *pDest = (byte *)getBasePtr(bounds.left, destY); scaleXCtr = 0; int x = bounds.left; - for (int xCtr = 0; xCtr < this->w; ++xCtr, ++pSrc) { + for (int xCtr = 0; xCtr < src->w; ++xCtr, ++pSrc) { // Handle horizontal scaling scaleXCtr += scaleX; if (scaleXCtr < SCALE_LIMIT) @@ -250,7 +250,7 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { scaleXCtr -= SCALE_LIMIT; // Only handle on-screen pixels - if (x >= dest->w) + if (x >= this->w) break; if (x >= 0 && *pSrc != 0) *pDest = *pSrc; @@ -264,8 +264,12 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { } } -void ASurface::copyTo(ASurface *dest) { - copyTo(dest, Common::Point()); +void ASurface::copyFrom(ASurface &src) { + copyFrom(&src, Common::Point()); +} + +void ASurface::copyBuffer(Graphics::Surface *src) { + Graphics::Surface::copyFrom(*src); } void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) { @@ -277,13 +281,14 @@ void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) { } void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) { - frame->copyTo(this, bounds); + copyFrom(frame, bounds); } void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) { ASurface flippedFrame; frame->flipHorizontal(flippedFrame); - flippedFrame.copyTo(this, bounds); + + copyFrom(&flippedFrame, bounds); } void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) { diff --git a/engines/access/asurface.h b/engines/access/asurface.h index ffa22d58e5..36fd2518c3 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -65,8 +65,6 @@ public: void clearBuffer(); - void copyBuffer(Graphics::Surface *src) { copyFrom(*src); } - bool clip(Common::Rect &r); void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt); @@ -97,11 +95,15 @@ public: virtual void drawRect(); - void copyTo(ASurface *dest, const Common::Point &destPos); + virtual void copyFrom(ASurface *src, const Common::Point &destPos); + + virtual void copyFrom(ASurface *src, const Common::Rect &bounds); + + virtual void copyFrom(ASurface &src); - void copyTo(ASurface *dest, const Common::Rect &bounds); + void copyTo(ASurface *dest) { dest->copyFrom(*this); } - void copyTo(ASurface *dest); + virtual void copyBuffer(Graphics::Surface *src); void saveBlock(const Common::Rect &bounds); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 98dbdb4e9c..14ead2e266 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -260,6 +260,21 @@ void Screen::drawRect() { ASurface::drawRect(); } +void Screen::copyFrom(ASurface *src, const Common::Point &destPos) { + addDirtyRect(Common::Rect(destPos.x, destPos.y, destPos.x + src->w, destPos.y + src->h)); + ASurface::copyFrom(src, destPos); +} + +void Screen::copyFrom(ASurface *src, const Common::Rect &bounds) { + addDirtyRect(bounds); + ASurface::copyFrom(src, bounds); +} + +void Screen::copyBuffer(Graphics::Surface *src) { + addDirtyRect(Common::Rect(0, 0, src->w, src->h)); + ASurface::copyBuffer(src); +} + void Screen::setPaletteCycle(int startCycle, int endCycle, int timer) { _startCycle = _cycleStart = startCycle; _endCycle = endCycle; diff --git a/engines/access/screen.h b/engines/access/screen.h index c43a03c9dc..1d93efbfee 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -88,6 +88,12 @@ public: virtual void restoreBlock(); virtual void drawRect(); + + virtual void copyFrom(ASurface *src, const Common::Point &destPos); + + virtual void copyFrom(ASurface *src, const Common::Rect &bounds); + + virtual void copyBuffer(Graphics::Surface *src); public: Screen(AccessEngine *vm); |