Fix clip state tracking in Context2D
A recent change (f45fe58ad2
)
introduced the concept of clipping being disabled for a context,
so that it can start with no clip path set. However, this state
is not properly tracked, so an attempt to restore a context state
which has no clip path does not work properly. This change adds
this information to the Clip command, so that it can be properly
restored.
This patch also re-enables a test case which was supposed to
check this behavior, but had been disabled.
Task-number: QTBUG-40312
Change-Id: I3fd5626ecfcc1298a81931828cbb590290098a92
Reviewed-by: Ulf Hermann <ulf.hermann@digia.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
This commit is contained in:
parent
22792559f5
commit
38d37b13a3
|
@ -3548,7 +3548,7 @@ void QQuickContext2D::clip()
|
|||
state.clip = true;
|
||||
state.clipPath = clipPath;
|
||||
}
|
||||
buffer()->clip(state.clipPath);
|
||||
buffer()->clip(state.clip, state.clipPath);
|
||||
}
|
||||
|
||||
void QQuickContext2D::stroke()
|
||||
|
@ -4283,8 +4283,8 @@ void QQuickContext2D::popState()
|
|||
if (newState.miterLimit != state.miterLimit)
|
||||
buffer()->setMiterLimit(newState.miterLimit);
|
||||
|
||||
if (newState.clip && (!state.clip || newState.clipPath != state.clipPath))
|
||||
buffer()->clip(newState.clipPath);
|
||||
if (newState.clip != state.clip || newState.clipPath != state.clipPath)
|
||||
buffer()->clip(newState.clip, newState.clipPath);
|
||||
|
||||
if (newState.shadowBlur != state.shadowBlur)
|
||||
buffer()->setShadowBlur(newState.shadowBlur);
|
||||
|
|
|
@ -207,6 +207,7 @@ void QQuickContext2DCommandBuffer::setPainterState(QPainter* p, const QQuickCont
|
|||
if (state.globalCompositeOperation != p->compositionMode())
|
||||
p->setCompositionMode(state.globalCompositeOperation);
|
||||
|
||||
p->setClipping(state.clip);
|
||||
if (state.clip)
|
||||
p->setClipPath(state.clipPath);
|
||||
}
|
||||
|
@ -383,9 +384,11 @@ void QQuickContext2DCommandBuffer::replay(QPainter* p, QQuickContext2D::State& s
|
|||
}
|
||||
case QQuickContext2D::Clip:
|
||||
{
|
||||
state.clip = takeBool();
|
||||
state.clipPath = takePath();
|
||||
p->setClipping(true);
|
||||
p->setClipPath(state.clipPath);
|
||||
p->setClipping(state.clip);
|
||||
if (state.clip)
|
||||
p->setClipPath(state.clipPath);
|
||||
break;
|
||||
}
|
||||
case QQuickContext2D::GlobalAlpha:
|
||||
|
|
|
@ -145,9 +145,10 @@ public:
|
|||
pathes << path;
|
||||
}
|
||||
|
||||
inline void clip(const QPainterPath& path)
|
||||
inline void clip(bool enabled, const QPainterPath& path)
|
||||
{
|
||||
commands << QQuickContext2D::Clip;
|
||||
bools << enabled;
|
||||
pathes << path;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ CanvasTestCase {
|
|||
ctx.restore();
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
//comparePixel(ctx, 50,25, 0,255,0,255);
|
||||
comparePixel(ctx, 50,25, 0,255,0,255);
|
||||
canvas.destroy()
|
||||
}
|
||||
function test_fillStyle(row) {
|
||||
|
|
Loading…
Reference in New Issue