diff --git a/krita/image/kis_grid_interpolation_tools.h b/krita/image/kis_grid_interpolation_tools.h index adfc2eb295a3d2acf9696606549eaf0f0a85ad35..24de41b212ad7b69034e733ad555e2d1cef3ee6b 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