Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
skia-rs
A 100% Rust implementation of the Skia 2D graphics library
Getting Started • Features • Examples • Documentation • Contributing
Overview
skia-rs is a pure Rust reimplementation of Google's Skia 2D graphics library. It aims to provide complete API compatibility with the original Skia while leveraging Rust's safety, performance, and ergonomics.
Why skia-rs?
- Pure Rust — No C/C++ dependencies, easy to build and deploy
- Memory Safe — Leverage Rust's ownership system, no use-after-free or buffer overflows
- Fast — Optimized software rasterizer, competitive with native Skia
- Portable — Works anywhere Rust compiles: desktop, mobile, WASM
- API Compatible — Familiar API for Skia users, smooth migration path
Getting Started
Add skia-rs-safe to your Cargo.toml:
[]
= "0.1"
Or use individual crates for more control:
[]
= "0.1" # Core types: Point, Rect, Matrix, Color
= "0.1" # Path geometry and operations
= "0.1" # Paint, shaders, filters
= "0.1" # Canvas and surface
Quick Example
use Surface;
use ;
use ;
Features
Core Graphics
- ✅ Geometry primitives — Point, Rect, RRect, Matrix, Matrix44
- ✅ Color management — Color, Color4f, ColorSpace, ICC profiles
- ✅ Path system — Path construction, boolean operations, effects
- ✅ Paint & styling — Stroke, fill, blend modes, shaders
Drawing Operations
- ✅ Canvas API — Full drawing operations with save/restore
- ✅ Anti-aliased rendering — High-quality edges
- ✅ Clipping — Rect and path-based clipping
- ✅ Transformations — Translate, rotate, scale, skew
Text
- ✅ Text shaping — via rustybuzz
- ✅ Font management — TrueType/OpenType support
- ✅ Rich text layout — Paragraph styling, decorations
Image Codecs
- ✅ PNG — Read/write support
- ✅ JPEG — Read/write support
- ✅ GIF — Read/write support
- ✅ WebP — Read/write support
Effects
- ✅ Shaders — Linear, radial, sweep gradients, image shaders
- ✅ Color filters — Matrix, lighting, blend mode filters
- ✅ Mask filters — Blur, shader-based masks
- ✅ Image filters — Blur, drop shadow, morphology, displacement
GPU Backends
- 🔄 wgpu — Cross-platform GPU rendering (in progress)
- 📋 Vulkan — Planned
- 📋 OpenGL — Planned
- 📋 Metal — Planned
Crate Structure
skia-rs/
├── skia-rs-core # Foundation: types, geometry, color
├── skia-rs-path # Path geometry and operations
├── skia-rs-paint # Paint, shaders, effects
├── skia-rs-canvas # Canvas, surface, recording
├── skia-rs-text # Text layout and rendering
├── skia-rs-codec # Image encoding/decoding
├── skia-rs-gpu # GPU backends
├── skia-rs-svg # SVG parsing and rendering
├── skia-rs-pdf # PDF generation
├── skia-rs-ffi # C FFI bindings
└── skia-rs-safe # High-level unified API
Feature Flags
The skia-rs-safe crate supports feature flags:
| Feature | Default | Description |
|---|---|---|
codec |
✅ | Image encoding/decoding (PNG, JPEG, GIF, WebP) |
svg |
✅ | SVG parsing and rendering |
pdf |
❌ | PDF document generation |
gpu |
❌ | GPU backends (wgpu) |
# All features
= { = "0.1", = ["codec", "svg", "pdf", "gpu"] }
# Minimal (no codecs or extras)
= { = "0.1", = false }
Performance
skia-rs includes a comprehensive benchmark suite. Key performance highlights:
| Operation | Performance |
|---|---|
| Rectangle fill (1000×1000) | 224 ns |
| Clear (1000×1000) | 189 ns |
| Anti-aliased line | 502 ns |
| Path boolean union | 12.4 µs |
| SVG path parsing | 890 ns |
Run benchmarks locally:
Examples
Drawing Shapes
use Surface;
use ;
use ;
use PathBuilder;
Gradients
use ;
use ;
let gradient = new;
let mut paint = new;
paint.set_shader;
canvas.draw_rect;
Image I/O
use ;
// Load an image
let image = from_file?;
// Draw it
canvas.draw_image;
// Save to file
surface.save_png?;
C FFI
skia-rs provides C bindings for use from other languages:
sk_surface_t* surface = ;
sk_canvas_t* canvas = ;
sk_paint_t* paint = ;
;
;
sk_rect_t rect = ;
;
;
;
Build the FFI library:
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Development
# Clone the repository
# Build all crates
# Run tests
# Run benchmarks
# Run fuzzing (requires nightly)
&&
Roadmap
See TODO.md for the complete development roadmap.
v0.1.0 (Current):
- Core types and geometry ✅
- Path system with boolean operations ✅
- Full paint/shader/filter stack ✅
- Software rasterizer with AA ✅
- Text shaping ✅
- Image codecs (PNG, JPEG, GIF, WebP) ✅
- C FFI bindings ✅
v0.2.0 (Planned):
- GPU rendering via wgpu
- SVG export
- Performance optimizations
- Extended font support
License
Licensed under either of:
at your option.
Acknowledgments
- Google Skia — The original inspiration
- rustybuzz — Text shaping
- wgpu — Cross-platform GPU abstraction