summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qpoint.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2010-12-16 13:45:21 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2010-12-22 13:47:40 (GMT)
commita562fd2d201e3b618ed99a316275f20385cc5c25 (patch)
tree492d4f9b68dc8ddfc5b25358d794186293acd2f9 /src/corelib/tools/qpoint.cpp
parent6210542b3fb2b577512f5e2970f14303d1e5f21a (diff)
downloadQt-a562fd2d201e3b618ed99a316275f20385cc5c25.zip
Qt-a562fd2d201e3b618ed99a316275f20385cc5c25.tar.gz
Qt-a562fd2d201e3b618ed99a316275f20385cc5c25.tar.bz2
Added int overloads to QPoint operator* and operator*=.
For increased performance to avoid having to convert to qreal and back. Separating the qreal overload into float and double overloads is also necessary to avoid compiler errors about ambiguous overloads. Task-number: QTBUG-15872 Reviewed-by: Eskil Abrahamsen Blomfeldt
Diffstat (limited to 'src/corelib/tools/qpoint.cpp')
-rw-r--r--src/corelib/tools/qpoint.cpp63
1 files changed, 60 insertions, 3 deletions
diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp
index c297709..592a83d 100644
--- a/src/corelib/tools/qpoint.cpp
+++ b/src/corelib/tools/qpoint.cpp
@@ -187,7 +187,19 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QPoint &QPoint::operator*=(qreal factor)
+ \fn QPoint &QPoint::operator*=(float factor)
+
+ Multiplies this point's coordinates by the given \a factor, and
+ returns a reference to this point.
+
+ Note that the result is rounded to the nearest integer as points are held as
+ integers. Use QPointF for floating point accuracy.
+
+ \sa operator/=()
+*/
+
+/*!
+ \fn QPoint &QPoint::operator*=(double factor)
Multiplies this point's coordinates by the given \a factor, and
returns a reference to this point. For example:
@@ -200,6 +212,14 @@ QT_BEGIN_NAMESPACE
\sa operator/=()
*/
+/*!
+ \fn QPoint &QPoint::operator*=(int factor)
+
+ Multiplies this point's coordinates by the given \a factor, and
+ returns a reference to this point.
+
+ \sa operator/=()
+*/
/*!
\fn bool operator==(const QPoint &p1, const QPoint &p2)
@@ -237,7 +257,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn const QPoint operator*(const QPoint &point, qreal factor)
+ \fn const QPoint operator*(const QPoint &point, float factor)
\relates QPoint
Returns a copy of the given \a point multiplied by the given \a factor.
@@ -249,7 +269,44 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn const QPoint operator*(qreal factor, const QPoint &point)
+ \fn const QPoint operator*(const QPoint &point, double factor)
+ \relates QPoint
+
+ Returns a copy of the given \a point multiplied by the given \a factor.
+
+ Note that the result is rounded to the nearest integer as points
+ are held as integers. Use QPointF for floating point accuracy.
+
+ \sa QPoint::operator*=()
+*/
+
+/*!
+ \fn const QPoint operator*(const QPoint &point, int factor)
+ \relates QPoint
+
+ Returns a copy of the given \a point multiplied by the given \a factor.
+
+ \sa QPoint::operator*=()
+*/
+
+/*!
+ \fn const QPoint operator*(float factor, const QPoint &point)
+ \overload
+ \relates QPoint
+
+ Returns a copy of the given \a point multiplied by the given \a factor.
+*/
+
+/*!
+ \fn const QPoint operator*(double factor, const QPoint &point)
+ \overload
+ \relates QPoint
+
+ Returns a copy of the given \a point multiplied by the given \a factor.
+*/
+
+/*!
+ \fn const QPoint operator*(int factor, const QPoint &point)
\overload
\relates QPoint