diff options
-rw-r--r-- | graphics/surface.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/graphics/surface.cpp b/graphics/surface.cpp index 5f8796566c..699e1ccd22 100644 --- a/graphics/surface.cpp +++ b/graphics/surface.cpp @@ -508,6 +508,11 @@ FloodFill::FloodFill(Graphics::Surface *surface, uint32 oldColor, uint32 fillCol _mask = nullptr; _maskMode = maskMode; + if (_maskMode) { + _mask = new Graphics::Surface(); + _mask->create(_w, _h, Graphics::PixelFormat::createFormatCLUT8()); // Uses calloc() + } + _visited = (byte *)calloc(_w * _h, 1); } @@ -588,10 +593,13 @@ void FloodFill::fill() { } void FloodFill::fillMask() { - _mask = new Graphics::Surface(); - _mask->create(_w, _h, Graphics::PixelFormat::createFormatCLUT8()); // Uses calloc() _maskMode = true; + if (!_mask) { + _mask = new Graphics::Surface(); + _mask->create(_w, _h, Graphics::PixelFormat::createFormatCLUT8()); // Uses calloc() + } + fill(); } |