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" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 SkTArray<SkString> hashes; | 158 SkTArray<SkString> hashes; |
159 SkStrSplit((const char*)data->data(), "\n", &hashes); | 159 SkStrSplit((const char*)data->data(), "\n", &hashes); |
160 for (const SkString& hash : hashes) { | 160 for (const SkString& hash : hashes) { |
161 gUninterestingHashes.add(hash); | 161 gUninterestingHashes.add(hash); |
162 } | 162 } |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 166 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
167 | 167 |
168 template <typename T> | 168 struct TaggedSrc : public SkAutoTDelete<Src> { |
169 struct Tagged : public SkAutoTDelete<T> { | 169 const char* tag; |
170 const char* tag; | 170 const char* options; |
171 const char* options; | 171 }; |
| 172 |
| 173 struct TaggedSink : public SkAutoTDelete<Sink> { |
| 174 const char* tag; |
| 175 const char* options; |
| 176 SinkType type; |
172 }; | 177 }; |
173 | 178 |
174 static const bool kMemcpyOK = true; | 179 static const bool kMemcpyOK = true; |
175 | 180 |
176 static SkTArray<Tagged<Src>, kMemcpyOK> gSrcs; | 181 static SkTArray<TaggedSrc, kMemcpyOK> gSrcs; |
177 static SkTArray<Tagged<Sink>, kMemcpyOK> gSinks; | 182 static SkTArray<TaggedSink, kMemcpyOK> gSinks; |
178 | 183 |
179 static bool in_shard() { | 184 static bool in_shard() { |
180 static int N = 0; | 185 static int N = 0; |
181 return N++ % FLAGS_shards == FLAGS_shard; | 186 return N++ % FLAGS_shards == FLAGS_shard; |
182 } | 187 } |
183 | 188 |
184 static void push_src(const char* tag, const char* options, Src* s) { | 189 static void push_src(const char* tag, const char* options, Src* s) { |
185 SkAutoTDelete<Src> src(s); | 190 SkAutoTDelete<Src> src(s); |
186 if (in_shard() && | 191 if (in_shard() && |
187 FLAGS_src.contains(tag) && | 192 FLAGS_src.contains(tag) && |
188 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { | 193 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { |
189 Tagged<Src>& s = gSrcs.push_back(); | 194 TaggedSrc& s = gSrcs.push_back(); |
190 s.reset(src.detach()); | 195 s.reset(src.detach()); |
191 s.tag = tag; | 196 s.tag = tag; |
192 s.options = options; | 197 s.options = options; |
193 } | 198 } |
194 } | 199 } |
195 | 200 |
196 static void push_codec_srcs(Path path) { | 201 static void push_codec_srcs(Path path) { |
197 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | 202 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); |
198 if (!encoded) { | 203 if (!encoded) { |
199 SkDebugf("Couldn't read %s.", path.c_str()); | 204 SkDebugf("Couldn't read %s.", path.c_str()); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } | 327 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } |
323 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } | 328 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } |
324 return kNone_GrGLStandard; | 329 return kNone_GrGLStandard; |
325 } | 330 } |
326 | 331 |
327 static void push_sink(const char* tag, Sink* s) { | 332 static void push_sink(const char* tag, Sink* s) { |
328 SkAutoTDelete<Sink> sink(s); | 333 SkAutoTDelete<Sink> sink(s); |
329 if (!FLAGS_config.contains(tag)) { | 334 if (!FLAGS_config.contains(tag)) { |
330 return; | 335 return; |
331 } | 336 } |
332 // Try a noop Src as a canary. If it fails, skip this sink. | 337 // Try a simple Src as a canary. If it fails, skip this sink. |
333 struct : public Src { | 338 struct : public Src { |
334 Error draw(SkCanvas*) const override { return ""; } | 339 Error draw(SkCanvas* c) const override { |
| 340 c->drawRect(SkRect::MakeWH(1,1), SkPaint()); |
| 341 return ""; |
| 342 } |
335 SkISize size() const override { return SkISize::Make(16, 16); } | 343 SkISize size() const override { return SkISize::Make(16, 16); } |
336 Name name() const override { return "noop"; } | 344 Name name() const override { return "justOneRect"; } |
337 } noop; | 345 } justOneRect; |
338 | 346 |
339 SkBitmap bitmap; | 347 SkBitmap bitmap; |
340 SkDynamicMemoryWStream stream; | 348 SkDynamicMemoryWStream stream; |
341 SkString log; | 349 SkString log; |
342 Error err = sink->draw(noop, &bitmap, &stream, &log); | 350 Error err = sink->draw(justOneRect, &bitmap, &stream, &log); |
343 if (err.isFatal()) { | 351 if (err.isFatal()) { |
344 SkDebugf("Could not run %s: %s\n", tag, err.c_str()); | 352 SkDebugf("Could not run %s: %s\n", tag, err.c_str()); |
345 exit(1); | 353 exit(1); |
346 } | 354 } |
347 | 355 |
348 Tagged<Sink>& ts = gSinks.push_back(); | 356 SinkType type = kRaster_SinkType; |
| 357 if (sink->enclave() == kGPU_Enclave) { type = kGPU_SinkType; } |
| 358 if (stream.bytesWritten() > 0) { type = kVector_SinkType; } |
| 359 |
| 360 TaggedSink& ts = gSinks.push_back(); |
349 ts.reset(sink.detach()); | 361 ts.reset(sink.detach()); |
350 ts.tag = tag; | 362 ts.tag = tag; |
| 363 ts.type = type; |
351 } | 364 } |
352 | 365 |
353 static bool gpu_supported() { | 366 static bool gpu_supported() { |
354 #if SK_SUPPORT_GPU | 367 #if SK_SUPPORT_GPU |
355 return FLAGS_gpu; | 368 return FLAGS_gpu; |
356 #else | 369 #else |
357 return false; | 370 return false; |
358 #endif | 371 #endif |
359 } | 372 } |
360 | 373 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 FLAGS_blacklist[i+0], FLAGS_blacklist[i+1], | 478 FLAGS_blacklist[i+0], FLAGS_blacklist[i+1], |
466 FLAGS_blacklist[i+2], FLAGS_blacklist[i+3]); | 479 FLAGS_blacklist[i+2], FLAGS_blacklist[i+3]); |
467 } | 480 } |
468 } | 481 } |
469 return ""; | 482 return ""; |
470 } | 483 } |
471 | 484 |
472 // The finest-grained unit of work we can run: draw a single Src into a single S
ink, | 485 // The finest-grained unit of work we can run: draw a single Src into a single S
ink, |
473 // report any errors, and perhaps write out the output: a .png of the bitmap, or
a raw stream. | 486 // report any errors, and perhaps write out the output: a .png of the bitmap, or
a raw stream. |
474 struct Task { | 487 struct Task { |
475 Task(const Tagged<Src>& src, const Tagged<Sink>& sink) : src(src), sink(sink
) {} | 488 Task(const TaggedSrc& src, const TaggedSink& sink) : src(src), sink(sink) {} |
476 const Tagged<Src>& src; | 489 const TaggedSrc& src; |
477 const Tagged<Sink>& sink; | 490 const TaggedSink& sink; |
478 | 491 |
479 static void Run(Task* task) { | 492 static void Run(Task* task) { |
480 SkString name = task->src->name(); | 493 SkString name = task->src->name(); |
481 SkString note; | 494 |
| 495 // We'll skip drawing this Src/Sink pair if: |
| 496 // - the Src vetoes the Sink; |
| 497 // - this Src / Sink combination is on the blacklist; |
| 498 // - it's a dry run. |
| 499 SkString note(task->src->veto(task->sink.type) ? " (veto)" : ""); |
482 SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag, | 500 SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag, |
483 task->src.options, name.c_str()
); | 501 task->src.options, name.c_str()
); |
484 if (!whyBlacklisted.isEmpty()) { | 502 if (!whyBlacklisted.isEmpty()) { |
485 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str()); | 503 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str()); |
486 } | 504 } |
| 505 |
487 SkString log; | 506 SkString log; |
488 WallTimer timer; | 507 WallTimer timer; |
489 timer.start(); | 508 timer.start(); |
490 if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) { | 509 if (!FLAGS_dryRun && note.isEmpty()) { |
491 SkBitmap bitmap; | 510 SkBitmap bitmap; |
492 SkDynamicMemoryWStream stream; | 511 SkDynamicMemoryWStream stream; |
493 if (FLAGS_pre_log) { | 512 if (FLAGS_pre_log) { |
494 SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag); | 513 SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag); |
495 } | 514 } |
496 start(task->sink.tag, task->src.tag, task->src.options, name.c_str()
); | 515 start(task->sink.tag, task->src.tag, task->src.options, name.c_str()
); |
497 Error err = task->sink->draw(*task->src, &bitmap, &stream, &log); | 516 Error err = task->sink->draw(*task->src, &bitmap, &stream, &log); |
498 if (!err.isEmpty()) { | 517 if (!err.isEmpty()) { |
499 timer.end(); | 518 timer.end(); |
500 if (err.isFatal()) { | 519 if (err.isFatal()) { |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 } | 845 } |
827 return 0; | 846 return 0; |
828 } | 847 } |
829 | 848 |
830 #if !defined(SK_BUILD_FOR_IOS) | 849 #if !defined(SK_BUILD_FOR_IOS) |
831 int main(int argc, char** argv) { | 850 int main(int argc, char** argv) { |
832 SkCommandLineFlags::Parse(argc, argv); | 851 SkCommandLineFlags::Parse(argc, argv); |
833 return dm_main(); | 852 return dm_main(); |
834 } | 853 } |
835 #endif | 854 #endif |
OLD | NEW |