| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 int* filter_length) const { | 91 int* filter_length) const { |
| 92 const FilterInstance& filter = filters_[value_offset]; | 92 const FilterInstance& filter = filters_[value_offset]; |
| 93 *filter_offset = filter.offset; | 93 *filter_offset = filter.offset; |
| 94 *filter_length = filter.length; | 94 *filter_length = filter.length; |
| 95 if (filter.length == 0) { | 95 if (filter.length == 0) { |
| 96 return NULL; | 96 return NULL; |
| 97 } | 97 } |
| 98 return &filter_values_[filter.data_location]; | 98 return &filter_values_[filter.data_location]; |
| 99 } | 99 } |
| 100 | 100 |
| 101 inline void PaddingForSIMD(int align) { |
| 102 // Padding more coefficients to allow SIMD to load after the last one. |
| 103 // This has to be done after all |AddFilter| calls. |
| 104 for (int i = 0; i < align; ++i) |
| 105 filter_values_.push_back(static_cast<Fixed>(0)); |
| 106 } |
| 107 |
| 101 private: | 108 private: |
| 102 struct FilterInstance { | 109 struct FilterInstance { |
| 103 // Offset within filter_values for this instance of the filter. | 110 // Offset within filter_values for this instance of the filter. |
| 104 int data_location; | 111 int data_location; |
| 105 | 112 |
| 106 // Distance from the left of the filter to the center. IN PIXELS | 113 // Distance from the left of the filter to the center. IN PIXELS |
| 107 int offset; | 114 int offset; |
| 108 | 115 |
| 109 // Number of values in this filter instance. | 116 // Number of values in this filter instance. |
| 110 int length; | 117 int length; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 139 // percent faster if you know the image is opaque. | 146 // percent faster if you know the image is opaque. |
| 140 // | 147 // |
| 141 // The layout in memory is assumed to be 4-bytes per pixel in B-G-R-A order | 148 // The layout in memory is assumed to be 4-bytes per pixel in B-G-R-A order |
| 142 // (this is ARGB when loaded into 32-bit words on a little-endian machine). | 149 // (this is ARGB when loaded into 32-bit words on a little-endian machine). |
| 143 void BGRAConvolve2D(const unsigned char* source_data, | 150 void BGRAConvolve2D(const unsigned char* source_data, |
| 144 int source_byte_row_stride, | 151 int source_byte_row_stride, |
| 145 bool source_has_alpha, | 152 bool source_has_alpha, |
| 146 const ConvolutionFilter1D& xfilter, | 153 const ConvolutionFilter1D& xfilter, |
| 147 const ConvolutionFilter1D& yfilter, | 154 const ConvolutionFilter1D& yfilter, |
| 148 int output_byte_row_stride, | 155 int output_byte_row_stride, |
| 149 unsigned char* output); | 156 unsigned char* output, |
| 157 bool use_sse2 = false); |
| 150 | 158 |
| 151 } // namespace skia | 159 } // namespace skia |
| 152 | 160 |
| 153 #endif // SKIA_EXT_CONVOLVER_H_ | 161 #endif // SKIA_EXT_CONVOLVER_H_ |
| OLD | NEW |