1/*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkGaussFilter_DEFINED
9#define SkGaussFilter_DEFINED
10
11#include <cstddef>
12
13// Define gaussian filters for values of sigma < 2. Produce values good to 1 part in 1,000,000.
14// Produces values as defined in "Scale-Space for Discrete Signals" by Tony Lindeberg.
15class SkGaussFilter {
16public:
17 static constexpr int kGaussArrayMax = 6;
18
19 explicit SkGaussFilter(double sigma);
20
21 size_t size() const { return fN; }
22 int radius() const { return fN - 1; }
23 int width() const { return 2 * this->radius() + 1; }
24
25 // Allow a filter to be used in a C++ ranged-for loop.
26 const double* begin() const { return &fBasis[0]; }
27 const double* end() const { return &fBasis[fN]; }
28
29private:
30 double fBasis[kGaussArrayMax];
31 int fN;
32};
33
34#endif // SkGaussFilter_DEFINED
35