Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
SlugFill.h File Reference

Shared Slug fill layouts and frozen shader interfaces. More...

#include <cmath>
#include <cstdint>
#include <initializer_list>
#include "donner/gpu/shader/CompiledShader.h"
Include dependency graph for SlugFill.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::gpu::shader::programs::SlugFillParams
 Per-draw transform, paint, geometry and clip parameters. More...
struct  donner::gpu::shader::programs::SlugFillInstance
 One painter-ordered instance, including its nested transform and bounding polygon. More...
struct  donner::gpu::shader::programs::SlugFillBand
 A band indexes the corresponding curve-reference range. More...
struct  donner::gpu::shader::programs::SlugPixelMapping
 Pixel-to-path mapping a Slug fragment applies to its own pixel center p: pathFromPixel * (p - pixelOrigin) + pathOffset, with pathFromPixel holding the inverse linear transform's two columns. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Functions

SlugPixelMapping donner::gpu::shader::programs::ComputeSlugPixelMapping (double a, double b, double c, double d, double e, double f)
 Computes the mapping for the path-to-target-pixel affine x' = a x + c y + e, y' = b x + d y + f, in double precision.
template<typename ParamsT>
void donner::gpu::shader::programs::WriteSlugPixelMapping (ParamsT &params, const SlugPixelMapping &mapping)
 Writes mapping into any parameter block carrying the three mapping fields.
const CompiledShaderView & donner::gpu::shader::programs::SlugFillShader ()
 Returns a stable view of the authored WGSL and reflected interface.
const CompiledShaderView & donner::gpu::shader::programs::SlugFillNativeShader ()
 Returns a stable view containing only the platform-native projection.

Variables

constexpr double donner::gpu::shader::programs::kSlugMaxExactPixelOrigin = 4194304.0
 Largest translation, in pixels, split off as an integer pixel origin. A pixel center is a multiple of one half inside a target at most tens of thousands of pixels wide, so it minus an integer origin below 2^22 is a multiple of one half below 2^23, which float32 represents exactly.

Detailed Description

Shared Slug fill layouts and frozen shader interfaces.

Function Documentation

◆ ComputeSlugPixelMapping()

SlugPixelMapping donner::gpu::shader::programs::ComputeSlugPixelMapping ( double a,
double b,
double c,
double d,
double e,
double f )
inline

Computes the mapping for the path-to-target-pixel affine x' = a x + c y + e, y' = b x + d y + f, in double precision.

The translation splits into an integer pixel origin and a fractional remainder. The shader subtracts the origin from the pixel center exactly, and every other input depends only on the linear part and that remainder. Draws whose translations differ by an integer, with the sum exact in double as it is for every atlas or tile placement of an ordinary draw, therefore map corresponding pixels to the same path positions whatever their target. A translation too large to split stays whole in the offset, as precise as the float path data it is compared with.

A transform without an inverse, or one whose inverse float cannot hold, gets an all-zero mapping, and the shaders cover no pixel of a draw that carries it. The draw's enclosure is built on the GPU from float axes that rounding can leave slightly invertible, so it can still rasterize a sliver of pixels, and only that rule keeps them empty.