summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChunLin Wang <wangchunlin@uniontech.com>2022-02-08 17:25:51 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-02-10 06:17:15 +0000
commit6d2c06a667152915cf95dc7686ec8f73690783aa (patch)
tree30437ca83ae09c417fd535d281044e610cdb3fc7
parent9b6e3c0d5d1e5d743ffd9d6e0b84b0fba14a5390 (diff)
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 Change-Id: I1e0ebbc2d6e1ffd98b9f3f537e83893579606a4b Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit 52a83658c3e930e4b751ea2546baf9b13b1fce5b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/gui/painting/qpainter.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 0ebc6253db..f1b02f3e9b 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -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;