blob: 00520ecf439173ea6372d41bb885c2c38851eba9 [file] [log] [blame]
caryclark@google.com07393ca2013-04-08 11:47:37 +00001/*
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
18class SkOpAngle {
19public:
20 bool operator<(const SkOpAngle& rh) const;
caryclark@google.comad65a3e2013-04-15 19:13:59 +000021
caryclark@google.com07393ca2013-04-08 11:47:37 +000022 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.comad65a3e2013-04-15 19:13:59 +000040
caryclark@google.com07393ca2013-04-08 11:47:37 +000041 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.comad65a3e2013-04-15 19:13:59 +000045
caryclark@google.com07393ca2013-04-08 11:47:37 +000046 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
80private:
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