shape ops work in progress
git-svn-id: http://skia.googlecode.com/svn/trunk@4586 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/Intersection/Simplify.cpp b/experimental/Intersection/Simplify.cpp
index c52d722..8cdec8f 100644
--- a/experimental/Intersection/Simplify.cpp
+++ b/experimental/Intersection/Simplify.cpp
@@ -42,10 +42,10 @@
#define DEBUG_CROSS 1
#define DEBUG_DUMP 1
#define DEBUG_PATH_CONSTRUCTION 1
-#define DEBUG_ACTIVE_SPANS 0
-#define DEBUG_WINDING 0
+#define DEBUG_ACTIVE_SPANS 01
+#define DEBUG_WINDING 01
#define DEBUG_UNUSED 0 // set to expose unused functions
-#define DEBUG_MARK_DONE 0
+#define DEBUG_MARK_DONE 01
#endif
@@ -682,23 +682,27 @@
bool activeAngleInner(int index, int& done, SkTDArray<Angle>& angles) const {
int next = nextSpan(index, 1);
if (next > 0) {
- addAngle(angles, index, next);
const Span& upSpan = fTs[index];
- if (upSpan.fDone) {
- done++;
- } else if (upSpan.fWindSum != SK_MinS32) {
- return true;
+ if (upSpan.fWindValue) {
+ addAngle(angles, index, next);
+ if (upSpan.fDone) {
+ done++;
+ } else if (upSpan.fWindSum != SK_MinS32) {
+ return true;
+ }
}
}
int prev = nextSpan(index, -1);
// edge leading into junction
if (prev >= 0) {
- addAngle(angles, index, prev);
const Span& downSpan = fTs[prev];
- if (downSpan.fDone) {
- done++;
- } else if (downSpan.fWindSum != SK_MinS32) {
- return true;
+ if (downSpan.fWindValue) {
+ addAngle(angles, index, prev);
+ if (downSpan.fDone) {
+ done++;
+ } else if (downSpan.fWindSum != SK_MinS32) {
+ return true;
+ }
}
}
return false;
@@ -1088,12 +1092,12 @@
}
int crossedSpan(const SkPoint& basePt, SkScalar& bestY, double& hitT) const {
- int start = 0;
int bestT = -1;
SkScalar top = bounds().fTop;
SkScalar bottom = bounds().fBottom;
- int end;
+ int end = 0;
do {
+ int start = end;
end = nextSpan(start, 1);
SkPoint edge[4];
// OPTIMIZE: wrap this so that if start==0 end==fTCount-1 we can
@@ -1119,7 +1123,6 @@
bestT = foundT < 1 ? start : end;
hitT = foundT;
}
- start = end;
} while (fTs[end].fT != 1);
return bestT;
}
@@ -1215,6 +1218,10 @@
firstEdge = false;
if (!winding) {
if (!foundAngle) {
+#if 0
+ nextAngle->segment()->markWinding(
+ SkMin32(nextAngle->start(), nextAngle->end()), maxWinding);
+#endif
foundAngle = nextAngle;
}
continue;
@@ -2831,7 +2838,7 @@
if (firstSign * winding > 0) {
winding -= firstSign;
}
- SkDebugf("%s firstSign=%d\n", __FUNCTION__, firstSign);
+ // SkDebugf("%s firstSign=%d\n", __FUNCTION__, firstSign);
// we care about first sign and whether wind sum indicates this
// edge is inside or outside. Maybe need to pass span winding
// or first winding or something into this function?
diff --git a/experimental/Intersection/SimplifyNew_Test.cpp b/experimental/Intersection/SimplifyNew_Test.cpp
index 8bd172b..06b0167 100644
--- a/experimental/Intersection/SimplifyNew_Test.cpp
+++ b/experimental/Intersection/SimplifyNew_Test.cpp
@@ -372,6 +372,30 @@
testSimplifyx(path);
}
+static void testLine33() {
+ SkPath path, simple;
+ path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
+ path.addRect(0, 0, 12, 12, (SkPath::Direction) 0);
+ path.addRect(4, 16, 13, 13, (SkPath::Direction) 0);
+ testSimplifyx(path);
+}
+
+static void testLine34() {
+ SkPath path, simple;
+ path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
+ path.addRect(0, 6, 12, 12, (SkPath::Direction) 0);
+ path.addRect(4, 12, 13, 13, (SkPath::Direction) 0);
+ testSimplifyx(path);
+}
+
+static void testLine35() {
+ SkPath path, simple;
+ path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
+ path.addRect(6, 0, 18, 18, (SkPath::Direction) 0);
+ path.addRect(4, 16, 13, 13, (SkPath::Direction) 0);
+ testSimplifyx(path);
+}
+
#define TEST(name) { name, #name }
static struct {
@@ -414,6 +438,9 @@
TEST(testLine30),
TEST(testLine31),
TEST(testLine32),
+ TEST(testLine33),
+ TEST(testLine34),
+ TEST(testLine35),
};
static const size_t testCount = sizeof(tests) / sizeof(tests[0]);
diff --git a/experimental/Intersection/op.htm b/experimental/Intersection/op.htm
index 64f7611..0400561 100644
--- a/experimental/Intersection/op.htm
+++ b/experimental/Intersection/op.htm
@@ -383,11 +383,25 @@
path.addRect(4, 16, 13, 13, (SkPath::Direction) 0);
</div>
+<div id="testLine34">
+ path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
+ path.addRect(0, 6, 12, 12, (SkPath::Direction) 0);
+ path.addRect(4, 12, 13, 13, (SkPath::Direction) 0);
+</div>
+
+<div id="testLine35">
+ path.addRect(0, 0, 20, 20, (SkPath::Direction) 0);
+ path.addRect(6, 0, 18, 18, (SkPath::Direction) 0);
+ path.addRect(4, 16, 13, 13, (SkPath::Direction) 0);
+</div>
+
</div>
<script type="text/javascript">
var testDivs = [
+ testLine35,
+ testLine34,
testLine33,
testLine9,
testLine7,