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)
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;
}
}
-
Q_ASSERT(ipos >= 0);
Q_ASSERT(ipos < GRADIENT_STOPTABLE_SIZE);