Skip to main content

Module paint

Module paint 

Source
Expand description

Paint encoding: peniko::Brush to a vello_common Paint plus its EncodedPaint side table.

A scene’s brushes are split into the two things the renderer needs. A solid colour is self-contained and travels premultiplied inside the Paint itself, costing no side-table entry. Anything else is encoded once into a caller-owned Vec<EncodedPaint> and referenced by index, so per-draw state stays small and two draws sharing a brush share one encoded entry.

Encoding a gradient also bakes nothing: the colour ramp is a separate, bounded GPU resource, so a gradient encoding yields a LutRequest naming the entry whose ramp must be made resident in the GradientCache before the frame is drawn. Requests are deliberately not serviced here — a caller batches them so ramp residency is decided once per frame rather than per draw.

An image is the one paint that cannot follow that deferred shape. A gradient’s encoded entry carries its own cache key, so the ramp can be baked afterwards and matched back up; an image’s encoded entry has to carry the ImageId itself, which only an allocation against the atlas can mint. Image residency is therefore resolved inline (encode_image and its two callers), against a residency the compiler owns — cheap, because allocation is a rectangle packer over plain values and only the upload it schedules costs anything, and that upload happens once per image rather than once per frame.

Structs§

BrushEncoding
One encoded brush: the paint a draw references, plus any ramp it still needs.
ImageEncoding
One encoded image paint: the paint a draw references, plus where the atlas made its texels resident.
LutRequest
A gradient whose colour ramp is not yet resident in the GradientCache.

Functions§

encode_brush
Encode brush into paint’s renderer-facing form, appending to encoded_paints.
encode_image
Make data resident and append its encoded entry, returning the paint that references it.
encode_image_brush
Encode an image brush drawn at its natural pixel size under transform.
encode_image_command
Encode a Command::Image: data’s natural pixel rectangle scaled to fill dest, under transform.
resolve_lut_request
Make the ramp named by request resident, returning where it landed.