2013-03-04 16:41:06 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2013-03-21 19:43:15 +00:00
|
|
|
#ifndef SK_COMMAND_LINE_FLAGS_H
|
|
|
|
#define SK_COMMAND_LINE_FLAGS_H
|
2013-03-04 16:41:06 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkString.h"
|
|
|
|
#include "include/private/SkTArray.h"
|
|
|
|
#include "include/private/SkTDArray.h"
|
2013-03-04 16:41:06 +00:00
|
|
|
|
|
|
|
/**
|
2019-03-20 15:50:33 +00:00
|
|
|
* Including this file (and compiling CommandLineFlags.cpp) provides command line
|
2013-03-04 16:41:06 +00:00
|
|
|
* parsing. In order to use it, use the following macros in global
|
|
|
|
* namespace:
|
|
|
|
*
|
|
|
|
* DEFINE_bool(name, defaultValue, helpString);
|
|
|
|
* DEFINE_string(name, defaultValue, helpString);
|
2019-03-21 16:42:21 +00:00
|
|
|
* DEFINE_int(name, defaultValue, helpString);
|
2013-03-04 16:41:06 +00:00
|
|
|
* DEFINE_double(name, defaultValue, helpString);
|
|
|
|
*
|
2019-03-20 15:50:33 +00:00
|
|
|
* Then, in main, call CommandLineFlags::SetUsage() to describe usage and call
|
|
|
|
* CommandLineFlags::Parse() to parse the flags. Henceforth, each flag can
|
2013-03-04 16:41:06 +00:00
|
|
|
* be referenced using
|
|
|
|
*
|
|
|
|
* FLAGS_name
|
|
|
|
*
|
|
|
|
* For example, the line
|
|
|
|
*
|
|
|
|
* DEFINE_bool(boolean, false, "The variable boolean does such and such");
|
|
|
|
*
|
|
|
|
* will create the following variable:
|
|
|
|
*
|
|
|
|
* bool FLAGS_boolean;
|
|
|
|
*
|
|
|
|
* which will initially be set to false, and can be set to true by using the
|
|
|
|
* flag "--boolean" on the commandline. "--noboolean" will set FLAGS_boolean
|
2013-03-21 13:10:59 +00:00
|
|
|
* to false. FLAGS_boolean can also be set using "--boolean=true" or
|
|
|
|
* "--boolean true" (where "true" can be replaced by "false", "TRUE", "FALSE",
|
|
|
|
* "1" or "0").
|
|
|
|
*
|
|
|
|
* The helpString will be printed if the help flag (-h or -help) is used.
|
2013-03-04 16:41:06 +00:00
|
|
|
*
|
|
|
|
* Similarly, the line
|
|
|
|
*
|
2019-03-21 16:42:21 +00:00
|
|
|
* DEFINE_int(integer, .., ..);
|
2013-03-04 16:41:06 +00:00
|
|
|
*
|
|
|
|
* will create
|
|
|
|
*
|
2019-03-21 16:42:21 +00:00
|
|
|
* int FLAGS_integer;
|
2013-03-04 16:41:06 +00:00
|
|
|
*
|
|
|
|
* and
|
|
|
|
*
|
|
|
|
* DEFINE_double(real, .., ..);
|
|
|
|
*
|
|
|
|
* will create
|
|
|
|
*
|
|
|
|
* double FLAGS_real;
|
|
|
|
*
|
|
|
|
* These flags can be set by specifying, for example, "--integer 7" and
|
2018-09-28 20:00:38 +00:00
|
|
|
* "--real 3.14" on the command line. Unsigned integers are parsed from the
|
|
|
|
* command line using strtoul() so will detect the base (0 for octal, and
|
|
|
|
* 0x or 0X for hex, otherwise assumes decimal).
|
2013-03-04 16:41:06 +00:00
|
|
|
*
|
|
|
|
* Unlike the others, the line
|
|
|
|
*
|
|
|
|
* DEFINE_string(args, .., ..);
|
|
|
|
*
|
|
|
|
* creates an array:
|
|
|
|
*
|
2019-03-20 15:50:33 +00:00
|
|
|
* CommandLineFlags::StringArray FLAGS_args;
|
2013-03-04 16:41:06 +00:00
|
|
|
*
|
|
|
|
* If the default value is the empty string, FLAGS_args will default to a size
|
|
|
|
* of zero. Otherwise it will default to a size of 1 with the default string
|
|
|
|
* as its value. All strings that follow the flag on the command line (until
|
|
|
|
* a string that begins with '-') will be entries in the array.
|
|
|
|
*
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
* DEFINE_extended_string(args, .., .., extendedHelpString);
|
|
|
|
*
|
|
|
|
* creates a similar string array flag as DEFINE_string. The flag will have extended help text
|
|
|
|
* (extendedHelpString) that can the user can see with '--help <args>' flag.
|
|
|
|
*
|
2013-03-04 16:41:06 +00:00
|
|
|
* Any flag can be referenced from another file after using the following:
|
|
|
|
*
|
|
|
|
* DECLARE_x(name);
|
|
|
|
*
|
|
|
|
* (where 'x' is the type specified in the DEFINE).
|
|
|
|
*
|
|
|
|
* Inspired by gflags (https://code.google.com/p/gflags/). Is not quite as
|
|
|
|
* robust as gflags, but suits our purposes. For example, allows creating
|
2019-03-20 15:50:33 +00:00
|
|
|
* a flag -h or -help which will never be used, since CommandLineFlags handles it.
|
|
|
|
* CommandLineFlags will also allow creating --flag and --noflag. Uses the same input
|
2013-03-04 16:41:06 +00:00
|
|
|
* format as gflags and creates similarly named variables (i.e. FLAGS_name).
|
|
|
|
* Strings are handled differently (resulting variable will be an array of
|
|
|
|
* strings) so that a flag can be followed by multiple parameters.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class SkFlagInfo;
|
|
|
|
|
2019-03-20 15:50:33 +00:00
|
|
|
class CommandLineFlags {
|
2013-03-04 16:41:06 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Call to set the help message to be displayed. Should be called before
|
2013-03-21 19:43:15 +00:00
|
|
|
* Parse.
|
2013-03-04 16:41:06 +00:00
|
|
|
*/
|
|
|
|
static void SetUsage(const char* usage);
|
|
|
|
|
2016-02-12 22:47:09 +00:00
|
|
|
/**
|
|
|
|
* Call this to display the help message. Should be called after SetUsage.
|
|
|
|
*/
|
|
|
|
static void PrintUsage();
|
|
|
|
|
2013-03-04 16:41:06 +00:00
|
|
|
/**
|
|
|
|
* Call at the beginning of main to parse flags created by DEFINE_x, above.
|
|
|
|
* Must only be called once.
|
|
|
|
*/
|
2019-03-20 15:50:33 +00:00
|
|
|
static void Parse(int argc, const char* const* argv);
|
2013-03-04 16:41:06 +00:00
|
|
|
|
2013-04-23 15:38:09 +00:00
|
|
|
/**
|
|
|
|
* Custom class for holding the arguments for a string flag.
|
|
|
|
* Publicly only has accessors so the strings cannot be modified.
|
|
|
|
*/
|
|
|
|
class StringArray {
|
|
|
|
public:
|
2019-03-20 15:50:33 +00:00
|
|
|
StringArray() {}
|
|
|
|
explicit StringArray(const SkTArray<SkString>& strings) : fStrings(strings) {}
|
2013-04-23 15:38:09 +00:00
|
|
|
const char* operator[](int i) const {
|
|
|
|
SkASSERT(i >= 0 && i < fStrings.count());
|
|
|
|
return fStrings[i].c_str();
|
|
|
|
}
|
|
|
|
|
2019-03-20 15:50:33 +00:00
|
|
|
int count() const { return fStrings.count(); }
|
2013-04-23 15:38:09 +00:00
|
|
|
|
|
|
|
bool isEmpty() const { return this->count() == 0; }
|
|
|
|
|
2013-09-19 06:18:27 +00:00
|
|
|
/**
|
|
|
|
* Returns true iff string is equal to one of the strings in this array.
|
|
|
|
*/
|
|
|
|
bool contains(const char* string) const {
|
|
|
|
for (int i = 0; i < fStrings.count(); i++) {
|
|
|
|
if (fStrings[i].equals(string)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-07-11 19:14:51 +00:00
|
|
|
void set(int i, const char* str) {
|
2018-10-31 20:16:54 +00:00
|
|
|
if (i >= fStrings.count()) {
|
|
|
|
this->append(str);
|
|
|
|
return;
|
|
|
|
}
|
2014-07-11 19:14:51 +00:00
|
|
|
fStrings[i].set(str);
|
|
|
|
}
|
|
|
|
|
2017-12-30 17:27:00 +00:00
|
|
|
const SkString* begin() const { return fStrings.begin(); }
|
2019-03-20 15:50:33 +00:00
|
|
|
const SkString* end() const { return fStrings.end(); }
|
2017-12-30 17:27:00 +00:00
|
|
|
|
2013-04-23 15:38:09 +00:00
|
|
|
private:
|
|
|
|
void reset() { fStrings.reset(); }
|
|
|
|
|
2019-03-20 15:50:33 +00:00
|
|
|
void append(const char* string) { fStrings.push_back().set(string); }
|
2013-04-23 15:38:09 +00:00
|
|
|
|
2019-03-20 15:50:33 +00:00
|
|
|
void append(const char* string, size_t length) { fStrings.push_back().set(string, length); }
|
2013-04-24 19:25:26 +00:00
|
|
|
|
2013-04-23 15:38:09 +00:00
|
|
|
SkTArray<SkString> fStrings;
|
|
|
|
|
|
|
|
friend class SkFlagInfo;
|
|
|
|
};
|
|
|
|
|
2013-08-30 15:52:46 +00:00
|
|
|
/* Takes a list of the form [~][^]match[$]
|
|
|
|
~ causes a matching test to always be skipped
|
|
|
|
^ requires the start of the test to match
|
|
|
|
$ requires the end of the test to match
|
|
|
|
^ and $ requires an exact match
|
|
|
|
If a test does not match any list entry, it is skipped unless some list entry starts with ~
|
|
|
|
*/
|
|
|
|
static bool ShouldSkip(const SkTDArray<const char*>& strings, const char* name);
|
|
|
|
static bool ShouldSkip(const StringArray& strings, const char* name);
|
|
|
|
|
2013-03-04 16:41:06 +00:00
|
|
|
private:
|
|
|
|
static SkFlagInfo* gHead;
|
|
|
|
static SkString gUsage;
|
|
|
|
|
|
|
|
// For access to gHead.
|
|
|
|
friend class SkFlagInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define TO_STRING2(s) #s
|
|
|
|
#define TO_STRING(s) TO_STRING2(s)
|
|
|
|
|
2019-03-20 15:50:33 +00:00
|
|
|
#define DEFINE_bool(name, defaultValue, helpString) \
|
|
|
|
bool FLAGS_##name; \
|
|
|
|
SK_UNUSED static bool unused_##name = SkFlagInfo::CreateBoolFlag( \
|
|
|
|
TO_STRING(name), nullptr, &FLAGS_##name, defaultValue, helpString)
|
2013-03-20 14:20:18 +00:00
|
|
|
|
|
|
|
// bool 2 allows specifying a short name. No check is done to ensure that shortName
|
|
|
|
// is actually shorter than name.
|
2019-03-20 15:50:33 +00:00
|
|
|
#define DEFINE_bool2(name, shortName, defaultValue, helpString) \
|
|
|
|
bool FLAGS_##name; \
|
|
|
|
SK_UNUSED static bool unused_##name = SkFlagInfo::CreateBoolFlag( \
|
|
|
|
TO_STRING(name), TO_STRING(shortName), &FLAGS_##name, defaultValue, helpString)
|
2013-03-04 16:41:06 +00:00
|
|
|
|
|
|
|
#define DECLARE_bool(name) extern bool FLAGS_##name;
|
|
|
|
|
2019-03-20 15:50:33 +00:00
|
|
|
#define DEFINE_string(name, defaultValue, helpString) \
|
|
|
|
CommandLineFlags::StringArray FLAGS_##name; \
|
|
|
|
SK_UNUSED static bool unused_##name = SkFlagInfo::CreateStringFlag( \
|
|
|
|
TO_STRING(name), nullptr, &FLAGS_##name, defaultValue, helpString, nullptr)
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
#define DEFINE_extended_string(name, defaultValue, helpString, extendedHelpString) \
|
2019-03-20 15:50:33 +00:00
|
|
|
CommandLineFlags::StringArray FLAGS_##name; \
|
|
|
|
SK_UNUSED static bool unused_##name = SkFlagInfo::CreateStringFlag( \
|
|
|
|
TO_STRING(name), nullptr, &FLAGS_##name, defaultValue, helpString, extendedHelpString)
|
2013-03-04 16:41:06 +00:00
|
|
|
|
2013-04-09 21:25:46 +00:00
|
|
|
// string2 allows specifying a short name. There is an assert that shortName
|
|
|
|
// is only 1 character.
|
2019-03-20 15:50:33 +00:00
|
|
|
#define DEFINE_string2(name, shortName, defaultValue, helpString) \
|
|
|
|
CommandLineFlags::StringArray FLAGS_##name; \
|
|
|
|
SK_UNUSED static bool unused_##name = SkFlagInfo::CreateStringFlag(TO_STRING(name), \
|
|
|
|
TO_STRING(shortName), \
|
|
|
|
&FLAGS_##name, \
|
|
|
|
defaultValue, \
|
|
|
|
helpString, \
|
|
|
|
nullptr)
|
|
|
|
|
|
|
|
#define DECLARE_string(name) extern CommandLineFlags::StringArray FLAGS_##name;
|
|
|
|
|
2019-03-21 16:42:21 +00:00
|
|
|
#define DEFINE_int(name, defaultValue, helpString) \
|
|
|
|
int FLAGS_##name; \
|
|
|
|
SK_UNUSED static bool unused_##name = \
|
2019-03-20 15:50:33 +00:00
|
|
|
SkFlagInfo::CreateIntFlag(TO_STRING(name), &FLAGS_##name, defaultValue, helpString)
|
|
|
|
|
2019-03-21 16:42:21 +00:00
|
|
|
#define DEFINE_int_2(name, shortName, defaultValue, helpString) \
|
|
|
|
int FLAGS_##name; \
|
2019-03-20 15:50:33 +00:00
|
|
|
SK_UNUSED static bool unused_##name = SkFlagInfo::CreateIntFlag( \
|
|
|
|
TO_STRING(name), TO_STRING(shortName), &FLAGS_##name, defaultValue, helpString)
|
2015-09-18 16:04:43 +00:00
|
|
|
|
2019-03-21 16:42:21 +00:00
|
|
|
#define DECLARE_int(name) extern int FLAGS_##name;
|
2018-09-28 20:00:38 +00:00
|
|
|
|
2019-03-20 15:50:33 +00:00
|
|
|
#define DEFINE_double(name, defaultValue, helpString) \
|
|
|
|
double FLAGS_##name; \
|
|
|
|
SK_UNUSED static bool unused_##name = \
|
|
|
|
SkFlagInfo::CreateDoubleFlag(TO_STRING(name), &FLAGS_##name, defaultValue, helpString)
|
2013-03-04 16:41:06 +00:00
|
|
|
|
|
|
|
#define DECLARE_double(name) extern double FLAGS_##name;
|
|
|
|
|
|
|
|
class SkFlagInfo {
|
|
|
|
public:
|
|
|
|
enum FlagTypes {
|
|
|
|
kBool_FlagType,
|
|
|
|
kString_FlagType,
|
|
|
|
kInt_FlagType,
|
|
|
|
kDouble_FlagType,
|
|
|
|
};
|
|
|
|
|
2013-04-24 19:25:26 +00:00
|
|
|
/**
|
|
|
|
* Each Create<Type>Flag function creates an SkFlagInfo of the specified type. The SkFlagInfo
|
2019-03-20 15:50:33 +00:00
|
|
|
* object is appended to a list, which is deleted when CommandLineFlags::Parse is called.
|
2013-04-24 19:25:26 +00:00
|
|
|
* Therefore, each call should be made before the call to ::Parse. They are not intended
|
|
|
|
* to be called directly. Instead, use the macros described above.
|
|
|
|
* @param name Long version (at least 2 characters) of the name of the flag. This name can
|
|
|
|
* be referenced on the command line as "--name" to set the value of this flag.
|
|
|
|
* @param shortName Short version (one character) of the name of the flag. This name can
|
|
|
|
* be referenced on the command line as "-shortName" to set the value of this flag.
|
2019-03-20 15:50:33 +00:00
|
|
|
* @param p<Type> Pointer to a global variable which holds the value set by CommandLineFlags.
|
2013-04-24 19:25:26 +00:00
|
|
|
* @param defaultValue The default value of this flag. The variable pointed to by p<Type> will
|
|
|
|
* be set to this value initially. This is also displayed as part of the help output.
|
|
|
|
* @param helpString Explanation of what this flag changes in the program.
|
|
|
|
*/
|
2019-03-20 15:50:33 +00:00
|
|
|
static bool CreateBoolFlag(const char* name,
|
|
|
|
const char* shortName,
|
|
|
|
bool* pBool,
|
|
|
|
bool defaultValue,
|
|
|
|
const char* helpString) {
|
|
|
|
SkFlagInfo* info = new SkFlagInfo(name, shortName, kBool_FlagType, helpString, nullptr);
|
|
|
|
info->fBoolValue = pBool;
|
2013-03-04 16:41:06 +00:00
|
|
|
*info->fBoolValue = info->fDefaultBool = defaultValue;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-04-24 19:25:26 +00:00
|
|
|
/**
|
|
|
|
* See comments for CreateBoolFlag.
|
|
|
|
* @param pStrings Unlike the others, this is a pointer to an array of values.
|
|
|
|
* @param defaultValue Thise default will be parsed so that strings separated by spaces
|
|
|
|
* will be added to pStrings.
|
|
|
|
*/
|
2019-03-20 15:50:33 +00:00
|
|
|
static bool CreateStringFlag(const char* name,
|
|
|
|
const char* shortName,
|
|
|
|
CommandLineFlags::StringArray* pStrings,
|
|
|
|
const char* defaultValue,
|
|
|
|
const char* helpString,
|
|
|
|
const char* extendedHelpString);
|
2013-03-04 16:41:06 +00:00
|
|
|
|
2013-04-24 19:25:26 +00:00
|
|
|
/**
|
|
|
|
* See comments for CreateBoolFlag.
|
|
|
|
*/
|
2019-03-20 15:50:33 +00:00
|
|
|
static bool CreateIntFlag(const char* name,
|
2019-03-21 16:42:21 +00:00
|
|
|
int* pInt,
|
|
|
|
int defaultValue,
|
2019-03-20 15:50:33 +00:00
|
|
|
const char* helpString) {
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
SkFlagInfo* info = new SkFlagInfo(name, nullptr, kInt_FlagType, helpString, nullptr);
|
2019-03-20 15:50:33 +00:00
|
|
|
info->fIntValue = pInt;
|
2013-03-04 16:41:06 +00:00
|
|
|
*info->fIntValue = info->fDefaultInt = defaultValue;
|
|
|
|
return true;
|
2015-09-18 16:04:43 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 15:50:33 +00:00
|
|
|
static bool CreateIntFlag(const char* name,
|
|
|
|
const char* shortName,
|
2019-03-21 16:42:21 +00:00
|
|
|
int* pInt,
|
|
|
|
int defaultValue,
|
2019-03-20 15:50:33 +00:00
|
|
|
const char* helpString) {
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
SkFlagInfo* info = new SkFlagInfo(name, shortName, kInt_FlagType, helpString, nullptr);
|
2019-03-20 15:50:33 +00:00
|
|
|
info->fIntValue = pInt;
|
2015-09-18 16:04:43 +00:00
|
|
|
*info->fIntValue = info->fDefaultInt = defaultValue;
|
|
|
|
return true;
|
2013-03-04 16:41:06 +00:00
|
|
|
}
|
|
|
|
|
2013-04-24 19:25:26 +00:00
|
|
|
/**
|
|
|
|
* See comments for CreateBoolFlag.
|
|
|
|
*/
|
2019-03-20 15:50:33 +00:00
|
|
|
static bool CreateDoubleFlag(const char* name,
|
|
|
|
double* pDouble,
|
|
|
|
double defaultValue,
|
|
|
|
const char* helpString) {
|
|
|
|
SkFlagInfo* info = new SkFlagInfo(name, nullptr, kDouble_FlagType, helpString, nullptr);
|
|
|
|
info->fDoubleValue = pDouble;
|
2013-03-04 16:41:06 +00:00
|
|
|
*info->fDoubleValue = info->fDefaultDouble = defaultValue;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-03-21 13:10:59 +00:00
|
|
|
* Returns true if the string matches this flag.
|
|
|
|
* For a boolean flag, also sets the value, since a boolean flag can be set in a number of ways
|
|
|
|
* without looking at the following string:
|
|
|
|
* --name
|
|
|
|
* --noname
|
|
|
|
* --name=true
|
|
|
|
* --name=false
|
|
|
|
* --name=1
|
|
|
|
* --name=0
|
|
|
|
* --name=TRUE
|
|
|
|
* --name=FALSE
|
2013-03-04 16:41:06 +00:00
|
|
|
*/
|
2013-03-21 13:10:59 +00:00
|
|
|
bool match(const char* string);
|
2013-03-04 16:41:06 +00:00
|
|
|
|
|
|
|
FlagTypes getFlagType() const { return fFlagType; }
|
|
|
|
|
|
|
|
void resetStrings() {
|
|
|
|
if (kString_FlagType == fFlagType) {
|
|
|
|
fStrings->reset();
|
|
|
|
} else {
|
2013-08-22 15:37:26 +00:00
|
|
|
SkDEBUGFAIL("Can only call resetStrings on kString_FlagType");
|
2013-03-04 16:41:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void append(const char* string) {
|
|
|
|
if (kString_FlagType == fFlagType) {
|
2013-04-23 15:38:09 +00:00
|
|
|
fStrings->append(string);
|
2013-03-04 16:41:06 +00:00
|
|
|
} else {
|
2013-08-22 15:37:26 +00:00
|
|
|
SkDEBUGFAIL("Can only append to kString_FlagType");
|
2013-03-04 16:41:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-21 16:42:21 +00:00
|
|
|
void setInt(int value) {
|
2013-03-04 16:41:06 +00:00
|
|
|
if (kInt_FlagType == fFlagType) {
|
|
|
|
*fIntValue = value;
|
|
|
|
} else {
|
2013-08-22 15:37:26 +00:00
|
|
|
SkDEBUGFAIL("Can only call setInt on kInt_FlagType");
|
2013-03-04 16:41:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDouble(double value) {
|
|
|
|
if (kDouble_FlagType == fFlagType) {
|
|
|
|
*fDoubleValue = value;
|
|
|
|
} else {
|
2013-08-22 15:37:26 +00:00
|
|
|
SkDEBUGFAIL("Can only call setDouble on kDouble_FlagType");
|
2013-03-04 16:41:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-21 13:10:59 +00:00
|
|
|
void setBool(bool value) {
|
|
|
|
if (kBool_FlagType == fFlagType) {
|
|
|
|
*fBoolValue = value;
|
|
|
|
} else {
|
2013-08-22 15:37:26 +00:00
|
|
|
SkDEBUGFAIL("Can only call setBool on kBool_FlagType");
|
2013-03-21 13:10:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-04 16:41:06 +00:00
|
|
|
SkFlagInfo* next() { return fNext; }
|
|
|
|
|
|
|
|
const SkString& name() const { return fName; }
|
|
|
|
|
2013-03-20 19:50:41 +00:00
|
|
|
const SkString& shortName() const { return fShortName; }
|
|
|
|
|
2013-03-04 16:41:06 +00:00
|
|
|
const SkString& help() const { return fHelpString; }
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
const SkString& extendedHelp() const { return fExtendedHelpString; }
|
2013-03-04 16:41:06 +00:00
|
|
|
|
|
|
|
SkString defaultValue() const {
|
|
|
|
SkString result;
|
|
|
|
switch (fFlagType) {
|
|
|
|
case SkFlagInfo::kBool_FlagType:
|
|
|
|
result.printf("%s", fDefaultBool ? "true" : "false");
|
|
|
|
break;
|
2019-03-20 15:50:33 +00:00
|
|
|
case SkFlagInfo::kString_FlagType: return fDefaultString;
|
|
|
|
case SkFlagInfo::kInt_FlagType: result.printf("%i", fDefaultInt); break;
|
|
|
|
case SkFlagInfo::kDouble_FlagType: result.printf("%2.2f", fDefaultDouble); break;
|
|
|
|
default: SkDEBUGFAIL("Invalid flag type");
|
2013-03-04 16:41:06 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkString typeAsString() const {
|
|
|
|
switch (fFlagType) {
|
2019-03-20 15:50:33 +00:00
|
|
|
case SkFlagInfo::kBool_FlagType: return SkString("bool");
|
|
|
|
case SkFlagInfo::kString_FlagType: return SkString("string");
|
|
|
|
case SkFlagInfo::kInt_FlagType: return SkString("int");
|
|
|
|
case SkFlagInfo::kDouble_FlagType: return SkString("double");
|
|
|
|
default: SkDEBUGFAIL("Invalid flag type"); return SkString();
|
2013-03-04 16:41:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2019-03-20 15:50:33 +00:00
|
|
|
SkFlagInfo(const char* name,
|
|
|
|
const char* shortName,
|
|
|
|
FlagTypes type,
|
|
|
|
const char* helpString,
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
const char* extendedHelpString)
|
2019-03-20 15:50:33 +00:00
|
|
|
: fName(name)
|
|
|
|
, fShortName(shortName)
|
|
|
|
, fFlagType(type)
|
|
|
|
, fHelpString(helpString)
|
|
|
|
, fExtendedHelpString(extendedHelpString)
|
|
|
|
, fBoolValue(nullptr)
|
|
|
|
, fDefaultBool(false)
|
|
|
|
, fIntValue(nullptr)
|
|
|
|
, fDefaultInt(0)
|
|
|
|
, fDoubleValue(nullptr)
|
|
|
|
, fDefaultDouble(0)
|
|
|
|
, fStrings(nullptr) {
|
|
|
|
fNext = CommandLineFlags::gHead;
|
|
|
|
CommandLineFlags::gHead = this;
|
2014-09-05 20:34:00 +00:00
|
|
|
SkASSERT(name && strlen(name) > 1);
|
2015-08-27 14:41:13 +00:00
|
|
|
SkASSERT(nullptr == shortName || 1 == strlen(shortName));
|
2013-03-04 16:41:06 +00:00
|
|
|
}
|
2013-04-24 19:25:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a StringArray to hold the values stored in defaultStrings.
|
|
|
|
* @param array The StringArray to modify.
|
|
|
|
* @param defaultStrings Space separated list of strings that should be inserted into array
|
|
|
|
* individually.
|
|
|
|
*/
|
2019-03-20 15:50:33 +00:00
|
|
|
static void SetDefaultStrings(CommandLineFlags::StringArray* array, const char* defaultStrings);
|
2013-04-24 19:25:26 +00:00
|
|
|
|
2013-03-04 16:41:06 +00:00
|
|
|
// Name of the flag, without initial dashes
|
2019-03-20 15:50:33 +00:00
|
|
|
SkString fName;
|
|
|
|
SkString fShortName;
|
|
|
|
FlagTypes fFlagType;
|
|
|
|
SkString fHelpString;
|
|
|
|
SkString fExtendedHelpString;
|
|
|
|
bool* fBoolValue;
|
|
|
|
bool fDefaultBool;
|
2019-03-21 16:42:21 +00:00
|
|
|
int* fIntValue;
|
|
|
|
int fDefaultInt;
|
2019-03-20 15:50:33 +00:00
|
|
|
double* fDoubleValue;
|
|
|
|
double fDefaultDouble;
|
|
|
|
CommandLineFlags::StringArray* fStrings;
|
2013-03-04 16:41:06 +00:00
|
|
|
// Both for the help string and in case fStrings is empty.
|
2019-03-20 15:50:33 +00:00
|
|
|
SkString fDefaultString;
|
2013-03-04 16:41:06 +00:00
|
|
|
|
|
|
|
// In order to keep a linked list.
|
2019-03-20 15:50:33 +00:00
|
|
|
SkFlagInfo* fNext;
|
2013-03-04 16:41:06 +00:00
|
|
|
};
|
2019-03-20 15:50:33 +00:00
|
|
|
#endif // SK_COMMAND_LINE_FLAGS_H
|