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 #include "SkOpAngle.h" | 7 #include "SkOpAngle.h" |
8 #include "SkOpSegment.h" | 8 #include "SkOpSegment.h" |
9 #include "SkPathOpsCurve.h" | 9 #include "SkPathOpsCurve.h" |
10 #include "SkTSort.h" | 10 #include "SkTSort.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 int SkOpAngle::allOnOneSide(const SkOpAngle* test) { | 175 int SkOpAngle::allOnOneSide(const SkOpAngle* test) { |
176 SkASSERT(!fIsCurve); | 176 SkASSERT(!fIsCurve); |
177 SkASSERT(test->fIsCurve); | 177 SkASSERT(test->fIsCurve); |
178 const SkDPoint& origin = test->fCurvePart[0]; | 178 const SkDPoint& origin = test->fCurvePart[0]; |
179 SkVector line; | 179 SkVector line; |
180 if (segment()->verb() == SkPath::kLine_Verb) { | 180 if (segment()->verb() == SkPath::kLine_Verb) { |
181 const SkPoint* linePts = segment()->pts(); | 181 const SkPoint* linePts = segment()->pts(); |
182 int lineStart = fStart->t() < fEnd->t() ? 0 : 1; | 182 int lineStart = fStart->t() < fEnd->t() ? 0 : 1; |
183 line = linePts[lineStart ^ 1] - linePts[lineStart]; | 183 line = linePts[lineStart ^ 1] - linePts[lineStart]; |
184 } else { | 184 } else { |
185 SkPoint shortPts[2] = { fCurvePart[0].asSkPoint(), fCurvePart[1].asSkPoi
nt() }; | 185 line = (fCurvePart[1] - fCurvePart[0]).asSkVector(); |
186 line = shortPts[1] - shortPts[0]; | |
187 } | 186 } |
188 float crosses[3]; | 187 float crosses[3]; |
189 SkPath::Verb testVerb = test->segment()->verb(); | 188 SkPath::Verb testVerb = test->segment()->verb(); |
190 int iMax = SkPathOpsVerbToPoints(testVerb); | 189 int iMax = SkPathOpsVerbToPoints(testVerb); |
191 // SkASSERT(origin == test.fCurveHalf[0]); | 190 // SkASSERT(origin == test.fCurveHalf[0]); |
192 const SkDCurve& testCurve = test->fCurvePart; | 191 const SkDCurve& testCurve = test->fCurvePart; |
193 for (int index = 1; index <= iMax; ++index) { | 192 for (int index = 1; index <= iMax; ++index) { |
194 float xy1 = (float) (line.fX * (testCurve[index].fY - origin.fY)); | 193 float xy1 = (float) (line.fX * (testCurve[index].fY - origin.fY)); |
195 float xy2 = (float) (line.fY * (testCurve[index].fX - origin.fX)); | 194 float xy2 = (float) (line.fY * (testCurve[index].fX - origin.fX)); |
196 crosses[index - 1] = AlmostEqualUlps(xy1, xy2) ? 0 : xy1 - xy2; | 195 crosses[index - 1] = AlmostEqualUlps(xy1, xy2) ? 0 : xy1 - xy2; |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 return true; | 1091 return true; |
1093 } | 1092 } |
1094 SkASSERT(s0dt0 != 0); | 1093 SkASSERT(s0dt0 != 0); |
1095 double m = s0xt0 / s0dt0; | 1094 double m = s0xt0 / s0dt0; |
1096 double sDist = sweep[0].length() * m; | 1095 double sDist = sweep[0].length() * m; |
1097 double tDist = tweep[0].length() * m; | 1096 double tDist = tweep[0].length() * m; |
1098 bool useS = fabs(sDist) < fabs(tDist); | 1097 bool useS = fabs(sDist) < fabs(tDist); |
1099 double mFactor = fabs(useS ? this->distEndRatio(sDist) : rh->distEndRatio(tD
ist)); | 1098 double mFactor = fabs(useS ? this->distEndRatio(sDist) : rh->distEndRatio(tD
ist)); |
1100 return mFactor < 2400; // empirically found limit | 1099 return mFactor < 2400; // empirically found limit |
1101 } | 1100 } |
OLD | NEW |