OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkBitmapFilter_DEFINED | 10 #ifndef SkBitmapFilter_DEFINED |
11 #define SkBitmapFilter_DEFINED | 11 #define SkBitmapFilter_DEFINED |
12 | 12 |
13 #include "SkMath.h" | 13 #include "SkMath.h" |
14 | 14 |
15 // size of the precomputed bitmap filter tables for high quality filtering. | 15 // size of the precomputed bitmap filter tables for high quality filtering. |
16 // Used to precompute the shape of the filter kernel. | 16 // Used to precompute the shape of the filter kernel. |
17 // Table size chosen from experiments to see where I could start to see a differ
ence. | 17 // Table size chosen from experiments to see where I could start to see a differ
ence. |
18 | 18 |
19 #define SKBITMAP_FILTER_TABLE_SIZE 32 | 19 #define SKBITMAP_FILTER_TABLE_SIZE 128 |
20 | 20 |
21 class SkBitmapFilter { | 21 class SkBitmapFilter { |
22 public: | 22 public: |
23 SkBitmapFilter(float width) | 23 SkBitmapFilter(float width) |
24 : fWidth(width), fInvWidth(1.f/width) { | 24 : fWidth(width), fInvWidth(1.f/width) { |
25 precomputed = false; | 25 precomputed = false; |
26 } | 26 } |
27 | 27 |
28 SkFixed lookup( float x ) const { | 28 SkFixed lookup( float x ) const { |
29 if (!precomputed) { | 29 if (!precomputed) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 float sinc = sk_float_sin(x) / x; | 141 float sinc = sk_float_sin(x) / x; |
142 float lanczos = sk_float_sin(x * tau) / (x * tau); | 142 float lanczos = sk_float_sin(x * tau) / (x * tau); |
143 return sinc * lanczos; | 143 return sinc * lanczos; |
144 } | 144 } |
145 protected: | 145 protected: |
146 float tau; | 146 float tau; |
147 }; | 147 }; |
148 | 148 |
149 | 149 |
150 #endif | 150 #endif |
OLD | NEW |