diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-06-25 11:59:20 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-06-28 17:14:43 +0000 |
commit | 74989b09147dd0a47d3e3d0324c6f4ee37a0c667 (patch) | |
tree | 5151e067ba1ae40a853efb44a5834ccd35f840c8 | |
parent | de5fd0faa1ed8e02e83d100faff5d978f27b3278 (diff) |
Avoid overflowing coverage in rasterizer
A single examined pixel might have sampled corners outside the logical
constraints, that needs to be ignore.
Fixes: QTBUG-92485
Change-Id: I105fd42d3388a48f3bb03c00d640832e8e99477c
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit aefb5c5a56dd6882179130b98fc44ac0fb366b03)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/gui/painting/qrasterizer.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index 8a3e46e58b..cd9d3ba4d0 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -1064,28 +1064,26 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, while (x <= leftMax) { QScFixed excluded = 0; - if (yFP <= iLeftFP) + if (yFP <= iLeftFP && rowBottomLeft > rowTop) excluded += intersectPixelFP(x, rowTop, rowBottomLeft, bottomLeftIntersectAf, topLeftIntersectAf, topLeftSlopeFP, invTopLeftSlopeFP); - if (yFP >= iLeftFP) + if (yFP >= iLeftFP && rowBottom > rowTopLeft) excluded += intersectPixelFP(x, rowTopLeft, rowBottom, topLeftIntersectBf, bottomLeftIntersectBf, bottomLeftSlopeFP, invBottomLeftSlopeFP); - if (x >= rightMin) { - if (yFP <= iRightFP) + if (yFP <= iRightFP && rowBottomRight > rowTop) excluded += (rowBottomRight - rowTop) - intersectPixelFP(x, rowTop, rowBottomRight, topRightIntersectAf, bottomRightIntersectAf, topRightSlopeFP, invTopRightSlopeFP); - if (yFP >= iRightFP) + if (yFP >= iRightFP && rowBottom > rowTopRight) excluded += (rowBottom - rowTopRight) - intersectPixelFP(x, rowTopRight, rowBottom, bottomRightIntersectBf, topRightIntersectBf, bottomRightSlopeFP, invBottomRightSlopeFP); } - if (excluded > QScFixedFactor) - excluded = excluded % QScFixedFactor; + Q_ASSERT(excluded >= 0 && excluded <= rowHeight); QScFixed coverage = rowHeight - excluded; buffer.addSpan(x, 1, QScFixedToInt(yFP), QScFixedToInt(255 * coverage)); @@ -1098,17 +1096,16 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, } while (x <= rightMax) { QScFixed excluded = 0; - if (yFP <= iRightFP) + if (yFP <= iRightFP && rowBottomRight > rowTop) excluded += (rowBottomRight - rowTop) - intersectPixelFP(x, rowTop, rowBottomRight, topRightIntersectAf, bottomRightIntersectAf, topRightSlopeFP, invTopRightSlopeFP); - if (yFP >= iRightFP) + if (yFP >= iRightFP && rowBottom > rowTopRight) excluded += (rowBottom - rowTopRight) - intersectPixelFP(x, rowTopRight, rowBottom, bottomRightIntersectBf, topRightIntersectBf, bottomRightSlopeFP, invBottomRightSlopeFP); - if (excluded > QScFixedFactor) - excluded = excluded % QScFixedFactor; + Q_ASSERT(excluded >= 0 && excluded <= rowHeight); QScFixed coverage = rowHeight - excluded; buffer.addSpan(x, 1, QScFixedToInt(yFP), QScFixedToInt(255 * coverage)); |