Donner SVG main
0.8.0 ยท 382bd0190.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 &)=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.
bool reportExternalResourceWarning ()
 Return true once per frame when an unsupported inherited resource needs a diagnostic.
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 reserveComplexPropertyBytes (Entity entity, std::size_t byteCount)
 Set an entity's retained complex-property charge, releasing bytes on reductions.
void release (Entity entity)
 Release one entity's retained complex-property bytes, if it has a reservation.
void releaseAll ()
 Release all retained complex-property bytes without resetting other counters.
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.

Detailed Description

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


Class Documentation

◆ donner::svg::components::StyleResourceBudget::Limits

struct donner::svg::components::StyleResourceBudget::Limits

Independent cascade, traversal, and retained-property limits.

Class Members
size_t complexPropertyBytes = kMaximumComplexPropertyBytes Maximum retained complex-property bytes for this budget.
size_t declarationApplications = kMaximumDeclarationApplications Maximum declaration applications.
size_t declarationByteWork = kMaximumDeclarationByteWork Maximum aggregate declaration source bytes charged.
size_t declarationComponentWork = kMaximumDeclarationComponentWork Maximum aggregate declaration component work units.
size_t ruleElementMatches = kMaximumRuleElementMatches Maximum rule-to-element matches.
size_t selectorTraversalSteps = css::SelectorTraversalBudget::kMaximumSteps Maximum selector traversal steps.

Constructor & Destructor Documentation

◆ StyleResourceBudget() [1/3]

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/3]

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/3]

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.

◆ release()

void donner::svg::components::StyleResourceBudget::release ( Entity entity)
inline

Release one entity's retained complex-property bytes, if it has a reservation.

Parameters
entityEntity whose reservation is removed.

◆ reserveComplexPropertyBytes()

bool donner::svg::components::StyleResourceBudget::reserveComplexPropertyBytes ( Entity entity,
std::size_t byteCount )
inlinenodiscard

Set an entity's retained complex-property charge, releasing bytes on reductions.

Parameters
entityEntity whose property charge changes.
byteCountNew retained byte count for this entity.
Returns
True for a reduction or an admitted increase; false for a refused increase.

◆ 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.

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