summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/tools/qeasingcurve.cpp12
-rw-r--r--tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp11
2 files changed, 23 insertions, 0 deletions
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index 2ae63fe135..52c8d13fe3 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -583,6 +583,13 @@ struct BezierEase : public QEasingCurveFunction
qWarning("QEasingCurve: Invalid bezier curve");
return x;
}
+
+ // The bezier computation is not always precise on the endpoints, so handle explicitly
+ if (!(x > 0))
+ return 0;
+ if (!(x < 1))
+ return 1;
+
SingleCubicBezier *singleCubicBezier = 0;
getBezierSegment(singleCubicBezier, x);
@@ -998,6 +1005,11 @@ struct BackEase : public QEasingCurveFunction
qreal value(qreal t) override
{
+ // The *Back() functions are not always precise on the endpoints, so handle explicitly
+ if (!(t > 0))
+ return 0;
+ if (!(t < 1))
+ return 1;
qreal o = (_o < 0) ? qreal(1.70158) : _o;
switch(_t) {
case QEasingCurve::InBack:
diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
index 3af6132695..2a9c1e1e41 100644
--- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
+++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
@@ -404,6 +404,11 @@ void tst_QEasingCurve::valueForProgress()
const qreal error = qAbs(ex - curve.valueForProgress(at.at(i)/qreal(100)));
QVERIFY(error <= errorBound);
}
+
+ if (type != QEasingCurve::SineCurve && type != QEasingCurve::CosineCurve) {
+ QVERIFY( !(curve.valueForProgress(0) > 0) );
+ QVERIFY( !(curve.valueForProgress(1) < 1) );
+ }
#endif
}
@@ -632,6 +637,9 @@ void tst_QEasingCurve::bezierSpline()
QCOMPARE(value, ex);
QVERIFY(error <= errorBound);
}
+
+ QVERIFY( !(bezierEasingCurve.valueForProgress(0) > 0) );
+ QVERIFY( !(bezierEasingCurve.valueForProgress(1) < 1) );
}
void tst_QEasingCurve::tcbSpline_data()
@@ -691,6 +699,9 @@ void tst_QEasingCurve::tcbSpline()
QCOMPARE(value, ex);
QVERIFY(error <= errorBound);
}
+
+ QVERIFY( !(tcbEasingCurve.valueForProgress(0) > 0) );
+ QVERIFY( !(tcbEasingCurve.valueForProgress(1) < 1) );
}
/*This is single precision code for a cubic root used inside the spline easing curve.