diff options
author | Chris Dalton <csmartdalton@google.com> | 2017-06-20 16:32:59 -0700 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-06-21 05:32:30 +0000 |
commit | 95cf16618a75610f509686a7c6d45e46a734a4e9 (patch) | |
tree | 636ccebf08e66ea96a91993f2c7b54ad53e5435b /samplecode | |
parent | 84cda40bd7e98f4e19574c6e946395e244901408 (diff) |
Fix WavyPathText sample
Bug: skia:
Change-Id: Ic1c370a38a5004afc84cb99734595d350d12e935
Reviewed-on: https://skia-review.googlesource.com/20360
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SamplePathText.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/samplecode/SamplePathText.cpp b/samplecode/SamplePathText.cpp index 023dc6dca1..22a1cd5d2c 100644 --- a/samplecode/SamplePathText.cpp +++ b/samplecode/SamplePathText.cpp @@ -354,12 +354,12 @@ void WavyPathText::Waves::reset(SkRandom& rand, int w, int h) { } SkPoint WavyPathText::Waves::apply(float tsec, const Sk2f matrix[3], const SkPoint& pt) const { - constexpr static int kTableSize = 1 << 12; - static float sin2table[kTableSize]; + constexpr static int kTablePeriod = 1 << 12; + static float sin2table[kTablePeriod + 1]; static SkOnce initTable; initTable([]() { - for (int i = 0; i < kTableSize; ++i) { - const double sintheta = sin(i * (SK_ScalarPI / kTableSize)); + for (int i = 0; i <= kTablePeriod; ++i) { + const double sintheta = sin(i * (SK_ScalarPI / kTablePeriod)); sin2table[i] = static_cast<float>(sintheta * sintheta - 0.5); } }); @@ -376,13 +376,13 @@ SkPoint WavyPathText::Waves::apply(float tsec, const Sk2f matrix[3], const SkPoi const Sk4f t = (frequencies * (dirsX * devicePt[0] + dirsY * devicePt[1]) + speeds * tsec + - offsets).abs() * (float(kTableSize) / float(SK_ScalarPI)); + offsets).abs() * (float(kTablePeriod) / float(SK_ScalarPI)); const Sk4i ipart = SkNx_cast<int>(t); const Sk4f fpart = t - SkNx_cast<float>(ipart); int32_t indices[4]; - (ipart & (kTableSize-1)).store(indices); + (ipart & (kTablePeriod-1)).store(indices); const Sk4f left(sin2table[indices[0]], sin2table[indices[1]], sin2table[indices[2]], sin2table[indices[3]]); |