QEasingCurve: return QVector for cubic spline representation

QEasingCurve internally holds the spline data in a
QVector<QPointF>. For the return from cubicBezierSpline(),
the vector is transformed into a QList<QPointF>.

This involves copying, and into an inefficient (for QPointF
payloads) container at that, so deprecate cubicBezierSpline()
in favour of a new toCubicSpline() returning the QVector
directly.

Change-Id: Ie4827fe7c6e289ad97a0b09772e47298779c76ca
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Marc Mutz 2012-02-15 18:55:25 +01:00 committed by Qt by Nokia
parent 1703558330
commit f63b23afda
2 changed files with 18 additions and 5 deletions

View File

@ -1303,14 +1303,20 @@ void QEasingCurve::addTCBSegment(const QPointF &nextPoint, qreal t, qreal c, qre
}
/*!
\fn QList<QPointF> QEasingCurve::cubicBezierSpline() const
\obsolete Use toCubicSpline() instead.
*/
/*!
\since 5.0
Returns the cubicBezierSpline that defines a custom easing curve.
If the easing curve does not have a custom bezier easing curve the list
is empty.
*/
QList<QPointF> QEasingCurve::cubicBezierSpline() const
*/
QVector<QPointF> QEasingCurve::toCubicSpline() const
{
return d_ptr->config ? d_ptr->config->_bezierCurves.toList() : QList<QPointF>();
return d_ptr->config ? d_ptr->config->_bezierCurves : QVector<QPointF>();
}
/*!

View File

@ -44,7 +44,11 @@
#include <QtCore/qglobal.h>
#include <QtCore/qobjectdefs.h>
#include <QtCore/qlist.h>
#include <QtCore/qvector.h>
#if QT_DEPRECATED_SINCE(5, 0)
# include <QtCore/qlist.h>
# include <QtCore/qpoint.h>
#endif
QT_BEGIN_HEADER
@ -94,7 +98,10 @@ public:
void addCubicBezierSegment(const QPointF & c1, const QPointF & c2, const QPointF & endPoint);
void addTCBSegment(const QPointF &nextPoint, qreal t, qreal c, qreal b);
QList<QPointF> cubicBezierSpline() const;
QVector<QPointF> toCubicSpline() const;
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED QList<QPointF> cubicBezierSpline() const { return toCubicSpline().toList(); }
#endif
Type type() const;
void setType(Type type);