aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-16 20:16:50 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-16 20:16:50 +0000
commit6ec1526680bcc05b8b8b2c7ad9f78ba247e123b7 (patch)
tree18765b5fb51689b9dd3738dd4502d0d96ff6a731
parent2c48c5eefcf76882cd11dd4dbd92475d15221ba9 (diff)
shape ops work in progress
git-svn-id: http://skia.googlecode.com/svn/trunk@6470 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--experimental/Intersection/ShapeOps.cpp25
-rw-r--r--experimental/Intersection/Simplify.cpp59
2 files changed, 45 insertions, 39 deletions
diff --git a/experimental/Intersection/ShapeOps.cpp b/experimental/Intersection/ShapeOps.cpp
index fa29ab769c..17a19e8369 100644
--- a/experimental/Intersection/ShapeOps.cpp
+++ b/experimental/Intersection/ShapeOps.cpp
@@ -171,10 +171,12 @@ static bool bridgeOp(SkTDArray<Contour*>& contourList, const ShapeOp op,
contourWinding = oppContourWinding = 0;
firstContour = false;
} else {
- int sumWinding = current->windSum(SkMin32(index, endIndex));
+ int minIndex = SkMin32(index, endIndex);
+ int sumWinding = current->windSum(minIndex);
+ int oppSumWinding = current->oppSum(minIndex);
// FIXME: don't I have to adjust windSum to get contourWinding?
if (sumWinding == SK_MinS32) {
- sumWinding = current->computeSum(index, endIndex);
+ sumWinding = current->computeSum(index, endIndex, &oppSumWinding);
}
if (sumWinding == SK_MinS32) {
contourWinding = innerContourCheck(contourList, current,
@@ -182,21 +184,12 @@ static bool bridgeOp(SkTDArray<Contour*>& contourList, const ShapeOp op,
oppContourWinding = innerContourCheck(contourList, current,
index, endIndex, true);
} else {
- contourWinding = sumWinding;
- oppContourWinding = 0;
- SkASSERT(0);
- // FIXME: need to get oppContourWinding by building sort wheel and
- // retrieving sumWinding of uphill opposite span, calling inner contour check
- // if need be
- int spanWinding = current->spanSign(index, endIndex);
- bool inner = useInnerWinding(sumWinding - spanWinding, sumWinding);
- if (inner) {
- contourWinding -= spanWinding;
- }
+ int spanWinding, oppWinding;
+ contourWinding = updateWindings(current, index, endIndex, spanWinding, oppWinding,
+ oppContourWinding);
#if DEBUG_WINDING
- SkDebugf("%s sumWinding=%d spanWinding=%d sign=%d inner=%d result=%d\n", __FUNCTION__,
- sumWinding, spanWinding, SkSign32(index - endIndex),
- inner, contourWinding);
+ SkDebugf("%s contourWinding=%d oppContourWinding=%d spanWinding=%d oppWinding=%d\n",
+ __FUNCTION__, contourWinding, oppContourWinding, spanWinding, oppWinding);
#endif
}
#if DEBUG_WINDING
diff --git a/experimental/Intersection/Simplify.cpp b/experimental/Intersection/Simplify.cpp
index 30044c505e..d6396eaacf 100644
--- a/experimental/Intersection/Simplify.cpp
+++ b/experimental/Intersection/Simplify.cpp
@@ -29,7 +29,7 @@ int gDebugMaxWindValue = SK_MaxS32;
#define TRY_ROTATE 1
#define DEBUG_UNUSED 0 // set to expose unused functions
-#define FORCE_RELEASE 1 // set force release to 1 for multiple thread -- no debugging
+#define FORCE_RELEASE 0 // set force release to 1 for multiple thread -- no debugging
#if FORCE_RELEASE || defined SK_RELEASE
@@ -1476,7 +1476,15 @@ public:
const double oStartT = oTest->fT;
do {
if (transfer) {
- if (!decrementThis & !thisXor & !opp) {
+ if (opp) {
+ if (decrementThis) {
+ if (decrementSpan(end)) {
+ TrackOutside(outsideTs, end->fT, oStartT);
+ }
+ } else {
+ end->fOppValue += oTest->fWindValue;
+ }
+ } else if (!decrementThis & !thisXor) {
#ifdef SK_DEBUG
SkASSERT(abs(end->fWindValue) < gDebugMaxWindValue);
#endif
@@ -1484,14 +1492,6 @@ public:
} else if (decrementSpan(end)) {
TrackOutside(outsideTs, end->fT, oStartT);
}
- } else if (opp) {
- if (decrementThis) {
- if (decrementSpan(end)) {
- TrackOutside(outsideTs, end->fT, oStartT);
- }
- } else {
- end->fOppValue += oTest->fWindValue;
- }
} else if (oTest->fWindValue) {
SkASSERT(decrementThis);
if (startIndex > 0 && fTs[startIndex - 1].fWindValue) {
@@ -1520,7 +1520,15 @@ public:
while (!approximately_negative(oEndT - oEnd->fT)
&& approximately_negative(oEnd->fT - otherTMatch)) {
if (transfer) {
- if (decrementThis & !otherXor & !opp) {
+ if (opp) {
+ if (decrementThis) {
+ oEnd->fOppValue += test->fWindValue;
+ } else {
+ if (decrementSpan(oEnd)) {
+ TrackOutside(oOutsideTs, oEnd->fT, startT);
+ }
+ }
+ } else if (decrementThis & !otherXor & !opp) {
#ifdef SK_DEBUG
SkASSERT(abs(oEnd->fWindValue) < gDebugMaxWindValue);
#endif
@@ -1528,14 +1536,6 @@ public:
} else if (decrementSpan(oEnd)) {
TrackOutside(oOutsideTs, oEnd->fT, startT);
}
- } else if (opp) {
- if (decrementThis) {
- oEnd->fOppValue += test->fWindValue;
- } else {
- if (decrementSpan(oEnd)) {
- TrackOutside(oOutsideTs, oEnd->fT, startT);
- }
- }
} else if (test->fWindValue) {
SkASSERT(decrementThis);
if (oStartIndex > 0 && fTs[oStartIndex - 1].fWindValue) {
@@ -1579,7 +1579,7 @@ public:
SkTDArray<double> xOutsideTs;
SkTDArray<double> oOutsideTs;
do {
- bool transfer = test->fWindValue && oTest->fWindValue && !opp;
+ bool transfer = test->fWindValue && oTest->fWindValue;
bool decrementThis = test->fWindValue < oTest->fWindValue;
if (decrementThis) {
oIndex = other.bumpCoincidentOther(test, transfer, decrementThis, otherXor, opp,
@@ -1689,7 +1689,7 @@ public:
other->addTwoAngles(next, oIndex, angles);
}
- int computeSum(int startIndex, int endIndex) {
+ int computeSum(int startIndex, int endIndex, int* oppoSum) {
SkTDArray<Angle> angles;
addTwoAngles(startIndex, endIndex, angles);
buildAngles(endIndex, angles, false);
@@ -1751,7 +1751,11 @@ public:
segment->markAndChaseWinding(angle, maxWinding);
}
} while (++nextIndex != lastIndex);
- return windSum(SkMin32(startIndex, endIndex));
+ int minIndex = SkMin32(startIndex, endIndex);
+ if (oppoSum) {
+ *oppoSum = oppSum(minIndex);
+ }
+ return windSum(minIndex);
}
int crossedSpan(const SkPoint& basePt, SkScalar& bestY, double& hitT) const {
@@ -3233,6 +3237,15 @@ public:
return xyAtT(span).fY;
}
+ void zeroSpan(Span* span) {
+ SkASSERT(span->fWindValue > 0);
+ span->fWindValue = 0;
+ if (!span->fDone) {
+ span->fDone = true;
+ ++fDoneSpans;
+ }
+ }
+
#if DEBUG_DUMP
void dump() const {
const char className[] = "Segment";
@@ -4990,7 +5003,7 @@ static bool bridgeWinding(SkTDArray<Contour*>& contourList, PathWrapper& simple)
int sumWinding = current->windSum(SkMin32(index, endIndex));
// FIXME: don't I have to adjust windSum to get contourWinding?
if (sumWinding == SK_MinS32) {
- sumWinding = current->computeSum(index, endIndex);
+ sumWinding = current->computeSum(index, endIndex, NULL);
}
if (sumWinding == SK_MinS32) {
contourWinding = innerContourCheck(contourList, current,