Chromium Code Reviews| Index: skia/ext/convolver.h |
| =================================================================== |
| --- skia/ext/convolver.h (revision 71667) |
| +++ skia/ext/convolver.h (working copy) |
| @@ -6,11 +6,13 @@ |
| #define SKIA_EXT_CONVOLVER_H_ |
| #pragma once |
| +#include <cmath> |
| #include <vector> |
| // avoid confusion with Mac OS X's math library (Carbon) |
| #if defined(__APPLE__) |
| #undef FloatToFixed |
| +#undef FixedToFloat |
| #endif |
| namespace skia { |
| @@ -40,6 +42,13 @@ |
| static unsigned char FixedToChar(Fixed x) { |
| return static_cast<unsigned char>(x >> kShiftBits); |
| } |
| + static float FixedToFloat(Fixed x) { |
| + // The cast relies on Fixed being a short, implying that on |
| + // the platforms we care about all (16) bits will fit into |
| + // the mantissa of a (32-bit) float. |
|
brettw
2011/01/20 21:48:06
How about adding a COMPILE_ASSERT(sizeof(Fixed) ==
evannier
2011/01/24 21:09:58
Done.
|
| + float raw = static_cast<float>(x); |
| + return ldexpf(raw, -kShiftBits); |
| + } |
| // Returns the maximum pixel span of a filter. |
| int max_filter() const { return max_filter_; } |
| @@ -80,7 +89,11 @@ |
| const FilterInstance& filter = filters_[value_offset]; |
| *filter_offset = filter.offset; |
| *filter_length = filter.length; |
| - return &filter_values_[filter.data_location]; |
| + if (filter.length == 0) { |
| + return NULL; |
| + } else { |
|
brettw
2011/01/20 21:48:06
We generally discourage an else after a return, so
evannier
2011/01/24 21:09:58
Done.
|
| + return &filter_values_[filter.data_location]; |
| + } |
| } |
| private: |
| @@ -130,9 +143,9 @@ |
| bool source_has_alpha, |
| const ConvolutionFilter1D& xfilter, |
| const ConvolutionFilter1D& yfilter, |
| + int output_byte_row_stride, |
| unsigned char* output); |
| } // namespace skia |
| #endif // SKIA_EXT_CONVOLVER_H_ |
| - |