| 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" |
| 11 #include "SkInstCnt.h" | 11 #include "SkInstCnt.h" |
| 12 #include "SkMD5.h" | 12 #include "SkMD5.h" |
| 13 #include "SkOSFile.h" | 13 #include "SkOSFile.h" |
| 14 #include "SkTDynamicHash.h" | 14 #include "SkTHash.h" |
| 15 #include "SkTaskGroup.h" | 15 #include "SkTaskGroup.h" |
| 16 #include "Test.h" | 16 #include "Test.h" |
| 17 #include "Timer.h" | 17 #include "Timer.h" |
| 18 | 18 |
| 19 DEFINE_string(src, "tests gm skp image subset", "Source types to test."); | 19 DEFINE_string(src, "tests gm skp image subset", "Source types to test."); |
| 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 1", | 24 DEFINE_string(matrix, "1 0 0 1", |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // 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. |
| 68 // Notice this also handles the final dm.json when pending == 0. | 68 // Notice this also handles the final dm.json when pending == 0. |
| 69 if (pending % 500 == 0) { | 69 if (pending % 500 == 0) { |
| 70 JsonWriter::DumpJson(); | 70 JsonWriter::DumpJson(); |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 74 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 75 | 75 |
| 76 struct Gold : public SkString { | 76 struct Gold : public SkString { |
| 77 Gold() : SkString("") {} |
| 77 Gold(ImplicitString sink, ImplicitString src, ImplicitString name, ImplicitS
tring md5) | 78 Gold(ImplicitString sink, ImplicitString src, ImplicitString name, ImplicitS
tring md5) |
| 78 : SkString("") { | 79 : SkString("") { |
| 79 this->append(sink); | 80 this->append(sink); |
| 80 this->append(src); | 81 this->append(src); |
| 81 this->append(name); | 82 this->append(name); |
| 82 this->append(md5); | 83 this->append(md5); |
| 83 while (this->size() % 4) { | 84 while (this->size() % 4) { |
| 84 this->append("!"); // Pad out if needed so we can pass this to Murm
ur3. | 85 this->append("!"); // Pad out if needed so we can pass this to Murm
ur3. |
| 85 } | 86 } |
| 86 } | 87 } |
| 87 static const Gold& GetKey(const Gold& g) { return g; } | |
| 88 static uint32_t Hash(const Gold& g) { | 88 static uint32_t Hash(const Gold& g) { |
| 89 return SkChecksum::Murmur3((const uint32_t*)g.c_str(), g.size()); | 89 return SkChecksum::Murmur3((const uint32_t*)g.c_str(), g.size()); |
| 90 } | 90 } |
| 91 }; | 91 }; |
| 92 static SkTDynamicHash<Gold, Gold> gGold; | 92 static SkTHashSet<Gold, Gold::Hash> gGold; |
| 93 | 93 |
| 94 static void add_gold(JsonWriter::BitmapResult r) { | 94 static void add_gold(JsonWriter::BitmapResult r) { |
| 95 gGold.add(new Gold(r.config, r.sourceType, r.name, r.md5)); // We'll let th
ese leak. Lazybones. | 95 gGold.add(Gold(r.config, r.sourceType, r.name, r.md5)); |
| 96 } | 96 } |
| 97 | 97 |
| 98 static void gather_gold() { | 98 static void gather_gold() { |
| 99 if (!FLAGS_readPath.isEmpty()) { | 99 if (!FLAGS_readPath.isEmpty()) { |
| 100 SkString path(FLAGS_readPath[0]); | 100 SkString path(FLAGS_readPath[0]); |
| 101 path.append("/dm.json"); | 101 path.append("/dm.json"); |
| 102 if (!JsonWriter::ReadJson(path.c_str(), add_gold)) { | 102 if (!JsonWriter::ReadJson(path.c_str(), add_gold)) { |
| 103 fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_s
tr())); | 103 fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_s
tr())); |
| 104 } | 104 } |
| 105 } | 105 } |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 hash.write(bitmap.getPixels(), bitmap.getSize()); | 333 hash.write(bitmap.getPixels(), bitmap.getSize()); |
| 334 } | 334 } |
| 335 SkMD5::Digest digest; | 335 SkMD5::Digest digest; |
| 336 hash.finish(digest); | 336 hash.finish(digest); |
| 337 for (int i = 0; i < 16; i++) { | 337 for (int i = 0; i < 16; i++) { |
| 338 md5.appendf("%02x", digest.data[i]); | 338 md5.appendf("%02x", digest.data[i]); |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 | 341 |
| 342 if (!FLAGS_readPath.isEmpty() && | 342 if (!FLAGS_readPath.isEmpty() && |
| 343 !gGold.find(Gold(task->sink.tag, task->src.tag, name, md5))) { | 343 !gGold.contains(Gold(task->sink.tag, task->src.tag, name, md5)))
{ |
| 344 fail(SkStringPrintf("%s not found for %s %s %s in %s", | 344 fail(SkStringPrintf("%s not found for %s %s %s in %s", |
| 345 md5.c_str(), | 345 md5.c_str(), |
| 346 task->sink.tag, | 346 task->sink.tag, |
| 347 task->src.tag, | 347 task->src.tag, |
| 348 name.c_str(), | 348 name.c_str(), |
| 349 FLAGS_readPath[0])); | 349 FLAGS_readPath[0])); |
| 350 } | 350 } |
| 351 | 351 |
| 352 if (!FLAGS_writePath.isEmpty()) { | 352 if (!FLAGS_writePath.isEmpty()) { |
| 353 const char* ext = task->sink->fileExtension(); | 353 const char* ext = task->sink->fileExtension(); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 } | 560 } |
| 561 return 0; | 561 return 0; |
| 562 } | 562 } |
| 563 | 563 |
| 564 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 564 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 565 int main(int argc, char** argv) { | 565 int main(int argc, char** argv) { |
| 566 SkCommandLineFlags::Parse(argc, argv); | 566 SkCommandLineFlags::Parse(argc, argv); |
| 567 return dm_main(); | 567 return dm_main(); |
| 568 } | 568 } |
| 569 #endif | 569 #endif |
| OLD | NEW |