raster: add pure-Go PNG, GIF, PDF, and PPTX rendering - #2868
Open
alixander wants to merge 2 commits into
Open
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
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 pure-Go PNG, GIF, PDF, and PPTX rendering.
The implementation is organized around four packages:
d2scenedefines a typed drawing model.d2scenebuildtranslates D2 shapes, text, links, effects, assets, and animation into scenes.d2rasterpaints scenes with a D2-owned scanline rasterizer.d2svgimportimports the bounded SVG subset used by image assets and MathJax.PNG renders one frame. GIF samples animated scenes while preserving frame timing. PDF and PPTX preserve pages, slides, and links. Missing images render a deterministic placeholder in their declared box. JPEG assets honor EXIF orientations 1–8, and raster assets are fully decoded only when they are painted.
The rasterizer provides analytic nonzero-winding coverage, adaptive curve flattening, bounded row scratch space, geometry-aware work accounting, and cancellation. Canvas, path, filter, asset, font, animation, and multi-board limits are checked before output is written.
Deterministic resources
Release integration
The CLI uses the native renderer directly for PNG, GIF, PDF, and PPTX. Archive CI verifies PNG export on Linux, macOS, and Windows for amd64 and arm64. The release container contains only the runtime dependencies needed by the native binary.
All six exact-head release binaries and archives pass their existing limits and reproduce byte-for-byte across clean builds. Binary growth is 11.53–12.19%; archive growth is 23.24–24.97%. The tightest result is macOS/amd64 at 39,917,376 of 40,000,000 bytes; the largest archive is Windows/amd64 at 17,176,172 of 18,000,000 bytes.
Performance
On an Apple M4, seven representative source-to-image cases took 436.469 ms with native rendering and 548.006 ms with D2-to-SVG plus official resvg 0.47.0. Native rendering used 20.353% less aggregate time. Each case used three warmups and 13 alternating fresh-process samples, and every output was decoded and dimension-checked.
Validation
./make.sh: formatting, generated-file checks, Go build/vet/tests, end-to-end tests, WebAssembly build, 43 JavaScript unit tests, and two JavaScript integrationsgovulncheck ./..., module verification, dependency-closure checks, and deterministic six-platform release builds