# linebender/resvg architecture

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

- Interactive diagram: https://gitdiagram.com/linebender/resvg
- Repository: https://github.com/linebender/resvg

## Overview

resvg is a static-SVG rendering product exposed as Rust and C libraries, a CLI, and supporting desktop tools. Its principal workflow preprocesses SVG into a usvg tree, then renders that tree into pixels with resvg. The graph preserves the documented preprocessing/rendering boundary, major parsing and rendering subsystems, and auxiliary interfaces. Arrows are limited to relationships visible in the supplied excerpts or documented in the README; unsampled wiring is left unasserted or marked unverified.

Main entry points: [`crates/resvg/src/render.rs`](https://github.com/linebender/resvg/blob/main/crates/resvg/src/render.rs) (Node render dispatch), [`crates/resvg/src/lib.rs`](https://github.com/linebender/resvg/blob/main/crates/resvg/src/lib.rs) (resvg rendering API), [`crates/usvg/src/lib.rs`](https://github.com/linebender/resvg/blob/main/crates/usvg/src/lib.rs) (usvg preprocessing API), [`crates/resvg/src/filter/mod.rs`](https://github.com/linebender/resvg/blob/main/crates/resvg/src/filter/mod.rs) (Filter execution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["SVG preprocessing"]
  node_usvg_api["usvg preprocessing API<br/>[lib.rs]"]
  node_svg_document["SVG document parsing<br/>[parse.rs]"]
  node_svg_converter["Tree conversion<br/>[converter.rs]"]
  node_svg_images["Image parsing<br/>[image.rs]"]
  node_paint_servers["Paint servers<br/>[paint_server.rs]"]
  node_filter_parser["Filter parsing<br/>[filter.rs]"]
  node_text_parser["SVG text parsing<br/>[text.rs]"]
  node_tree_model["Preprocessed tree<br/>[mod.rs]"]
  node_tree_filters["Tree filter model<br/>[filter.rs]"]
  node_text_layout["Text layout and cache<br/>[layout.rs]"]
end

subgraph group_render["Pixel rendering"]
  node_resvg_api["resvg rendering API<br/>[lib.rs]"]
  node_render_dispatch["Node render dispatch<br/>[render.rs]"]
  node_path_render["Path and paint rendering<br/>[path.rs]"]
  node_image_render["Image rendering<br/>[image.rs]"]
  node_clip_render["Clipping<br/>[clip.rs]"]
  node_mask_render["Masking<br/>[mask.rs]"]
  node_filter_render["Filter execution<br/>[mod.rs]"]
  node_filter_lighting["Filter lighting<br/>[lighting.rs]"]
end

subgraph group_interfaces["Product interfaces"]
  node_cli["Command-line renderer<br/>[main.rs]"]
  node_c_api["C API<br/>[lib.rs]"]
  node_thumbnailer["Explorer thumbnailer"]
  node_thumbnail_com["Thumbnail COM interfaces"]
  node_thumbnail_utils["Thumbnail conversion<br/>[utils.rs]"]
  node_viewer["Qt SVG viewer<br/>[svgview.cpp]"]
end

subgraph group_support["Shared support"]
  node_geometry["Render geometry<br/>[geom.rs]"]
  node_svg_values["SVG value types<br/>[colors.rs]"]
end

node_user(("SVG consumer"))
node_svg_input["SVG input"]

node_user -->|"provides"| node_svg_input
node_svg_input -.->|"preprocesses"| node_usvg_api
node_usvg_api -->|"passes tree"| node_resvg_api
node_resvg_api -->|"dispatches rendering"| node_render_dispatch
node_render_dispatch -->|"renders paths"| node_path_render
node_render_dispatch -->|"renders images"| node_image_render
node_render_dispatch -->|"applies filters"| node_filter_render
node_filter_render -->|"uses lighting"| node_filter_lighting
node_render_dispatch -->|"uses clipping"| node_clip_render
node_render_dispatch -->|"uses masks"| node_mask_render
node_filter_render -->|"uses geometry"| node_geometry
node_thumbnailer -->|"implements interface"| node_thumbnail_com
node_thumbnailer -->|"renders thumbnail"| node_thumbnail_utils
node_thumbnail_utils -.->|"parses stream"| node_usvg_api
node_thumbnail_utils -.->|"renders thumbnail"| node_resvg_api
node_cli -.->|"uses preprocessing"| node_usvg_api
node_cli -.->|"uses renderer"| node_resvg_api
node_c_api -.->|"exposes rendering"| node_resvg_api
node_viewer -.->|"uses C API"| node_c_api

click node_usvg_api "https://github.com/linebender/resvg/blob/main/crates/usvg/src/lib.rs"
click node_svg_document "https://github.com/linebender/resvg/blob/main/crates/usvg/src/parser/svgtree/parse.rs"
click node_svg_converter "https://github.com/linebender/resvg/blob/main/crates/usvg/src/parser/converter.rs"
click node_svg_images "https://github.com/linebender/resvg/blob/main/crates/usvg/src/parser/image.rs"
click node_paint_servers "https://github.com/linebender/resvg/blob/main/crates/usvg/src/parser/paint_server.rs"
click node_filter_parser "https://github.com/linebender/resvg/blob/main/crates/usvg/src/parser/filter.rs"
click node_text_parser "https://github.com/linebender/resvg/blob/main/crates/usvg/src/parser/svgtree/text.rs"
click node_tree_model "https://github.com/linebender/resvg/blob/main/crates/usvg/src/tree/mod.rs"
click node_tree_filters "https://github.com/linebender/resvg/blob/main/crates/usvg/src/tree/filter.rs"
click node_text_layout "https://github.com/linebender/resvg/blob/main/crates/usvg/src/text/layout.rs"
click node_resvg_api "https://github.com/linebender/resvg/blob/main/crates/resvg/src/lib.rs"
click node_render_dispatch "https://github.com/linebender/resvg/blob/main/crates/resvg/src/render.rs"
click node_path_render "https://github.com/linebender/resvg/blob/main/crates/resvg/src/path.rs"
click node_image_render "https://github.com/linebender/resvg/blob/main/crates/resvg/src/image.rs"
click node_clip_render "https://github.com/linebender/resvg/blob/main/crates/resvg/src/clip.rs"
click node_mask_render "https://github.com/linebender/resvg/blob/main/crates/resvg/src/mask.rs"
click node_filter_render "https://github.com/linebender/resvg/blob/main/crates/resvg/src/filter/mod.rs"
click node_filter_lighting "https://github.com/linebender/resvg/blob/main/crates/resvg/src/filter/lighting.rs"
click node_geometry "https://github.com/linebender/resvg/blob/main/crates/resvg/src/geom.rs"
click node_svg_values "https://github.com/linebender/resvg/blob/main/crates/svgtypes/src/colors.rs"
click node_cli "https://github.com/linebender/resvg/blob/main/crates/resvg/src/main.rs"
click node_c_api "https://github.com/linebender/resvg/blob/main/crates/c-api/lib.rs"
click node_thumbnailer "https://github.com/linebender/resvg/blob/main/tools/explorer-thumbnailer/src/thumbnail_provider.rs"
click node_thumbnail_com "https://github.com/linebender/resvg/blob/main/tools/explorer-thumbnailer/src/interfaces/ithumbnail_provider.rs"
click node_thumbnail_utils "https://github.com/linebender/resvg/blob/main/tools/explorer-thumbnailer/src/utils.rs"
click node_viewer "https://github.com/linebender/resvg/blob/main/tools/viewsvg/svgview.cpp"

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_usvg_api,node_svg_document,node_svg_converter,node_svg_images,node_paint_servers,node_filter_parser,node_text_parser,node_tree_model,node_tree_filters,node_text_layout toneBlue
class node_resvg_api,node_render_dispatch,node_path_render,node_image_render,node_clip_render,node_mask_render,node_filter_render,node_filter_lighting toneAmber
class node_cli,node_c_api,node_thumbnailer,node_thumbnail_com,node_thumbnail_utils,node_viewer toneMint
class node_geometry,node_svg_values toneRose
class node_user,node_svg_input toneIndigo
```

## Components

### SVG preprocessing

- [usvg preprocessing API](https://github.com/linebender/resvg/blob/main/crates/usvg/src/lib.rs): `crates/usvg/src/lib.rs`
- [SVG document parsing](https://github.com/linebender/resvg/blob/main/crates/usvg/src/parser/svgtree/parse.rs): `crates/usvg/src/parser/svgtree/parse.rs`
- [Tree conversion](https://github.com/linebender/resvg/blob/main/crates/usvg/src/parser/converter.rs): `crates/usvg/src/parser/converter.rs`
- [Image parsing](https://github.com/linebender/resvg/blob/main/crates/usvg/src/parser/image.rs): `crates/usvg/src/parser/image.rs`
- [Paint servers](https://github.com/linebender/resvg/blob/main/crates/usvg/src/parser/paint_server.rs): `crates/usvg/src/parser/paint_server.rs`
- [Filter parsing](https://github.com/linebender/resvg/blob/main/crates/usvg/src/parser/filter.rs): `crates/usvg/src/parser/filter.rs`
- [SVG text parsing](https://github.com/linebender/resvg/blob/main/crates/usvg/src/parser/svgtree/text.rs): `crates/usvg/src/parser/svgtree/text.rs`
- [Preprocessed tree](https://github.com/linebender/resvg/blob/main/crates/usvg/src/tree/mod.rs): `crates/usvg/src/tree/mod.rs`
- [Tree filter model](https://github.com/linebender/resvg/blob/main/crates/usvg/src/tree/filter.rs): `crates/usvg/src/tree/filter.rs`
- [Text layout and cache](https://github.com/linebender/resvg/blob/main/crates/usvg/src/text/layout.rs): `crates/usvg/src/text/layout.rs`

### Pixel rendering

- [resvg rendering API](https://github.com/linebender/resvg/blob/main/crates/resvg/src/lib.rs): `crates/resvg/src/lib.rs`
- [Node render dispatch](https://github.com/linebender/resvg/blob/main/crates/resvg/src/render.rs): `crates/resvg/src/render.rs`
- [Path and paint rendering](https://github.com/linebender/resvg/blob/main/crates/resvg/src/path.rs): `crates/resvg/src/path.rs`
- [Image rendering](https://github.com/linebender/resvg/blob/main/crates/resvg/src/image.rs): `crates/resvg/src/image.rs`
- [Clipping](https://github.com/linebender/resvg/blob/main/crates/resvg/src/clip.rs): `crates/resvg/src/clip.rs`
- [Masking](https://github.com/linebender/resvg/blob/main/crates/resvg/src/mask.rs): `crates/resvg/src/mask.rs`
- [Filter execution](https://github.com/linebender/resvg/blob/main/crates/resvg/src/filter/mod.rs): `crates/resvg/src/filter/mod.rs`
- [Filter lighting](https://github.com/linebender/resvg/blob/main/crates/resvg/src/filter/lighting.rs): `crates/resvg/src/filter/lighting.rs`

### Product interfaces

- [Command-line renderer](https://github.com/linebender/resvg/blob/main/crates/resvg/src/main.rs): `crates/resvg/src/main.rs`
- [C API](https://github.com/linebender/resvg/blob/main/crates/c-api/lib.rs): `crates/c-api/lib.rs`
- [Explorer thumbnailer](https://github.com/linebender/resvg/blob/main/tools/explorer-thumbnailer/src/thumbnail_provider.rs): `tools/explorer-thumbnailer/src/thumbnail_provider.rs`
- [Thumbnail COM interfaces](https://github.com/linebender/resvg/blob/main/tools/explorer-thumbnailer/src/interfaces/ithumbnail_provider.rs): `tools/explorer-thumbnailer/src/interfaces/ithumbnail_provider.rs`
- [Thumbnail conversion](https://github.com/linebender/resvg/blob/main/tools/explorer-thumbnailer/src/utils.rs): `tools/explorer-thumbnailer/src/utils.rs`
- [Qt SVG viewer](https://github.com/linebender/resvg/blob/main/tools/viewsvg/svgview.cpp): `tools/viewsvg/svgview.cpp`

### Shared support

- [Render geometry](https://github.com/linebender/resvg/blob/main/crates/resvg/src/geom.rs): `crates/resvg/src/geom.rs`
- [SVG value types](https://github.com/linebender/resvg/blob/main/crates/svgtypes/src/colors.rs): `crates/svgtypes/src/colors.rs`

### Other components

- **SVG consumer**
- **SVG input**

## Connections

- SVG consumer → SVG input: provides
- SVG input → usvg preprocessing API: preprocesses
- usvg preprocessing API → resvg rendering API: passes tree
- resvg rendering API → Node render dispatch: dispatches rendering (evidence: `crates/resvg/src/lib.rs`)
- Node render dispatch → Path and paint rendering: renders paths (evidence: `crates/resvg/src/render.rs`)
- Node render dispatch → Image rendering: renders images (evidence: `crates/resvg/src/render.rs`)
- Node render dispatch → Filter execution: applies filters (evidence: `crates/resvg/src/render.rs`)
- Filter execution → Filter lighting: uses lighting (evidence: `crates/resvg/src/filter/mod.rs`)
- Node render dispatch → Clipping: uses clipping (evidence: `crates/resvg/src/clip.rs`)
- Node render dispatch → Masking: uses masks (evidence: `crates/resvg/src/render.rs`)
- Filter execution → Render geometry: uses geometry (evidence: `crates/resvg/src/filter/mod.rs`)
- Explorer thumbnailer → Thumbnail COM interfaces: implements interface (evidence: `tools/explorer-thumbnailer/src/thumbnail_provider.rs`)
- Explorer thumbnailer → Thumbnail conversion: renders thumbnail (evidence: `tools/explorer-thumbnailer/src/thumbnail_provider.rs`)
- Thumbnail conversion → usvg preprocessing API: parses stream
- Thumbnail conversion → resvg rendering API: renders thumbnail
- Command-line renderer → usvg preprocessing API: uses preprocessing
- Command-line renderer → resvg rendering API: uses renderer
- C API → resvg rendering API: exposes rendering
- Qt SVG viewer → C API: uses C API
