OSDN Git Service

optimize QRect/QRectF animation interpolators
authorIvailo Monev <xakepa10@laimg.moc>
Mon, 29 Jun 2020 16:58:59 +0000 (16:58 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Mon, 29 Jun 2020 16:58:59 +0000 (16:58 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/gui/animation/qvariantanimation.cpp

index 5621ce5..9e717cb 100644 (file)
@@ -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)