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" |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 12 | |
| 13 | class SkOpEdgeBuilder { |
| 14 | public: |
caryclark | eed356d | 2016-09-14 07:18:20 -0700 | [diff] [blame] | 15 | SkOpEdgeBuilder(const SkPathWriter& path, SkOpContourHead* contours2, |
| 16 | SkOpGlobalState* globalState) |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 17 | : fGlobalState(globalState) |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 18 | , fPath(path.nativePath()) |
Cary Clark | ff11428 | 2016-12-14 11:56:16 -0500 | [diff] [blame] | 19 | , fContourBuilder(contours2) |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 20 | , fContoursHead(contours2) |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 21 | , fAllowOpenContours(true) { |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 22 | init(); |
| 23 | } |
| 24 | |
caryclark | eed356d | 2016-09-14 07:18:20 -0700 | [diff] [blame] | 25 | SkOpEdgeBuilder(const SkPath& path, SkOpContourHead* contours2, SkOpGlobalState* globalState) |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 26 | : fGlobalState(globalState) |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 27 | , fPath(&path) |
Cary Clark | ff11428 | 2016-12-14 11:56:16 -0500 | [diff] [blame] | 28 | , fContourBuilder(contours2) |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 29 | , fContoursHead(contours2) |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 30 | , fAllowOpenContours(false) { |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 31 | init(); |
| 32 | } |
| 33 | |
caryclark | d751ac0 | 2014-10-03 05:36:27 -0700 | [diff] [blame] | 34 | void addOperand(const SkPath& path); |
| 35 | |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 36 | void complete() { |
Cary Clark | ff11428 | 2016-12-14 11:56:16 -0500 | [diff] [blame] | 37 | fContourBuilder.flush(); |
| 38 | SkOpContour* contour = fContourBuilder.contour(); |
| 39 | if (contour && contour->count()) { |
| 40 | contour->complete(); |
| 41 | fContourBuilder.setContour(nullptr); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 42 | } |
| 43 | } |
| 44 | |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 45 | bool finish(); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 46 | |
| 47 | const SkOpContour* head() const { |
| 48 | return fContoursHead; |
| 49 | } |
| 50 | |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 51 | void init(); |
caryclark | d751ac0 | 2014-10-03 05:36:27 -0700 | [diff] [blame] | 52 | bool unparseable() const { return fUnparseable; } |
| 53 | SkPathOpsMask xorMask() const { return fXorMask[fOperand]; } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 54 | |
| 55 | private: |
caryclark@google.com | 07e97fc | 2013-07-08 17:17:02 +0000 | [diff] [blame] | 56 | void closeContour(const SkPoint& curveEnd, const SkPoint& curveStart); |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 57 | bool close(); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 58 | int preFetch(); |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 59 | bool walk(); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 60 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 61 | SkOpGlobalState* fGlobalState; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 62 | const SkPath* fPath; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 63 | SkTDArray<SkPoint> fPathPts; |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 64 | SkTDArray<SkScalar> fWeights; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 65 | SkTDArray<uint8_t> fPathVerbs; |
Cary Clark | ff11428 | 2016-12-14 11:56:16 -0500 | [diff] [blame] | 66 | SkOpContourBuilder fContourBuilder; |
caryclark | eed356d | 2016-09-14 07:18:20 -0700 | [diff] [blame] | 67 | SkOpContourHead* fContoursHead; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 68 | SkPathOpsMask fXorMask[2]; |
| 69 | int fSecondHalf; |
| 70 | bool fOperand; |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 71 | bool fAllowOpenContours; |
| 72 | bool fUnparseable; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | #endif |