Skip to content

Commit

Permalink
Stop using PREMUL and INV_PREMUL macros
Browse files Browse the repository at this point in the history
The two macros were replaced with qPremultiply and qUnpremultiply in
Qt 5.3, and this is the last place in Qt the old macros are still used.

Change-Id: Ic1bd1f37a843ffa76e37adfcbbde39fbfbd9ff2a
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
  • Loading branch information
carewolf committed Feb 24, 2015
1 parent 704ee03 commit b725b5f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/svg/qsvggenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,17 @@ class QSvgPaintEngine : public QPaintEngine
if (!constantAlpha) {
const qreal spacing = qreal(0.02);
QGradientStops newStops;
QRgb fromColor = PREMUL(stops.at(0).second.rgba());
QRgb fromColor = qPremultiply(stops.at(0).second.rgba());
QRgb toColor;
for (int i = 0; i + 1 < stops.size(); ++i) {
int parts = qCeil((stops.at(i + 1).first - stops.at(i).first) / spacing);
newStops.append(stops.at(i));
toColor = PREMUL(stops.at(i + 1).second.rgba());
toColor = qPremultiply(stops.at(i + 1).second.rgba());

if (parts > 1) {
qreal step = (stops.at(i + 1).first - stops.at(i).first) / parts;
for (int j = 1; j < parts; ++j) {
QRgb color = INV_PREMUL(INTERPOLATE_PIXEL_256(fromColor, 256 - 256 * j / parts, toColor, 256 * j / parts));
QRgb color = qUnpremultiply(INTERPOLATE_PIXEL_256(fromColor, 256 - 256 * j / parts, toColor, 256 * j / parts));
newStops.append(QGradientStop(stops.at(i).first + j * step, QColor::fromRgba(color)));
}
}
Expand Down

0 comments on commit b725b5f

Please sign in to comment.