stet-render
Software rasterizer for stet display lists. Turns a
DisplayList
— whether it came from the stet PostScript interpreter or from
stet-pdf-reader — into
RGBA pixels.
Built on
stet-tiny-skia, a modified
fork of tiny-skia with
higher-quality analytical antialiasing for PostScript-grade hairlines.
Rendering is multi-threaded and banded (sized to fit L2 cache), with
mask caching, clip fast paths, and ICC-aware CMYK handling.
Because DisplayList is the neutral meeting point between stet's PS
interpreter and stet-pdf-reader, the same renderer handles both PS
and PDF sources — there is no separate PDF rasterizer. The only
difference a consumer sees is where the display list came from.
This is a low-level crate. Most users should use the
stet facade (for PS / EPS) or
stet-pdf-reader (for PDF),
both of which drive stet-render for you.
What's inside
| API | Purpose |
|---|---|
render_to_rgba |
One-shot: DisplayList → Vec<u8> RGBA. Automatic banded parallelism. |
prepare_display_list + render_region_prepared |
Viewport rendering — pre-compute bounding boxes once, then rasterize any rectangular region at any zoom without re-interpretation. Powers the interactive viewer and the WASM frontend. |
render_region_prepared_parallel / _cancellable / _with_progress |
Parallel viewport variants with progress callbacks and cancellation tokens for interactive UIs. |
ImageCache |
Pre-converted RGBA image cache, amortizing decode + ICC conversion across repeated viewport renders of the same page. |
build_icc_cache_for_list |
Sweep a DisplayList and populate an IccCache with every embedded ICC profile it references. |
SkiaDevice |
OutputDevice implementation — plug it into a Context for streaming per-page PS/PDF rendering. Requires the ps-device feature (on by default). |
PngSinkFactory |
PageSinkFactory that streams banded output straight to a PNG file. |
Features
| Feature | Default | Description |
|---|---|---|
parallel |
yes | Multi-threaded banded rendering via rayon. Disable for a single-threaded build. |
ps-device |
yes | SkiaDevice and its OutputDevice implementation, for the PostScript interpreter to paint into. Pulls in stet-core. |
Turning ps-device off drops stet-core — the PostScript VM — from the
dependency graph entirely. Rendering a DisplayList needs none of it, so a
consumer that only rasterizes (a PDF viewer, say) can take:
= { = "0.8", = false, = ["parallel"] }
Note that default-features = false also switches off parallel, so re-enable
it by name unless you want single-threaded rendering. stet-pdf-reader depends
on stet-render exactly this way.
Usage
Render a PDF page to RGBA
use PdfDocument;
use render_to_rgba;
let data = read?;
let doc = from_bytes?;
let display_list = doc.render_page?;
let = ;
let rgba = render_to_rgba;
# Ok::
(For a one-call shortcut, PdfDocument::render_page_to_rgba wraps this
and the w/h derivation.)
Render a PostScript-produced display list
use Interpreter;
use render_to_rgba;
let mut interp = new;
let pages = interp.render_to_display_list?;
let p = &pages;
let rgba = render_to_rgba;
# Ok::
Viewport rendering (zoom / pan without re-interpreting)
use ;
let prepared = prepare_display_list;
let rgba = render_region_prepared;
License
Apache-2.0 OR MIT