aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2016-01-28 08:41:10 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-28 08:41:10 -0800
commit7579786f3bd5a8fda84a1abc45b16213c3371f93 (patch)
treecbc6108da49f2ce75e629c6262f2ac711e2cb40f /dm
parentd8ff5b336e586ad971ebcafa5fb2eb1e7ac95589 (diff)
Treat bad values passed to --images as a fatal error
If an option is passed to --images that is either a non-existent path or a folder with no images matching the supported types, assume this is an error and exit, so they can supply a valid path instead. Share code between DM and nanobench in SkCommonFlags. nanobench now behaves more like DM - it will check a directory for images that match the supported extensions. Only consider image paths ending in RAW suffixes as images if SK_CODE_DECODES_RAW is defined. This prevents us from seeing failure to decode errors on platforms that cannot decode it. GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1611323004 Review URL: https://codereview.chromium.org/1611323004
Diffstat (limited to 'dm')
-rw-r--r--dm/DM.cpp46
1 files changed, 21 insertions, 25 deletions
diff --git a/dm/DM.cpp b/dm/DM.cpp
index d53402e723..715c4cab14 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -519,7 +519,7 @@ static bool brd_supported(const char* ext) {
return false;
}
-static void gather_srcs() {
+static bool gather_srcs() {
for (const skiagm::GMRegistry* r = skiagm::GMRegistry::Head(); r; r = r->next()) {
push_src("gm", "", new GMSrc(r->factory()));
}
@@ -534,31 +534,25 @@ static void gather_srcs() {
push_src("skp", "", new SKPSrc(path));
}
}
- static const char* const exts[] = {
- "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico",
- "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO",
- "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
- "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
- };
- for (int i = 0; i < FLAGS_images.count(); i++) {
- const char* flag = FLAGS_images[i];
- if (sk_isdir(flag)) {
- for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) {
- SkOSFile::Iter it(flag, exts[j]);
- for (SkString file; it.next(&file); ) {
- SkString path = SkOSPath::Join(flag, file.c_str());
- push_codec_srcs(path);
- if (brd_supported(exts[j])) {
- push_brd_srcs(path);
- }
- }
- }
- } else if (sk_exists(flag)) {
- // assume that FLAGS_images[i] is a valid image if it is a file.
- push_codec_srcs(flag);
- push_brd_srcs(flag);
+
+ SkTArray<SkString> images;
+ if (!CollectImages(&images)) {
+ return false;
+ }
+
+ for (auto image : images) {
+ push_codec_srcs(image);
+ const char* ext = "";
+ int index = image.findLastOf('.');
+ if (index >= 0 && (size_t) ++index < image.size()) {
+ ext = &image.c_str()[index];
+ }
+ if (brd_supported(ext)) {
+ push_brd_srcs(image);
}
}
+
+ return true;
}
static void push_sink(const SkCommandLineConfig& config, Sink* s) {
@@ -1106,7 +1100,9 @@ int dm_main() {
gather_gold();
gather_uninteresting_hashes();
- gather_srcs();
+ if (!gather_srcs()) {
+ return 1;
+ }
gather_sinks();
gather_tests();