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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 setUpWinding(start, end, &maxWinding, sumWinding); | 155 setUpWinding(start, end, &maxWinding, sumWinding); |
156 bool from = maxWinding != 0; | 156 bool from = maxWinding != 0; |
157 bool to = *sumWinding != 0; | 157 bool to = *sumWinding != 0; |
158 bool result = gUnaryActiveEdge[from][to]; | 158 bool result = gUnaryActiveEdge[from][to]; |
159 return result; | 159 return result; |
160 } | 160 } |
161 | 161 |
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 SkOpCurve edge; | 165 SkDCurveSweep curvePart; |
166 const SkPoint* ePtr; | 166 start->segment()->subDivide(start, end, &curvePart.fCurve); |
167 SkScalar eWeight; | 167 curvePart.setCurveHullSweep(fVerb); |
168 if ((start == &fHead && end == &fTail) || (start == &fTail && end == &fHead)
) { | 168 SkPath::Verb verb = curvePart.isCurve() ? fVerb : SkPath::kLine_Verb; |
169 ePtr = fPts; | 169 path->deferredMove(start->ptT()); |
170 eWeight = fWeight; | 170 switch (verb) { |
171 } else { | 171 case SkPath::kLine_Verb: |
172 // OPTIMIZE? if not active, skip remainder and return xyAtT(end) | 172 path->deferredLine(end->ptT()); |
173 subDivide(start, end, &edge); | 173 break; |
174 ePtr = edge.fPts; | 174 case SkPath::kQuad_Verb: |
175 eWeight = edge.fWeight; | 175 path->quadTo(curvePart.fCurve.fQuad.fPts[1].asSkPoint(), end->ptT())
; |
176 } | 176 break; |
177 bool reverse = ePtr == fPts && start != &fHead; | 177 case SkPath::kConic_Verb: |
178 if (reverse) { | 178 path->conicTo(curvePart.fCurve.fConic.fPts[1].asSkPoint(), end->ptT(
), |
179 path->deferredMoveLine(ePtr[SkPathOpsVerbToPoints(fVerb)]); | 179 curvePart.fCurve.fConic.fWeight); |
180 switch (fVerb) { | 180 break; |
181 case SkPath::kLine_Verb: | 181 case SkPath::kCubic_Verb: |
182 path->deferredLine(ePtr[0]); | 182 path->cubicTo(curvePart.fCurve.fCubic.fPts[1].asSkPoint(), |
183 break; | 183 curvePart.fCurve.fCubic.fPts[2].asSkPoint(), end->ptT()); |
184 case SkPath::kQuad_Verb: | 184 break; |
185 path->quadTo(ePtr[1], ePtr[0]); | 185 default: |
186 break; | 186 SkASSERT(0); |
187 case SkPath::kConic_Verb: | |
188 path->conicTo(ePtr[1], ePtr[0], eWeight); | |
189 break; | |
190 case SkPath::kCubic_Verb: | |
191 path->cubicTo(ePtr[2], ePtr[1], ePtr[0]); | |
192 break; | |
193 default: | |
194 SkASSERT(0); | |
195 } | |
196 } else { | |
197 path->deferredMoveLine(ePtr[0]); | |
198 switch (fVerb) { | |
199 case SkPath::kLine_Verb: | |
200 path->deferredLine(ePtr[1]); | |
201 break; | |
202 case SkPath::kQuad_Verb: | |
203 path->quadTo(ePtr[1], ePtr[2]); | |
204 break; | |
205 case SkPath::kConic_Verb: | |
206 path->conicTo(ePtr[1], ePtr[2], eWeight); | |
207 break; | |
208 case SkPath::kCubic_Verb: | |
209 path->cubicTo(ePtr[1], ePtr[2], ePtr[3]); | |
210 break; | |
211 default: | |
212 SkASSERT(0); | |
213 } | |
214 } | 187 } |
215 return true; | 188 return true; |
216 } | 189 } |
217 | 190 |
218 const SkOpPtT* SkOpSegment::existing(double t, const SkOpSegment* opp) const { | 191 const SkOpPtT* SkOpSegment::existing(double t, const SkOpSegment* opp) const { |
219 const SkOpSpanBase* test = &fHead; | 192 const SkOpSpanBase* test = &fHead; |
220 const SkOpPtT* testPtT; | 193 const SkOpPtT* testPtT; |
221 SkPoint pt = this->ptAtT(t); | 194 SkPoint pt = this->ptAtT(t); |
222 do { | 195 do { |
223 testPtT = test->ptT(); | 196 testPtT = test->ptT(); |
(...skipping 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 int absOut = SkTAbs(outerWinding); | 1745 int absOut = SkTAbs(outerWinding); |
1773 int absIn = SkTAbs(innerWinding); | 1746 int absIn = SkTAbs(innerWinding); |
1774 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn; | 1747 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn; |
1775 return result; | 1748 return result; |
1776 } | 1749 } |
1777 | 1750 |
1778 int SkOpSegment::windSum(const SkOpAngle* angle) const { | 1751 int SkOpSegment::windSum(const SkOpAngle* angle) const { |
1779 const SkOpSpan* minSpan = angle->start()->starter(angle->end()); | 1752 const SkOpSpan* minSpan = angle->start()->starter(angle->end()); |
1780 return minSpan->windSum(); | 1753 return minSpan->windSum(); |
1781 } | 1754 } |
OLD | NEW |