diff options
author | Herb Derby <herb@google.com> | 2017-11-09 22:39:51 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-09 22:39:57 +0000 |
commit | 66918078bb373e28e381cab51409e789fe521315 (patch) | |
tree | d557529bf5d905bfa707ab29c17284365af454c9 /tests/SkGaussFilterTest.cpp | |
parent | 77e487dfc005be66346ebf3e33d3ec394de4cc36 (diff) |
Revert "Gauss filter calculation"
This reverts commit 53ec7dc7cb523f220a9f5cd713b241c706779c81.
Reason for revert: Segv on very specific machines.
Original change's description:
> Gauss filter calculation
>
> Change-Id: I921ef815d4f788c312aa729f353b6ea154140555
> Reviewed-on: https://skia-review.googlesource.com/67723
> Commit-Queue: Herb Derby <herb@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
TBR=herb@google.com,robertphillips@google.com
Change-Id: I15164809d081dee0076e815b40fbfdbc6374cfba
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/69641
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'tests/SkGaussFilterTest.cpp')
-rw-r--r-- | tests/SkGaussFilterTest.cpp | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/tests/SkGaussFilterTest.cpp b/tests/SkGaussFilterTest.cpp deleted file mode 100644 index 958e811ce5..0000000000 --- a/tests/SkGaussFilterTest.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2017 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "SkGaussFilter.h" - -#include <cmath> -#include <tuple> -#include <vector> -#include "Test.h" - -// one part in a million -static constexpr double kEpsilon = 0.000001; - -static double careful_add(int n, double* gauss) { - // Sum smallest to largest to retain precision. - double sum = 0; - for (int i = n - 1; i >= 1; i--) { - sum += 2.0 * gauss[i]; - } - sum += gauss[0]; - return sum; -} - -DEF_TEST(SkGaussFilterCommon, r) { - using Test = std::tuple<double, SkGaussFilter::Type, std::vector<double>>; - - auto golden_check = [&](const Test& test) { - double sigma; SkGaussFilter::Type type; std::vector<double> golden; - std::tie(sigma, type, golden) = test; - SkGaussFilter filter{sigma, type}; - double result[5]; - size_t n = filter.filterDouble(result); - REPORTER_ASSERT(r, n == golden.size()); - double sum = careful_add(n, result); - REPORTER_ASSERT(r, sum == 1.0); - for (size_t i = 0; i < golden.size(); i++) { - REPORTER_ASSERT(r, std::abs(golden[i] - result[i]) < kEpsilon); - } - }; - - // The following two sigmas account for about 85% of all sigmas used for masks. - // Golden values generated using Mathematica. - auto tests = { - // 0.788675 - most common mask sigma. - // GaussianMatrix[{{Automatic}, {.788675}}, Method -> "Gaussian"] - Test{0.788675, SkGaussFilter::Type::Gaussian, {0.506205, 0.226579, 0.0203189}}, - - // GaussianMatrix[{{Automatic}, {.788675}}] - Test{0.788675, SkGaussFilter::Type::Bessel, {0.593605, 0.176225, 0.0269721}}, - - // 1.07735 - second most common mask sigma. - // GaussianMatrix[{{Automatic}, {1.07735}}, Method -> "Gaussian"] - Test{1.07735, SkGaussFilter::Type::Gaussian, {0.376362, 0.244636, 0.0671835}}, - - // GaussianMatrix[{{4}, {1.07735}}, Method -> "Bessel"] - Test{1.07735, SkGaussFilter::Type::Bessel, {0.429537, 0.214955, 0.059143, 0.0111337}}, - }; - - for (auto& test : tests) { - golden_check(test); - } -} - -DEF_TEST(SkGaussFilterSweep, r) { - // The double just before 2.0. - const double maxSigma = nextafter(2.0, 0.0); - for (auto type : {SkGaussFilter::Type::Gaussian, SkGaussFilter::Type::Bessel}) { - - auto check = [&](double sigma) { - SkGaussFilter filter{sigma, type}; - double result[5]; - int n = filter.filterDouble(result); - REPORTER_ASSERT(r, n <= 5); - double sum = careful_add(n, result); - REPORTER_ASSERT(r, sum == 1.0); - }; - - for (double sigma = 0.0; sigma < 2.0; sigma += 0.1) { - check(sigma); - } - - check(maxSigma); - } -} |