# servo/pathfinder architecture

> Architecture diagram of the GitHub repository servo/pathfinder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/servo/pathfinder
- Repository: https://github.com/servo/pathfinder

## Overview

Pathfinder is a modular GPU rasterizer for fonts and vector graphics, exposed through a canvas-like API and Rust/C bindings. The main workflow is to create or load vector content, build a scene, prepare and tile it, then render it through a GPU backend. Separate branches cover text, SVG/SWF/Lottie input, and vector export. The README documents backend and rendering capabilities; several subsystem connections below are dashed because their implementation files were not sampled.

Main entry points: [`renderer/src/scene.rs`](https://github.com/servo/pathfinder/blob/main/renderer/src/scene.rs) (Scene model), [`canvas/src/lib.rs`](https://github.com/servo/pathfinder/blob/main/canvas/src/lib.rs) (Canvas API), [`gpu/src/lib.rs`](https://github.com/servo/pathfinder/blob/main/gpu/src/lib.rs) (GPU abstractions), [`renderer/src/builder.rs`](https://github.com/servo/pathfinder/blob/main/renderer/src/builder.rs) (Scene preparation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Authoring and content"]
  node_canvas["Canvas API<br/>[lib.rs]"]
  node_text["Text rendering<br/>[text.rs]"]
  node_content["Vector content<br/>[outline.rs]"]
  node_geometry["Geometry primitives<br/>[vector.rs]"]
end

subgraph group_rendering["Scene rendering"]
  node_scene["Scene model<br/>[scene.rs]"]
  node_paint["Paint data<br/>[paint.rs]"]
  node_builder["Scene preparation<br/>[builder.rs]"]
  node_tiler["Tile generation<br/>[tiler.rs]"]
  node_tilemap["Tile mapping<br/>[tile_map.rs]"]
  node_render["GPU renderer<br/>[renderer.rs]"]
end

subgraph group_platform["GPU platforms"]
  node_gpu["GPU abstractions<br/>[lib.rs]"]
  node_gl["OpenGL backend<br/>[lib.rs]"]
  node_webgl["WebGL backend<br/>[lib.rs]"]
  node_metal["Metal backend<br/>[lib.rs]"]
end

subgraph group_formats["Formats and export"]
  node_svg["SVG loading<br/>[lib.rs]"]
  node_swf["SWF shapes<br/>[shapes.rs]"]
  node_lottie["Lottie input<br/>[lib.rs]"]
  node_export["Vector export<br/>[lib.rs]"]
  node_pdf["PDF writer<br/>[pdf.rs]"]
end

subgraph group_interfaces["Application interfaces"]
  node_cbind["C bindings<br/>[lib.rs]"]
  node_webcanvas["Web canvas<br/>[lib.rs]"]
  node_ui["Vector UI<br/>[lib.rs]"]
end

node_app(("Application"))
node_output(("Rendered output"))

node_app -->|"draws with"| node_canvas
node_canvas -.->|"creates paths"| node_content
node_canvas -.->|"draws text"| node_text
node_canvas -->|"adds draw paths"| node_scene
node_content -.->|"uses geometry"| node_geometry
node_scene -.->|"references paint"| node_paint
node_scene -.->|"prepares scene"| node_builder
node_builder -.->|"generates tiles"| node_tiler
node_tiler -.->|"maps tiles"| node_tilemap
node_builder -.->|"submits work"| node_render
node_render -.->|"issues GPU work"| node_gpu
node_gpu -.->|"supports backend"| node_gl
node_gpu -.->|"supports backend"| node_webgl
node_gpu -.->|"supports backend"| node_metal
node_render -->|"renders"| node_output
node_app -->|"loads SVG"| node_svg
node_svg -.->|"provides vector content"| node_scene
node_app -.->|"loads SWF"| node_swf
node_app -.->|"loads animation"| node_lottie
node_scene -->|"exports scene"| node_export
node_export -->|"writes PDF"| node_pdf
node_app -->|"uses bindings"| node_cbind
node_app -.->|"uses web canvas"| node_webcanvas
node_app -.->|"uses vector UI"| node_ui

click node_canvas "https://github.com/servo/pathfinder/blob/main/canvas/src/lib.rs"
click node_text "https://github.com/servo/pathfinder/blob/main/canvas/src/text.rs"
click node_content "https://github.com/servo/pathfinder/blob/main/content/src/outline.rs"
click node_geometry "https://github.com/servo/pathfinder/blob/main/geometry/src/vector.rs"
click node_scene "https://github.com/servo/pathfinder/blob/main/renderer/src/scene.rs"
click node_paint "https://github.com/servo/pathfinder/blob/main/renderer/src/paint.rs"
click node_builder "https://github.com/servo/pathfinder/blob/main/renderer/src/builder.rs"
click node_tiler "https://github.com/servo/pathfinder/blob/main/renderer/src/tiler.rs"
click node_tilemap "https://github.com/servo/pathfinder/blob/main/renderer/src/tile_map.rs"
click node_render "https://github.com/servo/pathfinder/blob/main/renderer/src/gpu/renderer.rs"
click node_gpu "https://github.com/servo/pathfinder/blob/main/gpu/src/lib.rs"
click node_gl "https://github.com/servo/pathfinder/blob/main/gl/src/lib.rs"
click node_webgl "https://github.com/servo/pathfinder/blob/main/webgl/src/lib.rs"
click node_metal "https://github.com/servo/pathfinder/blob/main/metal/src/lib.rs"
click node_svg "https://github.com/servo/pathfinder/blob/main/svg/src/lib.rs"
click node_swf "https://github.com/servo/pathfinder/blob/main/swf/src/shapes.rs"
click node_lottie "https://github.com/servo/pathfinder/blob/main/lottie/src/lib.rs"
click node_export "https://github.com/servo/pathfinder/blob/main/export/src/lib.rs"
click node_pdf "https://github.com/servo/pathfinder/blob/main/export/src/pdf.rs"
click node_cbind "https://github.com/servo/pathfinder/blob/main/c/src/lib.rs"
click node_webcanvas "https://github.com/servo/pathfinder/blob/main/web_canvas/src/lib.rs"
click node_ui "https://github.com/servo/pathfinder/blob/main/ui/src/lib.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_canvas,node_text,node_content,node_geometry toneBlue
class node_scene,node_paint,node_builder,node_tiler,node_tilemap,node_render toneAmber
class node_gpu,node_gl,node_webgl,node_metal toneMint
class node_svg,node_swf,node_lottie,node_export,node_pdf toneRose
class node_cbind,node_webcanvas,node_ui,node_app,node_output toneIndigo
```

## Components

### Authoring and content

- [Canvas API](https://github.com/servo/pathfinder/blob/main/canvas/src/lib.rs): `canvas/src/lib.rs`
- [Text rendering](https://github.com/servo/pathfinder/blob/main/canvas/src/text.rs): `canvas/src/text.rs`
- [Vector content](https://github.com/servo/pathfinder/blob/main/content/src/outline.rs): `content/src/outline.rs`
- [Geometry primitives](https://github.com/servo/pathfinder/blob/main/geometry/src/vector.rs): `geometry/src/vector.rs`

### Scene rendering

- [Scene model](https://github.com/servo/pathfinder/blob/main/renderer/src/scene.rs): `renderer/src/scene.rs`
- [Paint data](https://github.com/servo/pathfinder/blob/main/renderer/src/paint.rs): `renderer/src/paint.rs`
- [Scene preparation](https://github.com/servo/pathfinder/blob/main/renderer/src/builder.rs): `renderer/src/builder.rs`
- [Tile generation](https://github.com/servo/pathfinder/blob/main/renderer/src/tiler.rs): `renderer/src/tiler.rs`
- [Tile mapping](https://github.com/servo/pathfinder/blob/main/renderer/src/tile_map.rs): `renderer/src/tile_map.rs`
- [GPU renderer](https://github.com/servo/pathfinder/blob/main/renderer/src/gpu/renderer.rs): `renderer/src/gpu/renderer.rs`

### GPU platforms

- [GPU abstractions](https://github.com/servo/pathfinder/blob/main/gpu/src/lib.rs): `gpu/src/lib.rs`
- [OpenGL backend](https://github.com/servo/pathfinder/blob/main/gl/src/lib.rs): `gl/src/lib.rs`
- [WebGL backend](https://github.com/servo/pathfinder/blob/main/webgl/src/lib.rs): `webgl/src/lib.rs`
- [Metal backend](https://github.com/servo/pathfinder/blob/main/metal/src/lib.rs): `metal/src/lib.rs`

### Formats and export

- [SVG loading](https://github.com/servo/pathfinder/blob/main/svg/src/lib.rs): `svg/src/lib.rs`
- [SWF shapes](https://github.com/servo/pathfinder/blob/main/swf/src/shapes.rs): `swf/src/shapes.rs`
- [Lottie input](https://github.com/servo/pathfinder/blob/main/lottie/src/lib.rs): `lottie/src/lib.rs`
- [Vector export](https://github.com/servo/pathfinder/blob/main/export/src/lib.rs): `export/src/lib.rs`
- [PDF writer](https://github.com/servo/pathfinder/blob/main/export/src/pdf.rs): `export/src/pdf.rs`

### Application interfaces

- [C bindings](https://github.com/servo/pathfinder/blob/main/c/src/lib.rs): `c/src/lib.rs`
- [Web canvas](https://github.com/servo/pathfinder/blob/main/web_canvas/src/lib.rs): `web_canvas/src/lib.rs`
- [Vector UI](https://github.com/servo/pathfinder/blob/main/ui/src/lib.rs): `ui/src/lib.rs`

### Other components

- **Application**
- **Rendered output**

## Connections

- Application → Canvas API: draws with (evidence: `README.md`)
- Canvas API → Vector content: creates paths
- Canvas API → Text rendering: draws text (evidence: `canvas/src/lib.rs`)
- Canvas API → Scene model: adds draw paths (evidence: `canvas/src/lib.rs`)
- Vector content → Geometry primitives: uses geometry
- Scene model → Paint data: references paint
- Scene model → Scene preparation: prepares scene
- Scene preparation → Tile generation: generates tiles
- Tile generation → Tile mapping: maps tiles
- Scene preparation → GPU renderer: submits work
- GPU renderer → GPU abstractions: issues GPU work
- GPU abstractions → OpenGL backend: supports backend
- GPU abstractions → WebGL backend: supports backend
- GPU abstractions → Metal backend: supports backend
- GPU renderer → Rendered output: renders (evidence: `README.md`)
- Application → SVG loading: loads SVG (evidence: `README.md`)
- SVG loading → Scene model: provides vector content
- Application → SWF shapes: loads SWF
- Application → Lottie input: loads animation
- Scene model → Vector export: exports scene (evidence: `export/src/lib.rs`)
- Vector export → PDF writer: writes PDF (evidence: `export/src/lib.rs`)
- Application → C bindings: uses bindings (evidence: `README.md`)
- Application → Web canvas: uses web canvas
- Application → Vector UI: uses vector UI
