aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichieSams2013-09-16 00:02:57 -0500
committerRichieSams2013-09-16 00:02:57 -0500
commit7ce6823158122d0b1922e675eccf31fd5382f9ef (patch)
treec929809ae757de420287d302f3d4c1f9be687c28
parent41afb2dd90caa5dc09a688d253c119e28ef25318 (diff)
downloadscummvm-rg350-7ce6823158122d0b1922e675eccf31fd5382f9ef.tar.gz
scummvm-rg350-7ce6823158122d0b1922e675eccf31fd5382f9ef.tar.bz2
scummvm-rg350-7ce6823158122d0b1922e675eccf31fd5382f9ef.zip
ZVISION: Convert _alphaDataEntries to a HashMap
So entries can be easily identified and removed if necessary
-rw-r--r--engines/zvision/render_manager.cpp32
-rw-r--r--engines/zvision/render_manager.h7
2 files changed, 23 insertions, 16 deletions
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index a5c659d115..c25f670acf 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -111,25 +111,31 @@ void RenderManager::renderBackbufferToScreen() {
}
void RenderManager::processAlphaEntries() {
- for (Common::List<AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); iter++) {
+ // TODO: Add dirty rectangling support. AKA only draw an entry if the _backbufferDirtyRect intersects/contains the entry Rect
+
+ for (Common::HashMap<uint32, AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); iter++) {
uint32 destOffset = 0;
uint32 sourceOffset = 0;
- uint16 *backbufferPtr = (uint16 *)_backBuffer.getBasePtr((*iter).destX + _workingWindow.left, (*iter).destY + _workingWindow.top);
- uint16 *entryPtr = (uint16 *)(*iter).data->getPixels();
+ uint16 *backbufferPtr = (uint16 *)_backBuffer.getBasePtr((*iter)._value.destX + _workingWindow.left, (*iter)._value.destY + _workingWindow.top);
+ uint16 *entryPtr = (uint16 *)(*iter)._value.data->getPixels();
- for (int32 y = 0; y < (*iter).height; y++) {
- for (int32 x = 0; x < (*iter).width; x++) {
+ for (int32 y = 0; y < (*iter)._value.height; y++) {
+ for (int32 x = 0; x < (*iter)._value.width; x++) {
uint16 color = entryPtr[sourceOffset + x];
- if (color != (*iter).alphaColor) {
+ if (color != (*iter)._value.alphaColor) {
backbufferPtr[destOffset + x] = color;
}
}
- destOffset += _workingWidth;
- sourceOffset += (*iter).width;
+ destOffset += _backBuffer.w;
+ sourceOffset += (*iter)._value.width;
}
- _backBufferDirtyRect.extend(Common::Rect((*iter).destX + _workingWindow.left, (*iter).destY + _workingWindow.top, (*iter).destX + _workingWindow.left + (*iter).width, (*iter).destY + _workingWindow.top + (*iter).height));
+ if (_backBufferDirtyRect.isEmpty()) {
+ _backBufferDirtyRect = Common::Rect((*iter)._value.destX + _workingWindow.left, (*iter)._value.destY + _workingWindow.top, (*iter)._value.destX + _workingWindow.left + (*iter)._value.width, (*iter)._value.destY + _workingWindow.top + (*iter)._value.height);
+ } else {
+ _backBufferDirtyRect.extend(Common::Rect((*iter)._value.destX + _workingWindow.left, (*iter)._value.destY + _workingWindow.top, (*iter)._value.destX + _workingWindow.left + (*iter)._value.width, (*iter)._value.destY + _workingWindow.top + (*iter)._value.height));
+ }
}
}
@@ -324,7 +330,7 @@ void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, i
assert(_workingWindowDirtyRect.width() <= _workingWidth && _workingWindowDirtyRect.height() <= _workingHeight);
}
-void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor) {
+void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor, uint32 idNumber) {
AlphaDataEntry entry;
entry.alphaColor = alphaColor;
entry.data = new Graphics::Surface();
@@ -347,10 +353,10 @@ void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, i
sourceOffset += imageWidth;
}
- _alphaDataEntries.push_back(entry);
+ _alphaDataEntries[idNumber] = entry;
}
-Common::Rect RenderManager::renderTextToWorkingWindow(const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) {
+Common::Rect RenderManager::renderTextToWorkingWindow(uint32 idNumber, const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) {
AlphaDataEntry entry;
entry.alphaColor = 0;
entry.destX = destX;
@@ -361,7 +367,7 @@ Common::Rect RenderManager::renderTextToWorkingWindow(const Common::String &text
entry.width = entry.data->w;
entry.height = entry.data->h;
- _alphaDataEntries.push_back(entry);
+ _alphaDataEntries[idNumber] = entry;
return Common::Rect(destX, destY, destX + entry.width, destY + entry.height);
}
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 50d2d1076f..e7030b06fe 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -25,6 +25,7 @@
#include "common/types.h"
#include "common/rect.h"
+#include "common/hashmap.h"
#include "graphics/surface.h"
@@ -67,7 +68,7 @@ private:
// It's used for panorama/tilt warping and for clearing the workingWindow to a single color
Graphics::Surface _workingWindowBuffer;
Graphics::Surface _backBuffer;
- Common::List<AlphaDataEntry> _alphaDataEntries;
+ Common::HashMap<uint32, AlphaDataEntry> _alphaDataEntries;
Common::Rect _workingWindowDirtyRect;
Common::Rect _backBufferDirtyRect;
@@ -123,9 +124,9 @@ public:
void processAlphaEntries();
void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height);
- void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor);
+ void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor, uint32 idNumber);
- Common::Rect renderTextToWorkingWindow(const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight = -1, Graphics::TextAlign align = Graphics::kTextAlignLeft, bool wrap = true);
+ Common::Rect renderTextToWorkingWindow(uint32 idNumber, const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight = -1, Graphics::TextAlign align = Graphics::kTextAlignLeft, bool wrap = true);
/**
* Fills the entire workingWindow with the specified color. Internally, the color