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§
- Brush
Encoding - One encoded brush: the paint a draw references, plus any ramp it still needs.
- Image
Encoding - 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
brushintopaint’s renderer-facing form, appending toencoded_paints. - encode_
image - Make
dataresident 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 filldest, undertransform. - resolve_
lut_ request - Make the ramp named by
requestresident, returning where it landed.