Skip to content

Commit bce0bdb

Browse files
committed
perf: optimize rendering at macro zoom levels
Replace bitmap text caching with normalized native text rendering, cull invisible text and decorations, simplify pen strokes at low zoom, and cache section big-title checks per frame.
1 parent 02226a7 commit bce0bdb

13 files changed

Lines changed: 285 additions & 303 deletions

File tree

app/src/core/render/canvas2d/basicRenderer/curveRenderer.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,27 @@ export class CurveRenderer {
4848
this.project.canvas.ctx.lineJoin = "round";
4949
if (stroke.length < 2) return;
5050

51+
if (this.project.camera.currentScale <= 0.065) {
52+
const ctx = this.project.canvas.ctx;
53+
ctx.beginPath();
54+
ctx.moveTo(stroke[0].location.x, stroke[0].location.y);
55+
let previous = stroke[0].location;
56+
for (let i = 1; i < stroke.length - 1; i++) {
57+
const current = stroke[i].location;
58+
const dx = current.x - previous.x;
59+
const dy = current.y - previous.y;
60+
if (dx * dx + dy * dy < 1) {
61+
continue;
62+
}
63+
ctx.lineTo(current.x, current.y);
64+
previous = current;
65+
}
66+
ctx.lineTo(stroke[stroke.length - 1].location.x, stroke[stroke.length - 1].location.y);
67+
ctx.lineWidth = Math.max(0.5, stroke[0].pressure * 5 * this.project.camera.currentScale);
68+
ctx.stroke();
69+
return;
70+
}
71+
5172
this.project.canvas.ctx.beginPath();
5273
this.project.canvas.ctx.moveTo(stroke[0].location.x, stroke[0].location.y);
5374

0 commit comments

Comments
 (0)