Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
sigma.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_IMPELLER_GEOMETRY_SIGMA_H_
6#define FLUTTER_IMPELLER_GEOMETRY_SIGMA_H_
7
9
10namespace impeller {
11
12/// For filters that use a Gaussian distribution, this is the `Radius` size to
13/// use per `Sigma` (standard deviation).
14///
15/// This cutoff (sqrt(3)) is taken from Flutter and Skia (where the
16/// multiplicative inverse of this constant is used (1 / sqrt(3)):
17/// https://api.flutter.dev/flutter/dart-ui/Shadow/convertRadiusToSigma.html
18///
19/// In practice, this value is somewhat arbitrary, and can be changed to a
20/// higher number to integrate more of the Gaussian function and render higher
21/// quality blurs (with exponentially diminishing returns for the same sigma
22/// input). Making this value any lower results in a noticable loss of
23/// quality in the blur.
24constexpr static float kKernelRadiusPerSigma = 1.73205080757;
25
26struct Radius;
27
28/// @brief In filters that use Gaussian distributions, "sigma" is a size of
29/// one standard deviation in terms of the local space pixel grid of
30/// the filter input. In other words, this determines how wide the
31/// distribution stretches.
32struct Sigma {
34
35 constexpr Sigma() = default;
36
37 explicit constexpr Sigma(Scalar p_sigma) : sigma(p_sigma) {}
38
39 operator Radius() const; // NOLINT(google-explicit-constructor)
40};
41
42/// @brief For convolution filters, the "radius" is the size of the
43/// convolution kernel to use on the local space pixel grid of the
44/// filter input.
45/// For Gaussian blur kernels, this unit has a linear
46/// relationship with `Sigma`. See `kKernelRadiusPerSigma` for
47/// details on how this relationship works.
48struct Radius {
50
51 constexpr Radius() = default;
52
53 explicit constexpr Radius(Scalar p_radius) : radius(p_radius) {}
54
55 operator Sigma() const; // NOLINT(google-explicit-constructor)
56};
57
58} // namespace impeller
59
60#endif // FLUTTER_IMPELLER_GEOMETRY_SIGMA_H_
float Scalar
Definition scalar.h:18
static constexpr float kKernelRadiusPerSigma
Definition sigma.h:24
For convolution filters, the "radius" is the size of the convolution kernel to use on the local space...
Definition sigma.h:48
constexpr Radius()=default
Scalar radius
Definition sigma.h:49
constexpr Radius(Scalar p_radius)
Definition sigma.h:53
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
Definition sigma.h:32
Scalar sigma
Definition sigma.h:33
constexpr Sigma(Scalar p_sigma)
Definition sigma.h:37
constexpr Sigma()=default