Skip to content

Commit 7c5695f

Browse files
authored
Merge pull request #19708 from calixteman/fix_save_smask_mode
Fix save/restore while in smask mode
2 parents 94b2c86 + c275c72 commit 7c5695f

1 file changed

Lines changed: 18 additions & 22 deletions

File tree

src/display/canvas.js

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,39 +1545,35 @@ class CanvasGraphics {
15451545
// Copy the temporary canvas state to the main(suspended) canvas to keep
15461546
// it in sync.
15471547
copyCtxState(this.ctx, this.suspendedCtx);
1548-
// Don't bother calling save on the temporary canvas since state is not
1549-
// saved there.
1550-
this.suspendedCtx.save();
1551-
} else {
1552-
this.ctx.save();
15531548
}
1549+
this.ctx.save();
15541550
const old = this.current;
15551551
this.stateStack.push(old);
15561552
this.current = old.clone();
15571553
}
15581554

15591555
restore() {
1560-
if (this.stateStack.length === 0 && this.inSMaskMode) {
1561-
this.endSMaskMode();
1562-
}
1563-
if (this.stateStack.length !== 0) {
1564-
this.current = this.stateStack.pop();
1556+
if (this.stateStack.length === 0) {
15651557
if (this.inSMaskMode) {
1566-
// Graphics state is stored on the main(suspended) canvas. Restore its
1567-
// state then copy it over to the temporary canvas.
1568-
this.suspendedCtx.restore();
1569-
copyCtxState(this.suspendedCtx, this.ctx);
1570-
} else {
1571-
this.ctx.restore();
1558+
this.endSMaskMode();
15721559
}
1573-
this.checkSMaskState();
1574-
1575-
// Ensure that the clipping path is reset (fixes issue6413.pdf).
1576-
this.pendingClip = null;
1560+
return;
1561+
}
15771562

1578-
this._cachedScaleForStroking[0] = -1;
1579-
this._cachedGetSinglePixelWidth = null;
1563+
this.current = this.stateStack.pop();
1564+
this.ctx.restore();
1565+
if (this.inSMaskMode) {
1566+
// Graphics state is stored on the main(suspended) canvas. Restore its
1567+
// state then copy it over to the temporary canvas.
1568+
copyCtxState(this.suspendedCtx, this.ctx);
15801569
}
1570+
this.checkSMaskState();
1571+
1572+
// Ensure that the clipping path is reset (fixes issue6413.pdf).
1573+
this.pendingClip = null;
1574+
1575+
this._cachedScaleForStroking[0] = -1;
1576+
this._cachedGetSinglePixelWidth = null;
15811577
}
15821578

15831579
transform(a, b, c, d, e, f) {

0 commit comments

Comments
 (0)