Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: src/pathops/SkOpAngle.h

Issue 1002693002: pathops version two (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix arm 64 inspired coincident handling Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pathops/SkIntersections.cpp ('k') | src/pathops/SkOpAngle.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "SkLineParameters.h" 10 #include "SkLineParameters.h"
11 #if DEBUG_ANGLE
12 #include "SkString.h"
13 #endif
12 14
15 class SkOpContour;
16 class SkOpPtT;
13 class SkOpSegment; 17 class SkOpSegment;
14 struct SkOpSpan; 18 class SkOpSpanBase;
19 class SkOpSpan;
15 20
16 // sorting angles 21 struct SkOpAngle {
17 // given angles of {dx dy ddx ddy dddx dddy} sort them
18 class SkOpAngle {
19 public:
20 enum { kStackBasedCount = 8 }; // FIXME: determine what this should be
21 enum IncludeType { 22 enum IncludeType {
22 kUnaryWinding, 23 kUnaryWinding,
23 kUnaryXor, 24 kUnaryXor,
24 kBinarySingle, 25 kBinarySingle,
25 kBinaryOpp, 26 kBinaryOpp,
26 }; 27 };
27 28
29 bool after(SkOpAngle* test);
30 int allOnOneSide(const SkOpAngle* test);
31 bool checkCrossesZero() const;
32 void checkNearCoincidence();
33 bool checkParallel(SkOpAngle* );
34 bool computeSector();
35 int convexHullOverlaps(const SkOpAngle* ) const;
28 36
29 int end() const { 37 const SkOpAngle* debugAngle(int id) const;
38 SkOpContour* debugContour(int id);
39
40 int debugID() const {
41 return PATH_OPS_DEBUG_RELEASE(fID, -1);
42 }
43
44 #if DEBUG_SORT
45 void debugLoop() const;
46 #endif
47
48 #if DEBUG_ANGLE
49 SkString debugPart() const;
50 #endif
51 const SkOpPtT* debugPtT(int id) const;
52 const SkOpSegment* debugSegment(int id) const;
53 const SkOpSpanBase* debugSpan(int id) const;
54 void debugValidate() const;
55 void debugValidateNext() const; // in debug builds, verify that angle loop is uncorrupted
56 double distEndRatio(double dist) const;
57 // available to testing only
58 void dump() const;
59 void dumpCurves() const;
60 void dumpLoop() const;
61 void dumpOne(bool functionHeader) const;
62 void dumpTo(const SkOpSegment* fromSeg, const SkOpAngle* ) const;
63 void dumpTest() const;
64
65 SkOpSpanBase* end() const {
30 return fEnd; 66 return fEnd;
31 } 67 }
32 68
33 const SkOpAngle* findFirst() const; 69 bool endsIntersect(SkOpAngle* );
34 70 bool endToSide(const SkOpAngle* rh, bool* inside) const;
35 bool inLoop() const { 71 SkOpAngle* findFirst();
36 return !!fNext; 72 int findSector(SkPath::Verb verb, double x, double y) const;
37 } 73 SkOpGlobalState* globalState() const;
38
39 void insert(SkOpAngle* ); 74 void insert(SkOpAngle* );
40 bool isHorizontal() const; 75 SkOpSpanBase* lastMarked() const;
41 SkOpSpan* lastMarked() const; 76 bool loopContains(const SkOpAngle* ) const;
42 bool loopContains(const SkOpAngle& ) const;
43 int loopCount() const; 77 int loopCount() const;
44 void markStops(); 78 void markStops();
45 bool merge(SkOpAngle* ); 79 bool merge(SkOpAngle* );
80 double midT() const;
81 bool midToSide(const SkOpAngle* rh, bool* inside) const;
46 82
47 SkOpAngle* next() const { 83 SkOpAngle* next() const {
48 return fNext; 84 return fNext;
49 } 85 }
50 86
87 bool oppositePlanes(const SkOpAngle* rh) const;
88 bool orderable(SkOpAngle* rh); // false == this < rh ; true == this > rh
51 SkOpAngle* previous() const; 89 SkOpAngle* previous() const;
52 90
53 int sectorEnd() const { 91 int sectorEnd() const {
54 return fSectorEnd; 92 return fSectorEnd;
55 } 93 }
56 94
57 int sectorStart() const { 95 int sectorStart() const {
58 return fSectorStart; 96 return fSectorStart;
59 } 97 }
60 98
61 void set(const SkOpSegment* segment, int start, int end); 99 SkOpSegment* segment() const;
62 100
63 void setLastMarked(SkOpSpan* marked) { 101 void set(SkOpSpanBase* start, SkOpSpanBase* end);
102 void setCurveHullSweep();
103
104 void setID(int id) {
105 PATH_OPS_DEBUG_CODE(fID = id);
106 }
107
108 void setLastMarked(SkOpSpanBase* marked) {
64 fLastMarked = marked; 109 fLastMarked = marked;
65 } 110 }
66 111
67 SkOpSegment* segment() const { 112 void setSector();
68 return const_cast<SkOpSegment*>(fSegment); 113 void setSpans();
114 int sign() const;
115
116 SkOpSpanBase* start() const {
117 return fStart;
69 } 118 }
70 119
71 int sign() const { 120 SkOpSpan* starter();
72 return SkSign32(fStart - fEnd); 121 bool tangentsDiverge(const SkOpAngle* rh, double s0xt0) const;
73 }
74
75 bool small() const;
76
77 int start() const {
78 return fStart;
79 }
80 122
81 bool unorderable() const { 123 bool unorderable() const {
82 return fUnorderable; 124 return fUnorderable;
83 } 125 }
84 126
85 // available to testing only 127 SkDCubic fCurvePart; // the curve from start to end
86 #if DEBUG_SORT
87 void debugLoop() const; // called by code during run
88 #endif
89 #if DEBUG_ANGLE
90 void debugSameAs(const SkOpAngle* compare) const;
91 #endif
92 void dump() const;
93 void dumpLoop() const;
94 void dumpTo(const SkOpSegment* fromSeg, const SkOpAngle* ) const;
95
96 #if DEBUG_ANGLE
97 int debugID() const { return fID; }
98
99 void setID(int id) {
100 fID = id;
101 }
102 #else
103 int debugID() const { return 0; }
104 #endif
105
106 #if DEBUG_VALIDATE
107 void debugValidateLoop() const;
108 #endif
109
110 private:
111 bool after(const SkOpAngle* test) const;
112 int allOnOneSide(const SkOpAngle& test) const;
113 bool calcSlop(double x, double y, double rx, double ry, bool* result) const;
114 bool checkCrossesZero() const;
115 bool checkParallel(const SkOpAngle& ) const;
116 bool computeSector();
117 int convexHullOverlaps(const SkOpAngle& ) const;
118 double distEndRatio(double dist) const;
119 int findSector(SkPath::Verb verb, double x, double y) const;
120 bool endsIntersect(const SkOpAngle& ) const;
121 double midT() const;
122 bool oppositePlanes(const SkOpAngle& rh) const;
123 bool orderable(const SkOpAngle& rh) const; // false == this < rh ; true == this > rh
124 bool overlap(const SkOpAngle& test) const;
125 void setCurveHullSweep();
126 void setSector();
127 void setSpans();
128 bool tangentsDiverge(const SkOpAngle& rh, double s0xt0) const;
129
130 SkDCubic fCurvePart; // the curve from start to end
131 double fSide; 128 double fSide;
132 SkLineParameters fTangentHalf; // used only to sort a pair of lines or line -like sections 129 SkLineParameters fTangentHalf; // used only to sort a pair of lines or line -like sections
133 const SkOpSegment* fSegment;
134 SkOpAngle* fNext; 130 SkOpAngle* fNext;
135 SkOpSpan* fLastMarked; 131 SkOpSpanBase* fLastMarked;
136 SkDVector fSweep[2]; 132 SkDVector fSweep[2];
137 int fStart; 133 SkOpSpanBase* fStart;
138 int fEnd; 134 SkOpSpanBase* fEnd;
139 int fComputedEnd; 135 SkOpSpanBase* fComputedEnd;
140 int fSectorMask; 136 int fSectorMask;
141 int8_t fSectorStart; // in 32nds of a circle 137 int8_t fSectorStart; // in 32nds of a circle
142 int8_t fSectorEnd; 138 int8_t fSectorEnd;
143 bool fIsCurve; 139 bool fIsCurve;
144 bool fStop; // set if ordered angle is greater than the previous 140 bool fStop; // set if ordered angle is greater than the previous
145 mutable bool fUnorderable; // this is editable by orderable() 141 bool fUnorderable;
146 bool fUnorderedSweep; // set when a cubic's first control point between the sweep vectors 142 bool fUnorderedSweep; // set when a cubic's first control point between the sweep vectors
147 bool fComputeSector; 143 bool fComputeSector;
148 bool fComputedSector; 144 bool fComputedSector;
145 bool fCheckCoincidence;
146 PATH_OPS_DEBUG_CODE(int fID);
149 147
150 #if DEBUG_ANGLE
151 int fID;
152 #endif
153 #if DEBUG_VALIDATE
154 void debugValidateNext() const; // in debug builds, verify that angle loop is uncorrupted
155 #else
156 void debugValidateNext() const {}
157 #endif
158 void dumpOne(bool showFunc) const; // available to testing only
159 void dumpPartials() const; // utility to be called by user from debugger
160 friend class PathOpsAngleTester;
161 }; 148 };
162 149
163 class SkOpAngleSet { 150
164 public:
165 SkOpAngleSet();
166 ~SkOpAngleSet();
167 SkOpAngle& push_back();
168 void reset();
169 private:
170 void dump() const; // utility to be called by user from debugger
171 SkChunkAlloc* fAngles;
172 #if DEBUG_ANGLE
173 int fCount;
174 #endif
175 };
176 151
177 #endif 152 #endif
OLDNEW
« no previous file with comments | « src/pathops/SkIntersections.cpp ('k') | src/pathops/SkOpAngle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698