1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkCommonFlags.h"
9 #include "SkOSFile.h"
10 #include "SkOSPath.h"
11
12 DEFINE_bool(cpu, true, "master switch for running CPU-bound work.");
13
14 DEFINE_bool(dryRun, false,
15 "just print the tests that would be run, without actually running them.");
16
17 DEFINE_bool(gpu, true, "master switch for running GPU-bound work.");
18
19 DEFINE_string(images, "", "List of images and/or directories to decode. A directory with no images"
20 " is treated as a fatal error.");
21
22 DEFINE_string(colorImages, "", "List of images and/or directories to decode with color correction. "
23 "A directory with no images is treated as a fatal error.");
24
25 DEFINE_bool(simpleCodec, false, "Runs of a subset of the codec tests. "
26 "For DM, this means no scaling or subsetting, always using the "
27 "canvas color type. "
28 "For nanobench, this means always N32, Premul or Opaque.");
29
30 DEFINE_string2(match, m, nullptr,
31 "[~][^]substring[$] [...] of GM name to run.\n"
32 "Multiple matches may be separated by spaces.\n"
33 "~ causes a matching GM to always be skipped\n"
34 "^ requires the start of the GM to match\n"
35 "$ requires the end of the GM to match\n"
36 "^ and $ requires an exact match\n"
37 "If a GM does not match any list entry,\n"
38 "it is skipped unless some list entry starts with ~");
39
40 DEFINE_bool2(quiet, q, false, "if true, don't print status updates.");
41
42 DEFINE_bool(preAbandonGpuContext, false, "Test abandoning the GrContext before running the test.");
43
44 DEFINE_bool(abandonGpuContext, false, "Test abandoning the GrContext after running each test.");
45
46 DEFINE_bool(releaseAndAbandonGpuContext, false,
47 "Test releasing all gpu resources and abandoning the GrContext after running each "
48 "test");
49
50 DEFINE_string(skps, "skps", "Directory to read skps from.");
51
52 DEFINE_string(svgs, "", "Directory to read SVGs from, or a single SVG file.");
53
54 DEFINE_int32_2(threads, j, -1, "Run threadsafe tests on a threadpool with this many extra threads, "
55 "defaulting to one extra thread per core.");
56
57 DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
58
59 DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose.");
60
61 DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs.");
62
63 DEFINE_string(key, "",
64 "Space-separated key/value pairs to add to JSON identifying this builder.");
65 DEFINE_string(properties, "",
66 "Space-separated key/value pairs to add to JSON identifying this run.");
67 DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehensible when threading");
68
69 DEFINE_bool(analyticAA, true, "If false, disable analytic anti-aliasing");
70
71 DEFINE_bool(forceAnalyticAA, false, "Force analytic anti-aliasing even if the path is complicated: "
72 "whether it's concave or convex, we consider a path complicated"
73 "if its number of points is comparable to its resolution.");
74
CollectImages(SkCommandLineFlags::StringArray images,SkTArray<SkString> * output)75 bool CollectImages(SkCommandLineFlags::StringArray images, SkTArray<SkString>* output) {
76 SkASSERT(output);
77
78 static const char* const exts[] = {
79 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico",
80 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO",
81 #ifdef SK_CODEC_DECODES_RAW
82 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
83 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
84 #endif
85 };
86
87 for (int i = 0; i < images.count(); ++i) {
88 const char* flag = images[i];
89 if (!sk_exists(flag)) {
90 SkDebugf("%s does not exist!\n", flag);
91 return false;
92 }
93
94 if (sk_isdir(flag)) {
95 // If the value passed in is a directory, add all the images
96 bool foundAnImage = false;
97 for (const char* ext : exts) {
98 SkOSFile::Iter it(flag, ext);
99 SkString file;
100 while (it.next(&file)) {
101 foundAnImage = true;
102 output->push_back() = SkOSPath::Join(flag, file.c_str());
103 }
104 }
105 if (!foundAnImage) {
106 SkDebugf("No supported images found in %s!\n", flag);
107 return false;
108 }
109 } else {
110 // Also add the value if it is a single image
111 output->push_back() = flag;
112 }
113 }
114 return true;
115 }
116