From 1f0121af495e5a70ecff2521729b7749c81a20b2 Mon Sep 17 00:00:00 2001 From: "halcanary@google.com" Date: Wed, 6 Nov 2013 15:07:44 +0000 Subject: 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 --- src/utils/SkRTConf.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src') 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 void SkRTConfRegistry::set(const char *name, T value) { - +template void SkRTConfRegistry::set(const char *name, + T value, + bool warnIfNotFound) { SkTDArray *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 *concrete = static_cast *>(*confBase); @@ -281,12 +285,12 @@ template 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; -- cgit v1.2.3