Avoid overflowing coverage in rasterizer
A single examined pixel might have sampled corners outside the logical constraints, that needs to be ignore. Pick-to: 6.4 6.3 6.2 Fixes: QTBUG-92485 Change-Id: I105fd42d3388a48f3bb03c00d640832e8e99477c Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
parent
3709bc3699
commit
aefb5c5a56
@ -1064,28 +1064,26 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width,
|
|||||||
while (x <= leftMax) {
|
while (x <= leftMax) {
|
||||||
QScFixed excluded = 0;
|
QScFixed excluded = 0;
|
||||||
|
|
||||||
if (yFP <= iLeftFP)
|
if (yFP <= iLeftFP && rowBottomLeft > rowTop)
|
||||||
excluded += intersectPixelFP(x, rowTop, rowBottomLeft,
|
excluded += intersectPixelFP(x, rowTop, rowBottomLeft,
|
||||||
bottomLeftIntersectAf, topLeftIntersectAf,
|
bottomLeftIntersectAf, topLeftIntersectAf,
|
||||||
topLeftSlopeFP, invTopLeftSlopeFP);
|
topLeftSlopeFP, invTopLeftSlopeFP);
|
||||||
if (yFP >= iLeftFP)
|
if (yFP >= iLeftFP && rowBottom > rowTopLeft)
|
||||||
excluded += intersectPixelFP(x, rowTopLeft, rowBottom,
|
excluded += intersectPixelFP(x, rowTopLeft, rowBottom,
|
||||||
topLeftIntersectBf, bottomLeftIntersectBf,
|
topLeftIntersectBf, bottomLeftIntersectBf,
|
||||||
bottomLeftSlopeFP, invBottomLeftSlopeFP);
|
bottomLeftSlopeFP, invBottomLeftSlopeFP);
|
||||||
|
|
||||||
if (x >= rightMin) {
|
if (x >= rightMin) {
|
||||||
if (yFP <= iRightFP)
|
if (yFP <= iRightFP && rowBottomRight > rowTop)
|
||||||
excluded += (rowBottomRight - rowTop) - intersectPixelFP(x, rowTop, rowBottomRight,
|
excluded += (rowBottomRight - rowTop) - intersectPixelFP(x, rowTop, rowBottomRight,
|
||||||
topRightIntersectAf, bottomRightIntersectAf,
|
topRightIntersectAf, bottomRightIntersectAf,
|
||||||
topRightSlopeFP, invTopRightSlopeFP);
|
topRightSlopeFP, invTopRightSlopeFP);
|
||||||
if (yFP >= iRightFP)
|
if (yFP >= iRightFP && rowBottom > rowTopRight)
|
||||||
excluded += (rowBottom - rowTopRight) - intersectPixelFP(x, rowTopRight, rowBottom,
|
excluded += (rowBottom - rowTopRight) - intersectPixelFP(x, rowTopRight, rowBottom,
|
||||||
bottomRightIntersectBf, topRightIntersectBf,
|
bottomRightIntersectBf, topRightIntersectBf,
|
||||||
bottomRightSlopeFP, invBottomRightSlopeFP);
|
bottomRightSlopeFP, invBottomRightSlopeFP);
|
||||||
}
|
}
|
||||||
if (excluded > QScFixedFactor)
|
|
||||||
excluded = excluded % QScFixedFactor;
|
|
||||||
|
|
||||||
|
Q_ASSERT(excluded >= 0 && excluded <= rowHeight);
|
||||||
QScFixed coverage = rowHeight - excluded;
|
QScFixed coverage = rowHeight - excluded;
|
||||||
buffer.addSpan(x, 1, QScFixedToInt(yFP),
|
buffer.addSpan(x, 1, QScFixedToInt(yFP),
|
||||||
QScFixedToInt(255 * coverage));
|
QScFixedToInt(255 * coverage));
|
||||||
@ -1098,17 +1096,16 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width,
|
|||||||
}
|
}
|
||||||
while (x <= rightMax) {
|
while (x <= rightMax) {
|
||||||
QScFixed excluded = 0;
|
QScFixed excluded = 0;
|
||||||
if (yFP <= iRightFP)
|
if (yFP <= iRightFP && rowBottomRight > rowTop)
|
||||||
excluded += (rowBottomRight - rowTop) - intersectPixelFP(x, rowTop, rowBottomRight,
|
excluded += (rowBottomRight - rowTop) - intersectPixelFP(x, rowTop, rowBottomRight,
|
||||||
topRightIntersectAf, bottomRightIntersectAf,
|
topRightIntersectAf, bottomRightIntersectAf,
|
||||||
topRightSlopeFP, invTopRightSlopeFP);
|
topRightSlopeFP, invTopRightSlopeFP);
|
||||||
if (yFP >= iRightFP)
|
if (yFP >= iRightFP && rowBottom > rowTopRight)
|
||||||
excluded += (rowBottom - rowTopRight) - intersectPixelFP(x, rowTopRight, rowBottom,
|
excluded += (rowBottom - rowTopRight) - intersectPixelFP(x, rowTopRight, rowBottom,
|
||||||
bottomRightIntersectBf, topRightIntersectBf,
|
bottomRightIntersectBf, topRightIntersectBf,
|
||||||
bottomRightSlopeFP, invBottomRightSlopeFP);
|
bottomRightSlopeFP, invBottomRightSlopeFP);
|
||||||
if (excluded > QScFixedFactor)
|
|
||||||
excluded = excluded % QScFixedFactor;
|
|
||||||
|
|
||||||
|
Q_ASSERT(excluded >= 0 && excluded <= rowHeight);
|
||||||
QScFixed coverage = rowHeight - excluded;
|
QScFixed coverage = rowHeight - excluded;
|
||||||
buffer.addSpan(x, 1, QScFixedToInt(yFP),
|
buffer.addSpan(x, 1, QScFixedToInt(yFP),
|
||||||
QScFixedToInt(255 * coverage));
|
QScFixedToInt(255 * coverage));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user