blob: cd1e47fb77f042c80c9e4af36b99bbfed6d8574f [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
Chris Dalton040238b2017-12-18 14:22:34 -07008#include "GrContextOptions.h"
caryclark17f0b6d2014-07-22 10:15:34 -07009#include "SkCommonFlags.h"
Brian Osmanf9810662017-08-30 10:02:10 -040010#include "SkExecutor.h"
11#include "SkOnce.h"
scroggo86737142016-02-03 12:19:11 -080012#include "SkOSFile.h"
Ben Wagnerbf111d72016-11-07 18:05:29 -050013#include "SkOSPath.h"
caryclark17f0b6d2014-07-22 10:15:34 -070014
caryclark17f0b6d2014-07-22 10:15:34 -070015DEFINE_bool(cpu, true, "master switch for running CPU-bound work.");
16
17DEFINE_bool(dryRun, false,
18 "just print the tests that would be run, without actually running them.");
19
20DEFINE_bool(gpu, true, "master switch for running GPU-bound work.");
21
scroggo86737142016-02-03 12:19:11 -080022DEFINE_string(images, "", "List of images and/or directories to decode. A directory with no images"
23 " is treated as a fatal error.");
msarett95f192d2015-02-13 09:05:41 -080024
msarett69deca82016-04-29 09:38:40 -070025DEFINE_string(colorImages, "", "List of images and/or directories to decode with color correction. "
26 "A directory with no images is treated as a fatal error.");
27
msarettdb197a52016-06-21 09:44:29 -070028DEFINE_bool(simpleCodec, false, "Runs of a subset of the codec tests. "
29 "For DM, this means no scaling or subsetting, always using the "
30 "canvas color type. "
31 "For nanobench, this means always N32, Premul or Opaque.");
32
halcanary96fcdcc2015-08-27 07:41:13 -070033DEFINE_string2(match, m, nullptr,
caryclark17f0b6d2014-07-22 10:15:34 -070034 "[~][^]substring[$] [...] of GM name to run.\n"
35 "Multiple matches may be separated by spaces.\n"
36 "~ causes a matching GM to always be skipped\n"
37 "^ requires the start of the GM to match\n"
38 "$ requires the end of the GM to match\n"
39 "^ and $ requires an exact match\n"
40 "If a GM does not match any list entry,\n"
41 "it is skipped unless some list entry starts with ~");
42
43DEFINE_bool2(quiet, q, false, "if true, don't print status updates.");
44
bsalomon6e2aad42016-04-01 11:54:31 -070045DEFINE_bool(preAbandonGpuContext, false, "Test abandoning the GrContext before running the test.");
joshualitt5f5a8d72015-02-25 14:09:45 -080046
bsalomon6e2aad42016-04-01 11:54:31 -070047DEFINE_bool(abandonGpuContext, false, "Test abandoning the GrContext after running each test.");
48
49DEFINE_bool(releaseAndAbandonGpuContext, false,
50 "Test releasing all gpu resources and abandoning the GrContext after running each "
51 "test");
caryclark17f0b6d2014-07-22 10:15:34 -070052
mtklein34580f72014-08-07 12:46:29 -070053DEFINE_string(skps, "skps", "Directory to read skps from.");
mtklein92007582014-08-01 07:46:52 -070054
fmalita95573e42016-09-14 09:05:43 -070055DEFINE_string(svgs, "", "Directory to read SVGs from, or a single SVG file.");
56
Mike Klein08c89632016-11-08 14:16:01 -050057DEFINE_int32_2(threads, j, -1, "Run threadsafe tests on a threadpool with this many extra threads, "
58 "defaulting to one extra thread per core.");
caryclark17f0b6d2014-07-22 10:15:34 -070059
60DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
61
62DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose.");
mtkleinb5110422014-08-07 15:20:02 -070063
64DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs.");
mtkleinea65bfa2014-09-09 07:59:46 -070065
66DEFINE_string(key, "",
67 "Space-separated key/value pairs to add to JSON identifying this builder.");
68DEFINE_string(properties, "",
69 "Space-separated key/value pairs to add to JSON identifying this run.");
benjaminwagner8d61f0d2016-01-25 13:02:40 -080070DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehensible when threading");
scroggo86737142016-02-03 12:19:11 -080071
Yuqian Liba62b4a2016-12-14 13:46:53 -050072DEFINE_bool(analyticAA, true, "If false, disable analytic anti-aliasing");
liyuqian38911a72016-10-04 11:23:22 -070073
Yuqian Li550148b2017-01-13 10:13:13 -050074DEFINE_bool(forceAnalyticAA, false, "Force analytic anti-aliasing even if the path is complicated: "
75 "whether it's concave or convex, we consider a path complicated"
76 "if its number of points is comparable to its resolution.");
77
Yuqian Li49fd5d52017-08-03 13:03:03 -040078#if defined(SK_SUPPORT_LEGACY_DELTA_AA) || (defined(_MSC_VER) && !defined(__clang__))
Yuqian Li93fe0cc2017-07-29 13:41:52 -040079constexpr bool kDefaultDeltaAA = false;
80#else
81constexpr bool kDefaultDeltaAA = true;
82#endif
83DEFINE_bool(deltaAA, kDefaultDeltaAA,
Yuqian Lidf60e362017-07-25 11:26:31 -040084 "If true, use delta anti-aliasing in suitable cases (it overrides forceAnalyticAA.");
85
86DEFINE_bool(forceDeltaAA, false, "Force delta anti-aliasing for all paths.");
87
msarett69deca82016-04-29 09:38:40 -070088bool CollectImages(SkCommandLineFlags::StringArray images, SkTArray<SkString>* output) {
scroggo86737142016-02-03 12:19:11 -080089 SkASSERT(output);
90
91 static const char* const exts[] = {
Leon Scroggins427da6f2016-12-16 13:51:59 +000092 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico",
93 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO",
Chong Zhangc1868cd2017-09-06 17:40:16 -070094#ifdef SK_HAS_HEIF_LIBRARY
95 "heic",
96 "HEIC",
97#endif
scroggo86737142016-02-03 12:19:11 -080098#ifdef SK_CODEC_DECODES_RAW
99 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
100 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
101#endif
102 };
103
msarett69deca82016-04-29 09:38:40 -0700104 for (int i = 0; i < images.count(); ++i) {
105 const char* flag = images[i];
scroggo86737142016-02-03 12:19:11 -0800106 if (!sk_exists(flag)) {
107 SkDebugf("%s does not exist!\n", flag);
108 return false;
109 }
110
111 if (sk_isdir(flag)) {
112 // If the value passed in is a directory, add all the images
113 bool foundAnImage = false;
114 for (const char* ext : exts) {
115 SkOSFile::Iter it(flag, ext);
116 SkString file;
117 while (it.next(&file)) {
118 foundAnImage = true;
119 output->push_back() = SkOSPath::Join(flag, file.c_str());
120 }
121 }
122 if (!foundAnImage) {
123 SkDebugf("No supported images found in %s!\n", flag);
124 return false;
125 }
126 } else {
127 // Also add the value if it is a single image
128 output->push_back() = flag;
129 }
130 }
131 return true;
132}
Brian Osmanf9810662017-08-30 10:02:10 -0400133
Chris Dalton040238b2017-12-18 14:22:34 -0700134#if SK_SUPPORT_GPU
135
136#include "SkCommonFlagsGpu.h"
137
138DEFINE_int32(gpuThreads, 2, "Create this many extra threads to assist with GPU work, "
139 "including software path rendering. Defaults to two.");
140
141DEFINE_bool(cachePathMasks, true, "Allows path mask textures to be cached in GPU configs.");
142
143DEFINE_bool(noGS, false, "Disables support for geometry shaders.");
144
145DEFINE_string(pr, "default",
146 "Set of enabled gpu path renderers. Defined as a list of: "
147 "[[~]all [~]default [~]dashline [~]nvpr [~]msaa [~]aaconvex "
148 "[~]aalinearizing [~]small [~]tess]");
149
Chris Daltonc70817a2017-12-20 09:10:26 -0700150void SetCtxOptionsFromCommonFlags(GrContextOptions* ctxOptions) {
Brian Osmanf9810662017-08-30 10:02:10 -0400151 static std::unique_ptr<SkExecutor> gGpuExecutor = (0 != FLAGS_gpuThreads)
Mike Klein022cfa22017-09-01 11:53:16 -0400152 ? SkExecutor::MakeFIFOThreadPool(FLAGS_gpuThreads) : nullptr;
Chris Daltonc70817a2017-12-20 09:10:26 -0700153 ctxOptions->fExecutor = gGpuExecutor.get();
Chris Dalton040238b2017-12-18 14:22:34 -0700154 ctxOptions->fAllowPathMaskCaching = FLAGS_cachePathMasks;
155 ctxOptions->fSuppressGeometryShaders = FLAGS_noGS;
Chris Daltonc70817a2017-12-20 09:10:26 -0700156 ctxOptions->fGpuPathRenderers = CollectGpuPathRenderersFromFlags();
Chris Dalton040238b2017-12-18 14:22:34 -0700157}
158
159#endif