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" |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 13 | |
| 14 | class SkOpEdgeBuilder { |
| 15 | public: |
| 16 | SkOpEdgeBuilder(const SkPathWriter& path, SkTArray<SkOpContour>& contours) |
| 17 | : fPath(path.nativePath()) |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 18 | , fContours(contours) |
| 19 | , fAllowOpenContours(true) { |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 20 | init(); |
| 21 | } |
| 22 | |
| 23 | SkOpEdgeBuilder(const SkPath& path, SkTArray<SkOpContour>& contours) |
| 24 | : fPath(&path) |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 25 | , fContours(contours) |
| 26 | , fAllowOpenContours(false) { |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 27 | init(); |
| 28 | } |
| 29 | |
caryclark | d751ac0 | 2014-10-03 05:36:27 -0700 | [diff] [blame] | 30 | void addOperand(const SkPath& path); |
| 31 | |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 32 | void complete() { |
| 33 | if (fCurrentContour && fCurrentContour->segments().count()) { |
| 34 | fCurrentContour->complete(); |
| 35 | fCurrentContour = NULL; |
| 36 | } |
| 37 | } |
| 38 | |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 39 | bool finish(); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 40 | void init(); |
caryclark | d751ac0 | 2014-10-03 05:36:27 -0700 | [diff] [blame] | 41 | bool unparseable() const { return fUnparseable; } |
| 42 | SkPathOpsMask xorMask() const { return fXorMask[fOperand]; } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 43 | |
| 44 | private: |
caryclark@google.com | 07e97fc | 2013-07-08 17:17:02 +0000 | [diff] [blame] | 45 | void closeContour(const SkPoint& curveEnd, const SkPoint& curveStart); |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 46 | bool close(); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 47 | int preFetch(); |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 48 | bool walk(); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 49 | |
| 50 | const SkPath* fPath; |
caryclark@google.com | d892bd8 | 2013-06-17 14:10:36 +0000 | [diff] [blame] | 51 | SkTArray<SkPoint, true> fPathPts; |
| 52 | SkTArray<uint8_t, true> fPathVerbs; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 53 | SkOpContour* fCurrentContour; |
| 54 | SkTArray<SkOpContour>& fContours; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 55 | SkPathOpsMask fXorMask[2]; |
| 56 | int fSecondHalf; |
| 57 | bool fOperand; |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 58 | bool fAllowOpenContours; |
| 59 | bool fUnparseable; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | #endif |