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 = fContoursHead; | 12 fCurrentContour = fContoursHead; |
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 fUnparseable = false; | 16 fUnparseable = false; |
17 fSecondHalf = preFetch(); | 17 fSecondHalf = preFetch(); |
18 } | 18 } |
19 | 19 |
20 void SkOpEdgeBuilder::addOperand(const SkPath& path) { | 20 void SkOpEdgeBuilder::addOperand(const SkPath& path) { |
21 SkASSERT(fPathVerbs.count() > 0 && fPathVerbs.end()[-1] == SkPath::kDone_Ver
b); | 21 SkASSERT(fPathVerbs.count() > 0 && fPathVerbs.end()[-1] == SkPath::kDone_Ver
b); |
22 fPathVerbs.pop(); | 22 fPathVerbs.pop(); |
23 fPath = &path; | 23 fPath = &path; |
24 fXorMask[1] = (fPath->getFillType() & 1) ? kEvenOdd_PathOpsMask | 24 fXorMask[1] = (fPath->getFillType() & 1) ? kEvenOdd_PathOpsMask |
25 : kWinding_PathOpsMask; | 25 : kWinding_PathOpsMask; |
26 preFetch(); | 26 preFetch(); |
27 } | 27 } |
28 | 28 |
29 int SkOpEdgeBuilder::count() const { | |
30 SkOpContour* contour = fContoursHead; | |
31 int count = 0; | |
32 while (contour) { | |
33 count += contour->count() > 0; | |
34 contour = contour->next(); | |
35 } | |
36 return count; | |
37 } | |
38 | |
39 bool SkOpEdgeBuilder::finish() { | 29 bool SkOpEdgeBuilder::finish() { |
40 fOperand = false; | 30 fOperand = false; |
41 if (fUnparseable || !walk()) { | 31 if (fUnparseable || !walk()) { |
42 return false; | 32 return false; |
43 } | 33 } |
44 complete(); | 34 complete(); |
45 if (fCurrentContour && !fCurrentContour->count()) { | 35 if (fCurrentContour && !fCurrentContour->count()) { |
46 fContoursHead->remove(fCurrentContour); | 36 fContoursHead->remove(fCurrentContour); |
47 } | 37 } |
48 return true; | 38 return true; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } | 238 } |
249 SkASSERT(fCurrentContour); | 239 SkASSERT(fCurrentContour); |
250 fCurrentContour->debugValidate(); | 240 fCurrentContour->debugValidate(); |
251 pointsPtr += SkPathOpsVerbToPoints(verb); | 241 pointsPtr += SkPathOpsVerbToPoints(verb); |
252 } | 242 } |
253 if (fCurrentContour && fCurrentContour->count() &&!fAllowOpenContours && !clo
se()) { | 243 if (fCurrentContour && fCurrentContour->count() &&!fAllowOpenContours && !clo
se()) { |
254 return false; | 244 return false; |
255 } | 245 } |
256 return true; | 246 return true; |
257 } | 247 } |
OLD | NEW |