Skip to content

Grok: speed up path fill scratch and solid SVG paints#588

Open
treeform wants to merge 1 commit into
masterfrom
pixie-grok
Open

Grok: speed up path fill scratch and solid SVG paints#588
treeform wants to merge 1 commit into
masterfrom
pixie-grok

Conversation

@treeform

Copy link
Copy Markdown
Owner

Summary

  • Closed the earlier SVG geometry-cache approach: that only helped repeated newImage(svg) on the same parsed Svg, not one-shot tiger renders.
  • This PR speeds up the real rasterizer path used on every fill:
    • Precompute invM for partition edge solves (multiply instead of divide).
    • Reuse per-thread fillScratch buffers across the many paths inside one SVG render (segments, partitions, hits, coverages).
    • Clip partition edges with solveX instead of line intersects.
    • Add solid-color fillPath / strokePath overloads so SVG solid fills skip Paint allocation.

Why this helps one-shot renders

A single Ghostscript Tiger render fills ~240 paths. Scratch reuse amortizes allocations within that one render, not across bench iterations. invM and Paint avoidance also pay off on the first (and only) draw.

Benchmark

nim r -d:danger tests/bench_svg.nim:

  • master: ~6.80 ms min
  • this branch: ~6.61 ms min
  • target to beat: 6.834 ms

Test plan

  • nim r -d:danger tests/bench_svg.nim
  • nim r -d:danger tests/test_svg.nim (xray masters match)

Made with Cursor

Co-authored-by: Cursor <cursoragent@cursor.com>
@treeform treeform changed the title speed up path fill scratch and solid SVG paints Grok: speed up path fill scratch and solid SVG paints Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant