|
|
Donner SVG Editor & Engine
SVG-native editor and embeddable SVG2 + CSS3 engine in C++20, with GPU (WebGPU) and compact CPU renderers, built for correctness, security, and performance.
|
Shared RGBA8 pixel-format conversion helpers used across Donner's renderer backends and the compositor. Split out from FilterGraphExecutor.h and CompositorController.cc so that callers which don't otherwise depend on the filter graph or the compositor can still premul / unpremul without pulling those in. More...
#include <cstddef>#include <cstdint>#include <span>#include <vector>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. | |
Functions | |
| std::vector< std::uint8_t > | donner::svg::PremultiplyRgba (std::span< const std::uint8_t > rgbaPixels) |
| Convert tightly-packed straight-alpha RGBA8 to premultiplied RGBA8. | |
| std::vector< std::uint8_t > | donner::svg::CopyTightRgbaRows (std::span< const std::uint8_t > rgbaPixels, int width, int height, std::size_t rowBytes) |
| Copy row-strided RGBA8 bytes into a tightly-packed RGBA8 buffer. | |
| std::vector< std::uint8_t > | donner::svg::PremultiplyRgbaRows (std::span< const std::uint8_t > rgbaPixels, int width, int height, std::size_t rowBytes) |
| Convert row-strided straight-alpha RGBA8 to tightly-packed premultiplied RGBA8. | |
| void | donner::svg::UnpremultiplyRgbaInPlace (std::vector< std::uint8_t > &rgba) |
| Convert tightly-packed premultiplied RGBA8 to straight-alpha RGBA8, in place. Fully-opaque pixels (alpha == 255) are unchanged; fully-transparent pixels (alpha == 0) become (0, 0, 0, 0). | |
| std::vector< std::uint8_t > | donner::svg::UnpremultiplyRgba (std::span< const std::uint8_t > rgbaPixels) |
| Non-mutating variant of UnpremultiplyRgbaInPlace that allocates. Prefer the in-place form on hot paths; use this when the caller needs to preserve the input. | |
| std::vector< std::uint8_t > | donner::svg::UnpremultiplyRgbaRows (std::span< const std::uint8_t > rgbaPixels, int width, int height, std::size_t rowBytes) |
| Convert row-strided premultiplied RGBA8 to tightly-packed straight-alpha RGBA8. | |
Shared RGBA8 pixel-format conversion helpers used across Donner's renderer backends and the compositor. Split out from FilterGraphExecutor.h and CompositorController.cc so that callers which don't otherwise depend on the filter graph or the compositor can still premul / unpremul without pulling those in.
Byte layout: RGBA, 4 bytes/pixel. Conversion helpers without an explicit rowBytes parameter expect tightly-packed data; row helpers copy from the caller-provided stride into a tightly-packed output. Unaligned tails are ignored (matches the pre-split behavior of every caller that had its own local copy).
Rounding convention: integer round-half-up in both directions, so a round-trip premul → unpremul is bit-identical for every well-formed premul input (i.e., r ≤ a, g ≤ a, b ≤ a). If a caller has out-of-range premul input, that is a bug upstream; these helpers will clamp to 255 without corrupting alpha.