aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-06 15:07:44 +0000
committerGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-06 15:07:44 +0000
commit1f0121af495e5a70ecff2521729b7749c81a20b2 (patch)
treea48e5ba75ef0fb82510ee51823f9ac7879a47c20 /include
parent137577861db78d6a4a63e8adbf54467557d2b26a (diff)
New SkRTConf macro SK_CONF_TRY_SET: no complaint on missing configuration
SK_CONF_TRY_SET() is like SK_CONF_SET(), but doesn't complain if confname can't be found. This is useful if the SK_CONF_DECLARE is inside a source file whose linkage is dependent on the system. Internally to the SkRTConf system, SkRTConfRegistry::set() was given an additional parameter controling wanrings. A new RuntimeConfig unit test was introduced. It should run silently. In the future, it should be expanded to cover all of the SkRTConf functionality. (For example, the images.jpeg.suppressDecoderWarnings variable is defined and used only in SkImageDecoder_libjpeg.cpp, but on MacOS, we use Core Graphics via SkImageDecoder_CG.cpp - SkImageDecoder_libjpeg is never linked in. The same is true of the Windows Imaging Component on Windows.) BUG= R=reed@google.com Review URL: https://codereview.chromium.org/54503007 git-svn-id: http://skia.googlecode.com/svn/trunk@12155 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r--include/utils/SkRTConf.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/include/utils/SkRTConf.h b/include/utils/SkRTConf.h
index d09410ebb1..4d7cda23d5 100644
--- a/include/utils/SkRTConf.h
+++ b/include/utils/SkRTConf.h
@@ -52,10 +52,17 @@ protected:
#ifdef SK_DEVELOPER
#define SK_CONF_DECLARE(confType, varName, confName, defaultValue, description) static SkRTConf<confType> varName(confName, defaultValue, description)
-#define SK_CONF_SET(confname, value) skRTConfRegistry().set(confname, value)
+#define SK_CONF_SET(confname, value) \
+ skRTConfRegistry().set(confname, value, true)
+/* SK_CONF_TRY_SET() is like SK_CONF_SET(), but doesn't complain if
+ confname can't be found. This is useful if the SK_CONF_DECLARE is
+ inside a source file whose linkage is dependent on the system. */
+#define SK_CONF_TRY_SET(confname, value) \
+ skRTConfRegistry().set(confname, value, false)
#else
#define SK_CONF_DECLARE(confType, varName, confName, defaultValue, description) static confType varName = defaultValue
#define SK_CONF_SET(confname, value) (void) confname, (void) value
+#define SK_CONF_TRY_SET(confname, value) (void) confname, (void) value
#endif
/** \class SkRTConfRegistry
@@ -72,7 +79,9 @@ public:
const char *configFileLocation() const;
void possiblyDumpFile() const;
void validate() const;
- template <typename T> void set(const char *confname, T value);
+ template <typename T> void set(const char *confname,
+ T value,
+ bool warnIfNotFound = true);
#ifdef SK_SUPPORT_UNITTEST
static void UnitTest();
#endif