When setting the line dash to be an empty array reset the style to Solid
An empty line dash array is indicating that it should be reset to be a Solid line, otherwise it ends up reusing the previous settings for the pen instead of drawing a solid line. Fixes: QTBUG-75553 Pick-to: 6.2 6.1 5.15 Change-Id: I16466672de95da8ef0cf3fc261969e7cc6add227 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This commit is contained in:
parent
13d86a3c4e
commit
c31638f16b
|
@ -371,7 +371,10 @@ void QQuickContext2DCommandBuffer::replay(QPainter* p, QQuickContext2D::State& s
|
||||||
}
|
}
|
||||||
state.lineDash = pattern;
|
state.lineDash = pattern;
|
||||||
QPen nPen = p->pen();
|
QPen nPen = p->pen();
|
||||||
|
if (count > 0)
|
||||||
nPen.setDashPattern(pattern);
|
nPen.setDashPattern(pattern);
|
||||||
|
else
|
||||||
|
nPen.setStyle(Qt::SolidLine);
|
||||||
p->setPen(nPen);
|
p->setPen(nPen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -894,6 +894,37 @@ CanvasTestCase {
|
||||||
comparePixel(ctx, 39,0, 0,0,0,0);
|
comparePixel(ctx, 39,0, 0,0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_lineDashReset(row) {
|
||||||
|
var canvas = createCanvasObject(row);
|
||||||
|
var ctx = canvas.getContext('2d');
|
||||||
|
ctx.reset();
|
||||||
|
ctx.strokeStyle = "#ff0000";
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
var pattern = [2, 3, 5, 1, 6, 3]
|
||||||
|
ctx.setLineDash(pattern)
|
||||||
|
|
||||||
|
compare(ctx.getLineDash(), pattern);
|
||||||
|
|
||||||
|
pattern = []
|
||||||
|
ctx.setLineDash(pattern)
|
||||||
|
compare(ctx.getLineDash(), pattern);
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(0, 0);
|
||||||
|
ctx.lineTo(40, 0);
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
comparePixel(ctx, 0,0, 255,0,0,255);
|
||||||
|
comparePixel(ctx, 4,0, 255,0,0,255);
|
||||||
|
comparePixel(ctx, 5,0, 255,0,0,255);
|
||||||
|
comparePixel(ctx, 14,0, 255,0,0,255);
|
||||||
|
comparePixel(ctx, 20,0, 255,0,0,255);
|
||||||
|
comparePixel(ctx, 21,0, 255,0,0,255);
|
||||||
|
comparePixel(ctx, 22,0, 255,0,0,255);
|
||||||
|
comparePixel(ctx, 34,0, 255,0,0,255);
|
||||||
|
comparePixel(ctx, 35,0, 255,0,0,255);
|
||||||
|
}
|
||||||
|
|
||||||
function test_lineDashOffset(row) {
|
function test_lineDashOffset(row) {
|
||||||
var canvas = createCanvasObject(row);
|
var canvas = createCanvasObject(row);
|
||||||
var ctx = canvas.getContext('2d');
|
var ctx = canvas.getContext('2d');
|
||||||
|
|
Loading…
Reference in New Issue