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 "SkOpCoincidence.h" | 7 #include "SkOpCoincidence.h" |
8 #include "SkOpContour.h" | 8 #include "SkOpContour.h" |
9 #include "SkOpSegment.h" | 9 #include "SkOpSegment.h" |
10 #include "SkPathWriter.h" | 10 #include "SkPathWriter.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 bool SkOpSegment::addCurveTo(const SkOpSpanBase* start, const SkOpSpanBase* end, | 162 bool SkOpSegment::addCurveTo(const SkOpSpanBase* start, const SkOpSpanBase* end, |
163 SkPathWriter* path) const { | 163 SkPathWriter* path) const { |
164 FAIL_IF(start->starter(end)->alreadyAdded()); | 164 FAIL_IF(start->starter(end)->alreadyAdded()); |
165 SkDCurveSweep curvePart; | 165 SkDCurveSweep curvePart; |
166 start->segment()->subDivide(start, end, &curvePart.fCurve); | 166 start->segment()->subDivide(start, end, &curvePart.fCurve); |
167 curvePart.setCurveHullSweep(fVerb); | 167 curvePart.setCurveHullSweep(fVerb); |
168 SkPath::Verb verb = curvePart.isCurve() ? fVerb : SkPath::kLine_Verb; | 168 SkPath::Verb verb = curvePart.isCurve() ? fVerb : SkPath::kLine_Verb; |
169 path->deferredMove(start->ptT()); | 169 path->deferredMove(start->ptT()); |
170 switch (verb) { | 170 switch (verb) { |
171 case SkPath::kLine_Verb: | 171 case SkPath::kLine_Verb: |
172 path->deferredLine(end->ptT()); | 172 FAIL_IF(!path->deferredLine(end->ptT())); |
173 break; | 173 break; |
174 case SkPath::kQuad_Verb: | 174 case SkPath::kQuad_Verb: |
175 path->quadTo(curvePart.fCurve.fQuad.fPts[1].asSkPoint(), end->ptT())
; | 175 path->quadTo(curvePart.fCurve.fQuad[1].asSkPoint(), end->ptT()); |
176 break; | 176 break; |
177 case SkPath::kConic_Verb: | 177 case SkPath::kConic_Verb: |
178 path->conicTo(curvePart.fCurve.fConic.fPts[1].asSkPoint(), end->ptT(
), | 178 path->conicTo(curvePart.fCurve.fConic[1].asSkPoint(), end->ptT(), |
179 curvePart.fCurve.fConic.fWeight); | 179 curvePart.fCurve.fConic.fWeight); |
180 break; | 180 break; |
181 case SkPath::kCubic_Verb: | 181 case SkPath::kCubic_Verb: |
182 path->cubicTo(curvePart.fCurve.fCubic.fPts[1].asSkPoint(), | 182 path->cubicTo(curvePart.fCurve.fCubic[1].asSkPoint(), |
183 curvePart.fCurve.fCubic.fPts[2].asSkPoint(), end->ptT()); | 183 curvePart.fCurve.fCubic[2].asSkPoint(), end->ptT()); |
184 break; | 184 break; |
185 default: | 185 default: |
186 SkASSERT(0); | 186 SkASSERT(0); |
187 } | 187 } |
188 return true; | 188 return true; |
189 } | 189 } |
190 | 190 |
191 const SkOpPtT* SkOpSegment::existing(double t, const SkOpSegment* opp) const { | 191 const SkOpPtT* SkOpSegment::existing(double t, const SkOpSegment* opp) const { |
192 const SkOpSpanBase* test = &fHead; | 192 const SkOpSpanBase* test = &fHead; |
193 const SkOpPtT* testPtT; | 193 const SkOpPtT* testPtT; |
(...skipping 24 matching lines...) Expand all Loading... |
218 foundMatch: | 218 foundMatch: |
219 return opp && !test->contains(opp) ? nullptr : testPtT; | 219 return opp && !test->contains(opp) ? nullptr : testPtT; |
220 } | 220 } |
221 | 221 |
222 // break the span so that the coincident part does not change the angle of the r
emainder | 222 // break the span so that the coincident part does not change the angle of the r
emainder |
223 bool SkOpSegment::addExpanded(double newT, const SkOpSpanBase* test, bool* start
Over) { | 223 bool SkOpSegment::addExpanded(double newT, const SkOpSpanBase* test, bool* start
Over) { |
224 if (this->contains(newT)) { | 224 if (this->contains(newT)) { |
225 return true; | 225 return true; |
226 } | 226 } |
227 this->globalState()->resetAllocatedOpSpan(); | 227 this->globalState()->resetAllocatedOpSpan(); |
| 228 FAIL_IF(!between(0, newT, 1)); |
228 SkOpPtT* newPtT = this->addT(newT); | 229 SkOpPtT* newPtT = this->addT(newT); |
229 *startOver |= this->globalState()->allocatedOpSpan(); | 230 *startOver |= this->globalState()->allocatedOpSpan(); |
230 if (!newPtT) { | 231 if (!newPtT) { |
231 return false; | 232 return false; |
232 } | 233 } |
233 newPtT->fPt = this->ptAtT(newT); | 234 newPtT->fPt = this->ptAtT(newT); |
234 SkOpPtT* oppPrev = test->ptT()->oppPrev(newPtT); | 235 SkOpPtT* oppPrev = test->ptT()->oppPrev(newPtT); |
235 if (oppPrev) { | 236 if (oppPrev) { |
236 // const cast away to change linked list; pt/t values stays unchanged | 237 // const cast away to change linked list; pt/t values stays unchanged |
237 SkOpSpanBase* writableTest = const_cast<SkOpSpanBase*>(test); | 238 SkOpSpanBase* writableTest = const_cast<SkOpSpanBase*>(test); |
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1687 int absOut = SkTAbs(outerWinding); | 1688 int absOut = SkTAbs(outerWinding); |
1688 int absIn = SkTAbs(innerWinding); | 1689 int absIn = SkTAbs(innerWinding); |
1689 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn; | 1690 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn; |
1690 return result; | 1691 return result; |
1691 } | 1692 } |
1692 | 1693 |
1693 int SkOpSegment::windSum(const SkOpAngle* angle) const { | 1694 int SkOpSegment::windSum(const SkOpAngle* angle) const { |
1694 const SkOpSpan* minSpan = angle->start()->starter(angle->end()); | 1695 const SkOpSpan* minSpan = angle->start()->starter(angle->end()); |
1695 return minSpan->windSum(); | 1696 return minSpan->windSum(); |
1696 } | 1697 } |
OLD | NEW |