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 "SkCommonFlags.h" | 7 #include "SkCommonFlags.h" |
8 #include "SkForceLinking.h" | 8 #include "SkForceLinking.h" |
9 #include "SkGraphics.h" | 9 #include "SkGraphics.h" |
10 #include "SkMD5.h" | 10 #include "SkMD5.h" |
11 #include "SkOSFile.h" | 11 #include "SkOSFile.h" |
12 #include "SkTaskGroup.h" | 12 #include "SkTaskGroup.h" |
13 #include "Test.h" | 13 #include "Test.h" |
14 #include "Timer.h" | 14 #include "Timer.h" |
15 | 15 |
16 DEFINE_bool(tests, true, "Run tests?"); | 16 DEFINE_bool(tests, true, "Run tests?"); |
17 DEFINE_string(images, "resources", "Images to decode."); | 17 DEFINE_string(images, "resources", "Images to decode."); |
18 //DEFINE_string(src, "gm skp image subset", "Source types to test."); | 18 //DEFINE_string(src, "gm skp image subset", "Source types to test."); |
19 DEFINE_string(src, "gm skp", "Source types to test. TEMPORARILY DISABLED"); | 19 DEFINE_string(src, "gm skp", "Source types to test. TEMPORARILY DISABLED"); |
20 DEFINE_bool(nameByHash, false, | 20 DEFINE_bool(nameByHash, false, |
21 "If true, write to FLAGS_writePath[0]/<hash>.png instead of " | 21 "If true, write to FLAGS_writePath[0]/<hash>.png instead of " |
22 "to FLAGS_writePath[0]/<config>/<sourceType>/<name>.png"); | 22 "to FLAGS_writePath[0]/<config>/<sourceType>/<name>.png"); |
23 DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests."); | 23 DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests."); |
24 DEFINE_string(matrix, "1 0 0 0 1 0 0 0 1", | 24 DEFINE_string(matrix, "1 0 0 0 1 0 0 0 1", |
25 "Matrix to apply when using 'matrix' in config."); | 25 "Matrix to apply when using 'matrix' in config."); |
26 DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?"); | 26 DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?"); |
27 | 27 |
| 28 DEFINE_string(blacklist, "", |
| 29 "Space-separated config/src/name triples to blacklist. '_' matches anyt
hing. E.g. \n" |
| 30 "'--blacklist gpu skp _' will blacklist all SKPs drawn into the gpu conf
ig.\n" |
| 31 "'--blacklist gpu skp _ 8888 gm aarects' will also blacklist the aarects
GM on 8888."); |
| 32 |
| 33 |
28 __SK_FORCE_IMAGE_DECODER_LINKING; | 34 __SK_FORCE_IMAGE_DECODER_LINKING; |
29 using namespace DM; | 35 using namespace DM; |
30 | 36 |
31 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 37 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
32 | 38 |
33 SK_DECLARE_STATIC_MUTEX(gFailuresMutex); | 39 SK_DECLARE_STATIC_MUTEX(gFailuresMutex); |
34 static SkTArray<SkString> gFailures; | 40 static SkTArray<SkString> gFailures; |
35 | 41 |
36 static void fail(ImplicitString err) { | 42 static void fail(ImplicitString err) { |
37 SkAutoMutexAcquire lock(gFailuresMutex); | 43 SkAutoMutexAcquire lock(gFailuresMutex); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 break; | 214 break; |
209 } | 215 } |
210 sink = next; | 216 sink = next; |
211 } | 217 } |
212 if (sink) { | 218 if (sink) { |
213 push_sink(config, sink); | 219 push_sink(config, sink); |
214 } | 220 } |
215 } | 221 } |
216 } | 222 } |
217 | 223 |
| 224 static bool match(const char* needle, const char* haystack) { |
| 225 return 0 == strcmp("_", needle) || NULL != strstr(haystack, needle); |
| 226 } |
| 227 |
| 228 static ImplicitString is_blacklisted(const char* sink, const char* src, const ch
ar* name) { |
| 229 for (int i = 0; i < FLAGS_blacklist.count() - 2; i += 3) { |
| 230 if (match(FLAGS_blacklist[i+0], sink) && |
| 231 match(FLAGS_blacklist[i+1], src) && |
| 232 match(FLAGS_blacklist[i+2], name)) { |
| 233 return SkStringPrintf("%s %s %s", |
| 234 FLAGS_blacklist[i+0], FLAGS_blacklist[i+1], FL
AGS_blacklist[i+2]); |
| 235 } |
| 236 } |
| 237 return ""; |
| 238 } |
| 239 |
218 // The finest-grained unit of work we can run: draw a single Src into a single S
ink, | 240 // The finest-grained unit of work we can run: draw a single Src into a single S
ink, |
219 // report any errors, and perhaps write out the output: a .png of the bitmap, or
a raw stream. | 241 // report any errors, and perhaps write out the output: a .png of the bitmap, or
a raw stream. |
220 struct Task { | 242 struct Task { |
221 Task(const Tagged<Src>& src, const Tagged<Sink>& sink) : src(src), sink(sink
) {} | 243 Task(const Tagged<Src>& src, const Tagged<Sink>& sink) : src(src), sink(sink
) {} |
222 const Tagged<Src>& src; | 244 const Tagged<Src>& src; |
223 const Tagged<Sink>& sink; | 245 const Tagged<Sink>& sink; |
224 | 246 |
225 static void Run(Task* task) { | 247 static void Run(Task* task) { |
| 248 SkString name = task->src->name(); |
| 249 SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag,
name.c_str()); |
226 WallTimer timer; | 250 WallTimer timer; |
227 timer.start(); | 251 timer.start(); |
228 if (!FLAGS_dryRun) { | 252 if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) { |
229 SkBitmap bitmap; | 253 SkBitmap bitmap; |
230 SkDynamicMemoryWStream stream; | 254 SkDynamicMemoryWStream stream; |
231 Error err = task->sink->draw(*task->src, &bitmap, &stream); | 255 Error err = task->sink->draw(*task->src, &bitmap, &stream); |
232 if (!err.isEmpty()) { | 256 if (!err.isEmpty()) { |
233 fail(SkStringPrintf("%s %s %s: %s", | 257 fail(SkStringPrintf("%s %s %s: %s", |
234 task->sink.tag, | 258 task->sink.tag, |
235 task->src.tag, | 259 task->src.tag, |
236 task->src->name().c_str(), | 260 name.c_str(), |
237 err.c_str())); | 261 err.c_str())); |
238 } | 262 } |
239 if (!FLAGS_writePath.isEmpty()) { | 263 if (!FLAGS_writePath.isEmpty()) { |
240 const char* ext = task->sink->fileExtension(); | 264 const char* ext = task->sink->fileExtension(); |
241 if (stream.bytesWritten() == 0) { | 265 if (stream.bytesWritten() == 0) { |
242 SkMemoryStream pixels(bitmap.getPixels(), bitmap.getSize()); | 266 SkMemoryStream pixels(bitmap.getPixels(), bitmap.getSize()); |
243 WriteToDisk(*task, &pixels, bitmap.getSize(), &bitmap, ext); | 267 WriteToDisk(*task, &pixels, bitmap.getSize(), &bitmap, ext); |
244 } else { | 268 } else { |
245 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); | 269 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); |
246 WriteToDisk(*task, data, data->getLength(), NULL, ext); | 270 WriteToDisk(*task, data, data->getLength(), NULL, ext); |
247 } | 271 } |
248 } | 272 } |
249 } | 273 } |
250 timer.end(); | 274 timer.end(); |
251 done(timer.fWall, task->sink.tag, task->src.tag, task->src->name()); | 275 if (!whyBlacklisted.isEmpty()) { |
| 276 name.appendf(" (--blacklist, %s)", whyBlacklisted.c_str()); |
| 277 } |
| 278 done(timer.fWall, task->sink.tag, task->src.tag, name); |
252 } | 279 } |
253 | 280 |
254 static void WriteToDisk(const Task& task, | 281 static void WriteToDisk(const Task& task, |
255 SkStream* data, size_t len, | 282 SkStream* data, size_t len, |
256 const SkBitmap* bitmap, | 283 const SkBitmap* bitmap, |
257 const char* ext) { | 284 const char* ext) { |
258 SkMD5 hash; | 285 SkMD5 hash; |
259 hash.writeStream(data, len); | 286 hash.writeStream(data, len); |
260 SkMD5::Digest digest; | 287 SkMD5::Digest digest; |
261 hash.finish(digest); | 288 hash.finish(digest); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 if (FLAGS_gpu_threading) { | 445 if (FLAGS_gpu_threading) { |
419 tg.batch(run_test, gGPUTests.begin(), gGPUTests.count()); | 446 tg.batch(run_test, gGPUTests.begin(), gGPUTests.count()); |
420 } else { | 447 } else { |
421 for (int i = 0; i < gGPUTests.count(); i++) { | 448 for (int i = 0; i < gGPUTests.count(); i++) { |
422 run_test(&gGPUTests[i]); | 449 run_test(&gGPUTests[i]); |
423 } | 450 } |
424 } | 451 } |
425 tg.wait(); | 452 tg.wait(); |
426 | 453 |
427 // At this point we're back in single-threaded land. | 454 // At this point we're back in single-threaded land. |
428 | 455 SkDebugf("\n"); |
429 if (!FLAGS_verbose) { | |
430 SkDebugf("\n"); | |
431 } | |
432 | 456 |
433 JsonWriter::DumpJson(); | 457 JsonWriter::DumpJson(); |
434 | 458 |
435 if (gFailures.count() > 0) { | 459 if (gFailures.count() > 0) { |
436 SkDebugf("Failures:\n"); | 460 SkDebugf("Failures:\n"); |
437 for (int i = 0; i < gFailures.count(); i++) { | 461 for (int i = 0; i < gFailures.count(); i++) { |
438 SkDebugf("\t%s", gFailures[i].c_str()); | 462 SkDebugf("\t%s", gFailures[i].c_str()); |
439 } | 463 } |
440 SkDebugf("%d failures\n", gFailures.count()); | 464 SkDebugf("%d failures\n", gFailures.count()); |
441 return 1; | 465 return 1; |
442 } | 466 } |
443 if (gPending > 0) { | 467 if (gPending > 0) { |
444 SkDebugf("Hrm, we didn't seem to run everything we intended to! Please
file a bug.\n"); | 468 SkDebugf("Hrm, we didn't seem to run everything we intended to! Please
file a bug.\n"); |
445 return 1; | 469 return 1; |
446 } | 470 } |
447 return 0; | 471 return 0; |
448 } | 472 } |
449 | 473 |
450 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 474 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
451 int main(int argc, char** argv) { | 475 int main(int argc, char** argv) { |
452 SkCommandLineFlags::Parse(argc, argv); | 476 SkCommandLineFlags::Parse(argc, argv); |
453 return dm_main(); | 477 return dm_main(); |
454 } | 478 } |
455 #endif | 479 #endif |
OLD | NEW |