aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2015-01-30 09:58:58 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-30 09:58:58 -0800
commit23b03c3c5a79d624c12bd1af5d11ba87967c53e2 (patch)
tree2826b5b9a5ea3399ecaab233434955dc4826be97
parent93957f4e8087774f35e2d1c3ff38ec7da306551d (diff)
dm: allow multiple --images flags, allow single files
-rw-r--r--dm/DM.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/dm/DM.cpp b/dm/DM.cpp
index dd4e48fc5d..15c1cfa5c9 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -133,18 +133,25 @@ static void gather_srcs() {
push_src("skp", new SKPSrc(SkString(path)));
}
}
- if (!FLAGS_images.isEmpty()) {
- const char* exts[] = {
- "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico",
- "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO",
- };
- for (size_t i = 0; i < SK_ARRAY_COUNT(exts); i++) {
- SkOSFile::Iter it(FLAGS_images[0], exts[i]);
- for (SkString file; it.next(&file); ) {
- SkString path = SkOSPath::Join(FLAGS_images[0], file.c_str());
- push_src("image", new ImageSrc(path)); // Decode entire image.
- push_src("image", new ImageSrc(path, 5)); // Decode 5 random subsets.
+ 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",
+ };
+ 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_src("image", new ImageSrc(path)); // Decode entire image.
+ push_src("image", new ImageSrc(path, 5)); // Decode 5 random subsets.
+ }
}
+ } else if (sk_exists(flag)) {
+ // assume that FLAGS_images[i] is a valid image if it is a file.
+ push_src("image", new ImageSrc(SkString(flag))); // Decode entire image.
+ push_src("image", new ImageSrc(SkString(flag), 5)); // Decode 5 random subsets.
}
}
}