Donner SVG main
0.8.0 ยท 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::geode::GeodePathCacheComponent Struct Reference

Per-entity cache of Geode's encoded-path output (and strokeToFill results). Installed lazily by RendererGeode at the encode call sites via get_or_emplace; removed automatically when the source ComputedPathComponent updates or is destroyed. More...

#include "donner/svg/renderer/geode/GeodePathCacheComponent.h"

Classes

struct  FillVariant
 One fill encode, built for one device-derived cubic tolerance bucket. More...
struct  StrokeVariant
 One cached stroke outline: the Path::strokeToFill output of the entity's geometry for one stroke key, and its encode. The key is everything the outline depends on besides the geometry, whose changes remove the whole component: the stroke style, the device-derived flattening tolerance, and the host transform of a non-scaling-stroke centerline. More...

Public Member Functions

std::optional< std::size_t > fillVariantFor (double drawTolerance) const
 Index of the variant serving drawTolerance, or nullopt when no cached encode matches.
std::optional< std::size_t > strokeVariantFor (const StrokeStyle &style, double tolerance, const std::optional< Transform2d > &hostFromLocal) const
 Index of the stroke variant serving a draw with the given key, or nullopt when none does.

Public Attributes

std::array< FillVariant, kFillVariantCount > fillVariants
 Fill encodes, one per recently drawn tolerance bucket. Populated on first encode for a bucket; reused while the bucket stays cached. Index i pairs with the resident slots of the same index in GeodeResidentPathSlots.
std::uint64_t fillUseClock = 0
 Monotonic use counter for FillVariant::lastUse.
std::array< std::unique_ptr< StrokeVariant >, kStrokeVariantCount > strokeVariants
 Stroke outlines, one per recently drawn stroke key. Each is allocated on first use, so an entity that is never stroked keeps only the pointers, and stays at one address while cached, so a pending batch can keep drawing from it. Index i pairs with the resident stroke slots of the same index in GeodeResidentPathSlots.
std::uint64_t strokeUseClock = 0
 Monotonic use counter for StrokeVariant::lastUse.

Static Public Attributes

static constexpr std::size_t page_size = 64
 Limit initial storage for this large component while retaining paged pointer stability: every document registry with a drawn path allocates at least one page.
static constexpr std::size_t kFillVariantCount = kGeodeFillVariantCount
 Number of tolerance buckets cached at once. Two covers an element drawn at its rest scale and an animated scale in the same frame. A further bucket replaces the least recently used variant, unless every variant may still be read by an open frame; then it draws from a scratch encode.
static constexpr std::size_t kStrokeVariantCount = kGeodeStrokeVariantCount
 Number of stroke keys cached at once. Eight covers an element whose <use> instances apply several stroke styles to it. A further key replaces the least recently used variant, unless every variant may still be read by an open frame (the current one, or an outer frame an offscreen pass runs inside); then it draws from a per-frame outline, so the keys of one frame cannot evict each other and a pending batch never loses the outline it points at.
static constexpr std::size_t kStrokeVariantsPerStyle = kGeodeFillVariantCount
 Most outlines one stroke style keeps across tolerance buckets and host transforms, the same bound fills keep across tolerance buckets: a rest scale and an animated one. Zooming through further scale buckets replaces the style's own least recently used outline instead of filling the cache.

Detailed Description

Per-entity cache of Geode's encoded-path output (and strokeToFill results). Installed lazily by RendererGeode at the encode call sites via get_or_emplace; removed automatically when the source ComputedPathComponent updates or is destroyed.

Lives in donner::geode (not donner::svg::geode) to match the other Geode types (EncodedPath, LinearGradientParams, ...) that RendererGeode.cc references unqualified via geode:: inside the donner::svg namespace.

Member Function Documentation

◆ strokeVariantFor()

std::optional< std::size_t > donner::geode::GeodePathCacheComponent::strokeVariantFor ( const StrokeStyle & style,
double tolerance,
const std::optional< Transform2d > & hostFromLocal ) const
inline

Index of the stroke variant serving a draw with the given key, or nullopt when none does.

Parameters
styleStroke parameters of the draw.
toleranceDevice-derived flattening tolerance of the draw.
hostFromLocalHost transform of a non-scaling-stroke draw, or nullopt.

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