Commit 3e9e1e5d authored by Boudewijn Rempt's avatar Boudewijn Rempt

Use QVector<QRect> instead of QRection, following API change in KisPainter

QRegion is dangerous, slow and degenerates into scanlines way too
quickly. Use QVector<QRect> instead and hope Dmitry is right that we
never generate overlapping QRects for updating.
parent 0f86c7f5
......@@ -78,7 +78,6 @@ void KisFloodFillBenchmark::benchmarkFlood()
QBENCHMARK
{
QRegion dirty;
KisFillPainter fillPainter(m_device);
//setupPainter(&fillPainter);
fillPainter.setBounds( QRect(0,0,GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT) );
......@@ -99,8 +98,6 @@ void KisFloodFillBenchmark::benchmarkFlood()
// fill twice
fillPainter.fillColor(1, 1, 0);
dirty = fillPainter.takeDirtyRegion();
fillPainter.deleteTransaction();
}
......
......@@ -40,10 +40,10 @@
void KisGradientBenchmark::initTestCase()
{
m_colorSpace = KoColorSpaceRegistry::instance()->rgb8();
m_colorSpace = KoColorSpaceRegistry::instance()->rgb8();
m_device = new KisPaintDevice(m_colorSpace);
m_color = KoColor(m_colorSpace);
m_color.fromQColor(QColor(0,0,0,0)); // default pixel
m_device->fill( 0,0,GMP_IMAGE_WIDTH, GMP_IMAGE_HEIGHT,m_color.data() );
}
......@@ -54,7 +54,7 @@ void KisGradientBenchmark::benchmarkGradient()
KoColor bg(m_colorSpace);
fg.fromQColor(Qt::blue);
bg.fromQColor(Qt::black);
QBENCHMARK
{
QLinearGradient grad;
......@@ -62,7 +62,6 @@ void KisGradientBenchmark::benchmarkGradient()
grad.setColorAt(1.0, Qt::red);
KoAbstractGradient* kograd = KoStopGradient::fromQGradient(&grad);
Q_ASSERT(kograd);
QRegion dirty;
KisGradientPainter fillPainter(m_device);
//setupPainter(&fillPainter);
fillPainter.setBounds( QRect(0,0,GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT) );
......@@ -74,13 +73,12 @@ void KisGradientBenchmark::benchmarkGradient()
fillPainter.setOpacity(OPACITY_OPAQUE_U8);
// default
fillPainter.setCompositeOp(COMPOSITE_OVER);
fillPainter.paintGradient(QPointF(0,0), QPointF(3000,3000), KisGradientPainter::GradientShapeBiLinear, KisGradientPainter::GradientRepeatNone, true, false, 0, 0, GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT);
dirty = fillPainter.takeDirtyRegion();
fillPainter.deleteTransaction();
}
// uncomment this to see the output
QImage out = m_device->convertToQImage(m_colorSpace->profile(),0,0,GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT);
out.save("fill_output.png");
......
......@@ -109,7 +109,7 @@ bool KisIndirectPaintingSupport::hasTemporaryTarget() const
return d->temporaryTarget;
}
void KisIndirectPaintingSupport::mergeToLayer(KisLayerSP layer, const QRegion &region, const QString &transactionText)
void KisIndirectPaintingSupport::mergeToLayer(KisLayerSP layer, const QVector<QRect> &region, const QString &transactionText)
{
/**
* We do not apply selection here, because it has already
......@@ -125,7 +125,7 @@ void KisIndirectPaintingSupport::mergeToLayer(KisLayerSP layer, const QRegion &r
gc.beginTransaction(transactionText);
}
foreach(const QRect& rc, region.rects()) {
foreach(const QRect &rc, region) {
gc.bitBlt(rc.topLeft(), d->temporaryTarget, rc);
}
d->temporaryTarget = 0;
......
......@@ -52,7 +52,7 @@ public:
* Writes the temporary target into the paint device of the layer.
* This action will lock the temporary target itself.
*/
void mergeToLayer(KisLayerSP layer, const QRegion &region,
void mergeToLayer(KisLayerSP layer, const QVector<QRect> &region,
const QString &transactionText);
/**
......@@ -65,7 +65,7 @@ public:
/**
* Unlock the temporary target
*
*
* \see lockTemporaryTarget()
*/
void unlockTemporaryTarget() const;
......
......@@ -321,11 +321,11 @@ void KisNode::setDirty()
setDirty(extent());
}
void KisNode::setDirty(const QRegion & region)
void KisNode::setDirty(const QVector<QRect> &region)
{
if (region.isEmpty()) return;
foreach(const QRect & rc, region.rects()) {
foreach(const QRect &rc, region) {
setDirty(rc);
}
}
......
......@@ -110,7 +110,7 @@ public:
* this percolates up to parent nodes all the way to the root
* node, if propagate is true;
*/
virtual void setDirty(const QRegion & region);
virtual void setDirty(const QVector<QRect> & region);
/**
* Some filters will cause a change of pixels those are outside
......@@ -128,7 +128,7 @@ public:
* See \ref changeRect
*/
virtual QRect needRect(const QRect &rect, PositionToFilthy pos = N_FILTHY) const;
virtual void setSystemLocked(bool l, bool update = true);
public: // Graph methods
......
......@@ -169,10 +169,11 @@ public:
KisNodeWSP parent;
KisDefaultBoundsSP defaultBounds;
PaintDeviceCache cache;
qint32 x;
qint32 y;
KoColorSpace* colorSpace;
PaintDeviceCache cache;
};
KisPaintDevice::KisPaintDevice(const KoColorSpace * colorSpace, const QString& name)
......@@ -216,13 +217,13 @@ void KisPaintDevice::init(KisDataManagerSP explicitDataManager,
}
else {
const qint32 pixelSize = colorSpace->pixelSize();
quint8* defaultPixel = new quint8[colorSpace->pixelSize()];
colorSpace->fromQColor(Qt::transparent, defaultPixel);
m_datamanager = new KisDataManager(pixelSize, defaultPixel);
delete[] defaultPixel;
Q_CHECK_PTR(m_datamanager);
}
m_d->cache.setupCache();
......@@ -303,11 +304,14 @@ void KisPaintDevice::setDirty(const QRect & rc)
m_d->parent->setDirty(rc);
}
void KisPaintDevice::setDirty(const QRegion & region)
void KisPaintDevice::setDirty(const QVector<QRect> &rects)
{
m_d->cache.invalidate();
if (m_d->parent.isValid())
m_d->parent->setDirty(region);
if (m_d->parent.isValid()) {
foreach(const QRect &rc, rects) {
m_d->parent->setDirty(rc);
}
}
}
void KisPaintDevice::setDirty()
......
......@@ -545,10 +545,10 @@ public:
virtual void setDirty(const QRect & rc);
/**
* Add the specified region to the parent layer's dirty region
* (if there is a parent layer)
* Add the specified rects to the parent layer's set of dirty rects
* (if there's a parent layer)
*/
virtual void setDirty(const QRegion & region);
virtual void setDirty(const QVector<QRect> &rc);
/**
* Set the parent layer completely dirty, if this paint device has
......
......@@ -374,7 +374,7 @@ public:
* The methods in this class do not tell the paintdevice to update, but they calculate the
* dirty area. This method returns this dirty area and resets it.
*/
void takeDirtyRegion();
QVector<QRect> takeDirtyRegion();
/**
* Paint a line that connects the dots in points
......@@ -661,7 +661,7 @@ public:
* Add the r to the current dirty rect, and return the vector
* of dirty rects after adding r to it.
*/
QVector<QRect> addDirtyRect(const QRect & r);
void addDirtyRect(const QRect & r);
/**
* Reset the selection to the given selection. All painter actions will be
......
......@@ -127,7 +127,7 @@ void KisRecordedPaintAction::toXML(QDomDocument& doc, QDomElement& elt, KisRecor
// compositeOp
elt.setAttribute("compositeOp", d->compositeOp);
// Save stroke style
switch(d->strokeStyle)
{
......@@ -298,7 +298,7 @@ void KisRecordedPaintAction::play(KisNodeSP node, const KisPlayInfo& info, KoUpd
painter->setPattern(d->pattern);
painter->setGradient(d->gradient);
painter->setGenerator(d->generator);
playPaint(info, painter);
if (!d->paintIncremental) {
......@@ -306,8 +306,7 @@ void KisRecordedPaintAction::play(KisNodeSP node, const KisPlayInfo& info, KoUpd
painter2.setCompositeOp(d->compositeOp);
painter2.setOpacity(d->opacity * 255);
QRegion r = painter->takeDirtyRegion();
QVector<QRect> dirtyRects = r.rects();
QVector<QRect> dirtyRects = painter->takeDirtyRegion();
QVector<QRect>::iterator it = dirtyRects.begin();
QVector<QRect>::iterator end = dirtyRects.end();
while (it != end) {
......@@ -345,7 +344,7 @@ void KisRecordedPaintActionFactory::setupPaintAction(KisRecordedPaintAction* act
KoColor bC = backgroundColorFromXML(elt);
KoColor fC = paintColorFromXML(elt);
action->setName(name);
action->setBackgroundColor(bC);
action->setPaintColor(fC);
......@@ -353,7 +352,7 @@ void KisRecordedPaintActionFactory::setupPaintAction(KisRecordedPaintAction* act
action->setPaintIncremental(paintIncremental);
action->setCompositeOp(compositeOp);
// Load stroke style
QString strokeAttr = elt.attribute("strokeStyle", "None");
if (strokeAttr == "Brush" )
......
......@@ -24,7 +24,7 @@
#include <QMouseEvent>
#include <QPaintEvent>
#include <QRectF>
#include <QRegion>
#include <QVector>
#include <QResizeEvent>
#include <QTabletEvent>
#include <kundo2command.h>
......@@ -182,10 +182,12 @@ void MixerCanvas::paintEvent(QPaintEvent *event)
QFrame::paintEvent(event);
}
void MixerCanvas::updateCanvas(const QRegion& region)
void MixerCanvas::updateCanvas(const QVector<QRect>& region)
{
m_dirty = true;
update(region.boundingRect());
foreach(const QRect &rc, region) {
update(rc);
}
}
void MixerCanvas::slotClear()
......
......@@ -22,6 +22,7 @@
#define MIXERCANVAS_H_
#include <QFrame>
#include <QVector>
#include <KoCanvasBase.h>
#include <kis_types.h>
......@@ -30,8 +31,8 @@ class QPoint;
class QImage;
class QMouseEvent;
class QPaintEvent;
class QRect;
class QRectF;
class QRegion;
class QResizeEvent;
class QTabletEvent;
class KUndo2Command;
......@@ -63,7 +64,7 @@ public:
QWidget *canvasWidget() { return this; }
const QWidget *canvasWidget() const { return this; }
void updateCanvas(const QRegion &region);
void updateCanvas(const QVector<QRect> &region);
KoColor currentColorAt(QPoint pos);
......
......@@ -238,7 +238,7 @@ void MixerTool::mouseReleaseEvent(KoPointerEvent *event)
m_d->mixer->resourceManager()->setResource(KoCanvasResource::ForegroundColor, event->pos());
}
void MixerTool::setDirty(const QRegion& region)
void MixerTool::setDirty(const QVector<QRect>& region)
{
m_d->mixer->updateCanvas(region);
}
......
......@@ -23,9 +23,11 @@
#include <KoToolBase.h>
#include <QVector>
#include <QRect>
class KoPointerEvent;
class MixerCanvas;
class QRegion;
class KisPaintInformation;
class MixerTool : public KoToolBase
......@@ -47,7 +49,7 @@ public:
public:
void setDirty(const QRegion &region);
void setDirty(const QVector<QRect> &region);
// KoToolBase Implementation.
......
......@@ -77,7 +77,7 @@ void KisToolBrush::timeoutPaint()
Q_ASSERT(currentPaintOpPreset()->settings()->isAirbrushing());
if (currentImage() && m_painter) {
paintAt(m_previousPaintInformation);
QRegion r = m_painter->takeDirtyRegion();
QVector<QRect> r = m_painter->takeDirtyRegion();
dbgPlugins << "Timeout paint dirty region:" << r;
currentNode()->setDirty(r);
}
......@@ -90,7 +90,7 @@ void KisToolBrush::initPaint(KoPointerEvent *e)
m_rate = currentPaintOpPreset()->settings()->rate();
m_isAirbrushing = currentPaintOpPreset()->settings()->isAirbrushing();
if (!m_painter) {
warnKrita << "Didn't create a painter! Something is wrong!";
return;
......
......@@ -70,7 +70,7 @@ void KisToolEllipse::finishEllipse(const QRectF& rect)
painter.paintEllipse(rect);
painter.endTransaction(image()->undoAdapter());
QRegion bound = painter.takeDirtyRegion();
QVector<QRect> bound = painter.takeDirtyRegion();
device->setDirty(bound);
notifyModified();
} else {
......
......@@ -99,7 +99,7 @@ bool KisToolFill::flood(int startX, int startY)
KoProgressUpdater * updater = canvas->view()->createProgressUpdater(KoProgressUpdater::Unthreaded);
updater->start(100, i18n("Flood Fill"));
QRegion dirty;
QVector<QRect> dirty;
if (m_fillOnlySelection && selection) {
QRect rc = selection->selectedRect();
......@@ -126,10 +126,8 @@ bool KisToolFill::flood(int startX, int startY)
m_painter->beginTransaction(i18n("Fill"));
QVector<QRect> rects = dirty.rects();
QVector<QRect>::iterator it = rects.begin();
QVector<QRect>::iterator end = rects.end();
QVector<QRect>::iterator it = dirty.begin();
QVector<QRect>::iterator end = dirty.end();
m_painter->setCompositeOp(m_compositeOp);
m_painter->setOpacity(m_opacity);
......
......@@ -86,13 +86,13 @@ QWidget* KisToolLine::createOptionWidget()
m_cbRotation = new QCheckBox(i18n("Rotation"));
m_cbTangPressure = new QCheckBox(i18n("Tangential Pressure"));
m_bnVaryingEnds = new QPushButton(i18n("Varying End-Points"));
m_cbPressure->setChecked(true);
m_cbTilt->setChecked(true);
m_cbRotation->setChecked(true);
m_cbTangPressure->setChecked(true);
m_bnVaryingEnds->setCheckable(true);
addOptionWidgetOption(m_cbPressure);
addOptionWidgetOption(m_cbTilt);
addOptionWidgetOption(m_cbRotation);
......@@ -104,7 +104,7 @@ QWidget* KisToolLine::createOptionWidget()
void KisToolLine::paint(QPainter& gc, const KoViewConverter &converter)
{
Q_UNUSED(converter);
if (mode() == KisTool::PAINT_MODE) {
paintLine(gc, QRect());
}
......@@ -117,7 +117,7 @@ void KisToolLine::mousePressEvent(KoPointerEvent *event)
Qt::LeftButton, Qt::NoModifier)) {
setMode(KisTool::PAINT_MODE);
m_startPos = KisPaintInformation(
convertToPixelCoord(event),
PRESSURE_DEFAULT,
......@@ -154,7 +154,7 @@ void KisToolLine::mouseMoveEvent(KoPointerEvent *event)
} else {
m_endPos.setPos(pos);
}
m_maxPressure = qMax(m_maxPressure, float(pressureToCurve(event->pressure())));
updatePreview();
}
......@@ -171,7 +171,7 @@ void KisToolLine::mouseReleaseEvent(KoPointerEvent *event)
updatePreview();
QPointF pos = convertToPixelCoord(event);
if(m_bnVaryingEnds->isChecked()) {
m_endPos = KisPaintInformation(
m_endPos.pos(),
......@@ -196,7 +196,7 @@ void KisToolLine::mouseReleaseEvent(KoPointerEvent *event)
if (m_startPos.pos() == m_endPos.pos())
return;
if(m_cbPressure->isChecked()) {
m_startPos.setPressure(m_maxPressure);
m_endPos.setPressure(m_maxPressure);
......@@ -225,7 +225,7 @@ void KisToolLine::mouseReleaseEvent(KoPointerEvent *event)
setupPainter(m_painter);
m_painter->paintLine(m_startPos, m_endPos);
QRegion dirtyRegion = m_painter->takeDirtyRegion();
QVector<QRect> dirtyRegion = m_painter->takeDirtyRegion();
m_painter->endTransaction(image()->undoAdapter());
device->setDirty(dirtyRegion);
......
......@@ -132,15 +132,11 @@ void KisToolMultihand::timeoutPaint()
if (currentImage() && !m_painters.isEmpty()) {
for (int i = 0; i < m_painters.size(); i++){
KisPainter * painter = m_painters.at(i);
KisPaintInformation pi1 = m_previousPaintInformation;
pi1.setPos( m_brushTransforms.at(i).map(pi1.pos()) );
paintAt(pi1, m_painters[i]);
QRegion r = m_painters[i]->takeDirtyRegion();
currentNode()->setDirty(r);
currentNode()->setDirty(m_painters[i]->takeDirtyRegion());
}
}
}
......@@ -604,7 +600,7 @@ void KisToolMultihand::endPaint()
indirect->mergeToLayer(layer, m_incrementalDirtyRegion, m_transactionText);
m_incrementalDirtyRegion = QRegion();
m_incrementalDirtyRegion.clear();
} else {
m_transaction->commit(image()->undoAdapter());
}
......@@ -681,7 +677,7 @@ bool KisToolMultihand::wantsAutoScroll() const
return false;
}
void KisToolMultihand::setDirty(const QRegion& region)
void KisToolMultihand::setDirty(const QVector<QRect>& region)
{
if (region.isEmpty())
return;
......
......@@ -60,7 +60,7 @@ public:
KisToolMultihand(KoCanvasBase * canvas, const QCursor & cursor, const QString & transactionText);
virtual ~KisToolMultihand();
virtual int flags() const;
virtual void setDirty(const QRegion& region);
virtual void setDirty(const QVector<QRect>& region);
protected:
void gesture(const QPointF &offsetInDocPixels,
......@@ -197,7 +197,7 @@ private:
qint32 m_rate;
bool m_isAirbrushing;
QRegion m_incrementalDirtyRegion;
QVector<QRect> m_incrementalDirtyRegion;
QList<FreehandPaintJob*> m_paintJobs;
KisRecordedPathPaintAction* m_pathPaintAction;
QThreadPool* m_executor;
......
......@@ -171,7 +171,7 @@ void KisToolPath::addPathShape(KoPathShape* pathShape)
}
}
image->actionRecorder()->addAction(bezierCurvePaintAction);
if (!currentNode->inherits("KisShapeLayer")) {
KisPaintDeviceSP dev = currentNode->paintDevice();
......@@ -179,9 +179,9 @@ void KisToolPath::addPathShape(KoPathShape* pathShape)
if (!dev) {
return;
}
setCurrentNodeLocked(true);
KisSelectionSP selection = kiscanvas->view()->selection();
KisPainter painter(dev, selection);
......@@ -191,8 +191,7 @@ void KisToolPath::addPathShape(KoPathShape* pathShape)
painter.paintPainterPath(mapedOutline);
painter.endTransaction(image->undoAdapter());
QRegion dirtyRegion = painter.takeDirtyRegion();
dev->setDirty(dirtyRegion);
dev->setDirty(painter.takeDirtyRegion());
image->setModified();
setCurrentNodeLocked(false);
......
......@@ -64,7 +64,7 @@ void KisToolRectangle::finishRect(const QRectF &rect)
{
if (rect.isNull())
return;
if (image()) {
KisRecordedShapePaintAction linePaintAction(KisNodeQueryPath::absolutePath(currentNode()), currentPaintOpPreset(), KisRecordedShapePaintAction::Rectangle, rect);
setupPaintAction(&linePaintAction);
......@@ -82,8 +82,7 @@ void KisToolRectangle::finishRect(const QRectF &rect)
painter.paintRect(rect);
painter.endTransaction(image()->undoAdapter());
QRegion bound = painter.takeDirtyRegion();
device->setDirty(bound);
device->setDirty(painter.takeDirtyRegion());
notifyModified();
} else {
QRectF r = convertToPt(rect);
......
......@@ -62,7 +62,7 @@ KisToolDyna::KisToolDyna(KoCanvasBase * canvas)
m_timer = new QTimer(this);
Q_CHECK_PTR(m_timer);
connect(m_timer, SIGNAL(timeout()), this, SLOT(timeoutPaint()));
initDyna();
}
......@@ -94,9 +94,7 @@ void KisToolDyna::timeoutPaint()
if (currentImage() && m_painter) {
paintAt(m_previousPaintInformation);
QRegion r = m_painter->takeDirtyRegion();
dbgPlugins << "Timeout paint dirty region:" << r;
currentNode()->setDirty(r);
currentNode()->setDirty(m_painter->takeDirtyRegion());
}
}
......@@ -105,14 +103,14 @@ void KisToolDyna::timeoutPaint()
void KisToolDyna::initPaint(KoPointerEvent *e)
{
m_rate = currentPaintOpPreset()->settings()->rate();
QRectF imageSize = QRectF(QPointF(0.0,0.0),currentImage()->size());
QRectF documentSize = currentImage()->pixelToDocument(imageSize);
m_surfaceWidth = documentSize.width();
m_surfaceHeight = documentSize.height();
setMousePosition(e->point);
m_mouse.init(m_mousePos.x(), m_mousePos.y());
KisToolFreehand::initPaint(e);
if (!m_painter) {
......@@ -138,7 +136,7 @@ void KisToolDyna::mousePressEvent(KoPointerEvent *e)
m_mouse.init(m_mousePos.x(), m_mousePos.y());
m_odelx = m_mousePos.x();
m_odely = m_mousePos.y();
KisToolFreehand::mousePressEvent(e);
}
......@@ -279,10 +277,10 @@ KoPointerEvent KisToolDyna::filterEvent(KoPointerEvent* event)
m_pressure = m_mouse.vel * 100;
m_pressure = qBound<qreal>(0.0,m_pressure, 1.0);
m_odelx = delx;
m_odely = dely;
// how to change pressure in the KoPointerEvent???
return KoPointerEvent(event,now);
}
......
......@@ -370,9 +370,9 @@ void KisToolFreehand::initPaint(KoPointerEvent *)
indirect->setTemporaryTarget(targetDevice);
indirect->setTemporaryCompositeOp(m_compositeOp);
indirect->setTemporaryOpacity(m_opacity);
KisPaintLayer* paintLayer = dynamic_cast<KisPaintLayer*>(currentNode().data());
if(paintLayer)
indirect->setTemporaryChannelFlags(paintLayer->channelLockFlags());
}
......@@ -392,7 +392,7 @@ void KisToolFreehand::initPaint(KoPointerEvent *)
m_painter->beginTransaction(m_transactionText);
setupPainter(m_painter);
if (m_paintIncremental) {
m_painter->setCompositeOp(m_compositeOp);
m_painter->setOpacity(m_opacity);
......@@ -441,7 +441,7 @@ void KisToolFreehand::endPaint()
indirect->mergeToLayer(layer, m_incrementalDirtyRegion, m_transactionText);
m_incrementalDirtyRegion = QRegion();
m_incrementalDirtyRegion.clear();
} else {
m_painter->endTransaction(image()->undoAdapter());
}
......@@ -456,11 +456,11 @@ void KisToolFreehand::endPaint()
}
m_paintJobs.clear();
}
if (m_assistant) {
static_cast<KisCanvas2*>(canvas())->view()->paintingAssistantManager()->endStroke();
}
#ifdef ENABLE_RECORDING
if (image() && m_pathPaintAction)
image()->actionRecorder()->addAction(*m_pathPaintAction);
......@@ -511,7 +511,7 @@ bool KisToolFreehand::wantsAutoScroll() const
return false;
}
void KisToolFreehand::setDirty(const QRegion& region)
void KisToolFreehand::setDirty(const QVector<QRect>& region)
{
if (region.isEmpty())
return;
......
......@@ -53,7 +53,7 @@ public:
KisToolFreehand(KoCanvasBase * canvas, const QCursor & cursor, const QString & transactionText);
virtual ~KisToolFreehand();
virtual int flags() const;
virtual void setDirty(const QRegion& region);
virtual void setDirty(const QVector<QRect>& region);
protected:
void gesture(const QPointF &offsetInDocPixels,
......@@ -143,7 +143,7 @@ private:
bool m_explicitShowOutline;
QRegion m_incrementalDirtyRegion;
QVector<QRect> m_incrementalDirtyRegion;
QList<FreehandPaintJob*> m_paintJobs;
KisRecordedPathPaintAction* m_pathPaintAction;
QThreadPool* m_executor;
......
......@@ -407,9 +407,9 @@ void KisScratchPad::initPainting(QEvent* event) {
}
m_distanceInformation.spacing = m_painter->paintAt(m_previousPaintInformation);
m_distanceInformation.distance = 0.0;
QRect rc = m_painter->takeDirtyRegion().boundingRect();
update(pos.x() - rc.width(), pos.y() - rc.height(), rc.width() * 2, rc.height() *2);
foreach(const QRect &rc, m_painter->takeDirtyRegion()) {
update(pos.x() - rc.width(), pos.y() - rc.height(), rc.width() * 2, rc.height() *2);
}
}
void KisScratchPad::paint(QEvent* event) {
......@@ -439,12 +439,15 @@ void KisScratchPad::paint(QEvent* event) {
m_distanceInformation = m_painter->paintLine(m_previousPaintInformation, info, m_distanceInformation);
m_previousPaintInformation = info;
QRegion dirtRegion = m_painter->takeDirtyRegion();
QRect rc = dirtRegion.boundingRect();
m_incrementalDirtyRegion+=dirtRegion;
m_paintLayer->updateProjection(dirtRegion.boundingRect());
update(pos.x() - rc.width(), pos.y() - rc.height(), rc.width() * 2, rc.height() *2);
QVector<QRect> rects = m_painter->takeDirtyRegion();