From 13ca806db619712b73968677c44f1f82cce4834c Mon Sep 17 00:00:00 2001 From: Dmitry Kazakov Date: Sat, 18 Oct 2014 17:23:38 +0400 Subject: [PATCH] Fix 1 px borderline problem in Liquify Transform worker The border line appeared because of weird rounding/conversions between QPolygonF->QRectF->QRect. Now we add some noise manually to avoid that. --- krita/image/kis_grid_interpolation_tools.h | 23 ++++ krita/image/kis_paint_device.cc | 10 ++ krita/image/kis_paint_device.h | 8 ++ .../kis_liquify_transform_worker_test.cpp | 125 ++++-------------- .../tests/kis_liquify_transform_worker_test.h | 1 + 5 files changed, 68 insertions(+), 99 deletions(-) diff --git a/krita/image/kis_grid_interpolation_tools.h b/krita/image/kis_grid_interpolation_tools.h index adfc2eb295..24de41b212 100644 --- a/krita/image/kis_grid_interpolation_tools.h +++ b/krita/image/kis_grid_interpolation_tools.h @@ -531,6 +531,26 @@ struct AlwaysCompletePolygonPolicy { } }; +/** + * There is a weird problem in fetching correct bounds of the polygon. + * If the rightmost (bottommost) point of the polygon is integral, then + * QRectF() will end exactly on it, but when converting into QRect the last + * point will not be taken into account. It happens due to the difference + * between center-point/topleft-point point representation. In many cases + * the latter is expected, but we don't work with it in Qt/Krita. + */ +inline void adjustAlignedPolygon(QPolygonF &polygon) +{ + static const qreal eps = 1e-5; + static const QPointF p1(eps, 0.0); + static const QPointF p2(eps, eps); + static const QPointF p3(0.0, eps); + + polygon[1] += p1; + polygon[2] += p2; + polygon[3] += p3; +} + template