summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qblendfunctions.cpp
diff options
context:
space:
mode:
authorAleksandar Sasha Babic <aleksandar.babic@nokia.com>2009-11-03 09:36:52 (GMT)
committerAleksandar Sasha Babic <aleksandar.babic@nokia.com>2009-11-06 16:45:51 (GMT)
commit676780d515cedca85829ae962e4f501c5e5b6581 (patch)
treeb2994f82bf34031ae4b23ed9eb3a078e3c2a1e39 /src/gui/painting/qblendfunctions.cpp
parent03b19519768b504e5c7f5fd3923a14591e58b365 (diff)
downloadQt-676780d515cedca85829ae962e4f501c5e5b6581.zip
Qt-676780d515cedca85829ae962e4f501c5e5b6581.tar.gz
Qt-676780d515cedca85829ae962e4f501c5e5b6581.tar.bz2
Using qreal more consistently in code (prevent misuse of double)
We want to force use of qreal where possible. This can lead to better performance on platforms where qreal -> float (i.e. ARM). To achieve this we: 1. changed from 'double' to 'qreal', where justified 2. using qreal() to intialize constants, where justified 3. adding helper functions that are overloaded for qreal like qAtan2(), qAcos(), qFabs() ... 4. defining QT_USE_MATH_H_FLOATS for Symbian platform In addtion we used opportunity to improve code with some small things 5. converting divisions to multiplications (i.e. '/ 2.0' -> '* qreal(0.5)') 6. defining new constants (i.e. 'Q_PI / 180.0' -> 'Q_PI180') 7. declaring variables as 'const', where justified Reviewed-by: Andreas Aardal Hanssen Reviewed-by: Gunnar Sletta Reviewed-by: Jan-Arve Reviewed-by: Kim Motoyoshi Kalland Reviewed-by: Alessandro Portale Reviewed-by: Janne Koskinen
Diffstat (limited to 'src/gui/painting/qblendfunctions.cpp')
-rw-r--r--src/gui/painting/qblendfunctions.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp
index f8dd424..76d50db 100644
--- a/src/gui/painting/qblendfunctions.cpp
+++ b/src/gui/painting/qblendfunctions.cpp
@@ -223,8 +223,8 @@ void qt_scale_image_16bit(uchar *destPixels, int dbpl,
int h = ty2 - ty1;
int w = tx2 - tx1;
- const int dstx = qCeil((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix) - 1;
- const int dsty = qCeil((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy) - 1;
+ const int dstx = qCeil((tx1 + qreal(0.5) - qMin(targetRect.left(), targetRect.right())) * ix) - 1;
+ const int dsty = qCeil((ty1 + qreal(0.5) - qMin(targetRect.top(), targetRect.bottom())) * iy) - 1;
quint32 basex = quint32((sx < 0 ? srcRect.right() : srcRect.left()) * 65536) + dstx;
quint32 srcy = quint32((sy < 0 ? srcRect.bottom() : srcRect.top()) * 65536) + dsty;
@@ -723,8 +723,8 @@ template <typename T> void qt_scale_image_32bit(uchar *destPixels, int dbpl,
int h = ty2 - ty1;
int w = tx2 - tx1;
- const int dstx = qCeil((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix) - 1;
- const int dsty = qCeil((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy) - 1;
+ const int dstx = qCeil((tx1 + qreal(0.5) - qMin(targetRect.left(), targetRect.right())) * ix) - 1;
+ const int dsty = qCeil((ty1 + qreal(0.5) - qMin(targetRect.top(), targetRect.bottom())) * iy) - 1;
quint32 basex = quint32((sx < 0 ? srcRect.right() : srcRect.left()) * 65536) + dstx;
quint32 srcy = quint32((sy < 0 ? srcRect.bottom() : srcRect.top()) * 65536) + dsty;
@@ -818,8 +818,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
int dx_l = int(leftSlope * 0x10000);
int dx_r = int(rightSlope * 0x10000);
- int x_l = int((topLeft.x + (0.5 + fromY - topLeft.y) * leftSlope + 0.5) * 0x10000);
- int x_r = int((topRight.x + (0.5 + fromY - topRight.y) * rightSlope + 0.5) * 0x10000);
+ int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+ int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
int fromX, toX, x1, x2, u, v, i, ii;
DestT *line;
@@ -996,7 +996,7 @@ void qt_transform_image(DestT *destPixels, int dbpl,
if (det == 0)
return;
- qreal invDet = 1.0 / det;
+ qreal invDet = qreal(1.0) / det;
qreal m11, m12, m21, m22, mdx, mdy;
m11 = (u.u * w.y - u.y * w.u) * invDet;
@@ -1010,8 +1010,8 @@ void qt_transform_image(DestT *destPixels, int dbpl,
int dvdx = int(m21 * 0x10000);
int dudy = int(m12 * 0x10000);
int dvdy = int(m22 * 0x10000);
- int u0 = qCeil((0.5 * m11 + 0.5 * m12 + mdx) * 0x10000) - 1;
- int v0 = qCeil((0.5 * m21 + 0.5 * m22 + mdy) * 0x10000) - 1;
+ int u0 = qCeil((qreal(0.5) * m11 + qreal(0.5) * m12 + mdx) * 0x10000) - 1;
+ int v0 = qCeil((qreal(0.5) * m21 + qreal(0.5) * m22 + mdy) * 0x10000) - 1;
int x1 = qFloor(sourceRect.left());
int y1 = qFloor(sourceRect.top());