OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkPathOpsBounds.h" | 7 #include "SkPathOpsBounds.h" |
8 #include "SkPathOpsRect.h" | 8 #include "SkPathOpsRect.h" |
9 #include "SkPathOpsCurve.h" | 9 #include "SkPathOpsCurve.h" |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 double largest = SkTMax(SkTMax(maxX, maxY), -SkTMin(minX, minY)); | 48 double largest = SkTMax(SkTMax(maxX, maxY), -SkTMin(minX, minY)); |
49 if (!AlmostEqualUlps_Pin(largest, largest + minDist)) { // is distance withi
n ULPS tolerance? | 49 if (!AlmostEqualUlps_Pin(largest, largest + minDist)) { // is distance withi
n ULPS tolerance? |
50 return -1; | 50 return -1; |
51 } | 51 } |
52 return SkPinT(i[0][minIndex]); | 52 return SkPinT(i[0][minIndex]); |
53 } | 53 } |
54 | 54 |
55 void SkDCurve::offset(SkPath::Verb verb, const SkDVector& off) { | 55 void SkDCurve::offset(SkPath::Verb verb, const SkDVector& off) { |
56 int count = SkPathOpsVerbToPoints(verb); | 56 int count = SkPathOpsVerbToPoints(verb); |
57 for (int index = 0; index < count; ++index) { | 57 for (int index = 0; index <= count; ++index) { |
58 fCubic.fPts[index] += off; | 58 fCubic.fPts[index] += off; |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 void SkDCurve::setConicBounds(const SkPoint curve[3], SkScalar curveWeight, | 62 void SkDCurve::setConicBounds(const SkPoint curve[3], SkScalar curveWeight, |
63 double tStart, double tEnd, SkPathOpsBounds* bounds) { | 63 double tStart, double tEnd, SkPathOpsBounds* bounds) { |
64 SkDConic dCurve; | 64 SkDConic dCurve; |
65 dCurve.set(curve, curveWeight); | 65 dCurve.set(curve, curveWeight); |
66 SkDRect dRect; | 66 SkDRect dRect; |
67 dRect.setBounds(dCurve, fConic, tStart, tEnd); | 67 dRect.setBounds(dCurve, fConic, tStart, tEnd); |
(...skipping 26 matching lines...) Expand all Loading... |
94 fSweep[0] = fCurve[1] - fCurve[0]; | 94 fSweep[0] = fCurve[1] - fCurve[0]; |
95 if (SkPath::kLine_Verb == verb) { | 95 if (SkPath::kLine_Verb == verb) { |
96 fSweep[1] = fSweep[0]; | 96 fSweep[1] = fSweep[0]; |
97 fIsCurve = false; | 97 fIsCurve = false; |
98 return; | 98 return; |
99 } | 99 } |
100 fSweep[1] = fCurve[2] - fCurve[0]; | 100 fSweep[1] = fCurve[2] - fCurve[0]; |
101 // OPTIMIZE: I do the following float check a lot -- probably need a | 101 // OPTIMIZE: I do the following float check a lot -- probably need a |
102 // central place for this val-is-small-compared-to-curve check | 102 // central place for this val-is-small-compared-to-curve check |
103 double maxVal = 0; | 103 double maxVal = 0; |
104 for (int index = 0; index < SkPathOpsVerbToPoints(verb); ++index) { | 104 for (int index = 0; index <= SkPathOpsVerbToPoints(verb); ++index) { |
105 maxVal = SkTMax(maxVal, SkTMax(SkTAbs(fCurve[index].fX), | 105 maxVal = SkTMax(maxVal, SkTMax(SkTAbs(fCurve[index].fX), |
106 SkTAbs(fCurve[index].fY))); | 106 SkTAbs(fCurve[index].fY))); |
107 } | 107 } |
108 { | 108 { |
109 if (SkPath::kCubic_Verb != verb) { | 109 if (SkPath::kCubic_Verb != verb) { |
110 if (roughly_zero_when_compared_to(fSweep[0].fX, maxVal) | 110 if (roughly_zero_when_compared_to(fSweep[0].fX, maxVal) |
111 && roughly_zero_when_compared_to(fSweep[0].fY, maxVal)) { | 111 && roughly_zero_when_compared_to(fSweep[0].fY, maxVal)) { |
112 fSweep[0] = fSweep[1]; | 112 fSweep[0] = fSweep[1]; |
113 } | 113 } |
114 goto setIsCurve; | 114 goto setIsCurve; |
(...skipping 21 matching lines...) Expand all Loading... |
136 if (s3x2 * s2x1 < 0) { | 136 if (s3x2 * s2x1 < 0) { |
137 SkASSERT(s2x1 * s1x3 > 0); | 137 SkASSERT(s2x1 * s1x3 > 0); |
138 fSweep[0] = fSweep[1]; | 138 fSweep[0] = fSweep[1]; |
139 fOrdered = false; | 139 fOrdered = false; |
140 } | 140 } |
141 fSweep[1] = thirdSweep; | 141 fSweep[1] = thirdSweep; |
142 } | 142 } |
143 setIsCurve: | 143 setIsCurve: |
144 fIsCurve = fSweep[0].crossCheck(fSweep[1]) != 0; | 144 fIsCurve = fSweep[0].crossCheck(fSweep[1]) != 0; |
145 } | 145 } |
OLD | NEW |