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

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

Issue 13094010: Add implementation of path ops (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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/SkAddIntersections.cpp ('k') | src/pathops/SkIntersectionHelper.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "SkOpContour.h"
8 #include "SkPath.h"
9
10 class SkIntersectionHelper {
11 public:
12 enum SegmentType {
13 kHorizontalLine_Segment = -1,
14 kVerticalLine_Segment = 0,
15 kLine_Segment = SkPath::kLine_Verb,
16 kQuad_Segment = SkPath::kQuad_Verb,
17 kCubic_Segment = SkPath::kCubic_Verb,
18 };
19
20 void addCoincident(SkIntersectionHelper& other, const SkIntersections& ts, b ool swap) {
21 fContour->addCoincident(fIndex, other.fContour, other.fIndex, ts, swap);
22 }
23
24 // FIXME: does it make sense to write otherIndex now if we're going to
25 // fix it up later?
26 void addOtherT(int index, double otherT, int otherIndex) {
27 fContour->addOtherT(fIndex, index, otherT, otherIndex);
28 }
29
30 // Avoid collapsing t values that are close to the same since
31 // we walk ts to describe consecutive intersections. Since a pair of ts can
32 // be nearly equal, any problems caused by this should be taken care
33 // of later.
34 // On the edge or out of range values are negative; add 2 to get end
35 int addT(const SkIntersectionHelper& other, const SkPoint& pt, double newT) {
36 return fContour->addT(fIndex, other.fContour, other.fIndex, pt, newT);
37 }
38
39 int addSelfT(const SkIntersectionHelper& other, const SkPoint& pt, double ne wT) {
40 return fContour->addSelfT(fIndex, other.fContour, other.fIndex, pt, newT );
41 }
42
43 int addUnsortableT(const SkIntersectionHelper& other, bool start, const SkPo int& pt,
44 double newT) {
45 return fContour->addUnsortableT(fIndex, other.fContour, other.fIndex, st art, pt, newT);
46 }
47
48 bool advance() {
49 return ++fIndex < fLast;
50 }
51
52 SkScalar bottom() const {
53 return bounds().fBottom;
54 }
55
56 const SkPathOpsBounds& bounds() const {
57 return fContour->segments()[fIndex].bounds();
58 }
59
60 void init(SkOpContour* contour) {
61 fContour = contour;
62 fIndex = 0;
63 fLast = contour->segments().count();
64 }
65
66 bool isAdjacent(const SkIntersectionHelper& next) {
67 return fContour == next.fContour && fIndex + 1 == next.fIndex;
68 }
69
70 bool isFirstLast(const SkIntersectionHelper& next) {
71 return fContour == next.fContour && fIndex == 0
72 && next.fIndex == fLast - 1;
73 }
74
75 SkScalar left() const {
76 return bounds().fLeft;
77 }
78
79 const SkPoint* pts() const {
80 return fContour->segments()[fIndex].pts();
81 }
82
83 SkScalar right() const {
84 return bounds().fRight;
85 }
86
87 ptrdiff_t segmentIndex() const {
88 return fIndex;
89 }
90
91 SegmentType segmentType() const {
92 const SkOpSegment& segment = fContour->segments()[fIndex];
93 SegmentType type = (SegmentType) segment.verb();
94 if (type != kLine_Segment) {
95 return type;
96 }
97 if (segment.isHorizontal()) {
98 return kHorizontalLine_Segment;
99 }
100 if (segment.isVertical()) {
101 return kVerticalLine_Segment;
102 }
103 return kLine_Segment;
104 }
105
106 bool startAfter(const SkIntersectionHelper& after) {
107 fIndex = after.fIndex;
108 return advance();
109 }
110
111 SkScalar top() const {
112 return bounds().fTop;
113 }
114
115 SkPath::Verb verb() const {
116 return fContour->segments()[fIndex].verb();
117 }
118
119 SkScalar x() const {
120 return bounds().fLeft;
121 }
122
123 bool xFlipped() const {
124 return x() != pts()[0].fX;
125 }
126
127 SkScalar y() const {
128 return bounds().fTop;
129 }
130
131 bool yFlipped() const {
132 return y() != pts()[0].fY;
133 }
134
135 private:
136 SkOpContour* fContour;
137 int fIndex;
138 int fLast;
139 };
OLDNEW
« no previous file with comments | « src/pathops/SkAddIntersections.cpp ('k') | src/pathops/SkIntersectionHelper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698