Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Fix confusing API of rects merging in interpolation tools
Dmitry Kazakovd026f67a616d
diff --git a/libs/image/kis_grid_interpolation_tools.h b/libs/image/kis_grid_interpolation_tools.hindex c2ce3e53ef..54e686863c 100644--- a/libs/image/kis_grid_interpolation_tools.h+++ b/libs/image/kis_grid_interpolation_tools.h@@ -171,6 +171,16 @@ struct PaintDevicePolygonOpPaintDevicePolygonOp(KisPaintDeviceSP srcDev, KisPaintDeviceSP dstDev): m_srcDev(srcDev), m_dstDev(dstDev) {}+ ~PaintDevicePolygonOp()+ {+ /**+ * When setCanMergeRects() is set to true, the caller should+ * call finalize() to process all the postponed rects, which+ * would clear the vector+ */+ KIS_SAFE_ASSERT_RECOVER_NOOP(m_rectsToCopy.isEmpty());+ }+void fastCopyArea(QRect areaToCopy) {fastCopyArea(areaToCopy, m_canMergeRects);}@@ -314,6 +324,12 @@ struct PaintDevicePolygonOpcopyPreviousRects();}+ /**+ * IMPORTANT: When setCanMergeRects() is set to `true`,+ * the caller should calls finalilze() in the end of+ * the processing action to actually copy all the lazily+ * postponed rects.+ */inline void setCanMergeRects(bool newCanMergeRects) {m_canMergeRects = newCanMergeRects;}@@ -331,7 +347,7 @@ struct PaintDevicePolygonOp#endifprivate:- bool m_canMergeRects {true};+ bool m_canMergeRects {false};QVector<QRect> m_rectsToCopy;};@@ -349,6 +365,16 @@ struct QImagePolygonOp{}+ ~QImagePolygonOp()+ {+ /**+ * When setCanMergeRects() is set to true, the caller should+ * call finalize() to process all the postponed rects, which+ * would clear the vector+ */+ KIS_SAFE_ASSERT_RECOVER_NOOP(m_rectsToCopy.isEmpty());+ }+void fastCopyArea(QRect areaToCopy) {fastCopyArea(areaToCopy, m_canMergeRects);}@@ -472,11 +498,16 @@ struct QImagePolygonOpcopyPreviousRects();}+ /**+ * IMPORTANT: When setCanMergeRects() is set to `true`,+ * the caller should calls finalilze() in the end of+ * the processing action to actually copy all the lazily+ * postponed rects.+ */inline void setCanMergeRects(bool canMergeRects) {m_canMergeRects = canMergeRects;}-const QImage &m_srcImage;QImage &m_dstImage;QPointF m_srcImageOffset;@@ -488,7 +519,7 @@ struct QImagePolygonOpconst qreal m_epsilon {0.001};private:- bool m_canMergeRects {true};+ bool m_canMergeRects {false};QVector<QRect> m_rectsToCopy;};diff --git a/libs/image/kis_warptransform_worker.cc b/libs/image/kis_warptransform_worker.ccindex bfb15ad18f..1d7411e9af 100644--- a/libs/image/kis_warptransform_worker.cc+++ b/libs/image/kis_warptransform_worker.cc@@ -245,6 +245,14 @@ void KisWarpTransformWorker::run(KisPaintDeviceSP srcDev, KisPaintDeviceSP dstDeFunctionTransformOp functionOp(m_warpMathFunction, m_origPoint, m_transfPoint, m_alpha);GridIterationTools::PaintDevicePolygonOp polygonOp(srcDev, dstDev);+ /**+ * The lazy rects copying is currently explicitly disabled for Warp transform.+ * To activate it we need:+ *+ * 1) A proper detection with GridIterationTools::canProcessRectsInRandomOrder()+ * 2) A unittest to test this mode+ */+ polygonOp.setCanMergeRects(false);GridIterationTools::processGrid(polygonOp, functionOp,srcBounds, pixelPrecision);polygonOp.finalize();@@ -347,7 +355,16 @@ QImage KisWarpTransformWorker::transformQImage(WarpType warpType,const int pixelPrecision = 32;GridIterationTools::QImagePolygonOp polygonOp(srcImage, dstImage, srcQImageOffset, dstQImageOffset);+ /**+ * The lazy rects copying is currently explicitly disabled for Warp transform.+ * To activate it we need:+ *+ * 1) A proper detection with GridIterationTools::canProcessRectsInRandomOrder()+ * 2) A unittest to test this mode+ */+ polygonOp.setCanMergeRects(false);GridIterationTools::processGrid(polygonOp, functionOp, srcBounds.toAlignedRect(), pixelPrecision);+ polygonOp.finalize();return dstImage;}