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
#pragma once
6
7
#include "
impeller/geometry/scalar.h
"
8
9
namespace
impeller
{
10
11
/// For filters that use a Gaussian distribution, this is the `Radius` size to
12
/// use per `Sigma` (standard deviation).
13
///
14
/// This cutoff (sqrt(3)) is taken from Flutter and Skia (where the
15
/// multiplicative inverse of this constant is used (1 / sqrt(3)):
16
/// https://api.flutter.dev/flutter/dart-ui/Shadow/convertRadiusToSigma.html
17
///
18
/// In practice, this value is somewhat arbitrary, and can be changed to a
19
/// higher number to integrate more of the Gaussian function and render higher
20
/// quality blurs (with exponentially diminishing returns for the same sigma
21
/// input). Making this value any lower results in a noticable loss of
22
/// quality in the blur.
23
constexpr
static
float
kKernelRadiusPerSigma
= 1.73205080757;
24
25
struct
Radius
;
26
27
/// @brief In filters that use Gaussian distributions, "sigma" is a size of
28
/// one standard deviation in terms of the local space pixel grid of
29
/// the filter input. In other words, this determines how wide the
30
/// distribution stretches.
31
struct
Sigma
{
32
Scalar
sigma
= 0.0;
33
34
constexpr
Sigma
() =
default
;
35
36
explicit
constexpr
Sigma
(
Scalar
p_sigma) :
sigma
(p_sigma) {}
37
38
operator
Radius
()
const
;
// NOLINT(google-explicit-constructor)
39
};
40
41
/// @brief For convolution filters, the "radius" is the size of the
42
/// convolution kernel to use on the local space pixel grid of the
43
/// filter input.
44
/// For Gaussian blur kernels, this unit has a linear
45
/// relationship with `Sigma`. See `kKernelRadiusPerSigma` for
46
/// details on how this relationship works.
47
struct
Radius
{
48
Scalar
radius
= 0.0;
49
50
constexpr
Radius
() =
default
;
51
52
explicit
constexpr
Radius
(
Scalar
p_radius) :
radius
(p_radius) {}
53
54
operator
Sigma
()
const
;
// NOLINT(google-explicit-constructor)
55
};
56
57
}
// namespace impeller
impeller::Sigma::sigma
Scalar sigma
Definition:
sigma.h:32
impeller::Radius::radius
Scalar radius
Definition:
sigma.h:48
impeller::Scalar
float Scalar
Definition:
scalar.h:15
impeller::Radius::Radius
constexpr Radius(Scalar p_radius)
Definition:
sigma.h:52
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:47
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:31
scalar.h
impeller::kKernelRadiusPerSigma
constexpr static float kKernelRadiusPerSigma
Definition:
sigma.h:23
impeller::Sigma::Sigma
constexpr Sigma(Scalar p_sigma)
Definition:
sigma.h:36
impeller
Definition:
aiks_context.cc:10
impeller
geometry
sigma.h
Generated by
1.8.17