|
|
Donner SVG 0.8.0-pre
SVG editor and embeddable C++20 engine.
|
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 | |
| bool | donner::svg::HasExactRgbaPayload (std::span< const std::uint8_t > rgbaPixels, int width, int height) |
| Returns whether a byte span is exactly one tightly packed RGBA8 payload. | |
| std::vector< std::uint8_t > | donner::svg::PremultiplyRgba (std::span< const std::uint8_t > rgbaPixels) |
| Convert tightly-packed straight-alpha RGBA8 to premultiplied RGBA8. | |
| void | donner::svg::PremultiplyRgbaInto (std::span< const std::uint8_t > rgbaPixels, std::vector< std::uint8_t > &out) |
| Convert tightly-packed straight-alpha RGBA8 to premultiplied RGBA8, writing into a caller-owned buffer. | |
| 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. | |
| void | donner::svg::CopyTightRgbaRowsInto (std::span< const std::uint8_t > rgbaPixels, int width, int height, std::size_t rowBytes, std::vector< std::uint8_t > &out) |
| Copy row-strided RGBA8 bytes into a caller-owned tightly-packed 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::PremultiplyRgbaRowsInto (std::span< const std::uint8_t > rgbaPixels, int width, int height, std::size_t rowBytes, std::vector< std::uint8_t > &out) |
| Convert row-strided straight-alpha RGBA8 to tightly-packed premultiplied RGBA8, writing into a caller-owned buffer. | |
| 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).
Aliasing: the *Into helpers write through their out buffer while reading rgbaPixels, so the two must not overlap. Passing a span into out's own storage (including out itself) is undefined behavior - the write can reallocate out and dangle the input span. Every other helper returns a fresh buffer and has no such constraint.
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.