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 "CrashHandler.h" | 4 #include "CrashHandler.h" |
5 #include "LazyDecodeBitmap.h" | 5 #include "LazyDecodeBitmap.h" |
6 #include "SkCommonFlags.h" | 6 #include "SkCommonFlags.h" |
7 #include "SkForceLinking.h" | 7 #include "SkForceLinking.h" |
8 #include "SkGraphics.h" | 8 #include "SkGraphics.h" |
9 #include "SkOSFile.h" | 9 #include "SkOSFile.h" |
10 #include "SkPicture.h" | 10 #include "SkPicture.h" |
11 #include "SkString.h" | 11 #include "SkString.h" |
12 #include "SkTaskGroup.h" | 12 #include "SkTaskGroup.h" |
13 #include "Test.h" | 13 #include "Test.h" |
14 #include "gm.h" | 14 #include "gm.h" |
15 #include "sk_tool_utils.h" | 15 #include "sk_tool_utils.h" |
16 #include "sk_tool_utils_flags.h" | 16 #include "sk_tool_utils_flags.h" |
17 | 17 |
18 #include "DMCpuGMTask.h" | 18 #include "DMCpuGMTask.h" |
19 #include "DMGpuGMTask.h" | 19 #include "DMGpuGMTask.h" |
20 #include "DMGpuSupport.h" | 20 #include "DMGpuSupport.h" |
| 21 #include "DMImageTask.h" |
21 #include "DMJsonWriter.h" | 22 #include "DMJsonWriter.h" |
22 #include "DMPDFTask.h" | 23 #include "DMPDFTask.h" |
23 #include "DMReporter.h" | 24 #include "DMReporter.h" |
24 #include "DMSKPTask.h" | 25 #include "DMSKPTask.h" |
25 #include "DMTask.h" | 26 #include "DMTask.h" |
26 #include "DMTaskRunner.h" | 27 #include "DMTaskRunner.h" |
27 #include "DMTestTask.h" | 28 #include "DMTestTask.h" |
28 | 29 |
29 #ifdef SK_BUILD_POPPLER | 30 #ifdef SK_BUILD_POPPLER |
30 # include "SkPDFRasterizer.h" | 31 # include "SkPDFRasterizer.h" |
(...skipping 12 matching lines...) Expand all Loading... |
43 using skiatest::Test; | 44 using skiatest::Test; |
44 using skiatest::TestRegistry; | 45 using skiatest::TestRegistry; |
45 | 46 |
46 static const char kGpuAPINameGL[] = "gl"; | 47 static const char kGpuAPINameGL[] = "gl"; |
47 static const char kGpuAPINameGLES[] = "gles"; | 48 static const char kGpuAPINameGLES[] = "gles"; |
48 | 49 |
49 DEFINE_bool(gms, true, "Run GMs?"); | 50 DEFINE_bool(gms, true, "Run GMs?"); |
50 DEFINE_bool(tests, true, "Run tests?"); | 51 DEFINE_bool(tests, true, "Run tests?"); |
51 DEFINE_bool(reportUsedChars, false, "Output test font construction data to be pa
sted into" | 52 DEFINE_bool(reportUsedChars, false, "Output test font construction data to be pa
sted into" |
52 " create_test_font.cpp."); | 53 " create_test_font.cpp."); |
| 54 DEFINE_string(images, "resources", "Path to directory containing images to decod
e."); |
53 | 55 |
54 __SK_FORCE_IMAGE_DECODER_LINKING; | 56 __SK_FORCE_IMAGE_DECODER_LINKING; |
55 | 57 |
56 // "FooBar" -> "foobar". Obviously, ASCII only. | 58 // "FooBar" -> "foobar". Obviously, ASCII only. |
57 static SkString lowercase(SkString s) { | 59 static SkString lowercase(SkString s) { |
58 for (size_t i = 0; i < s.size(); i++) { | 60 for (size_t i = 0; i < s.size(); i++) { |
59 s[i] = tolower(s[i]); | 61 s[i] = tolower(s[i]); |
60 } | 62 } |
61 return s; | 63 return s; |
62 } | 64 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 for (int i = 0; i < tests.count(); i++) { | 114 for (int i = 0; i < tests.count(); i++) { |
113 SkAutoTDelete<Test> test(tests[i](NULL)); | 115 SkAutoTDelete<Test> test(tests[i](NULL)); |
114 if (test->isGPUTest()) { | 116 if (test->isGPUTest()) { |
115 tasks->add(SkNEW_ARGS(DM::GpuTestTask, (reporter, tasks, tests[i])))
; | 117 tasks->add(SkNEW_ARGS(DM::GpuTestTask, (reporter, tasks, tests[i])))
; |
116 } else { | 118 } else { |
117 tasks->add(SkNEW_ARGS(DM::CpuTestTask, (reporter, tasks, tests[i])))
; | 119 tasks->add(SkNEW_ARGS(DM::CpuTestTask, (reporter, tasks, tests[i])))
; |
118 } | 120 } |
119 } | 121 } |
120 } | 122 } |
121 | 123 |
122 static void find_skps(SkTArray<SkString>* skps) { | 124 static void find_files(const char* dir, |
123 if (FLAGS_skps.isEmpty()) { | 125 const char* suffixes[], |
| 126 size_t num_suffixes, |
| 127 SkTArray<SkString>* files) { |
| 128 if (0 == strcmp(dir, "")) { |
124 return; | 129 return; |
125 } | 130 } |
126 | 131 |
127 SkOSFile::Iter it(FLAGS_skps[0], ".skp"); | |
128 SkString filename; | 132 SkString filename; |
129 while (it.next(&filename)) { | 133 for (size_t i = 0; i < num_suffixes; i++) { |
130 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, filename.c_str())) { | 134 SkOSFile::Iter it(dir, suffixes[i]); |
131 skps->push_back(SkOSPath::Join(FLAGS_skps[0], filename.c_str())); | 135 while (it.next(&filename)) { |
| 136 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, filename.c_str()))
{ |
| 137 files->push_back(SkOSPath::Join(dir, filename.c_str())); |
| 138 } |
132 } | 139 } |
133 } | 140 } |
134 } | 141 } |
135 | 142 |
136 static void kick_off_skps(const SkTArray<SkString>& skps, | 143 static void kick_off_skps(const SkTArray<SkString>& skps, |
137 DM::Reporter* reporter, | 144 DM::Reporter* reporter, |
138 DM::TaskRunner* tasks) { | 145 DM::TaskRunner* tasks) { |
139 for (int i = 0; i < skps.count(); ++i) { | 146 for (int i = 0; i < skps.count(); ++i) { |
140 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(skps[i].c_str())); | 147 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(skps[i].c_str())); |
141 if (stream.get() == NULL) { | 148 if (stream.get() == NULL) { |
142 SkDebugf("Could not read %s.\n", skps[i].c_str()); | 149 SkDebugf("Could not read %s.\n", skps[i].c_str()); |
143 exit(1); | 150 exit(1); |
144 } | 151 } |
145 SkAutoTUnref<SkPicture> pic( | 152 SkAutoTUnref<SkPicture> pic( |
146 SkPicture::CreateFromStream(stream.get(), &sk_tools::LazyDecodeB
itmap)); | 153 SkPicture::CreateFromStream(stream.get(), &sk_tools::LazyDecodeB
itmap)); |
147 if (pic.get() == NULL) { | 154 if (pic.get() == NULL) { |
148 SkDebugf("Could not read %s as an SkPicture.\n", skps[i].c_str()); | 155 SkDebugf("Could not read %s as an SkPicture.\n", skps[i].c_str()); |
149 exit(1); | 156 exit(1); |
150 } | 157 } |
151 | 158 |
152 SkString filename = SkOSPath::Basename(skps[i].c_str()); | 159 SkString filename = SkOSPath::Basename(skps[i].c_str()); |
153 tasks->add(SkNEW_ARGS(DM::SKPTask, (reporter, tasks, pic, filename))); | 160 tasks->add(SkNEW_ARGS(DM::SKPTask, (reporter, tasks, pic, filename))); |
154 tasks->add(SkNEW_ARGS(DM::PDFTask, (reporter, tasks, pic, filename, RAST
ERIZE_PDF_PROC))); | 161 tasks->add(SkNEW_ARGS(DM::PDFTask, (reporter, tasks, pic, filename, RAST
ERIZE_PDF_PROC))); |
155 } | 162 } |
156 } | 163 } |
157 | 164 |
| 165 static void kick_off_images(const SkTArray<SkString>& images, |
| 166 DM::Reporter* reporter, |
| 167 DM::TaskRunner* tasks) { |
| 168 for (int i = 0; i < images.count(); i++) { |
| 169 SkAutoTUnref<SkData> image(SkData::NewFromFileName(images[i].c_str())); |
| 170 if (!image) { |
| 171 SkDebugf("Could not read %s.\n", images[i].c_str()); |
| 172 exit(1); |
| 173 } |
| 174 SkString filename = SkOSPath::Basename(images[i].c_str()); |
| 175 tasks->add(SkNEW_ARGS(DM::ImageTask, (reporter, tasks, image, filename))
); |
| 176 tasks->add(SkNEW_ARGS(DM::ImageTask, (reporter, tasks, image, filename,
5/*subsets*/))); |
| 177 } |
| 178 } |
| 179 |
| 180 |
158 static void report_failures(const SkTArray<SkString>& failures) { | 181 static void report_failures(const SkTArray<SkString>& failures) { |
159 if (failures.count() == 0) { | 182 if (failures.count() == 0) { |
160 return; | 183 return; |
161 } | 184 } |
162 | 185 |
163 SkDebugf("Failures:\n"); | 186 SkDebugf("Failures:\n"); |
164 for (int i = 0; i < failures.count(); i++) { | 187 for (int i = 0; i < failures.count(); i++) { |
165 SkDebugf(" %s\n", failures[i].c_str()); | 188 SkDebugf(" %s\n", failures[i].c_str()); |
166 } | 189 } |
167 SkDebugf("%d failures.\n", failures.count()); | 190 SkDebugf("%d failures.\n", failures.count()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 SkTDArray<GMRegistry::Factory> gms; | 233 SkTDArray<GMRegistry::Factory> gms; |
211 if (FLAGS_gms) { | 234 if (FLAGS_gms) { |
212 append_matching_factories<GM>(GMRegistry::Head(), &gms); | 235 append_matching_factories<GM>(GMRegistry::Head(), &gms); |
213 } | 236 } |
214 | 237 |
215 SkTDArray<TestRegistry::Factory> tests; | 238 SkTDArray<TestRegistry::Factory> tests; |
216 if (FLAGS_tests) { | 239 if (FLAGS_tests) { |
217 append_matching_factories<Test>(TestRegistry::Head(), &tests); | 240 append_matching_factories<Test>(TestRegistry::Head(), &tests); |
218 } | 241 } |
219 | 242 |
| 243 |
220 SkTArray<SkString> skps; | 244 SkTArray<SkString> skps; |
221 find_skps(&skps); | 245 if (!FLAGS_skps.isEmpty()) { |
| 246 const char* suffixes[] = { "skp" }; |
| 247 find_files(FLAGS_skps[0], suffixes, SK_ARRAY_COUNT(suffixes), &skps); |
| 248 } |
222 | 249 |
223 SkDebugf("%d GMs x %d configs, %d tests, %d pictures\n", | 250 SkTArray<SkString> images; |
224 gms.count(), configs.count(), tests.count(), skps.count()); | 251 if (!FLAGS_images.isEmpty()) { |
| 252 const char* suffixes[] = { "bmp", "gif", "jpg", "png", "webp", "ktx", "a
stc" }; |
| 253 find_files(FLAGS_images[0], suffixes, SK_ARRAY_COUNT(suffixes), &images)
; |
| 254 } |
| 255 |
| 256 SkDebugf("%d GMs x %d configs, %d tests, %d pictures, %d images\n", |
| 257 gms.count(), configs.count(), tests.count(), skps.count(), images.c
ount()); |
225 DM::Reporter reporter; | 258 DM::Reporter reporter; |
226 | 259 |
227 DM::TaskRunner tasks; | 260 DM::TaskRunner tasks; |
228 kick_off_tests(tests, &reporter, &tasks); | 261 kick_off_tests(tests, &reporter, &tasks); |
229 kick_off_gms(gms, configs, gpuAPI, &reporter, &tasks); | 262 kick_off_gms(gms, configs, gpuAPI, &reporter, &tasks); |
230 kick_off_skps(skps, &reporter, &tasks); | 263 kick_off_skps(skps, &reporter, &tasks); |
| 264 kick_off_images(images, &reporter, &tasks); |
231 tasks.wait(); | 265 tasks.wait(); |
232 | 266 |
233 DM::JsonWriter::DumpJson(); | 267 DM::JsonWriter::DumpJson(); |
234 | 268 |
235 SkDebugf("\n"); | 269 SkDebugf("\n"); |
236 #ifdef SK_DEBUG | 270 #ifdef SK_DEBUG |
237 if (FLAGS_portableFonts && FLAGS_reportUsedChars) { | 271 if (FLAGS_portableFonts && FLAGS_reportUsedChars) { |
238 sk_tool_utils::report_used_chars(); | 272 sk_tool_utils::report_used_chars(); |
239 } | 273 } |
240 #endif | 274 #endif |
241 | 275 |
242 SkTArray<SkString> failures; | 276 SkTArray<SkString> failures; |
243 reporter.getFailures(&failures); | 277 reporter.getFailures(&failures); |
244 report_failures(failures); | 278 report_failures(failures); |
245 return failures.count() > 0; | 279 return failures.count() > 0; |
246 } | 280 } |
247 | 281 |
248 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 282 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
249 int main(int argc, char** argv) { | 283 int main(int argc, char** argv) { |
250 SkCommandLineFlags::Parse(argc, argv); | 284 SkCommandLineFlags::Parse(argc, argv); |
251 return dm_main(); | 285 return dm_main(); |
252 } | 286 } |
253 #endif | 287 #endif |
OLD | NEW |