OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "PathOpsExtendedTest.h" | 8 #include "PathOpsExtendedTest.h" |
9 #include "PathOpsThreadedCommon.h" | 9 #include "PathOpsThreadedCommon.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkMatrix.h" | 12 #include "SkMatrix.h" |
13 #include "SkPaint.h" | 13 #include "SkPaint.h" |
14 #include "SkStream.h" | 14 #include "SkStream.h" |
| 15 #include "SkThreadPool.h" |
15 | 16 |
16 #ifdef SK_BUILD_FOR_MAC | 17 #ifdef SK_BUILD_FOR_MAC |
17 #include <sys/sysctl.h> | 18 #include <sys/sysctl.h> |
18 #endif | 19 #endif |
19 | 20 |
20 static const char marker[] = | 21 static const char marker[] = |
21 "</div>\n" | 22 "</div>\n" |
22 "\n" | 23 "\n" |
23 "<script type=\"text/javascript\">\n" | 24 "<script type=\"text/javascript\">\n" |
24 "\n" | 25 "\n" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 return; | 72 return; |
72 } | 73 } |
73 } | 74 } |
74 } | 75 } |
75 | 76 |
76 void showPath(const SkPath& path, const char* str) { | 77 void showPath(const SkPath& path, const char* str) { |
77 SkDebugf("%s\n", !str ? "original:" : str); | 78 SkDebugf("%s\n", !str ? "original:" : str); |
78 showPath(path); | 79 showPath(path); |
79 } | 80 } |
80 | 81 |
81 const char* fillTypeStr[] = { | 82 static const char* fillTypeStr[] = { |
82 "kWinding_FillType", | 83 "kWinding_FillType", |
83 "kEvenOdd_FillType", | 84 "kEvenOdd_FillType", |
84 "kInverseWinding_FillType", | 85 "kInverseWinding_FillType", |
85 "kInverseEvenOdd_FillType" | 86 "kInverseEvenOdd_FillType" |
86 }; | 87 }; |
87 | 88 |
88 void showPath(const SkPath& path) { | 89 void showPath(const SkPath& path) { |
89 SkPath::Iter iter(path, true); | 90 SkPath::Iter iter(path, true); |
90 #define SUPPORT_RECT_CONTOUR_DETECTION 0 | 91 #define SUPPORT_RECT_CONTOUR_DETECTION 0 |
91 #if SUPPORT_RECT_CONTOUR_DETECTION | 92 #if SUPPORT_RECT_CONTOUR_DETECTION |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 const char testFunction[] = "testSimplifyx(path);"; | 472 const char testFunction[] = "testSimplifyx(path);"; |
472 outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, str
eam); | 473 outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, str
eam); |
473 SkDebugf(temp); | 474 SkDebugf(temp); |
474 REPORTER_ASSERT(state.fReporter, 0); | 475 REPORTER_ASSERT(state.fReporter, 0); |
475 } | 476 } |
476 state.fReporter->bumpTestCount(); | 477 state.fReporter->bumpTestCount(); |
477 return result == 0; | 478 return result == 0; |
478 } | 479 } |
479 | 480 |
480 bool testSimplify(skiatest::Reporter* reporter, const SkPath& path) { | 481 bool testSimplify(skiatest::Reporter* reporter, const SkPath& path) { |
481 #if FORCE_RELEASE == 0 | 482 #if DEBUG_SHOW_TEST_NAME |
482 showPathData(path); | 483 showPathData(path); |
483 #endif | 484 #endif |
484 SkPath out; | 485 SkPath out; |
485 if (!Simplify(path, &out)) { | 486 if (!Simplify(path, &out)) { |
486 SkDebugf("%s did not expect failure\n", __FUNCTION__); | 487 SkDebugf("%s did not expect failure\n", __FUNCTION__); |
487 REPORTER_ASSERT(reporter, 0); | 488 REPORTER_ASSERT(reporter, 0); |
488 return false; | 489 return false; |
489 } | 490 } |
490 SkBitmap bitmap; | 491 SkBitmap bitmap; |
491 int result = comparePaths(reporter, path, out, bitmap); | 492 int result = comparePaths(reporter, path, out, bitmap); |
492 if (result && gPathStrAssert) { | 493 if (result && gPathStrAssert) { |
493 REPORTER_ASSERT(reporter, 0); | 494 REPORTER_ASSERT(reporter, 0); |
494 } | 495 } |
495 reporter->bumpTestCount(); | 496 reporter->bumpTestCount(); |
496 return result == 0; | 497 return result == 0; |
497 } | 498 } |
498 | 499 |
499 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, | 500 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
500 const SkPathOp shapeOp) { | 501 const SkPathOp shapeOp) { |
501 #if FORCE_RELEASE == 0 | 502 #if DEBUG_SHOW_TEST_NAME |
502 showPathData(a); | 503 showPathData(a); |
503 showOp(shapeOp); | 504 showOp(shapeOp); |
504 showPathData(b); | 505 showPathData(b); |
505 #endif | 506 #endif |
506 SkPath out; | 507 SkPath out; |
507 if (!Op(a, b, shapeOp, &out) ) { | 508 if (!Op(a, b, shapeOp, &out) ) { |
508 SkDebugf("%s did not expect failure\n", __FUNCTION__); | 509 SkDebugf("%s did not expect failure\n", __FUNCTION__); |
509 REPORTER_ASSERT(reporter, 0); | 510 REPORTER_ASSERT(reporter, 0); |
510 return false; | 511 return false; |
511 } | 512 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 | 589 |
589 void RunTestSet(skiatest::Reporter* reporter, TestDesc tests[], size_t count, | 590 void RunTestSet(skiatest::Reporter* reporter, TestDesc tests[], size_t count, |
590 void (*firstTest)(skiatest::Reporter* ), | 591 void (*firstTest)(skiatest::Reporter* ), |
591 void (*stopTest)(skiatest::Reporter* ), bool reverse) { | 592 void (*stopTest)(skiatest::Reporter* ), bool reverse) { |
592 size_t index; | 593 size_t index; |
593 if (firstTest) { | 594 if (firstTest) { |
594 index = count - 1; | 595 index = count - 1; |
595 while (index > 0 && tests[index].fun != firstTest) { | 596 while (index > 0 && tests[index].fun != firstTest) { |
596 --index; | 597 --index; |
597 } | 598 } |
598 #if FORCE_RELEASE == 0 | 599 #if DEBUG_SHOW_TEST_NAME |
599 SkDebugf("<div id=\"%s\">\n", tests[index].str); | 600 SkDebugf("<div id=\"%s\">\n", tests[index].str); |
600 SkDebugf(" %s [%s]\n", __FUNCTION__, tests[index].str); | 601 SkDebugf(" %s [%s]\n", __FUNCTION__, tests[index].str); |
601 #endif | 602 #endif |
602 (*tests[index].fun)(reporter); | 603 (*tests[index].fun)(reporter); |
603 } | 604 } |
604 index = reverse ? count - 1 : 0; | 605 index = reverse ? count - 1 : 0; |
605 size_t last = reverse ? 0 : count - 1; | 606 size_t last = reverse ? 0 : count - 1; |
606 do { | 607 do { |
607 if (tests[index].fun != firstTest) { | 608 if (tests[index].fun != firstTest) { |
608 #if FORCE_RELEASE == 0 | 609 #if DEBUG_SHOW_TEST_NAME |
609 SkDebugf("<div id=\"%s\">\n", tests[index].str); | 610 SkDebugf("<div id=\"%s\">\n", tests[index].str); |
610 SkDebugf(" %s [%s]\n", __FUNCTION__, tests[index].str); | 611 SkDebugf(" %s [%s]\n", __FUNCTION__, tests[index].str); |
611 #endif | 612 #endif |
612 (*tests[index].fun)(reporter); | 613 (*tests[index].fun)(reporter); |
613 } | 614 } |
614 if (tests[index].fun == stopTest) { | 615 if (tests[index].fun == stopTest) { |
615 SkDebugf("lastTest\n"); | 616 SkDebugf("lastTest\n"); |
616 } | 617 } |
617 if (index == last) { | 618 if (index == last) { |
618 break; | 619 break; |
619 } | 620 } |
620 index += reverse ? -1 : 1; | 621 index += reverse ? -1 : 1; |
621 } while (true); | 622 } while (true); |
622 } | 623 } |
OLD | NEW |