ZVISION: Convert _alphaDataEntries to a HashMap

So entries can be easily identified and removed if necessary
This commit is contained in:
RichieSams 2013-09-16 00:02:57 -05:00
parent 41afb2dd90
commit 7ce6823158
2 changed files with 23 additions and 16 deletions

View File

@ -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);
}

View File

@ -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