aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBastien Bouclet2010-11-29 20:57:54 +0000
committerBastien Bouclet2010-11-29 20:57:54 +0000
commita9617cbe2888be357d6dbee9899f34827d159b26 (patch)
treef88c0887563d7c002574eb1e5c52063fcf93133e /engines
parent2ac1fdad321a510fdb10f01f89c32818a06488a3 (diff)
downloadscummvm-rg350-a9617cbe2888be357d6dbee9899f34827d159b26.tar.gz
scummvm-rg350-a9617cbe2888be357d6dbee9899f34827d159b26.tar.bz2
scummvm-rg350-a9617cbe2888be357d6dbee9899f34827d159b26.zip
MOHAWK: Added dirty rects support for Myst
svn-id: r54625
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/graphics.cpp19
-rw-r--r--engines/mohawk/graphics.h2
2 files changed, 13 insertions, 8 deletions
diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp
index 5732c96d0d..dc637e8cc1 100644
--- a/engines/mohawk/graphics.cpp
+++ b/engines/mohawk/graphics.cpp
@@ -141,7 +141,6 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : GraphicsManager(), _vm(vm) {
// Initialize our buffer
_mainScreen = new Graphics::Surface();
_mainScreen->create(_vm->_system->getWidth(), _vm->_system->getHeight(), _pixelFormat.bytesPerPixel);
- _dirtyScreen = false;
}
MystGraphics::~MystGraphics() {
@@ -277,8 +276,8 @@ void MystGraphics::copyImageSectionToScreen(uint16 image, Common::Rect src, Comm
for (uint16 i = 0; i < height; i++)
memcpy(_mainScreen->getBasePtr(dest.left, i + dest.top), surface->getBasePtr(src.left, top + i), width * surface->bytesPerPixel);
- // Mark the screen as dirty
- _dirtyScreen = true;
+ // Add to the list of dirty rects
+ _dirtyRects.push_back(dest);
}
void MystGraphics::copyImageToScreen(uint16 image, Common::Rect dest) {
@@ -286,11 +285,17 @@ void MystGraphics::copyImageToScreen(uint16 image, Common::Rect dest) {
}
void MystGraphics::updateScreen() {
- if (_dirtyScreen) {
- // Only copy the buffer to the screen if it's dirty
- _vm->_system->copyRectToScreen((byte *)_mainScreen->pixels, _mainScreen->pitch, 0, 0, _mainScreen->w, _mainScreen->h);
+ // Only update the screen if there have been changes since last frame
+ if (!_dirtyRects.empty()) {
+
+ // Copy any modified area
+ for (uint i = 0; i < _dirtyRects.size(); i++) {
+ Common::Rect &r = _dirtyRects[i];
+ _vm->_system->copyRectToScreen((byte *)_mainScreen->getBasePtr(r.left, r.top), _mainScreen->pitch, r.left, r.top, r.width(), r.height());
+ }
+
_vm->_system->updateScreen();
- _dirtyScreen = false;
+ _dirtyRects.clear();
}
}
diff --git a/engines/mohawk/graphics.h b/engines/mohawk/graphics.h
index 6942aba4f4..ec5c01af75 100644
--- a/engines/mohawk/graphics.h
+++ b/engines/mohawk/graphics.h
@@ -131,7 +131,7 @@ private:
} _pictureFile;
Graphics::Surface *_mainScreen;
- bool _dirtyScreen;
+ Common::Array<Common::Rect> _dirtyRects;
Graphics::PixelFormat _pixelFormat;
};