| 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 SkOpAngle_DEFINED | 7 #ifndef SkOpAngle_DEFINED |
| 8 #define SkOpAngle_DEFINED | 8 #define SkOpAngle_DEFINED |
| 9 | 9 |
| 10 #include "SkLineParameters.h" | 10 #include "SkLineParameters.h" |
| 11 #include "SkPathOpsCurve.h" | 11 #include "SkPathOpsCurve.h" |
| 12 #if DEBUG_ANGLE | 12 #if DEBUG_ANGLE |
| 13 #include "SkString.h" | 13 #include "SkString.h" |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 class SkOpContour; | 16 class SkOpContour; |
| 17 class SkOpPtT; | 17 class SkOpPtT; |
| 18 class SkOpSegment; | 18 class SkOpSegment; |
| 19 class SkOpSpanBase; | 19 class SkOpSpanBase; |
| 20 class SkOpSpan; | 20 class SkOpSpan; |
| 21 | 21 |
| 22 struct SkOpAngle { | 22 class SkOpAngle { |
| 23 public: |
| 23 enum IncludeType { | 24 enum IncludeType { |
| 24 kUnaryWinding, | 25 kUnaryWinding, |
| 25 kUnaryXor, | 26 kUnaryXor, |
| 26 kBinarySingle, | 27 kBinarySingle, |
| 27 kBinaryOpp, | 28 kBinaryOpp, |
| 28 }; | 29 }; |
| 29 | 30 |
| 30 bool after(SkOpAngle* test); | |
| 31 int allOnOneSide(const SkOpAngle* test); | |
| 32 bool checkCrossesZero() const; | |
| 33 bool checkParallel(SkOpAngle* ); | |
| 34 bool computeSector(); | |
| 35 int convexHullOverlaps(const SkOpAngle* ) const; | |
| 36 | |
| 37 const SkOpAngle* debugAngle(int id) const; | 31 const SkOpAngle* debugAngle(int id) const; |
| 32 const SkOpCoincidence* debugCoincidence() const; |
| 38 SkOpContour* debugContour(int id); | 33 SkOpContour* debugContour(int id); |
| 39 | 34 |
| 40 int debugID() const { | 35 int debugID() const { |
| 41 return SkDEBUGRELEASE(fID, -1); | 36 return SkDEBUGRELEASE(fID, -1); |
| 42 } | 37 } |
| 43 | 38 |
| 44 #if DEBUG_SORT | 39 #if DEBUG_SORT |
| 45 void debugLoop() const; | 40 void debugLoop() const; |
| 46 #endif | 41 #endif |
| 47 | 42 |
| 48 #if DEBUG_ANGLE | 43 #if DEBUG_ANGLE |
| 44 bool debugCheckCoincidence() const { return fCheckCoincidence; } |
| 49 void debugCheckNearCoincidence() const; | 45 void debugCheckNearCoincidence() const; |
| 50 SkString debugPart() const; | 46 SkString debugPart() const; |
| 51 #endif | 47 #endif |
| 52 const SkOpPtT* debugPtT(int id) const; | 48 const SkOpPtT* debugPtT(int id) const; |
| 53 const SkOpSegment* debugSegment(int id) const; | 49 const SkOpSegment* debugSegment(int id) const; |
| 54 int debugSign() const; | 50 int debugSign() const; |
| 55 const SkOpSpanBase* debugSpan(int id) const; | 51 const SkOpSpanBase* debugSpan(int id) const; |
| 56 void debugValidate() const; | 52 void debugValidate() const; |
| 57 void debugValidateNext() const; // in debug builds, verify that angle loop
is uncorrupted | 53 void debugValidateNext() const; // in debug builds, verify that angle loop
is uncorrupted |
| 58 double distEndRatio(double dist) const; | 54 double distEndRatio(double dist) const; |
| 59 // available to testing only | 55 // available to testing only |
| 60 void dump() const; | 56 void dump() const; |
| 61 void dumpCurves() const; | 57 void dumpCurves() const; |
| 62 void dumpLoop() const; | 58 void dumpLoop() const; |
| 63 void dumpOne(bool functionHeader) const; | 59 void dumpOne(bool functionHeader) const; |
| 64 void dumpTo(const SkOpSegment* fromSeg, const SkOpAngle* ) const; | 60 void dumpTo(const SkOpSegment* fromSeg, const SkOpAngle* ) const; |
| 65 void dumpTest() const; | 61 void dumpTest() const; |
| 66 | 62 |
| 67 SkOpSpanBase* end() const { | 63 SkOpSpanBase* end() const { |
| 68 return fEnd; | 64 return fEnd; |
| 69 } | 65 } |
| 70 | 66 |
| 71 bool endsIntersect(SkOpAngle* ); | |
| 72 bool endToSide(const SkOpAngle* rh, bool* inside) const; | |
| 73 int findSector(SkPath::Verb verb, double x, double y) const; | |
| 74 SkOpGlobalState* globalState() const; | |
| 75 void insert(SkOpAngle* ); | 67 void insert(SkOpAngle* ); |
| 76 SkOpSpanBase* lastMarked() const; | 68 SkOpSpanBase* lastMarked() const; |
| 77 bool loopContains(const SkOpAngle* ) const; | 69 bool loopContains(const SkOpAngle* ) const; |
| 78 int loopCount() const; | 70 int loopCount() const; |
| 79 bool merge(SkOpAngle* ); | |
| 80 double midT() const; | |
| 81 bool midToSide(const SkOpAngle* rh, bool* inside) const; | |
| 82 | 71 |
| 83 SkOpAngle* next() const { | 72 SkOpAngle* next() const { |
| 84 return fNext; | 73 return fNext; |
| 85 } | 74 } |
| 86 | 75 |
| 87 bool oppositePlanes(const SkOpAngle* rh) const; | |
| 88 bool orderable(SkOpAngle* rh); // false == this < rh ; true == this > rh | |
| 89 SkOpAngle* previous() const; | 76 SkOpAngle* previous() const; |
| 90 | |
| 91 int sectorEnd() const { | |
| 92 return fSectorEnd; | |
| 93 } | |
| 94 | |
| 95 int sectorStart() const { | |
| 96 return fSectorStart; | |
| 97 } | |
| 98 | |
| 99 SkOpSegment* segment() const; | 77 SkOpSegment* segment() const; |
| 100 | |
| 101 void set(SkOpSpanBase* start, SkOpSpanBase* end); | 78 void set(SkOpSpanBase* start, SkOpSpanBase* end); |
| 102 void setCurveHullSweep(); | |
| 103 | |
| 104 void setID(int id) { | |
| 105 SkDEBUGCODE(fID = id); | |
| 106 } | |
| 107 | 79 |
| 108 void setLastMarked(SkOpSpanBase* marked) { | 80 void setLastMarked(SkOpSpanBase* marked) { |
| 109 fLastMarked = marked; | 81 fLastMarked = marked; |
| 110 } | 82 } |
| 111 | 83 |
| 112 void setSector(); | |
| 113 void setSpans(); | |
| 114 | |
| 115 SkOpSpanBase* start() const { | 84 SkOpSpanBase* start() const { |
| 116 return fStart; | 85 return fStart; |
| 117 } | 86 } |
| 118 | 87 |
| 119 SkOpSpan* starter(); | 88 SkOpSpan* starter(); |
| 120 bool tangentsDiverge(const SkOpAngle* rh, double s0xt0) const; | |
| 121 | 89 |
| 122 bool unorderable() const { | 90 bool unorderable() const { |
| 123 return fUnorderable; | 91 return fUnorderable; |
| 124 } | 92 } |
| 125 | 93 |
| 126 SkDCurve fCurvePart; // the curve from start to end | 94 private: |
| 95 bool after(SkOpAngle* test); |
| 96 int allOnOneSide(const SkOpAngle* test); |
| 97 bool checkCrossesZero() const; |
| 98 bool checkParallel(SkOpAngle* ); |
| 99 bool computeSector(); |
| 100 int convexHullOverlaps(const SkOpAngle* ) const; |
| 101 bool endToSide(const SkOpAngle* rh, bool* inside) const; |
| 102 bool endsIntersect(SkOpAngle* ); |
| 103 int findSector(SkPath::Verb verb, double x, double y) const; |
| 104 SkOpGlobalState* globalState() const; |
| 105 bool merge(SkOpAngle* ); |
| 106 double midT() const; |
| 107 bool midToSide(const SkOpAngle* rh, bool* inside) const; |
| 108 bool oppositePlanes(const SkOpAngle* rh) const; |
| 109 bool orderable(SkOpAngle* rh); // false == this < rh ; true == this > rh |
| 110 void setCurveHullSweep(); |
| 111 void setSector(); |
| 112 void setSpans(); |
| 113 bool tangentsDiverge(const SkOpAngle* rh, double s0xt0) const; |
| 114 |
| 115 SkDCurve fOriginalCurvePart; // the curve from start to end |
| 116 SkDCurve fCurvePart; // the curve from start to end offset as needed |
| 127 double fSide; | 117 double fSide; |
| 128 SkLineParameters fTangentHalf; // used only to sort a pair of lines or line
-like sections | 118 SkLineParameters fTangentHalf; // used only to sort a pair of lines or line
-like sections |
| 129 SkOpAngle* fNext; | 119 SkOpAngle* fNext; |
| 130 SkOpSpanBase* fLastMarked; | 120 SkOpSpanBase* fLastMarked; |
| 131 SkDVector fSweep[2]; | 121 SkDVector fSweep[2]; |
| 132 SkOpSpanBase* fStart; | 122 SkOpSpanBase* fStart; |
| 133 SkOpSpanBase* fEnd; | 123 SkOpSpanBase* fEnd; |
| 134 SkOpSpanBase* fComputedEnd; | 124 SkOpSpanBase* fComputedEnd; |
| 135 int fSectorMask; | 125 int fSectorMask; |
| 136 int8_t fSectorStart; // in 32nds of a circle | 126 int8_t fSectorStart; // in 32nds of a circle |
| 137 int8_t fSectorEnd; | 127 int8_t fSectorEnd; |
| 138 bool fIsCurve; | 128 bool fIsCurve; |
| 139 bool fUnorderable; | 129 bool fUnorderable; |
| 140 bool fUnorderedSweep; // set when a cubic's first control point between the
sweep vectors | 130 bool fUnorderedSweep; // set when a cubic's first control point between the
sweep vectors |
| 141 bool fComputeSector; | 131 bool fComputeSector; |
| 142 bool fComputedSector; | 132 bool fComputedSector; |
| 143 bool fCheckCoincidence; | 133 bool fCheckCoincidence; |
| 144 SkDEBUGCODE(int fID); | 134 SkDEBUGCODE(int fID); |
| 145 | 135 |
| 136 friend class PathOpsAngleTester; |
| 146 }; | 137 }; |
| 147 | 138 |
| 148 | 139 |
| 149 | 140 |
| 150 #endif | 141 #endif |
| OLD | NEW |