RiveRenderer and rive::gpu::RenderContext are one possible backend. The
core runtime is renderer-agnostic — anything you pass to
StateMachineInstance::draw only has to implement two interfaces:
rive::Renderer— receives draw / clip / save / restore commands.rive::Factory— createsRenderPath,RenderPaint,RenderImage,RenderShader,RenderBuffer,Font,AudioSourcefrom raw bytes or parameters during file import.
Use Cases
- You already have a 2D vector engine (Skia, Direct2D, custom) and want Rive to render through it.
- You’re targeting a platform Rive doesn’t ship a backend for.
- You want CPU-side hit-testing or analytics — render into a no-op
Rendererthat records command counts.
The Renderer Interface
save/restoreform a stack and must capture: the current transform, clip stack, and the modulated opacity.clipPathadds to the current clip — never replaces it.modulateOpacityis multiplicative;0.5then0.2⇒0.1effective opacity until the nextrestore.drawImageMeshindices are 16-bit; vertex / UV buffers are tightly-packedfloatpairs.
The Factory Interface
- Gradient
colors[]are packed ARGB ints;stops[]are normalized 0..1. makeRenderPath(RawPath&, FillRule)may steal the path’s storage — treat the input as moved-from after the call.decodeImageis called with raw PNG / JPEG / WebP bytes, etc. Decode in whatever pixel format your renderer prefers and wrap the result in a subclass ofRenderImage.decodeFont/decodeAudioare non-virtual helpers that fan out to Rive’s built-in HarfBuzz / miniaudio paths. They are not subclass override points; use the actual virtualFactoryextension points for custom font shaping or audio integration.
RenderPath / RenderPaint Subclasses
Each holds the state your backend reads during drawing:rive/command_path.hpp (for CommandPath) and
rive/renderer.hpp (for RenderPath and RenderPaint) — read those for
the full set.)
Wiring It Up
RenderContext in this path — your Renderer is responsible
for making the GPU calls (or buffering them, or counting them, or whatever
you want).
Reference Implementations
All paths below are in the rive-runtime repo.| Project | Uses | Where |
|---|---|---|
rive::gpu::RenderContext | Pixel-local-storage GPU renderer | renderer/src/ |
SkiaFactory / SkiaRenderer | Skia | skia/renderer/ |
CGFactory / CGRenderer | CoreGraphics | cg_renderer/ |
SokolFactory | Sokol (tessellation) | tess/src/sokol/ |
Renderer.