| Flutter Impeller |

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
8 #include "impeller/geometry/scalar.h"
9
10 namespace 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.
24 constexpr static float kKernelRadiusPerSigma = 1.73205080757;
25
26 struct 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.
32 struct Sigma {
33 Scalar sigma = 0.0;
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.
48 struct Radius {
49 Scalar radius = 0.0;
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_
impeller::Sigma::sigma
Scalar sigma
Definition: sigma.h:33
impeller::Radius::radius
Scalar radius
Definition: sigma.h:49
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::Radius::Radius
constexpr Radius(Scalar p_radius)
Definition: sigma.h:53
impeller::Radius::Radius
constexpr Radius()=default
impeller::Radius
For convolution filters, the "radius" is the size of the convolution kernel to use on the local space...
Definition: sigma.h:48
impeller::Sigma::Sigma
constexpr Sigma()=default
impeller::Sigma
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
Definition: sigma.h:32
scalar.h
impeller::kKernelRadiusPerSigma
constexpr static float kKernelRadiusPerSigma
Definition: sigma.h:24
impeller::Sigma::Sigma
constexpr Sigma(Scalar p_sigma)
Definition: sigma.h:37
impeller
Definition: aiks_blur_unittests.cc:20