caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | #ifndef SkOpEdgeBuilder_DEFINED |
| 8 | #define SkOpEdgeBuilder_DEFINED |
| 9 | |
| 10 | #include "SkOpContour.h" |
| 11 | #include "SkPathWriter.h" |
| 12 | #include "SkTArray.h" |
| 13 | #include "SkTDArray.h" |
| 14 | |
| 15 | class SkOpEdgeBuilder { |
| 16 | public: |
| 17 | SkOpEdgeBuilder(const SkPathWriter& path, SkTArray<SkOpContour>& contours) |
| 18 | : fPath(path.nativePath()) |
| 19 | , fContours(contours) { |
| 20 | init(); |
| 21 | } |
| 22 | |
| 23 | SkOpEdgeBuilder(const SkPath& path, SkTArray<SkOpContour>& contours) |
| 24 | : fPath(&path) |
| 25 | , fContours(contours) { |
| 26 | init(); |
| 27 | } |
| 28 | |
| 29 | void complete() { |
| 30 | if (fCurrentContour && fCurrentContour->segments().count()) { |
| 31 | fCurrentContour->complete(); |
| 32 | fCurrentContour = NULL; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | SkPathOpsMask xorMask() const { |
| 37 | return fXorMask[fOperand]; |
| 38 | } |
| 39 | |
| 40 | void addOperand(const SkPath& path); |
| 41 | void finish(); |
| 42 | void init(); |
| 43 | |
| 44 | private: |
| 45 | int preFetch(); |
| 46 | void walk(); |
| 47 | |
| 48 | const SkPath* fPath; |
| 49 | SkTDArray<SkPoint> fPathPts; // FIXME: point directly to path pts instead |
| 50 | SkTDArray<uint8_t> fPathVerbs; // FIXME: remove |
| 51 | SkOpContour* fCurrentContour; |
| 52 | SkTArray<SkOpContour>& fContours; |
| 53 | SkTDArray<SkPoint> fReducePts; // segments created on the fly |
| 54 | SkTDArray<int> fExtra; // -1 marks new contour, > 0 offsets into contour |
| 55 | SkPathOpsMask fXorMask[2]; |
| 56 | int fSecondHalf; |
| 57 | bool fOperand; |
| 58 | }; |
| 59 | |
| 60 | #endif |