aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pathops/SkOpContour.h
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-14 17:08:59 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-14 17:08:59 +0000
commit4431e7757cfcb8cfa99535eed0e9f156dabf95c2 (patch)
treef5939d4bb12b64c6953c8bae3ea684791565ca7f /src/pathops/SkOpContour.h
parent95f79261addecd8c3b4e64f2f1469f9e1aa0acb2 (diff)
Mike R: please sanity check SkPostConfig.h
Mike K: please sanity check Test.cpp and skia_test.cpp Feel free to look at the rest, but I don't expect any in depth review of path ops innards. Path Ops first iteration used QuickSort to order segments radiating from an intersection to compute the winding rule. This revision uses a circular sort instead. Breaking out the circular sort into its own long-lived structure (SkOpAngle) allows doing less work and provides a home for caching additional sorting data. The circle sort is more stable than the former sort, has a robust ordering and fewer exceptions. It finds unsortable ordering less often. It is less reliant on the initial curve tangent, using convex hulls instead whenever it can. Additional debug validation makes sure that the computed structures are self-consistent. A new visualization tool helps verify that the angle ordering is correct. The 70+M tests pass with this change on Windows, Mac, Linux 32 and Linux 64 in debug and release. R=mtklein@google.com, reed@google.com Author: caryclark@google.com Review URL: https://codereview.chromium.org/131103009 git-svn-id: http://skia.googlecode.com/svn/trunk@14183 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pathops/SkOpContour.h')
-rw-r--r--src/pathops/SkOpContour.h54
1 files changed, 49 insertions, 5 deletions
diff --git a/src/pathops/SkOpContour.h b/src/pathops/SkOpContour.h
index 8cedab4cb1..5b92a4b071 100644
--- a/src/pathops/SkOpContour.h
+++ b/src/pathops/SkOpContour.h
@@ -25,7 +25,7 @@ class SkOpContour {
public:
SkOpContour() {
reset();
-#ifdef SK_DEBUG
+#if defined(SK_DEBUG) || !FORCE_RELEASE
fID = ++SkPathOpsDebug::gContourID;
#endif
}
@@ -77,18 +77,29 @@ public:
return fSegments[segIndex].addT(&other->fSegments[otherIndex], pt, newT);
}
- int addSelfT(int segIndex, SkOpContour* other, int otherIndex, const SkPoint& pt, double newT) {
+ int addSelfT(int segIndex, const SkPoint& pt, double newT) {
setContainsIntercepts();
- return fSegments[segIndex].addSelfT(&other->fSegments[otherIndex], pt, newT);
+ return fSegments[segIndex].addSelfT(pt, newT);
}
const SkPathOpsBounds& bounds() const {
return fBounds;
}
+ bool calcAngles();
void calcCoincidentWinding();
void calcPartialCoincidentWinding();
+ void checkDuplicates() {
+ int segmentCount = fSegments.count();
+ for (int sIndex = 0; sIndex < segmentCount; ++sIndex) {
+ SkOpSegment& segment = fSegments[sIndex];
+ if (segment.count() > 2) {
+ segment.checkDuplicates();
+ }
+ }
+ }
+
void checkEnds() {
if (!fContainsCurves) {
return;
@@ -106,6 +117,26 @@ public:
}
}
+ void checkMultiples() {
+ int segmentCount = fSegments.count();
+ for (int sIndex = 0; sIndex < segmentCount; ++sIndex) {
+ SkOpSegment& segment = fSegments[sIndex];
+ if (segment.count() > 2) {
+ segment.checkMultiples();
+ }
+ }
+ }
+
+ void checkSmall() {
+ int segmentCount = fSegments.count();
+ for (int sIndex = 0; sIndex < segmentCount; ++sIndex) {
+ SkOpSegment& segment = fSegments[sIndex];
+ if (segment.hasSmall()) {
+ segment.checkSmall();
+ }
+ }
+ }
+
// if same point has different T values, choose a common T
void checkTiny() {
int segmentCount = fSegments.count();
@@ -113,7 +144,10 @@ public:
return;
}
for (int sIndex = 0; sIndex < segmentCount; ++sIndex) {
- fSegments[sIndex].checkTiny();
+ SkOpSegment& segment = fSegments[sIndex];
+ if (segment.hasTiny()) {
+ segment.checkTiny();
+ }
}
}
@@ -192,6 +226,7 @@ public:
fXor = isXor;
}
+ void sortAngles();
void sortSegments();
const SkPoint& start() const {
@@ -242,6 +277,12 @@ public:
static void debugShowWindingValues(const SkTArray<SkOpContour*, true>& contourList);
#endif
+ // available to test routines only
+ void dump() const;
+ void dumpAngles() const;
+ void dumpPts() const;
+ void dumpSpans() const;
+
private:
void calcCommonCoincidentWinding(const SkCoincidence& );
void joinCoincidence(const SkTArray<SkCoincidence, true>& , bool partial);
@@ -261,8 +302,11 @@ private:
bool fOperand; // true for the second argument to a binary operator
bool fXor;
bool fOppXor;
-#ifdef SK_DEBUG
+#if defined(SK_DEBUG) || !FORCE_RELEASE
+ int debugID() const { return fID; }
int fID;
+#else
+ int debugID() const { return -1; }
#endif
};