2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
7 #ifndef SkOpAngle_DEFINED
8 #define SkOpAngle_DEFINED
10 #include "SkLineParameters.h"
16 // given angles of {dx dy ddx ddy dddx dddy} sort them
19 enum { kStackBasedCount = 8 }; // FIXME: determine what this should be
32 const SkOpAngle* findFirst() const;
38 void insert(SkOpAngle* );
39 bool isHorizontal() const;
40 SkOpSpan* lastMarked() const;
41 bool loopContains(const SkOpAngle& ) const;
42 int loopCount() const;
44 bool merge(SkOpAngle* );
46 SkOpAngle* next() const {
50 SkOpAngle* previous() const;
52 void set(const SkOpSegment* segment, int start, int end);
54 void setLastMarked(SkOpSpan* marked) {
58 SkOpSegment* segment() const {
59 return const_cast<SkOpSegment*>(fSegment);
63 return SkSign32(fStart - fEnd);
72 bool unorderable() const {
76 // available to testing only
78 void debugLoop() const; // called by code during run
81 void debugSameAs(const SkOpAngle* compare) const;
84 void dumpFromTo(const SkOpSegment* fromSeg, int from, int to) const;
92 void debugValidateLoop() const;
96 bool after(const SkOpAngle* test) const;
97 int allOnOneSide(const SkOpAngle& test) const;
98 bool calcSlop(double x, double y, double rx, double ry, bool* result) const;
99 bool checkCrossesZero() const;
100 bool checkParallel(const SkOpAngle& ) const;
101 bool computeSector();
102 int convexHullOverlaps(const SkOpAngle& ) const;
103 double distEndRatio(double dist) const;
104 int findSector(SkPath::Verb verb, double x, double y) const;
105 bool endsIntersect(const SkOpAngle& ) const;
107 bool oppositePlanes(const SkOpAngle& rh) const;
108 bool orderable(const SkOpAngle& rh) const; // false == this < rh ; true == this > rh
109 bool overlap(const SkOpAngle& test) const;
110 void setCurveHullSweep();
113 bool tangentsDiverge(const SkOpAngle& rh, double s0xt0) const;
115 SkDCubic fCurvePart; // the curve from start to end
117 SkLineParameters fTangentHalf; // used only to sort a pair of lines or line-like sections
118 const SkOpSegment* fSegment;
120 SkOpSpan* fLastMarked;
125 int8_t fSectorStart; // in 32nds of a circle
128 bool fStop; // set if ordered angle is greater than the previous
129 mutable bool fUnorderable; // this is editable by orderable()
130 bool fUnorderedSweep; // set when a cubic's first control point between the sweep vectors
132 bool fComputedSector;
135 void debugOne(bool showFunc) const; // available to testing only
138 int debugID() const { return fID; }
142 void debugValidateNext() const; // in debug builds, verify that angle loop is uncorrupted
144 void debugValidateNext() const {}
146 void dumpLoop() const; // utility to be called by user from debugger
147 void dumpPartials() const; // utility to be called by user from debugger
148 friend class PathOpsAngleTester;