OLD | NEW |
1 // Main binary for DM. | 1 // Main binary for DM. |
2 // For a high-level overview, please see dm/README. | 2 // For a high-level overview, please see dm/README. |
3 | 3 |
4 #include "SkBenchmark.h" | 4 #include "SkBenchmark.h" |
5 #include "SkCommandLineFlags.h" | 5 #include "SkCommandLineFlags.h" |
6 #include "SkForceLinking.h" | 6 #include "SkForceLinking.h" |
7 #include "SkGraphics.h" | 7 #include "SkGraphics.h" |
| 8 #include "SkPicture.h" |
8 #include "SkString.h" | 9 #include "SkString.h" |
9 #include "Test.h" | 10 #include "Test.h" |
10 #include "gm.h" | 11 #include "gm.h" |
11 | 12 |
12 #include "DMBenchTask.h" | 13 #include "DMBenchTask.h" |
13 #include "DMCpuGMTask.h" | 14 #include "DMCpuGMTask.h" |
14 #include "DMGpuGMTask.h" | 15 #include "DMGpuGMTask.h" |
15 #include "DMGpuSupport.h" | 16 #include "DMGpuSupport.h" |
16 #include "DMReporter.h" | 17 #include "DMReporter.h" |
| 18 #include "DMSKPTask.h" |
17 #include "DMTask.h" | 19 #include "DMTask.h" |
18 #include "DMTaskRunner.h" | 20 #include "DMTaskRunner.h" |
19 #include "DMTestTask.h" | 21 #include "DMTestTask.h" |
20 #include "DMWriteTask.h" | 22 #include "DMWriteTask.h" |
21 | 23 |
22 #include <string.h> | 24 #include <string.h> |
23 | 25 |
24 using skiagm::GM; | 26 using skiagm::GM; |
25 using skiagm::GMRegistry; | 27 using skiagm::GMRegistry; |
26 using skiatest::Test; | 28 using skiatest::Test; |
27 using skiatest::TestRegistry; | 29 using skiatest::TestRegistry; |
28 | 30 |
29 DEFINE_int32(threads, -1, "Threads for CPU work. Default NUM_CPUS."); | 31 DEFINE_int32(threads, -1, "Threads for CPU work. Default NUM_CPUS."); |
30 DEFINE_int32(gpuThreads, 1, "Threads for GPU work."); | 32 DEFINE_int32(gpuThreads, 1, "Threads for GPU work."); |
31 DEFINE_string2(expectations, r, "", | 33 DEFINE_string2(expectations, r, "", |
32 "If a directory, compare generated images against images under th
is path. " | 34 "If a directory, compare generated images against images under th
is path. " |
33 "If a file, compare generated images against JSON expectations at
this path."); | 35 "If a file, compare generated images against JSON expectations at
this path."); |
34 DEFINE_string2(resources, i, "resources", "Path to resources directory."); | 36 DEFINE_string2(resources, i, "resources", "Path to resources directory."); |
35 DEFINE_string(match, "", "[~][^]substring[$] [...] of GM name to run.\n" | 37 DEFINE_string(match, "", "[~][^]substring[$] [...] of GM name to run.\n" |
36 "Multiple matches may be separated by spaces.\n" | 38 "Multiple matches may be separated by spaces.\n" |
37 "~ causes a matching GM to always be skipped\n" | 39 "~ causes a matching GM to always be skipped\n" |
38 "^ requires the start of the GM to match\n" | 40 "^ requires the start of the GM to match\n" |
39 "$ requires the end of the GM to match\n" | 41 "$ requires the end of the GM to match\n" |
40 "^ and $ requires an exact match\n" | 42 "^ and $ requires an exact match\n" |
41 "If a GM does not match any list entry,\n" | 43 "If a GM does not match any list entry,\n" |
42 "it is skipped unless some list entry starts with ~"); | 44 "it is skipped unless some list entry starts with ~"); |
43 DEFINE_string(config, "565 8888 gpu nonrendering", | 45 DEFINE_string(config, "565 8888 gpu nonrendering", |
44 "Options: 565 8888 gpu nonrendering msaa4 msaa16 nvprmsaa4 nvprmsa
a16 gpunull gpudebug angle mesa"); | 46 "Options: 565 8888 gpu nonrendering msaa4 msaa16 nvprmsaa4 nvprmsa
a16 gpunull gpudebug angle mesa"); |
45 DEFINE_bool(leaks, false, "Print leaked instance-counted objects at exit?"); | 47 DEFINE_bool(leaks, false, "Print leaked instance-counted objects at exit?"); |
| 48 DEFINE_string(skps, "", "Directory to read skps from."); |
46 | 49 |
47 DEFINE_bool(gms, true, "Run GMs?"); | 50 DEFINE_bool(gms, true, "Run GMs?"); |
48 DEFINE_bool(benches, true, "Run benches? Does not run GMs-as-benches."); | 51 DEFINE_bool(benches, true, "Run benches? Does not run GMs-as-benches."); |
49 DEFINE_bool(tests, true, "Run tests?"); | 52 DEFINE_bool(tests, true, "Run tests?"); |
50 | 53 |
51 __SK_FORCE_IMAGE_DECODER_LINKING; | 54 __SK_FORCE_IMAGE_DECODER_LINKING; |
52 | 55 |
53 // "FooBar" -> "foobar". Obviously, ASCII only. | 56 // "FooBar" -> "foobar". Obviously, ASCII only. |
54 static SkString lowercase(SkString s) { | 57 static SkString lowercase(SkString s) { |
55 for (size_t i = 0; i < s.size(); i++) { | 58 for (size_t i = 0; i < s.size(); i++) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 for (int i = 0; i < tests.count(); i++) { | 139 for (int i = 0; i < tests.count(); i++) { |
137 SkAutoTDelete<Test> test(tests[i](NULL)); | 140 SkAutoTDelete<Test> test(tests[i](NULL)); |
138 if (test->isGPUTest()) { | 141 if (test->isGPUTest()) { |
139 tasks->add(SkNEW_ARGS(DM::GpuTestTask, (reporter, tasks, tests[i])))
; | 142 tasks->add(SkNEW_ARGS(DM::GpuTestTask, (reporter, tasks, tests[i])))
; |
140 } else { | 143 } else { |
141 tasks->add(SkNEW_ARGS(DM::CpuTestTask, (reporter, tasks, tests[i])))
; | 144 tasks->add(SkNEW_ARGS(DM::CpuTestTask, (reporter, tasks, tests[i])))
; |
142 } | 145 } |
143 } | 146 } |
144 } | 147 } |
145 | 148 |
| 149 static void kick_off_skps(DM::Reporter* reporter, DM::TaskRunner* tasks) { |
| 150 if (FLAGS_skps.isEmpty()) { |
| 151 return; |
| 152 } |
| 153 |
| 154 SkOSFile::Iter it(FLAGS_skps[0], ".skp"); |
| 155 SkString filename; |
| 156 while (it.next(&filename)) { |
| 157 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, filename.c_str())) { |
| 158 continue; |
| 159 } |
| 160 |
| 161 const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str
()); |
| 162 |
| 163 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path.c_str())); |
| 164 if (stream.get() == NULL) { |
| 165 SkDebugf("Could not read %s.\n", path.c_str()); |
| 166 exit(1); |
| 167 } |
| 168 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream.get())); |
| 169 if (pic.get() == NULL) { |
| 170 SkDebugf("Could not read %s as an SkPicture.\n", path.c_str()); |
| 171 exit(1); |
| 172 } |
| 173 |
| 174 tasks->add(SkNEW_ARGS(DM::SKPTask, (reporter, tasks, pic.detach(), filen
ame))); |
| 175 } |
| 176 } |
| 177 |
146 static void report_failures(const DM::Reporter& reporter) { | 178 static void report_failures(const DM::Reporter& reporter) { |
147 SkTArray<SkString> failures; | 179 SkTArray<SkString> failures; |
148 reporter.getFailures(&failures); | 180 reporter.getFailures(&failures); |
149 | 181 |
150 if (failures.count() == 0) { | 182 if (failures.count() == 0) { |
151 return; | 183 return; |
152 } | 184 } |
153 | 185 |
154 SkDebugf("Failures:\n"); | 186 SkDebugf("Failures:\n"); |
155 for (int i = 0; i < failures.count(); i++) { | 187 for (int i = 0; i < failures.count(); i++) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 append_matching_factories<Test>(TestRegistry::Head(), &tests); | 240 append_matching_factories<Test>(TestRegistry::Head(), &tests); |
209 } | 241 } |
210 | 242 |
211 SkDebugf("(%d GMs, %d benches) x %d configs, %d tests\n", | 243 SkDebugf("(%d GMs, %d benches) x %d configs, %d tests\n", |
212 gms.count(), benches.count(), configs.count(), tests.count()); | 244 gms.count(), benches.count(), configs.count(), tests.count()); |
213 DM::Reporter reporter; | 245 DM::Reporter reporter; |
214 DM::TaskRunner tasks(FLAGS_threads, FLAGS_gpuThreads); | 246 DM::TaskRunner tasks(FLAGS_threads, FLAGS_gpuThreads); |
215 kick_off_gms(gms, configs, *expectations, &reporter, &tasks); | 247 kick_off_gms(gms, configs, *expectations, &reporter, &tasks); |
216 kick_off_benches(benches, configs, &reporter, &tasks); | 248 kick_off_benches(benches, configs, &reporter, &tasks); |
217 kick_off_tests(tests, &reporter, &tasks); | 249 kick_off_tests(tests, &reporter, &tasks); |
| 250 kick_off_skps(&reporter, &tasks); |
218 tasks.wait(); | 251 tasks.wait(); |
219 | 252 |
220 SkDebugf("\n"); | 253 SkDebugf("\n"); |
221 report_failures(reporter); | 254 report_failures(reporter); |
222 | 255 |
223 SkGraphics::Term(); | 256 SkGraphics::Term(); |
224 | 257 |
225 return reporter.failed() > 0; | 258 return reporter.failed() > 0; |
226 } | 259 } |
227 | 260 |
228 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 261 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
229 int main(int argc, char** argv) { | 262 int main(int argc, char** argv) { |
230 return tool_main(argc, argv); | 263 return tool_main(argc, argv); |
231 } | 264 } |
232 #endif | 265 #endif |
OLD | NEW |