Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Unified Diff: tools/flags/SkCommandLineFlags.h

Issue 1490113005: Add config options to run different GPU APIs to dm and nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@commandbuffer-as-api-03-context-factory-glcontext-type
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/TestConfigParsing.cpp ('k') | tools/flags/SkCommandLineFlags.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/flags/SkCommandLineFlags.h
diff --git a/tools/flags/SkCommandLineFlags.h b/tools/flags/SkCommandLineFlags.h
index 5909413523143f87fd9d25eab0d565a37d82c082..909718d3e79fa404c273541d4db89455176821e9 100644
--- a/tools/flags/SkCommandLineFlags.h
+++ b/tools/flags/SkCommandLineFlags.h
@@ -76,6 +76,11 @@
* 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.
*
+ * 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.
+ *
* Any flag can be referenced from another file after using the following:
*
* DECLARE_x(name);
@@ -114,6 +119,10 @@ public:
*/
class StringArray {
public:
+ StringArray() { }
+ explicit StringArray(const SkTArray<SkString>& strings)
+ : fStrings(strings) {
+ }
const char* operator[](int i) const {
SkASSERT(i >= 0 && i < fStrings.count());
return fStrings[i].c_str();
@@ -204,7 +213,15 @@ SK_UNUSED static bool unused_##name = SkFlagInfo::CreateStringFlag(TO_STRING(nam
nullptr, \
&FLAGS_##name, \
defaultValue, \
- helpString)
+ helpString, nullptr)
+#define DEFINE_extended_string(name, defaultValue, helpString, extendedHelpString) \
+SkCommandLineFlags::StringArray FLAGS_##name; \
+SK_UNUSED static bool unused_##name = SkFlagInfo::CreateStringFlag(TO_STRING(name), \
+ nullptr, \
+ &FLAGS_##name, \
+ defaultValue, \
+ helpString, \
+ extendedHelpString)
// string2 allows specifying a short name. There is an assert that shortName
// is only 1 character.
@@ -214,7 +231,7 @@ SK_UNUSED static bool unused_##name = SkFlagInfo::CreateStringFlag(TO_STRING(nam
TO_STRING(shortName), \
&FLAGS_##name, \
defaultValue, \
- helpString)
+ helpString, nullptr)
#define DECLARE_string(name) extern SkCommandLineFlags::StringArray FLAGS_##name;
@@ -273,7 +290,7 @@ public:
*/
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);
+ SkFlagInfo* info = new SkFlagInfo(name, shortName, kBool_FlagType, helpString, nullptr);
info->fBoolValue = pBool;
*info->fBoolValue = info->fDefaultBool = defaultValue;
return true;
@@ -287,14 +304,15 @@ public:
*/
static bool CreateStringFlag(const char* name, const char* shortName,
SkCommandLineFlags::StringArray* pStrings,
- const char* defaultValue, const char* helpString);
+ const char* defaultValue, const char* helpString,
+ const char* extendedHelpString);
/**
* See comments for CreateBoolFlag.
*/
static bool CreateIntFlag(const char* name, int32_t* pInt,
int32_t defaultValue, const char* helpString) {
- SkFlagInfo* info = new SkFlagInfo(name, nullptr, kInt_FlagType, helpString);
+ SkFlagInfo* info = new SkFlagInfo(name, nullptr, kInt_FlagType, helpString, nullptr);
info->fIntValue = pInt;
*info->fIntValue = info->fDefaultInt = defaultValue;
return true;
@@ -302,7 +320,7 @@ public:
static bool CreateIntFlag(const char* name, const char* shortName, int32_t* pInt,
int32_t defaultValue, const char* helpString) {
- SkFlagInfo* info = new SkFlagInfo(name, shortName, kInt_FlagType, helpString);
+ SkFlagInfo* info = new SkFlagInfo(name, shortName, kInt_FlagType, helpString, nullptr);
info->fIntValue = pInt;
*info->fIntValue = info->fDefaultInt = defaultValue;
return true;
@@ -313,7 +331,7 @@ public:
*/
static bool CreateDoubleFlag(const char* name, double* pDouble,
double defaultValue, const char* helpString) {
- SkFlagInfo* info = new SkFlagInfo(name, nullptr, kDouble_FlagType, helpString);
+ SkFlagInfo* info = new SkFlagInfo(name, nullptr, kDouble_FlagType, helpString, nullptr);
info->fDoubleValue = pDouble;
*info->fDoubleValue = info->fDefaultDouble = defaultValue;
return true;
@@ -383,6 +401,7 @@ public:
const SkString& shortName() const { return fShortName; }
const SkString& help() const { return fHelpString; }
+ const SkString& extendedHelp() const { return fExtendedHelpString; }
SkString defaultValue() const {
SkString result;
@@ -421,11 +440,13 @@ public:
}
private:
- SkFlagInfo(const char* name, const char* shortName, FlagTypes type, const char* helpString)
+ SkFlagInfo(const char* name, const char* shortName, FlagTypes type, const char* helpString,
+ const char* extendedHelpString)
: fName(name)
, fShortName(shortName)
, fFlagType(type)
, fHelpString(helpString)
+ , fExtendedHelpString(extendedHelpString)
, fBoolValue(nullptr)
, fDefaultBool(false)
, fIntValue(nullptr)
@@ -453,6 +474,7 @@ private:
SkString fShortName;
FlagTypes fFlagType;
SkString fHelpString;
+ SkString fExtendedHelpString;
bool* fBoolValue;
bool fDefaultBool;
int32_t* fIntValue;
« no previous file with comments | « tests/TestConfigParsing.cpp ('k') | tools/flags/SkCommandLineFlags.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698