From df85826f31dfce3214186ff7011df0421f49a41e Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Wed, 6 Mar 2024 16:44:08 +0100 Subject: [PATCH] Don't stroke when the current path isn't in the current clip box --- src/display/canvas.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/display/canvas.js b/src/display/canvas.js index 384b9fd51e913..808a1d89ccacd 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -578,6 +578,19 @@ class CanvasExtraState { this.maxY = 0; } + isPathInClipBox() { + const { + clipBox: [x0, y0, x1, y1], + minX, + minY, + maxX, + maxY, + } = this; + return ( + minX === Infinity || !(minX > x1 || maxX < x0 || minY > y1 || maxY < y0) + ); + } + getClippedPathBoundingBox(pathType = PathType.FILL, transform = null) { return Util.intersect( this.clipBox, @@ -1764,6 +1777,9 @@ class CanvasGraphics { } stroke(consumePath = true) { + if (!this.current.isPathInClipBox()) { + return; + } const ctx = this.ctx; const strokeColor = this.current.strokeColor; // For stroke we want to temporarily change the global alpha to the