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

Single-precision mapping from target pixels to source texels for nearest image sampling. More...

#include <array>
#include <optional>
#include "donner/base/Transform.h"
Include dependency graph for GeodeNearestSampling.h:

Classes

struct  donner::geode::NearestTexelRows
 Affine rows that map a target pixel position (x, y) to source texel coordinates: texelX = x * texelX[0] + (y * texelX[1] + texelX[2]), and likewise for texelY. More...

Namespaces

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

Functions

std::optional< NearestTexelRows > donner::geode::NearestTexelRowsFor (const Transform2d &targetFromTexel)
 Inverts targetFromTexel the way the software renderer's image sampler does: the transform is first narrowed to single precision, then inverted with that sampler's algorithm (a single precision reciprocal for scale and translation, otherwise a double precision determinant with each coefficient rounded once).

Detailed Description

Single-precision mapping from target pixels to source texels for nearest image sampling.

Function Documentation

◆ NearestTexelRowsFor()

std::optional< NearestTexelRows > donner::geode::NearestTexelRowsFor ( const Transform2d & targetFromTexel)

Inverts targetFromTexel the way the software renderer's image sampler does: the transform is first narrowed to single precision, then inverted with that sampler's algorithm (a single precision reciprocal for scale and translation, otherwise a double precision determinant with each coefficient rounded once).

Sampling the same pixel centers through these rows then selects the same texels as the software renderer wherever a texel boundary passes through a pixel center, up to the floating-point contraction of the final multiply-add.

Parameters
targetFromTexelTransform from source texel coordinates to target pixels.
Returns
The rows, or std::nullopt when the narrowed transform is not invertible.