diff options
author | Paul Gilbert | 2016-07-26 19:48:14 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-26 19:48:14 -0400 |
commit | 504cf6ecb688a3f1c65a857bffd527d8b0e6ba63 (patch) | |
tree | 0c0d96d4061c11850c851f0fc981c75a58c20515 /graphics/surface.h | |
parent | d8c28d15ae553d047b7e571f98727fa79ee143f3 (diff) | |
parent | e19922d181e775791f9105b8be7ff410770ede51 (diff) | |
download | scummvm-rg350-504cf6ecb688a3f1c65a857bffd527d8b0e6ba63.tar.gz scummvm-rg350-504cf6ecb688a3f1c65a857bffd527d8b0e6ba63.tar.bz2 scummvm-rg350-504cf6ecb688a3f1c65a857bffd527d8b0e6ba63.zip |
Merge branch 'master' into xeen
Diffstat (limited to 'graphics/surface.h')
-rw-r--r-- | graphics/surface.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/graphics/surface.h b/graphics/surface.h index aaa386b168..87c5f52503 100644 --- a/graphics/surface.h +++ b/graphics/surface.h @@ -24,9 +24,11 @@ #define GRAPHICS_SURFACE_H #include "common/scummsys.h" +#include "common/list.h" namespace Common { struct Rect; +struct Point; } #include "graphics/pixelformat.h" @@ -341,6 +343,72 @@ struct SharedPtrSurfaceDeleter { } }; +/** + * Stack-based flood fill algorithm for arbitrary Surfaces. + * + * It could be used in 2 ways. One is to fill the pixels of oldColor + * with fillColor. Second is when the surface stays intact but another + * surface with mask is created, where filled colors are marked with 255. + * + * Before running fill() or fillMask(), the initial pixels must be addSeed + * with addSeed() method. + */ +class FloodFill { +public: + /** + * Construct a simple Surface object. + * + * @param surface Input surface + * @param oldColor Color on the surface to change + * @param fillColor Color to fill with + */ + FloodFill(Surface *surface, uint32 oldColor, uint32 fillColor, bool maskMode = false); + ~FloodFill(); + + /** + * Add pixels to the fill queue. + * + * @param x The x coordinate of the pixel. + * @param y The x coordinate of the pixel. + */ + void addSeed(int x, int y); + + /** + * Fill the surface as requested. + * + * It uses pixels which were added with addSeed() method. + * + * @see addSeed + */ + void fill(); + + /** + * Fill the mask. The mask is a CLUT8 Surface with pixels 0 and 255. + * 255 means that the pixel has been filled. + * + * It uses pixels which were added with addSeed() method. + * + * @see addSeed + */ + void fillMask(); + + /** + * Get the resulting mask. + * + * @see fillMask + */ + Surface *getMask() { return _mask; } + +private: + Common::List<Common::Point *> _queue; + Surface *_surface; + Surface *_mask; + uint32 _oldColor, _fillColor; + byte *_visited; + int _w, _h; + + bool _maskMode; +}; } // End of namespace Graphics |