aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pathops/SkIntersectionHelper.h
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-03-24 13:55:33 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-24 13:55:33 -0700
commit0dc4dd6dda9a7912f696b46d9c02155ec1d1ba5f (patch)
tree994c85a8e418986415175ddccc71adf924df3846 /src/pathops/SkIntersectionHelper.h
parent82dec0e16ae10026194ce45b67af931700510450 (diff)
Revert of pathops version two (patchset #16 id:150001 of https://codereview.chromium.org/1002693002/)
Reason for revert: ASAN investigation Original issue's description: > pathops version two > > R=reed@google.com > > marked 'no commit' to attempt to get trybots to run > > TBR=reed@google.com > > Committed: https://skia.googlesource.com/skia/+/ccec0f958ffc71a9986d236bc2eb335cb2111119 TBR=caryclark@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1029993002
Diffstat (limited to 'src/pathops/SkIntersectionHelper.h')
-rw-r--r--src/pathops/SkIntersectionHelper.h91
1 files changed, 72 insertions, 19 deletions
diff --git a/src/pathops/SkIntersectionHelper.h b/src/pathops/SkIntersectionHelper.h
index c633fd02df..3569c934de 100644
--- a/src/pathops/SkIntersectionHelper.h
+++ b/src/pathops/SkIntersectionHelper.h
@@ -5,7 +5,6 @@
* found in the LICENSE file.
*/
#include "SkOpContour.h"
-#include "SkOpSegment.h"
#include "SkPath.h"
#ifdef SK_DEBUG
@@ -22,9 +21,42 @@ public:
kCubic_Segment = SkPath::kCubic_Verb,
};
+ bool addCoincident(SkIntersectionHelper& other, const SkIntersections& ts, bool swap) {
+ return fContour->addCoincident(fIndex, other.fContour, other.fIndex, ts, swap);
+ }
+
+ // FIXME: does it make sense to write otherIndex now if we're going to
+ // fix it up later?
+ void addOtherT(int index, double otherT, int otherIndex) {
+ fContour->addOtherT(fIndex, index, otherT, otherIndex);
+ }
+
+ bool addPartialCoincident(SkIntersectionHelper& other, const SkIntersections& ts, int index,
+ bool swap) {
+ return fContour->addPartialCoincident(fIndex, other.fContour, other.fIndex, ts, index,
+ swap);
+ }
+
+ // Avoid collapsing t values that are close to the same since
+ // we walk ts to describe consecutive intersections. Since a pair of ts can
+ // be nearly equal, any problems caused by this should be taken care
+ // of later.
+ // On the edge or out of range values are negative; add 2 to get end
+ int addT(const SkIntersectionHelper& other, const SkPoint& pt, double newT) {
+ return fContour->addT(fIndex, other.fContour, other.fIndex, pt, newT);
+ }
+
+ int addSelfT(const SkPoint& pt, double newT) {
+ return fContour->addSelfT(fIndex, pt, newT);
+ }
+
bool advance() {
- fSegment = fSegment->next();
- return fSegment != NULL;
+ return ++fIndex < fLast;
+ }
+
+ void alignTPt(SkIntersectionHelper& other, bool swap, int index,
+ SkIntersections* ts, SkPoint* point) {
+ fContour->alignTPt(fIndex, other.fContour, other.fIndex, swap, index, ts, point);
}
SkScalar bottom() const {
@@ -32,15 +64,30 @@ public:
}
const SkPathOpsBounds& bounds() const {
- return fSegment->bounds();
+ return fContour->segments()[fIndex].bounds();
}
- SkOpContour* contour() const {
- return fSegment->contour();
+ void init(SkOpContour* contour) {
+ fContour = contour;
+ fIndex = 0;
+ fLast = contour->segments().count();
}
- void init(SkOpContour* contour) {
- fSegment = contour->first();
+ bool isAdjacent(const SkIntersectionHelper& next) {
+ return fContour == next.fContour && fIndex + 1 == next.fIndex;
+ }
+
+ bool isFirstLast(const SkIntersectionHelper& next) {
+ return fContour == next.fContour && fIndex == 0
+ && next.fIndex == fLast - 1;
+ }
+
+ bool isPartial(double t1, double t2, const SkDPoint& pt1, const SkDPoint& pt2) const {
+ const SkOpSegment& segment = fContour->segments()[fIndex];
+ double mid = (t1 + t2) / 2;
+ SkDPoint midPtByT = segment.dPtAtT(mid);
+ SkDPoint midPtByAvg = SkDPoint::Mid(pt1, pt2);
+ return midPtByT.approximatelyPEqual(midPtByAvg);
}
SkScalar left() const {
@@ -48,40 +95,41 @@ public:
}
const SkPoint* pts() const {
- return fSegment->pts();
+ return fContour->segments()[fIndex].pts();
}
SkScalar right() const {
return bounds().fRight;
}
- SkOpSegment* segment() const {
- return fSegment;
- }
-
SegmentType segmentType() const {
- SegmentType type = (SegmentType) fSegment->verb();
+ const SkOpSegment& segment = fContour->segments()[fIndex];
+ SegmentType type = (SegmentType) segment.verb();
if (type != kLine_Segment) {
return type;
}
- if (fSegment->isHorizontal()) {
+ if (segment.isHorizontal()) {
return kHorizontalLine_Segment;
}
- if (fSegment->isVertical()) {
+ if (segment.isVertical()) {
return kVerticalLine_Segment;
}
return kLine_Segment;
}
bool startAfter(const SkIntersectionHelper& after) {
- fSegment = after.fSegment->next();
- return fSegment != NULL;
+ fIndex = after.fIndex;
+ return advance();
}
SkScalar top() const {
return bounds().fTop;
}
+ SkPath::Verb verb() const {
+ return fContour->segments()[fIndex].verb();
+ }
+
SkScalar x() const {
return bounds().fLeft;
}
@@ -99,5 +147,10 @@ public:
}
private:
- SkOpSegment* fSegment;
+ // utility callable by the user from the debugger when the implementation code is linked in
+ void dump() const;
+
+ SkOpContour* fContour;
+ int fIndex;
+ int fLast;
};