raster: add pure-Go PNG, GIF, PDF, and PPTX rendering - #2868
Merged
Conversation
alixander
force-pushed
the
agent/native-raster-renderer
branch
2 times, most recently
from
August 29, 2026 23:23
175cc21 to
705d465
Compare
alixander
force-pushed
the
agent/native-raster-renderer
branch
8 times, most recently
from
September 2, 2026 00:34
d935139 to
6f14deb
Compare
alixander
force-pushed
the
agent/native-raster-renderer
branch
from
September 2, 2026 00:39
6f14deb to
235c34a
Compare
alixander
force-pushed
the
agent/native-raster-renderer
branch
from
September 2, 2026 14:49
c31d3fa to
51c7830
Compare
This was referenced Sep 3, 2026
This was referenced Sep 3, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human
AI
Adds native Go rendering for PNG, GIF, PDF, and PPTX exports.
The implementation has four main layers:
d2sceneis the typed drawing model shared by renderers.d2scenebuildconverts compiled D2 diagrams into scenes, including text, links, effects, assets, and animation.d2rasterpaints scenes with an analytic scanline rasterizer.d2svgimportparses the bounded SVG subset used by image assets and MathJax output.PNG renders one frame. GIF preserves animation timing. PDF and PPTX preserve boards and links. Missing images render a deterministic placeholder in their declared box; JPEG assets honor EXIF orientations 1–8.
The renderer bounds canvas size, path work, filters, decoded assets, fonts, animation, multi-board exports, and encoded output before writing a result. Rendering and encoding honor cancellation throughout.
Text and assets
CLI and packaging
The existing CLI output-format behavior directly selects the appropriate renderer; there is no backend flag or additional command. The release container no longer installs Node.js or Playwright because those packages are not runtime dependencies of these export formats.
The stripped
CGO_ENABLED=0binary is 36,849,058 bytes on darwin/arm64: 3,223,824 bytes (9.59%) larger than current master and 679,776 bytes smaller than the previous PR revision.Performance
Operation-scoped workspaces reuse frame, scanline, offscreen, shaping, PNG, and GIF storage without retaining caller-owned inputs or outputs. Representative Apple M4 measurements include:
image/pngimage/gifFast paths retain exact byte-output tests against the standard encoders and scalar raster oracles.
Validation
CGO_ENABLED=0 go test ./...CGO_ENABLED=1 go test -race ./..., followed by focused exact-head race tests after the final optimizationsgo vet ./...,go mod verify, and a cleango mod tidy -diff