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