Skip to content

Commit

Permalink
WAGE: Remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Jan 4, 2016
1 parent 9d09466 commit 0aaab27
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 53 deletions.
60 changes: 16 additions & 44 deletions engines/wage/design.cpp
Expand Up @@ -78,7 +78,7 @@ Design::~Design() {
delete _surface;
}

void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, int x, int y) {
void Design::paint(Graphics::Surface *surface, Patterns &patterns, int x, int y) {
Common::MemoryReadStream in(_data, _len);
Common::Rect r(0, 0, _bounds->width(), _bounds->height());
bool needRender = false;
Expand All @@ -91,10 +91,6 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, in
needRender = true;
}

if (mask) {
_surface->fillRect(r, kColorWhite);
}

#if 0
plotData pd(_surface, &patterns, 8, 1);
int x1 = 50, y1 = 50, x2 = 200, y2 = 200, borderThickness = 30;
Expand Down Expand Up @@ -129,20 +125,20 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, in
debug(8, "fill: %d borderFill: %d border: %d type: %d", fillType, borderFillType, borderThickness, type);
switch (type) {
case 4:
drawRect(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
drawRect(_surface, in, patterns, fillType, borderThickness, borderFillType);
break;
case 8:
drawRoundRect(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
drawRoundRect(_surface, in, patterns, fillType, borderThickness, borderFillType);
break;
case 12:
drawOval(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
drawOval(_surface, in, patterns, fillType, borderThickness, borderFillType);
break;
case 16:
case 20:
drawPolygon(_surface, in, mask, patterns, fillType, borderThickness, borderFillType);
drawPolygon(_surface, in, patterns, fillType, borderThickness, borderFillType);
break;
case 24:
drawBitmap(_surface, in, mask);
drawBitmap(_surface, in);
break;
default:
warning("Unknown type => %d", type);
Expand Down Expand Up @@ -211,7 +207,7 @@ void drawPixelPlain(int x, int y, int color, void *data) {
*((byte *)p->surface->getBasePtr(x, y)) = (byte)color;
}

void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
int16 y1 = in.readSint16BE();
int16 x1 = in.readSint16BE();
Expand All @@ -223,18 +219,11 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
if (y1 > y2)
SWAP(y1, y2);

Common::Rect outer(x1, y1, x2, y2);

Common::Rect r(x1, y1, x2, y2);
plotData pd(surface, &patterns, fillType, 1);

if (mask) {
drawFilledRect(outer, kColorBlack, drawPixelPlain, &pd);
return;
}
Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness);

if (fillType <= patterns.size())
drawFilledRect(outer, kColorBlack, drawPixel, &pd);
drawFilledRect(r, kColorBlack, drawPixel, &pd);

pd.fillType = borderFillType;
pd.thickness = borderThickness;
Expand All @@ -247,7 +236,7 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m
}
}

void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
int16 y1 = in.readSint16BE();
int16 x1 = in.readSint16BE();
Expand All @@ -260,26 +249,20 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
if (y1 > y2)
SWAP(y1, y2);

Common::Rect outer(x1, y1, x2, y2);

Common::Rect r(x1, y1, x2, y2);
plotData pd(surface, &patterns, fillType, 1);

if (mask) {
drawRoundRect(outer, arc, kColorBlack, true, drawPixelPlain, &pd);
return;
}

if (fillType <= patterns.size())
drawRoundRect(outer, arc/2, kColorBlack, true, drawPixel, &pd);
drawRoundRect(r, arc/2, kColorBlack, true, drawPixel, &pd);

pd.fillType = borderFillType;
pd.thickness = borderThickness;

if (borderThickness > 0 && borderFillType <= patterns.size())
drawRoundRect(outer, arc/2, kColorBlack, false, drawPixel, &pd);
drawRoundRect(r, arc/2, kColorBlack, false, drawPixel, &pd);
}

void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {

byte ignored = in.readSint16BE(); // ignored
Expand Down Expand Up @@ -339,11 +322,6 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo

plotData pd(surface, &patterns, fillType, 1);

if (mask) {
drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixelPlain, &pd);
return;
}

if (fillType <= patterns.size()) {
drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixel, &pd);
}
Expand All @@ -359,20 +337,14 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
free(ypoints);
}

void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
int16 y1 = in.readSint16BE();
int16 x1 = in.readSint16BE();
int16 y2 = in.readSint16BE();
int16 x2 = in.readSint16BE();

plotData pd(surface, &patterns, fillType, 1);

if (mask) {
drawEllipse(x1, y1, x2, y2, true, drawPixelPlain, &pd);
return;
}

if (fillType <= patterns.size())
drawEllipse(x1, y1, x2-1, y2-1, true, drawPixel, &pd);

Expand All @@ -383,7 +355,7 @@ void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool m
drawEllipse(x1, y1, x2-1, y2-1, false, drawPixel, &pd);
}

void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask) {
void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in) {
int numBytes = in.readSint16BE();
int y1 = in.readSint16BE();
int x1 = in.readSint16BE();
Expand Down
12 changes: 6 additions & 6 deletions engines/wage/design.h
Expand Up @@ -67,7 +67,7 @@ class Design {
return _bounds;
}

void paint(Graphics::Surface *canvas, Patterns &patterns, bool mask, int x, int y);
void paint(Graphics::Surface *canvas, Patterns &patterns, int x, int y);
bool isPointOpaque(int x, int y);
static void drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType);
static void drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType);
Expand All @@ -79,15 +79,15 @@ class Design {
Graphics::Surface *_surface;

private:
void drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
void drawRect(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
void drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
void drawOval(Graphics::Surface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);
void drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask);
void drawBitmap(Graphics::Surface *surface, Common::ReadStream &in);

void drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data);
static void drawRoundRect(Common::Rect &rect, int arc, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data);
Expand Down
6 changes: 3 additions & 3 deletions engines/wage/entities.cpp
Expand Up @@ -126,16 +126,16 @@ void Scene::paint(Graphics::Surface *surface, int x, int y) {
Common::Rect r(x + 5, y + 5, _design->getBounds()->width() + x - 10, _design->getBounds()->height() + y - 10);
surface->fillRect(r, kColorWhite);

_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false, x, y);
_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);

for (Common::List<Obj *>::const_iterator it = _objs.begin(); it != _objs.end(); ++it) {
debug(2, "paining Obj: %s", (*it)->_name.c_str());
(*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false, x, y);
(*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);
}

for (Common::List<Chr *>::const_iterator it = _chrs.begin(); it != _chrs.end(); ++it) {
debug(2, "paining Chr: %s", (*it)->_name.c_str());
(*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false, x, y);
(*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);
}
}

Expand Down

0 comments on commit 0aaab27

Please sign in to comment.