Rasterizer: A GPU-accelerated 2D vector graphics engine in ~4k LOC
9 days ago
- #development
- #graphics
- #GPU
- Inspired by Adobe Flash, the author developed Rasterizer, a GPU-accelerated 2D vector graphics engine for iPhone and Mac.
- Rasterizer is up to 60x faster than CPU rendering, ideal for vector animated UI.
- The project took 10 years, focusing on efficiently converting vector paths to anti-aliased pixels with innovative solutions.
- Current implementation uses C++11 and Metal for macOS, with plans for an iOS port.
- The demo app supports SVG and PDF files, with interactive controls for navigation and viewing.
- Path objects follow the Postscript model, supporting even-odd and non-zero fill rules and stroking.
- Scene objects group Path objects with draw parameters like color, transform, and stroke width.
- Rendering involves SceneList objects, grouping Scene objects with their draw parameters.
- Filled paths are rasterized in two stages: to a float mask buffer, then to the color buffer.
- Stroked paths use GPU triangulation, with quadratic Bézier curves solved on the GPU.
- CPU stages use batch parallelism; GPU holds no state, with frames written to double-buffered shared memory.
- The library is licensed under a personal use zlib license.