• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
75 DEFINE_bool(trace, false, "Show trace events using SkDebugf.");
76 
CollectImages(SkCommandLineFlags::StringArray images,SkTArray<SkString> * output)77 bool CollectImages(SkCommandLineFlags::StringArray images, SkTArray<SkString>* output) {
78     SkASSERT(output);
79 
80     static const char* const exts[] = {
81         "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico",
82         "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO",
83 #ifdef SK_CODEC_DECODES_RAW
84         "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
85         "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
86 #endif
87     };
88 
89     for (int i = 0; i < images.count(); ++i) {
90         const char* flag = images[i];
91         if (!sk_exists(flag)) {
92             SkDebugf("%s does not exist!\n", flag);
93             return false;
94         }
95 
96         if (sk_isdir(flag)) {
97             // If the value passed in is a directory, add all the images
98             bool foundAnImage = false;
99             for (const char* ext : exts) {
100                 SkOSFile::Iter it(flag, ext);
101                 SkString file;
102                 while (it.next(&file)) {
103                     foundAnImage = true;
104                     output->push_back() = SkOSPath::Join(flag, file.c_str());
105                 }
106             }
107             if (!foundAnImage) {
108                 SkDebugf("No supported images found in %s!\n", flag);
109                 return false;
110             }
111         } else {
112             // Also add the value if it is a single image
113             output->push_back() = flag;
114         }
115     }
116     return true;
117 }
118