Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: dm/DM.cpp

Issue 1611323004: Treat bad values passed to --images as a fatal error (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase; remove DNG specific changes Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « bench/nanobench.cpp ('k') | tools/flags/SkCommonFlags.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 }; 512 };
513 513
514 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { 514 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) {
515 if (0 == strcmp(exts[i], ext)) { 515 if (0 == strcmp(exts[i], ext)) {
516 return true; 516 return true;
517 } 517 }
518 } 518 }
519 return false; 519 return false;
520 } 520 }
521 521
522 static void gather_srcs() { 522 static bool gather_srcs() {
523 for (const skiagm::GMRegistry* r = skiagm::GMRegistry::Head(); r; r = r->nex t()) { 523 for (const skiagm::GMRegistry* r = skiagm::GMRegistry::Head(); r; r = r->nex t()) {
524 push_src("gm", "", new GMSrc(r->factory())); 524 push_src("gm", "", new GMSrc(r->factory()));
525 } 525 }
526 for (int i = 0; i < FLAGS_skps.count(); i++) { 526 for (int i = 0; i < FLAGS_skps.count(); i++) {
527 const char* path = FLAGS_skps[i]; 527 const char* path = FLAGS_skps[i];
528 if (sk_isdir(path)) { 528 if (sk_isdir(path)) {
529 SkOSFile::Iter it(path, "skp"); 529 SkOSFile::Iter it(path, "skp");
530 for (SkString file; it.next(&file); ) { 530 for (SkString file; it.next(&file); ) {
531 push_src("skp", "", new SKPSrc(SkOSPath::Join(path, file.c_str() ))); 531 push_src("skp", "", new SKPSrc(SkOSPath::Join(path, file.c_str() )));
532 } 532 }
533 } else { 533 } else {
534 push_src("skp", "", new SKPSrc(path)); 534 push_src("skp", "", new SKPSrc(path));
535 } 535 }
536 } 536 }
537 static const char* const exts[] = { 537
538 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico" , 538 SkTArray<SkString> images;
539 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO" , 539 if (!CollectImages(&images)) {
540 #ifdef SK_CODEC_DECODES_RAW 540 return false;
541 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw", 541 }
542 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW", 542
543 #endif 543 for (auto image : images) {
544 }; 544 push_codec_srcs(image);
545 for (int i = 0; i < FLAGS_images.count(); i++) { 545 const char* ext = "";
546 const char* flag = FLAGS_images[i]; 546 int index = image.findLastOf('.');
547 if (sk_isdir(flag)) { 547 if (index >= 0 && (size_t) ++index < image.size()) {
548 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { 548 ext = &image.c_str()[index];
549 SkOSFile::Iter it(flag, exts[j]); 549 }
550 for (SkString file; it.next(&file); ) { 550 if (brd_supported(ext)) {
551 SkString path = SkOSPath::Join(flag, file.c_str()); 551 push_brd_srcs(image);
552 push_codec_srcs(path);
553 if (brd_supported(exts[j])) {
554 push_brd_srcs(path);
555 }
556 }
557 }
558 } else if (sk_exists(flag)) {
559 // assume that FLAGS_images[i] is a valid image if it is a file.
560 push_codec_srcs(flag);
561 push_brd_srcs(flag);
562 } 552 }
563 } 553 }
554
555 return true;
564 } 556 }
565 557
566 static void push_sink(const SkCommandLineConfig& config, Sink* s) { 558 static void push_sink(const SkCommandLineConfig& config, Sink* s) {
567 SkAutoTDelete<Sink> sink(s); 559 SkAutoTDelete<Sink> sink(s);
568 560
569 // Try a simple Src as a canary. If it fails, skip this sink. 561 // Try a simple Src as a canary. If it fails, skip this sink.
570 struct : public Src { 562 struct : public Src {
571 Error draw(SkCanvas* c) const override { 563 Error draw(SkCanvas* c) const override {
572 c->drawRect(SkRect::MakeWH(1,1), SkPaint()); 564 c->drawRect(SkRect::MakeWH(1,1), SkPaint());
573 return ""; 565 return "";
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 JsonWriter::DumpJson(); // It's handy for the bots to assume this is ~never missing. 1093 JsonWriter::DumpJson(); // It's handy for the bots to assume this is ~never missing.
1102 SkAutoGraphics ag; 1094 SkAutoGraphics ag;
1103 SkTaskGroup::Enabler enabled(FLAGS_threads); 1095 SkTaskGroup::Enabler enabled(FLAGS_threads);
1104 gCreateTypefaceDelegate = &create_from_name; 1096 gCreateTypefaceDelegate = &create_from_name;
1105 1097
1106 start_keepalive(); 1098 start_keepalive();
1107 1099
1108 gather_gold(); 1100 gather_gold();
1109 gather_uninteresting_hashes(); 1101 gather_uninteresting_hashes();
1110 1102
1111 gather_srcs(); 1103 if (!gather_srcs()) {
1104 return 1;
1105 }
1112 gather_sinks(); 1106 gather_sinks();
1113 gather_tests(); 1107 gather_tests();
1114 1108
1115 gPending = gSrcs.count() * gSinks.count() + gThreadedTests.count() + gGPUTes ts.count(); 1109 gPending = gSrcs.count() * gSinks.count() + gThreadedTests.count() + gGPUTes ts.count();
1116 SkDebugf("%d srcs * %d sinks + %d tests == %d tasks\n", 1110 SkDebugf("%d srcs * %d sinks + %d tests == %d tasks\n",
1117 gSrcs.count(), gSinks.count(), gThreadedTests.count() + gGPUTests.c ount(), gPending); 1111 gSrcs.count(), gSinks.count(), gThreadedTests.count() + gGPUTests.c ount(), gPending);
1118 1112
1119 // We try to exploit as much parallelism as is safe. Most Src/Sink pairs ru n on any thread, 1113 // We try to exploit as much parallelism as is safe. Most Src/Sink pairs ru n on any thread,
1120 // but Sinks that identify as part of a particular enclave run serially on a single thread. 1114 // but Sinks that identify as part of a particular enclave run serially on a single thread.
1121 // CPU tests run on any thread. GPU tests depend on --gpu_threading. 1115 // CPU tests run on any thread. GPU tests depend on --gpu_threading.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 Reporter* reporter, 1258 Reporter* reporter,
1265 GrContextFactory* fac tory); 1259 GrContextFactory* fac tory);
1266 } // namespace skiatest 1260 } // namespace skiatest
1267 1261
1268 #if !defined(SK_BUILD_FOR_IOS) 1262 #if !defined(SK_BUILD_FOR_IOS)
1269 int main(int argc, char** argv) { 1263 int main(int argc, char** argv) {
1270 SkCommandLineFlags::Parse(argc, argv); 1264 SkCommandLineFlags::Parse(argc, argv);
1271 return dm_main(); 1265 return dm_main();
1272 } 1266 }
1273 #endif 1267 #endif
OLDNEW
« no previous file with comments | « bench/nanobench.cpp ('k') | tools/flags/SkCommonFlags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698