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 #include <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "skia/ext/convolver.h" | 7 #include "skia/ext/convolver.h" |
8 #include "skia/ext/convolver_SSE2.h" | 8 #include "skia/ext/convolver_SSE2.h" |
9 #include "third_party/skia/include/core/SkTypes.h" | 9 #include "third_party/skia/include/core/SkTypes.h" |
10 | 10 |
11 #include <emmintrin.h> // ARCH_CPU_X86_FAMILY was defined in build/config.h | 11 #include <emmintrin.h> // ARCH_CPU_X86_FAMILY was defined in build/config.h |
12 | 12 |
13 namespace skia { | 13 namespace skia { |
14 | 14 |
15 // Convolves horizontally along a single row. The row data is given in | 15 // Convolves horizontally along a single row. The row data is given in |
16 // |src_data| and continues for the num_values() of the filter. | 16 // |src_data| and continues for the num_values() of the filter. |
17 template<bool has_alpha> | |
Stephen White
2013/05/13 14:08:43
If this function is going to ignore has_alpha anyw
Teodora Novkovic
2013/05/13 16:23:06
Done.
| |
17 void ConvolveHorizontally_SSE2(const unsigned char* src_data, | 18 void ConvolveHorizontally_SSE2(const unsigned char* src_data, |
18 const ConvolutionFilter1D& filter, | 19 const ConvolutionFilter1D& filter, |
19 unsigned char* out_row) { | 20 unsigned char* out_row) { |
20 int num_values = filter.num_values(); | 21 int num_values = filter.num_values(); |
21 | 22 |
22 int filter_offset, filter_length; | 23 int filter_offset, filter_length; |
23 __m128i zero = _mm_setzero_si128(); | 24 __m128i zero = _mm_setzero_si128(); |
24 __m128i mask[4]; | 25 __m128i mask[4]; |
25 // |mask| will be used to decimate all extra filter coefficients that are | 26 // |mask| will be used to decimate all extra filter coefficients that are |
26 // loaded by SIMD when |filter_length| is not divisible by 4. | 27 // loaded by SIMD when |filter_length| is not divisible by 4. |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 out_row); | 447 out_row); |
447 } else { | 448 } else { |
448 ConvolveVertically_SSE2<false>(filter_values, | 449 ConvolveVertically_SSE2<false>(filter_values, |
449 filter_length, | 450 filter_length, |
450 source_data_rows, | 451 source_data_rows, |
451 pixel_width, | 452 pixel_width, |
452 out_row); | 453 out_row); |
453 } | 454 } |
454 } | 455 } |
455 | 456 |
457 void ConvolveHorizontally_SSE2(const unsigned char* src_data, | |
458 const ConvolutionFilter1D& filter, | |
459 unsigned char* out_row, | |
460 bool has_alpha) { | |
461 if (has_alpha) { | |
462 ConvolveHorizontally_SSE2<true>(src_data, | |
463 filter, | |
464 out_row); | |
465 } else { | |
466 ConvolveHorizontally_SSE2<false>(src_data, | |
467 filter, | |
468 out_row); | |
469 } | |
470 } | |
456 } // namespace skia | 471 } // namespace skia |
OLD | NEW |