summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2010-09-18 11:04:29 +0200
committerOlivier Goffart <olivier.goffart@nokia.com>2011-05-10 12:54:45 +0200
commit28e32c0bc3bbe4816b85753645b3856f879ae390 (patch)
tree4e4a702f32e3beec0ce4a60a1d6a97a3abcf639d /src/gui
parent79d238abdcd7927fd2f81e500b8d0893b44b01d6 (diff)
Improved qt_gradient_clamp for reflect spreads.
Using GRADIENT_STOPTABLE_SIZE * 2 as the modulo gives more correct behaviour, and also improves performance slightly. Reviewed-by: Benjamin Poulain (cherry picked from commit 44dd7ef86a3970694a4f8fd9516575c0533a336e)
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/painting/qdrawhelper_p.h7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index 2cfcffb681..6377fe130c 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -349,13 +349,11 @@ static inline uint qt_gradient_clamp(const QGradientData *data, int ipos)
if (data->spread == QGradient::RepeatSpread) {
ipos = ipos % GRADIENT_STOPTABLE_SIZE;
ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos;
-
} else if (data->spread == QGradient::ReflectSpread) {
- const int limit = GRADIENT_STOPTABLE_SIZE * 2 - 1;
+ const int limit = GRADIENT_STOPTABLE_SIZE * 2;
ipos = ipos % limit;
ipos = ipos < 0 ? limit + ipos : ipos;
- ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - ipos : ipos;
-
+ ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - 1 - ipos : ipos;
} else {
if (ipos < 0)
ipos = 0;
@@ -364,7 +362,6 @@ static inline uint qt_gradient_clamp(const QGradientData *data, int ipos)
}
}
-
Q_ASSERT(ipos >= 0);
Q_ASSERT(ipos < GRADIENT_STOPTABLE_SIZE);