Documentation
¶
Overview ¶
Package renderhost runs the core module of the Rust renderer (renderer/, SDD-013) from Go with wazero: pure Go, no cgo, no import for the module to reach anything through. It is the only place that knows the exports of SDD-013 section 4.2.
Index ¶
- Constants
- Variables
- func ModuleSHA256() string
- type Config
- type Error
- type Host
- func (h *Host) Close(ctx context.Context) error
- func (h *Host) PutBitmap(ctx context.Context, key string, bm bitmap.Bitmap) error
- func (h *Host) PutFont(ctx context.Context, hash string, data []byte) error
- func (h *Host) PutLUT(ctx context.Context, asset string, t *lut.Table) error
- func (h *Host) PutTexture(ctx context.Context, item string, w, ht int, rgba []byte, opaque bool) error
- func (h *Host) Release(ctx context.Context, id string) error
- func (h *Host) Render(ctx context.Context, in RenderInput, dst *image.RGBA) error
- func (h *Host) RunText(ctx context.Context, request []byte) ([]byte, error)
- func (h *Host) ValidateFont(ctx context.Context, data []byte) error
- type Output
- type Reason
- type RenderInput
- type TextError
Constants ¶
const ( DefaultMaxTextureBytes = 512 << 20 DefaultMaxBitmapBytes = 128 << 20 )
Default budgets of vr_init (SDD-013 section 7.2).
const APIVersion = 3
APIVersion is the vr_api_version this host knows.
const RenderInputVersion = 1
RenderInputVersion is the version of the render input this host writes (SDD-000 section 12).
Variables ¶
var ErrClosed = errors.New("renderhost: the instance is closed")
ErrClosed is returned by a host that was closed or whose instance trapped: a trapped instance is discarded and its stored textures are gone.
Functions ¶
func ModuleSHA256 ¶
func ModuleSHA256() string
ModuleSHA256 is the digest of the embedded module, as lower-case hex.
Types ¶
type Config ¶
type Config struct {
MaxTextureBytes uint32
MaxBitmapBytes uint32
// Uncancellable runs the instance without the check that stops a call when its context ends, which is
// about five times faster. Text requests use it: they are bounded by construction (SDD-013 section 4.6).
Uncancellable bool
}
Config is what New needs; a zero value is the defaults.
type Error ¶
Error is a failure of the renderer. Detail names an item, a key or a limit, never a pixel or a path.
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host runs one instance of the core module. It is not safe for concurrent use.
func New ¶
New instantiates the embedded module, compiled once per process. The module is refused unless its digest matches, it has no import, and its vr_api_version is APIVersion.
func (*Host) PutBitmap ¶
PutBitmap uploads a bitmap of the rasterizer under its key (plan.BitmapSpec.Key). The module premultiplies it.
func (*Host) PutFont ¶
PutFont stores the bytes of a user font under its lower-case hex SHA-256 for the requests that name it; empty data records that the file is not stored. The caller has checked that the bytes hash to the digest.
func (*Host) PutLUT ¶
PutLUT uploads the lookup table of a lut asset under the asset id, replacing the table of that id (SDD-004 section 3.6): the entries are the little-endian 16-bit values of the table (lut.Table.Bytes).
func (*Host) PutTexture ¶
func (h *Host) PutTexture(ctx context.Context, item string, w, ht int, rgba []byte, opaque bool) error
PutTexture uploads the premultiplied RGBA pixels of a media layer under its item id, replacing the texture of that id. The module copies the pixels, so the caller reuses rgba at once.
func (*Host) Release ¶
Release forgets the texture, bitmap or lookup table with that id or key; an unknown one is not an error.
func (*Host) Render ¶
Render draws the frame into dst: RGBA, no stride padding, exactly Output.Width by Output.Height. With a band (Output.Y1 > Output.Y0) only those rows of dst are written.
type Output ¶
Output is the frame to write (SDD-013 section 2.1). Width and Height are whole pixels from 1 to 4096; Scale is the output scale of SDD-004 section 6, which multiplies every position and size of the plan. When Y1 is greater than Y0 the module draws only the rows [Y0, Y1) of the frame, which is how a band of the export is rendered by its own instance.
type Reason ¶
type Reason string
Reason is a reason of SDD-013 section 7.1.
const ( InvalidPlan Reason = "invalid_plan" UnsupportedVersion Reason = "unsupported_version" UnsupportedLayer Reason = "unsupported_layer" MissingTexture Reason = "missing_texture" LimitExceeded Reason = "limit_exceeded" OutOfMemory Reason = "out_of_memory" InvalidArgument Reason = "invalid_argument" InvalidSpec Reason = "invalid_spec" FontUnknown Reason = "font_unknown" FontInvalid Reason = "font_invalid" FontNeeded Reason = "font_needed" TextFailed Reason = "text_failed" RenderTrap Reason = "render_trap" )
The reasons a call can fail with; RenderTrap has no status, the call itself failed.
type RenderInput ¶
RenderInput is what one render call reads: the frame to write and the frame plan to draw.
func (RenderInput) MarshalJSON ¶
func (in RenderInput) MarshalJSON() ([]byte, error)
MarshalJSON writes the render input of SDD-013 section 2.1: the plan keeps the JSON names of core/plan.