Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: src/pathops/SkDQuadIntersection.cpp

Issue 75453003: optimize pathops coverage (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remove unused code now that testing is complete Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Another approach is to start with the implicit form of one curve and solve 1 // Another approach is to start with the implicit form of one curve and solve
2 // (seek implicit coefficients in QuadraticParameter.cpp 2 // (seek implicit coefficients in QuadraticParameter.cpp
3 // by substituting in the parametric form of the other. 3 // by substituting in the parametric form of the other.
4 // The downside of this approach is that early rejects are difficult to come by. 4 // The downside of this approach is that early rejects are difficult to come by.
5 // http://planetmath.org/encyclopedia/GaloisTheoreticDerivationOfTheQuarticFormu la.html#step 5 // http://planetmath.org/encyclopedia/GaloisTheoreticDerivationOfTheQuarticFormu la.html#step
6 6
7 7
8 #include "SkDQuadImplicit.h" 8 #include "SkDQuadImplicit.h"
9 #include "SkIntersections.h" 9 #include "SkIntersections.h"
10 #include "SkPathOpsLine.h" 10 #include "SkPathOpsLine.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 SkSTArray<kTestCount * 2, double, true> tsFound; 155 SkSTArray<kTestCount * 2, double, true> tsFound;
156 for (size_t index = 0; index < kTestCount; ++index) { 156 for (size_t index = 0; index < kTestCount; ++index) {
157 SkIntersections rootTs; 157 SkIntersections rootTs;
158 rootTs.allowNear(false); 158 rootTs.allowNear(false);
159 int roots = rootTs.intersect(q2, *testLines[index]); 159 int roots = rootTs.intersect(q2, *testLines[index]);
160 for (int idx2 = 0; idx2 < roots; ++idx2) { 160 for (int idx2 = 0; idx2 < roots; ++idx2) {
161 double t = rootTs[0][idx2]; 161 double t = rootTs[0][idx2];
162 #ifdef SK_DEBUG 162 #ifdef SK_DEBUG
163 SkDPoint qPt = q2.ptAtT(t); 163 SkDPoint qPt = q2.ptAtT(t);
164 SkDPoint lPt = testLines[index]->ptAtT(rootTs[1][idx2]); 164 SkDPoint lPt = testLines[index]->ptAtT(rootTs[1][idx2]);
165 SkASSERT(qPt.approximatelyEqual(lPt)); 165 SkASSERT(qPt.approximatelyPEqual(lPt));
166 #endif 166 #endif
167 if (approximately_negative(t - t2s) || approximately_positive(t - t2 e)) { 167 if (approximately_negative(t - t2s) || approximately_positive(t - t2 e)) {
168 continue; 168 continue;
169 } 169 }
170 tsFound.push_back(rootTs[0][idx2]); 170 tsFound.push_back(rootTs[0][idx2]);
171 } 171 }
172 } 172 }
173 int tCount = tsFound.count(); 173 int tCount = tsFound.count();
174 if (tCount <= 0) { 174 if (tCount <= 0) {
175 return true; 175 return true;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 i->insert(impTs[0][index], testT, tmpLine[0]); 392 i->insert(impTs[0][index], testT, tmpLine[0]);
393 } 393 }
394 } 394 }
395 } 395 }
396 396
397 int SkIntersections::intersect(const SkDQuad& q1, const SkDQuad& q2) { 397 int SkIntersections::intersect(const SkDQuad& q1, const SkDQuad& q2) {
398 fMax = 4; 398 fMax = 4;
399 // if the quads share an end point, check to see if they overlap 399 // if the quads share an end point, check to see if they overlap
400 for (int i1 = 0; i1 < 3; i1 += 2) { 400 for (int i1 = 0; i1 < 3; i1 += 2) {
401 for (int i2 = 0; i2 < 3; i2 += 2) { 401 for (int i2 = 0; i2 < 3; i2 += 2) {
402 if (q1[i1] == q2[i2]) { 402 if (q1[i1].asSkPoint() == q2[i2].asSkPoint()) {
403 insert(i1 >> 1, i2 >> 1, q1[i1]); 403 insert(i1 >> 1, i2 >> 1, q1[i1]);
404 } 404 }
405 } 405 }
406 } 406 }
407 if (fAllowNear || true) { // FIXME ? cubic/cubic intersection fails withou t (cubicOp67u)
408 for (int i1 = 0; i1 < 3; i1 += 2) {
409 for (int i2 = 0; i2 < 3; i2 += 2) {
410 if (q1[i1] != q2[i2] && q1[i1].approximatelyEqual(q2[i2])) {
411 insertNear(i1 >> 1, i2 >> 1, q1[i1]);
412 }
413 }
414 }
415 }
416 SkASSERT(fUsed < 3); 407 SkASSERT(fUsed < 3);
417 if (only_end_pts_in_common(q1, q2)) { 408 if (only_end_pts_in_common(q1, q2)) {
418 return fUsed; 409 return fUsed;
419 } 410 }
420 if (only_end_pts_in_common(q2, q1)) { 411 if (only_end_pts_in_common(q2, q1)) {
421 return fUsed; 412 return fUsed;
422 } 413 }
423 // see if either quad is really a line 414 // see if either quad is really a line
424 // FIXME: figure out why reduce step didn't find this earlier 415 // FIXME: figure out why reduce step didn't find this earlier
425 if (is_linear(q1, q2, this)) { 416 if (is_linear(q1, q2, this)) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 } 544 }
554 if (lowestIndex < 0) { 545 if (lowestIndex < 0) {
555 break; 546 break;
556 } 547 }
557 insert(roots1Copy[lowestIndex], roots2Copy[closest[lowestIndex]], 548 insert(roots1Copy[lowestIndex], roots2Copy[closest[lowestIndex]],
558 pts1[lowestIndex]); 549 pts1[lowestIndex]);
559 closest[lowestIndex] = -1; 550 closest[lowestIndex] = -1;
560 } while (++used < r1Count); 551 } while (++used < r1Count);
561 return fUsed; 552 return fUsed;
562 } 553 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698