4609 int stopCount = stops.
count();
4614 if (stopCount == 2) {
4621 if (second_stop < first_stop) {
4622 qSwap(first_color, second_color);
4623 qSwap(first_stop, second_stop);
4626 if (colorInterpolation) {
4627 first_color =
PREMUL(first_color);
4628 second_color =
PREMUL(second_color);
4634 uint red_first =
qRed(first_color) << 16;
4635 uint green_first =
qGreen(first_color) << 16;
4636 uint blue_first =
qBlue(first_color) << 16;
4637 uint alpha_first =
qAlpha(first_color) << 16;
4639 uint red_second =
qRed(second_color) << 16;
4640 uint green_second =
qGreen(second_color) << 16;
4641 uint blue_second =
qBlue(second_color) << 16;
4642 uint alpha_second =
qAlpha(second_color) << 16;
4646 if (colorInterpolation)
4647 colorTable[i] = first_color;
4649 colorTable[i] =
PREMUL(first_color);
4652 if (i < second_index) {
4653 qreal reciprocal =
qreal(1) / (second_index - first_index);
4655 int red_delta =
qRound(
int(red_second - red_first) * reciprocal);
4656 int green_delta =
qRound(
int(green_second - green_first) * reciprocal);
4657 int blue_delta =
qRound(
int(blue_second - blue_first) * reciprocal);
4658 int alpha_delta =
qRound(
int(alpha_second - alpha_first) * reciprocal);
4661 red_first += 1 << 15;
4662 green_first += 1 << 15;
4663 blue_first += 1 << 15;
4664 alpha_first += 1 << 15;
4667 red_first += red_delta;
4668 green_first += green_delta;
4669 blue_first += blue_delta;
4670 alpha_first += alpha_delta;
4672 const uint color = ((alpha_first << 8) & 0xff000000) | (red_first & 0xff0000)
4673 | ((green_first >> 8) & 0xff00) | (blue_first >> 16);
4675 if (colorInterpolation)
4676 colorTable[i] = color;
4678 colorTable[i] =
PREMUL(color);
4683 if (colorInterpolation)
4684 colorTable[i] = second_color;
4686 colorTable[i] =
PREMUL(second_color);
4693 if (stopCount == 1) {
4694 current_color =
PREMUL(current_color);
4695 for (
int i = 0; i < size; ++i)
4696 colorTable[i] = current_color;
4708 qreal dpos = 1.5 * incr;
4711 colorTable[pos++] =
PREMUL(current_color);
4712 while (dpos <= begin_pos) {
4713 colorTable[pos] = colorTable[pos - 1];
4718 int current_stop = 0;
4723 if (dpos < end_pos) {
4725 while (dpos > stops[current_stop+1].first)
4728 if (current_stop != 0)
4732 if (colorInterpolation) {
4733 current_color =
PREMUL(current_color);
4734 next_color =
PREMUL(next_color);
4739 t = (dpos - stops[current_stop].
first) * c;
4743 Q_ASSERT(current_stop < stopCount);
4746 int idist = 256 - dist;
4748 if (colorInterpolation)
4756 if (dpos >= end_pos)
4762 while (dpos > stops[current_stop+skip+1].first)
4766 current_stop += skip;
4768 current_color = next_color;
4773 if (colorInterpolation) {
4775 current_color =
PREMUL(current_color);
4776 next_color =
PREMUL(next_color);
4781 t = (dpos - stops[current_stop].
first) * c;
4789 while (pos < size - 1) {
4790 colorTable[pos] = current_color;
4795 colorTable[size - 1] = current_color;
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define GRADIENT_STOPTABLE_SIZE
Q_GUI_EXPORT_INLINE int qAlpha(QRgb rgb)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
T & first()
Returns a reference to the first item in the vector.
Q_GUI_EXPORT_INLINE int qRed(QRgb rgb)
#define ARGB_COMBINE_ALPHA(argb, alpha)
Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x)
Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b)
Q_GUI_EXPORT_INLINE int qBlue(QRgb rgb)
void qSwap(T &value1, T &value2)
Q_GUI_EXPORT_INLINE int qGreen(QRgb rgb)
Q_DECL_CONSTEXPR int qRound(qreal d)