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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "skia/ext/convolver.h" | 8 #include "skia/ext/convolver.h" |
9 #include "skia/ext/convolver_SSE2.h" | 9 #include "skia/ext/convolver_SSE2.h" |
10 #include "skia/ext/convolver_mips_dspr2.h" | 10 #include "skia/ext/convolver_mips_dspr2.h" |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 // This is how many extra pixels may be read by the | 355 // This is how many extra pixels may be read by the |
356 // conolve*horizontally functions. | 356 // conolve*horizontally functions. |
357 int extra_horizontal_reads; | 357 int extra_horizontal_reads; |
358 ConvolveVertically_pointer convolve_vertically; | 358 ConvolveVertically_pointer convolve_vertically; |
359 Convolve4RowsHorizontally_pointer convolve_4rows_horizontally; | 359 Convolve4RowsHorizontally_pointer convolve_4rows_horizontally; |
360 ConvolveHorizontally_pointer convolve_horizontally; | 360 ConvolveHorizontally_pointer convolve_horizontally; |
361 }; | 361 }; |
362 | 362 |
363 void SetupSIMD(ConvolveProcs *procs) { | 363 void SetupSIMD(ConvolveProcs *procs) { |
364 #ifdef SIMD_SSE2 | 364 #ifdef SIMD_SSE2 |
365 base::CPU cpu; | 365 procs->extra_horizontal_reads = 3; |
366 if (cpu.has_sse2()) { | 366 procs->convolve_vertically = &ConvolveVertically_SSE2; |
367 procs->extra_horizontal_reads = 3; | 367 procs->convolve_4rows_horizontally = &Convolve4RowsHorizontally_SSE2; |
368 procs->convolve_vertically = &ConvolveVertically_SSE2; | 368 procs->convolve_horizontally = &ConvolveHorizontally_SSE2; |
369 procs->convolve_4rows_horizontally = &Convolve4RowsHorizontally_SSE2; | |
370 procs->convolve_horizontally = &ConvolveHorizontally_SSE2; | |
371 } | |
372 #elif defined SIMD_MIPS_DSPR2 | 369 #elif defined SIMD_MIPS_DSPR2 |
373 procs->extra_horizontal_reads = 3; | 370 procs->extra_horizontal_reads = 3; |
374 procs->convolve_vertically = &ConvolveVertically_mips_dspr2; | 371 procs->convolve_vertically = &ConvolveVertically_mips_dspr2; |
375 procs->convolve_horizontally = &ConvolveHorizontally_mips_dspr2; | 372 procs->convolve_horizontally = &ConvolveHorizontally_mips_dspr2; |
376 #endif | 373 #endif |
377 } | 374 } |
378 | 375 |
379 void BGRAConvolve2D(const unsigned char* source_data, | 376 void BGRAConvolve2D(const unsigned char* source_data, |
380 int source_byte_row_stride, | 377 int source_byte_row_stride, |
381 bool source_has_alpha, | 378 bool source_has_alpha, |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 float v = sigmasq * kernel_weights[tail_length + ii] / ii; | 704 float v = sigmasq * kernel_weights[tail_length + ii] / ii; |
708 kernel_weights[tail_length + ii] = v; | 705 kernel_weights[tail_length + ii] = v; |
709 kernel_weights[tail_length - ii] = -v; | 706 kernel_weights[tail_length - ii] = -v; |
710 } | 707 } |
711 } | 708 } |
712 | 709 |
713 filter->AddFilter(0, &kernel_weights[0], kernel_weights.size()); | 710 filter->AddFilter(0, &kernel_weights[0], kernel_weights.size()); |
714 } | 711 } |
715 | 712 |
716 } // namespace skia | 713 } // namespace skia |
OLD | NEW |