aboutsummaryrefslogtreecommitdiff
path: root/engines/wage/design.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2015-12-18 18:45:28 +0100
committerEugene Sandulenko2015-12-27 15:40:53 +0100
commitb054e82dbe25063f5c83bd122830f756d32a2089 (patch)
treebca03a2cd131f854c5eb6fdfdd8bddc73ada7551 /engines/wage/design.cpp
parent8950bd52482e316f5d38e36332d6b1ea056fdd61 (diff)
downloadscummvm-rg350-b054e82dbe25063f5c83bd122830f756d32a2089.tar.gz
scummvm-rg350-b054e82dbe25063f5c83bd122830f756d32a2089.tar.bz2
scummvm-rg350-b054e82dbe25063f5c83bd122830f756d32a2089.zip
WAGE: Switched polygon drawing to generic
Diffstat (limited to 'engines/wage/design.cpp')
-rw-r--r--engines/wage/design.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 1388db974f..ff6ea496af 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -121,10 +121,13 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
void drawPixel(int x, int y, int color, void *data) {
plotData *p = (plotData *)data;
+ if (p->fillType > (*p->patterns).size())
+ return;
+
if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h)
*((byte *)p->surface->getBasePtr(x, y)) =
((*p->patterns)[p->fillType - 1][(y - p->y0) % 8] & (1 << (7 - (x - p->x0) % 8))) ?
- kColorBlack : kColorWhite;
+ color : kColorWhite;
}
void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
@@ -146,7 +149,6 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
- plotData pd;
//surface->setColor(Color.BLACK);
//in.readUint16BE();
@@ -162,12 +164,6 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
Common::Rect bbox(bx1, by1, bx2, by2);
warning("Bbox: %d, %d, %d, %d", bx1, by1, bx2, by2);
- pd.surface = surface;
- pd.patterns = &patterns;
- pd.fillType = fillType;
- pd.x0 = bx1;
- pd.y0 = by1;
-
numBytes -= 8;
int y1 = in.readSint16BE();
@@ -245,7 +241,15 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
//if (borderThickness != 1)
surface->setStroke(new BasicStroke(borderThickness - 0.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL));
*/
- patternThickPolygon(surface, patterns, xpoints, ypoints, npoints, bbox, borderFillType, fillType);
+ plotData pd;
+
+ pd.surface = surface;
+ pd.patterns = &patterns;
+ pd.fillType = fillType;
+ pd.x0 = bx1;
+ pd.y0 = by1;
+
+ drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixel, &pd);
// surface->setStroke(oldStroke);
// }
@@ -335,8 +339,8 @@ void Design::patternRect(Graphics::Surface *surface, Patterns &patterns, Common:
// Based on public-domain code by Darel Rex Finley, 2007
// http://alienryderflex.com/polygon_fill/
-void Design::patternThickPolygon(Graphics::Surface *surface, Patterns &patterns, int *polyX,
- int *polyY, int npoints, Common::Rect &bbox, byte borderFillType, byte fillType) {
+void Design::drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color,
+ void (*plotProc)(int, int, int, void *), void *data) {
int *nodeX = (int *)calloc(npoints, sizeof(int));
int i, j;
@@ -374,7 +378,7 @@ void Design::patternThickPolygon(Graphics::Surface *surface, Patterns &patterns,
nodeX[i] = MAX<int16>(nodeX[i], bbox.left);
nodeX[i + 1] = MIN<int16>(nodeX[i + 1], bbox.right);
- patternHLine(surface, patterns, fillType, nodeX[i], nodeX[i + 1], pixelY, bbox.left, bbox.top);
+ drawHLine(nodeX[i], nodeX[i + 1], pixelY, color, plotProc, data);
}
}
}
@@ -424,6 +428,14 @@ void Design::plotEllipseRect(Graphics::Surface *surface, Patterns &patterns,
}
}
+void Design::drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data) {
+ if (x1 > x2)
+ SWAP(x1, x2);
+
+ for (int x = x1; x < x2; x++)
+ (*plotProc)(x, y, color, data);
+}
+
void Design::patternHLine(Graphics::Surface *surface, Patterns &patterns, byte fillType, int x1, int x2, int y, int x0, int y0) {
if (x1 > x2)
SWAP(x1, x2);