| OLD | NEW |
| 1 #include "CrashHandler.h" | 1 #include "CrashHandler.h" |
| 2 #include "DMJsonWriter.h" | 2 #include "DMJsonWriter.h" |
| 3 #include "DMSrcSink.h" | 3 #include "DMSrcSink.h" |
| 4 #include "OverwriteLine.h" | 4 #include "OverwriteLine.h" |
| 5 #include "ProcStats.h" | 5 #include "ProcStats.h" |
| 6 #include "SkBBHFactory.h" | 6 #include "SkBBHFactory.h" |
| 7 #include "SkChecksum.h" | 7 #include "SkChecksum.h" |
| 8 #include "SkCommonFlags.h" | 8 #include "SkCommonFlags.h" |
| 9 #include "SkForceLinking.h" | 9 #include "SkForceLinking.h" |
| 10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 static SkTArray<SkString> gFailures; | 42 static SkTArray<SkString> gFailures; |
| 43 | 43 |
| 44 static void fail(ImplicitString err) { | 44 static void fail(ImplicitString err) { |
| 45 SkAutoMutexAcquire lock(gFailuresMutex); | 45 SkAutoMutexAcquire lock(gFailuresMutex); |
| 46 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); | 46 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); |
| 47 gFailures.push_back(err); | 47 gFailures.push_back(err); |
| 48 } | 48 } |
| 49 | 49 |
| 50 static int32_t gPending = 0; // Atomic. | 50 static int32_t gPending = 0; // Atomic. |
| 51 | 51 |
| 52 static void done(double ms, ImplicitString config, ImplicitString src, ImplicitS
tring name) { | 52 static void done(double ms, |
| 53 ImplicitString config, ImplicitString src, ImplicitString name, |
| 54 ImplicitString log) { |
| 55 if (!log.isEmpty()) { |
| 56 log.prepend("\n"); |
| 57 } |
| 53 int32_t pending = sk_atomic_dec(&gPending)-1; | 58 int32_t pending = sk_atomic_dec(&gPending)-1; |
| 54 SkDebugf("%s(%4dMB %5d) %s\t%s %s %s ", FLAGS_verbose ? "\n" : kSkOverwrite
Line | 59 SkDebugf("%s(%4dMB %5d) %s\t%s %s %s%s", FLAGS_verbose ? "\n" : kSkOverwrite
Line |
| 55 , sk_tools::getMaxResidentSetSizeMB() | 60 , sk_tools::getMaxResidentSetSizeMB() |
| 56 , pending | 61 , pending |
| 57 , HumanizeMs(ms).c_str() | 62 , HumanizeMs(ms).c_str() |
| 58 , config.c_str() | 63 , config.c_str() |
| 59 , src.c_str() | 64 , src.c_str() |
| 60 , name.c_str()); | 65 , name.c_str() |
| 66 , log.c_str()); |
| 61 // We write our dm.json file every once in a while in case we crash. | 67 // We write our dm.json file every once in a while in case we crash. |
| 62 // Notice this also handles the final dm.json when pending == 0. | 68 // Notice this also handles the final dm.json when pending == 0. |
| 63 if (pending % 500 == 0) { | 69 if (pending % 500 == 0) { |
| 64 JsonWriter::DumpJson(); | 70 JsonWriter::DumpJson(); |
| 65 } | 71 } |
| 66 } | 72 } |
| 67 | 73 |
| 68 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 74 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 69 | 75 |
| 70 struct Gold : public SkString { | 76 struct Gold : public SkString { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 176 } |
| 171 // Try a noop Src as a canary. If it fails, skip this sink. | 177 // Try a noop Src as a canary. If it fails, skip this sink. |
| 172 struct : public Src { | 178 struct : public Src { |
| 173 Error draw(SkCanvas*) const SK_OVERRIDE { return ""; } | 179 Error draw(SkCanvas*) const SK_OVERRIDE { return ""; } |
| 174 SkISize size() const SK_OVERRIDE { return SkISize::Make(16, 16); } | 180 SkISize size() const SK_OVERRIDE { return SkISize::Make(16, 16); } |
| 175 Name name() const SK_OVERRIDE { return "noop"; } | 181 Name name() const SK_OVERRIDE { return "noop"; } |
| 176 } noop; | 182 } noop; |
| 177 | 183 |
| 178 SkBitmap bitmap; | 184 SkBitmap bitmap; |
| 179 SkDynamicMemoryWStream stream; | 185 SkDynamicMemoryWStream stream; |
| 180 Error err = sink->draw(noop, &bitmap, &stream); | 186 SkString log; |
| 187 Error err = sink->draw(noop, &bitmap, &stream, &log); |
| 181 if (!err.isEmpty()) { | 188 if (!err.isEmpty()) { |
| 182 SkDebugf("Skipping %s: %s\n", tag, err.c_str()); | 189 SkDebugf("Skipping %s: %s\n", tag, err.c_str()); |
| 183 return; | 190 return; |
| 184 } | 191 } |
| 185 | 192 |
| 186 Tagged<Sink>& ts = gSinks.push_back(); | 193 Tagged<Sink>& ts = gSinks.push_back(); |
| 187 ts.reset(sink.detach()); | 194 ts.reset(sink.detach()); |
| 188 ts.tag = tag; | 195 ts.tag = tag; |
| 189 } | 196 } |
| 190 | 197 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // The finest-grained unit of work we can run: draw a single Src into a single S
ink, | 297 // The finest-grained unit of work we can run: draw a single Src into a single S
ink, |
| 291 // report any errors, and perhaps write out the output: a .png of the bitmap, or
a raw stream. | 298 // report any errors, and perhaps write out the output: a .png of the bitmap, or
a raw stream. |
| 292 struct Task { | 299 struct Task { |
| 293 Task(const Tagged<Src>& src, const Tagged<Sink>& sink) : src(src), sink(sink
) {} | 300 Task(const Tagged<Src>& src, const Tagged<Sink>& sink) : src(src), sink(sink
) {} |
| 294 const Tagged<Src>& src; | 301 const Tagged<Src>& src; |
| 295 const Tagged<Sink>& sink; | 302 const Tagged<Sink>& sink; |
| 296 | 303 |
| 297 static void Run(Task* task) { | 304 static void Run(Task* task) { |
| 298 SkString name = task->src->name(); | 305 SkString name = task->src->name(); |
| 299 SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag,
name.c_str()); | 306 SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag,
name.c_str()); |
| 307 SkString log; |
| 300 WallTimer timer; | 308 WallTimer timer; |
| 301 timer.start(); | 309 timer.start(); |
| 302 if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) { | 310 if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) { |
| 303 SkBitmap bitmap; | 311 SkBitmap bitmap; |
| 304 SkDynamicMemoryWStream stream; | 312 SkDynamicMemoryWStream stream; |
| 305 Error err = task->sink->draw(*task->src, &bitmap, &stream); | 313 Error err = task->sink->draw(*task->src, &bitmap, &stream, &log); |
| 306 if (!err.isEmpty()) { | 314 if (!err.isEmpty()) { |
| 307 fail(SkStringPrintf("%s %s %s: %s", | 315 fail(SkStringPrintf("%s %s %s: %s", |
| 308 task->sink.tag, | 316 task->sink.tag, |
| 309 task->src.tag, | 317 task->src.tag, |
| 310 name.c_str(), | 318 name.c_str(), |
| 311 err.c_str())); | 319 err.c_str())); |
| 312 } | 320 } |
| 313 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); | 321 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); |
| 314 | 322 |
| 315 SkString md5; | 323 SkString md5; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 345 SkASSERT(bitmap.drawsNothing()); | 353 SkASSERT(bitmap.drawsNothing()); |
| 346 } else if (!bitmap.drawsNothing()) { | 354 } else if (!bitmap.drawsNothing()) { |
| 347 WriteToDisk(*task, md5, ext, NULL, 0, &bitmap); | 355 WriteToDisk(*task, md5, ext, NULL, 0, &bitmap); |
| 348 } | 356 } |
| 349 } | 357 } |
| 350 } | 358 } |
| 351 timer.end(); | 359 timer.end(); |
| 352 if (!whyBlacklisted.isEmpty()) { | 360 if (!whyBlacklisted.isEmpty()) { |
| 353 name.appendf(" (--blacklist, %s)", whyBlacklisted.c_str()); | 361 name.appendf(" (--blacklist, %s)", whyBlacklisted.c_str()); |
| 354 } | 362 } |
| 355 done(timer.fWall, task->sink.tag, task->src.tag, name); | 363 done(timer.fWall, task->sink.tag, task->src.tag, name, log); |
| 356 } | 364 } |
| 357 | 365 |
| 358 static void WriteToDisk(const Task& task, | 366 static void WriteToDisk(const Task& task, |
| 359 SkString md5, | 367 SkString md5, |
| 360 const char* ext, | 368 const char* ext, |
| 361 SkStream* data, size_t len, | 369 SkStream* data, size_t len, |
| 362 const SkBitmap* bitmap) { | 370 const SkBitmap* bitmap) { |
| 363 JsonWriter::BitmapResult result; | 371 JsonWriter::BitmapResult result; |
| 364 result.name = task.src->name(); | 372 result.name = task.src->name(); |
| 365 result.config = task.sink.tag; | 373 result.config = task.sink.tag; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 } | 474 } |
| 467 bool verbose() const SK_OVERRIDE { return FLAGS_veryVerbose; } | 475 bool verbose() const SK_OVERRIDE { return FLAGS_veryVerbose; } |
| 468 } reporter; | 476 } reporter; |
| 469 WallTimer timer; | 477 WallTimer timer; |
| 470 timer.start(); | 478 timer.start(); |
| 471 if (!FLAGS_dryRun) { | 479 if (!FLAGS_dryRun) { |
| 472 GrContextFactory factory; | 480 GrContextFactory factory; |
| 473 test->proc(&reporter, &factory); | 481 test->proc(&reporter, &factory); |
| 474 } | 482 } |
| 475 timer.end(); | 483 timer.end(); |
| 476 done(timer.fWall, "unit", "test", test->name); | 484 done(timer.fWall, "unit", "test", test->name, ""); |
| 477 } | 485 } |
| 478 | 486 |
| 479 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 487 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 480 | 488 |
| 481 // If we're isolating all GPU-bound work to one thread (the default), this funct
ion runs all that. | 489 // If we're isolating all GPU-bound work to one thread (the default), this funct
ion runs all that. |
| 482 static void run_enclave_and_gpu_tests(SkTArray<Task>* tasks) { | 490 static void run_enclave_and_gpu_tests(SkTArray<Task>* tasks) { |
| 483 run_enclave(tasks); | 491 run_enclave(tasks); |
| 484 for (int i = 0; i < gGPUTests.count(); i++) { | 492 for (int i = 0; i < gGPUTests.count(); i++) { |
| 485 run_test(&gGPUTests[i]); | 493 run_test(&gGPUTests[i]); |
| 486 } | 494 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 } | 557 } |
| 550 return 0; | 558 return 0; |
| 551 } | 559 } |
| 552 | 560 |
| 553 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 561 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 554 int main(int argc, char** argv) { | 562 int main(int argc, char** argv) { |
| 555 SkCommandLineFlags::Parse(argc, argv); | 563 SkCommandLineFlags::Parse(argc, argv); |
| 556 return dm_main(); | 564 return dm_main(); |
| 557 } | 565 } |
| 558 #endif | 566 #endif |
| OLD | NEW |