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

Side by Side Diff: tests/PathOpsSkpClipTest.cpp

Issue 239563004: fix minor skp-found bugs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix mac-detected errors Created 6 years, 8 months 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
« no previous file with comments | « tests/PathOpsSimplifyTest.cpp ('k') | tests/PathOpsSkpTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 #include "SkBitmap.h" 2 #include "SkBitmap.h"
3 #include "SkCanvas.h" 3 #include "SkCanvas.h"
4 #include "SkColor.h" 4 #include "SkColor.h"
5 #include "SkColorPriv.h" 5 #include "SkColorPriv.h"
6 #include "SkDevice.h" 6 #include "SkDevice.h"
7 #include "SkGraphics.h" 7 #include "SkGraphics.h"
8 #include "SkImageDecoder.h" 8 #include "SkImageDecoder.h"
9 #include "SkImageEncoder.h" 9 #include "SkImageEncoder.h"
10 #include "SkOSFile.h" 10 #include "SkOSFile.h"
11 #include "SkPathOpsDebug.h" 11 #include "SkPathOpsDebug.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkRTConf.h" 13 #include "SkRTConf.h"
14 #include "SkTSort.h" 14 #include "SkTSort.h"
15 #include "SkStream.h" 15 #include "SkStream.h"
16 #include "SkString.h" 16 #include "SkString.h"
17 #include "SkTArray.h" 17 #include "SkTArray.h"
18 #include "SkTDArray.h" 18 #include "SkTDArray.h"
19 #include "SkThreadPool.h" 19 #include "SkThreadPool.h"
20 #include "SkTime.h" 20 #include "SkTime.h"
21 #include "Test.h" 21 #include "Test.h"
22 22
23 #ifdef SK_BUILD_FOR_WIN 23 #ifdef SK_BUILD_FOR_WIN
24 #define PATH_SLASH "\\" 24 #define PATH_SLASH "\\"
25 #define IN_DIR "D:\\skp\\slave" 25 #define IN_DIR "D:\\skp\\slave"
26 #define OUT_DIR "D:\\skpOut\\1\\" 26 #define OUT_DIR "D:\\skpOut\\1\\"
27 #else 27 #else
28 #define PATH_SLASH "/" 28 #define PATH_SLASH "/"
29 #define IN_DIR "/skp/slave" 29 #define IN_DIR "/skp/2311328-7fc2228/slave"
30 #define OUT_DIR "/skpOut/1/" 30 #define OUT_DIR "/skpOut/2/"
31 #endif 31 #endif
32 32
33 const struct { 33 const struct {
34 int directory; 34 int directory;
35 const char* filename; 35 const char* filename;
36 } skipOverSept[] = { 36 } skipOverSept[] = {
37 {1, "http___elpais_com_.skp"}, 37 { 9, "http___www_catingueiraonline_com_.skp"}, // infinite loop
38 {1, "http___namecheap_com_.skp"}, 38 {13, "http___www_galaxystwo_com_.skp"}, // infinite loop
39 {1, "http___www_alrakoba_net_.skp"}, 39 {15, "http___www_giffingtool_com_.skp"}, // joinCoincidence / findT / asser t
40 {1, "http___www_briian_com_.skp"}, // triggers assert at line 467 of SkRRec t.cpp 40 {15, "http___www_thaienews_blogspot_com_.skp"}, // infinite loop
41 {1, "http___www_cityads_ru_.skp"}, 41 {17, "http___www_gruposejaumdivulgador_com_br_.skp"}, // calcCoincidentWindi ng asserts zeroSpan
42 {3, "http___www_abeautifulmess_com_.skp"}, // asserts in IntToFixed from Sk Scan::AntiFilllXRect 42 {18, "http___www_argus_presse_fr_.skp"}, // can't find winding of remaining vertical edge
43 {1, "http___www_dealnews_com_.skp"}, 43 {21, "http___www_fashionscandal_com_.skp"}, // infinite loop
44 {1, "http___www_inmotionhosting_com.skp"}, 44 {21, "http___www_kenlevine_blogspot_com_.skp"}, // infinite loop
45 {25, "http___www_defense_studies_blogspot_com_.skp"}, // infinite loop
46 {27, "http___www_brokeroutpost_com_.skp"}, // suspect infinite loop
47 {28, "http___www_jaimebatistadasilva_blogspot_com_br_.skp"}, // suspect inf inite loop
48 {28, "http___www_odia_com_br_.skp"}, // !simple->isClosed()
49 {29, "http___www_hubbyscook_com_.skp"}, // joinCoincidence / findT / assert
50 {30, "http___www_spankystokes_com_.skp"}, // suspect infinite loop
51 {32, "http___www_adalbertoday_blogspot_com_br_.skp"}, // suspect infinite l oop
52 {32, "http___www_galery_annisa_com_.skp"}, // suspect infinite loop
53 {33, "http___www_pindosiya_com_.skp"}, // line quad intersection SkIntersec tions::assert
54 {36, "http___www_educationalcraft_com_.skp"}, // cubic / cubic near end / a ssert in SkIntersections::insert (missing skp test)
55 {36, "http___www_shaam_org_.skp"}, // suspect infinite loop
56 {36, "http___www_my_pillow_book_blogspot_gr_.skp"}, // suspect infinite loo p
57 {39, "http___www_opbeat_com_.skp"}, // suspect infinite loop
58 {40, "http___www_phototransferapp_com_.skp"}, // !simple->isClosed()
59 {41, "http___www_freeismylife_com_.skp"}, // suspect infinite loop
60 {41, "http___www_accordidelmomento_com_.skp"}, // suspect infinite loop
61 {41, "http___www_evolvehq_com_.skp"}, // joinCoincidence / findT / assert
62 {44, "http___www_contextualnewsfeeds_com_.skp"}, // !simple->isClosed()
63 {44, "http___www_cooksnaps_com_.skp"}, // !simple->isClosed()
64 {44, "http___www_helha_be_.skp"}, // !simple->isClosed()
65 {45, "http___www_blondesmakemoney_blogspot_com_.skp"}, // suspect infinite loop
66 {46, "http___www_cheaphealthygood_blogspot_com_.skp"}, // suspect infinite loop
67 {47, "http___www_ajitvadakayil_blogspot_in_.skp"}, // suspect infinite loop
68 {49, "http___www_karnivool_com_au_.skp"}, // SkOpAngle::setSector SkASSERT( fSectorStart >= 0);
69 {49, "http___www_tunero_de_.skp"}, // computeonesumreverse calls markwindin g with 0 winding
70 {49, "http___www_thaienews_blogspot_sg_.skp"}, // suspect infinite loop
71 {50, "http___www_docgelo_com_.skp"}, // rightAngleWinding (probably same as argus_presse)
72 {53, "http___www_lojaanabotafogo_com_br_.skp"}, // rrect validate assert
73 {54, "http___www_odecktestanswer2013_blogspot_in_.skp"}, // suspect infinit e loop
74 {54, "http___www_cleristonsilva_com_br_.skp"}, // suspect infinite loop
75 {56, "http___www_simplysaru_com_.skp"}, // joinCoincidence / findT / assert
76 {57, "http___www_koukfamily_blogspot_gr_.skp"}, // suspect infinite loop
77 {57, "http___www_dinar2010_blogspot_com_.skp"}, // suspect infinite loop
78 {58, "http___www_artblart_com_.skp"}, // rightAngleWinding
79 {59, "http___www_accrispin_blogspot_com_.skp"}, // suspect infinite loop
80 {59, "http___www_vicisitudysordidez_blogspot_com_es_.skp"}, // suspect infi nite loop
81 {60, "http___www_thehousingbubbleblog_com_.skp"}, // suspect infinite loop
82 {61, "http___www_jessicaslens_wordpress_com_.skp"}, // joinCoincidence / fi ndT / assert
83 {61, "http___www_partsdata_de_.skp"}, // cubic-cubic intersection reduce ch eckLinear assert
84 {62, "http___www_blondesmakemoney_blogspot_com_au_.skp"}, // suspect infini te loop
85 {62, "http___www_intellibriefs_blogspot_in_.skp"}, // suspect infinite loop
86 {63, "http___www_tankerenemy_com_.skp"}, // suspect infinite loop
87 {65, "http___www_kpopexplorer_net_.skp"}, // joinCoincidence / findT / asse rt
88 {65, "http___www_bestthingsinbeauty_blogspot_com_.skp"}, // suspect infinit e loop
89 {65, "http___www_wartepop_blogspot_com_br_.skp"}, // !simple->isClosed()
90 {65, "http___www_eolake_blogspot_com_.skp"}, // suspect infinite loop
91 {67, "http___www_cacadordemisterio_blogspot_com_br_.skp"}, // suspect infin ite loop
92 {69, "http___www_misnotasyapuntes_blogspot_mx_.skp"}, // suspect infinite l oop
93 {69, "http___www_awalkintheparknyc_blogspot_com_.skp"}, // suspect infinite loop
94 {71, "http___www_lokado_de_.skp"}, // joinCoincidence / findT / assert
95 {72, "http___www_karlosdesanjuan_blogspot_com_.skp"}, // suspect infinite l oop
96 {73, "http___www_cyberlawsinindia_blogspot_in_.skp"}, // suspect infinite l oop
97 {73, "http___www_taxiemmovimento_blogspot_com_br_.skp"}, // suspect infinit e loop
98 {74, "http___www_giveusliberty1776_blogspot_com_.skp"}, // suspect infinite loop
99 {75, "http___www_e_cynical_blogspot_gr_.skp"}, // suspect infinite loop
100 {76, "http___www_seopack_blogspot_com_.skp"}, // SkOpAngle::setSector SkASS ERT(fSectorStart >= 0);
101 {77, "http___www_sunsky_russia_com_.skp"}, // joinCoincidence / findT / ass ert (no op test, already fixed hopefully)
102 {78, "http___www_bisnisonlineinfo_com_.skp"}, // suspect infinite loop
103 {79, "http___www_danielsgroupcpa_com_.skp"}, // joinCoincidence / findT / a ssert (no op test, already fixed hopefully)
104 {80, "http___www_clinique_portugal_com_.skp"}, // suspect infinite loop
105 {81, "http___www_europebusines_blogspot_com_.skp"}, // suspect infinite loo p
106 {82, "http___www_apopsignomi_blogspot_gr_.skp"}, // suspect infinite loop
107 {85, "http___www_ajitvadakayil_blogspot_com_.skp"}, // suspect infinite loo p
108 {86, "http___www_madhousefamilyreviews_blogspot_co_uk_.skp"}, // suspect in finite loop
45 }; 109 };
46 110
47 size_t skipOverSeptCount = sizeof(skipOverSept) / sizeof(skipOverSept[0]); 111 size_t skipOverSeptCount = sizeof(skipOverSept) / sizeof(skipOverSept[0]);
48 112
49 enum TestStep { 113 enum TestStep {
50 kCompareBits, 114 kCompareBits,
51 kEncodeFiles, 115 kEncodeFiles,
52 }; 116 };
53 117
54 enum { 118 enum {
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 466 }
403 pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::DecodeMemory ); 467 pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::DecodeMemory );
404 if (!pic) { 468 if (!pic) {
405 SkDebugf("unable to decode %s\n", fFilename); 469 SkDebugf("unable to decode %s\n", fFilename);
406 goto finish; 470 goto finish;
407 } 471 }
408 int width = pic->width(); 472 int width = pic->width();
409 int height = pic->height(); 473 int height = pic->height();
410 SkBitmap oldBitmap, opBitmap; 474 SkBitmap oldBitmap, opBitmap;
411 fScale = 1; 475 fScale = 1;
476 while (width / fScale > 32767 || height / fScale > 32767) {
477 ++fScale;
478 }
412 do { 479 do {
413 int dimX = (width + fScale - 1) / fScale; 480 int dimX = (width + fScale - 1) / fScale;
414 int dimY = (height + fScale - 1) / fScale; 481 int dimY = (height + fScale - 1) / fScale;
415 if (oldBitmap.allocN32Pixels(dimX, dimY) && 482 if (oldBitmap.allocN32Pixels(dimX, dimY) &&
416 opBitmap.allocN32Pixels(dimX, dimY)) { 483 opBitmap.allocN32Pixels(dimX, dimY)) {
417 break; 484 break;
418 } 485 }
419 SkDebugf("-%d-", fScale); 486 SkDebugf("-%d-", fScale);
420 } while ((fScale *= 2) < 256); 487 } while (++fScale < 256);
421 if (fScale >= 256) { 488 if (fScale >= 256) {
422 SkDebugf("unable to allocate bitmap for %s (w=%d h=%d)\n", fFilename , 489 SkDebugf("unable to allocate bitmap for %s (w=%d h=%d)\n", fFilename ,
423 width, height); 490 width, height);
424 goto finish; 491 goto finish;
425 } 492 }
426 oldBitmap.eraseColor(SK_ColorWHITE); 493 oldBitmap.eraseColor(SK_ColorWHITE);
427 SkCanvas oldCanvas(oldBitmap); 494 SkCanvas oldCanvas(oldBitmap);
428 oldCanvas.setAllowSimplifyClip(false); 495 oldCanvas.setAllowSimplifyClip(false);
429 opBitmap.eraseColor(SK_ColorWHITE); 496 opBitmap.eraseColor(SK_ColorWHITE);
430 SkCanvas opCanvas(opBitmap); 497 SkCanvas opCanvas(opBitmap);
(...skipping 20 matching lines...) Expand all
451 518
452 static SkString makeStatusString(int dirNo) { 519 static SkString makeStatusString(int dirNo) {
453 SkString statName; 520 SkString statName;
454 statName.printf("stats%d.txt", dirNo); 521 statName.printf("stats%d.txt", dirNo);
455 SkString statusFile = make_filepath(0, outStatusDir, statName.c_str()); 522 SkString statusFile = make_filepath(0, outStatusDir, statName.c_str());
456 return statusFile; 523 return statusFile;
457 } 524 }
458 525
459 class PreParser { 526 class PreParser {
460 public: 527 public:
461 PreParser(int dirNo) 528 PreParser(int dirNo, bool threaded)
462 : fDirNo(dirNo) 529 : fDirNo(dirNo)
463 , fIndex(0) { 530 , fIndex(0)
531 , fThreaded(threaded) {
464 SkString statusPath = makeStatusString(dirNo); 532 SkString statusPath = makeStatusString(dirNo);
465 if (!sk_exists(statusPath.c_str())) { 533 if (!sk_exists(statusPath.c_str())) {
466 return; 534 return;
467 } 535 }
468 SkFILEStream reader; 536 SkFILEStream reader;
469 reader.setPath(statusPath.c_str()); 537 reader.setPath(statusPath.c_str());
470 while (fetch(reader, &fResults.push_back())) 538 while (fetch(reader, &fResults.push_back()))
471 ; 539 ;
472 fResults.pop_back(); 540 fResults.pop_back();
473 } 541 }
474 542
475 bool fetch(SkFILEStream& reader, TestResult* result) { 543 bool fetch(SkFILEStream& reader, TestResult* result) {
476 char c; 544 char c;
477 int i = 0; 545 int i = 0;
478 result->init(fDirNo); 546 result->init(fDirNo);
479 result->fPixelError = 0; 547 result->fPixelError = 0;
480 result->fTime = 0; 548 result->fTime = 0;
481 do { 549 do {
482 bool readOne = reader.read(&c, 1) != 0; 550 bool readOne = reader.read(&c, 1) != 0;
483 if (!readOne) { 551 if (!readOne) {
484 SkASSERT(i == 0); 552 // SkASSERT(i == 0); // the current text may be incomplete -- i f so, ignore it
485 return false; 553 return false;
486 } 554 }
487 if (c == ' ') { 555 if (c == ' ') {
488 result->fFilename[i++] = '\0'; 556 result->fFilename[i++] = '\0';
489 break; 557 break;
490 } 558 }
491 result->fFilename[i++] = c; 559 result->fFilename[i++] = c;
492 SkASSERT(i < kMaxLength); 560 SkASSERT(i < kMaxLength);
493 } while (true); 561 } while (true);
494 do { 562 do {
495 SkAssertResult(reader.read(&c, 1)); 563 if (!reader.read(&c, 1)) {
564 return false;
565 }
496 if (c == ' ') { 566 if (c == ' ') {
497 break; 567 break;
498 } 568 }
499 SkASSERT(c >= '0' && c <= '9'); 569 SkASSERT(c >= '0' && c <= '9');
500 result->fPixelError = result->fPixelError * 10 + (c - '0'); 570 result->fPixelError = result->fPixelError * 10 + (c - '0');
501 } while (true); 571 } while (true);
502 bool minus = false; 572 bool minus = false;
503 do { 573 do {
504 SkAssertResult(reader.read(&c, 1)); 574 if (!reader.read(&c, 1)) {
575 return false;
576 }
505 if (c == '\n') { 577 if (c == '\n') {
506 break; 578 break;
507 } 579 }
508 if (c == '-') { 580 if (c == '-') {
509 minus = true; 581 minus = true;
510 continue; 582 continue;
511 } 583 }
512 SkASSERT(c >= '0' && c <= '9'); 584 SkASSERT(c >= '0' && c <= '9');
513 result->fTime = result->fTime * 10 + (c - '0'); 585 result->fTime = result->fTime * 10 + (c - '0');
514 } while (true); 586 } while (true);
515 if (minus) { 587 if (minus) {
516 result->fTime = -result->fTime; 588 result->fTime = -result->fTime;
517 } 589 }
518 return true; 590 return true;
519 } 591 }
520 592
521 bool match(const SkString& filename, SkFILEWStream* stream, TestResult* resu lt) { 593 bool match(const SkString& filename, SkFILEWStream* stream, TestResult* resu lt) {
522 if (fIndex < fResults.count()) { 594 if (fThreaded) {
595 for (int index = 0; index < fResults.count(); ++index) {
596 const TestResult& test = fResults[index];
597 if (filename.equals(test.fFilename)) {
598 *result = test;
599 SkString outStr(result->status());
600 stream->write(outStr.c_str(), outStr.size());
601 return true;
602 }
603 }
604 } else if (fIndex < fResults.count()) {
523 *result = fResults[fIndex++]; 605 *result = fResults[fIndex++];
524 SkASSERT(filename.equals(result->fFilename)); 606 SkASSERT(filename.equals(result->fFilename));
525 SkString outStr(result->status()); 607 SkString outStr(result->status());
526 stream->write(outStr.c_str(), outStr.size()); 608 stream->write(outStr.c_str(), outStr.size());
527 return true; 609 return true;
528 } 610 }
529 return false; 611 return false;
530 } 612 }
531 613
532 private: 614 private:
533 int fDirNo; 615 int fDirNo;
534 int fIndex; 616 int fIndex;
535 SkTArray<TestResult, true> fResults; 617 SkTArray<TestResult, true> fResults;
618 bool fThreaded;
536 }; 619 };
537 620
538 static bool doOneDir(TestState* state) { 621 static bool doOneDir(TestState* state, bool threaded) {
539 int dirNo = state->fResult.fDirNo; 622 int dirNo = state->fResult.fDirNo;
540 skiatest::Reporter* reporter = state->fReporter; 623 skiatest::Reporter* reporter = state->fReporter;
541 SkString dirName = make_in_dir_name(dirNo); 624 SkString dirName = make_in_dir_name(dirNo);
542 if (!dirName.size()) { 625 if (!dirName.size()) {
543 return false; 626 return false;
544 } 627 }
545 SkOSFile::Iter iter(dirName.c_str(), "skp"); 628 SkOSFile::Iter iter(dirName.c_str(), "skp");
546 SkString filename; 629 SkString filename;
547 int testCount = 0; 630 int testCount = 0;
548 PreParser preParser(dirNo); 631 PreParser preParser(dirNo, threaded);
549 SkFILEWStream statusStream(makeStatusString(dirNo).c_str()); 632 SkFILEWStream statusStream(makeStatusString(dirNo).c_str());
550 while (iter.next(&filename)) { 633 while (iter.next(&filename)) {
551 for (size_t index = 0; index < skipOverSeptCount; ++index) { 634 for (size_t index = 0; index < skipOverSeptCount; ++index) {
552 if (skipOverSept[index].directory == dirNo 635 if (skipOverSept[index].directory == dirNo
553 && strcmp(filename.c_str(), skipOverSept[index].filename) == 0) { 636 && strcmp(filename.c_str(), skipOverSept[index].filename) == 0) {
554 goto checkEarlyExit; 637 goto checkEarlyExit;
555 } 638 }
556 } 639 }
557 if (preParser.match(filename, &statusStream, &state->fResult)) { 640 if (preParser.match(filename, &statusStream, &state->fResult)) {
558 (void) addError(state, state->fResult); 641 (void) addError(state, state->fResult);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 return; 708 return;
626 } 709 }
627 SkTArray<TestResult, true> errors; 710 SkTArray<TestResult, true> errors;
628 TestState state; 711 TestState state;
629 state.init(0, reporter); 712 state.init(0, reporter);
630 for (int dirNo = 1; dirNo <= 100; ++dirNo) { 713 for (int dirNo = 1; dirNo <= 100; ++dirNo) {
631 if (reporter->verbose()) { 714 if (reporter->verbose()) {
632 SkDebugf("dirNo=%d\n", dirNo); 715 SkDebugf("dirNo=%d\n", dirNo);
633 } 716 }
634 state.fResult.fDirNo = dirNo; 717 state.fResult.fDirNo = dirNo;
635 if (!doOneDir(&state)) { 718 if (!doOneDir(&state, false)) {
636 break; 719 break;
637 } 720 }
638 } 721 }
639 encodeFound(reporter, state); 722 encodeFound(reporter, state);
640 } 723 }
641 724
642 static void testSkpClipMain(TestState* data) { 725 static void testSkpClipMain(TestState* data) {
643 (void) doOneDir(data); 726 (void) doOneDir(data, true);
644 } 727 }
645 728
646 DEF_TEST(PathOpsSkpClipThreaded, reporter) { 729 DEF_TEST(PathOpsSkpClipThreaded, reporter) {
647 if (!initTest()) { 730 if (!initTest()) {
648 return; 731 return;
649 } 732 }
650 int threadCount = reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 1; 733 int threadCount = reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 1;
651 TestRunner testRunner(reporter, threadCount); 734 TestRunner testRunner(reporter, threadCount);
652 for (int dirNo = 1; dirNo <= 100; ++dirNo) { 735 for (int dirNo = 1; dirNo <= 100; ++dirNo) {
653 *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnable, 736 *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnable,
(...skipping 21 matching lines...) Expand all
675 SkAssertResult(make_in_dir_name(dirNo).size()); 758 SkAssertResult(make_in_dir_name(dirNo).size());
676 SkString filename(skipOverSept[testIndex].filename); 759 SkString filename(skipOverSept[testIndex].filename);
677 TestResult state; 760 TestResult state;
678 state.test(dirNo, filename); 761 state.test(dirNo, filename);
679 if (reporter->verbose()) { 762 if (reporter->verbose()) {
680 SkDebugf("%s", state.status().c_str()); 763 SkDebugf("%s", state.status().c_str());
681 } 764 }
682 state.fTestStep = kEncodeFiles; 765 state.fTestStep = kEncodeFiles;
683 state.testOne(); 766 state.testOne();
684 } 767 }
OLDNEW
« no previous file with comments | « tests/PathOpsSimplifyTest.cpp ('k') | tests/PathOpsSkpTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698