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 "SkOpSpan.h" | 11 #include "SkOpSpan.h" |
12 #include "SkPath.h" | 12 #include "SkPath.h" |
13 #include "SkPathOpsCubic.h" | 13 #include "SkPathOpsCubic.h" |
14 #include "SkTDArray.h" | 14 #include "SkTDArray.h" |
15 | 15 |
| 16 class SkOpSegment; |
| 17 |
16 // sorting angles | 18 // sorting angles |
17 // given angles of {dx dy ddx ddy dddx dddy} sort them | 19 // given angles of {dx dy ddx ddy dddx dddy} sort them |
18 class SkOpAngle { | 20 class SkOpAngle { |
19 public: | 21 public: |
20 bool operator<(const SkOpAngle& rh) const; | 22 bool operator<(const SkOpAngle& rh) const; |
21 | 23 |
22 double dx() const { | 24 double dx() const { |
23 return fTangent1.dx(); | 25 return fTangent1.dx(); |
24 } | 26 } |
25 | 27 |
26 double dy() const { | 28 double dy() const { |
27 return fTangent1.dy(); | 29 return fTangent1.dy(); |
28 } | 30 } |
29 | 31 |
30 int end() const { | 32 int end() const { |
31 return fEnd; | 33 return fEnd; |
32 } | 34 } |
33 | 35 |
34 bool isHorizontal() const { | 36 bool isHorizontal() const; |
35 return dy() == 0 && fVerb == SkPath::kLine_Verb; | |
36 } | |
37 | |
38 bool lengthen(); | 37 bool lengthen(); |
39 bool reverseLengthen(); | 38 bool reverseLengthen(); |
40 | 39 |
41 void set(const SkPoint* orig, SkPath::Verb verb, const SkOpSegment* segment, | 40 void set(const SkPoint* orig, SkPath::Verb verb, const SkOpSegment* segment, |
42 int start, int end, const SkTDArray<SkOpSpan>& spans); | 41 int start, int end, const SkTDArray<SkOpSpan>& spans); |
43 | 42 |
44 void setSpans(); | 43 void setSpans(); |
45 | 44 |
46 SkOpSegment* segment() const { | 45 SkOpSegment* segment() const { |
47 return const_cast<SkOpSegment*>(fSegment); | 46 return const_cast<SkOpSegment*>(fSegment); |
48 } | 47 } |
49 | 48 |
50 int sign() const { | 49 int sign() const { |
51 return SkSign32(fStart - fEnd); | 50 return SkSign32(fStart - fEnd); |
52 } | 51 } |
53 | 52 |
54 const SkTDArray<SkOpSpan>* spans() const { | |
55 return fSpans; | |
56 } | |
57 | |
58 int start() const { | 53 int start() const { |
59 return fStart; | 54 return fStart; |
60 } | 55 } |
61 | 56 |
62 bool unsortable() const { | 57 bool unsortable() const { |
63 return fUnsortable; | 58 return fUnsortable; |
64 } | 59 } |
65 | 60 |
66 #if DEBUG_ANGLE | 61 #if DEBUG_ANGLE |
67 const SkPoint* pts() const { | |
68 return fPts; | |
69 } | |
70 | |
71 SkPath::Verb verb() const { | |
72 return fVerb; | |
73 } | |
74 | |
75 void debugShow(const SkPoint& a) const { | 62 void debugShow(const SkPoint& a) const { |
76 SkDebugf(" d=(%1.9g,%1.9g) side=%1.9g\n", dx(), dy(), fSide); | 63 SkDebugf(" d=(%1.9g,%1.9g) side=%1.9g\n", dx(), dy(), fSide); |
77 } | 64 } |
78 #endif | 65 #endif |
79 | 66 |
80 private: | 67 private: |
81 const SkPoint* fPts; | |
82 SkDCubic fCurvePart; | 68 SkDCubic fCurvePart; |
83 SkPath::Verb fVerb; | |
84 double fSide; | 69 double fSide; |
85 SkLineParameters fTangent1; | 70 SkLineParameters fTangent1; |
86 const SkTDArray<SkOpSpan>* fSpans; | |
87 const SkOpSegment* fSegment; | 71 const SkOpSegment* fSegment; |
88 int fStart; | 72 int fStart; |
89 int fEnd; | 73 int fEnd; |
90 bool fReversed; | 74 bool fReversed; |
91 mutable bool fUnsortable; // this alone is editable by the less than operat
or | 75 mutable bool fUnsortable; // this alone is editable by the less than operat
or |
92 }; | 76 }; |
93 | 77 |
94 #endif | 78 #endif |
OLD | NEW |