

GitHub - google/forma: An efficient vector-graphics renderer
source link: https://github.com/google/forma
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

A (thouroughly) parallelized experimental Rust vector-graphics renderer with both a software (CPU) and hardware (GPU) back-end having the following goals, in this order:
- Portability; supporting Fuchsia, Linux, macOS, Windows, Android & iOS.
- Performance; making use of compute-focused pipeline that is highly parallelized both at the instruction-level and the thread-level.
- Simplicity; implementing an easy-to-understand 4-stage pipeline.
- Size; minimizing the number of dependencies and focusing on vector-graphics only.
It relies on Rust's SIMD auto-vectorization/intrinsics and Rayon to have good performance on the CPU, while using WebGPU (wgpu) to take advantage of the GPU.
Getting started
Add the following to your Cargo.toml
dependencies:
forma = { version = "0.1.0", package = "forma-render" }
4-stage Pipeline
1. Curve flattening | 2. Line segment rasterization | 3. Sorting | 4. Painting |
---|---|---|---|
Bézier curves | line segments | pixel segments | sorted pixel segments, old tiles |
![]() ![]() ![]() |
![]() ![]() ![]() |
![]() ![]() ![]() |
![]() ![]() ![]() |
line segments | pixel segments | sorted pixel segments | freshly painted tiles |
Implementation Highlights 
Here are a few implementation highlights that make forma stand out from commonly used vector renderers.
Curvature-aware flatteningCheap translations and rotationsParallel pixel grid intersectionEfficient sortingUpdate only the tiles that change (currently CPU-only)
Animation as it appears on the screen | Updated tiles only |
---|---|
![]() |
![]() |
You can run the demo above with:
cargo run --release -p demo -- spaceship
Similar Projects
forma draws heavy inspiration from the following projects:
Example
You can use the included demo
example to render a few examples, one of which is a non-compliant & incomplete SVG renderer:
cargo run --release -p demo -- svg assets/svgs/paris-30k.svg
It renders enormous SVGs at interactive framerates, even on CPU: (compare to your web browser)
(Currently) Missing Pieces 
Since this project is work-in-progress, breakage in the API, while not drastic, is expected. The performance on the GPU back-end is also expected to improve especially on mobile where performance is known to be poor and where the CPU back-end is currently advised instead.
Other than that:
- Automated layer ordering
- Strokes
- More color spaces for blends & gradients
- Faster GPU sorter
- Use of
f16
for great mobile GPU performance
This is not an officially supported Google product.
Recommend
-
157
vg-renderer - A vector graphics renderer for bgfx, based on ideas from NanoVG and ImDrawList (Dear ImGUI)
-
6
Introducing Unity Forma: Reimagine marketing with real-time 3D Edward Martin,
-
11
Unity Forma makes it easy to create and publish marketing content and interactive experiences, including real-time 3D product configurators, from 3D product data. Let’s explore the import process and how to take the first step to start market...
-
12
Unity Forma for manufacturing: Creating a virtual machinery showroom
-
8
Create marketing assets faster with Forma Render
-
6
Kobo Forma 電子書閱讀器發佈:2020-07-302,569 Views非技術類讀書
-
12
Abstracting the Graphics API for a toy renderer – Interplay of Light Skip to content I’ve been asked a few times i...
-
10
Search Engine Land » Google » Google Search rolls out a more visual search interface on mobile with grid format ...
-
6
Forma AI poised to grow AI-supported sales compensation management platform
-
5
Rodolfo Felipe Celante April 27, 2023 5 minute re...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK