OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "CrashHandler.h" | 8 #include "CrashHandler.h" |
9 #include "DMJsonWriter.h" | 9 #include "DMJsonWriter.h" |
10 #include "DMSrcSink.h" | 10 #include "DMSrcSink.h" |
11 #include "DMSrcSinkAndroid.h" | 11 #include "DMSrcSinkAndroid.h" |
12 #include "OverwriteLine.h" | 12 #include "OverwriteLine.h" |
13 #include "ProcStats.h" | 13 #include "ProcStats.h" |
14 #include "SkBBHFactory.h" | 14 #include "SkBBHFactory.h" |
15 #include "SkChecksum.h" | 15 #include "SkChecksum.h" |
16 #include "SkCommonFlags.h" | 16 #include "SkCommonFlags.h" |
17 #include "SkForceLinking.h" | 17 #include "SkForceLinking.h" |
18 #include "SkGraphics.h" | 18 #include "SkGraphics.h" |
19 #include "SkInstCnt.h" | 19 #include "SkInstCnt.h" |
20 #include "SkJSONCPP.h" | |
20 #include "SkMD5.h" | 21 #include "SkMD5.h" |
21 #include "SkOSFile.h" | 22 #include "SkOSFile.h" |
23 #include "SkTDict.h" | |
22 #include "SkTHash.h" | 24 #include "SkTHash.h" |
23 #include "SkTaskGroup.h" | 25 #include "SkTaskGroup.h" |
24 #include "SkThreadUtils.h" | 26 #include "SkThreadUtils.h" |
25 #include "Test.h" | 27 #include "Test.h" |
26 #include "Timer.h" | 28 #include "Timer.h" |
27 | 29 |
28 DEFINE_string(src, "tests gm skp image", "Source types to test."); | 30 DEFINE_string(src, "tests gm skp image", "Source types to test."); |
29 DEFINE_bool(nameByHash, false, | 31 DEFINE_bool(nameByHash, false, |
30 "If true, write to FLAGS_writePath[0]/<hash>.png instead of " | 32 "If true, write to FLAGS_writePath[0]/<hash>.png instead of " |
31 "to FLAGS_writePath[0]/<config>/<sourceType>/<sourceOptions>/<name>. png"); | 33 "to FLAGS_writePath[0]/<config>/<sourceType>/<sourceOptions>/<name>. png"); |
32 DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests."); | 34 DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests."); |
33 DEFINE_string(matrix, "1 0 0 1", | 35 DEFINE_string(matrix, "1 0 0 1", |
34 "2x2 scale+skew matrix to apply or upright when using " | 36 "2x2 scale+skew matrix to apply or upright when using " |
35 "'matrix' or 'upright' in config."); | 37 "'matrix' or 'upright' in config."); |
36 DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?"); | 38 DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?"); |
37 | 39 |
38 DEFINE_string(blacklist, "", | 40 DEFINE_string(blacklist, "", |
39 "Space-separated config/src/srcOptions/name quadruples to blacklist. '_ ' matches anything. E.g. \n" | 41 "Space-separated config/src/srcOptions/name quadruples to blacklist. '_ ' matches anything. E.g. \n" |
40 "'--blacklist gpu skp _ _' will blacklist all SKPs drawn into the gpu co nfig.\n" | 42 "'--blacklist gpu skp _ _' will blacklist all SKPs drawn into the gpu co nfig.\n" |
41 "'--blacklist gpu skp _ _ 8888 gm _ aarects' will also blacklist the aar ects GM on 8888."); | 43 "'--blacklist gpu skp _ _ 8888 gm _ aarects' will also blacklist the aar ects GM on 8888."); |
42 | 44 |
43 DEFINE_string2(readPath, r, "", "If set check for equality with golden results i n this directory."); | 45 DEFINE_string2(readPath, r, "", "If set check for equality with golden results i n this directory."); |
44 | 46 |
47 DEFINE_string(uninterestingHashesFile, "", | |
48 "JSON file containing a list of uninteresting hashes. If a result hashes to something in " | |
49 "this list, no image is written for that result."); | |
50 | |
45 __SK_FORCE_IMAGE_DECODER_LINKING; | 51 __SK_FORCE_IMAGE_DECODER_LINKING; |
46 using namespace DM; | 52 using namespace DM; |
47 | 53 |
48 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ | 54 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ |
49 | 55 |
50 SK_DECLARE_STATIC_MUTEX(gFailuresMutex); | 56 SK_DECLARE_STATIC_MUTEX(gFailuresMutex); |
51 static SkTArray<SkString> gFailures; | 57 static SkTArray<SkString> gFailures; |
52 | 58 |
53 static void fail(ImplicitString err) { | 59 static void fail(ImplicitString err) { |
54 SkAutoMutexAcquire lock(gFailuresMutex); | 60 SkAutoMutexAcquire lock(gFailuresMutex); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 SkString path(FLAGS_readPath[0]); | 136 SkString path(FLAGS_readPath[0]); |
131 path.append("/dm.json"); | 137 path.append("/dm.json"); |
132 if (!JsonWriter::ReadJson(path.c_str(), add_gold)) { | 138 if (!JsonWriter::ReadJson(path.c_str(), add_gold)) { |
133 fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_s tr())); | 139 fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_s tr())); |
134 } | 140 } |
135 } | 141 } |
136 } | 142 } |
137 | 143 |
138 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ | 144 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ |
139 | 145 |
146 static SkTDict<bool> gUninterestingHashes(0); | |
mtklein
2015/04/03 19:58:04
Let's try:
static SkTHashSet<SkString> gUnintere
borenet
2015/04/03 20:26:50
Done.
| |
147 | |
148 static void gather_uninteresting_hashes() { | |
149 if (!FLAGS_uninterestingHashesFile.isEmpty()) { | |
150 SkString path(FLAGS_uninterestingHashesFile[0]); | |
151 SkAutoTUnref<SkData> json(SkData::NewFromFileName(path.c_str())); | |
152 if (!json) { | |
153 fail(SkStringPrintf("Couldn't read %s to get the list of uninteresti ng hashes.", | |
154 path.c_str())); | |
155 } | |
156 | |
157 Json::Reader reader; | |
158 Json::Value root; | |
159 const char* data = (const char*)json->data(); | |
160 if (!reader.parse(data, data+json->size(), root)) { | |
161 fail(SkStringPrintf("Couldn't parse JSON from %s.", path.c_str())); | |
162 } | |
163 | |
164 for (unsigned i = 0; i < root.size(); i++) { | |
165 gUninterestingHashes.set(root[i].asCString(), true); | |
166 } | |
167 } | |
168 } | |
169 | |
170 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ | |
171 | |
140 template <typename T> | 172 template <typename T> |
141 struct Tagged : public SkAutoTDelete<T> { | 173 struct Tagged : public SkAutoTDelete<T> { |
142 const char* tag; | 174 const char* tag; |
143 const char* options; | 175 const char* options; |
144 }; | 176 }; |
145 | 177 |
146 static const bool kMemcpyOK = true; | 178 static const bool kMemcpyOK = true; |
147 | 179 |
148 static SkTArray<Tagged<Src>, kMemcpyOK> gSrcs; | 180 static SkTArray<Tagged<Src>, kMemcpyOK> gSrcs; |
149 static SkTArray<Tagged<Sink>, kMemcpyOK> gSinks; | 181 static SkTArray<Tagged<Sink>, kMemcpyOK> gSinks; |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 task->src.options, name, md5))) { | 460 task->src.options, name, md5))) { |
429 fail(SkStringPrintf("%s not found for %s %s %s %s in %s", | 461 fail(SkStringPrintf("%s not found for %s %s %s %s in %s", |
430 md5.c_str(), | 462 md5.c_str(), |
431 task->sink.tag, | 463 task->sink.tag, |
432 task->src.tag, | 464 task->src.tag, |
433 task->src.options, | 465 task->src.options, |
434 name.c_str(), | 466 name.c_str(), |
435 FLAGS_readPath[0])); | 467 FLAGS_readPath[0])); |
436 } | 468 } |
437 | 469 |
438 if (!FLAGS_writePath.isEmpty()) { | 470 if (!FLAGS_writePath.isEmpty() && !gUninterestingHashes.find(md5.c_s tr(), md5.size())) { |
439 const char* ext = task->sink->fileExtension(); | 471 const char* ext = task->sink->fileExtension(); |
440 if (data->getLength()) { | 472 if (data->getLength()) { |
441 WriteToDisk(*task, md5, ext, data, data->getLength(), NULL); | 473 WriteToDisk(*task, md5, ext, data, data->getLength(), NULL); |
442 SkASSERT(bitmap.drawsNothing()); | 474 SkASSERT(bitmap.drawsNothing()); |
443 } else if (!bitmap.drawsNothing()) { | 475 } else if (!bitmap.drawsNothing()) { |
444 WriteToDisk(*task, md5, ext, NULL, 0, &bitmap); | 476 WriteToDisk(*task, md5, ext, NULL, 0, &bitmap); |
445 } | 477 } |
446 } | 478 } |
447 } | 479 } |
448 timer.end(); | 480 timer.end(); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
618 SetupCrashHandler(); | 650 SetupCrashHandler(); |
619 SkAutoGraphics ag; | 651 SkAutoGraphics ag; |
620 SkTaskGroup::Enabler enabled(FLAGS_threads); | 652 SkTaskGroup::Enabler enabled(FLAGS_threads); |
621 if (FLAGS_leaks) { | 653 if (FLAGS_leaks) { |
622 SkInstCountPrintLeaksOnExit(); | 654 SkInstCountPrintLeaksOnExit(); |
623 } | 655 } |
624 | 656 |
625 start_keepalive(); | 657 start_keepalive(); |
626 | 658 |
627 gather_gold(); | 659 gather_gold(); |
660 gather_uninteresting_hashes(); | |
628 | 661 |
629 gather_srcs(); | 662 gather_srcs(); |
630 gather_sinks(); | 663 gather_sinks(); |
631 gather_tests(); | 664 gather_tests(); |
632 | 665 |
633 gPending = gSrcs.count() * gSinks.count() + gThreadedTests.count() + gGPUTes ts.count(); | 666 gPending = gSrcs.count() * gSinks.count() + gThreadedTests.count() + gGPUTes ts.count(); |
634 SkDebugf("%d srcs * %d sinks + %d tests == %d tasks\n", | 667 SkDebugf("%d srcs * %d sinks + %d tests == %d tasks\n", |
635 gSrcs.count(), gSinks.count(), gThreadedTests.count() + gGPUTests.c ount(), gPending); | 668 gSrcs.count(), gSinks.count(), gThreadedTests.count() + gGPUTests.c ount(), gPending); |
636 | 669 |
637 // We try to exploit as much parallelism as is safe. Most Src/Sink pairs ru n on any thread, | 670 // We try to exploit as much parallelism as is safe. Most Src/Sink pairs ru n on any thread, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
678 } | 711 } |
679 return 0; | 712 return 0; |
680 } | 713 } |
681 | 714 |
682 #if !defined(SK_BUILD_FOR_IOS) | 715 #if !defined(SK_BUILD_FOR_IOS) |
683 int main(int argc, char** argv) { | 716 int main(int argc, char** argv) { |
684 SkCommandLineFlags::Parse(argc, argv); | 717 SkCommandLineFlags::Parse(argc, argv); |
685 return dm_main(); | 718 return dm_main(); |
686 } | 719 } |
687 #endif | 720 #endif |
OLD | NEW |