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 "SkGeometry.h" | 7 #include "SkGeometry.h" |
8 #include "SkOpEdgeBuilder.h" | 8 #include "SkOpEdgeBuilder.h" |
9 #include "SkReduceOrder.h" | 9 #include "SkReduceOrder.h" |
10 | 10 |
11 void SkOpEdgeBuilder::init() { | 11 void SkOpEdgeBuilder::init() { |
12 fCurrentContour = NULL; | 12 fCurrentContour = NULL; |
13 fOperand = false; | 13 fOperand = false; |
14 fXorMask[0] = fXorMask[1] = (fPath->getFillType() & 1) ? kEvenOdd_PathOpsMas
k | 14 fXorMask[0] = fXorMask[1] = (fPath->getFillType() & 1) ? kEvenOdd_PathOpsMas
k |
15 : kWinding_PathOpsMask; | 15 : kWinding_PathOpsMask; |
16 #if DEBUG_DUMP | 16 #ifdef SK_DEBUG |
17 gContourID = 0; | 17 SkPathOpsDebug::gContourID = 0; |
18 gSegmentID = 0; | 18 SkPathOpsDebug::gSegmentID = 0; |
19 #endif | 19 #endif |
20 fUnparseable = false; | 20 fUnparseable = false; |
21 fSecondHalf = preFetch(); | 21 fSecondHalf = preFetch(); |
22 } | 22 } |
23 | 23 |
24 void SkOpEdgeBuilder::addOperand(const SkPath& path) { | 24 void SkOpEdgeBuilder::addOperand(const SkPath& path) { |
25 SkASSERT(fPathVerbs.count() > 0 && fPathVerbs.end()[-1] == SkPath::kDone_Ver
b); | 25 SkASSERT(fPathVerbs.count() > 0 && fPathVerbs.end()[-1] == SkPath::kDone_Ver
b); |
26 fPathVerbs.pop_back(); | 26 fPathVerbs.pop_back(); |
27 fPath = &path; | 27 fPath = &path; |
28 fXorMask[1] = (fPath->getFillType() & 1) ? kEvenOdd_PathOpsMask | 28 fXorMask[1] = (fPath->getFillType() & 1) ? kEvenOdd_PathOpsMask |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 closeContour(curve[0], curveStart); | 77 closeContour(curve[0], curveStart); |
78 } | 78 } |
79 fPathVerbs.push_back(verb); | 79 fPathVerbs.push_back(verb); |
80 fPathPts.push_back(pts[0]); | 80 fPathPts.push_back(pts[0]); |
81 curveStart = curve[0] = pts[0]; | 81 curveStart = curve[0] = pts[0]; |
82 lastCurve = false; | 82 lastCurve = false; |
83 continue; | 83 continue; |
84 case SkPath::kLine_Verb: | 84 case SkPath::kLine_Verb: |
85 if (AlmostEqualUlps(curve[0].fX, pts[1].fX) | 85 if (AlmostEqualUlps(curve[0].fX, pts[1].fX) |
86 && AlmostEqualUlps(curve[0].fY, pts[1].fY)) { | 86 && AlmostEqualUlps(curve[0].fY, pts[1].fY)) { |
| 87 if (fPathVerbs.back() != SkPath::kLine_Verb) { |
| 88 fPathPts.back() = pts[1]; |
| 89 } |
87 continue; // skip degenerate points | 90 continue; // skip degenerate points |
88 } | 91 } |
89 break; | 92 break; |
90 case SkPath::kQuad_Verb: | 93 case SkPath::kQuad_Verb: |
91 curve[1] = pts[1]; | 94 curve[1] = pts[1]; |
92 curve[2] = pts[2]; | 95 curve[2] = pts[2]; |
93 verb = SkReduceOrder::Quad(curve, pts); | 96 verb = SkReduceOrder::Quad(curve, pts); |
94 if (verb == SkPath::kMove_Verb) { | 97 if (verb == SkPath::kMove_Verb) { |
95 continue; // skip degenerate points | 98 continue; // skip degenerate points |
96 } | 99 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 return false; | 190 return false; |
188 } | 191 } |
189 pointsPtr += SkPathOpsVerbToPoints(verb); | 192 pointsPtr += SkPathOpsVerbToPoints(verb); |
190 SkASSERT(fCurrentContour); | 193 SkASSERT(fCurrentContour); |
191 } | 194 } |
192 if (fCurrentContour && !fAllowOpenContours && !close()) { | 195 if (fCurrentContour && !fAllowOpenContours && !close()) { |
193 return false; | 196 return false; |
194 } | 197 } |
195 return true; | 198 return true; |
196 } | 199 } |
OLD | NEW |