diff options
author | halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-11-06 15:07:44 +0000 |
---|---|---|
committer | halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-11-06 15:07:44 +0000 |
commit | 1f0121af495e5a70ecff2521729b7749c81a20b2 (patch) | |
tree | a48e5ba75ef0fb82510ee51823f9ac7879a47c20 /src | |
parent | 137577861db78d6a4a63e8adbf54467557d2b26a (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 'src')
-rw-r--r-- | src/utils/SkRTConf.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/utils/SkRTConf.cpp b/src/utils/SkRTConf.cpp index b19ebdd10a..895cfa5e31 100644 --- a/src/utils/SkRTConf.cpp +++ b/src/utils/SkRTConf.cpp @@ -263,14 +263,18 @@ template bool SkRTConfRegistry::parse(const char *name, float *value); template bool SkRTConfRegistry::parse(const char *name, double *value); template bool SkRTConfRegistry::parse(const char *name, const char **value); -template <typename T> void SkRTConfRegistry::set(const char *name, T value) { - +template <typename T> void SkRTConfRegistry::set(const char *name, + T value, + bool warnIfNotFound) { SkTDArray<SkRTConfBase *> *confArray; if (!fConfs.find(name, &confArray)) { - SkDebugf("WARNING: Attempting to set configuration value \"%s\", but I've never heard of that.\n", name); + if (warnIfNotFound) { + SkDebugf("WARNING: Attempting to set configuration value \"%s\"," + " but I've never heard of that.\n", name); + } return; } - + SkASSERT(confArray != NULL); for (SkRTConfBase **confBase = confArray->begin(); confBase != confArray->end(); confBase++) { // static_cast here is okay because there's only one kind of child class. SkRTConf<T> *concrete = static_cast<SkRTConf<T> *>(*confBase); @@ -281,12 +285,12 @@ template <typename T> void SkRTConfRegistry::set(const char *name, T value) { } } -template void SkRTConfRegistry::set(const char *name, bool value); -template void SkRTConfRegistry::set(const char *name, int value); -template void SkRTConfRegistry::set(const char *name, unsigned int value); -template void SkRTConfRegistry::set(const char *name, float value); -template void SkRTConfRegistry::set(const char *name, double value); -template void SkRTConfRegistry::set(const char *name, char * value); +template void SkRTConfRegistry::set(const char *name, bool value, bool); +template void SkRTConfRegistry::set(const char *name, int value, bool); +template void SkRTConfRegistry::set(const char *name, unsigned int value, bool); +template void SkRTConfRegistry::set(const char *name, float value, bool); +template void SkRTConfRegistry::set(const char *name, double value, bool); +template void SkRTConfRegistry::set(const char *name, char * value, bool); SkRTConfRegistry &skRTConfRegistry() { static SkRTConfRegistry r; |