Don't replace IntersectClip with ReplaceClip on a QPicture

QPainter should not try to be smart and optimize IntersectClip with ReplaceClip when working on a QPicture paint device. Doing so will change the end result as the actually state when replayed might be different from the one it was recorded in.
QPainter will no longer try to replace IntersectClip with ReplaceClip if the paint engine is a QPicture.Consistent with QPainter::setClipRect and QPainter::setClipRegion.

Fixes: QTBUG-100420
Pick-to: 6.2 6.3
Change-Id: I1e0ebbc2d6e1ffd98b9f3f537e83893579606a4b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
ChunLin Wang 2022-02-08 17:25:51 +08:00
parent bb67b6ff26
commit 52a83658c3

View File

@ -3048,7 +3048,8 @@ void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op)
return;
}
if ((!d->state->clipEnabled && op != Qt::NoClip))
bool simplifyClipOp = (paintEngine()->type() != QPaintEngine::Picture);
if (simplifyClipOp && (!d->state->clipEnabled && op != Qt::NoClip))
op = Qt::ReplaceClip;
if (d->extended) {
@ -3062,7 +3063,7 @@ void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op)
return;
}
if (d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip)
if (simplifyClipOp && d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip)
op = Qt::ReplaceClip;
d->state->clipPath = path;