Commit 231ea266 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Fix flickering of the outline when the tool is is HOVER mode

The saved lastly used point must not be equal to the current one,
otherwise the drawing angle is not defined.
parent 11e15099
......@@ -38,6 +38,47 @@
* A special class containing the previous position of the cursor for
* the sake of painting the outline of the paint op. The main purposu
* of this class is to ensure that the saved point does not equal to
* the current one, which would cause a outline flicker. To echieve
* this the class stores two previosly requested points instead of the
* last one.
class PositionHistory
* \return the previously used point, which is guaranteed not to
* be equal to \p pt and updates the history if needed
QPointF pushThroughHistory(const QPointF &pt) {
QPointF result;
const qreal pointSwapThreshold = 7.0;
* We check x *and* y separately, because events generated by
* a mouse device tend to come separately for x and y offsets.
* Efficienty generating the 'stairs' pattern.
if (qAbs(pt.x() - m_second.x()) > pointSwapThreshold &&
qAbs(pt.y() - m_second.y()) > pointSwapThreshold) {
result = m_second;
m_first = m_second;
m_second = pt;
} else {
result = m_first;
return result;
QPointF m_first;
QPointF m_second;
struct KisToolFreehandHelper::Private
......@@ -67,7 +108,7 @@ struct KisToolFreehandHelper::Private
QList<KisPaintInformation> history;
QList<qreal> distanceHistory;
QPointF lastOutlinePos;
PositionHistory lastOutlinePos;
......@@ -100,8 +141,7 @@ QPainterPath KisToolFreehandHelper::paintOpOutline(const QPointF &savedCursorPos
const KisPaintOpSettings *settings = globalSettings;
KisPaintInformation info(savedCursorPos);
KisDistanceInformation distanceInfo(m_d->lastOutlinePos, 0);
m_d->lastOutlinePos = savedCursorPos;
KisDistanceInformation distanceInfo(m_d->lastOutlinePos.pushThroughHistory(savedCursorPos), 0);
if (!m_d->painterInfos.isEmpty()) {
settings = m_d->resources->currentPaintOpPreset()->settings();
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