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 "SkLineParameters.h" | 10 #include "SkLineParameters.h" |
11 #include "SkPath.h" | 11 #include "SkPath.h" |
12 #include "SkPathOpsCubic.h" | 12 #include "SkPathOpsCubic.h" |
13 | 13 |
14 class SkOpSegment; | 14 class SkOpSegment; |
| 15 struct SkOpSpan; |
15 | 16 |
16 // sorting angles | 17 // sorting angles |
17 // given angles of {dx dy ddx ddy dddx dddy} sort them | 18 // given angles of {dx dy ddx ddy dddx dddy} sort them |
18 class SkOpAngle { | 19 class SkOpAngle { |
19 public: | 20 public: |
20 enum { kStackBasedCount = 8 }; // FIXME: determine what this should be | 21 enum { kStackBasedCount = 8 }; // FIXME: determine what this should be |
| 22 enum IncludeType { |
| 23 kUnaryWinding, |
| 24 kUnaryXor, |
| 25 kBinarySingle, |
| 26 kBinaryOpp, |
| 27 }; |
21 | 28 |
22 bool operator<(const SkOpAngle& rh) const; | 29 bool operator<(const SkOpAngle& rh) const; |
23 | 30 |
24 bool calcSlop(double x, double y, double rx, double ry, bool* result) const; | 31 bool calcSlop(double x, double y, double rx, double ry, bool* result) const; |
25 | 32 |
26 double dx() const { | 33 double dx() const { |
27 return fTangent1.dx(); | 34 return fTangentPart.dx(); |
28 } | 35 } |
29 | 36 |
30 double dy() const { | 37 double dy() const { |
31 return fTangent1.dy(); | 38 return fTangentPart.dy(); |
32 } | 39 } |
33 | 40 |
34 int end() const { | 41 int end() const { |
35 return fEnd; | 42 return fEnd; |
36 } | 43 } |
37 | 44 |
38 bool isHorizontal() const; | 45 bool isHorizontal() const; |
39 | 46 |
| 47 SkOpSpan* lastMarked() const { |
| 48 return fLastMarked; |
| 49 } |
| 50 |
40 void set(const SkOpSegment* segment, int start, int end); | 51 void set(const SkOpSegment* segment, int start, int end); |
41 | 52 |
| 53 void setLastMarked(SkOpSpan* marked) { |
| 54 fLastMarked = marked; |
| 55 } |
| 56 |
42 SkOpSegment* segment() const { | 57 SkOpSegment* segment() const { |
43 return const_cast<SkOpSegment*>(fSegment); | 58 return const_cast<SkOpSegment*>(fSegment); |
44 } | 59 } |
45 | 60 |
46 int sign() const { | 61 int sign() const { |
47 return SkSign32(fStart - fEnd); | 62 return SkSign32(fStart - fEnd); |
48 } | 63 } |
49 | 64 |
50 int start() const { | 65 int start() const { |
51 return fStart; | 66 return fStart; |
52 } | 67 } |
53 | 68 |
54 bool unorderable() const { | 69 bool unorderable() const { |
55 return fUnorderable; | 70 return fUnorderable; |
56 } | 71 } |
57 | 72 |
58 bool unsortable() const { | 73 bool unsortable() const { |
59 return fUnsortable; | 74 return fUnsortable; |
60 } | 75 } |
61 | 76 |
| 77 #ifdef SK_DEBUG |
| 78 void dump() const; |
| 79 #endif |
| 80 |
62 #if DEBUG_ANGLE | 81 #if DEBUG_ANGLE |
63 void debugShow(const SkPoint& a) const { | |
64 SkDebugf(" d=(%1.9g,%1.9g) side=%1.9g\n", dx(), dy(), fSide); | |
65 } | |
66 | |
67 void setID(int id) { | 82 void setID(int id) { |
68 fID = id; | 83 fID = id; |
69 } | 84 } |
70 #endif | 85 #endif |
71 | 86 |
72 private: | 87 private: |
73 bool lengthen(const SkOpAngle& ); | 88 bool lengthen(const SkOpAngle& ); |
74 void setSpans(); | 89 void setSpans(); |
75 | 90 |
76 SkDCubic fCurvePart; | 91 SkDCubic fCurvePart; // the curve from start to end |
| 92 SkDCubic fCurveHalf; // the curve from start to 1 or 0 |
77 double fSide; | 93 double fSide; |
78 SkLineParameters fTangent1; | 94 double fSide2; |
| 95 SkLineParameters fTangentPart; |
| 96 SkLineParameters fTangentHalf; |
79 const SkOpSegment* fSegment; | 97 const SkOpSegment* fSegment; |
| 98 SkOpSpan* fLastMarked; |
80 int fStart; | 99 int fStart; |
81 int fEnd; | 100 int fEnd; |
82 bool fComputed; // tangent is computed, may contain some error | 101 bool fComputed; // tangent is computed, may contain some error |
83 // if subdividing a quad or cubic causes the tangent to go from the maximum
angle to the | 102 // if subdividing a quad or cubic causes the tangent to go from the maximum
angle to the |
84 // minimum, mark it unorderable. It still can be sorted, which is good enoug
h for find-top | 103 // minimum, mark it unorderable. It still can be sorted, which is good enoug
h for find-top |
85 // but can't be ordered, and therefore can't be used to compute winding | 104 // but can't be ordered, and therefore can't be used to compute winding |
86 bool fUnorderable; | 105 bool fUnorderable; |
87 mutable bool fUnsortable; // this alone is editable by the less than operat
or | 106 mutable bool fUnsortable; // this alone is editable by the less than operat
or |
88 #if DEBUG_ANGLE | 107 #if DEBUG_ANGLE |
89 int fID; | 108 int fID; |
90 #endif | 109 #endif |
91 }; | 110 }; |
92 | 111 |
93 #endif | 112 #endif |
OLD | NEW |