OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkBitmapFilter_DEFINED | 8 #ifndef SkBitmapFilter_DEFINED |
9 #define SkBitmapFilter_DEFINED | 9 #define SkBitmapFilter_DEFINED |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 for (int index = 0; index < count; index++) { | 58 for (int index = 0; index < count; index++) { |
59 float filterValue = evaluate(val); | 59 float filterValue = evaluate(val); |
60 *output++ = filterValue; | 60 *output++ = filterValue; |
61 sum += filterValue; | 61 sum += filterValue; |
62 val += diff; | 62 val += diff; |
63 } | 63 } |
64 return sum; | 64 return sum; |
65 } | 65 } |
66 #endif | 66 #endif |
67 | 67 |
68 static SkBitmapFilter* Allocate(); | |
69 | |
70 protected: | 68 protected: |
71 float fWidth; | 69 float fWidth; |
72 float fInvWidth; | 70 float fInvWidth; |
73 float fLookupMultiplier; | 71 float fLookupMultiplier; |
74 | 72 |
75 mutable bool fPrecomputed; | 73 mutable bool fPrecomputed; |
76 mutable SkFixed fFilterTable[SKBITMAP_FILTER_TABLE_SIZE]; | 74 mutable SkFixed fFilterTable[SKBITMAP_FILTER_TABLE_SIZE]; |
77 mutable SkScalar fFilterTableScalar[SKBITMAP_FILTER_TABLE_SIZE]; | 75 mutable SkScalar fFilterTableScalar[SKBITMAP_FILTER_TABLE_SIZE]; |
78 | 76 |
79 private: | 77 private: |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 return 1.0f; // Special case the discontinuity at the origin. | 243 return 1.0f; // Special case the discontinuity at the origin. |
246 } | 244 } |
247 float xpi = x * static_cast<float>(SK_ScalarPI); | 245 float xpi = x * static_cast<float>(SK_ScalarPI); |
248 return (sk_float_sin(xpi) / xpi) * // sinc(x) | 246 return (sk_float_sin(xpi) / xpi) * // sinc(x) |
249 sk_float_sin(xpi / fWidth) / (xpi / fWidth); // sinc(x/fWidth) | 247 sk_float_sin(xpi / fWidth) / (xpi / fWidth); // sinc(x/fWidth) |
250 } | 248 } |
251 }; | 249 }; |
252 | 250 |
253 | 251 |
254 #endif | 252 #endif |
OLD | NEW |