Index: skia/ext/convolver.h |
diff --git a/skia/ext/convolver.h b/skia/ext/convolver.h |
index 04d6fe5c52db2e05218b8973c5e90b944e0b5d8f..6208053c08824af13d5483dae4a3ac3fd05db1ce 100644 |
--- a/skia/ext/convolver.h |
+++ b/skia/ext/convolver.h |
@@ -10,6 +10,7 @@ |
#include <vector> |
#include "base/basictypes.h" |
+#include "base/cpu.h" |
// avoid confusion with Mac OS X's math library (Carbon) |
#if defined(__APPLE__) |
@@ -98,6 +99,17 @@ class ConvolutionFilter1D { |
return &filter_values_[filter.data_location]; |
} |
+ |
+ inline void PaddingForSIMD(int padding_count) { |
+ // Padding |padding_count| of more dummy coefficients after the coefficients |
+ // of last filter to prevent SIMD instructions which load 8 or 16 bytes |
+ // together to access invalid memory areas. We are not trying to align the |
+ // coefficients right now due to the opaqueness of <vector> implementation. |
+ // This has to be done after all |AddFilter| calls. |
+ for (int i = 0; i < padding_count; ++i) |
+ filter_values_.push_back(static_cast<Fixed>(0)); |
+ } |
+ |
private: |
struct FilterInstance { |
// Offset within filter_values for this instance of the filter. |
@@ -146,8 +158,8 @@ void BGRAConvolve2D(const unsigned char* source_data, |
const ConvolutionFilter1D& xfilter, |
const ConvolutionFilter1D& yfilter, |
int output_byte_row_stride, |
- unsigned char* output); |
- |
+ unsigned char* output, |
+ bool use_sse2); |
} // namespace skia |
#endif // SKIA_EXT_CONVOLVER_H_ |