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