Donner 0.5.0
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::geode::GeoEncoder Class Reference

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

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

Classes

struct  Impl

Public Member Functions

 GeoEncoder (GeodeDevice &device, const GeodePipeline &pipeline, const wgpu::Texture &target)
 Create an encoder targeting the given texture.
 GeoEncoder (const GeoEncoder &)=delete
GeoEncoderoperator= (const GeoEncoder &)=delete
 GeoEncoder (GeoEncoder &&) noexcept
GeoEncoderoperator= (GeoEncoder &&) noexcept
void clear (const css::RGBA &color)
 Clear the target texture to the given color.
void setTransform (const Transform2d &transform)
 Set the model-view transform for subsequent draw calls.
void fillPath (const Path &path, const css::RGBA &color, FillRule rule)
 Fill a path with a solid color.
void finish ()
 Submit all encoded commands to the GPU queue.

Detailed Description

Drawing API for the Geode GPU renderer.

GeoEncoder is a per-frame command builder. Construct one against a target texture, issue draw calls (fillPath, clear, etc.), then call finish() to submit the command buffer to the GPU.

The encoder owns no GPU buffers itself — each draw call allocates fresh vertex / band / curve / uniform buffers. This is the simplest possible implementation; later phases will add buffer pooling and the ECS-backed GeodePathCacheComponent for paths whose geometry hasn't changed.

Typical usage:

GeoEncoder encoder(device, pipeline, targetTexture);
encoder.clear(css::RGBA::White);
encoder.setTransform(Transform2d::Scale(2.0));
encoder.fillPath(myPath, css::RGBA::Red, FillRule::NonZero);
encoder.finish();

Constructor & Destructor Documentation

◆ GeoEncoder()

donner::geode::GeoEncoder::GeoEncoder ( GeodeDevice & device,
const GeodePipeline & pipeline,
const wgpu::Texture & target )

Create an encoder targeting the given texture.

Parameters
deviceThe Geode device (owns the wgpu::Device + queue).
pipelineThe Slug fill pipeline (must match the target's format).
targetTexture to render into. Must be created with RenderAttachment usage. The encoder takes a reference; the caller must keep the texture alive until finish() returns.

Member Function Documentation

◆ clear()

void donner::geode::GeoEncoder::clear ( const css::RGBA & color)

Clear the target texture to the given color.

Must be called before any draw calls — clear is implemented as the load op of the first render pass, so calling it after a draw is a no-op. Subsequent calls override the previous clear color.

◆ fillPath()

void donner::geode::GeoEncoder::fillPath ( const Path & path,
const css::RGBA & color,
FillRule rule )

Fill a path with a solid color.

The path is encoded into Slug band data on the CPU, uploaded to GPU buffers, and a draw call is recorded. The fill is applied with the current transform.

Parameters
pathThe path to fill.
colorSolid fill color (NOT premultiplied — the encoder handles premultiplication for the blend pipeline).
ruleFill rule (NonZero or EvenOdd).

◆ finish()

void donner::geode::GeoEncoder::finish ( )

Submit all encoded commands to the GPU queue.

After this call, the encoder is in a "finished" state and no further draws can be issued. The caller is responsible for any synchronization (e.g., MapAsync + Tick loop) needed to actually use the rendered output.


The documentation for this class was generated from the following files:
  • donner/svg/renderer/geode/GeoEncoder.h
  • donner/svg/renderer/geode/GeoEncoder.cc