Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
FilterRegionContext.h File Reference
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <optional>
#include <string>
#include <unordered_map>
#include <utility>
#include <variant>
#include "donner/base/MathUtils.h"
#include "donner/base/Transform.h"
#include "donner/svg/components/animation/AnimationValueSampler.h"
#include "donner/svg/components/filter/FilterGraph.h"
Include dependency graph for FilterRegionContext.h:

Classes

struct  donner::svg::FilterInputMargin
 Input a filter layer's capture must include beyond each output pixel, in device pixels. More...
struct  donner::svg::FilterInputMarginBuilder
 Accumulates each primitive's input reach in device pixels, converting lengths with the same helpers and bounds the filter executors use. The executors round each primitive to whole pixels (offsets and morphology radii to the nearest pixel, blur kernels up), so each primitive's reach rounds up to whole pixels before the chain adds them. More...
struct  donner::svg::FilterInputBuffer
 Filter input raster layout around a viewport: the viewport plus input margins on each side. More...
struct  donner::svg::FilterInputAxis
 One axis of a FilterInputBuffer. More...
struct  donner::svg::FilterRegionSample
 Resolved clipping bounds and optional un-clipped animated geometry, in user coordinates. More...
struct  donner::svg::FilterRegionContext
 Per-invocation filter coordinates and subregion history, independent of GPU resources. More...

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

double donner::svg::BoundedPositiveFilterPixels (double value)
 Clamp a finite nonnegative radius to the filter-work bound.
double donner::svg::BoundedSignedFilterPixels (double value)
 Clamp a finite offset to the filter-work bound.
size_t donner::svg::FilterInputSlotCount (const components::FilterNode &node)
 The number of inputs a primitive reads through the filter attribute surface. feComposite, feBlend and feDisplacementMap each take a second input (in2); feMerge is variadic and reads exactly the list it was built with, and every other primitive reads at most one input. The cap of two is deliberate rather than a lower bound: those primitives never sample a third input, so an extra entry a caller appends must not widen the node's subregion either.
components::FilterInput donner::svg::FilterInputOrDefault (const components::FilterNode &node, size_t index)
 The input in slot index, or the default for a slot the graph left empty. A slot the graph never populated is an unspecified in/in2 attribute, and both resolve the same way: to the preceding primitive's result, which is SourceGraphic only when this node is the first primitive in the filter. Falling back to the node's own first input instead would silently composite, blend, or displace a buffer against itself.
double donner::svg::FilterDeviceScaleX (const Transform2d &transform)
 Device scale of the filter X axis.
double donner::svg::FilterDeviceScaleY (const Transform2d &transform, double scaleX)
 Device scale of the filter Y axis.
double donner::svg::FilterLengthInPixels (double value, double bound, double scale, bool objectBounds)
 Resolve an effect length in device pixels.
Vector2d donner::svg::FilterOffsetInPixels (Vector2d offset, Vector2d bounds, bool objectBounds, const Transform2d &transform)
 Resolve a filter offset vector in device coordinates.
const components::FilterNode * donner::svg::FilterFirstInputNode (const components::FilterGraph &graph, size_t index)
 The node a primitive's first input names, or nullptr when it reads a standard input.
Vector2d donner::svg::FinishFilterReach (Vector2d reach)
 Finish a device reach: one more pixel covers rounding at the reach's edge.
FilterInputMargin donner::svg::ComputeFilterSamplingReach (const components::FilterGraph &graph, const Transform2d &deviceFromFilter)
 Conservatively measure how far beyond each output pixel a filter graph reads its raster. Every primitive counts, including those fed only by generators: feFlood, feImage and feTurbulence produce output only over the raster, so a later blur or tile still needs the raster to extend past the viewport. Reaches add up, since chained primitives compound.
FilterInputMargin donner::svg::ComputeFilterInputMargin (const components::FilterGraph &graph, const Transform2d &deviceFromFilter)
 The input margin a filter layer's capture gets: the graph's sampling reach, or none when the capture must stay viewport-aligned (see components::FilterGraph::keepsViewportAlignedCapture and feTurbulence).
int donner::svg::FilterInputExtension (double beyond, double needed)
 Pixels to extend a filter input raster past one viewport edge.
FilterInputAxis donner::svg::LayoutFilterInputAxis (std::pair< double, double > region, double reach, std::optional< std::pair< double, double > > capture, int viewport)
 Lay out one raster axis.
FilterInputBuffer donner::svg::ComputeFilterInputBuffer (const components::FilterGraph &graph, const std::optional< Box2d > &filterRegion, const Transform2d &deviceFromFilter, int viewportWidth, int viewportHeight)
 Lay out the input raster for a filter layer over a viewportWidth by viewportHeight surface. Primitives that read input away from the output position need the filtered content just past the viewport, so the raster extends by the graph's input margin wherever the filter region extends past the viewport, up to the whole region for a graph with unbounded reach. Each axis stays within the surface dimension limit; a layout over the pixel limit falls back to the viewport. Renderers also fall back to the viewport when the larger raster would not fit the frame's filter budgets.
std::optional< Transform2d > donner::svg::FiniteFilterInverse (const Transform2d &deviceFromFilter)
 Invert only finite, nonsingular transforms whose inverse remains finite.

Class Documentation

◆ donner::svg::FilterInputMargin

struct donner::svg::FilterInputMargin

Input a filter layer's capture must include beyond each output pixel, in device pixels.

Class Members
Vector2d captureReach Input read beyond userCapture by the primitives feeding it.
Vector2d pixels Farthest input read from an output pixel, per axis.
optional< Box2d > userCapture User-space rectangle the capture must cover in full.
bool wholeRegion = false Some primitive can read any position in its input.

◆ donner::svg::FilterInputAxis

struct donner::svg::FilterInputAxis

One axis of a FilterInputBuffer.

Class Members
int before = 0 Pixels before the viewport.
int extent = 0 Total pixels.

◆ donner::svg::FilterRegionSample

struct donner::svg::FilterRegionSample

Resolved clipping bounds and optional un-clipped animated geometry, in user coordinates.

Class Members
optional< Box2d > animatedRegion Un-clipped region for image placement when sampled.
Box2d bounds Clip region, intersected with the filter region.