michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: #ifndef SkOpAngle_DEFINED michael@0: #define SkOpAngle_DEFINED michael@0: michael@0: #include "SkLineParameters.h" michael@0: #include "SkPath.h" michael@0: #include "SkPathOpsCubic.h" michael@0: michael@0: class SkOpSegment; michael@0: struct SkOpSpan; michael@0: michael@0: // sorting angles michael@0: // given angles of {dx dy ddx ddy dddx dddy} sort them michael@0: class SkOpAngle { michael@0: public: michael@0: enum { kStackBasedCount = 8 }; // FIXME: determine what this should be michael@0: enum IncludeType { michael@0: kUnaryWinding, michael@0: kUnaryXor, michael@0: kBinarySingle, michael@0: kBinaryOpp, michael@0: }; michael@0: michael@0: bool operator<(const SkOpAngle& rh) const; michael@0: michael@0: bool calcSlop(double x, double y, double rx, double ry, bool* result) const; michael@0: michael@0: double dx() const { michael@0: return fTangentPart.dx(); michael@0: } michael@0: michael@0: double dy() const { michael@0: return fTangentPart.dy(); michael@0: } michael@0: michael@0: int end() const { michael@0: return fEnd; michael@0: } michael@0: michael@0: bool isHorizontal() const; michael@0: michael@0: SkOpSpan* lastMarked() const { michael@0: return fLastMarked; michael@0: } michael@0: michael@0: void set(const SkOpSegment* segment, int start, int end); michael@0: michael@0: void setLastMarked(SkOpSpan* marked) { michael@0: fLastMarked = marked; michael@0: } michael@0: michael@0: SkOpSegment* segment() const { michael@0: return const_cast(fSegment); michael@0: } michael@0: michael@0: int sign() const { michael@0: return SkSign32(fStart - fEnd); michael@0: } michael@0: michael@0: int start() const { michael@0: return fStart; michael@0: } michael@0: michael@0: bool unorderable() const { michael@0: return fUnorderable; michael@0: } michael@0: michael@0: bool unsortable() const { michael@0: return fUnsortable; michael@0: } michael@0: michael@0: #ifdef SK_DEBUG michael@0: void dump() const; michael@0: #endif michael@0: michael@0: #if DEBUG_ANGLE michael@0: void setID(int id) { michael@0: fID = id; michael@0: } michael@0: #endif michael@0: michael@0: private: michael@0: bool lengthen(const SkOpAngle& ); michael@0: void setSpans(); michael@0: michael@0: SkDCubic fCurvePart; // the curve from start to end michael@0: SkDCubic fCurveHalf; // the curve from start to 1 or 0 michael@0: double fSide; michael@0: double fSide2; michael@0: SkLineParameters fTangentPart; michael@0: SkLineParameters fTangentHalf; michael@0: const SkOpSegment* fSegment; michael@0: SkOpSpan* fLastMarked; michael@0: int fStart; michael@0: int fEnd; michael@0: bool fComputed; // tangent is computed, may contain some error michael@0: // if subdividing a quad or cubic causes the tangent to go from the maximum angle to the michael@0: // minimum, mark it unorderable. It still can be sorted, which is good enough for find-top michael@0: // but can't be ordered, and therefore can't be used to compute winding michael@0: bool fUnorderable; michael@0: mutable bool fUnsortable; // this alone is editable by the less than operator michael@0: #if DEBUG_ANGLE michael@0: int fID; michael@0: #endif michael@0: }; michael@0: michael@0: #endif