shape ops work in progress

git-svn-id: http://skia.googlecode.com/svn/trunk@4586 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
caryclark@google.com 2012-07-12 21:05:13 +00:00
parent 30580f6949
commit 210acafc52
3 changed files with 65 additions and 17 deletions

View File

@ -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 @@ public:
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 @@ public:
}
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 @@ public:
bestT = foundT < 1 ? start : end;
hitT = foundT;
}
start = end;
} while (fTs[end].fT != 1);
return bestT;
}
@ -1215,6 +1218,10 @@ public:
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 @@ static Segment* findChase(SkTDArray<Span*>& chase, int& tIndex, int& endIndex) {
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?

View File

@ -372,6 +372,30 @@ static void testLine32() {
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 @@ static struct {
TEST(testLine30),
TEST(testLine31),
TEST(testLine32),
TEST(testLine33),
TEST(testLine34),
TEST(testLine35),
};
static const size_t testCount = sizeof(tests) / sizeof(tests[0]);

View File

@ -383,11 +383,25 @@ path.close();
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,