diff options
author | Herb Derby <herb@google.com> | 2017-11-16 14:38:57 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-17 19:10:16 +0000 |
commit | 7ceb0b89f4030a13421ce28b2da1573c6846cf90 (patch) | |
tree | 2bf3686248e8e539bc282ba8ab200ac67d6d1ae2 /src/core | |
parent | 28db288ec26bf01e203183acffb4cbd683de322f (diff) |
Remove api call from SkGaussFilter
Simplify the SkGaussFilter API to facilitate using
ranged-for loops.
Change-Id: Id853bd6bfe342ae95b7c6248c459fbf865f75d1e
Reviewed-on: https://skia-review.googlesource.com/73262
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkGaussFilter.cpp | 7 | ||||
-rw-r--r-- | src/core/SkGaussFilter.h | 16 | ||||
-rw-r--r-- | src/core/SkMaskBlurFilter.cpp | 4 |
3 files changed, 7 insertions, 20 deletions
diff --git a/src/core/SkGaussFilter.cpp b/src/core/SkGaussFilter.cpp index c0d612ddec..5bbdc05f43 100644 --- a/src/core/SkGaussFilter.cpp +++ b/src/core/SkGaussFilter.cpp @@ -142,10 +142,3 @@ SkGaussFilter::SkGaussFilter(double sigma, Type type) { fN = calculate_gauss_factors(sigma, fBasis); } } - -int SkGaussFilter::filterDouble(double values[5]) const { - for (int i = 0; i < fN; i++) { - values[i] = fBasis[i]; - } - return fN; -} diff --git a/src/core/SkGaussFilter.h b/src/core/SkGaussFilter.h index be00cf2cc0..8ad0831e9f 100644 --- a/src/core/SkGaussFilter.h +++ b/src/core/SkGaussFilter.h @@ -8,7 +8,7 @@ #ifndef SkGaussFilter_DEFINED #define SkGaussFilter_DEFINED -#include <cstdint> +#include <cstddef> // Define gaussian filters for values of sigma < 2. Produce values good to 1 part in 1,000,000. // Gaussian produces values as defined in the SVG 1.1 spec: @@ -16,6 +16,7 @@ // Bessel produces values as defined in "Scale-Space for Discrete Signals" by Tony Lindeberg class SkGaussFilter { public: + static constexpr int kGaussArrayMax = 5; enum class Type : bool { Gaussian, Bessel @@ -24,24 +25,17 @@ public: // Type selects which method is used to calculate the gaussian factors. SkGaussFilter(double sigma, Type type); + size_t size() const { return fN; } int radius() const { return fN - 1; } - int width() const { return 2 * this->radius() + 1; } - - // TODO: remove filterDouble and use the ranged-for loop interface. - - // Take an array of values where the gaussian factors will be placed. Return the number of - // values filled. - int filterDouble(double values[5]) const; + 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[5]; + double fBasis[kGaussArrayMax]; int fN; }; #endif // SkGaussFilter_DEFINED - - diff --git a/src/core/SkMaskBlurFilter.cpp b/src/core/SkMaskBlurFilter.cpp index 9de68fcedc..dac21ee60c 100644 --- a/src/core/SkMaskBlurFilter.cpp +++ b/src/core/SkMaskBlurFilter.cpp @@ -1159,8 +1159,8 @@ static SkIPoint small_blur(double sigmaX, double sigmaY, const SkMask& src, SkMa } }; - uint16_t gaussFactorsX[5], - gaussFactorsY[5]; + uint16_t gaussFactorsX[SkGaussFilter::kGaussArrayMax], + gaussFactorsY[SkGaussFilter::kGaussArrayMax]; prepareGauss(filterX, gaussFactorsX); prepareGauss(filterY, gaussFactorsY); |