Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner Namespace Reference

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

Namespaces

namespace  parser
 Parsers for shared data types such as NumberParser and LengthParser.
namespace  css
 Donner CSS library, a standalone composable CSS parser.
namespace  svg
 Donner SVG library, which can load, manipulate and render SVG files.
namespace  xml
 XML parsing and document model support, top-level objects are donner::xml::XMLParser and donner::xml::XMLDocument.

Classes

struct  FrameSuspendTotals
 Suspend totals accumulated between BeginSuspendFrame and EndSuspendFrame on the calling thread. More...
class  ScopedSuspendPoint
 Brackets one call that may suspend the wasm stack under ASYNCIFY. More...
struct  Box2
 A 2D axis-aligned bounding box. More...
class  ChunkedString
 ChunkedString is a small helper to accumulate multiple RcStringOrRef pieces, either as small appended fragments or single codepoints. More...
struct  CompileTimeMapTables
 Perfect-hash metadata used to resolve keys into storage slots. More...
struct  CompileTimeMapDiagnostics
 Diagnostics describing how a CompileTimeMap was constructed. More...
class  CompileTimeMap
 Compile-time associative container backed by a perfect hash layout. More...
class  DiagnosticRenderer
 Renders diagnostic messages with source context and caret/tilde indicators, similar to clang/rustc output. More...
class  ElementTraversalGenerator
 Selectors may need to traverse the tree in different ways to match, and this is abstracted away using C++20 coroutines. More...
class  Decompress
 A utility class for decompressing data. More...
struct  FileOffset
 Error context for a failed parse, such as the error reason, line, and character offset. More...
struct  SourceRange
 Holds a selection range for a region in the source text, as a half-open interval [start, end). More...
struct  AllocTagTotals
 Live large-block bytes attributed to each AllocTag. More...
class  ScopedAllocTag
 Sets the calling thread's AllocTag for the lifetime of the scope, restoring the previous one on exit so guards nest. More...
struct  HeapSizeHistogram
 Live allocation totals split by block size. More...
struct  Length
 Parses a CSS <length-percentage> type as defined by https://www.w3.org/TR/css-values-3/#typedef-length-percentage. More...
struct  MathConstants
 Contains a set of math constants for the specified type (float or double). More...
struct  MathConstants< float >
 Math constants for float. More...
struct  MathConstants< double >
 Math constants for double. More...
struct  QuadraticSolution
 Holds the solution of a quadratic equation, as returned by SolveQuadratic. More...
struct  MemoryAttributionSample
 One frame's view of where the process's bytes are. More...
struct  MemoryStageSample
 Net allocator movement attributed to each stage. More...
class  ScopedHeapDelta
 Brackets one stage of the frame and attributes the allocator movement across it. More...
class  OptionalRef
 A class that simulates an optional reference to a constant object of type T. More...
struct  ParseDiagnostic
 A diagnostic message from a parser, with severity, source range, and human-readable reason. More...
class  ParseResult
 A parser result, which may contain a result of type T, or an error, or both. More...
class  ParseWarningSink
 Collects parse warnings during parsing. More...
struct  StrokeStyle
 Parameters for converting a stroked path to a filled outline. More...
class  Path
 Immutable 2D vector path. More...
class  PathBuilder
 Mutable builder for constructing immutable Path objects. More...
struct  PathBooleanInput
 One filled path participating in a boolean operation. More...
struct  PathBooleanOptions
 Limits and tolerances for bounded boolean operations. More...
struct  PathBooleanResult
 Result of ApplyPathBoolean. More...
class  RcString
 A reference counted string, that is copy-on-write and implements the small-string optimization. More...
class  RcStringOrRef
 An in-transit type that can hold either an RcString or std::string_view, to enable transferring the RcString reference or also accepting a non-owning std::string_view from API surfaces. More...
struct  FontMetrics
 A container for font information relevant for computing font-relative lengths, per https://www.w3.org/TR/css-values/#font-relative-lengths. More...
struct  AbsoluteLengthMetrics
 A container with ratios for converting absolute lengths, such as "cm" or "in", see https://www.w3.org/TR/css-values/#absolute-lengths. More...
class  SmallVector
 A vector with small-size optimization. More...
struct  CaseInsensitiveCharTraits
 Type traits for case-insensitive string comparison, usable with algorithms that accept an STL std::char_traits. More...
class  StringUtils
 A collection of string utils, such as case-insensitive comparison and StartsWith/EndsWith. More...
struct  Transform2
 A 2D matrix representing an affine transformation. More...
class  Utf8
 Utility class for working with UTF-8 encoded strings. More...
struct  Vector2
 A 2D vector, (x, y). More...

Concepts

concept  ElementLike
 Concept for types that can be matched against a selector, such as a donner::svg::SVGElement.
concept  StringLike
 A concept for types that are string-like, i.e.

Typedefs

using Entity = entt::entity
 Entity type for the Registry, a std::uint32_t alias.
using Registry = entt::basic_registry<Entity>
 Registry type for the SVG ECS, which is the entry point for storing all data.
using EntityHandle = entt::basic_handle<Registry>
 Convenience handle for a Entity with an attached Registry.
using FileReadResult = std::variant<std::string, FileReadError>
 Contents or failure from a bounded file read.
using Lengthd = Length<double>
 Shorthand for Length<double>.
Typedefs
using Box2d = Box2<double>
 Shorthand for Box2<double>.
using Transform2f = Transform2<float>
 Shorthand for Transform2<float>.
using Transform2d = Transform2<double>
 Shorthand for Transform2<double>.
using Vector2f = Vector2<float>
 Shorthand for Vector2<float>.
using Vector2d = Vector2<double>
 Shorthand for Vector2<double>.
using Vector2i = Vector2<int>
 Shorthand for Vector2<int>.

Enumerations

enum class  SuspendKind : std::uint8_t {
  TileYield = 0 ,
  GpuReadback = 1 ,
  DeviceWait = 2 ,
  Startup = 3
}
 Why a call site can suspend. Kept small and stable: it is published to the stats surface as an array index. More...
enum class  CompileTimeMapStatus {
  kOk ,
  kUsingFallbackHash ,
  kDuplicateKey ,
  kSeedSearchFailed ,
  kConstexprHashUnsupported
}
 Indicates the result of building a CompileTimeMap. More...
enum class  FileReadError {
  OpenFailed ,
  TooLarge ,
  ReadFailed
}
 Failure returned by ReadFileBounded.
enum class  FillRule : uint8_t {
  NonZero ,
  EvenOdd
}
 The parsed result of the 'fill-rule' property, see: https://www.w3.org/TR/SVG2/painting.html#FillRuleProperty. More...
enum class  AllocTag : std::uint8_t {
  Untagged = 0 ,
  WorkerRenderFrame = 1 ,
  WorkerBuildPreview = 2 ,
  WorkerFinalSnapshot = 3 ,
  WorkerOther = 4 ,
  AppPollResult = 5 ,
  AppUiFrame = 6 ,
  AppHostFrame = 7 ,
  AppInput = 8 ,
  RenderTileRaster = 9 ,
  GpuReadbackStaging = 10 ,
  CompositorBitmap = 11 ,
  PresentationUpload = 12 ,
  ImGuiDrawLists = 13
}
 Who was on the stack when a large block was allocated. More...
enum class  LengthUnit : uint8_t {
  None ,
  Percent ,
  Cm ,
  Mm ,
  Q ,
  In ,
  Pc ,
  Pt ,
  Px ,
  Em ,
  Ex ,
  Ch ,
  Rem ,
  Vw ,
  Vh ,
  Vmin ,
  Vmax
}
 The unit identifier for a length, corresponding to CSS unit identifiers. More...
enum class  MemoryCategory : std::uint8_t {
  CompositorSegmentBitmaps = 0 ,
  CompositorSegmentTextures = 1 ,
  CompositorLayerBitmaps = 2 ,
  CompositorLayerTextures = 3 ,
  RenderResultTiles = 4 ,
  WorkerFrameSnapshot = 5 ,
  PresentationTiles = 6 ,
  PresentationOverviewTiles = 7 ,
  PresentationRetired = 8 ,
  LayerThumbnails = 9
}
 A subsystem that retains or allocates pixel-scale memory. Kept small and stable: values are published to the stats surface as array indices. More...
enum class  MemoryStage : std::uint8_t {
  WorkerRenderFrame = 0 ,
  WorkerBuildPreview = 1 ,
  WorkerFinalSnapshot = 2 ,
  WorkerOther = 3 ,
  AppPollResult = 4 ,
  AppUiFrame = 5 ,
  AppHostFrame = 6 ,
  AppInput = 7
}
 A bracketed stage of the frame, measured by what it does to the allocator rather than by what a subsystem says it holds. More...
enum class  DiagnosticSeverity : uint8_t {
  Warning ,
  Error
}
 Severity level for a parser diagnostic. More...
enum class  LineCap : uint8_t {
  Butt ,
  Round ,
  Square
}
 Line cap style for stroke endpoints. More...
enum class  LineJoin : uint8_t {
  Miter ,
  Round ,
  Bevel
}
 Line join style for stroke corners. More...
enum class  PathBooleanOp : std::uint8_t {
  Union ,
  Intersect ,
  Difference ,
  Xor
}
 Boolean operation to apply to filled path inputs. More...
enum class  PathBooleanStatus : std::uint8_t {
  Ok ,
  EmptyResult ,
  InvalidInput ,
  TooComplex
}
 Status for a path boolean result. More...
enum class  StringComparison : uint8_t {
  Default ,
  IgnoreCase
}
 String comparison options, e.g. case sensitivity. More...

Functions

void BeginSuspendFrame ()
 Start a new attribution window on the calling thread, discarding whatever was accumulated since the previous EndSuspendFrame.
FrameSuspendTotals EndSuspendFrame ()
 Close the attribution window opened by BeginSuspendFrame and return what it accumulated. Safe to call without a matching begin; the totals are then everything since the thread's last reset.
FrameSuspendTotals PeekSuspendFrame ()
 Read the current window's totals without closing it.
FrameSuspendTotals LifetimeSuspendTotals ()
 Lifetime totals for the calling thread, never reset by frame boundaries. Used by the boot report, where there is no frame to attribute against.
Vector2d EvalQuadratic (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, double t)
 Evaluate a quadratic Bezier curve at parameter t using the standard basis expansion.
Vector2d EvalCubic (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3, double t)
 Evaluate a cubic Bezier curve at parameter t using the standard basis expansion.
std::pair< std::array< Vector2d, 3 >, std::array< Vector2d, 3 > > SplitQuadratic (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, double t)
 Split a quadratic Bezier curve at parameter t using De Casteljau subdivision.
std::pair< std::array< Vector2d, 4 >, std::array< Vector2d, 4 > > SplitCubic (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3, double t)
 Split a cubic Bezier curve at parameter t using De Casteljau subdivision.
void ApproximateCubicWithQuadratics (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3, double tolerance, std::vector< Vector2d > &out)
 Approximate a cubic Bezier curve as a sequence of quadratic Bezier curves within a given tolerance.
bool ApproximateCubicWithQuadratics (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3, double tolerance, std::size_t maximumOutputPoints, std::vector< Vector2d > &out)
 Bounded variant of ApproximateCubicWithQuadratics.
SmallVector< double, 1 > QuadraticYExtrema (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2)
 Find parameter values where the Y-derivative is zero for a quadratic Bezier curve.
SmallVector< double, 1 > QuadraticXExtrema (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2)
 Find parameter values where the X-derivative is zero for a quadratic Bezier curve.
SmallVector< double, 2 > CubicYExtrema (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3)
 Find parameter values where the Y-derivative is zero for a cubic Bezier curve.
SmallVector< double, 2 > CubicXExtrema (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3)
 Find parameter values where the X-derivative is zero for a cubic Bezier curve.
Box2d QuadraticBounds (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2)
 Compute the tight axis-aligned bounding box of a quadratic Bezier curve.
Box2d CubicBounds (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3)
 Compute the tight axis-aligned bounding box of a cubic Bezier curve.
constexpr uint64_t mixHash (uint64_t baseHash, std::uint32_t seed)
 Mix a base hash value with a seed to produce a new hash. Used to construct perfect-hash bucket seeds during CompileTimeMap construction.
template<typename Key>
constexpr bool supportsConstexprHash ()
 Returns true when the provided key type can be hashed in a constexpr context by constexprHashValue.
template<typename Key>
constexpr uint64_t constexprHashValue (const Key &key)
 Compute a constexpr-friendly hash of key for supported key types.
template<typename Key, std::size_t N, typename KeyEqual>
constexpr bool hasDuplicateKeys (const std::array< Key, N > &keys, KeyEqual keyEqual)
 Returns true when the provided keys contain duplicates.
auto operator<=> (Entity lhs, Entity rhs)
 Compare two Entity values.
template<ElementLike T>
ElementTraversalGenerator< T > singleElementGenerator (T element)
 A generator that yields a single element, if it exists.
template<ElementLike T>
ElementTraversalGenerator< T > parentsGenerator (T element)
 A generator that yields all parents of an element, repeatedly following parentElement() until reaching the root.
template<ElementLike T>
ElementTraversalGenerator< T > previousSiblingsGenerator (T element)
 A generator that yields all siblings of an element, in reverse order.
template<ElementLike T>
ElementTraversalGenerator< T > allChildrenRecursiveGenerator (T element)
 A generator that yields all children of an element recursively with pre-order traversal.
ParseResult< std::vector< uint8_t > > DecodeBase64Data (std::string_view base64String)
 Decode a base64-encoded string into a byte array.
std::string EncodeBase64Data (std::span< const uint8_t > data)
 Encode a byte array into a base64-encoded string.
std::vector< uint8_t > UrlDecode (std::string_view urlEncodedString)
 Decode a URL-encoded string into a byte array, translating XX sequences into the corresponding byte value.
void InstallFailureSignalHandler ()
 Install signal handlers for crash signals (SIGSEGV, SIGABRT, SIGFPE, SIGILL, SIGBUS, SIGTRAP).
FileReadResult ReadFileBounded (const std::filesystem::path &path, size_t maximumSize)
 Open and read a regular file without allocating more than maximumSize bytes.
const char * FileReadErrorMessage (FileReadError error)
 Human-readable description for error.
std::ostream & operator<< (std::ostream &os, FillRule value)
 Ostream output operator for FillRule enum, outputs the CSS value.
const char * AllocTagName (AllocTag tag)
 Stable short names for AllocTag, indexed by the enum value.
AllocTagTotals SampleAllocTagTotals ()
 Read the per-tag live large-block totals.
HeapSizeHistogram SampleHeapSizeHistogram ()
 Read the histogram. Cheap: a load per bucket.
bool HeapSizeHistogramEnabled ()
 Whether the allocator wrappers are linked in. False in shipping builds.
std::ostream & operator<< (std::ostream &os, LengthUnit unit)
 OStream output operator, writes the CSS unit identifier to the stream, e.g. % or px.
float NarrowToFloat (double from)
 Semantically represent a narrowing conversion, such as converting a double to a float, to make the conversion more visible.
template<typename T>
const T & Min (const T &a, const T &b)
 Returns minimum of the provided values.
template<typename T, typename... Args>
const T & Min (const T &a, const T &b, Args &&... args)
 Returns minimum of the provided values.
template<typename T>
const T & Max (const T &a, const T &b)
 Returns maximum of the provided values.
template<typename T, typename... Args>
const T & Max (const T &a, const T &b, Args &&... args)
 Returns maximum of the provided values.
float Abs (float a)
 Returns the absolute value of the number.
double Abs (double a)
 Returns the absolute value of the number.
template<typename T, typename = std::enable_if<std::is_integral<T>::value && std::is_signed<T>::value>>
Abs (T a)
 Returns the absolute value of the number.
template<typename T, typename = std::enable_if<std::is_floating_point<T>::value>>
Round (T orig)
 Round a floating point value to an integer.
template<typename T>
Lerp (T a, T b, const float t)
 Returns linear interpolation of a and b with ratio t.
template<typename T>
const T Clamp (T value, T low, T high)
 Clamps a value between low and high.
template<typename T>
bool NearEquals (T a, T b, T tolerance=std::numeric_limits< T >::epsilon())
 Returns if a equals b, taking possible rounding errors into account.
template<typename T>
bool NearZero (T a, T tolerance=std::numeric_limits< T >::epsilon())
 Returns if a equals zero, taking rounding errors into account.
template<typename T, typename = std::enable_if<std::is_integral<T>::value>>
bool InRange (T var, T start, T end)
 Test if a variable is in a specific range, using an optimized technique that requires only one branch.
template<typename T>
QuadraticSolution< T > SolveQuadratic (T a, T b, T c)
 Solve a quadratic equation.
const char * MemoryCategoryName (MemoryCategory category)
 Stable short names for MemoryCategory, indexed by the enum value. Used as the key set of the published stats object so a reader does not have to keep an index table in sync.
void SetRetainedBytes (MemoryCategory category, std::uint64_t bytes)
 Publish bytes as the current retained total for category, replacing whatever the category last published.
void SetEntryCount (MemoryCategory category, std::uint64_t count)
 Publish count as the current live object count for category.
void AddTransientBytes (MemoryCategory category, std::uint64_t bytes)
 Add bytes to the frame's allocation flow for category.
MemoryAttributionSample SampleMemoryAttribution ()
 Read every counter, fold the per-frame flows into their high waters, and open a new frame window. Call once per frame from the publishing thread.
MemoryAttributionSample PeekMemoryAttribution ()
 Read every counter without closing the frame window.
const char * MemoryStageName (MemoryStage stage)
 Stable short names for MemoryStage, indexed by the enum value.
MemoryStageSample SampleMemoryStages ()
 Read the stage counters and open a new frame window for them.
AllocTag AllocTagForStage (MemoryStage stage)
 The AllocTag that names the same part of the frame as stage, so a stage bracket and a large-block tag never disagree about what to call it.
std::ostream & operator<< (std::ostream &os, DiagnosticSeverity severity)
 Ostream output operator for DiagnosticSeverity.
std::ostream & operator<< (std::ostream &os, LineCap cap)
 Ostream output operator for LineCap.
std::ostream & operator<< (std::ostream &os, LineJoin join)
 Ostream output operator for LineJoin.
PathBooleanResult ApplyPathBoolean (PathBooleanOp op, std::span< const PathBooleanInput > inputs, const PathBooleanOptions &options={})
 Apply a filled path boolean operation.
std::string EscapeTerminalText (std::string_view text, bool preserveNewlines=false)
 Escape untrusted bytes and terminal format controls while preserving printable UTF-8.
RcString toSVGTransformString (const Transform2d &transform)
 Serialize a Transform2d to its canonical SVG transform attribute text, decomposing to the simplest form when possible:

Variables

constexpr std::size_t kSuspendKindCount = 4
 Number of distinct SuspendKind values.
constexpr std::size_t kHeapSizeBucketCount = 32
 Number of power-of-two size buckets. Bucket k covers [2^k, 2^(k+1)) bytes, so 32 buckets reach 2 GiB, past anything a 512 MiB wasm heap can hold.
constexpr std::size_t kLargeAllocationBytes = 4u * 1024u * 1024u
 Requested byte size at or above which an allocation is recorded in HeapSizeHistogram::recentLargeBytes. Chosen to catch anything canvas-scale while ignoring ordinary containers.
constexpr std::size_t kRecentLargeAllocationCount = 16
 Number of recent large allocation sizes retained.
constexpr std::size_t kLiveLargeBlockCount = 48
 Capacity of the live large-block table.
constexpr std::size_t kAllocTagCount = 14
 Number of distinct AllocTag values.
constexpr std::size_t kMemoryCategoryCount = 10
 Number of distinct MemoryCategory values.
constexpr std::size_t kMemoryStageCount = 8
 Number of distinct MemoryStage values.

Detailed Description

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


Class Documentation

◆ donner::FrameSuspendTotals

struct donner::FrameSuspendTotals

Suspend totals accumulated between BeginSuspendFrame and EndSuspendFrame on the calling thread.

Class Members
uint32_t count = 0 Suspend points entered during the frame.
uint32_t countByKind[kSuspendKindCount] = {} Per-kind entry counts, indexed by SuspendKind.
double longestMs = 0.0 Longest single suspend during the frame, in milliseconds.
double msByKind[kSuspendKindCount] = {} Per-kind wall time in milliseconds, indexed by SuspendKind.
double totalMs = 0.0 Summed wall time inside those suspend points, in milliseconds.

◆ donner::CompileTimeMapTables

struct donner::CompileTimeMapTables
template<std::size_t N>
struct donner::CompileTimeMapTables< N >

Perfect-hash metadata used to resolve keys into storage slots.

Class Members
uint32_t bucketCount = 0 Number of buckets used by the first-level table; zero enables fallback lookup.
array< uint32_t, N > primary {} First-level table storing direct indices or bucket seeds.
array< uint32_t, N > secondary {} Secondary slot table addressed with the bucket seed and key hash.

◆ donner::CompileTimeMapDiagnostics

struct donner::CompileTimeMapDiagnostics

Diagnostics describing how a CompileTimeMap was constructed.

Class Members
bool constexprHashSupported = true Whether constexpr hashing was available for the provided key type.
uint32_t failedBucket = kEmptySlot Index of the bucket that failed to place, or kEmptySlot when successful.
uint32_t maxBucketSize = 0 Largest bucket size observed while building the table.
uint32_t seedAttempts = 0 Total seed attempts across all buckets.

◆ donner::AllocTagTotals

struct donner::AllocTagTotals

Live large-block bytes attributed to each AllocTag.

Class Members
int64_t liveBlocks[kAllocTagCount] = {} Live large blocks tagged with this value.
int64_t liveBytes[kAllocTagCount] = {} Bytes in live large blocks tagged with this value.
int64_t peakLiveBytes[kAllocTagCount] = {} Highest liveBytes seen for this tag.
int64_t totalAllocations[kAllocTagCount] = {} Large allocations ever made under this tag.

◆ donner::HeapSizeHistogram

struct donner::HeapSizeHistogram

Live allocation totals split by block size.

Class Members
int64_t largeAllocationCount = 0 Total large allocations seen since boot.
int64_t liveBlocks[kHeapSizeBucketCount] = {} Currently allocated block count in each bucket.
int64_t liveBytes[kHeapSizeBucketCount] = {} Currently allocated bytes in each bucket, measured as usable size.
int64_t liveLargeBytes[kLiveLargeBlockCount] = {} Usable sizes of the large blocks that are live right now; zero entries are empty slots.
int64_t liveLargeTags[kLiveLargeBlockCount] = {} AllocTag in force when the corresponding liveLargeBytes entry was allocated, as its integer value.
int64_t peakLiveBytes[kHeapSizeBucketCount] = {} Highest liveBytes seen in each bucket.
int64_t recentLargeBytes[kRecentLargeAllocationCount] = {} Requested sizes of the most recent large allocations, newest last. A bucket says a block is "16 to 32 MiB"; this says it is exactly 19,120,128 bytes, which is a 2186-pixel-wide RGBA surface and therefore identifies its owner by arithmetic instead of by guesswork.
int64_t tableOverflows = 0 Large allocations that found the live-block table full. Non-zero means the per-tag totals under-count and kLiveLargeBlockCount needs raising.

◆ donner::MathConstants

struct donner::MathConstants
template<typename T>
struct donner::MathConstants< T >

Contains a set of math constants for the specified type (float or double).

Template Parameters
T

◆ donner::QuadraticSolution

struct donner::QuadraticSolution
template<typename T>
struct donner::QuadraticSolution< T >

Holds the solution of a quadratic equation, as returned by SolveQuadratic.

Template Parameters
T
Class Members
bool hasSolution = false True if the equation has solutions.
array< T, 2 > solution Solutions to the equation, valid if hasSolution is true.

◆ donner::MemoryAttributionSample

struct donner::MemoryAttributionSample

One frame's view of where the process's bytes are.

Class Members
uint64_t entryCounts[kMemoryCategoryCount] = {} Live object count per category (textures, tiles), where the owner tracks one.
uint64_t mallocArenaBytes = 0 Total space the allocator has taken from the system, from mallinfo.
uint64_t mallocFreeBytes = 0 Bytes in the allocator's free lists, from mallinfo.
uint64_t mallocLiveBytes = 0 Bytes in allocated malloc blocks, from mallinfo; 0 where unavailable.
uint64_t mallocLiveHighWaterBytes = 0 Highest mallocLiveBytes seen since boot.
uint64_t retainedBytes[kMemoryCategoryCount] = {} Current retained bytes per category, indexed by MemoryCategory.
uint64_t retainedHighWaterBytes[kMemoryCategoryCount] = {} Highest retainedBytes seen since boot, per category.
uint64_t totalRetainedBytes = 0 Sum of retainedBytes across categories.
uint64_t totalRetainedHighWaterBytes = 0 Highest totalRetainedBytes seen since boot.
uint64_t transientBytes[kMemoryCategoryCount] = {} Bytes allocated during the frame just closed, per category.
uint64_t transientHighWaterBytes[kMemoryCategoryCount] = {} Highest single-frame transientBytes seen since boot, per category.
uint64_t wasmHeapBytes = 0 wasm linear memory size in bytes; 0 where the platform has no such notion.
uint64_t wasmHeapHighWaterBytes = 0 Highest wasmHeapBytes seen since boot.

◆ donner::MemoryStageSample

struct donner::MemoryStageSample

Net allocator movement attributed to each stage.

Class Members
int64_t cumulativeNetBytes[kMemoryStageCount] = {} Net live-heap change since boot, per stage. A stage that is in balance hovers near zero however long the session runs; a stage that retains climbs without bound, and this is the number that names it.
uint64_t entries[kMemoryStageCount] = {} Times the stage was entered since boot.
int64_t maxNetBytes[kMemoryStageCount] = {} Largest single-entry net growth seen for the stage, in bytes.
int64_t netBytes[kMemoryStageCount] = {} Net live-heap change during the frame just closed, per stage. Negative means the stage freed more than it allocated.

◆ donner::PathBooleanInput

struct donner::PathBooleanInput

One filled path participating in a boolean operation.

Class Members
FillRule fillRule = FillRule::NonZero Fill rule for path.
Transform2d outputFromPath = Transform2d() Transform into output coordinates.
Path path Source path geometry.

◆ donner::PathBooleanOptions

struct donner::PathBooleanOptions

Limits and tolerances for bounded boolean operations.

Class Members
double geometricTolerance = 1e-6 Geometric comparison tolerance.
size_t maxCurveCount = 100000 Maximum input segment count.
size_t maxIntersections = 100000 Maximum segment intersections.
size_t maxOutputCommands = 200000 Maximum emitted output commands.

◆ donner::PathBooleanResult

struct donner::PathBooleanResult

Result of ApplyPathBoolean.

Class Members
vector< string > diagnostics Compact diagnostic messages.
vector< Path > paths Output paths on success.
PathBooleanStatus status = PathBooleanStatus::Ok Operation status.

Typedef Documentation

◆ Entity

using donner::Entity = entt::entity

Entity type for the Registry, a std::uint32_t alias.

Entity type for the Registry.

This is a core type for the the ECS, and is used to identify entities in the Registry.

See also
Entity Component System (ECS)
Registry

◆ EntityHandle

typedef entt::basic_handle< Registry > donner::EntityHandle = entt::basic_handle<Registry>

Convenience handle for a Entity with an attached Registry.

Forward declaration of EntityHandle.

Allows calling functions typically on Registry without having to pass around two values.

◆ Registry

typedef entt::basic_registry< Entity > donner::Registry = entt::basic_registry<Entity>

Registry type for the SVG ECS, which is the entry point for storing all data.

Forward declaration of Registry.

It is used to create new entities:

Registry registry;
const Entity entity = registry.create();
entt::basic_registry< Entity > Registry
Registry type for the SVG ECS, which is the entry point for storing all data.
Definition EcsRegistry.h:50
entt::entity Entity
Entity type for the Registry, a std::uint32_t alias.
Definition EcsRegistry.h:20

Attach or remove data classes to entities:

registry.emplace<components::TreeComponent>(entity, "unknown");
Stores the tree structure for an XML element, such as the parent, children, and siblings.
Definition TreeComponent.h:18
void remove(Registry &registry)
Remove this node from its parent, if it has one.

Store global objects (singleton-like):

registry.ctx().emplace<components::RenderingContext>(registry));
const Entity root = registry.ctx().get<components::RenderingContext>().rootEntity;
See also
Entity Component System (ECS)

Enumeration Type Documentation

◆ AllocTag

enum class donner::AllocTag : std::uint8_t
strong

Who was on the stack when a large block was allocated.

A size histogram says "four blocks of about 19 MiB are live"; it cannot say who holds them, and a category counter cannot either, because the whole point of an unattributed block is that no subsystem is counting it. This closes that gap without a backtrace: a thread-local tag, pushed by a scope guard around the candidate call sites and by the frame-stage brackets, is stored alongside every live large block. It costs one thread-local store per guard and one extra field per tracked block, and it works in an optimized wasm build where return addresses do not symbolize.

Enumerator
Untagged 

No guard was active. A large block landing here is a call site the investigation has not covered yet.

WorkerRenderFrame 

CompositorController::renderFrame on the render thread.

WorkerBuildPreview 

Building the composited preview from the compositor's tile state.

WorkerFinalSnapshot 

The end-of-frame full-canvas CPU or GPU snapshot.

WorkerOther 

Render-thread work outside the three stages above.

AppPollResult 

The app thread accepting a completed epoch, including texture upload.

AppUiFrame 

The app thread's ImGui frame body.

AppHostFrame 

The app thread's host present (ImGui render, surface acquire, submit).

AppInput 

Browser input translated into editor events on the app thread.

RenderTileRaster 

Rasterizing one CPU tile of the render result.

GpuReadbackStaging 

A GPU texture readback staging buffer.

CompositorBitmap 

A compositor layer or segment bitmap.

PresentationUpload 

Presentation-side texture upload staging.

ImGuiDrawLists 

ImGui's own draw-list vertex and index vectors.

◆ CompileTimeMapStatus

enum class donner::CompileTimeMapStatus
strong

Indicates the result of building a CompileTimeMap.

Enumerator
kOk 

Perfect-hash tables were constructed successfully.

kUsingFallbackHash 

Map is available but using the linear fallback path instead of perfect hashing.

kDuplicateKey 

Duplicate keys were detected in the input payload.

kSeedSearchFailed 

Perfect-hash seed search failed; map is available via fallback lookup.

kConstexprHashUnsupported 

Compile-time hashing is unsupported for this key type when evaluated constexpr.

◆ DiagnosticSeverity

enum class donner::DiagnosticSeverity : uint8_t
strong

Severity level for a parser diagnostic.

Enumerator
Warning 

Non-fatal issue; parsing continues.

Error 

Fatal issue; parsing may stop or produce partial results.

◆ FillRule

enum class donner::FillRule : uint8_t
strong

The parsed result of the 'fill-rule' property, see: https://www.w3.org/TR/SVG2/painting.html#FillRuleProperty.

Enumerator
NonZero 

[DEFAULT] Determines "insideness" of a point by counting crossings of a ray drawn from that point to infinity and path segments. If crossings is non-zero, the point is inside, else outside.

EvenOdd 

Determines "insideness" of a point by counting the number of path segments from the shape crossed by a ray drawn from that point to infinity. If count is odd, point is inside, else outside.

◆ LengthUnit

enum class donner::LengthUnit : uint8_t
strong

The unit identifier for a length, corresponding to CSS unit identifiers.

See https://www.w3.org/TR/css-values-3/#lengths for definitions.

Enumerator
None 

Unitless.

Percent 

Percentage, using the '%' symbol.

Cm 

Centimeters, 1cm = 96px/2.54.

Mm 

Millimeters, 1mm = 1/10th of 1cm.

Quarter-millimeters, 1Q = 1/40th of 1cm.

In 

Inches, 1in = 2.54cm = 96px.

Pc 

Picas, 1pc = 1/6th of 1in.

Pt 

Points, 1pt = 1/72nd of 1in.

Px 

Pixels, 1px = 1/96th of 1in.

Em 

Font size, 1em = current font size.

Ex 

x-height of the current font, 1ex = x-height of current font.

Ch 

Width of the glyph '0' in the current font, 1ch = width of '0' in current font.

Rem 

Root font size, 1rem = font size of the root element.

Vw 

Viewport width, 1vw = 1% of viewport width.

Vh 

Viewport height, 1vh = 1% of viewport height.

Vmin 

Smaller of viewport width and height, 1vmin = 1% of smaller of viewport width and height.

Vmax 

Larger of viewport width and height, 1vmax = 1% of larger of viewport width and height.

◆ LineCap

enum class donner::LineCap : uint8_t
strong

Line cap style for stroke endpoints.

Enumerator
Butt 

The stroke is squared off at the endpoint of the path.

Round 

The stroke is rounded at the endpoint of the path.

Square 

The stroke extends beyond the endpoint by half the stroke width and is squared off.

◆ LineJoin

enum class donner::LineJoin : uint8_t
strong

Line join style for stroke corners.

Enumerator
Miter 

The outer edges of the strokes are extended until they meet at a sharp point.

Round 

The corners of the stroke are rounded using a circular arc.

Bevel 

A triangular shape fills the area between the two stroked segments.

◆ MemoryCategory

enum class donner::MemoryCategory : std::uint8_t
strong

A subsystem that retains or allocates pixel-scale memory. Kept small and stable: values are published to the stats surface as array indices.

Enumerator
CompositorSegmentBitmaps 

CPU pixel buffers for the compositor's cached static segments.

CompositorSegmentTextures 

GPU textures for the compositor's cached static segments.

CompositorLayerBitmaps 

CPU pixel buffers for promoted compositor layers.

CompositorLayerTextures 

GPU textures for promoted compositor layers.

RenderResultTiles 

CPU tile payload in the epoch the render thread handed to the app thread.

WorkerFrameSnapshot 

Full-canvas snapshot the worker takes at the end of a frame, CPU or GPU.

PresentationTiles 

Presentation textures for the active (viewport-bounded) tile set.

PresentationOverviewTiles 

Presentation textures for the retained zoom-out overview tile set.

PresentationRetired 

Presentation textures waiting out the backend's frames-in-flight window.

LayerThumbnails 

Layers-panel thumbnail textures.

◆ MemoryStage

enum class donner::MemoryStage : std::uint8_t
strong

A bracketed stage of the frame, measured by what it does to the allocator rather than by what a subsystem says it holds.

The category counters above only see memory a subsystem knows it owns. When live heap grows and no category moves, the bytes are somewhere no owner is reporting - a backend's staging buffer, a queue, a container nobody thought of - and the only way to find them is to ask which part of the frame the allocator grew during. These stages partition the frame so that question has an answer.

Enumerator
WorkerRenderFrame 

CompositorController::renderFrame on the render thread.

WorkerBuildPreview 

Building the composited preview from the compositor's tile state.

WorkerFinalSnapshot 

The end-of-frame full-canvas CPU or GPU snapshot.

WorkerOther 

Everything else in one render-thread iteration.

AppPollResult 

The app thread accepting a completed epoch, including texture upload.

AppUiFrame 

The app thread's ImGui frame body.

AppHostFrame 

The app thread's host present (ImGui render, surface acquire, submit).

AppInput 

Browser input translated into editor events on the app thread.

◆ PathBooleanOp

enum class donner::PathBooleanOp : std::uint8_t
strong

Boolean operation to apply to filled path inputs.

Enumerator
Union 

Filled region covered by any input.

Intersect 

Filled region covered by every input.

Difference 

Filled region covered by the first input but no later input.

Xor 

Filled region covered by an odd number of inputs.

◆ PathBooleanStatus

enum class donner::PathBooleanStatus : std::uint8_t
strong

Status for a path boolean result.

Enumerator
Ok 

Operation succeeded and produced at least one output path.

EmptyResult 

Operation succeeded but the requested region is empty.

InvalidInput 

Input paths or options are invalid.

TooComplex 

Operation exceeded configured complexity caps.

◆ StringComparison

enum class donner::StringComparison : uint8_t
strong

String comparison options, e.g. case sensitivity.

Enumerator
Default 

The default case-sensitive string comparison.

IgnoreCase 

Case-insensitive string comparison.

◆ SuspendKind

enum class donner::SuspendKind : std::uint8_t
strong

Why a call site can suspend. Kept small and stable: it is published to the stats surface as an array index.

Enumerator
TileYield 

yieldBetweenTiles: a deliberate one-turn yield at a compositor tile boundary so the thread's event loop can service canvas-size commits and WebGPU callbacks mid-pass.

GpuReadback 

Waiting for a GPU readback (mapAsync completion) to land.

DeviceWait 

device.poll / instance.waitAny: emdawnwebgpu yields the Asyncify worker for roughly one browser task per call regardless of the wait argument.

Startup 

Device and adapter acquisition, and anything else that suspends outside the steady-state frame path.

Function Documentation

◆ ApplyPathBoolean()

PathBooleanResult donner::ApplyPathBoolean ( PathBooleanOp op,
std::span< const PathBooleanInput > inputs,
const PathBooleanOptions & options = {} )

Apply a filled path boolean operation.

The implementation is in-tree and preserves line, quadratic, and cubic segments for retained boundary spans. It is intentionally bounded: invalid inputs or operations exceeding configured caps return a non-PathBooleanStatus::Ok status instead of mutating caller state.

Parameters
opBoolean operation to apply.
inputsFilled path inputs in operation order.
optionsTolerances and complexity caps.

◆ constexprHashValue()

template<typename Key>
uint64_t donner::constexprHashValue ( const Key & key)
constexpr

Compute a constexpr-friendly hash of key for supported key types.

Returns uint64_t to ensure consistent hashing on both 32-bit and 64-bit platforms.

◆ DecodeBase64Data()

ParseResult< std::vector< uint8_t > > donner::DecodeBase64Data ( std::string_view base64String)

Decode a base64-encoded string into a byte array.

If the string is not valid base64, an error is returned.

Parameters
base64StringThe base64-encoded string to decode.
Returns
The decoded byte array, or an error if the input is not valid base64.

◆ EncodeBase64Data()

std::string donner::EncodeBase64Data ( std::span< const uint8_t > data)

Encode a byte array into a base64-encoded string.

Parameters
dataThe byte array to encode.
Returns
The base64-encoded string.

◆ InRange()

template<typename T, typename = std::enable_if<std::is_integral<T>::value>>
bool donner::InRange ( T var,
T start,
T end )
inline

Test if a variable is in a specific range, using an optimized technique that requires only one branch.

Some compilers do this automatically.

Example:

if (InRange(var, 'a', 'z')) // ...
bool InRange(T var, T start, T end)
Test if a variable is in a specific range, using an optimized technique that requires only one branch...
Definition MathUtils.h:219

◆ InstallFailureSignalHandler()

void donner::InstallFailureSignalHandler ( )

Install signal handlers for crash signals (SIGSEGV, SIGABRT, SIGFPE, SIGILL, SIGBUS, SIGTRAP).

When a crash signal is received, the handler prints a stack trace to stderr and then re-raises the signal so the default handler can produce a core dump.

◆ Lerp()

template<typename T>
T donner::Lerp ( T a,
T b,
const float t )
inline

Returns linear interpolation of a and b with ratio t.

Returns
a if t == 0, b if t == 1, and the linear interpolation else.

◆ mixHash()

uint64_t donner::mixHash ( uint64_t baseHash,
std::uint32_t seed )
constexpr

Mix a base hash value with a seed to produce a new hash. Used to construct perfect-hash bucket seeds during CompileTimeMap construction.

Uses uint64_t explicitly to ensure correct behavior on 32-bit platforms (e.g., WASM) where std::size_t is 32 bits and the >> 33 shift would be undefined behavior.

◆ NarrowToFloat()

float donner::NarrowToFloat ( double from)
inline

Semantically represent a narrowing conversion, such as converting a double to a float, to make the conversion more visible.

For example: const float f = NarrowToFloat(1.0);

◆ parentsGenerator()

template<ElementLike T>
ElementTraversalGenerator< T > donner::parentsGenerator ( T element)

A generator that yields all parents of an element, repeatedly following parentElement() until reaching the root.

Parameters
elementThe element to start from, which is not yielded.

◆ previousSiblingsGenerator()

template<ElementLike T>
ElementTraversalGenerator< T > donner::previousSiblingsGenerator ( T element)

A generator that yields all siblings of an element, in reverse order.

This repeatedly follows previousSibling().

Parameters
elementThe element to start from, which is not yielded.

◆ ReadFileBounded()

FileReadResult donner::ReadFileBounded ( const std::filesystem::path & path,
size_t maximumSize )

Open and read a regular file without allocating more than maximumSize bytes.

The read uses a nonblocking descriptor or handle, follows the requested final symlink, and validates the opened object as a regular file. It fails closed for directories, FIFOs, devices, size changes, and data beyond the expected byte count.

Parameters
pathFile to read.
maximumSizeMaximum accepted byte count.
Examples
geode_embed.cc, svg_to_png.cc, and svg_viewer.cc.

◆ singleElementGenerator()

template<ElementLike T>
ElementTraversalGenerator< T > donner::singleElementGenerator ( T element)

A generator that yields a single element, if it exists.

Parameters
elementThe element to yield. If this is std::nullopt, the generator will yield nothing.

◆ SolveQuadratic()

template<typename T>
QuadraticSolution< T > donner::SolveQuadratic ( T a,
T b,
T c )

Solve a quadratic equation.

\( a x^2 + b x + c = 0 \)

Parameters
aFirst coefficient.
bSecond coefficient.
cThird coefficient.
Returns
QuadraticSolution, containing 0-2 solutions.

◆ toSVGTransformString()

RcString donner::toSVGTransformString ( const Transform2d & transform)

Serialize a Transform2d to its canonical SVG transform attribute text, decomposing to the simplest form when possible:

  • Identity → empty string
  • Pure translate ([1 0 0 1 e f]) → translate(e, f), or translate(e) when f == 0
  • Pure uniform scale ([s 0 0 s 0 0]) → scale(s)
  • Pure non-uniform scale ([sx 0 0 sy 0 0]) → scale(sx, sy)
  • Pure rotation around origin ([cos -sin sin cos 0 0]) → rotate(deg)
  • General → matrix(a, b, c, d, e, f)

Numbers are emitted via {} (integer-valued doubles) or {:g} (fractional) so the output is the shortest form that round-trips. Arguments are comma-separated with a space after the comma, matching the canonical CSS transform syntax.

Round-trips with donner::svg::parser::TransformParser::Parse for every shape above.

Parameters
transformTransform to serialize.
Returns
Canonical SVG transform text (empty string for identity).

◆ UrlDecode()

std::vector< uint8_t > donner::UrlDecode ( std::string_view urlEncodedString)

Decode a URL-encoded string into a byte array, translating XX sequences into the corresponding byte value.

See also
https://url.spec.whatwg.org/#percent-encoded-bytes
Parameters
urlEncodedStringThe URL-encoded string to decode.
Returns
A vector of decoded byte values.