summaryrefslogtreecommitdiffstats
path: root/gfx/skia/skia/src/core/SkGaussFilter.h
blob: 11ff4a85e826a491713c33409a73388bea32a960 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkGaussFilter_DEFINED
#define SkGaussFilter_DEFINED

#include <cstddef>

// Define gaussian filters for values of sigma < 2. Produce values good to 1 part in 1,000,000.
// Produces values as defined in "Scale-Space for Discrete Signals" by Tony Lindeberg.
class SkGaussFilter {
public:
    inline static constexpr int kGaussArrayMax = 6;

    explicit SkGaussFilter(double sigma);

    size_t size()   const { return fN; }
    int radius() const { return fN - 1; }
    int width()  const { return 2 * this->radius() + 1; }

    // Allow a filter to be used in a C++ ranged-for loop.
    const double* begin() const { return &fBasis[0];  }
    const double* end()   const { return &fBasis[fN]; }

private:
    double fBasis[kGaussArrayMax];
    int    fN;
};

#endif  // SkGaussFilter_DEFINED