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

Unified 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 Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: dm/DM.cpp
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 9f2684cea9c8068fcc45e80131ce6e8eca5ca912..f9186874dc5504c4fe02d37bf49cc6eb9fc1f4fc 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -519,21 +519,7 @@ static bool brd_supported(const char* ext) {
return false;
}
-static bool is_raw(const SkString& file) {
scroggo 2016/01/27 15:43:36 This was only here to prevent testing RAW with SkI
- static const char* const exts[] = {
- "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
- "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
- };
-
- for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) {
- if (file.endsWith(exts[i])) {
- return true;
- }
- }
- 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()));
}
@@ -548,37 +534,26 @@ 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());
- if (!is_raw(file)) {
- push_src("image", "decode", new ImageSrc(path)); // Decode entire image
- }
- 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.
- if (!is_raw(SkString(flag))) {
- push_src("image", "decode", new ImageSrc(flag)); // Decode entire image.
- }
- push_codec_srcs(flag);
- push_brd_srcs(flag);
+
+ SkTArray<SkString> images;
+ if (!CollectImages(&images)) {
+ return false;
+ }
+
+ for (auto image : images) {
+ push_src("image", "decode", new ImageSrc(image)); // Decode entire image
+ 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) {
@@ -1126,7 +1101,9 @@ int dm_main() {
gather_gold();
gather_uninteresting_hashes();
- gather_srcs();
+ if (!gather_srcs()) {
+ exit(1);
+ }
gather_sinks();
gather_tests();
« no previous file with comments | « bench/nanobench.cpp ('k') | tools/flags/SkCommonFlags.h » ('j') | tools/flags/SkCommonFlags.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698