From 6d04b26155de74df880836f2a89cce6e1adfe709 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 29 Jun 2020 16:58:59 +0000 Subject: [PATCH] optimize QRect/QRectF animation interpolators Signed-off-by: Ivailo Monev --- src/gui/animation/qvariantanimation.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/gui/animation/qvariantanimation.cpp b/src/gui/animation/qvariantanimation.cpp index 5621ce5af..9e717cb20 100644 --- a/src/gui/animation/qvariantanimation.cpp +++ b/src/gui/animation/qvariantanimation.cpp @@ -159,22 +159,16 @@ static QVariant defaultInterpolator(const void *, const void *, qreal) template<> Q_INLINE_TEMPLATE QRect _q_interpolate(const QRect &f, const QRect &t, qreal progress) { - QRect ret; - ret.setCoords(_q_interpolate(f.left(), t.left(), progress), - _q_interpolate(f.top(), t.top(), progress), - _q_interpolate(f.right(), t.right(), progress), - _q_interpolate(f.bottom(), t.bottom(), progress)); - return ret; + return QRect(_q_interpolate(f.left(), t.left(), progress), + _q_interpolate(f.top(), t.top(), progress), + _q_interpolate(f.right(), t.right(), progress), + _q_interpolate(f.bottom(), t.bottom(), progress)); } template<> Q_INLINE_TEMPLATE QRectF _q_interpolate(const QRectF &f, const QRectF &t, qreal progress) { - qreal x1, y1, w1, h1; - f.getRect(&x1, &y1, &w1, &h1); - qreal x2, y2, w2, h2; - t.getRect(&x2, &y2, &w2, &h2); - return QRectF(_q_interpolate(x1, x2, progress), _q_interpolate(y1, y2, progress), - _q_interpolate(w1, w2, progress), _q_interpolate(h1, h2, progress)); + return QRectF(_q_interpolate(f.x(), t.x(), progress), _q_interpolate(f.y(), t.y(), progress), + _q_interpolate(f.width(), t.width(), progress), _q_interpolate(f.height(), t.height(), progress)); } template<> Q_INLINE_TEMPLATE QLine _q_interpolate(const QLine &f, const QLine &t, qreal progress) -- 2.11.0