Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: src/pathops/SkOpAngle.h

Issue 15338003: path ops -- rewrite angle sort (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/pathops/SkLineParameters.h ('k') | src/pathops/SkOpAngle.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
12 #include "SkPath.h" 11 #include "SkPath.h"
13 #include "SkPathOpsCubic.h" 12 #include "SkPathOpsCubic.h"
14 #include "SkTDArray.h" 13
14 class SkOpSegment;
15 15
16 // sorting angles 16 // sorting angles
17 // given angles of {dx dy ddx ddy dddx dddy} sort them 17 // given angles of {dx dy ddx ddy dddx dddy} sort them
18 class SkOpAngle { 18 class SkOpAngle {
19 public: 19 public:
20 bool operator<(const SkOpAngle& rh) const; 20 bool operator<(const SkOpAngle& rh) const;
21 21
22 bool calcSlop(double x, double y, double rx, double ry, bool* result) const;
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 37
38 bool lengthen(); 38 void set(const SkOpSegment* segment, int start, int end);
39 bool reverseLengthen();
40
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();
45 39
46 SkOpSegment* segment() const { 40 SkOpSegment* segment() const {
47 return const_cast<SkOpSegment*>(fSegment); 41 return const_cast<SkOpSegment*>(fSegment);
48 } 42 }
49 43
50 int sign() const { 44 int sign() const {
51 return SkSign32(fStart - fEnd); 45 return SkSign32(fStart - fEnd);
52 } 46 }
53 47
54 const SkTDArray<SkOpSpan>* spans() const {
55 return fSpans;
56 }
57
58 int start() const { 48 int start() const {
59 return fStart; 49 return fStart;
60 } 50 }
61 51
52 bool unorderable() const {
53 return fUnorderable;
54 }
55
62 bool unsortable() const { 56 bool unsortable() const {
63 return fUnsortable; 57 return fUnsortable;
64 } 58 }
65 59
66 #if DEBUG_ANGLE 60 #if DEBUG_ANGLE
67 const SkPoint* pts() const { 61 void debugShow(const SkPoint& a) const {
68 return fPts; 62 SkDebugf(" d=(%1.9g,%1.9g) side=%1.9g\n", dx(), dy(), fSide);
69 } 63 }
70 64
71 SkPath::Verb verb() const { 65 void setID(int id) {
72 return fVerb; 66 fID = id;
73 }
74
75 void debugShow(const SkPoint& a) const {
76 SkDebugf(" d=(%1.9g,%1.9g) side=%1.9g\n", dx(), dy(), fSide);
77 } 67 }
78 #endif 68 #endif
79 69
80 private: 70 private:
81 const SkPoint* fPts; 71 bool lengthen(const SkOpAngle& );
72 void setSpans();
73
82 SkDCubic fCurvePart; 74 SkDCubic fCurvePart;
83 SkPath::Verb fVerb;
84 double fSide; 75 double fSide;
85 SkLineParameters fTangent1; 76 SkLineParameters fTangent1;
86 const SkTDArray<SkOpSpan>* fSpans;
87 const SkOpSegment* fSegment; 77 const SkOpSegment* fSegment;
88 int fStart; 78 int fStart;
89 int fEnd; 79 int fEnd;
90 bool fReversed; 80 bool fComputed; // tangent is computed, may contain some error
81 // if subdividing a quad or cubic causes the tangent to go from the maximum angle to the
82 // minimum, mark it unorderable. It still can be sorted, which is good enoug h for find-top
83 // but can't be ordered, and therefore can't be used to compute winding
84 bool fUnorderable;
91 mutable bool fUnsortable; // this alone is editable by the less than operat or 85 mutable bool fUnsortable; // this alone is editable by the less than operat or
86 #if DEBUG_ANGLE
87 int fID;
88 #endif
92 }; 89 };
93 90
94 #endif 91 #endif
OLDNEW
« no previous file with comments | « src/pathops/SkLineParameters.h ('k') | src/pathops/SkOpAngle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698