|
tiny-skia-cpp
A C++20 2D rendering library (port of tiny-skia)
|
A fast, minimal CPU-only 2D rendering library for C++20 — a faithful port of tiny-skia, which implements a subset of Skia's rendering algorithms in Rust.
tiny-skia-cpp brings the same proven rasterization and blending algorithms to C++ with native SIMD acceleration and zero external dependencies.
Speedup vs Rust tiny-skia on 512×512 px workloads (higher is better):
| Workload | C++ SIMD (ARM) | C++ SIMD (x86) | Rust (tiny-skia) |
|---|---|---|---|
| FillRect | 1.9× | 1.3× | 1.0× |
| FillPath | 1.4× | 1.2× | 1.0× |
SIMD speedup over C++ Scalar: up to 2.3× (x86 AVX2) / 1.9× (ARM NEON).
| Type | Purpose |
|---|---|
| tiny_skia::Canvas | Drawing surface backed by a Pixmap or MutablePixmapView (fillRect, fillPath, strokePath, drawPixmap, applyMask) |
| tiny_skia::Pixmap | Owned RGBA pixel buffer |
| tiny_skia::MutablePixmapView | Non-owning mutable view into a pixmap |
| tiny_skia::Path | Immutable vector path (lines, quads, cubics) |
| tiny_skia::PathBuilder | Builder for constructing Path objects |
| tiny_skia::Paint | Shader + blend mode + anti-alias settings |
| tiny_skia::Transform | 2D affine transformation matrix |
| tiny_skia::Mask | 8-bit alpha mask for clipping |
| tiny_skia::Stroke | Stroke width, line cap, line join, dash pattern |
| tiny_skia::Color | Floating-point RGBA color [0,1] |
| tiny_skia::ColorU8 | 8-bit RGBA color |
The tiny_skia::Shader variant holds one of:
Full examples are in the examples/ directory:
fill.cpp — basic path fillingstroke.cpp — dashed stroke with round capslinear_gradient.cpp — linear gradient shadermask.cpp — alpha mask clippingpattern.cpp — pixmap pattern shader