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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
448 task->src.options, name, md5))) { | 448 task->src.options, name, md5))) { |
449 fail(SkStringPrintf("%s not found for %s %s %s %s in %s", | 449 fail(SkStringPrintf("%s not found for %s %s %s %s in %s", |
450 md5.c_str(), | 450 md5.c_str(), |
451 task->sink.tag, | 451 task->sink.tag, |
452 task->src.tag, | 452 task->src.tag, |
453 task->src.options, | 453 task->src.options, |
454 name.c_str(), | 454 name.c_str(), |
455 FLAGS_readPath[0])); | 455 FLAGS_readPath[0])); |
456 } | 456 } |
457 | 457 |
458 if (!FLAGS_writePath.isEmpty() && !gUninterestingHashes.contains(md5 )) { | 458 if (!FLAGS_writePath.isEmpty()) { |
459 const char* ext = task->sink->fileExtension(); | 459 const char* ext = task->sink->fileExtension(); |
460 if (data->getLength()) { | 460 if (data->getLength()) { |
461 WriteToDisk(*task, md5, ext, data, data->getLength(), NULL); | 461 WriteToDisk(*task, md5, ext, data, data->getLength(), NULL); |
462 SkASSERT(bitmap.drawsNothing()); | 462 SkASSERT(bitmap.drawsNothing()); |
463 } else if (!bitmap.drawsNothing()) { | 463 } else if (!bitmap.drawsNothing()) { |
464 WriteToDisk(*task, md5, ext, NULL, 0, &bitmap); | 464 WriteToDisk(*task, md5, ext, NULL, 0, &bitmap); |
465 } | 465 } |
466 } | 466 } |
467 } | 467 } |
468 timer.end(); | 468 timer.end(); |
469 done(timer.fWall, task->sink.tag, task->src.tag, task->src.options, name , note, log); | 469 done(timer.fWall, task->sink.tag, task->src.tag, task->src.options, name , note, log); |
470 } | 470 } |
471 | 471 |
472 static void WriteToDisk(const Task& task, | 472 static void WriteToDisk(const Task& task, |
473 SkString md5, | 473 SkString md5, |
474 const char* ext, | 474 const char* ext, |
475 SkStream* data, size_t len, | 475 SkStream* data, size_t len, |
476 const SkBitmap* bitmap) { | 476 const SkBitmap* bitmap) { |
477 JsonWriter::BitmapResult result; | 477 JsonWriter::BitmapResult result; |
478 result.name = task.src->name(); | 478 result.name = task.src->name(); |
479 result.config = task.sink.tag; | 479 result.config = task.sink.tag; |
480 result.sourceType = task.src.tag; | 480 result.sourceType = task.src.tag; |
481 result.sourceOptions = task.src.options; | 481 result.sourceOptions = task.src.options; |
482 result.ext = ext; | 482 result.ext = ext; |
483 result.md5 = md5; | 483 result.md5 = md5; |
484 JsonWriter::AddBitmapResult(result); | 484 JsonWriter::AddBitmapResult(result); |
485 | 485 |
486 // If an MD5 is uninteresting, we want it noted in the JSON file, | |
487 // but don't want to dump it out as a .png (or whatever ext is). | |
488 if (gUninterestingHashes.contains(md5)) { | |
489 return; | |
490 } | |
borenet
2015/04/08 11:47:54
I didn't realize WriteToDisk did more than write t
| |
491 | |
486 const char* dir = FLAGS_writePath[0]; | 492 const char* dir = FLAGS_writePath[0]; |
487 if (0 == strcmp(dir, "@")) { // Needed for iOS. | 493 if (0 == strcmp(dir, "@")) { // Needed for iOS. |
488 dir = FLAGS_resourcePath[0]; | 494 dir = FLAGS_resourcePath[0]; |
489 } | 495 } |
490 sk_mkdir(dir); | 496 sk_mkdir(dir); |
491 | 497 |
492 SkString path; | 498 SkString path; |
493 if (FLAGS_nameByHash) { | 499 if (FLAGS_nameByHash) { |
494 path = SkOSPath::Join(dir, result.md5.c_str()); | 500 path = SkOSPath::Join(dir, result.md5.c_str()); |
495 path.append("."); | 501 path.append("."); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
699 } | 705 } |
700 return 0; | 706 return 0; |
701 } | 707 } |
702 | 708 |
703 #if !defined(SK_BUILD_FOR_IOS) | 709 #if !defined(SK_BUILD_FOR_IOS) |
704 int main(int argc, char** argv) { | 710 int main(int argc, char** argv) { |
705 SkCommandLineFlags::Parse(argc, argv); | 711 SkCommandLineFlags::Parse(argc, argv); |
706 return dm_main(); | 712 return dm_main(); |
707 } | 713 } |
708 #endif | 714 #endif |
OLD | NEW |