OLD | NEW |
---|---|
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #ifndef SkClampRange_DEFINED | 8 #ifndef SkClampRange_DEFINED |
11 #define SkClampRange_DEFINED | 9 #define SkClampRange_DEFINED |
12 | 10 |
13 #include "SkFixed.h" | 11 #include "SkFixed.h" |
12 #include "SkScalar.h" | |
13 | |
14 #define SK_SUPPORT_LEGACY_GRADIENT_PRECISION | |
15 | |
16 typedef int64_t SkF32Dot32; | |
caryclark
2014/12/18 19:40:56
is this different from SkFixed3232 ?
reed1
2014/12/18 20:17:49
Done.
| |
17 | |
18 static inline SkF32Dot32 SkFixedToF32Dot32(SkFixed value) { | |
caryclark
2014/12/18 19:40:56
looks like SkFixedToFixed3232 ?
reed1
2014/12/18 20:17:49
Done.
| |
19 SkF32Dot32 value32 = value; | |
20 return value32 << 16; | |
21 } | |
22 | |
23 static inline SkF32Dot32 SkScalarToF32Dot32(SkScalar x) { | |
caryclark
2014/12/18 19:40:56
looks like SkFloatToFixed3232 ?
reed1
2014/12/18 20:17:49
Done.
| |
24 return (SkF32Dot32)(x * (1LL << 32)); | |
25 } | |
26 | |
27 #ifdef SK_SUPPORT_LEGACY_GRADIENT_PRECISION | |
28 #define SkGradFixed SkFixed | |
29 #define SkScalarToGradFixed SkScalarToFixed | |
30 #define SkFixedToGradFixed(x) (x) | |
31 #define SkGradFixedToFixed(x) (x) | |
32 #define kFracMax_SkGradFixed 0xFFFF | |
33 #else | |
34 #define SkGradFixed SkF32Dot32 | |
35 #define SkScalarToGradFixed SkScalarToF32Dot32 | |
36 #define SkFixedToGradFixed SkFixedToF32Dot32 | |
37 #define SkGradFixedToFixed(x) (SkFixed)((x) >> 16) | |
38 #define kFracMax_SkGradFixed 0xFFFFFFFFLL | |
39 #endif | |
14 | 40 |
15 /** | 41 /** |
16 * Iteration fixed fx by dx, clamping as you go to [0..0xFFFF], this class | 42 * Iteration fixed fx by dx, clamping as you go to [0..kFracMax_SkGradFixed], t his class |
17 * computes the (up to) 3 spans there are: | 43 * computes the (up to) 3 spans there are: |
18 * | 44 * |
19 * range0: use constant value V0 | 45 * range0: use constant value V0 |
20 * range1: iterate as usual fx += dx | 46 * range1: iterate as usual fx += dx |
21 * range2: use constant value V1 | 47 * range2: use constant value V1 |
22 */ | 48 */ |
23 struct SkClampRange { | 49 struct SkClampRange { |
24 int fCount0; // count for fV0 | 50 int fCount0; // count for fV0 |
25 int fCount1; // count for interpolating (fV0...fV1) | 51 int fCount1; // count for interpolating (fV0...fV1) |
26 int fCount2; // count for fV1 | 52 int fCount2; // count for fV1 |
27 SkFixed fFx1; // initial fx value for the fCount1 range. | 53 SkGradFixed fFx1; // initial fx value for the fCount1 range. |
28 // only valid if fCount1 > 0 | 54 // only valid if fCount1 > 0 |
29 int fV0, fV1; | 55 int fV0, fV1; |
30 | 56 |
31 void init(SkFixed fx, SkFixed dx, int count, int v0, int v1); | 57 void init(SkGradFixed fx, SkGradFixed dx, int count, int v0, int v1); |
32 | 58 |
33 private: | 59 private: |
34 void initFor1(SkFixed fx); | 60 void initFor1(SkGradFixed fx); |
35 }; | 61 }; |
36 | 62 |
37 #endif | 63 #endif |
OLD | NEW |