Class DrawingInstructionSerializer
Compact, order-preserving binary (de)serializer for a list of DrawingInstruction. Used by DiskPortrayalInstructionCache to persist the post-pipeline display list across process restarts.
public static class DrawingInstructionSerializer
- Inheritance
-
DrawingInstructionSerializer
- Inherited Members
Remarks
The frame is [FormatVersion:int][count:int] then, per instruction,
[typeTag:byte] followed by the base fields and the type-specific
fields. Order is preserved exactly: the list is written and read as a
sequence, never sorted or de-duplicated, because the input order is the
renderer's final priority tie-breaker (VectorPipeline.SortByPriority
is a stable sort that falls back to input order).
Increment FormatVersion whenever the DrawingInstruction shape or this frame changes; a mismatched version read is treated as a miss by the disk cache (and the persisted scope key also folds the version in, so stale files are never reused).
Fields
FormatVersion
Version stamp for the serialization frame. Bump on any change to the frame layout or the DrawingInstruction field set.
public const int FormatVersion = 8
Field Value
Remarks
v3: the base fields carry AdditionalViewingGroups (a count-prefixed id list after the primary viewing group), so v2 lists — which dropped every viewing group but the first — are rebuilt. v4: text instructions carry FontWeight, FontProportion, HaloColor and HaloWidth. v5: the base fields carry TimeValid. v6: line instructions carry Suppression. v7: point and text instructions carry AreaPlacement and AreaPlacement. v8: the base fields carry AlertReference.
Methods
Serialize(IReadOnlyList<DrawingInstruction>)
Serializes instructions into the binary frame.
public static byte[] Serialize(IReadOnlyList<DrawingInstruction> instructions)
Parameters
instructionsIReadOnlyList<DrawingInstruction>The post-pipeline display list to persist.
Returns
- byte[]
The serialized bytes.
TryDeserialize(byte[])
Deserializes a list previously produced by Serialize(IReadOnlyList<DrawingInstruction>). Returns null when the bytes are truncated, corrupt, or carry a mismatched FormatVersion — the caller treats that as a cache miss.
public static IReadOnlyList<DrawingInstruction>? TryDeserialize(byte[] bytes)
Parameters
bytesbyte[]The serialized bytes.
Returns
- IReadOnlyList<DrawingInstruction>
The deserialized list, or null on any failure.