| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| mike@reedtribe.org | 676d69b | 2011-04-15 03:43:23 +0000 | [diff] [blame] | 2 | /* |
| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| mike@reedtribe.org | 676d69b | 2011-04-15 03:43:23 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
| mike@reedtribe.org | 676d69b | 2011-04-15 03:43:23 +0000 | [diff] [blame] | 10 | #ifndef SkClampRange_DEFINED |
| 11 | #define SkClampRange_DEFINED |
| 12 | |
| 13 | #include "SkFixed.h" |
| 14 | |
| 15 | /** |
| 16 | * Iteration fixed fx by dx, clamping as you go to [0..0xFFFF], this class |
| 17 | * computes the (up to) 3 spans there are: |
| 18 | * |
| 19 | * range0: use constant value V0 |
| 20 | * range1: iterate as usual fx += dx |
| 21 | * range2: use constant value V1 |
| 22 | */ |
| 23 | struct SkClampRange { |
| 24 | int fCount0; // count for fV0 |
| 25 | int fCount1; // count for interpolating (fV0...fV1) |
| 26 | int fCount2; // count for fV1 |
| reed@google.com | 63c1ad8 | 2011-04-18 14:15:36 +0000 | [diff] [blame] | 27 | SkFixed fFx1; // initial fx value for the fCount1 range. |
| 28 | // only valid if fCount1 > 0 |
| mike@reedtribe.org | 676d69b | 2011-04-15 03:43:23 +0000 | [diff] [blame] | 29 | int fV0, fV1; |
| reed@google.com | 63c1ad8 | 2011-04-18 14:15:36 +0000 | [diff] [blame] | 30 | bool fOverflowed; // true if we had to clamp due to numerical overflow |
| mike@reedtribe.org | 676d69b | 2011-04-15 03:43:23 +0000 | [diff] [blame] | 31 | |
| 32 | void init(SkFixed fx, SkFixed dx, int count, int v0, int v1); |
| reed@google.com | 13659f1 | 2011-04-18 19:59:38 +0000 | [diff] [blame] | 33 | |
| 34 | private: |
| 35 | void initFor1(SkFixed fx); |
| mike@reedtribe.org | 676d69b | 2011-04-15 03:43:23 +0000 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | #endif |