| 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 "SkConvolver.h" | 5 #include "SkConvolver.h" |
| 6 #include "SkTArray.h" | 6 #include "SkTArray.h" |
| 7 | 7 |
| 8 namespace { | 8 namespace { |
| 9 | 9 |
| 10 // Converts the argument to an 8-bit unsigned value by clamping to the range | 10 // Converts the argument to an 8-bit unsigned value by clamping to the range |
| 11 // 0-255. | 11 // 0-255. |
| 12 inline unsigned char ClampTo8(int a) { | 12 inline unsigned char ClampTo8(int a) { |
| 13 if (static_cast<unsigned>(a) < 256) { | 13 if (static_cast<unsigned>(a) < 256) { |
| 14 return a; // Avoid the extra check in the common case. | 14 return a; // Avoid the extra check in the common case. |
| 15 } | 15 } |
| 16 if (a < 0) { | |
| 17 return 0; | |
| 18 } | |
| 19 return 255; | 16 return 255; |
| 20 } | 17 } |
| 21 | 18 |
| 22 // Stores a list of rows in a circular buffer. The usage is you write into i
t | 19 // Stores a list of rows in a circular buffer. The usage is you write into i
t |
| 23 // by calling AdvanceRow. It will keep track of which row in the buffer it | 20 // by calling AdvanceRow. It will keep track of which row in the buffer it |
| 24 // should use next, and the total number of rows added. | 21 // should use next, and the total number of rows added. |
| 25 class CircularRowBuffer { | 22 class CircularRowBuffer { |
| 26 public: | 23 public: |
| 27 // The number of pixels in each row is given in |sourceRowPixelWidth|. | 24 // The number of pixels in each row is given in |sourceRowPixelWidth|. |
| 28 // The maximum number of rows needed in the buffer is |maxYFilterSize| | 25 // The maximum number of rows needed in the buffer is |maxYFilterSize| |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 sourceHasAlpha); | 474 sourceHasAlpha); |
| 478 } else { | 475 } else { |
| 479 ConvolveVertically(filterValues, filterLength, | 476 ConvolveVertically(filterValues, filterLength, |
| 480 firstRowForFilter, | 477 firstRowForFilter, |
| 481 filterX.numValues(), curOutputRow, | 478 filterX.numValues(), curOutputRow, |
| 482 sourceHasAlpha); | 479 sourceHasAlpha); |
| 483 } | 480 } |
| 484 } | 481 } |
| 485 return true; | 482 return true; |
| 486 } | 483 } |
| OLD | NEW |