| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SKIA_EXT_CONVOLVER_H_ | 5 #ifndef SKIA_EXT_CONVOLVER_H_ |
| 6 #define SKIA_EXT_CONVOLVER_H_ | 6 #define SKIA_EXT_CONVOLVER_H_ |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 static Fixed FloatToFixed(float f) { | 53 static Fixed FloatToFixed(float f) { |
| 54 return static_cast<Fixed>(f * (1 << kShiftBits)); | 54 return static_cast<Fixed>(f * (1 << kShiftBits)); |
| 55 } | 55 } |
| 56 static unsigned char FixedToChar(Fixed x) { | 56 static unsigned char FixedToChar(Fixed x) { |
| 57 return static_cast<unsigned char>(x >> kShiftBits); | 57 return static_cast<unsigned char>(x >> kShiftBits); |
| 58 } | 58 } |
| 59 static float FixedToFloat(Fixed x) { | 59 static float FixedToFloat(Fixed x) { |
| 60 // The cast relies on Fixed being a short, implying that on | 60 // The cast relies on Fixed being a short, implying that on |
| 61 // the platforms we care about all (16) bits will fit into | 61 // the platforms we care about all (16) bits will fit into |
| 62 // the mantissa of a (32-bit) float. | 62 // the mantissa of a (32-bit) float. |
| 63 COMPILE_ASSERT(sizeof(Fixed) == 2, fixed_type_should_fit_in_float_mantissa); | 63 static_assert(sizeof(Fixed) == 2, |
| 64 "fixed type should fit in float mantissa"); |
| 64 float raw = static_cast<float>(x); | 65 float raw = static_cast<float>(x); |
| 65 return ldexpf(raw, -kShiftBits); | 66 return ldexpf(raw, -kShiftBits); |
| 66 } | 67 } |
| 67 | 68 |
| 68 // Returns the maximum pixel span of a filter. | 69 // Returns the maximum pixel span of a filter. |
| 69 int max_filter() const { return max_filter_; } | 70 int max_filter() const { return max_filter_; } |
| 70 | 71 |
| 71 // Returns the number of filters in this filter. This is the dimension of the | 72 // Returns the number of filters in this filter. This is the dimension of the |
| 72 // output image. | 73 // output image. |
| 73 int num_values() const { return static_cast<int>(filters_.size()); } | 74 int num_values() const { return static_cast<int>(filters_.size()); } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 // Set up the |filter| instance with a gaussian kernel. |kernel_sigma| is the | 226 // Set up the |filter| instance with a gaussian kernel. |kernel_sigma| is the |
| 226 // parameter of gaussian. If |derivative| is true, the kernel will be that of | 227 // parameter of gaussian. If |derivative| is true, the kernel will be that of |
| 227 // the first derivative. Intended for use with the two routines above. | 228 // the first derivative. Intended for use with the two routines above. |
| 228 SK_API void SetUpGaussianConvolutionKernel(ConvolutionFilter1D* filter, | 229 SK_API void SetUpGaussianConvolutionKernel(ConvolutionFilter1D* filter, |
| 229 float kernel_sigma, | 230 float kernel_sigma, |
| 230 bool derivative); | 231 bool derivative); |
| 231 | 232 |
| 232 } // namespace skia | 233 } // namespace skia |
| 233 | 234 |
| 234 #endif // SKIA_EXT_CONVOLVER_H_ | 235 #endif // SKIA_EXT_CONVOLVER_H_ |
| OLD | NEW |