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

Persistent per-occurrence instance records for one text element. More...

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

Classes

struct  Occurrence
 One occurrence's record slot plus the bytes last written to it. More...

Public Types

using OccurrenceOwner = std::unique_ptr<Occurrence>

Public Member Functions

 GeodeTextInstanceRecordComponent (const GeodeTextInstanceRecordComponent &)=delete
GeodeTextInstanceRecordComponent & operator= (const GeodeTextInstanceRecordComponent &)=delete
 GeodeTextInstanceRecordComponent (GeodeTextInstanceRecordComponent &&other) noexcept
GeodeTextInstanceRecordComponent & operator= (GeodeTextInstanceRecordComponent &&other) noexcept
bool reserveOccurrence (std::shared_ptr< GeodeDocumentGeometryBudget > budget)
bool appendReservedOccurrence (const GeodeRecordSlab::Slot &slot)
void rollbackOccurrence ()
uint64_t cpuRetainedBytesForTesting () const
void freeRecordSlots ()
 Return every slot to the slab (deferred to the next frame's merge, like every other record free) and drop them.

Public Attributes

std::vector< OccurrenceOwner > occurrences
 Occurrence slots in paint order. Index is the occurrence's ordinal within the element's draw, so it is stable across unchanged frames. Owners may move when the vector grows, but each separately allocated occurrence stays put while a pending batch holds pointers into it.
std::shared_ptr< GeodeRecordSlabrecordSlab
 Slab the slots were allocated from; also keeps that slab alive so a device change cannot leave the slots pointing at a destroyed slab.
uint64_t lastFrame = 0
 Device-scoped frame generation of the last draw that wrote these slots. Zero means "never written": generations start at 1, and the guard reads this as "older than every open frame", which is what an untouched component is.
std::shared_ptr< GeodeDocumentGeometryBudgetcpuBudget
GeodeGeometryCacheReservation cpuReservation
uint64_t cpuRetainedBytes = 0

Static Public Attributes

static constexpr uint64_t kOccurrencePayloadBytes = sizeof(Occurrence) + sizeof(InstanceRecord)
static constexpr uint64_t kProjectedBytesPerOccurrence

Detailed Description

Persistent per-occurrence instance records for one text element.

Glyph geometry is shared, so the thing that has to exist once per OCCURRENCE is the record: transform, colour, and the shared outline's chunk-relative geometry bases. Handing every occurrence a fresh record slot each frame would work, but it would also write 256 bytes per glyph per frame forever, which keeps a static text frame off the zero-bytes steady state the rest of the renderer reaches.

So the slots live on the text element and persist. Occurrence i of the element always writes slot i, the bytes are compared before writing, and an unchanged frame writes nothing. Slots are bump-allocated together on first use, which keeps their indices consecutive - exactly the property a batch needs to cover them with one draw.

No explicit invalidation is needed when the text changes: a re-laid-out element simply produces different record bytes for the affected slots, the compare misses, and those slots are rewritten. A shorter run leaves trailing slots unused (and free for the element to grow back into); a longer one appends.

lastFrame guards the one case the compare cannot: the same element written twice while an earlier writer's draws are still unsubmitted - the same element drawn twice in one frame (a <use> of the text), or an offscreen pass rendering the same document inside an outer frame that has already recorded its glyph batch. The second writer must not rewrite those records, because every buffer write in a frame executes before every draw in that frame's submit. lastFrame holds a DEVICE-scoped generation (GeodeDevice::beginFrameGeneration) so the comparison covers renderers sharing a device, and the renderer diverts the second writer to per-frame temporary slots instead.


Class Documentation

◆ donner::geode::GeodeTextInstanceRecordComponent::Occurrence

struct donner::geode::GeodeTextInstanceRecordComponent::Occurrence

One occurrence's record slot plus the bytes last written to it.

Class Members
vector< uint8_t > lastRecord
Slot slot

Member Data Documentation

◆ kProjectedBytesPerOccurrence

uint64_t donner::geode::GeodeTextInstanceRecordComponent::kProjectedBytesPerOccurrence
staticconstexpr
Initial value:
=
sizeof(OccurrenceOwner) + kOccurrencePayloadBytes

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