OLD | NEW |
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 "SkStream.h" | 15 #include "SkStream.h" |
15 #include "SkString.h" | 16 #include "SkString.h" |
16 #include "SkTArray.h" | 17 #include "SkTArray.h" |
17 #include "SkTDArray.h" | 18 #include "SkTDArray.h" |
18 #include "SkThreadPool.h" | 19 #include "SkThreadPool.h" |
19 #include "SkTime.h" | 20 #include "SkTime.h" |
20 #include "Test.h" | 21 #include "Test.h" |
21 | 22 |
22 #ifdef SK_BUILD_FOR_WIN | 23 #ifdef SK_BUILD_FOR_WIN |
23 #define PATH_SLASH "\\" | 24 #define PATH_SLASH "\\" |
24 #define IN_DIR "D:\\9-30-13\\" | 25 #define IN_DIR "D:\\skp\\slave" |
25 #define OUT_DIR "D:\\opSkpClip\\1\\" | 26 #define OUT_DIR "D:\\skpOut\\1\\" |
26 #else | 27 #else |
27 #define PATH_SLASH "/" | 28 #define PATH_SLASH "/" |
28 #ifdef SK_BUILD_FOR_MAC | 29 #define IN_DIR "/skp/slave" |
29 #define IN_DIR "/Volumes/tera/9-30-13/skp" | 30 #define OUT_DIR "/skpOut/1/" |
30 #define OUT_DIR "/Volumes/tera/out/9-30-13/1/" | |
31 #else | |
32 #define IN_DIR "/usr/local/google/home/caryclark/skps/9-30-13/skp" | |
33 #define OUT_DIR "/mnt/skia/opSkpClip/1/" | |
34 #endif | |
35 #endif | 31 #endif |
36 | 32 |
37 const struct { | 33 const struct { |
38 int directory; | 34 int directory; |
39 const char* filename; | 35 const char* filename; |
40 } skipOverSept[] = { | 36 } skipOverSept[] = { |
41 {9, "http___www_symptome_ch_.skp"}, // triangle clip with corner at x.999 | 37 {1, "http___elpais_com_.skp"}, |
42 {11, "http___www_menly_fr_.skp"}, | 38 {1, "http___namecheap_com_.skp"}, |
43 {12, "http___www_banrasdr_com_.skp"}, | 39 {1, "http___www_alrakoba_net_.skp"}, |
| 40 {1, "http___www_briian_com_.skp"}, // triggers assert at line 467 of SkRRec
t.cpp |
| 41 {1, "http___www_cityads_ru_.skp"}, |
| 42 {3, "http___www_abeautifulmess_com_.skp"}, // asserts in IntToFixed from Sk
Scan::AntiFilllXRect |
| 43 {1, "http___www_dealnews_com_.skp"}, |
| 44 {1, "http___www_inmotionhosting_com.skp"}, |
44 }; | 45 }; |
45 | 46 |
46 size_t skipOverSeptCount = sizeof(skipOverSept) / sizeof(skipOverSept[0]); | 47 size_t skipOverSeptCount = sizeof(skipOverSept) / sizeof(skipOverSept[0]); |
47 | 48 |
48 enum TestStep { | 49 enum TestStep { |
49 kCompareBits, | 50 kCompareBits, |
50 kEncodeFiles, | 51 kEncodeFiles, |
51 }; | 52 }; |
52 | 53 |
53 enum { | 54 enum { |
54 kMaxLength = 128, | 55 kMaxLength = 128, |
55 kMaxFiles = 128, | 56 kMaxFiles = 128, |
56 kSmallLimit = 1000, | 57 kSmallLimit = 1000, |
57 }; | 58 }; |
58 | 59 |
59 struct TestResult { | 60 struct TestResult { |
60 void init(int dirNo) { | 61 void init(int dirNo) { |
61 fDirNo = dirNo; | 62 fDirNo = dirNo; |
62 sk_bzero(fFilename, sizeof(fFilename)); | 63 sk_bzero(fFilename, sizeof(fFilename)); |
63 fTestStep = kCompareBits; | 64 fTestStep = kCompareBits; |
64 fScaleOversized = true; | 65 fScale = 1; |
65 } | 66 } |
66 | 67 |
67 SkString status() { | 68 SkString status() { |
68 SkString outStr; | 69 SkString outStr; |
69 outStr.printf("%s %d %d\n", fFilename, fPixelError, fTime); | 70 outStr.printf("%s %d %d\n", fFilename, fPixelError, fTime); |
70 return outStr; | 71 return outStr; |
71 } | 72 } |
72 | 73 |
| 74 SkString progress() { |
| 75 SkString outStr; |
| 76 outStr.printf("dir=%d %s ", fDirNo, fFilename); |
| 77 if (fPixelError) { |
| 78 outStr.appendf(" err=%d", fPixelError); |
| 79 } |
| 80 if (fTime) { |
| 81 outStr.appendf(" time=%d", fTime); |
| 82 } |
| 83 if (fScale != 1) { |
| 84 outStr.appendf(" scale=%d", fScale); |
| 85 } |
| 86 outStr.appendf("\n"); |
| 87 return outStr; |
| 88 |
| 89 } |
| 90 |
73 static void Test(int dirNo, const char* filename, TestStep testStep) { | 91 static void Test(int dirNo, const char* filename, TestStep testStep) { |
74 TestResult test; | 92 TestResult test; |
75 test.init(dirNo); | 93 test.init(dirNo); |
76 test.fTestStep = testStep; | 94 test.fTestStep = testStep; |
77 strcpy(test.fFilename, filename); | 95 strcpy(test.fFilename, filename); |
78 test.testOne(); | 96 test.testOne(); |
79 } | 97 } |
80 | 98 |
81 void test(int dirNo, const SkString& filename) { | 99 void test(int dirNo, const SkString& filename) { |
82 init(dirNo); | 100 init(dirNo); |
83 strcpy(fFilename, filename.c_str()); | 101 strcpy(fFilename, filename.c_str()); |
84 testOne(); | 102 testOne(); |
85 } | 103 } |
86 | 104 |
87 void testOne(); | 105 void testOne(); |
88 | 106 |
89 char fFilename[kMaxLength]; | 107 char fFilename[kMaxLength]; |
90 TestStep fTestStep; | 108 TestStep fTestStep; |
91 int fDirNo; | 109 int fDirNo; |
92 int fPixelError; | 110 int fPixelError; |
93 int fTime; | 111 int fTime; |
94 bool fScaleOversized; | 112 int fScale; |
| 113 }; |
| 114 |
| 115 class SortByPixel : public TestResult { |
| 116 public: |
| 117 bool operator<(const SortByPixel& rh) const { |
| 118 return fPixelError < rh.fPixelError; |
| 119 } |
| 120 }; |
| 121 |
| 122 class SortByTime : public TestResult { |
| 123 public: |
| 124 bool operator<(const SortByTime& rh) const { |
| 125 return fTime < rh.fTime; |
| 126 } |
95 }; | 127 }; |
96 | 128 |
97 struct TestState { | 129 struct TestState { |
98 void init(int dirNo, skiatest::Reporter* reporter) { | 130 void init(int dirNo, skiatest::Reporter* reporter) { |
99 fReporter = reporter; | 131 fReporter = reporter; |
100 fResult.init(dirNo); | 132 fResult.init(dirNo); |
101 fFoundCount = 0; | |
102 TestState::fSmallCount = 0; | |
103 fSmallestError = 0; | |
104 sk_bzero(fFilesFound, sizeof(fFilesFound)); | |
105 sk_bzero(fDirsFound, sizeof(fDirsFound)); | |
106 sk_bzero(fError, sizeof(fError)); | |
107 } | 133 } |
108 | 134 |
109 static bool bumpSmallCount() { | 135 SkTDArray<SortByPixel> fPixelWorst; |
110 sk_atomic_inc(&fSmallCount); | 136 SkTDArray<SortByTime> fSlowest; |
111 return fSmallCount > kSmallLimit; | |
112 } | |
113 | |
114 static void clearSmallCount() { | |
115 if (fSmallCount < kSmallLimit) { | |
116 fSmallCount = 0; | |
117 } | |
118 } | |
119 | |
120 char fFilesFound[kMaxFiles][kMaxLength]; | |
121 int fDirsFound[kMaxFiles]; | |
122 int fError[kMaxFiles]; | |
123 int fFoundCount; | |
124 static int fSmallCount; | |
125 int fSmallestError; | |
126 skiatest::Reporter* fReporter; | 137 skiatest::Reporter* fReporter; |
127 TestResult fResult; | 138 TestResult fResult; |
128 }; | 139 }; |
129 | 140 |
130 int TestState::fSmallCount; | |
131 | |
132 struct TestRunner { | 141 struct TestRunner { |
133 TestRunner(skiatest::Reporter* reporter, int threadCount) | 142 TestRunner(skiatest::Reporter* reporter, int threadCount) |
134 : fNumThreads(threadCount) | 143 : fNumThreads(threadCount) |
135 , fReporter(reporter) { | 144 , fReporter(reporter) { |
136 } | 145 } |
137 | 146 |
138 ~TestRunner(); | 147 ~TestRunner(); |
139 void render(); | 148 void render(); |
140 int fNumThreads; | 149 int fNumThreads; |
141 SkTDArray<class TestRunnable*> fRunnables; | 150 SkTDArray<class TestRunnable*> fRunnables; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 || base[width * 2 + x] < kThreshold) { | 283 || base[width * 2 + x] < kThreshold) { |
275 continue; | 284 continue; |
276 } | 285 } |
277 errorTotal += error; | 286 errorTotal += error; |
278 } | 287 } |
279 } | 288 } |
280 return errorTotal; | 289 return errorTotal; |
281 } | 290 } |
282 | 291 |
283 static bool addError(TestState* data, const TestResult& testResult) { | 292 static bool addError(TestState* data, const TestResult& testResult) { |
284 bool foundSmaller = false; | 293 if (testResult.fPixelError <= 0 && testResult.fTime <= 0) { |
285 int dCount = data->fFoundCount; | 294 return false; |
| 295 } |
| 296 int worstCount = data->fPixelWorst.count(); |
286 int pixelError = testResult.fPixelError; | 297 int pixelError = testResult.fPixelError; |
287 if (data->fFoundCount < kMaxFiles) { | 298 if (pixelError > 0) { |
288 data->fError[dCount] = pixelError; | 299 for (int index = 0; index < worstCount; ++index) { |
289 strcpy(data->fFilesFound[dCount], testResult.fFilename); | 300 if (pixelError > data->fPixelWorst[index].fPixelError) { |
290 data->fDirsFound[dCount] = testResult.fDirNo; | 301 data->fPixelWorst[index] = *(SortByPixel*) &testResult; |
291 ++data->fFoundCount; | 302 return true; |
292 } else if (pixelError > data->fSmallestError) { | |
293 int smallest = SK_MaxS32; | |
294 int smallestIndex = 0; | |
295 for (int index = 0; index < kMaxFiles; ++index) { | |
296 if (smallest > data->fError[index]) { | |
297 smallest = data->fError[index]; | |
298 smallestIndex = index; | |
299 } | 303 } |
300 } | 304 } |
301 data->fError[smallestIndex] = pixelError; | 305 } |
302 strcpy(data->fFilesFound[smallestIndex], testResult.fFilename); | 306 int slowCount = data->fSlowest.count(); |
303 data->fDirsFound[smallestIndex] = testResult.fDirNo; | 307 int time = testResult.fTime; |
304 data->fSmallestError = SK_MaxS32; | 308 if (time > 0) { |
305 for (int index = 0; index < kMaxFiles; ++index) { | 309 for (int index = 0; index < slowCount; ++index) { |
306 if (data->fSmallestError > data->fError[index]) { | 310 if (time > data->fSlowest[index].fTime) { |
307 data->fSmallestError = data->fError[index]; | 311 data->fSlowest[index] = *(SortByTime*) &testResult; |
| 312 return true; |
308 } | 313 } |
309 } | 314 } |
310 SkDebugf("*%d*", data->fSmallestError); | |
311 foundSmaller = true; | |
312 } | 315 } |
313 return foundSmaller; | 316 if (pixelError > 0 && worstCount < kMaxFiles) { |
| 317 *data->fPixelWorst.append() = *(SortByPixel*) &testResult; |
| 318 return true; |
| 319 } |
| 320 if (time > 0 && slowCount < kMaxFiles) { |
| 321 *data->fSlowest.append() = *(SortByTime*) &testResult; |
| 322 return true; |
| 323 } |
| 324 return false; |
314 } | 325 } |
315 | 326 |
316 | |
317 | |
318 static SkMSec timePict(SkPicture* pic, SkCanvas* canvas) { | 327 static SkMSec timePict(SkPicture* pic, SkCanvas* canvas) { |
319 canvas->save(); | 328 canvas->save(); |
320 int pWidth = pic->width(); | 329 int pWidth = pic->width(); |
321 int pHeight = pic->height(); | 330 int pHeight = pic->height(); |
322 const int maxDimension = 1000; | 331 const int maxDimension = 1000; |
323 const int slices = 3; | 332 const int slices = 3; |
324 int xInterval = SkTMax(pWidth - maxDimension, 0) / (slices - 1); | 333 int xInterval = SkTMax(pWidth - maxDimension, 0) / (slices - 1); |
325 int yInterval = SkTMax(pHeight - maxDimension, 0) / (slices - 1); | 334 int yInterval = SkTMax(pHeight - maxDimension, 0) / (slices - 1); |
326 SkRect rect = {0, 0, SkIntToScalar(SkTMin(maxDimension, pWidth)), | 335 SkRect rect = {0, 0, SkIntToScalar(SkTMin(maxDimension, pWidth)), |
327 SkIntToScalar(SkTMin(maxDimension, pHeight))}; | 336 SkIntToScalar(SkTMin(maxDimension, pHeight))}; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 } else if (fTestStep == kEncodeFiles) { | 393 } else if (fTestStep == kEncodeFiles) { |
385 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH); | 394 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH); |
386 } | 395 } |
387 #endif | 396 #endif |
388 SkString path = make_filepath(fDirNo, IN_DIR, fFilename); | 397 SkString path = make_filepath(fDirNo, IN_DIR, fFilename); |
389 SkFILEStream stream(path.c_str()); | 398 SkFILEStream stream(path.c_str()); |
390 if (!stream.isValid()) { | 399 if (!stream.isValid()) { |
391 SkDebugf("invalid stream %s\n", path.c_str()); | 400 SkDebugf("invalid stream %s\n", path.c_str()); |
392 goto finish; | 401 goto finish; |
393 } | 402 } |
394 SkPicture* pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::D
ecodeMemory); | 403 pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::DecodeMemory
); |
395 if (!pic) { | 404 if (!pic) { |
396 SkDebugf("unable to decode %s\n", fFilename); | 405 SkDebugf("unable to decode %s\n", fFilename); |
397 goto finish; | 406 goto finish; |
398 } | 407 } |
399 int width = pic->width(); | 408 int width = pic->width(); |
400 int height = pic->height(); | 409 int height = pic->height(); |
401 SkBitmap oldBitmap, opBitmap; | 410 SkBitmap oldBitmap, opBitmap; |
402 int scale = 1; | 411 fScale = 1; |
403 do { | 412 do { |
404 int dimX = (width + scale - 1) / scale; | 413 int dimX = (width + fScale - 1) / fScale; |
405 int dimY = (height + scale - 1) / scale; | 414 int dimY = (height + fScale - 1) / fScale; |
406 if (oldBitmap.allocN32Pixels(dimX, dimY) && | 415 if (oldBitmap.allocN32Pixels(dimX, dimY) && |
407 opBitmap.allocN32Pixels(dimX, dimY)) { | 416 opBitmap.allocN32Pixels(dimX, dimY)) { |
408 break; | 417 break; |
409 } | 418 } |
410 SkDebugf("-%d-", scale); | 419 SkDebugf("-%d-", fScale); |
411 } while ((scale *= 2) < 256); | 420 } while ((fScale *= 2) < 256); |
412 if (scale >= 256) { | 421 if (fScale >= 256) { |
413 SkDebugf("unable to allocate bitmap for %s (w=%d h=%d)\n", fFilename
, | 422 SkDebugf("unable to allocate bitmap for %s (w=%d h=%d)\n", fFilename
, |
414 width, height); | 423 width, height); |
415 return; | 424 goto finish; |
416 } | 425 } |
417 oldBitmap.eraseColor(SK_ColorWHITE); | 426 oldBitmap.eraseColor(SK_ColorWHITE); |
418 SkCanvas oldCanvas(oldBitmap); | 427 SkCanvas oldCanvas(oldBitmap); |
419 oldCanvas.setAllowSimplifyClip(false); | 428 oldCanvas.setAllowSimplifyClip(false); |
420 opBitmap.eraseColor(SK_ColorWHITE); | 429 opBitmap.eraseColor(SK_ColorWHITE); |
421 SkCanvas opCanvas(opBitmap); | 430 SkCanvas opCanvas(opBitmap); |
422 opCanvas.setAllowSimplifyClip(true); | 431 opCanvas.setAllowSimplifyClip(true); |
423 drawPict(pic, &oldCanvas, fScaleOversized ? scale : 1); | 432 drawPict(pic, &oldCanvas, fScale); |
424 drawPict(pic, &opCanvas, fScaleOversized ? scale : 1); | 433 drawPict(pic, &opCanvas, fScale); |
425 if (fTestStep == kCompareBits) { | 434 if (fTestStep == kCompareBits) { |
426 fPixelError = similarBits(oldBitmap, opBitmap); | 435 fPixelError = similarBits(oldBitmap, opBitmap); |
427 int oldTime = timePict(pic, &oldCanvas); | 436 int oldTime = timePict(pic, &oldCanvas); |
428 int opTime = timePict(pic, &opCanvas); | 437 int opTime = timePict(pic, &opCanvas); |
429 fTime = oldTime - opTime; | 438 fTime = SkTMax(0, oldTime - opTime); |
430 } else if (fTestStep == kEncodeFiles) { | 439 } else if (fTestStep == kEncodeFiles) { |
431 SkString pngStr = make_png_name(fFilename); | 440 SkString pngStr = make_png_name(fFilename); |
432 const char* pngName = pngStr.c_str(); | 441 const char* pngName = pngStr.c_str(); |
433 writePict(oldBitmap, outOldDir, pngName); | 442 writePict(oldBitmap, outOldDir, pngName); |
434 writePict(opBitmap, outOpDir, pngName); | 443 writePict(opBitmap, outOpDir, pngName); |
435 } | 444 } |
436 } | 445 } |
437 finish: | 446 finish: |
438 SkDELETE(pic); | 447 if (pic) { |
| 448 pic->unref(); |
| 449 } |
439 } | 450 } |
440 | 451 |
441 static SkString makeStatusString(int dirNo) { | 452 static SkString makeStatusString(int dirNo) { |
442 SkString statName; | 453 SkString statName; |
443 statName.printf("stats%d.txt", dirNo); | 454 statName.printf("stats%d.txt", dirNo); |
444 SkString statusFile = make_filepath(0, outStatusDir, statName.c_str()); | 455 SkString statusFile = make_filepath(0, outStatusDir, statName.c_str()); |
445 return statusFile; | 456 return statusFile; |
446 } | 457 } |
447 | 458 |
448 class PreParser { | 459 class PreParser { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 private: | 532 private: |
522 int fDirNo; | 533 int fDirNo; |
523 int fIndex; | 534 int fIndex; |
524 SkTArray<TestResult, true> fResults; | 535 SkTArray<TestResult, true> fResults; |
525 }; | 536 }; |
526 | 537 |
527 static bool doOneDir(TestState* state) { | 538 static bool doOneDir(TestState* state) { |
528 int dirNo = state->fResult.fDirNo; | 539 int dirNo = state->fResult.fDirNo; |
529 skiatest::Reporter* reporter = state->fReporter; | 540 skiatest::Reporter* reporter = state->fReporter; |
530 SkString dirName = make_in_dir_name(dirNo); | 541 SkString dirName = make_in_dir_name(dirNo); |
531 SkASSERT(dirName.size()); | 542 if (!dirName.size()) { |
| 543 return false; |
| 544 } |
532 SkOSFile::Iter iter(dirName.c_str(), "skp"); | 545 SkOSFile::Iter iter(dirName.c_str(), "skp"); |
533 SkString filename; | 546 SkString filename; |
534 int testCount = 0; | 547 int testCount = 0; |
535 PreParser preParser(dirNo); | 548 PreParser preParser(dirNo); |
536 SkFILEWStream statusStream(makeStatusString(dirNo).c_str()); | 549 SkFILEWStream statusStream(makeStatusString(dirNo).c_str()); |
537 while (iter.next(&filename)) { | 550 while (iter.next(&filename)) { |
538 for (size_t index = 0; index < skipOverSeptCount; ++index) { | 551 for (size_t index = 0; index < skipOverSeptCount; ++index) { |
539 if (skipOverSept[index].directory == dirNo | 552 if (skipOverSept[index].directory == dirNo |
540 && strcmp(filename.c_str(), skipOverSept[index].filename) ==
0) { | 553 && strcmp(filename.c_str(), skipOverSept[index].filename) ==
0) { |
541 goto skipOver; | 554 goto checkEarlyExit; |
542 } | 555 } |
543 } | 556 } |
544 if (preParser.match(filename, &statusStream, &state->fResult)) { | 557 if (preParser.match(filename, &statusStream, &state->fResult)) { |
545 addError(state, state->fResult); | 558 (void) addError(state, state->fResult); |
546 ++testCount; | 559 ++testCount; |
547 goto checkEarlyExit; | 560 goto checkEarlyExit; |
548 } | 561 } |
549 if (state->fSmallestError > 5000000) { | |
550 return false; | |
551 } | |
552 { | 562 { |
553 TestResult& result = state->fResult; | 563 TestResult& result = state->fResult; |
554 result.test(dirNo, filename); | 564 result.test(dirNo, filename); |
555 SkString outStr(result.status()); | 565 SkString outStr(result.status()); |
556 statusStream.write(outStr.c_str(), outStr.size()); | 566 statusStream.write(outStr.c_str(), outStr.size()); |
557 statusStream.flush(); | 567 statusStream.flush(); |
558 if (1) { | 568 if (addError(state, result)) { |
559 SkDebugf("%s", outStr.c_str()); | 569 SkDebugf("%s", result.progress().c_str()); |
560 } | |
561 bool noMatch = addError(state, state->fResult); | |
562 if (noMatch) { | |
563 state->clearSmallCount(); | |
564 } else if (state->bumpSmallCount()) { | |
565 return false; | |
566 } | 570 } |
567 } | 571 } |
568 ++testCount; | 572 ++testCount; |
569 if (reporter->verbose()) { | 573 if (reporter->verbose()) { |
570 SkDebugf("."); | 574 SkDebugf("."); |
571 if (++testCount % 100 == 0) { | 575 if (++testCount % 100 == 0) { |
572 SkDebugf("%d\n", testCount); | 576 SkDebugf("%d\n", testCount); |
573 } | 577 } |
574 } | 578 } |
575 skipOver: | |
576 if (reporter->verbose()) { | |
577 static int threadTestCount; | |
578 SkDebugf("."); | |
579 sk_atomic_inc(&threadTestCount); | |
580 if (threadTestCount % 100 == 0) { | |
581 SkDebugf("%d\n", threadTestCount); | |
582 } | |
583 } | |
584 checkEarlyExit: | 579 checkEarlyExit: |
585 if (1 && testCount == 20) { | 580 if (0 && testCount >= 1) { |
586 return true; | 581 return true; |
587 } | 582 } |
588 } | 583 } |
589 return true; | 584 return true; |
590 } | 585 } |
591 | 586 |
592 static bool initTest() { | 587 static bool initTest() { |
593 #if !defined SK_BUILD_FOR_WIN && !defined SK_BUILD_FOR_MAC | 588 #if !defined SK_BUILD_FOR_WIN && !defined SK_BUILD_FOR_MAC |
594 SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true); | 589 SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true); |
595 SK_CONF_SET("images.png.suppressDecoderWarnings", true); | 590 SK_CONF_SET("images.png.suppressDecoderWarnings", true); |
596 #endif | 591 #endif |
597 return make_out_dirs(); | 592 return make_out_dirs(); |
598 } | 593 } |
599 | 594 |
600 static void encodeFound(skiatest::Reporter* reporter, TestState& state) { | 595 static void encodeFound(skiatest::Reporter* reporter, TestState& state) { |
601 if (reporter->verbose()) { | 596 if (reporter->verbose()) { |
602 for (int index = 0; index < state.fFoundCount; ++index) { | 597 SkTDArray<SortByPixel*> worst; |
603 SkDebugf("%d %s %d\n", state.fDirsFound[index], state.fFilesFound[in
dex], | 598 for (int index = 0; index < state.fPixelWorst.count(); ++index) { |
604 state.fError[index]); | 599 *worst.append() = &state.fPixelWorst[index]; |
| 600 } |
| 601 SkTQSort<SortByPixel>(worst.begin(), worst.end() - 1); |
| 602 for (int index = 0; index < state.fPixelWorst.count(); ++index) { |
| 603 const TestResult& result = *worst[index]; |
| 604 SkDebugf("%d %s pixelError=%d\n", result.fDirNo, result.fFilename, r
esult.fPixelError); |
| 605 } |
| 606 SkTDArray<SortByTime*> slowest; |
| 607 for (int index = 0; index < state.fSlowest.count(); ++index) { |
| 608 *slowest.append() = &state.fSlowest[index]; |
| 609 } |
| 610 SkTQSort<SortByTime>(slowest.begin(), slowest.end() - 1); |
| 611 for (int index = 0; index < slowest.count(); ++index) { |
| 612 const TestResult& result = *slowest[index]; |
| 613 SkDebugf("%d %s time=%d\n", result.fDirNo, result.fFilename, result.
fTime); |
605 } | 614 } |
606 } | 615 } |
607 for (int index = 0; index < state.fFoundCount; ++index) { | 616 for (int index = 0; index < state.fPixelWorst.count(); ++index) { |
608 TestResult::Test(state.fDirsFound[index], state.fFilesFound[index], kEnc
odeFiles); | 617 const TestResult& result = state.fPixelWorst[index]; |
| 618 TestResult::Test(result.fDirNo, result.fFilename, kEncodeFiles); |
609 if (state.fReporter->verbose()) SkDebugf("+"); | 619 if (state.fReporter->verbose()) SkDebugf("+"); |
610 } | 620 } |
611 } | 621 } |
612 | 622 |
613 DEF_TEST(PathOpsSkpClip, reporter) { | 623 DEF_TEST(PathOpsSkpClip, reporter) { |
614 if (!initTest()) { | 624 if (!initTest()) { |
615 return; | 625 return; |
616 } | 626 } |
617 SkTArray<TestResult, true> errors; | 627 SkTArray<TestResult, true> errors; |
618 TestState state; | 628 TestState state; |
(...skipping 22 matching lines...) Expand all Loading... |
641 TestRunner testRunner(reporter, threadCount); | 651 TestRunner testRunner(reporter, threadCount); |
642 for (int dirNo = 1; dirNo <= 100; ++dirNo) { | 652 for (int dirNo = 1; dirNo <= 100; ++dirNo) { |
643 *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnable, | 653 *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnable, |
644 (&testSkpClipMain, dirNo, &testRunner)); | 654 (&testSkpClipMain, dirNo, &testRunner)); |
645 } | 655 } |
646 testRunner.render(); | 656 testRunner.render(); |
647 TestState state; | 657 TestState state; |
648 state.init(0, reporter); | 658 state.init(0, reporter); |
649 for (int dirNo = 1; dirNo <= 100; ++dirNo) { | 659 for (int dirNo = 1; dirNo <= 100; ++dirNo) { |
650 TestState& testState = testRunner.fRunnables[dirNo - 1]->fState; | 660 TestState& testState = testRunner.fRunnables[dirNo - 1]->fState; |
651 for (int inner = 0; inner < testState.fFoundCount; ++inner) { | 661 for (int inner = 0; inner < testState.fPixelWorst.count(); ++inner) { |
652 TestResult& testResult = testState.fResult; | 662 SkASSERT(testState.fResult.fDirNo == dirNo); |
653 SkASSERT(testResult.fDirNo == dirNo); | 663 addError(&state, testState.fPixelWorst[inner]); |
654 testResult.fPixelError = testState.fError[inner]; | |
655 strcpy(testResult.fFilename, testState.fFilesFound[inner]); | |
656 addError(&state, testResult); | |
657 } | 664 } |
658 } | 665 } |
659 encodeFound(reporter, state); | 666 encodeFound(reporter, state); |
660 } | 667 } |
661 | 668 |
662 DEF_TEST(PathOpsSkpClipOneOff, reporter) { | 669 DEF_TEST(PathOpsSkpClipOneOff, reporter) { |
663 if (!initTest()) { | 670 if (!initTest()) { |
664 return; | 671 return; |
665 } | 672 } |
666 const int testIndex = 43 - 41; | 673 const int testIndex = 43 - 37; |
667 int dirNo = skipOverSept[testIndex].directory; | 674 int dirNo = skipOverSept[testIndex].directory; |
668 SkAssertResult(make_in_dir_name(dirNo).size()); | 675 SkAssertResult(make_in_dir_name(dirNo).size()); |
669 SkString filename(skipOverSept[testIndex].filename); | 676 SkString filename(skipOverSept[testIndex].filename); |
670 TestResult state; | 677 TestResult state; |
671 state.test(dirNo, filename); | 678 state.test(dirNo, filename); |
672 if (reporter->verbose()) { | 679 if (reporter->verbose()) { |
673 SkDebugf("%s", state.status().c_str()); | 680 SkDebugf("%s", state.status().c_str()); |
674 } | 681 } |
675 state.fTestStep = kEncodeFiles; | 682 state.fTestStep = kEncodeFiles; |
676 state.testOne(); | 683 state.testOne(); |
677 } | 684 } |
OLD | NEW |