Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
GeoEncoder.h File Reference

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

#include <cstdint>
#include <memory>
#include <span>
#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 dependency graph for GeoEncoder.h:

Classes

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::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 premultiplied linear RGBA.

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

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

Collaboration diagram for donner::geode::GeoEncoder::PatternPaint:
[legend]
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.
Texture tile 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().