OLD | NEW |
1 #include "PathOpsExtendedTest.h" | 1 |
2 #include "PathOpsThreadedCommon.h" | |
3 #include "SkBitmap.h" | 2 #include "SkBitmap.h" |
| 3 #include "SkCanvas.h" |
4 #include "SkColor.h" | 4 #include "SkColor.h" |
| 5 #include "SkColorPriv.h" |
5 #include "SkDevice.h" | 6 #include "SkDevice.h" |
6 #include "SkCanvas.h" | 7 #include "SkGraphics.h" |
7 #include "SkImageDecoder.h" | 8 #include "SkImageDecoder.h" |
8 #include "SkImageEncoder.h" | 9 #include "SkImageEncoder.h" |
| 10 #include "SkOSFile.h" |
| 11 #include "SkPathOpsDebug.h" |
| 12 #include "SkPicture.h" |
| 13 #include "SkRTConf.h" |
9 #include "SkStream.h" | 14 #include "SkStream.h" |
10 #include "SkOSFile.h" | |
11 #include "SkPicture.h" | |
12 #include "SkString.h" | 15 #include "SkString.h" |
| 16 #include "SkTArray.h" |
| 17 #include "SkTDArray.h" |
| 18 #include "SkThreadPool.h" |
| 19 #include "SkTime.h" |
| 20 #include "Test.h" |
13 | 21 |
14 #ifdef SK_BUILD_FOR_WIN | 22 #ifdef SK_BUILD_FOR_WIN |
15 #define PATH_SLASH "\\" | 23 #define PATH_SLASH "\\" |
16 #define IN_DIR "D:" PATH_SLASH "skp" | 24 #define IN_DIR "D:\\9-30-13\\" |
17 #define OUT_DIR "D:" PATH_SLASH | 25 #define OUT_DIR "D:\\opSkpClip\\1\\" |
18 #else | 26 #else |
19 #define PATH_SLASH "/" | 27 #define PATH_SLASH "/" |
20 #if 1 | 28 #ifdef SK_BUILD_FOR_MAC |
21 #define IN_DIR "/usr/local/google/home/caryclark/new10k" PATH_SLASH | 29 #define IN_DIR "/Volumes/tera/9-30-13/skp" |
22 #define OUT_DIR "/usr/local/google/home/caryclark/out10k" PATH_SLASH | 30 #define OUT_DIR "/Volumes/tera/out/9-30-13/1/" |
23 #else | 31 #else |
24 #define IN_DIR "/usr/local/google/home/caryclark/6-18-13" PATH_SLASH | 32 #define IN_DIR "/usr/local/google/home/caryclark/skps/9-30-13/skp" |
25 #define OUT_DIR "/usr/local/google/home/caryclark" PATH_SLASH | 33 #define OUT_DIR "/mnt/skia/opSkpClip/1/" |
26 #endif | 34 #endif |
27 #endif | 35 #endif |
28 | 36 |
29 static const char pictDir[] = IN_DIR ; | 37 const struct { |
30 static const char outSkpClipDir[] = OUT_DIR "skpClip"; | 38 int directory; |
31 static const char outOldClipDir[] = OUT_DIR "oldClip"; | 39 const char* filename; |
32 | 40 } skipOverSept[] = { |
33 static SkString make_filepath(const char* dir, const SkString& name) { | 41 {9, "http___www_symptome_ch_.skp"}, // triangle clip with corner at x.999 |
| 42 {11, "http___www_menly_fr_.skp"}, |
| 43 {12, "http___www_banrasdr_com_.skp"}, |
| 44 }; |
| 45 |
| 46 size_t skipOverSeptCount = sizeof(skipOverSept) / sizeof(skipOverSept[0]); |
| 47 |
| 48 enum TestStep { |
| 49 kCompareBits, |
| 50 kEncodeFiles, |
| 51 }; |
| 52 |
| 53 enum { |
| 54 kMaxLength = 128, |
| 55 kMaxFiles = 128, |
| 56 kSmallLimit = 1000, |
| 57 }; |
| 58 |
| 59 struct TestResult { |
| 60 void init(int dirNo) { |
| 61 fDirNo = dirNo; |
| 62 sk_bzero(fFilename, sizeof(fFilename)); |
| 63 fTestStep = kCompareBits; |
| 64 fScaleOversized = true; |
| 65 } |
| 66 |
| 67 SkString status() { |
| 68 SkString outStr; |
| 69 outStr.printf("%s %d %d\n", fFilename, fPixelError, fTime); |
| 70 return outStr; |
| 71 } |
| 72 |
| 73 static void Test(int dirNo, const char* filename, TestStep testStep) { |
| 74 TestResult test; |
| 75 test.init(dirNo); |
| 76 test.fTestStep = testStep; |
| 77 strcpy(test.fFilename, filename); |
| 78 test.testOne(); |
| 79 } |
| 80 |
| 81 void test(int dirNo, const SkString& filename) { |
| 82 init(dirNo); |
| 83 strcpy(fFilename, filename.c_str()); |
| 84 testOne(); |
| 85 } |
| 86 |
| 87 void testOne(); |
| 88 |
| 89 char fFilename[kMaxLength]; |
| 90 TestStep fTestStep; |
| 91 int fDirNo; |
| 92 int fPixelError; |
| 93 int fTime; |
| 94 bool fScaleOversized; |
| 95 }; |
| 96 |
| 97 struct TestState { |
| 98 void init(int dirNo, skiatest::Reporter* reporter) { |
| 99 fReporter = reporter; |
| 100 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 } |
| 108 |
| 109 static bool bumpSmallCount() { |
| 110 sk_atomic_inc(&fSmallCount); |
| 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; |
| 127 TestResult fResult; |
| 128 }; |
| 129 |
| 130 int TestState::fSmallCount; |
| 131 |
| 132 struct TestRunner { |
| 133 TestRunner(skiatest::Reporter* reporter, int threadCount) |
| 134 : fNumThreads(threadCount) |
| 135 , fReporter(reporter) { |
| 136 } |
| 137 |
| 138 ~TestRunner(); |
| 139 void render(); |
| 140 int fNumThreads; |
| 141 SkTDArray<class TestRunnable*> fRunnables; |
| 142 skiatest::Reporter* fReporter; |
| 143 }; |
| 144 |
| 145 class TestRunnable : public SkRunnable { |
| 146 public: |
| 147 TestRunnable(void (*testFun)(TestState*), int dirNo, TestRunner* runner) { |
| 148 fState.init(dirNo, runner->fReporter); |
| 149 fTestFun = testFun; |
| 150 } |
| 151 |
| 152 virtual void run() SK_OVERRIDE { |
| 153 SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024); |
| 154 (*fTestFun)(&fState); |
| 155 } |
| 156 |
| 157 TestState fState; |
| 158 void (*fTestFun)(TestState*); |
| 159 }; |
| 160 |
| 161 TestRunner::~TestRunner() { |
| 162 for (int index = 0; index < fRunnables.count(); index++) { |
| 163 SkDELETE(fRunnables[index]); |
| 164 } |
| 165 } |
| 166 |
| 167 void TestRunner::render() { |
| 168 SkThreadPool pool(fNumThreads); |
| 169 for (int index = 0; index < fRunnables.count(); ++ index) { |
| 170 pool.add(fRunnables[index]); |
| 171 } |
| 172 } |
| 173 |
| 174 //////////////////////////////////////////////// |
| 175 |
| 176 static const char outOpDir[] = OUT_DIR "opClip"; |
| 177 static const char outOldDir[] = OUT_DIR "oldClip"; |
| 178 static const char outSkpDir[] = OUT_DIR "skpTest"; |
| 179 static const char outDiffDir[] = OUT_DIR "outTest"; |
| 180 static const char outStatusDir[] = OUT_DIR "statusTest"; |
| 181 |
| 182 static SkString make_filepath(int dirNo, const char* dir, const char* name) { |
34 SkString path(dir); | 183 SkString path(dir); |
35 size_t len = strlen(dir); | 184 if (dirNo) { |
36 if (len > 0 && dir[len - 1] != PATH_SLASH[0]) { | 185 path.appendf("%d", dirNo); |
37 path.append(PATH_SLASH); | 186 } |
38 } | 187 path.append(PATH_SLASH); |
39 path.append(name); | 188 path.append(name); |
40 return path; | 189 return path; |
41 } | 190 } |
42 | 191 |
43 static SkString make_png_name(const SkString& filename) { | 192 static SkString make_in_dir_name(int dirNo) { |
| 193 SkString dirName(IN_DIR); |
| 194 dirName.appendf("%d", dirNo); |
| 195 if (!sk_exists(dirName.c_str())) { |
| 196 SkDebugf("could not read dir %s\n", dirName.c_str()); |
| 197 return SkString(); |
| 198 } |
| 199 return dirName; |
| 200 } |
| 201 |
| 202 static bool make_one_out_dir(const char* outDirStr) { |
| 203 SkString outDir = make_filepath(0, outDirStr, ""); |
| 204 if (!sk_exists(outDir.c_str())) { |
| 205 if (!sk_mkdir(outDir.c_str())) { |
| 206 SkDebugf("could not create dir %s\n", outDir.c_str()); |
| 207 return false; |
| 208 } |
| 209 } |
| 210 return true; |
| 211 } |
| 212 |
| 213 static bool make_out_dirs() { |
| 214 SkString outDir = make_filepath(0, OUT_DIR, ""); |
| 215 if (!sk_exists(outDir.c_str())) { |
| 216 if (!sk_mkdir(outDir.c_str())) { |
| 217 SkDebugf("could not create dir %s\n", outDir.c_str()); |
| 218 return false; |
| 219 } |
| 220 } |
| 221 return make_one_out_dir(outOldDir) |
| 222 && make_one_out_dir(outOpDir) |
| 223 && make_one_out_dir(outSkpDir) |
| 224 && make_one_out_dir(outDiffDir) |
| 225 && make_one_out_dir(outStatusDir); |
| 226 } |
| 227 |
| 228 static SkString make_png_name(const char* filename) { |
44 SkString pngName = SkString(filename); | 229 SkString pngName = SkString(filename); |
45 pngName.remove(pngName.size() - 3, 3); | 230 pngName.remove(pngName.size() - 3, 3); |
46 pngName.append("png"); | 231 pngName.append("png"); |
47 return pngName; | 232 return pngName; |
48 } | 233 } |
49 | 234 |
50 static void testOne(const SkString& filename) { | 235 static int similarBits(const SkBitmap& gr, const SkBitmap& sk) { |
51 if (filename == SkString("http___migracioncolombia_gov_co.skp") | 236 const int kRowCount = 3; |
52 || filename == SkString("http___miuki_info.skp") | 237 const int kThreshold = 3; |
53 ) { | 238 int width = SkTMin(gr.width(), sk.width()); |
54 return; | 239 if (width < kRowCount) { |
55 } | 240 return true; |
56 #if DEBUG_SHOW_TEST_NAME | 241 } |
57 SkString testName(filename); | 242 int height = SkTMin(gr.height(), sk.height()); |
58 const char http[] = "http"; | 243 if (height < kRowCount) { |
59 if (testName.startsWith(http)) { | 244 return true; |
60 testName.remove(0, sizeof(http) - 1); | 245 } |
61 } | 246 int errorTotal = 0; |
62 while (testName.startsWith("_")) { | 247 SkTArray<int, true> errorRows; |
63 testName.remove(0, 1); | 248 errorRows.push_back_n(width * kRowCount); |
64 } | 249 SkAutoLockPixels autoGr(gr); |
65 const char dotSkp[] = ".skp"; | 250 SkAutoLockPixels autoSk(sk); |
66 if (testName.endsWith(dotSkp)) { | 251 for (int y = 0; y < height; ++y) { |
67 size_t len = testName.size(); | 252 SkPMColor* grRow = gr.getAddr32(0, y); |
68 testName.remove(len - (sizeof(dotSkp) - 1), sizeof(dotSkp) - 1); | 253 SkPMColor* skRow = sk.getAddr32(0, y); |
69 } | 254 int* base = &errorRows[0]; |
70 testName.prepend("skp"); | 255 int* cOut = &errorRows[y % kRowCount]; |
71 testName.append("1"); | 256 for (int x = 0; x < width; ++x) { |
72 strncpy(DEBUG_FILENAME_STRING, testName.c_str(), DEBUG_FILENAME_STRING_LENGT
H); | 257 SkPMColor grColor = grRow[x]; |
73 #endif | 258 SkPMColor skColor = skRow[x]; |
74 SkString path = make_filepath(pictDir, filename); | 259 int dr = SkGetPackedR32(grColor) - SkGetPackedR32(skColor); |
75 SkFILEStream stream(path.c_str()); | 260 int dg = SkGetPackedG32(grColor) - SkGetPackedG32(skColor); |
76 if (!stream.isValid()) { | 261 int db = SkGetPackedB32(grColor) - SkGetPackedB32(skColor); |
77 return; | 262 int error = cOut[x] = SkTMax(SkAbs32(dr), SkTMax(SkAbs32(dg), SkAbs3
2(db))); |
78 } | 263 if (error < kThreshold || x < 2) { |
79 SkPicture* pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::Decod
eMemory); | 264 continue; |
80 if (!pic) { | 265 } |
81 SkDebugf("unable to decode %s\n", filename.c_str()); | 266 if (base[x - 2] < kThreshold |
82 return; | 267 || base[width + x - 2] < kThreshold |
83 } | 268 || base[width * 2 + x - 2] < kThreshold |
84 int width = pic->width(); | 269 || base[x - 1] < kThreshold |
85 int height = pic->height(); | 270 || base[width + x - 1] < kThreshold |
86 | 271 || base[width * 2 + x - 1] < kThreshold |
87 SkBitmap bitmap; | 272 || base[x] < kThreshold |
88 int scale = 1; | 273 || base[width + x] < kThreshold |
89 do { | 274 || base[width * 2 + x] < kThreshold) { |
90 bitmap.setConfig(SkBitmap::kARGB_8888_Config, (width + scale - 1) / scal
e, | 275 continue; |
91 (height + scale - 1) / scale); | 276 } |
92 bool success = bitmap.allocPixels(); | 277 errorTotal += error; |
93 bitmap.eraseColor(SK_ColorWHITE); | 278 } |
94 if (success) { | 279 } |
95 break; | 280 return errorTotal; |
96 } | 281 } |
97 SkDebugf("-%d-", scale); | 282 |
98 } while ((scale *= 2) < 32); | 283 static bool addError(TestState* data, const TestResult& testResult) { |
99 if (scale >= 32) { | 284 bool foundSmaller = false; |
100 SkDebugf("unable to allocate bitmap for %s (w=%d h=%d)\n", filename.c_st
r(), | 285 int dCount = data->fFoundCount; |
101 width, height); | 286 int pixelError = testResult.fPixelError; |
102 return; | 287 if (data->fFoundCount < kMaxFiles) { |
103 } | 288 data->fError[dCount] = pixelError; |
104 SkCanvas canvas(bitmap); | 289 strcpy(data->fFilesFound[dCount], testResult.fFilename); |
105 canvas.scale(1.0f / scale, 1.0f / scale); | 290 data->fDirsFound[dCount] = testResult.fDirNo; |
106 SkString pngName = make_png_name(filename); | 291 ++data->fFoundCount; |
107 for (int i = 0; i < 2; ++i) { | 292 } else if (pixelError > data->fSmallestError) { |
108 bool useOp = i ? true : false; | 293 int smallest = SK_MaxS32; |
109 canvas.setAllowSimplifyClip(useOp); | 294 int smallestIndex = 0; |
110 pic->draw(&canvas); | 295 for (int index = 0; index < kMaxFiles; ++index) { |
111 SkString outFile = make_filepath(useOp ? outSkpClipDir : outOldClipDir,
pngName); | 296 if (smallest > data->fError[index]) { |
112 if (!SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder:
:kPNG_Type, | 297 smallest = data->fError[index]; |
113 100)) { | 298 smallestIndex = index; |
114 SkDebugf("unable to encode %s (width=%d height=%d)\n", pngName.c_str
(), | 299 } |
115 bitmap.width(), bitmap.height()); | 300 } |
116 } | 301 data->fError[smallestIndex] = pixelError; |
117 } | 302 strcpy(data->fFilesFound[smallestIndex], testResult.fFilename); |
| 303 data->fDirsFound[smallestIndex] = testResult.fDirNo; |
| 304 data->fSmallestError = SK_MaxS32; |
| 305 for (int index = 0; index < kMaxFiles; ++index) { |
| 306 if (data->fSmallestError > data->fError[index]) { |
| 307 data->fSmallestError = data->fError[index]; |
| 308 } |
| 309 } |
| 310 SkDebugf("*%d*", data->fSmallestError); |
| 311 foundSmaller = true; |
| 312 } |
| 313 return foundSmaller; |
| 314 } |
| 315 |
| 316 |
| 317 |
| 318 static SkMSec timePict(SkPicture* pic, SkCanvas* canvas) { |
| 319 canvas->save(); |
| 320 int pWidth = pic->width(); |
| 321 int pHeight = pic->height(); |
| 322 const int maxDimension = 1000; |
| 323 const int slices = 3; |
| 324 int xInterval = SkTMax(pWidth - maxDimension, 0) / (slices - 1); |
| 325 int yInterval = SkTMax(pHeight - maxDimension, 0) / (slices - 1); |
| 326 SkRect rect = {0, 0, SkIntToScalar(SkTMin(maxDimension, pWidth)), |
| 327 SkIntToScalar(SkTMin(maxDimension, pHeight))}; |
| 328 canvas->clipRect(rect); |
| 329 SkMSec start = SkTime::GetMSecs(); |
| 330 for (int x = 0; x < slices; ++x) { |
| 331 for (int y = 0; y < slices; ++y) { |
| 332 pic->draw(canvas); |
| 333 canvas->translate(0, SkIntToScalar(yInterval)); |
| 334 } |
| 335 canvas->translate(SkIntToScalar(xInterval), SkIntToScalar(-yInterval * s
lices)); |
| 336 } |
| 337 SkMSec end = SkTime::GetMSecs(); |
| 338 canvas->restore(); |
| 339 return end - start; |
| 340 } |
| 341 |
| 342 static void drawPict(SkPicture* pic, SkCanvas* canvas, int scale) { |
| 343 canvas->clear(SK_ColorWHITE); |
| 344 if (scale != 1) { |
| 345 canvas->save(); |
| 346 canvas->scale(1.0f / scale, 1.0f / scale); |
| 347 } |
| 348 pic->draw(canvas); |
| 349 if (scale != 1) { |
| 350 canvas->restore(); |
| 351 } |
| 352 } |
| 353 |
| 354 static void writePict(const SkBitmap& bitmap, const char* outDir, const char* pn
gName) { |
| 355 SkString outFile = make_filepath(0, outDir, pngName); |
| 356 if (!SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, |
| 357 SkImageEncoder::kPNG_Type, 100)) { |
| 358 SkDebugf("unable to encode gr %s (width=%d height=%d)\n", pngName, |
| 359 bitmap.width(), bitmap.height()); |
| 360 } |
| 361 } |
| 362 |
| 363 void TestResult::testOne() { |
| 364 SkPicture* pic = NULL; |
| 365 { |
| 366 #if DEBUG_SHOW_TEST_NAME |
| 367 if (fTestStep == kCompareBits) { |
| 368 SkString testName(fFilename); |
| 369 const char http[] = "http"; |
| 370 if (testName.startsWith(http)) { |
| 371 testName.remove(0, sizeof(http) - 1); |
| 372 } |
| 373 while (testName.startsWith("_")) { |
| 374 testName.remove(0, 1); |
| 375 } |
| 376 const char dotSkp[] = ".skp"; |
| 377 if (testName.endsWith(dotSkp)) { |
| 378 size_t len = testName.size(); |
| 379 testName.remove(len - (sizeof(dotSkp) - 1), sizeof(dotSkp) - 1); |
| 380 } |
| 381 testName.prepend("skp"); |
| 382 testName.append("1"); |
| 383 strncpy(DEBUG_FILENAME_STRING, testName.c_str(), DEBUG_FILENAME_STRI
NG_LENGTH); |
| 384 } else if (fTestStep == kEncodeFiles) { |
| 385 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH); |
| 386 } |
| 387 #endif |
| 388 SkString path = make_filepath(fDirNo, IN_DIR, fFilename); |
| 389 SkFILEStream stream(path.c_str()); |
| 390 if (!stream.isValid()) { |
| 391 SkDebugf("invalid stream %s\n", path.c_str()); |
| 392 goto finish; |
| 393 } |
| 394 SkPicture* pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::D
ecodeMemory); |
| 395 if (!pic) { |
| 396 SkDebugf("unable to decode %s\n", fFilename); |
| 397 goto finish; |
| 398 } |
| 399 int width = pic->width(); |
| 400 int height = pic->height(); |
| 401 SkBitmap oldBitmap, opBitmap; |
| 402 int scale = 1; |
| 403 do { |
| 404 int dimX = (width + scale - 1) / scale; |
| 405 int dimY = (height + scale - 1) / scale; |
| 406 oldBitmap.setConfig(SkBitmap::kARGB_8888_Config, dimX, dimY); |
| 407 opBitmap.setConfig(SkBitmap::kARGB_8888_Config, dimX, dimY); |
| 408 bool success = oldBitmap.allocPixels() && opBitmap.allocPixels(); |
| 409 if (success) { |
| 410 break; |
| 411 } |
| 412 SkDebugf("-%d-", scale); |
| 413 } while ((scale *= 2) < 256); |
| 414 if (scale >= 256) { |
| 415 SkDebugf("unable to allocate bitmap for %s (w=%d h=%d)\n", fFilename
, |
| 416 width, height); |
| 417 return; |
| 418 } |
| 419 oldBitmap.eraseColor(SK_ColorWHITE); |
| 420 SkCanvas oldCanvas(oldBitmap); |
| 421 oldCanvas.setAllowSimplifyClip(false); |
| 422 opBitmap.eraseColor(SK_ColorWHITE); |
| 423 SkCanvas opCanvas(opBitmap); |
| 424 opCanvas.setAllowSimplifyClip(true); |
| 425 drawPict(pic, &oldCanvas, fScaleOversized ? scale : 1); |
| 426 drawPict(pic, &opCanvas, fScaleOversized ? scale : 1); |
| 427 if (fTestStep == kCompareBits) { |
| 428 fPixelError = similarBits(oldBitmap, opBitmap); |
| 429 int oldTime = timePict(pic, &oldCanvas); |
| 430 int opTime = timePict(pic, &opCanvas); |
| 431 fTime = oldTime - opTime; |
| 432 } else if (fTestStep == kEncodeFiles) { |
| 433 SkString pngStr = make_png_name(fFilename); |
| 434 const char* pngName = pngStr.c_str(); |
| 435 writePict(oldBitmap, outOldDir, pngName); |
| 436 writePict(opBitmap, outOpDir, pngName); |
| 437 } |
| 438 } |
| 439 finish: |
118 SkDELETE(pic); | 440 SkDELETE(pic); |
119 } | 441 } |
120 | 442 |
121 const char* tryFixed[] = { | 443 static SkString makeStatusString(int dirNo) { |
122 0 | 444 SkString statName; |
123 }; | 445 statName.printf("stats%d.txt", dirNo); |
124 | 446 SkString statusFile = make_filepath(0, outStatusDir, statName.c_str()); |
125 size_t tryFixedCount = sizeof(tryFixed) / sizeof(tryFixed[0]); | 447 return statusFile; |
126 | 448 } |
127 const char* skipOver[] = { | 449 |
128 "http___carpetplanet_ru.skp", // cubic/cubic intersect | 450 class PreParser { |
129 "http___carrot_is.skp", // bridgeOp() SkASSERT(unsortable || !current->don
e()); | 451 public: |
130 | 452 PreParser(int dirNo) |
131 /*!*/"http___dotsrc_org.skp", // asserts in png decode | 453 : fDirNo(dirNo) |
132 "http___frauen_magazin_com.skp", // bridgeOp() SkASSERT(unsortable || !cur
rent->done()); | 454 , fIndex(0) { |
133 "http___i_gino_com.skp", // unexpected cubic/quad coincidence | 455 SkString statusPath = makeStatusString(dirNo); |
134 // {61, 857, 61, 789.06897, 116.068977, 734, 184, 73
4} | 456 if (!sk_exists(statusPath.c_str())) { |
135 // {184, 734, 133.051727, 734, 97.0258636, 770.02587
9} | 457 return; |
136 "http___ilkoora_com.skp", // assert wind sum != min32 from markDoneBinary /
findNextOp #28k | 458 } |
137 /*!*/"http___migracioncolombia_gov_co.skp", // crashes on picture decode | 459 SkFILEStream reader; |
138 "http___mm4everfriends_com.skp", // bumpSpan/addTCoincident (from calcParti
alCoincidentWinding) | 460 reader.setPath(statusPath.c_str()); |
139 "http___mtrk_uz.skp", // checkEnds() assert #36.3k | 461 while (fetch(reader, &fResults.push_back())) |
140 "http___pchappy_com_au.skp", // bridgeOp() assert unsortable || ! empty #37
.2k | 462 ; |
141 "http___sciality_com.skp", // bridgeOp() SkASSERT(unsortable || !current->
done()); #32.4k | 463 fResults.pop_back(); |
142 /*!*/"http___sozialticker_com.skp", // asserts in png decode | 464 } |
143 "http___sudoestenegocios_com.skp", // assert fT < 1 in addTCoincident | 465 |
144 "http___thesuburbanite_com.skp", // bridgeOp() SkASSERT(unsortable || !cur
rent->done()); | 466 bool fetch(SkFILEStream& reader, TestResult* result) { |
145 | 467 char c; |
146 "http___fluentin3months_com.skp", // calcCommonCoincidentWinding from calcPa
rtialCoincidentWinding #38.3k | 468 int i = 0; |
147 "http___teachersbadi_blogspot_in.skp", // calcCommonCoincidentWinding from
calcPartialCoincidentWinding #53.4k | 469 result->init(fDirNo); |
148 "http___wsms_ru.skp", // assert wind sum != min32 from markDoneBinary / fin
dNextOp #49.5k | 470 result->fPixelError = 0; |
149 "http___voycer_de.skp", // calcCommonCoincidentWinding from calcPartialCoin
cidentWinding #47k | 471 result->fTime = 0; |
150 "http___77hz_jp.skp", // addTCancel from calcCoincidentWinding #47.1k | 472 do { |
151 | 473 bool readOne = reader.read(&c, 1) != 0; |
152 "http___hostloco_com.skp", // t < 0 AddIntersectsT | 474 if (!readOne) { |
153 /*!*/"http___oggicronaca_it.skp", // asserts in png decode | 475 SkASSERT(i == 0); |
154 "http___sergeychunkevich_com.skp", // t < 0 AddIntersectsT | 476 return false; |
155 "http___tracksflow_com.skp", // assert otherEnd >= 0 from nextChase | 477 } |
156 "http___autobutler_dk.skp", // t < 0 AddIntersectsT | 478 if (c == ' ') { |
157 "http___onlinecollege_org.skp", // bridgeOp() assert unsortable || ! empty
#100.1k | 479 result->fFilename[i++] = '\0'; |
158 "http___national_com_au.skp", // bridgeOp() assert unsortable || ! empty #1
10.2k | 480 break; |
159 /*!*/"http___anitadongre_com.skp", // exceptionally large width and height | 481 } |
160 "http___rentacheat_com.skp", // bridgeOp() assert unsortable || ! empty #11
0.8k | 482 result->fFilename[i++] = c; |
161 /*!*/"http___gruesse_de.skp", // asserts in png decode | 483 SkASSERT(i < kMaxLength); |
162 /*!*/"http___crn_in.png", // width=1250047 | 484 } while (true); |
163 "http___breakmystyle_com.skp", // assert qPt == lPt in quad intersection | 485 do { |
164 "http___naoxrane_ru.skp", // assert t4+...t0 == 0 in quartic roots #128.3k | 486 SkAssertResult(reader.read(&c, 1)); |
165 "http___tcmevents_org.skp", // assert in addTCoincident (from calcPartialCo
incidentWinding) #143.3k | 487 if (c == ' ') { |
166 /*!*/"http___listbuildingcashsecrets_com.skp", // asserts in png decode #152.7k | 488 break; |
167 /*!*/"http___skyscraperpage_com.skp", // asserts in png decode #155.5k | 489 } |
168 "http___mlk_com.skp", // bridgeOp() assert unsortable || ! empty #158.7k | 490 SkASSERT(c >= '0' && c <= '9'); |
169 "http___sd_graphic_net.skp", // bridgeOp() assert unsortable || ! empty #16
3.3k | 491 result->fPixelError = result->fPixelError * 10 + (c - '0'); |
170 "http___kopepasah_com.skp", // checkEnds() assert #188.2k | 492 } while (true); |
171 /*!*/"http___darkreloaded_com.skp", // asserts in png decode #188.4k | 493 bool minus = false; |
172 "http___redbullskatearcade_es.skp", // bridgeOp() assert unsortable || ! em
pty #192.5k | 494 do { |
173 "http___partainasdemo250_org.skp", // bridgeOp() assert unsortable || ! em
pty #200.2k | 495 SkAssertResult(reader.read(&c, 1)); |
174 | 496 if (c == '\n') { |
175 // these failures are from the new 10k set | 497 break; |
176 "http___www_freerepublic_com_.skp", // assert in opangle < | 498 } |
177 "http___www_lavoixdunord_fr_.skp", // bridgeOp() assert unsortable || ! emp
ty | 499 if (c == '-') { |
178 "http___www_booking_com_.skp", // bridgeOp() assert unsortable || ! empty | 500 minus = true; |
179 "http___www_fj_p_com_.skp", // markWinding assert from findChaseOp | 501 continue; |
180 "http___www_leadpages_net_.skp", // assert in opangle < | 502 } |
181 "http___www_despegar_com_mx_.skp", // bridgeOp() assert unsortable || ! emp
ty | 503 SkASSERT(c >= '0' && c <= '9'); |
182 }; | 504 result->fTime = result->fTime * 10 + (c - '0'); |
183 | 505 } while (true); |
184 size_t skipOverCount = sizeof(skipOver) / sizeof(skipOver[0]); | 506 if (minus) { |
185 | 507 result->fTime = -result->fTime; |
186 static void PathOpsSkpClipTest(skiatest::Reporter* reporter) { | 508 } |
187 SkOSFile::Iter iter(pictDir, "skp"); | 509 return true; |
| 510 } |
| 511 |
| 512 bool match(const SkString& filename, SkFILEWStream* stream, TestResult* resu
lt) { |
| 513 if (fIndex < fResults.count()) { |
| 514 *result = fResults[fIndex++]; |
| 515 SkASSERT(filename.equals(result->fFilename)); |
| 516 SkString outStr(result->status()); |
| 517 stream->write(outStr.c_str(), outStr.size()); |
| 518 return true; |
| 519 } |
| 520 return false; |
| 521 } |
| 522 |
| 523 private: |
| 524 int fDirNo; |
| 525 int fIndex; |
| 526 SkTArray<TestResult, true> fResults; |
| 527 }; |
| 528 |
| 529 static bool doOneDir(TestState* state) { |
| 530 int dirNo = state->fResult.fDirNo; |
| 531 skiatest::Reporter* reporter = state->fReporter; |
| 532 SkString dirName = make_in_dir_name(dirNo); |
| 533 SkASSERT(dirName.size()); |
| 534 SkOSFile::Iter iter(dirName.c_str(), "skp"); |
188 SkString filename; | 535 SkString filename; |
189 int testCount = 0; | 536 int testCount = 0; |
| 537 PreParser preParser(dirNo); |
| 538 SkFILEWStream statusStream(makeStatusString(dirNo).c_str()); |
190 while (iter.next(&filename)) { | 539 while (iter.next(&filename)) { |
191 SkString pngName = make_png_name(filename); | 540 for (size_t index = 0; index < skipOverSeptCount; ++index) { |
192 SkString oldPng = make_filepath(outOldClipDir, pngName); | 541 if (skipOverSept[index].directory == dirNo |
193 SkString newPng = make_filepath(outSkpClipDir, pngName); | 542 && strcmp(filename.c_str(), skipOverSept[index].filename) ==
0) { |
194 if (sk_exists(oldPng.c_str()) && sk_exists(newPng.c_str())) { | |
195 reporter->bumpTestCount(); | |
196 continue; | |
197 } | |
198 for (size_t index = 0; index < skipOverCount; ++index) { | |
199 if (skipOver[index] && strcmp(filename.c_str(), skipOver[index]) ==
0) { | |
200 reporter->bumpTestCount(); | |
201 goto skipOver; | 543 goto skipOver; |
202 } | 544 } |
203 } | 545 } |
204 testOne(filename); | 546 if (preParser.match(filename, &statusStream, &state->fResult)) { |
| 547 addError(state, state->fResult); |
| 548 ++testCount; |
| 549 goto checkEarlyExit; |
| 550 } |
| 551 if (state->fSmallestError > 5000000) { |
| 552 return false; |
| 553 } |
| 554 { |
| 555 TestResult& result = state->fResult; |
| 556 result.test(dirNo, filename); |
| 557 SkString outStr(result.status()); |
| 558 statusStream.write(outStr.c_str(), outStr.size()); |
| 559 statusStream.flush(); |
| 560 if (1) { |
| 561 SkDebugf("%s", outStr.c_str()); |
| 562 } |
| 563 bool noMatch = addError(state, state->fResult); |
| 564 if (noMatch) { |
| 565 state->clearSmallCount(); |
| 566 } else if (state->bumpSmallCount()) { |
| 567 return false; |
| 568 } |
| 569 } |
| 570 ++testCount; |
205 if (reporter->verbose()) { | 571 if (reporter->verbose()) { |
206 SkDebugf("."); | 572 SkDebugf("."); |
207 if (++testCount % 100 == 0) { | 573 if (++testCount % 100 == 0) { |
208 SkDebugf("%d\n", testCount); | 574 SkDebugf("%d\n", testCount); |
209 } | 575 } |
210 } | 576 } |
211 skipOver: | 577 skipOver: |
212 reporter->bumpTestCount(); | 578 if (reporter->verbose()) { |
| 579 static int threadTestCount; |
| 580 SkDebugf("."); |
| 581 sk_atomic_inc(&threadTestCount); |
| 582 if (threadTestCount % 100 == 0) { |
| 583 SkDebugf("%d\n", threadTestCount); |
| 584 } |
| 585 } |
| 586 checkEarlyExit: |
| 587 if (1 && testCount == 20) { |
| 588 return true; |
| 589 } |
| 590 } |
| 591 return true; |
| 592 } |
| 593 |
| 594 static bool initTest() { |
| 595 #if !defined SK_BUILD_FOR_WIN && !defined SK_BUILD_FOR_MAC |
| 596 SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true); |
| 597 SK_CONF_SET("images.png.suppressDecoderWarnings", true); |
| 598 #endif |
| 599 return make_out_dirs(); |
| 600 } |
| 601 |
| 602 static void encodeFound(skiatest::Reporter* reporter, TestState& state) { |
| 603 if (reporter->verbose()) { |
| 604 for (int index = 0; index < state.fFoundCount; ++index) { |
| 605 SkDebugf("%d %s %d\n", state.fDirsFound[index], state.fFilesFound[in
dex], |
| 606 state.fError[index]); |
| 607 } |
| 608 } |
| 609 for (int index = 0; index < state.fFoundCount; ++index) { |
| 610 TestResult::Test(state.fDirsFound[index], state.fFilesFound[index], kEnc
odeFiles); |
| 611 if (state.fReporter->verbose()) SkDebugf("+"); |
213 } | 612 } |
214 } | 613 } |
215 | 614 |
216 static void bumpCount(skiatest::Reporter* reporter, bool skipping) { | 615 static void PathOpsSkpClipTest(skiatest::Reporter* reporter) { |
217 if (reporter->verbose()) { | 616 if (!initTest()) { |
218 static int threadTestCount; | 617 return; |
219 if (!skipping) { | 618 } |
220 SkDebugf("."); | 619 SkTArray<TestResult, true> errors; |
| 620 TestState state; |
| 621 state.init(0, reporter); |
| 622 for (int dirNo = 1; dirNo <= 100; ++dirNo) { |
| 623 if (reporter->verbose()) { |
| 624 SkDebugf("dirNo=%d\n", dirNo); |
221 } | 625 } |
222 sk_atomic_inc(&threadTestCount); | 626 state.fResult.fDirNo = dirNo; |
223 if (!skipping && threadTestCount % 100 == 0) { | 627 if (!doOneDir(&state)) { |
224 SkDebugf("%d\n", threadTestCount); | 628 break; |
225 } | |
226 if (skipping && threadTestCount % 10000 == 0) { | |
227 SkDebugf("%d\n", threadTestCount); | |
228 } | 629 } |
229 } | 630 } |
| 631 encodeFound(reporter, state); |
230 } | 632 } |
231 | 633 |
232 static void testSkpClipMain(PathOpsThreadState* data) { | 634 static void testSkpClipMain(TestState* data) { |
233 SkString str(data->fSerialNo); | 635 (void) doOneDir(data); |
234 testOne(str); | |
235 bumpCount(data->fReporter, false); | |
236 data->fReporter->bumpTestCount(); | |
237 } | 636 } |
238 | 637 |
239 static void PathOpsSkpClipThreadedTest(skiatest::Reporter* reporter) { | 638 static void PathOpsSkpClipThreadedTest(skiatest::Reporter* reporter) { |
240 int threadCount = initializeTests(reporter, "skpClipThreadedTest"); | 639 if (!initTest()) { |
241 PathOpsThreadedTestRunner testRunner(reporter, threadCount); | 640 return; |
242 SkOSFile::Iter iter(pictDir, "skp"); | 641 } |
243 SkString filename; | 642 int threadCount = reporter->allowThreaded() ? SkThreadPool::kThreadPerCore :
1; |
244 while (iter.next(&filename)) { | 643 TestRunner testRunner(reporter, threadCount); |
245 SkString pngName = make_png_name(filename); | 644 for (int dirNo = 1; dirNo <= 100; ++dirNo) { |
246 SkString oldPng = make_filepath(outOldClipDir, pngName); | 645 *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnable, |
247 SkString newPng = make_filepath(outSkpClipDir, pngName); | 646 (&testSkpClipMain, dirNo, &testRunner)); |
248 if (sk_exists(oldPng.c_str()) && sk_exists(newPng.c_str())) { | |
249 bumpCount(reporter, true); | |
250 continue; | |
251 } | |
252 for (size_t index = 0; index < skipOverCount; ++index) { | |
253 if (skipOver[index] && strcmp(filename.c_str(), skipOver[index]) ==
0) { | |
254 bumpCount(reporter, true); | |
255 goto skipOver; | |
256 } | |
257 } | |
258 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable, | |
259 (&testSkpClipMain, filename.c_str(), &testRunner)); | |
260 skipOver: | |
261 ; | |
262 } | 647 } |
263 testRunner.render(); | 648 testRunner.render(); |
264 } | 649 TestState state; |
265 | 650 state.init(0, reporter); |
266 static void PathOpsSkpClipFixedTest(skiatest::Reporter* reporter) { | 651 for (int dirNo = 1; dirNo <= 100; ++dirNo) { |
267 for (size_t index = 0; index < tryFixedCount; ) { | 652 TestState& testState = testRunner.fRunnables[dirNo - 1]->fState; |
268 SkString filename(tryFixed[index]); | 653 for (int inner = 0; inner < testState.fFoundCount; ++inner) { |
269 testOne(filename); | 654 TestResult& testResult = testState.fResult; |
270 ++index; | 655 SkASSERT(testResult.fDirNo == dirNo); |
271 if (reporter->verbose()) { | 656 testResult.fPixelError = testState.fError[inner]; |
272 SkDebugf("."); | 657 strcpy(testResult.fFilename, testState.fFilesFound[inner]); |
273 if (index % 100 == 0) { | 658 addError(&state, testResult); |
274 SkDebugf("\n"); | |
275 } | |
276 } | 659 } |
277 reporter->bumpTestCount(); | |
278 } | 660 } |
| 661 encodeFound(reporter, state); |
279 } | 662 } |
280 | 663 |
281 static void PathOpsSkpClipOneOffTest(skiatest::Reporter* reporter) { | 664 static void PathOpsSkpClipOneOffTest(skiatest::Reporter* reporter) { |
282 SkString filename("http___78_cn_.skp"); | 665 if (!initTest()) { |
283 testOne(filename); | 666 return; |
| 667 } |
| 668 const int testIndex = 43 - 41; |
| 669 int dirNo = skipOverSept[testIndex].directory; |
| 670 SkAssertResult(make_in_dir_name(dirNo).size()); |
| 671 SkString filename(skipOverSept[testIndex].filename); |
| 672 TestResult state; |
| 673 state.test(dirNo, filename); |
| 674 if (reporter->verbose()) { |
| 675 SkDebugf("%s", state.status().c_str()); |
| 676 } |
| 677 state.fTestStep = kEncodeFiles; |
| 678 state.testOne(); |
284 } | 679 } |
285 | 680 |
286 #include "TestClassDef.h" | 681 #include "TestClassDef.h" |
287 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipTest) | 682 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipTest) |
288 | 683 |
289 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipFixedTest) | |
290 | |
291 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipOneOffTest) | 684 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipOneOffTest) |
292 | 685 |
293 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipThreadedTest) | 686 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipThreadedTest) |
OLD | NEW |