aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kiewitz2009-10-08 19:14:58 +0000
committerMartin Kiewitz2009-10-08 19:14:58 +0000
commitf5ccaf7e29183d6e51456d5994eccfd35ff9a117 (patch)
tree66b95c575e518babead817ad130e14c687760a3e
parentd46aac8404f5212e6387a21530ce579298bc65f9 (diff)
downloadscummvm-rg350-f5ccaf7e29183d6e51456d5994eccfd35ff9a117.tar.gz
scummvm-rg350-f5ccaf7e29183d6e51456d5994eccfd35ff9a117.tar.bz2
scummvm-rg350-f5ccaf7e29183d6e51456d5994eccfd35ff9a117.zip
SCI/newgui: floodfill cleanup, pattern drawing: helper went private, clipping implemented
svn-id: r44792
-rw-r--r--engines/sci/gui/gui_gfx.cpp48
-rw-r--r--engines/sci/gui/gui_gfx.h11
-rw-r--r--engines/sci/gui/gui_picture.cpp2
3 files changed, 30 insertions, 31 deletions
diff --git a/engines/sci/gui/gui_gfx.cpp b/engines/sci/gui/gui_gfx.cpp
index c9fa5f01b2..c8ceaf9b87 100644
--- a/engines/sci/gui/gui_gfx.cpp
+++ b/engines/sci/gui/gui_gfx.cpp
@@ -890,8 +890,10 @@ void SciGuiGfx::Draw_Pattern(int16 x, int16 y, byte color, byte priority, byte c
y -= size; if (y < 0) y = 0;
x -= size; if (x < 0) x = 0;
- rect.top = y + _curPort->top; rect.left = x + _curPort->left;
+ rect.top = y; rect.left = x;
rect.setHeight((size*2)+1); rect.setWidth((size*2)+2);
+ OffsetRect(rect);
+ rect.clip(_screen->_width, _screen->_height);
if (code & SCI_PATTERN_CODE_RECTANGLE) {
// Rectangle
@@ -921,31 +923,27 @@ void SciGuiGfx::Draw_String(const char *text) {
}
// Do not replace w/ some generic code. This algo really needs to behave exactly as the one from sierra
-void SciGuiGfx::Pic_Fill(int16 x, int16 y, byte color, byte prio, byte control) {
+void SciGuiGfx::FloodFill(int16 x, int16 y, byte color, byte priority, byte control) {
Common::Stack<Common::Point> stack;
Common::Point p, p1;
- byte flag = _screen->getDrawingMask(color, prio, control), fmatch;
+ byte screenMask = _screen->getDrawingMask(color, priority, control), matchMask;
p.x = x + _curPort->left;
p.y = y + _curPort->top;
stack.push(p);
- // parameters check
- //if ((flag & 2 && prio == 0) || (flag & 3 && control == 0))
- // return;
-
- byte t_col = _screen->getVisual(p.x, p.y);
- byte t_pri = _screen->getPriority(p.x, p.y);
- byte t_con = _screen->getControl(p.x, p.y);
+ byte searchColor = _screen->getVisual(p.x, p.y);
+ byte searchPriority = _screen->getPriority(p.x, p.y);
+ byte searchControl = _screen->getControl(p.x, p.y);
int16 w, e, a_set, b_set;
// if in 1st point priority,control or color is already set to target, clear the flag
- if (flag & 1 && t_col == color)
- flag ^= 1;
- if (flag & 2 && t_pri == prio)
- flag ^= 2;
- if (flag & 4 && t_con == control)
- flag ^= 4;
- if (flag == 0)// nothing to fill
+ if (screenMask & SCI_SCREEN_MASK_VISUAL && searchColor == color)
+ screenMask ^= SCI_SCREEN_MASK_VISUAL;
+ if (screenMask & SCI_SCREEN_MASK_PRIORITY && searchPriority == priority)
+ screenMask ^= SCI_SCREEN_MASK_PRIORITY;
+ if (screenMask & SCI_SCREEN_MASK_CONTROL && searchControl == control)
+ screenMask ^= SCI_SCREEN_MASK_CONTROL;
+ if (screenMask == 0)// nothing to fill
return;
// hard borders for filling
@@ -955,20 +953,20 @@ void SciGuiGfx::Pic_Fill(int16 x, int16 y, byte color, byte prio, byte control)
int b = _curPort->rect.bottom + _curPort->top - 1;
while (stack.size()) {
p = stack.pop();
- if ((fmatch = _screen->isFillMatch(p.x, p.y, flag, t_col, t_pri, t_con)) == 0) // already filled
+ if ((matchMask = _screen->isFillMatch(p.x, p.y, screenMask, searchColor, searchPriority, searchControl)) == 0) // already filled
continue;
- _screen->putPixel(p.x, p.y, flag, color, prio, control);
+ _screen->putPixel(p.x, p.y, screenMask, color, priority, control);
w = p.x;
e = p.x;
// moving west and east pointers as long as there is a matching color to fill
- while (w > l && (fmatch == _screen->isFillMatch(w - 1, p.y, flag, t_col, t_pri, t_con)))
- _screen->putPixel(--w, p.y, fmatch, color, prio, control);
- while (e < r && (fmatch == _screen->isFillMatch(e + 1, p.y, flag, t_col, t_pri, t_con)))
- _screen->putPixel(++e, p.y, fmatch, color, prio, control);
+ while (w > l && (matchMask == _screen->isFillMatch(w - 1, p.y, screenMask, searchColor, searchPriority, searchControl)))
+ _screen->putPixel(--w, p.y, matchMask, color, priority, control);
+ while (e < r && (matchMask == _screen->isFillMatch(e + 1, p.y, screenMask, searchColor, searchPriority, searchControl)))
+ _screen->putPixel(++e, p.y, matchMask, color, priority, control);
// checking lines above and below for possible flood targets
a_set = b_set = 0;
while (w <= e) {
- if (p.y > t && (fmatch == _screen->isFillMatch(w, p.y - 1, flag, t_col, t_pri, t_con))) { // one line above
+ if (p.y > t && (matchMask == _screen->isFillMatch(w, p.y - 1, screenMask, searchColor, searchPriority, searchControl))) { // one line above
if (a_set == 0) {
p1.x = w;
p1.y = p.y - 1;
@@ -978,7 +976,7 @@ void SciGuiGfx::Pic_Fill(int16 x, int16 y, byte color, byte prio, byte control)
} else
a_set = 0;
- if (p.y < b && (fmatch == _screen->isFillMatch(w, p.y + 1, flag, t_col, t_pri, t_con))) { // one line below
+ if (p.y < b && (matchMask == _screen->isFillMatch(w, p.y + 1, screenMask, searchColor, searchPriority, searchControl))) { // one line below
if (b_set == 0) {
p1.x = w;
p1.y = p.y + 1;
diff --git a/engines/sci/gui/gui_gfx.h b/engines/sci/gui/gui_gfx.h
index 6ddd6bd55e..26261aab75 100644
--- a/engines/sci/gui/gui_gfx.h
+++ b/engines/sci/gui/gui_gfx.h
@@ -92,13 +92,9 @@ public:
void RestoreBits(GuiMemoryHandle memoryHandle);
void drawLine(int16 left, int16 top, int16 right, int16 bottom, byte color, byte prio, byte control);
- void Draw_Box(Common::Rect box, byte color, byte prio, byte control);
- void Draw_TexturedBox(Common::Rect box, byte color, byte prio, byte control, byte texture);
- void Draw_Circle(Common::Rect box, byte size, byte color, byte prio, byte control);
- void Draw_TexturedCircle(Common::Rect box, byte size, byte color, byte prio, byte control, byte texture);
void Draw_Pattern(int16 x, int16 y, byte pic_color, byte pic_priority, byte pic_control, byte code, byte texture);
void Draw_String(const char *text);
- void Pic_Fill(int16 x, int16 y, byte color, byte prio, byte control);
+ void FloodFill(int16 x, int16 y, byte color, byte prio, byte control);
void drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, GuiResourceId paletteId);
void drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo);
@@ -124,6 +120,11 @@ private:
void DrawText(const char *str, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor);
void ShowText(const char *str, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor);
+ void Draw_Box(Common::Rect box, byte color, byte prio, byte control);
+ void Draw_TexturedBox(Common::Rect box, byte color, byte prio, byte control, byte texture);
+ void Draw_Circle(Common::Rect box, byte size, byte color, byte prio, byte control);
+ void Draw_TexturedCircle(Common::Rect box, byte size, byte color, byte prio, byte control, byte texture);
+
EngineState *_s;
SciGuiScreen *_screen;
SciGuiPalette *_palette;
diff --git a/engines/sci/gui/gui_picture.cpp b/engines/sci/gui/gui_picture.cpp
index 0a4da6acc4..fbdaea01a6 100644
--- a/engines/sci/gui/gui_picture.cpp
+++ b/engines/sci/gui/gui_picture.cpp
@@ -380,7 +380,7 @@ void SciGuiPicture::drawVectorData(byte *data, int dataSize) {
case PIC_OP_FILL: //fill
while (vectorIsNonOpcode(data[curPos])) {
vectorGetAbsCoords(data, curPos, x, y);
- _gfx->Pic_Fill(x, y, pic_color, pic_priority, pic_control);
+ _gfx->FloodFill(x, y, pic_color, pic_priority, pic_control);
}
break;