diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2010-09-18 09:04:29 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-04-13 08:12:58 (GMT) |
commit | 44dd7ef86a3970694a4f8fd9516575c0533a336e (patch) | |
tree | e3176105ff1fd175c4f184d1317dfdc028c175ca /src/gui/painting/qdrawhelper_p.h | |
parent | f16c261348193b4c03f796db4e1e3a5db09267a2 (diff) | |
download | Qt-44dd7ef86a3970694a4f8fd9516575c0533a336e.zip Qt-44dd7ef86a3970694a4f8fd9516575c0533a336e.tar.gz Qt-44dd7ef86a3970694a4f8fd9516575c0533a336e.tar.bz2 |
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
Diffstat (limited to 'src/gui/painting/qdrawhelper_p.h')
-rw-r--r-- | src/gui/painting/qdrawhelper_p.h | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 2cfcffb..6377fe1 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); |