Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/cpu.h" | |
| 13 | 14 |
| 14 // avoid confusion with Mac OS X's math library (Carbon) | 15 // avoid confusion with Mac OS X's math library (Carbon) |
| 15 #if defined(__APPLE__) | 16 #if defined(__APPLE__) |
| 16 #undef FloatToFixed | 17 #undef FloatToFixed |
| 17 #undef FixedToFloat | 18 #undef FixedToFloat |
| 18 #endif | 19 #endif |
| 19 | 20 |
| 20 namespace skia { | 21 namespace skia { |
| 21 | 22 |
| 22 // Represents a filter in one dimension. Each output pixel has one entry in this | 23 // Represents a filter in one dimension. Each output pixel has one entry in this |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 int* filter_length) const { | 92 int* filter_length) const { |
| 92 const FilterInstance& filter = filters_[value_offset]; | 93 const FilterInstance& filter = filters_[value_offset]; |
| 93 *filter_offset = filter.offset; | 94 *filter_offset = filter.offset; |
| 94 *filter_length = filter.length; | 95 *filter_length = filter.length; |
| 95 if (filter.length == 0) { | 96 if (filter.length == 0) { |
| 96 return NULL; | 97 return NULL; |
| 97 } | 98 } |
| 98 return &filter_values_[filter.data_location]; | 99 return &filter_values_[filter.data_location]; |
| 99 } | 100 } |
| 100 | 101 |
| 102 inline void PaddingForSIMD(int align) { | |
|
brettw
2011/02/21 04:45:45
I would have thought that you'd want to pad up to
jiesun
2011/02/22 21:37:03
padding in SIMD serve two purpose:
1. make element
| |
| 103 // Padding more coefficients to allow SIMD to load after the last one. | |
| 104 // This has to be done after all |AddFilter| calls. | |
| 105 for (int i = 0; i < align; ++i) | |
| 106 filter_values_.push_back(static_cast<Fixed>(0)); | |
| 107 } | |
| 108 | |
| 101 private: | 109 private: |
| 102 struct FilterInstance { | 110 struct FilterInstance { |
| 103 // Offset within filter_values for this instance of the filter. | 111 // Offset within filter_values for this instance of the filter. |
| 104 int data_location; | 112 int data_location; |
| 105 | 113 |
| 106 // Distance from the left of the filter to the center. IN PIXELS | 114 // Distance from the left of the filter to the center. IN PIXELS |
| 107 int offset; | 115 int offset; |
| 108 | 116 |
| 109 // Number of values in this filter instance. | 117 // Number of values in this filter instance. |
| 110 int length; | 118 int length; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 141 // The layout in memory is assumed to be 4-bytes per pixel in B-G-R-A order | 149 // 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). | 150 // (this is ARGB when loaded into 32-bit words on a little-endian machine). |
| 143 void BGRAConvolve2D(const unsigned char* source_data, | 151 void BGRAConvolve2D(const unsigned char* source_data, |
| 144 int source_byte_row_stride, | 152 int source_byte_row_stride, |
| 145 bool source_has_alpha, | 153 bool source_has_alpha, |
| 146 const ConvolutionFilter1D& xfilter, | 154 const ConvolutionFilter1D& xfilter, |
| 147 const ConvolutionFilter1D& yfilter, | 155 const ConvolutionFilter1D& yfilter, |
| 148 int output_byte_row_stride, | 156 int output_byte_row_stride, |
| 149 unsigned char* output); | 157 unsigned char* output); |
| 150 | 158 |
| 159 void BGRAConvolve2D_C(const unsigned char* source_data, | |
| 160 int source_byte_row_stride, | |
|
brettw
2011/02/21 04:45:45
Style: be sure to align the args in these two func
jiesun
2011/02/22 21:37:03
Done.
| |
| 161 bool source_has_alpha, | |
| 162 const ConvolutionFilter1D& filter_x, | |
| 163 const ConvolutionFilter1D& filter_y, | |
| 164 int output_byte_row_stride, | |
| 165 unsigned char* output); | |
| 166 | |
| 167 void BGRAConvolve2D_SSE2(const unsigned char* source_data, | |
| 168 int source_byte_row_stride, | |
| 169 bool source_has_alpha, | |
| 170 const ConvolutionFilter1D& filter_x, | |
| 171 const ConvolutionFilter1D& filter_y, | |
| 172 int output_byte_row_stride, | |
| 173 unsigned char* output); | |
| 151 } // namespace skia | 174 } // namespace skia |
| 152 | 175 |
| 153 #endif // SKIA_EXT_CONVOLVER_H_ | 176 #endif // SKIA_EXT_CONVOLVER_H_ |
| OLD | NEW |