Commit 7d412c71 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Fix Transorm Worker to shrink device bounds when doing scale-down

When doing a scale-down a great portion of the image becomes filled
with the default pixel. If the default pixel of a paint device is not
fully transparent, then the exactBounds() will not shrink automatically.
That is why we need to purge() all the default tiles of the paint device
here.

Note: the Crop visitor needs *not* the same stuff, since
      KisPaintDevice::crop() calls KisDataManager::setExtent() which
      explicitly drops all the tiles outside of the requested area.

Special thanks to Boud, who has found the real cause of the bug!

BUG:327860
parent fc3fd9c4
......@@ -525,6 +525,11 @@ void KisPaintDevice::crop(const QRect &rect)
m_d->currentStrategy()->crop(rect);
}
void KisPaintDevice::purgeDefaultPixels()
{
m_d->dataManager->purge(m_d->dataManager->extent());
}
void KisPaintDevice::setDefaultPixel(const quint8 *defPixel)
{
m_d->dataManager->setDefaultPixel(defPixel);
......
......@@ -227,6 +227,12 @@ public:
*/
void clear(const QRect & rc);
/**
* Frees the memory occupied by the pixels containing default
* values. The extents() and exactBounds() of the image will
* probably also shrink
*/
void purgeDefaultPixels();
/**
* Sets the default pixel. New data will be initialised with this pixel. The pixel is copied: the
......
......@@ -397,6 +397,12 @@ bool KisTransformWorker::run()
m_progressUpdater->setProgress(100);
}
/**
* Purge the tiles which might be left after scaling down the
* image
*/
m_dev->purgeDefaultPixels();
return true;
}
......
......@@ -297,6 +297,8 @@ void KisTiledDataManager::purge(const QRect& area)
foreach(KisTileSP tile, tilesToDelete) {
m_hashTable->deleteTile(tile);
}
recalculateExtent();
}
quint8* KisTiledDataManager::duplicatePixel(qint32 num, const quint8 *pixel)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment