|
|
Donner SVG 0.8.0-pre
SVG editor and embeddable C++20 engine.
|
#include <optional>#include <span>#include <vector>#include "donner/svg/renderer/RendererInterface.h"Classes | |
| struct | donner::editor::EmbeddedSvgIconRequest |
| One embedded-SVG rasterization, for the batched atlas path. More... | |
Namespaces | |
| namespace | donner |
| Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css. | |
Functions | |
| void | donner::editor::ConfigureEmbeddedSvgIconRenderer (svg::RendererInterface &renderer) |
| Use an editor-owned renderer for subsequent embedded-SVG rasterization. | |
| void | donner::editor::ResetEmbeddedSvgIconRenderer (const svg::RendererInterface &expectedRenderer) |
| Stop using the configured renderer before its owner is destroyed. | |
| std::optional< svg::RendererBitmap > | donner::editor::RenderEmbeddedSvgIcon (std::span< const unsigned char > svgBytes, int outputSizePx) |
| Render an embedded SVG icon resource into a tintable RGBA bitmap. | |
| std::optional< svg::RendererBitmap > | donner::editor::RenderEmbeddedSvgArtwork (std::span< const unsigned char > svgBytes, int outputSizePx) |
| Render embedded SVG artwork while preserving its authored RGBA colors. | |
| std::vector< std::optional< svg::RendererBitmap > > | donner::editor::RenderEmbeddedSvgIconBatch (std::span< const EmbeddedSvgIconRequest > requests) |
| Rasterize a set of embedded icons in one render pass and one GPU readback. | |
| void | donner::editor::PrewarmEmbeddedSvgIcons (std::span< const EmbeddedSvgIconRequest > requests) |
| Rasterize a set of embedded icons up front so later single-icon calls are free. | |
| void donner::editor::ConfigureEmbeddedSvgIconRenderer | ( | svg::RendererInterface & | renderer | ) |
Use an editor-owned renderer for subsequent embedded-SVG rasterization.
The editor calls this before its first UI frame so icon rendering reuses the already-created backend/device instead of creating a second headless device. The renderer must outlive the matching reset call.
| void donner::editor::PrewarmEmbeddedSvgIcons | ( | std::span< const EmbeddedSvgIconRequest > | requests | ) |
Rasterize a set of embedded icons up front so later single-icon calls are free.
The editor's first UI frame draws every affordance icon it shows, and each one used to pay its own GPU readback while the frame was blocked on it. This collapses that into one batched readback before the frame starts: RenderEmbeddedSvgIcon and RenderEmbeddedSvgArtwork return the prewarmed bitmap for any request already rasterized here.
Requests that fail are simply not cached, so the matching single-icon call still falls back to its own rasterization.
| requests | Icons to rasterize and cache. |
|
nodiscard |
Render embedded SVG artwork while preserving its authored RGBA colors.
Use this for small multi-color assets such as the editor's black-core, white-halo tool icons. Single-color affordances should continue to use RenderEmbeddedSvgIcon so ImGui can tint their alpha mask.
| svgBytes | Embedded SVG source bytes. |
| outputSizePx | Square output bitmap size in device pixels. |
|
nodiscard |
Render an embedded SVG icon resource into a tintable RGBA bitmap.
The source SVG is parsed and rasterized through Donner. The returned bitmap is normalized to a white premultiplied-alpha mask so callers can tint it with the current ImGui text color when displaying the resulting texture.
| svgBytes | Embedded SVG source bytes. |
| outputSizePx | Square output bitmap size in device pixels. |
|
nodiscard |
Rasterize a set of embedded icons in one render pass and one GPU readback.
Icons are packed into a single atlas render target, drawn together, read back once, then sliced apart. Each slice is byte-identical to the bitmap the matching single-icon call would return, so this is purely a cost change: on a GPU backend a readback is an asynchronous buffer mapping whose latency is paid per call, and the per-icon path pays it once per icon.
| requests | Icons to rasterize. |
| void donner::editor::ResetEmbeddedSvgIconRenderer | ( | const svg::RendererInterface & | expectedRenderer | ) |
Stop using the configured renderer before its owner is destroyed.
The reset is ignored when another editor has since installed a different renderer, which keeps overlapping editor lifetimes safe.