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.

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
diff --git a/tools/flags/SkCommonFlags.h b/tools/flags/SkCommonFlags.h
index 127d373..8e00e75 100644
--- a/tools/flags/SkCommonFlags.h
+++ b/tools/flags/SkCommonFlags.h
@@ -9,6 +9,8 @@
 #define SK_COMMON_FLAGS_H
 
 #include "SkCommandLineFlags.h"
+#include "SkTArray.h"
+#include "SkString.h"
 
 DECLARE_bool(cpu);
 DECLARE_bool(dryRun);
@@ -30,4 +32,18 @@
 DECLARE_string(key);
 DECLARE_string(properties);
 
+/**
+ *  Helper to assist in collecting image paths from --images.
+ *
+ *  Populates an array of strings with paths to images to test.
+ *
+ *  Returns true if each argument to --images is meaningful:
+ *  - If the file/directory does not exist, return false.
+ *  - If a directory passed to --images does not have any supported images (based on file
+ *  type), return false.
+ *  - If a file is passed to --images, assume the user is deliberately testing this image,
+ *  regardless of file type.
+ */
+bool CollectImages(SkTArray<SkString>*);
+
 #endif