diff options
author | Eugene Sandulenko | 2016-06-02 23:44:43 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-06-03 00:45:56 +0200 |
commit | 531b190d5974f2bb396a19cd4869020ce2669c3a (patch) | |
tree | 64aceb68b7e143a7dc1d7e276cac512c923a5d9a /engines | |
parent | 2c7976e4e94d52bbd27a07eba8ae15379977189b (diff) | |
download | scummvm-rg350-531b190d5974f2bb396a19cd4869020ce2669c3a.tar.gz scummvm-rg350-531b190d5974f2bb396a19cd4869020ce2669c3a.tar.bz2 scummvm-rg350-531b190d5974f2bb396a19cd4869020ce2669c3a.zip |
GRAPHICS: Added FloodFill class to Surface.
Moved from WAGE engine and is using stack-based classic floodfill
implementation.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wage/design.cpp | 54 | ||||
-rw-r--r-- | engines/wage/design.h | 15 |
2 files changed, 2 insertions, 67 deletions
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp index eda28df159..f2a8aba812 100644 --- a/engines/wage/design.cpp +++ b/engines/wage/design.cpp @@ -422,7 +422,7 @@ void Design::drawBitmap(Graphics::ManagedSurface *surface, Common::SeekableReadS int x2 = in.readSint16BE(); int w = x2 - x1; int h = y2 - y1; - Graphics::ManagedSurface tmp; + Graphics::Surface tmp; tmp.create(w, h, Graphics::PixelFormat::createFormatCLUT8()); @@ -477,7 +477,7 @@ void Design::drawBitmap(Graphics::ManagedSurface *surface, Common::SeekableReadS if (_boundsCalculationMode) return; - FloodFill ff(&tmp, kColorWhite, kColorGreen); + Graphics::FloodFill ff(&tmp, kColorWhite, kColorGreen); for (int yy = 0; yy < h; yy++) { ff.addSeed(0, yy); ff.addSeed(w - 1, yy); @@ -541,54 +541,4 @@ void Design::drawVLine(Graphics::ManagedSurface *surface, int x, int y1, int y2, Graphics::drawVLine(x, y1, y2, color, drawPixel, &pd); } -FloodFill::FloodFill(Graphics::ManagedSurface *surface, byte color1, byte color2) { - _surface = surface; - _color1 = color1; - _color2 = color2; - _w = surface->w; - _h = surface->h; - - _visited = (byte *)calloc(_w * _h, 1); -} - -FloodFill::~FloodFill() { - while(!_queue.empty()) { - Common::Point *p = _queue.front(); - - delete p; - _queue.pop_front(); - } - - free(_visited); -} - -void FloodFill::addSeed(int x, int y) { - byte *p; - - if (x >= 0 && x < _w && y >= 0 && y < _h) { - if (!_visited[y * _w + x] && *(p = (byte *)_surface->getBasePtr(x, y)) == _color1) { - _visited[y * _w + x] = 1; - *p = _color2; - - Common::Point *pt = new Common::Point(x, y); - - _queue.push_back(pt); - } - } -} - -void FloodFill::fill() { - while (!_queue.empty()) { - Common::Point *p = _queue.front(); - _queue.pop_front(); - addSeed(p->x , p->y - 1); - addSeed(p->x - 1, p->y ); - addSeed(p->x , p->y + 1); - addSeed(p->x + 1, p->y ); - - delete p; - } -} - - } // End of namespace Wage diff --git a/engines/wage/design.h b/engines/wage/design.h index 9b0231ca96..86225c9224 100644 --- a/engines/wage/design.h +++ b/engines/wage/design.h @@ -100,21 +100,6 @@ private: void drawBitmap(Graphics::ManagedSurface *surface, Common::SeekableReadStream &in); }; -class FloodFill { -public: - FloodFill(Graphics::ManagedSurface *surface, byte color1, byte color2); - ~FloodFill(); - void addSeed(int x, int y); - void fill(); - -private: - Common::List<Common::Point *> _queue; - Graphics::ManagedSurface *_surface; - byte _color1, _color2; - byte *_visited; - int _w, _h; -}; - } // End of namespace Wage #endif |