shape ops work in progress

git-svn-id: http://skia.googlecode.com/svn/trunk@6020 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
caryclark@google.com 2012-10-19 18:26:24 +00:00
parent 183e34b906
commit 185c7c4798
6 changed files with 90 additions and 9 deletions

View File

@ -115,10 +115,18 @@ inline bool approximately_greater_than_one(double x) {
return x > 1 - FLT_EPSILON;
}
inline bool precisely_greater_than_one(double x) {
return x > 1 - DBL_EPSILON;
}
inline bool approximately_less_than_zero(double x) {
return x < FLT_EPSILON;
}
inline bool precisely_less_than_zero(double x) {
return x < DBL_EPSILON;
}
inline bool approximately_negative(double x) {
return x < FLT_EPSILON;
}

View File

@ -292,7 +292,7 @@ static bool drawLetters(SkCanvas* canvas, int step, bool useOld)
}
#endif
paint.getPosTextPath(testStr, testStrLen, textPos, &path);
#if 0
#if 1
tryRonco(path);
#endif
#if 0

View File

@ -16,7 +16,7 @@ public:
};
protected:
virtual void onDraw(SkCanvas* canvas) {
static int step = 0; // 17909 ; // drawLetters first error
static int step = 17909 ; // drawLetters first error
// drawStars triggers error at 23275
// drawStars error not easy to debug last time I checked
static double seconds;

View File

@ -29,7 +29,7 @@ int gDebugMaxWindValue = SK_MaxS32;
#define SORTABLE_CONTOURS 0 // set to 1 for old code that works most of the time
#define DEBUG_UNUSED 0 // set to expose unused functions
#define FORCE_RELEASE 0
#define FORCE_RELEASE 1
#if FORCE_RELEASE || defined SK_RELEASE // set force release to 1 for multiple thread -- no debugging
@ -42,7 +42,7 @@ const bool gRunTestsInOneThread = false;
#define DEBUG_CONCIDENT 0
#define DEBUG_CROSS 0
#define DEBUG_MARK_DONE 0
#define DEBUG_PATH_CONSTRUCTION 0
#define DEBUG_PATH_CONSTRUCTION 1
#define DEBUG_SORT 0
#define DEBUG_WIND_BUMP 0
#define DEBUG_WINDING 0
@ -553,6 +553,14 @@ public:
return longer < rhLonger;
}
}
if ((fVerb == SkPath::kLine_Verb && approximately_zero(x) && approximately_zero(y))
|| (rh.fVerb == SkPath::kLine_Verb && approximately_zero(rx) && approximately_zero(ry))) {
// See general unsortable comment below. This case can happen when
// one line has a non-zero change in t but no change in x and y.
fUnsortable = true;
rh.fUnsortable = true;
return this < &rh; // even with no solution, return a stable sort
}
SkASSERT(fVerb == SkPath::kQuad_Verb); // worry about cubics later
SkASSERT(rh.fVerb == SkPath::kQuad_Verb);
// FIXME: until I can think of something better, project a ray from the
@ -1084,6 +1092,11 @@ public:
// add 2 to edge or out of range values to get T extremes
void addOtherT(int index, double otherT, int otherIndex) {
Span& span = fTs[index];
if (precisely_less_than_zero(otherT)) {
otherT = 0;
} else if (precisely_greater_than_one(otherT)) {
otherT = 1;
}
span.fOtherT = otherT;
span.fOtherIndex = otherIndex;
}
@ -1106,10 +1119,9 @@ public:
int insertedAt = -1;
size_t tCount = fTs.count();
// FIXME: only do this pinning here (e.g. this is done also in quad/line intersect)
if (approximately_less_than_zero(newT)) {
if (precisely_less_than_zero(newT)) {
newT = 0;
}
if (approximately_greater_than_one(newT)) {
} else if (precisely_greater_than_one(newT)) {
newT = 1;
}
for (size_t index = 0; index < tCount; ++index) {

View File

@ -2841,7 +2841,7 @@ static void testQuadratic51() {
testSimplifyx(path);
}
static void (*firstTest)() = testQuadratic51;
static void (*firstTest)() = 0;
static struct {
void (*fun)();
@ -3127,7 +3127,7 @@ static const size_t subTestCount = sizeof(subTests) / sizeof(subTests[0]);
static bool skipAll = false;
static bool runSubTests = false;
static bool runReverse = true;
static bool runReverse = false;
void SimplifyNew_Test() {
if (skipAll) {

View File

@ -2414,11 +2414,72 @@ path.lineTo(369.970581, 137.94342);
path.close();
</div>
<div id="testQuadratic52o">
path.moveTo(366.400513, 204.162521);
path.lineTo(411.545044, 81.6732483);
path.lineTo(366.400513, 204.162521);
path.close();
path.moveTo(331.585693, 138.050415);
path.quadTo(345.867188, 121.147957, 368.11853, 121.147957);
path.quadTo(389.193115, 121.147957, 400.693176, 136.124817);
path.lineTo(331.585693, 138.050415);
path.close();
path.moveTo(369.863983, 145.645813);
path.quadTo(382.380371, 121.254936, 406.236359, 121.254936);
path.lineTo(369.863983, 145.645813);
path.close();
path.moveTo(369.970581, 137.94342);
path.quadTo(383.98465, 121.254936, 406.235992, 121.254936);
path.lineTo(369.970581, 137.94342);
path.close();
</div>
<div id="testQuadratic52s">
path.moveTo(331.585693, 138.050415);
path.quadTo(345.867188,121.147957, 368.11853,121.147957);
path.quadTo(378.797424,121.147957, 387.017914,124.993469);
path.quadTo(391.577667,123.030998, 396.645874,122.098694);
path.quadTo(401.232697,121.254936, 406.235992,121.254936);
path.close();
path.moveTo(383.340973, 136.608322);
path.lineTo(369.863983,145.645813);
path.quadTo(372.378204,140.746292, 375.350006,136.830978);
path.lineTo(372.197113,136.918823);
path.lineTo(369.970581,137.94342);
path.quadTo(370.390961,137.442825, 370.818756,136.95723);
path.lineTo(331.585693,138.050415);
path.quadTo(345.867188,121.147957, 368.11853,121.147957);
path.quadTo(378.797424,121.147957, 387.017914,124.993469);
path.quadTo(391.577667,123.030998, 396.645874,122.098694);
path.quadTo(401.232697,121.254936, 406.235992,121.254936);
path.close();
path.moveTo(383.340973, 136.608322);
path.lineTo(391.380798,136.384293);
path.lineTo(400.693176,136.124817);
path.quadTo(397.721985,132.255341, 394.111664,129.385605);
path.lineTo(406.236359,121.254936);
path.quadTo(406.236176,121.254936, 406.235992,121.254936);
path.lineTo(406.235992,121.254936);
path.quadTo(401.232697,121.254936, 396.645874,122.098694);
path.quadTo(391.577667,123.030998, 387.017914,124.993469);
path.quadTo(378.797424,121.147957, 368.11853,121.147957);
path.quadTo(345.867188,121.147957, 331.585693,138.050415);
path.lineTo(370.818756,136.95723);
path.quadTo(370.390961,137.442825, 369.970581,137.94342);
path.lineTo(372.197113,136.918823);
path.lineTo(375.350006,136.830978);
path.quadTo(372.378204,140.746292, 369.863983,145.645813);
path.lineTo(383.340973,136.608322);
path.close();
</div>
</div>
<script type="text/javascript">
var testDivs = [
testQuadratic52o,
testQuadratic52s,
testQuadratic51,
testQuadratic50o,
testQuadratic50s,