Merge pull request #19732 from calixteman/rm_useless_beginpath

Remove few useless beginPaths
This commit is contained in:
calixteman 2025-04-02 13:46:05 +02:00 committed by GitHub
commit b7437376f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1605,7 +1605,6 @@ class CanvasGraphics {
const paths = this.pendingTextPaths; const paths = this.pendingTextPaths;
const ctx = this.ctx; const ctx = this.ctx;
if (paths === undefined) { if (paths === undefined) {
ctx.beginPath();
return; return;
} }
@ -1622,7 +1621,6 @@ class CanvasGraphics {
} }
ctx.clip(newPath); ctx.clip(newPath);
ctx.beginPath();
delete this.pendingTextPaths; delete this.pendingTextPaths;
} }
@ -2127,8 +2125,9 @@ class CanvasGraphics {
} }
setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) { setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
this.ctx.rect(llx, lly, urx - llx, ury - lly); const clip = new Path2D();
this.ctx.clip(); clip.rect(llx, lly, urx - llx, ury - lly);
this.ctx.clip(clip);
this.endPath(); this.endPath();
} }
@ -2271,11 +2270,11 @@ class CanvasGraphics {
this.baseTransform = getCurrentTransform(this.ctx); this.baseTransform = getCurrentTransform(this.ctx);
if (bbox) { if (bbox) {
const width = bbox[2] - bbox[0];
const height = bbox[3] - bbox[1];
this.ctx.rect(bbox[0], bbox[1], width, height);
this.current.updateRectMinMax(getCurrentTransform(this.ctx), bbox); this.current.updateRectMinMax(getCurrentTransform(this.ctx), bbox);
this.clip(); const [x0, y0, x1, y1] = bbox;
const clip = new Path2D();
clip.rect(x0, y0, x1 - x0, y1 - y0);
this.ctx.clip(clip);
this.endPath(); this.endPath();
} }
} }
@ -2503,9 +2502,9 @@ class CanvasGraphics {
// Consume a potential path before clipping. // Consume a potential path before clipping.
this.endPath(); this.endPath();
this.ctx.rect(rect[0], rect[1], width, height); const clip = new Path2D();
this.ctx.clip(); clip.rect(rect[0], rect[1], width, height);
this.ctx.beginPath(); this.ctx.clip(clip);
} }
} }
@ -2902,7 +2901,6 @@ class CanvasGraphics {
this.pendingClip = null; this.pendingClip = null;
} }
this.current.startNewPathAndClipBox(this.current.clipBox); this.current.startNewPathAndClipBox(this.current.clipBox);
ctx.beginPath();
} }
getSinglePixelWidth() { getSinglePixelWidth() {