Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

update saveBox recompute logic of normal fill

Abel You2d5b2a780710
diff --git a/toonz/sources/tnztools/filltool.cpp b/toonz/sources/tnztools/filltool.cpp
index e1b3c4d45..a039b4f7f 100644
--- a/toonz/sources/tnztools/filltool.cpp
+++ b/toonz/sources/tnztools/filltool.cpp
@@ -408,7 +408,10 @@ public:
} else
r = image->getRaster();
if (m_params.m_fillType == ALL || m_params.m_fillType == AREAS) {
- recomputeSavebox = fill(r, m_params, 0, m_refImg);
+ TTileSaverCM32 saver = TTileSaverCM32(r, TRasterUndo::m_tiles);
+ fill(r, m_params, &saver);
+ recomputeSavebox =
+ !getImage()->getSavebox().contains(TRasterUndo::m_tiles->getBBox());
}
if (m_params.m_fillType == ALL || m_params.m_fillType == LINES) {
if (m_params.m_segment)
@@ -1072,7 +1075,9 @@ void doRefFill(const TImageP &img, const TRaster32P &refImg, const TPointD &pos,
// !autoPaintLines will temporary disable autopaint line feature
if (plt && hasAutoInks(plt) && autopaintLines) params.m_palette = plt;
if (params.m_fillType == ALL || params.m_fillType == AREAS) {
- recomputeSavebox = fill(ras, params, &tileSaver, refImg);
+ fill(ras, params, &tileSaver, refImg);
+ recomputeSavebox =
+ !ti->getSavebox().contains(tileSaver.getTileSet()->getBBox());
}
if (params.m_fillType == ALL || params.m_fillType == LINES) {
if (params.m_segment)
diff --git a/toonz/sources/toonzlib/fill.cpp b/toonz/sources/toonzlib/fill.cpp
index 01b521ca6..38bcb2ef8 100644
--- a/toonz/sources/toonzlib/fill.cpp
+++ b/toonz/sources/toonzlib/fill.cpp
@@ -4,6 +4,7 @@
#include "toonz/fill.h"
#include "toonz/ttilesaver.h"
+#include "toonz/ttileset.h"
#include "tpalette.h"
#include "tpixelutils.h"
#include "trastercm.h"
@@ -539,7 +540,7 @@ int getMostFrequentNeighborStyleId(TRasterCM32P ras,
//-----------------------------------------------------------------------------
} // namespace
//-----------------------------------------------------------------------------
-/*-- The return value is whether the saveBox has been updated or not. --*/
+/*-- Return true if fill processed --*/
bool fill(const TRasterCM32P &r, const FillParameters &params,
TTileSaverCM32 *saver, const TRaster32P &Ref) {
TPixelCM32 *pix, *limit, *pix0, *oldpix;
@@ -588,23 +589,6 @@ bool fill(const TRasterCM32P &r, const FillParameters &params,
fillDepth = adjustFillDepth(fillDepth);
- /*--Look at the colors in the four corners and update the saveBox if any of
- * the colors change. --*/
- TPixelCM32 borderIndex[4];
- TPixelCM32 *borderPix[4];
- pix = r->pixels(0);
- borderPix[0] = pix;
- borderIndex[0] = *pix;
- pix += r->getLx() - 1;
- borderPix[1] = pix;
- borderIndex[1] = *pix;
- pix = r->pixels(r->getLy() - 1);
- borderPix[2] = pix;
- borderIndex[2] = *pix;
- pix += r->getLx() - 1;
- borderPix[3] = pix;
- borderIndex[3] = *pix;
-
std::stack<FillSeed> seeds;
fillRow(r, p, xa, xb, paint, params.m_palette, saver, params.m_prevailing,
@@ -661,14 +645,7 @@ bool fill(const TRasterCM32P &r, const FillParameters &params,
if (refImagePut) TRop::eraseRefInks(r);
- bool saveBoxChanged = false;
- for (int i = 0; i < 4; i++) {
- if (!((*borderPix[i]) == borderIndex[i])) {
- saveBoxChanged = true;
- break;
- }
- }
- return saveBoxChanged;
+ return true;
}
//-----------------------------------------------------------------------------