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 "SkChunkAlloc.h" |
10 #include "SkLineParameters.h" | 11 #include "SkLineParameters.h" |
11 | 12 |
12 class SkOpSegment; | 13 class SkOpSegment; |
13 struct SkOpSpan; | 14 struct SkOpSpan; |
14 | 15 |
15 // sorting angles | 16 // sorting angles |
16 // given angles of {dx dy ddx ddy dddx dddy} sort them | 17 // given angles of {dx dy ddx ddy dddx dddy} sort them |
17 class SkOpAngle { | 18 class SkOpAngle { |
18 public: | 19 public: |
19 enum { kStackBasedCount = 8 }; // FIXME: determine what this should be | 20 enum { kStackBasedCount = 8 }; // FIXME: determine what this should be |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 75 } |
75 | 76 |
76 // available to testing only | 77 // available to testing only |
77 #if DEBUG_SORT | 78 #if DEBUG_SORT |
78 void debugLoop() const; // called by code during run | 79 void debugLoop() const; // called by code during run |
79 #endif | 80 #endif |
80 #if DEBUG_ANGLE | 81 #if DEBUG_ANGLE |
81 void debugSameAs(const SkOpAngle* compare) const; | 82 void debugSameAs(const SkOpAngle* compare) const; |
82 #endif | 83 #endif |
83 void dump() const; | 84 void dump() const; |
84 void dumpFromTo(const SkOpSegment* fromSeg, int from, int to) const; | 85 void dumpLoop() const; |
| 86 void dumpTo(const SkOpSegment* fromSeg, const SkOpAngle* ) const; |
85 | 87 |
86 #if DEBUG_ANGLE | 88 #if DEBUG_ANGLE |
| 89 int debugID() const { return fID; } |
| 90 |
87 void setID(int id) { | 91 void setID(int id) { |
88 fID = id; | 92 fID = id; |
89 } | 93 } |
| 94 #else |
| 95 int debugID() const { return 0; } |
90 #endif | 96 #endif |
| 97 |
91 #if DEBUG_VALIDATE | 98 #if DEBUG_VALIDATE |
92 void debugValidateLoop() const; | 99 void debugValidateLoop() const; |
93 #endif | 100 #endif |
94 | 101 |
95 private: | 102 private: |
96 bool after(const SkOpAngle* test) const; | 103 bool after(const SkOpAngle* test) const; |
97 int allOnOneSide(const SkOpAngle& test) const; | 104 int allOnOneSide(const SkOpAngle& test) const; |
98 bool calcSlop(double x, double y, double rx, double ry, bool* result) const; | 105 bool calcSlop(double x, double y, double rx, double ry, bool* result) const; |
99 bool checkCrossesZero() const; | 106 bool checkCrossesZero() const; |
100 bool checkParallel(const SkOpAngle& ) const; | 107 bool checkParallel(const SkOpAngle& ) const; |
(...skipping 13 matching lines...) Expand all Loading... |
114 | 121 |
115 SkDCubic fCurvePart; // the curve from start to end | 122 SkDCubic fCurvePart; // the curve from start to end |
116 double fSide; | 123 double fSide; |
117 SkLineParameters fTangentHalf; // used only to sort a pair of lines or line
-like sections | 124 SkLineParameters fTangentHalf; // used only to sort a pair of lines or line
-like sections |
118 const SkOpSegment* fSegment; | 125 const SkOpSegment* fSegment; |
119 SkOpAngle* fNext; | 126 SkOpAngle* fNext; |
120 SkOpSpan* fLastMarked; | 127 SkOpSpan* fLastMarked; |
121 SkDVector fSweep[2]; | 128 SkDVector fSweep[2]; |
122 int fStart; | 129 int fStart; |
123 int fEnd; | 130 int fEnd; |
| 131 int fComputedEnd; |
124 int fSectorMask; | 132 int fSectorMask; |
125 int8_t fSectorStart; // in 32nds of a circle | 133 int8_t fSectorStart; // in 32nds of a circle |
126 int8_t fSectorEnd; | 134 int8_t fSectorEnd; |
127 bool fIsCurve; | 135 bool fIsCurve; |
128 bool fStop; // set if ordered angle is greater than the previous | 136 bool fStop; // set if ordered angle is greater than the previous |
129 mutable bool fUnorderable; // this is editable by orderable() | 137 mutable bool fUnorderable; // this is editable by orderable() |
130 bool fUnorderedSweep; // set when a cubic's first control point between the
sweep vectors | 138 bool fUnorderedSweep; // set when a cubic's first control point between the
sweep vectors |
131 bool fComputeSector; | 139 bool fComputeSector; |
132 bool fComputedSector; | 140 bool fComputedSector; |
133 | 141 |
134 #if DEBUG_SORT | |
135 void debugOne(bool showFunc) const; // available to testing only | |
136 #endif | |
137 #if DEBUG_ANGLE | 142 #if DEBUG_ANGLE |
138 int debugID() const { return fID; } | |
139 int fID; | 143 int fID; |
140 #endif | 144 #endif |
141 #if DEBUG_VALIDATE | 145 #if DEBUG_VALIDATE |
142 void debugValidateNext() const; // in debug builds, verify that angle loop
is uncorrupted | 146 void debugValidateNext() const; // in debug builds, verify that angle loop
is uncorrupted |
143 #else | 147 #else |
144 void debugValidateNext() const {} | 148 void debugValidateNext() const {} |
145 #endif | 149 #endif |
146 void dumpLoop() const; // utility to be called by user from debugger | 150 void dumpOne(bool showFunc) const; // available to testing only |
147 void dumpPartials() const; // utility to be called by user from debugger | 151 void dumpPartials() const; // utility to be called by user from debugger |
148 friend class PathOpsAngleTester; | 152 friend class PathOpsAngleTester; |
149 }; | 153 }; |
150 | 154 |
| 155 class SkOpAngleSet { |
| 156 public: |
| 157 SkOpAngleSet(); |
| 158 ~SkOpAngleSet(); |
| 159 SkOpAngle& push_back(); |
| 160 void reset(); |
| 161 private: |
| 162 void dump() const; // utility to be called by user from debugger |
| 163 #if DEBUG_ANGLE |
| 164 int fCount; |
151 #endif | 165 #endif |
| 166 SkChunkAlloc* fAngles; |
| 167 }; |
| 168 |
| 169 #endif |
OLD | NEW |