aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/zvision/render_manager.cpp27
-rw-r--r--engines/zvision/render_manager.h3
-rw-r--r--engines/zvision/render_table.cpp17
-rw-r--r--engines/zvision/render_table.h2
4 files changed, 34 insertions, 15 deletions
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 7f796451f4..bd3e73563f 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -60,6 +60,10 @@ RenderManager::~RenderManager() {
}
void RenderManager::update(uint deltaTimeInMillis) {
+ // Clear the dirty rects from last frame
+ _workingWindowDirtyRect = Common::Rect();
+ _backBufferDirtyRect = Common::Rect();
+
// An inverse velocity of 0 would be infinitely fast, so we'll let 0 mean no velocity.
if (_backgroundInverseVelocity != 0) {
_accumulatedVelocityMilliseconds += deltaTimeInMillis;
@@ -78,16 +82,25 @@ void RenderManager::update(uint deltaTimeInMillis) {
}
void RenderManager::renderBackbufferToScreen() {
- RenderTable::RenderState state = _renderTable.getRenderState();
- if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- _renderTable.mutateImage((uint16 *)_workingWindowBuffer.getPixels(), (uint16 *)_backBuffer.getBasePtr(_workingWindow.left, _workingWindow.top), _backBuffer.w);
- } else {
- _backBuffer.copyRectToSurface(_workingWindowBuffer.getPixels(), _workingWindowBuffer.pitch, _workingWindow.left, _workingWindow.top, _workingWindowBuffer.w, _workingWindowBuffer.h);
+ if (!_workingWindowDirtyRect.isEmpty()) {
+ RenderTable::RenderState state = _renderTable.getRenderState();
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ _renderTable.mutateImage((uint16 *)_workingWindowBuffer.getPixels(), (uint16 *)_backBuffer.getBasePtr(_workingWindow.left + _workingWindowDirtyRect.left, _workingWindow.top + _workingWindowDirtyRect.top), _backBuffer.w, _workingWindowDirtyRect);
+ } else {
+ _backBuffer.copyRectToSurface(_workingWindowBuffer.getBasePtr(_workingWindowDirtyRect.left, _workingWindowDirtyRect.top), _workingWindowBuffer.pitch, _workingWindow.left + _workingWindowDirtyRect.left, _workingWindow.top + _workingWindowDirtyRect.top, _workingWindowDirtyRect.width(), _workingWindowDirtyRect.height());
+ }
+
+ // Translate the working window dirty rect to screen coords
+ _workingWindowDirtyRect.translate(_workingWindow.left, _workingWindow.top);
+ // Then extend the backbuffer dirty rect to contain it
+ _backBufferDirtyRect.extend(_workingWindowDirtyRect);
}
// TODO: Add menu rendering
- _system->copyRectToScreen(_backBuffer.getPixels(), _backBuffer.pitch, 0, 0, _backBuffer.w, _backBuffer.h);
+ if (!_backBufferDirtyRect.isEmpty()) {
+ _system->copyRectToScreen(_backBuffer.getBasePtr(_backBufferDirtyRect.left, _backBufferDirtyRect.top), _backBuffer.pitch, _backBufferDirtyRect.left, _backBufferDirtyRect.top, _backBufferDirtyRect.width(), _backBufferDirtyRect.height());
+ }
}
void RenderManager::clearWorkingWindowTo555Color(uint16 color) {
@@ -274,6 +287,8 @@ void RenderManager::renderRectToWorkingWindow(uint16 *buffer, int32 imageWidth,
destOffset += _workingWidth;
sourceOffset += imageWidth;
}
+
+ _workingWindowDirtyRect.extend(Common::Rect(destX, destY, destX + width, destY + height));
}
const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) {
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 07b2e854ae..fd36ab5730 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -57,6 +57,9 @@ private:
Graphics::Surface _workingWindowBuffer;
Graphics::Surface _backBuffer;
+ Common::Rect _workingWindowDirtyRect;
+ Common::Rect _backBufferDirtyRect;
+
/** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */
const int _workingWidth;
/** Height of the working window. Saved to prevent extraneous calls to _workingWindow.height() */
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index 3e7a86e348..5eb208eb8c 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -100,14 +100,15 @@ uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
return returnColor;
}
-void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth) {
- uint32 destColumnOffset = 0;
+void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth, const Common::Rect &subRect) {
+ uint32 destOffset = 0;
- for (uint32 y = 0; y < _numRows; y++) {
- uint32 sourceColumnOffset = y * _numColumns;
+ for (uint32 y = subRect.top; y < subRect.bottom; y++) {
+ uint32 sourceOffset = y * _numColumns;
- for (uint32 x = 0; x < _numColumns; x++) {
- uint32 index = sourceColumnOffset + x;
+ for (uint32 x = subRect.left; x < subRect.right; x++) {
+ uint32 normalizedX = x - subRect.left;
+ uint32 index = sourceOffset + x;
// RenderTable only stores offsets from the original coordinates
uint32 sourceYIndex = y + _internalBuffer[index].y;
@@ -119,10 +120,10 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 d
// Clamp the xIndex to the size of the image
sourceXIndex = CLIP<uint32>(sourceXIndex, 0, _numColumns - 1);
- destBuffer[destColumnOffset + x] = sourceBuffer[sourceYIndex * _numColumns + sourceXIndex];
+ destBuffer[destOffset + normalizedX] = sourceBuffer[sourceYIndex * _numColumns + sourceXIndex];
}
- destColumnOffset += destWidth;
+ destOffset += destWidth;
}
}
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index ba3c7d2f5d..7c8e7d6a2d 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -66,7 +66,7 @@ public:
const Common::Point convertWarpedCoordToFlatCoord(const Common::Point &point);
- void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth);
+ void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth, const Common::Rect &subRect);
void generateRenderTable();
void setPanoramaFoV(float fov);