Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
SandboxCodecs.h File Reference

Encoders and decoders for Donner value types that cross the sandbox wire boundary. Every Encode* writes its type into a WireWriter; every Decode* reads from a WireReader and sets the reader's failure flag on any problem (truncation, invalid variant tag, out-of-range enum, length cap). Decoders never throw and never crash on adversarial input. More...

Include dependency graph for SandboxCodecs.h:

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Functions

Primitive Donner types
void donner::editor::sandbox::EncodeVector2d (WireWriter &w, const Vector2d &v)
bool donner::editor::sandbox::DecodeVector2d (WireReader &r, Vector2d &out)
void donner::editor::sandbox::EncodeVector2i (WireWriter &w, const Vector2i &v)
bool donner::editor::sandbox::DecodeVector2i (WireReader &r, Vector2i &out)
void donner::editor::sandbox::EncodeTransform2d (WireWriter &w, const Transform2d &t)
bool donner::editor::sandbox::DecodeTransform2d (WireReader &r, Transform2d &out)
void donner::editor::sandbox::EncodeBox2d (WireWriter &w, const Box2d &b)
bool donner::editor::sandbox::DecodeBox2d (WireReader &r, Box2d &out)
void donner::editor::sandbox::EncodeRgba (WireWriter &w, const css::RGBA &rgba)
bool donner::editor::sandbox::DecodeRgba (WireReader &r, css::RGBA &out)
void donner::editor::sandbox::EncodeColor (WireWriter &w, const css::Color &color)
 Encodes a css::Color. HSLA and CurrentColor are not fully faithful in S2 — HSLA is converted to RGBA, and CurrentColor is encoded with a fallback RGBA so the replayed paint doesn't resolve to a surprise value.
bool donner::editor::sandbox::DecodeColor (WireReader &r, css::Color &out)
Enums (encoded as a single <tt>u8</tt> byte each)
void donner::editor::sandbox::EncodeFillRule (WireWriter &w, FillRule v)
bool donner::editor::sandbox::DecodeFillRule (WireReader &r, FillRule &out)
void donner::editor::sandbox::EncodeMixBlendMode (WireWriter &w, svg::MixBlendMode v)
bool donner::editor::sandbox::DecodeMixBlendMode (WireReader &r, svg::MixBlendMode &out)
void donner::editor::sandbox::EncodeStrokeLinecap (WireWriter &w, svg::StrokeLinecap v)
bool donner::editor::sandbox::DecodeStrokeLinecap (WireReader &r, svg::StrokeLinecap &out)
void donner::editor::sandbox::EncodeStrokeLinejoin (WireWriter &w, svg::StrokeLinejoin v)
bool donner::editor::sandbox::DecodeStrokeLinejoin (WireReader &r, svg::StrokeLinejoin &out)
Path and stroke state
void donner::editor::sandbox::EncodePath (WireWriter &w, const Path &path)
 Encodes a Path as: u32 commandCount, then each command as u8 verb, u32 pointIndex, then u32 pointCount, then pointCount * Vector2d. isInternal is not preserved — S2 paths come straight from the driver and the flag is only used for marker placement, which happens before this encoder sees the path.
bool donner::editor::sandbox::DecodePath (WireReader &r, Path &out)
void donner::editor::sandbox::EncodeStrokeParams (WireWriter &w, const svg::StrokeParams &s)
bool donner::editor::sandbox::DecodeStrokeParams (WireReader &r, svg::StrokeParams &out)
void donner::editor::sandbox::EncodePathShape (WireWriter &w, const svg::PathShape &p)
bool donner::editor::sandbox::DecodePathShape (WireReader &r, svg::PathShape &out)
Misc
void donner::editor::sandbox::EncodeRenderViewport (WireWriter &w, const svg::RenderViewport &v)
bool donner::editor::sandbox::DecodeRenderViewport (WireReader &r, svg::RenderViewport &out)
void donner::editor::sandbox::EncodeImageParams (WireWriter &w, const svg::ImageParams &p)
bool donner::editor::sandbox::DecodeImageParams (WireReader &r, svg::ImageParams &out)
void donner::editor::sandbox::EncodeImageResource (WireWriter &w, const svg::ImageResource &img)
 Encodes an ImageResource as: u32 width, u32 height, u32 byteLength, u8[byteLength]. Bytes are stored RGBA-straight (the same format RendererInterface::drawImage expects).
bool donner::editor::sandbox::DecodeImageResource (WireReader &r, svg::ImageResource &out)
void donner::editor::sandbox::EncodeFontFace (WireWriter &w, const css::FontFace &face)
 Encodes a single css::FontFace (family name, weight/style/stretch, and the source list including inline font data blobs).
bool donner::editor::sandbox::DecodeFontFace (WireReader &r, css::FontFace &out)
 Decodes a single css::FontFace. Returns false on any parse failure.
void donner::editor::sandbox::EncodeTextParams (WireWriter &w, const svg::TextParams &p)
 Encodes a TextParams struct including fontFaces with full inline font data. Up to 256 font faces are supported.
bool donner::editor::sandbox::DecodeTextParams (WireReader &r, svg::TextParams &out, std::vector< css::FontFace > *outFontFaces=nullptr)
 Decodes a TextParams. The decoded font faces are stored into outFontFaces (if non-null) so the caller can keep the backing storage alive for the fontFaces span. When outFontFaces is provided and non-empty after decode, out.fontFaces is set to reference it.
void donner::editor::sandbox::EncodeComputedTextComponent (WireWriter &w, const svg::components::ComputedTextComponent &text)
 Encodes a ComputedTextComponent (vector of TextSpan, each carrying text content, positioning lists, paint servers, font style, etc.).
bool donner::editor::sandbox::DecodeComputedTextComponent (WireReader &r, svg::components::ComputedTextComponent &out)
void donner::editor::sandbox::EncodeFilterGraph (WireWriter &w, const svg::components::FilterGraph &g)
 Encodes a FilterGraph as metadata only: 0 nodes (transparent pass-through), colorInterpolationFilters, primitiveUnits, elementBoundingBox, filterRegion, userToPixelScale. The full primitive chain is deferred to a follow-up milestone — the pass-through stub preserves layout without producing visual effects.
bool donner::editor::sandbox::DecodeFilterGraph (WireReader &r, svg::components::FilterGraph &out)

Paint and clip

using donner::editor::sandbox::WireGradient = svg::ResolvedGradientData
 Self-contained gradient payload — everything needed to reconstruct a linear or radial gradient on the replay side without registry lookups. This is the serializer's side of WIRE.5: it flattens a PaintResolvedReference to a gradient entity into plain values that cross the wire, then the replayer materializes them onto a fresh ECS entity via GradientReplayRegistry.
void donner::editor::sandbox::EncodeLengthd (WireWriter &w, const Lengthd &v)
 Encodes a Lengthd as f64 value, u8 unit.
bool donner::editor::sandbox::DecodeLengthd (WireReader &r, Lengthd &out)
void donner::editor::sandbox::EncodeWireGradient (WireWriter &w, const WireGradient &g)
 Encodes a WireGradient in full. The gradient kind tag is written first so a truncated stream can still be recognized as malformed early.
bool donner::editor::sandbox::DecodeWireGradient (WireReader &r, WireGradient &out)
void donner::editor::sandbox::EncodeResolvedPaintServer (WireWriter &w, const svg::components::ResolvedPaintServer &p)
 Encodes a ResolvedPaintServer variant. Supports:
bool donner::editor::sandbox::DecodeResolvedPaintServer (WireReader &r, svg::components::ResolvedPaintServer &out, std::optional< WireGradient > *outPendingGradient=nullptr)
 Decodes a ResolvedPaintServer. When the wire carries a gradient tag the fully-decoded WireGradient is stashed in *outPendingGradient (if non-null) and out is set to PaintServer::None. The caller is expected to materialize the gradient via a replay-side ECS registry before forwarding out to the backend. If outPendingGradient is null, gradients silently decode as None.
void donner::editor::sandbox::EncodePaintParams (WireWriter &w, const svg::PaintParams &p)
bool donner::editor::sandbox::DecodePaintParams (WireReader &r, svg::PaintParams &out, std::optional< WireGradient > *outFillGradient=nullptr, std::optional< WireGradient > *outStrokeGradient=nullptr)
 Decodes a PaintParams. Fill and stroke gradients (if any) are stashed in the corresponding out-parameters rather than being flattened into the result's ResolvedPaintServer variants — see DecodeResolvedPaintServer.
void donner::editor::sandbox::EncodeResolvedClip (WireWriter &w, const svg::ResolvedClip &c)
 Encodes the subset of ResolvedClip we support in S2: rect + paths + unit-transform. The optional mask is always encoded as "absent" — masks cross the wire as kUnsupported from higher up in the caller chain.
bool donner::editor::sandbox::DecodeResolvedClip (WireReader &r, svg::ResolvedClip &out)

Detailed Description

Encoders and decoders for Donner value types that cross the sandbox wire boundary. Every Encode* writes its type into a WireWriter; every Decode* reads from a WireReader and sets the reader's failure flag on any problem (truncation, invalid variant tag, out-of-range enum, length cap). Decoders never throw and never crash on adversarial input.

Scope for S2: paths, transforms, boxes, colors, stroke params, solid paint servers, simple clips. Gradients, patterns, filters, masks, text, and images are out of scope and the SerializingRenderer emits a kUnsupported message instead of attempting to encode them.

Function Documentation

◆ EncodeResolvedPaintServer()

void donner::editor::sandbox::EncodeResolvedPaintServer ( WireWriter & w,
const svg::components::ResolvedPaintServer & p )

Encodes a ResolvedPaintServer variant. Supports:

  • PaintServer::None
  • PaintServer::Solid
  • PaintResolvedReference carrying a linear or radial gradient (flattened to a WireGradient). Pattern paint servers and other unresolved references still fall through as stubs that decode to None. That's a separate milestone — see docs/design_docs/0023-editor_sandbox.md.