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 #include "SkAntiEdge.h" | 7 #include "SkAntiEdge.h" |
8 #include "SkPoint.h" | 8 #include "SkPoint.h" |
9 | 9 |
10 /** Returns the signed fraction of a SkFixed | |
11 */ | |
12 static inline SkFixed SkFixedFraction(SkFixed x) | |
13 { | |
14 SkFixed mask = x >> 31 << 16; | |
15 return (x & 0xFFFF) | mask; | |
16 } | |
caryclark
2013/12/19 13:56:57
alternatives --
- let experimental/Intersection
| |
17 | |
10 void SkAntiEdge::pointOnLine(SkFixed x, SkFixed y) { | 18 void SkAntiEdge::pointOnLine(SkFixed x, SkFixed y) { |
11 float x0 = SkFixedToFloat(x); | 19 float x0 = SkFixedToFloat(x); |
12 float y0 = SkFixedToFloat(y); | 20 float y0 = SkFixedToFloat(y); |
13 float x1 = SkFixedToFloat(fFirstX); | 21 float x1 = SkFixedToFloat(fFirstX); |
14 float y1 = SkFixedToFloat(fFirstY); | 22 float y1 = SkFixedToFloat(fFirstY); |
15 float x2 = SkFixedToFloat(fLastX); | 23 float x2 = SkFixedToFloat(fLastX); |
16 float y2 = SkFixedToFloat(fLastY); | 24 float y2 = SkFixedToFloat(fLastY); |
17 float numer = (x2 - x1) * (y1 - y0) - (x1 - x0) * (y2 - y1); | 25 float numer = (x2 - x1) * (y1 - y0) - (x1 - x0) * (y2 - y1); |
18 float denom = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1); | 26 float denom = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1); |
19 double dist = fabs(numer) / sqrt(denom); | 27 double dist = fabs(numer) / sqrt(denom); |
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1069 #else | 1077 #else |
1070 testsweep_test = -1; | 1078 testsweep_test = -1; |
1071 #endif | 1079 #endif |
1072 if (testsweep_test == -1) { | 1080 if (testsweep_test == -1) { |
1073 test_3_by_3(); | 1081 test_3_by_3(); |
1074 } | 1082 } |
1075 test_sweep(); | 1083 test_sweep(); |
1076 test_horz(); | 1084 test_horz(); |
1077 test_vert(); | 1085 test_vert(); |
1078 } | 1086 } |
OLD | NEW |