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 #ifndef SkOpEdgeBuilder_DEFINED | 7 #ifndef SkOpEdgeBuilder_DEFINED |
8 #define SkOpEdgeBuilder_DEFINED | 8 #define SkOpEdgeBuilder_DEFINED |
9 | 9 |
10 #include "SkOpContour.h" | 10 #include "SkOpContour.h" |
11 #include "SkPathWriter.h" | 11 #include "SkPathWriter.h" |
12 #include "SkTArray.h" | 12 #include "SkTArray.h" |
13 | 13 |
14 class SkOpEdgeBuilder { | 14 class SkOpEdgeBuilder { |
15 public: | 15 public: |
16 SkOpEdgeBuilder(const SkPathWriter& path, SkTArray<SkOpContour>& contours) | 16 SkOpEdgeBuilder(const SkPathWriter& path, SkTArray<SkOpContour>& contours) |
17 : fPath(path.nativePath()) | 17 : fPath(path.nativePath()) |
18 , fContours(contours) | 18 , fContours(contours) |
19 , fAllowOpenContours(true) { | 19 , fAllowOpenContours(true) { |
20 init(); | 20 init(); |
21 } | 21 } |
22 | 22 |
23 SkOpEdgeBuilder(const SkPath& path, SkTArray<SkOpContour>& contours) | 23 SkOpEdgeBuilder(const SkPath& path, SkTArray<SkOpContour>& contours) |
24 : fPath(&path) | 24 : fPath(&path) |
25 , fContours(contours) | 25 , fContours(contours) |
26 , fAllowOpenContours(false) { | 26 , fAllowOpenContours(false) { |
27 init(); | 27 init(); |
28 } | 28 } |
29 | 29 |
| 30 void addOperand(const SkPath& path); |
| 31 |
30 void complete() { | 32 void complete() { |
31 if (fCurrentContour && fCurrentContour->segments().count()) { | 33 if (fCurrentContour && fCurrentContour->segments().count()) { |
32 fCurrentContour->complete(); | 34 fCurrentContour->complete(); |
33 fCurrentContour = NULL; | 35 fCurrentContour = NULL; |
34 } | 36 } |
35 } | 37 } |
36 | 38 |
37 SkPathOpsMask xorMask() const { | |
38 return fXorMask[fOperand]; | |
39 } | |
40 | |
41 void addOperand(const SkPath& path); | |
42 bool finish(); | 39 bool finish(); |
43 void init(); | 40 void init(); |
| 41 bool unparseable() const { return fUnparseable; } |
| 42 SkPathOpsMask xorMask() const { return fXorMask[fOperand]; } |
44 | 43 |
45 private: | 44 private: |
46 void closeContour(const SkPoint& curveEnd, const SkPoint& curveStart); | 45 void closeContour(const SkPoint& curveEnd, const SkPoint& curveStart); |
47 bool close(); | 46 bool close(); |
48 int preFetch(); | 47 int preFetch(); |
49 bool walk(); | 48 bool walk(); |
50 | 49 |
51 const SkPath* fPath; | 50 const SkPath* fPath; |
52 SkTArray<SkPoint, true> fPathPts; | 51 SkTArray<SkPoint, true> fPathPts; |
53 SkTArray<uint8_t, true> fPathVerbs; | 52 SkTArray<uint8_t, true> fPathVerbs; |
54 SkOpContour* fCurrentContour; | 53 SkOpContour* fCurrentContour; |
55 SkTArray<SkOpContour>& fContours; | 54 SkTArray<SkOpContour>& fContours; |
56 SkPathOpsMask fXorMask[2]; | 55 SkPathOpsMask fXorMask[2]; |
57 int fSecondHalf; | 56 int fSecondHalf; |
58 bool fOperand; | 57 bool fOperand; |
59 bool fAllowOpenContours; | 58 bool fAllowOpenContours; |
60 bool fUnparseable; | 59 bool fUnparseable; |
61 }; | 60 }; |
62 | 61 |
63 #endif | 62 #endif |
OLD | NEW |