Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
GeoEncoder.h File Reference

Drawing API for the Geode GPU renderer. More...

#include <cstddef>
#include <cstdint>
#include <memory>
#include <span>
#include <vector>
#include <webgpu/webgpu.hpp>
#include "donner/base/Box.h"
#include "donner/base/FillRule.h"
#include "donner/base/Transform.h"
#include "donner/base/Vector2.h"
#include "donner/css/Color.h"
#include "donner/gpu/CommandEncoder.h"
#include "donner/gpu/Handles.h"
#include "donner/svg/core/ImageRendering.h"
#include "donner/svg/core/MaskType.h"
#include "donner/svg/renderer/geode/GeodeResidentPathComponent.h"
Include dependency graph for GeoEncoder.h:

Classes

class  donner::geode::GeometryDebugSink
 Optional debug observer for Slug draws that actually reach a GPU draw call. More...
class  donner::geode::GeometryAdmission
 Frame-wide admission gate invoked before every Slug geometry upload or draw. More...
struct  donner::geode::LinearGradientParams
 Parameters for a linear gradient fill at the Geode drawing layer. More...
struct  donner::geode::LinearGradientParams::Stop
 Gradient stops. Colors are in straight alpha, 0..1 per channel - the encoder premultiplies before upload. Offsets must be in [0, 1]. More...
struct  donner::geode::RadialGradientParams
 Parameters for a radial gradient fill at the Geode drawing layer. More...
class  donner::geode::GeoEncoder
 Drawing API for the Geode GPU renderer. More...
struct  donner::geode::GeoEncoder::ScenePaint
 Paint carried by one cross-entity batch instance: a solid colour, or a resolved gradient whose parameters and stop ramp the encoder copies into the slot's persistent paint block. More...
struct  donner::geode::GeoEncoder::SceneRecordState
 The record fields a batched instance takes from encoder-side state rather than from its own arguments: the paint scalars published into its slot and the clip rectangle live at the time it was appended. More...
struct  donner::geode::GeoEncoder::SceneBatchBinding
 One cross-entity ordered batch: consecutive resident slots of one slab chunk plus a run of consecutive record-slab slots. More...
struct  donner::geode::GeoEncoder::PatternPaint
 Describes a pattern tile used as a paint source for fillPathPattern. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.
namespace  donner::svg
 Donner SVG library, which can load, manipulate and render SVG files.

Detailed Description

Drawing API for the Geode GPU renderer.


Class Documentation

◆ donner::geode::LinearGradientParams::Stop

struct donner::geode::LinearGradientParams::Stop

Gradient stops. Colors are in straight alpha, 0..1 per channel - the encoder premultiplies before upload. Offsets must be in [0, 1].

A hard cap of 16 stops is enforced inside the encoder to match the fixed-size uniform buffer layout in slug_gradient.wgsl. Stops beyond the cap are silently truncated - a follow-up will move stop storage to a texture lookup (GeodeGradientCacheComponent) to lift this limit. A single gradient stop: normalized offset and STRAIGHT-alpha RGBA. Not premultiplied: the resolver writes r/g/b/a each divided by 255, and both gradient shaders interpolate stops in straight alpha and premultiply only at output (stop-opacity conformance depends on it).

Class Members
float offset = 0.0f Stop offset in [0, 1].
float rgba[4] = {0.0f, 0.0f, 0.0f, 1.0f} Straight-alpha RGBA color.

◆ donner::geode::GeoEncoder::SceneRecordState

struct donner::geode::GeoEncoder::SceneRecordState

The record fields a batched instance takes from encoder-side state rather than from its own arguments: the paint scalars published into its slot and the clip rectangle live at the time it was appended.

A batch re-derives every instance's record when it flushes, which can be arbitrarily far from the append: other draws of the same entity, and other clip changes, can happen in between. Reading these back off the slot or off the encoder at that point reads the LATEST state, not the appended one. The caller therefore captures them at append and hands the same values back at flush, which is what makes the re-derivation reproduce byte-identical bytes.

Class Members
float clipRect[4] = {0.0f, 0.0f, 0.0f, 0.0f}
uint32_t clipRectActive = 0
uint32_t gradientSpread = 0
uint32_t gradientStopCount = 0
uint32_t paintMode = 0

◆ donner::geode::GeoEncoder::SceneBatchBinding

struct donner::geode::GeoEncoder::SceneBatchBinding

One cross-entity ordered batch: consecutive resident slots of one slab chunk plus a run of consecutive record-slab slots.

Class Members
BufferRef chunkBuffer Slab chunk holding every instance's geometry.
uint64_t chunkBufferId = 0
uint64_t chunkBytes = 0 Byte size of chunkBuffer; scene batches bind the whole chunk.
uint64_t firstRecordOffset = 0 BYTE offset of the first instance's record inside recordBuffer. Record-slot indices are global across slab chunks, so an index is not a byte offset once the slab has grown; the caller passes the first slot's own buffer-relative offset instead.
uint32_t instanceCount = 1
BufferRef recordBuffer Record-slab buffer holding the records. Stable identities of chunkBuffer / recordBuffer (see GeodeDevice::AllocateBufferId). The bind-group cache outlives the document that owns these buffers, so it keys on these ids; the raw handle addresses are recycled once that document is destroyed.
uint64_t recordBufferId = 0
GeodeRecordSlab * recordSlab = nullptr
uint32_t vertexCount = 0 Max fan vertex count over the instances. Record slab the instances' records live in. Supplies the persistent batch-uniform buffer so a steady frame writes nothing; null falls back to the encoder's per-frame uniform arena.

◆ donner::geode::GeoEncoder::PatternPaint

struct donner::geode::GeoEncoder::PatternPaint

Describes a pattern tile used as a paint source for fillPathPattern.

The tile texture is expected to contain pre-rendered pattern content in premultiplied RGBA. The Slug fill shader samples it with the Repeat wrap mode (equivalent to SVG <pattern> default behaviour) using the provided transform to map path-space positions into tile-space.

Class Members
double opacity = 1.0 Multiplicative alpha applied to the sampled tile color. Usually fill-opacity * opacity.
Transform2d patternFromPath Transform from path space (where the path being filled lives) to pattern tile space. Typically inverse(targetFromPattern) composed with the current encoder transform - the RendererGeode layer builds the right composition.
const Texture * tile = nullptr Pre-rendered tile texture (RGBA8, premultiplied).
Vector2d tileSize Size of the tile rectangle in pattern space (width, height). The shader uses this to wrap sample positions via fract().