Donner SVG main
0.8.0 ยท 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::components::StyleResourceBudget Class Reference

Aggregate stylesheet cascade and selector traversal budget for one style-computation pass. More...

#include "donner/svg/components/style/StyleSystem.h"

Classes

struct  Limits
 Independent cascade, traversal, and retained-property limits. More...
class  OwnerScope
 Shared owner scope; nested recording and fallback work preserves the current allowance. More...
class  ActiveRegistryScope
 Keep mutable document storage active throughout preparation, drawing and restoration. More...

Public Member Functions

 StyleResourceBudget (std::shared_ptr< DocumentResourceFamilyBudget > family=nullptr)
 Construct a style budget with default limits.
 StyleResourceBudget (Limits limits, std::shared_ptr< DocumentResourceFamilyBudget > family=nullptr)
 Construct a style budget with caller-supplied limits.
 StyleResourceBudget (const StyleResourceBudget &document, Limits share)
 Give a worker independent work counters while charging records to the document.
Limits remainingWorkLimits (Limits requested) const
 Clamp a requested share to work still available locally and in the aggregate envelope.
 StyleResourceBudget (const StyleResourceBudget &)=delete
StyleResourceBudget & operator= (const StyleResourceBudget &)=delete
 StyleResourceBudget (StyleResourceBudget &&other) noexcept
 Transfer counters and retained-property reservations from another budget.
StyleResourceBudget & operator= (StyleResourceBudget &&)=delete
bool isRegistryActive (const Registry &registry) const
 Return whether mutable storage is already on this render operation's traversal stack.
bool reserveExternalInstanceWork (std::size_t entities)
 Admit bounded entity work for one external-use preparation against the frame allowance.
std::size_t externalInstanceWork () const
 External-use instance work admitted in the current frame.
bool reserveExternalMeasureWork (std::size_t entities)
 Admit bounded entity work for laying out one external-use occurrence to measure its bounds for a host effect, against a frame allowance of its own.
std::size_t externalMeasureWork () const
 External-use measurement work admitted in the current frame.
bool reserveExternalMeasureGeometryBytes (std::size_t bytes)
 Admit bytes of path geometry that external-use measurement retains until the frame ends, against a frame allowance of its own.
std::size_t externalMeasureGeometryBytes () const
 Path bytes external-use measurement retains in the current frame.
bool externalMeasureGeometryExhausted () const
 Whether a path copy external-use measurement asked to retain did not fit the current frame's allowance, after which no more are retained.
void noteExternalMeasureGeometryComparison ()
 Count one full comparison of a measured path against a retained path copy.
std::size_t externalMeasureGeometryComparisons () const
 Full path comparisons external-use measurement made in the current frame.
bool reportExternalResourceWarning ()
 Return true once per frame when an unsupported inherited resource needs a diagnostic.
bool reportVariableLimitWarning ()
 Return true for the first variable expansion refusal of the pass.
void setAggregateWorkBudget (StyleResourceBudget *budget)
 Set a frame-wide aggregate work allowance while an external-use scope is active.
void reset ()
 Reset traversal, match/declaration counters and local refusal; retained bytes remain.
bool reserveRuleElementMatch ()
 Charge one rule-to-element match, or latch rejection when a limit has been reached.
bool reserveDeclarationApplication (std::size_t componentCount=0, std::size_t sourceBytes=0)
 Charge one declaration application and its associated component and source work.
bool canReserveDeclarationWork (std::size_t applications, std::size_t componentCount, std::size_t sourceBytes) const
 Test a declaration-work sequence without changing counters or refusal state.
bool reserveGeneratedDeclarationWork (std::size_t components, std::size_t bytes)
 Charge output generated by one substitution without charging another application.
bool tryReplaySelectorWork (std::size_t rules, std::size_t steps)
 Admit previously measured selector work if it fits; declining leaves all counters unchanged.
bool tryReplayCacheHit (std::size_t rules, std::size_t applications, std::size_t components, std::size_t bytes, std::size_t traversal)
 Debit a complete cache-hit sequence. A declined shortcut leaves ordinary serial admission intact.
bool retainComputedStyle (ComputedStyle &style, std::size_t byteCount)
 Charge one immutable computed-style record for exactly its lifetime.
void noteRetainedCustomPropertyRefusal ()
 Stop admitting style work after canonical custom-property storage was refused.
bool canRetainComputedStyle (std::size_t byteCount) const
 Return whether bytes fit without changing counters or refusal state.
const std::shared_ptr< RetainedStyleBytes > & retainedStyleBytes () const
 Shared account held by every computed-style record created for this document.
css::SelectorTraversalBudget & selectorTraversal ()
 Return the mutable selector traversal budget for this computation pass.
const css::SelectorTraversalBudget & selectorTraversal () const
 Return the selector traversal budget for this computation pass.
std::size_t ruleElementMatches () const
 Return the number of rule-to-element matches charged.
std::size_t declarationApplications () const
 Return the number of declaration applications charged.
std::size_t declarationComponentWork () const
 Return aggregate declaration component work units charged.
std::size_t declarationByteWork () const
 Return aggregate declaration source bytes charged.
std::size_t complexPropertyBytes () const
 Return retained complex-property bytes charged to this budget.
bool rejected () const
 Return whether this budget or its selector traversal budget refused work.
const Limits & limits () const
 Return the active cascade, traversal, and retained-property ceilings.

Static Public Attributes

static constexpr std::size_t kMaximumRuleElementMatches = 1024 * 1024
 Default maximum rule-to-element matches in one computation pass.
static constexpr std::size_t kMaximumDeclarationApplications = 1024 * 1024
 Default maximum declaration applications in one pass.
static constexpr std::size_t kMaximumDeclarationComponentWork = 16 * 1024 * 1024
 Default maximum aggregate declaration component work units.
static constexpr std::size_t kMaximumDeclarationByteWork = 16 * 1024 * 1024
 Default maximum aggregate declaration source bytes charged.
static constexpr std::size_t kMaximumComplexPropertyBytes = 64 * 1024 * 1024
 Default maximum retained complex-property bytes.
static constexpr std::size_t kMaximumExternalMeasureGeometryBytes = 32 * 1024 * 1024
 Default maximum path bytes external-use measurement retains in one frame.

Detailed Description

Aggregate stylesheet cascade and selector traversal budget for one style-computation pass.

Constructor & Destructor Documentation

◆ StyleResourceBudget() [1/4]

donner::svg::components::StyleResourceBudget::StyleResourceBudget ( std::shared_ptr< DocumentResourceFamilyBudget > family = nullptr)
inlineexplicit

Construct a style budget with default limits.

Parameters
familyOptional shared document-family envelope for retained style bytes.

◆ StyleResourceBudget() [2/4]

donner::svg::components::StyleResourceBudget::StyleResourceBudget ( Limits limits,
std::shared_ptr< DocumentResourceFamilyBudget > family = nullptr )
inlineexplicit

Construct a style budget with caller-supplied limits.

Parameters
limitsCascade, traversal, and retained-property ceilings.
familyOptional shared document-family envelope for retained style bytes.

◆ StyleResourceBudget() [3/4]

donner::svg::components::StyleResourceBudget::StyleResourceBudget ( const StyleResourceBudget & document,
Limits share )
inline

Give a worker independent work counters while charging records to the document.

Parameters
documentBudget that owns the retained-byte account.
shareWork limits assigned before dispatch. The document supplies the retained-byte limit.

◆ StyleResourceBudget() [4/4]

donner::svg::components::StyleResourceBudget::StyleResourceBudget ( StyleResourceBudget && other)
inlinenoexcept

Transfer counters and retained-property reservations from another budget.

Only move a budget when no OwnerScope or ActiveRegistryScope refers to it.

Parameters
otherBudget whose family charge moves to this instance.

Member Function Documentation

◆ isRegistryActive()

bool donner::svg::components::StyleResourceBudget::isRegistryActive ( const Registry & registry) const
inline

Return whether mutable storage is already on this render operation's traversal stack.

Parameters
registryStorage considered for child admission.

◆ reserveDeclarationApplication()

bool donner::svg::components::StyleResourceBudget::reserveDeclarationApplication ( std::size_t componentCount = 0,
std::size_t sourceBytes = 0 )
inlinenodiscard

Charge one declaration application and its associated component and source work.

Parameters
componentCountComponent work units for this application.
sourceBytesSource bytes charged for this application.
Returns
True when all charges fit; false after a prior or current refusal.

◆ reserveExternalMeasureGeometryBytes()

bool donner::svg::components::StyleResourceBudget::reserveExternalMeasureGeometryBytes ( std::size_t bytes)
inline

Admit bytes of path geometry that external-use measurement retains until the frame ends, against a frame allowance of its own.

The first refusal exhausts the allowance for the frame.

Parameters
bytesBytes of one retained path copy.
Returns
True when the bytes fit the remaining allowance.

◆ reserveExternalMeasureWork()

bool donner::svg::components::StyleResourceBudget::reserveExternalMeasureWork ( std::size_t entities)
inline

Admit bounded entity work for laying out one external-use occurrence to measure its bounds for a host effect, against a frame allowance of its own.

Measuring recurses into the occurrence's own external uses, so without an allowance a family of documents that each use the next several times would cost exponential work. A refusal leaves drawing unaffected.

Parameters
entitiesEntities the measured occurrence lays out.
Returns
True when the work fits the remaining measurement allowance.

The documentation for this class was generated from the following file: