From 4391014d4533e60dc4e5e413db50b21f68f4658c Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Tue, 15 Dec 2009 13:50:01 +0100 Subject: qreal-ization Using math wrapper functions instead direct call. This gives us top-level control to what (single/double) precision we are effectively using. Task-number: QTBUG-4894 Reviewed-by: janarve Reviewed-by: Kim Motoyoshi Kalland --- src/gui/painting/qbezier.cpp | 20 ++++++++++---------- src/gui/painting/qdrawhelper.cpp | 12 ++++++------ src/gui/painting/qpathclipper.cpp | 2 +- src/gui/painting/qstroker.cpp | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp index a6b4cef01b..f6264942ca 100644 --- a/src/gui/painting/qbezier.cpp +++ b/src/gui/painting/qbezier.cpp @@ -497,7 +497,7 @@ static bool addCircle(const QBezier *b, qreal offset, QBezier *o) cos_a = 1.; if (cos_a < -1.) cos_a = -1; - angles[i] = acos(cos_a)/Q_PI; + angles[i] = qAcos(cos_a)/Q_PI; } if (angles[0] + angles[1] > 1.) { @@ -816,17 +816,17 @@ bool QBezier::findIntersections(const QBezier &a, const QBezier &b, QVector > *t) { if (IntersectBB(a, b)) { - QPointF la1(fabs((a.x3 - a.x2) - (a.x2 - a.x1)), - fabs((a.y3 - a.y2) - (a.y2 - a.y1))); - QPointF la2(fabs((a.x4 - a.x3) - (a.x3 - a.x2)), - fabs((a.y4 - a.y3) - (a.y3 - a.y2))); + QPointF la1(qFabs((a.x3 - a.x2) - (a.x2 - a.x1)), + qFabs((a.y3 - a.y2) - (a.y2 - a.y1))); + QPointF la2(qFabs((a.x4 - a.x3) - (a.x3 - a.x2)), + qFabs((a.y4 - a.y3) - (a.y3 - a.y2))); QPointF la; if (la1.x() > la2.x()) la.setX(la1.x()); else la.setX(la2.x()); if (la1.y() > la2.y()) la.setY(la1.y()); else la.setY(la2.y()); - QPointF lb1(fabs((b.x3 - b.x2) - (b.x2 - b.x1)), - fabs((b.y3 - b.y2) - (b.y2 - b.y1))); - QPointF lb2(fabs((b.x4 - b.x3) - (b.x3 - b.x2)), - fabs((b.y4 - b.y3) - (b.y3 - b.y2))); + QPointF lb1(qFabs((b.x3 - b.x2) - (b.x2 - b.x1)), + qFabs((b.y3 - b.y2) - (b.y2 - b.y1))); + QPointF lb2(qFabs((b.x4 - b.x3) - (b.x3 - b.x2)), + qFabs((b.y4 - b.y3) - (b.y3 - b.y2))); QPointF lb; if (lb1.x() > lb2.x()) lb.setX(lb1.x()); else lb.setX(lb2.x()); if (lb1.y() > lb2.y()) lb.setY(lb1.y()); else lb.setY(lb2.y()); @@ -1120,7 +1120,7 @@ static inline void bindInflectionPoint(const QBezier &bez, const qreal t, qreal ey = 3 * (right.y2 - right.y3); qreal s4 = qAbs(6 * (ey * ax - ex * ay) / qSqrt(ex * ex + ey * ey)) + 0.00001f; - qreal tf = pow(qreal(9 * flatness / s4), qreal(1./3.)); + qreal tf = qPow(qreal(9 * flatness / s4), qreal(1./3.)); *tMinus = t - (1 - t) * tf; *tPlus = t + (1 - t) * tf; } diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 4df7f8ab20..23236ece20 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1182,7 +1182,7 @@ static const uint * QT_FASTCALL fetchConicalGradient(uint *buffer, const Operato rx -= data->gradient.conical.center.x; ry -= data->gradient.conical.center.y; while (buffer < end) { - qreal angle = atan2(ry, rx) + data->gradient.conical.angle; + qreal angle = qAtan2(ry, rx) + data->gradient.conical.angle; *buffer = qt_gradient_pixel(&data->gradient, 1 - angle / (2*Q_PI)); @@ -1196,7 +1196,7 @@ static const uint * QT_FASTCALL fetchConicalGradient(uint *buffer, const Operato if (!rw) rw = 1; while (buffer < end) { - qreal angle = atan2(ry/rw - data->gradient.conical.center.x, + qreal angle = qAtan2(ry/rw - data->gradient.conical.center.x, rx/rw - data->gradient.conical.center.y) + data->gradient.conical.angle; @@ -7140,17 +7140,17 @@ void qt_build_pow_tables() { } #else for (int i=0; i<256; ++i) { - qt_pow_rgb_gamma[i] = uchar(qRound(pow(i / qreal(255.0), smoothing) * 255)); - qt_pow_rgb_invgamma[i] = uchar(qRound(pow(i / qreal(255.), 1 / smoothing) * 255)); + qt_pow_rgb_gamma[i] = uchar(qRound(qPow(i / qreal(255.0), smoothing) * 255)); + qt_pow_rgb_invgamma[i] = uchar(qRound(qPow(i / qreal(255.), 1 / smoothing) * 255)); } #endif #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) const qreal gray_gamma = 2.31; for (int i=0; i<256; ++i) - qt_pow_gamma[i] = uint(qRound(pow(i / qreal(255.), gray_gamma) * 2047)); + qt_pow_gamma[i] = uint(qRound(qPow(i / qreal(255.), gray_gamma) * 2047)); for (int i=0; i<2048; ++i) - qt_pow_invgamma[i] = uchar(qRound(pow(i / 2047.0, 1 / gray_gamma) * 255)); + qt_pow_invgamma[i] = uchar(qRound(qPow(i / 2047.0, 1 / gray_gamma) * 255)); #endif } diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index 51d6195ed8..a41ab6d24c 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -1209,7 +1209,7 @@ static qreal computeAngle(const QPointF &v) } #else // doesn't seem to be robust enough - return atan2(v.x(), v.y()) + Q_PI; + return qAtan2(v.x(), v.y()) + Q_PI; #endif } diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index 228a6b12f3..8bb4728350 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -910,8 +910,8 @@ QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLengt } } - int startSegment = int(floor(startAngle / 90)); - int endSegment = int(floor((startAngle + sweepLength) / 90)); + int startSegment = int(qFloor(startAngle / 90)); + int endSegment = int(qFloor((startAngle + sweepLength) / 90)); qreal startT = (startAngle - startSegment * 90) / 90; qreal endT = (startAngle + sweepLength - endSegment * 90) / 90; -- cgit v1.2.3