blob: facbd3139bcf4856348da873383de42fc76b1e2b [file] [log] [blame]
caryclark17f0b6d2014-07-22 10:15:34 -07001/*
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"
scroggo86737142016-02-03 12:19:11 -08009#include "SkOSFile.h"
Ben Wagnerbf111d72016-11-07 18:05:29 -050010#include "SkOSPath.h"
caryclark17f0b6d2014-07-22 10:15:34 -070011
caryclark17f0b6d2014-07-22 10:15:34 -070012DEFINE_bool(cpu, true, "master switch for running CPU-bound work.");
13
14DEFINE_bool(dryRun, false,
15 "just print the tests that would be run, without actually running them.");
16
17DEFINE_bool(gpu, true, "master switch for running GPU-bound work.");
18
scroggo86737142016-02-03 12:19:11 -080019DEFINE_string(images, "", "List of images and/or directories to decode. A directory with no images"
20 " is treated as a fatal error.");
msarett95f192d2015-02-13 09:05:41 -080021
msarett69deca82016-04-29 09:38:40 -070022DEFINE_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
msarettdb197a52016-06-21 09:44:29 -070025DEFINE_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
halcanary96fcdcc2015-08-27 07:41:13 -070030DEFINE_string2(match, m, nullptr,
caryclark17f0b6d2014-07-22 10:15:34 -070031 "[~][^]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
40DEFINE_bool2(quiet, q, false, "if true, don't print status updates.");
41
bsalomon6e2aad42016-04-01 11:54:31 -070042DEFINE_bool(preAbandonGpuContext, false, "Test abandoning the GrContext before running the test.");
joshualitt5f5a8d72015-02-25 14:09:45 -080043
bsalomon6e2aad42016-04-01 11:54:31 -070044DEFINE_bool(abandonGpuContext, false, "Test abandoning the GrContext after running each test.");
45
46DEFINE_bool(releaseAndAbandonGpuContext, false,
47 "Test releasing all gpu resources and abandoning the GrContext after running each "
48 "test");
caryclark17f0b6d2014-07-22 10:15:34 -070049
mtklein34580f72014-08-07 12:46:29 -070050DEFINE_string(skps, "skps", "Directory to read skps from.");
mtklein92007582014-08-01 07:46:52 -070051
fmalita95573e42016-09-14 09:05:43 -070052DEFINE_string(svgs, "", "Directory to read SVGs from, or a single SVG file.");
53
Mike Klein08c89632016-11-08 14:16:01 -050054DEFINE_int32_2(threads, j, -1, "Run threadsafe tests on a threadpool with this many extra threads, "
55 "defaulting to one extra thread per core.");
caryclark17f0b6d2014-07-22 10:15:34 -070056
57DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
58
59DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose.");
mtkleinb5110422014-08-07 15:20:02 -070060
61DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs.");
mtkleinea65bfa2014-09-09 07:59:46 -070062
63DEFINE_string(key, "",
64 "Space-separated key/value pairs to add to JSON identifying this builder.");
65DEFINE_string(properties, "",
66 "Space-separated key/value pairs to add to JSON identifying this run.");
benjaminwagner8d61f0d2016-01-25 13:02:40 -080067DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehensible when threading");
scroggo86737142016-02-03 12:19:11 -080068
Yuqian Liba62b4a2016-12-14 13:46:53 -050069DEFINE_bool(analyticAA, true, "If false, disable analytic anti-aliasing");
liyuqian38911a72016-10-04 11:23:22 -070070
Yuqian Li550148b2017-01-13 10:13:13 -050071DEFINE_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
Yuqian Li49fd5d52017-08-03 13:03:03 -040075#if defined(SK_SUPPORT_LEGACY_DELTA_AA) || (defined(_MSC_VER) && !defined(__clang__))
Yuqian Li93fe0cc2017-07-29 13:41:52 -040076constexpr bool kDefaultDeltaAA = false;
77#else
78constexpr bool kDefaultDeltaAA = true;
79#endif
80DEFINE_bool(deltaAA, kDefaultDeltaAA,
Yuqian Lidf60e362017-07-25 11:26:31 -040081 "If true, use delta anti-aliasing in suitable cases (it overrides forceAnalyticAA.");
82
83DEFINE_bool(forceDeltaAA, false, "Force delta anti-aliasing for all paths.");
84
msarett69deca82016-04-29 09:38:40 -070085bool CollectImages(SkCommandLineFlags::StringArray images, SkTArray<SkString>* output) {
scroggo86737142016-02-03 12:19:11 -080086 SkASSERT(output);
87
88 static const char* const exts[] = {
Leon Scroggins427da6f2016-12-16 13:51:59 +000089 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico",
90 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO",
scroggo86737142016-02-03 12:19:11 -080091#ifdef SK_CODEC_DECODES_RAW
92 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
93 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
94#endif
95 };
96
msarett69deca82016-04-29 09:38:40 -070097 for (int i = 0; i < images.count(); ++i) {
98 const char* flag = images[i];
scroggo86737142016-02-03 12:19:11 -080099 if (!sk_exists(flag)) {
100 SkDebugf("%s does not exist!\n", flag);
101 return false;
102 }
103
104 if (sk_isdir(flag)) {
105 // If the value passed in is a directory, add all the images
106 bool foundAnImage = false;
107 for (const char* ext : exts) {
108 SkOSFile::Iter it(flag, ext);
109 SkString file;
110 while (it.next(&file)) {
111 foundAnImage = true;
112 output->push_back() = SkOSPath::Join(flag, file.c_str());
113 }
114 }
115 if (!foundAnImage) {
116 SkDebugf("No supported images found in %s!\n", flag);
117 return false;
118 }
119 } else {
120 // Also add the value if it is a single image
121 output->push_back() = flag;
122 }
123 }
124 return true;
125}