|
|
Donner 0.5.0
Embeddable browser-grade SVG2 engine
|
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 | |
| GeoEncoder & | operator= (const GeoEncoder &)=delete |
| GeoEncoder (GeoEncoder &&) noexcept | |
| GeoEncoder & | operator= (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. | |
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();
| donner::geode::GeoEncoder::GeoEncoder | ( | GeodeDevice & | device, |
| const GeodePipeline & | pipeline, | ||
| const wgpu::Texture & | target ) |
Create an encoder targeting the given texture.
| device | The Geode device (owns the wgpu::Device + queue). |
| pipeline | The Slug fill pipeline (must match the target's format). |
| target | Texture to render into. Must be created with RenderAttachment usage. The encoder takes a reference; the caller must keep the texture alive until finish() returns. |
| 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.
| 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.
| path | The path to fill. |
| color | Solid fill color (NOT premultiplied — the encoder handles premultiplication for the blend pipeline). |
| rule | Fill rule (NonZero or EvenOdd). |
| 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.