diff options
Diffstat (limited to 'src/gui/painting/qcosmeticstroker.cpp')
-rw-r--r-- | src/gui/painting/qcosmeticstroker.cpp | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index 5cbcdf83d4..4965762d74 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -68,8 +68,8 @@ static inline uint sourceOver(uint d, uint color) inline static int F16Dot16FixedDiv(int x, int y) { if (qAbs(x) > 0x7fff) - return (((qlonglong)x) << 16) / y; - return (x << 16) / y; + return qlonglong(x) * (1<<16) / y; + return x * (1<<16) / y; } typedef void (*DrawPixel)(QCosmeticStroker *stroker, int x, int y, int coverage); @@ -147,12 +147,14 @@ inline void drawPixel(QCosmeticStroker *stroker, int x, int y, int coverage) if (x < cl.x() || x > cl.right() || y < cl.y() || y > cl.bottom()) return; - int lastx = stroker->spans[stroker->current_span-1].x + stroker->spans[stroker->current_span-1].len ; - int lasty = stroker->spans[stroker->current_span-1].y; + if (stroker->current_span > 0) { + const int lastx = stroker->spans[stroker->current_span-1].x + stroker->spans[stroker->current_span-1].len ; + const int lasty = stroker->spans[stroker->current_span-1].y; - if (stroker->current_span == QCosmeticStroker::NSPANS || y < lasty || (y == lasty && x < lastx)) { - stroker->blend(stroker->current_span, stroker->spans, &stroker->state->penData); - stroker->current_span = 0; + if (stroker->current_span == QCosmeticStroker::NSPANS || y < lasty || (y == lasty && x < lastx)) { + stroker->blend(stroker->current_span, stroker->spans, &stroker->state->penData); + stroker->current_span = 0; + } } stroker->spans[stroker->current_span].x = ushort(x); @@ -439,14 +441,14 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal qSwap(x1, x2); } int xinc = F16Dot16FixedDiv(x2 - x1, y2 - y1); - int x = x1 << 10; + int x = x1 * (1<<10); int y = (y1 + 32) >> 6; int ys = (y2 + 32) >> 6; int round = (xinc > 0) ? 32 : 0; if (y != ys) { - x += ( ((((y << 6) + round - y1))) * xinc ) >> 6; + x += ((y * (1<<6)) + round - y1) * xinc >> 6; if (swapped) { lastPixel.x = x >> 16; @@ -478,7 +480,7 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal int round = (yinc > 0) ? 32 : 0; if (x != xs) { - y += ( ((((x << 6) + round - x1))) * yinc ) >> 6; + y += ((x * (1<<6)) + round - x1) * yinc >> 6; if (swapped) { lastPixel.x = x; @@ -757,7 +759,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, dir = QCosmeticStroker::BottomToTop; } int xinc = F16Dot16FixedDiv(x2 - x1, y2 - y1); - int x = x1 << 10; + int x = x1 * (1<<10); if ((stroker->lastDir ^ QCosmeticStroker::VerticalMask) == dir) caps |= swapped ? QCosmeticStroker::CapEnd : QCosmeticStroker::CapBegin; @@ -769,7 +771,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, int round = (xinc > 0) ? 32 : 0; if (y != ys) { - x += ( ((((y << 6) + round - y1))) * xinc ) >> 6; + x += ((y * (1<<6)) + round - y1) * xinc >> 6; // calculate first and last pixel and perform dropout control QCosmeticStroker::Point first; @@ -808,7 +810,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, stroker->lastDir = dir; stroker->lastAxisAligned = axisAligned; - Dasher dasher(stroker, swapped, y << 6, ys << 6); + Dasher dasher(stroker, swapped, y * (1<<6), ys * (1<<6)); do { if (dasher.on()) @@ -834,7 +836,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, dir = QCosmeticStroker::RightToLeft; } int yinc = F16Dot16FixedDiv(y2 - y1, x2 - x1); - int y = y1 << 10; + int y = y1 * (1<<10); if ((stroker->lastDir ^ QCosmeticStroker::HorizontalMask) == dir) caps |= swapped ? QCosmeticStroker::CapEnd : QCosmeticStroker::CapBegin; @@ -846,7 +848,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, int round = (yinc > 0) ? 32 : 0; if (x != xs) { - y += ( ((((x << 6) + round - x1))) * yinc ) >> 6; + y += ((x * (1<<6)) + round - x1) * yinc >> 6; // calculate first and last pixel to perform dropout control QCosmeticStroker::Point first; @@ -884,7 +886,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, stroker->lastDir = dir; stroker->lastAxisAligned = axisAligned; - Dasher dasher(stroker, swapped, x << 6, xs << 6); + Dasher dasher(stroker, swapped, x * (1<<6), xs * (1<<6)); do { if (dasher.on()) @@ -927,7 +929,7 @@ static bool drawLineAA(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx caps = swapCaps(caps); } - int x = (x1 - 32) << 10; + int x = (x1 - 32) * (1<<10); x -= ( ((y1 & 63) - 32) * xinc ) >> 6; capAdjust(caps, y1, y2, x, xinc); @@ -990,7 +992,7 @@ static bool drawLineAA(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx caps = swapCaps(caps); } - int y = (y1 - 32) << 10; + int y = (y1 - 32) * (1<<10); y -= ( ((x1 & 63) - 32) * yinc ) >> 6; capAdjust(caps, x1, x2, y, yinc); |