SkGaussFilter.h 938 B

12345678910111213141516171819202122232425262728293031323334
  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. #ifndef SkGaussFilter_DEFINED
  8. #define SkGaussFilter_DEFINED
  9. #include <cstddef>
  10. // Define gaussian filters for values of sigma < 2. Produce values good to 1 part in 1,000,000.
  11. // Produces values as defined in "Scale-Space for Discrete Signals" by Tony Lindeberg.
  12. class SkGaussFilter {
  13. public:
  14. static constexpr int kGaussArrayMax = 6;
  15. explicit SkGaussFilter(double sigma);
  16. size_t size() const { return fN; }
  17. int radius() const { return fN - 1; }
  18. int width() const { return 2 * this->radius() + 1; }
  19. // Allow a filter to be used in a C++ ranged-for loop.
  20. const double* begin() const { return &fBasis[0]; }
  21. const double* end() const { return &fBasis[fN]; }
  22. private:
  23. double fBasis[kGaussArrayMax];
  24. int fN;
  25. };
  26. #endif // SkGaussFilter_DEFINED