OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "Sk4fLinearGradient.h" | 8 #include "Sk4fLinearGradient.h" |
9 #include "SkLinearGradient.h" | 9 #include "SkLinearGradient.h" |
10 | 10 |
11 // define to test the 4f gradient path | 11 // define to test the 4f gradient path |
12 // #define FORCE_4F_CONTEXT | 12 // #define FORCE_4F_CONTEXT |
13 | 13 |
14 static const float kInv255Float = 1.0f / 255; | 14 static const float kInv255Float = 1.0f / 255; |
15 | 15 |
16 static inline int repeat_8bits(int x) { | 16 static inline int repeat_8bits(int x) { |
17 return x & 0xFF; | 17 return x & 0xFF; |
18 } | 18 } |
19 | 19 |
20 // Visual Studio 2010 (MSC_VER=1600) optimizes bit-shift code incorrectly. | |
21 // See http://code.google.com/p/skia/issues/detail?id=472 | |
22 #if defined(_MSC_VER) && (_MSC_VER >= 1600) | |
mtklein
2016/03/10 17:37:48
ditto
| |
23 #pragma optimize("", off) | |
24 #endif | |
25 | |
26 static inline int mirror_8bits(int x) { | 20 static inline int mirror_8bits(int x) { |
27 if (x & 256) { | 21 if (x & 256) { |
28 x = ~x; | 22 x = ~x; |
29 } | 23 } |
30 return x & 255; | 24 return x & 255; |
31 } | 25 } |
32 | 26 |
33 #if defined(_MSC_VER) && (_MSC_VER >= 1600) | |
34 #pragma optimize("", on) | |
35 #endif | |
36 | |
37 static SkMatrix pts_to_unit_matrix(const SkPoint pts[2]) { | 27 static SkMatrix pts_to_unit_matrix(const SkPoint pts[2]) { |
38 SkVector vec = pts[1] - pts[0]; | 28 SkVector vec = pts[1] - pts[0]; |
39 SkScalar mag = vec.length(); | 29 SkScalar mag = vec.length(); |
40 SkScalar inv = mag ? SkScalarInvert(mag) : 0; | 30 SkScalar inv = mag ? SkScalarInvert(mag) : 0; |
41 | 31 |
42 vec.scale(inv); | 32 vec.scale(inv); |
43 SkMatrix matrix; | 33 SkMatrix matrix; |
44 matrix.setSinCos(-vec.fY, vec.fX, pts[0].fX, pts[0].fY); | 34 matrix.setSinCos(-vec.fY, vec.fX, pts[0].fX, pts[0].fY); |
45 matrix.postTranslate(-pts[0].fX, -pts[0].fY); | 35 matrix.postTranslate(-pts[0].fX, -pts[0].fY); |
46 matrix.postScale(inv, inv); | 36 matrix.postScale(inv, inv); |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
760 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe r); | 750 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe r); |
761 } | 751 } |
762 } else { | 752 } else { |
763 if (fApplyAlphaAfterInterp) { | 753 if (fApplyAlphaAfterInterp) { |
764 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe r); | 754 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe r); |
765 } else { | 755 } else { |
766 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith er); | 756 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith er); |
767 } | 757 } |
768 } | 758 } |
769 } | 759 } |
OLD | NEW |