OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkClampRange_DEFINED | 8 #ifndef SkClampRange_DEFINED |
9 #define SkClampRange_DEFINED | 9 #define SkClampRange_DEFINED |
10 | 10 |
11 #include "SkFixed.h" | 11 #include "SkFixed.h" |
12 #include "SkScalar.h" | 12 #include "SkScalar.h" |
13 | 13 |
14 #ifdef SK_SUPPORT_LEGACY_GRADIENT_PRECISION | 14 #define SkGradFixed SkFixed3232 |
15 #define SkGradFixed SkFixed | 15 #define SkScalarToGradFixed SkScalarToFixed3232 |
16 #define SkScalarToGradFixed SkScalarToFixed | 16 #define SkFixedToGradFixed SkFixedToFixed3232 |
17 #define SkFixedToGradFixed(x) (x) | 17 #define SkGradFixedToFixed(x) (SkFixed)((x) >> 16) |
18 #define SkGradFixedToFixed(x) (x) | 18 #define kFracMax_SkGradFixed 0xFFFFFFFFLL |
19 #define kFracMax_SkGradFixed 0xFFFF | |
20 #else | |
21 #define SkGradFixed SkFixed3232 | |
22 #define SkScalarToGradFixed SkScalarToFixed3232 | |
23 #define SkFixedToGradFixed SkFixedToFixed3232 | |
24 #define SkGradFixedToFixed(x) (SkFixed)((x) >> 16) | |
25 #define kFracMax_SkGradFixed 0xFFFFFFFFLL | |
26 #endif | |
27 | 19 |
28 /** | 20 /** |
29 * Iteration fixed fx by dx, clamping as you go to [0..kFracMax_SkGradFixed], t
his class | 21 * Iteration fixed fx by dx, clamping as you go to [0..kFracMax_SkGradFixed], t
his class |
30 * computes the (up to) 3 spans there are: | 22 * computes the (up to) 3 spans there are: |
31 * | 23 * |
32 * range0: use constant value V0 | 24 * range0: use constant value V0 |
33 * range1: iterate as usual fx += dx | 25 * range1: iterate as usual fx += dx |
34 * range2: use constant value V1 | 26 * range2: use constant value V1 |
35 */ | 27 */ |
36 struct SkClampRange { | 28 struct SkClampRange { |
37 int fCount0; // count for fV0 | 29 int fCount0; // count for fV0 |
38 int fCount1; // count for interpolating (fV0...fV1) | 30 int fCount1; // count for interpolating (fV0...fV1) |
39 int fCount2; // count for fV1 | 31 int fCount2; // count for fV1 |
40 SkGradFixed fFx1; // initial fx value for the fCount1 range. | 32 SkGradFixed fFx1; // initial fx value for the fCount1 range. |
41 // only valid if fCount1 > 0 | 33 // only valid if fCount1 > 0 |
42 int fV0, fV1; | 34 int fV0, fV1; |
43 | 35 |
44 void init(SkGradFixed fx, SkGradFixed dx, int count, int v0, int v1); | 36 void init(SkGradFixed fx, SkGradFixed dx, int count, int v0, int v1); |
45 | 37 |
46 private: | 38 private: |
47 void initFor1(SkGradFixed fx); | 39 void initFor1(SkGradFixed fx); |
48 }; | 40 }; |
49 | 41 |
50 #endif | 42 #endif |
OLD | NEW |